Skip to content

Commit

Permalink
GUI : add about dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslepoix committed Nov 3, 2024
1 parent 2ba7675 commit a2eb3c3
Show file tree
Hide file tree
Showing 12 changed files with 276 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ project( qucsrflayout
)
message( STATUS "Version: ${PROJECT_VERSION}" )

set( QRFL_BUGREPORT "https://github.com/thomaslepoix/Qucs-RFlayout/issues" )
set( QRFL_FUNDING "https://liberapay.com/thomaslepoix" )
file( READ "${CMAKE_SOURCE_DIR}/CHANGELOG" QRFL_CHANGELOG )

set( CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake"
Expand Down
1 change: 0 additions & 1 deletion doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ if( WIN32 )
else()
set( QRFL_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" )
endif( WIN32 )
set( QRFL_BUGREPORT "https://github.com/thomaslepoix/Qucs-RFlayout/issues" )
set( QRFL_OEMS_TUTORIAL "https://github.com/thomaslepoix/Qucs-RFlayout/blob/master/doc/tutorials/openems.md" )

configure_file(
Expand Down
3 changes: 3 additions & 0 deletions doc/qucsrflayout.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ The GUI (\fB-G\fR) may be completely disabled at build time, in which case \fB--
.SH REPORTING BUGS
@QRFL_BUGREPORT@

.SH FUNDING
@QRFL_FUNDING@

.SH COPYRIGHT
Copyright \(co 2018 Thomas Lepoix <[email protected]>
.PP
Expand Down
11 changes: 11 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/changelog.hpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/generated/changelog.hpp"
@ONLY
)

add_executable( ${PROJECT_NAME} WIN32 )

target_sources( ${PROJECT_NAME}
Expand Down Expand Up @@ -27,6 +33,7 @@ target_sources( ${PROJECT_NAME}
"${CMAKE_CURRENT_SOURCE_DIR}/layoutstrings.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/layoutwriter.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/converter.cpp"
"$<$<NOT:$<BOOL:${QRFL_MINIMAL}>>:${CMAKE_CURRENT_SOURCE_DIR}/aboutdialog.cpp>"
"$<$<NOT:$<BOOL:${QRFL_MINIMAL}>>:${CMAKE_CURRENT_SOURCE_DIR}/preview.cpp>"
"$<$<NOT:$<BOOL:${QRFL_MINIMAL}>>:${CMAKE_CURRENT_SOURCE_DIR}/mainwindow.cpp>"
"$<$<NOT:$<BOOL:${QRFL_MINIMAL}>>:${CMAKE_CURRENT_SOURCE_DIR}/resources.qrc>"
Expand All @@ -38,6 +45,9 @@ target_compile_definitions( ${PROJECT_NAME}
PRIVATE
${QT_DEPRECATED_WARNINGS}
QRFL_VERSION="${PROJECT_VERSION}"
QRFL_HOMEPAGE="${PROJECT_HOMEPAGE_URL}"
QRFL_FUNDING="${QRFL_FUNDING}"
QRFL_BUGREPORT="${QRFL_BUGREPORT}"
$<$<BOOL:${QRFL_MINIMAL}>:QRFL_MINIMAL>
)

Expand All @@ -58,6 +68,7 @@ target_compile_options( ${PROJECT_NAME}
target_include_directories( ${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}/generated"
)

target_link_libraries( ${PROJECT_NAME}
Expand Down
46 changes: 46 additions & 0 deletions src/aboutdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
///*****************************************************************************
/// @date Oct 2018
/// @copyright GPL-3.0-or-later
/// @author Thomas Lepoix <[email protected]>
///*****************************************************************************

#include <QRegularExpression>

#include "changelog.hpp"
#include "version.hpp"

#include "aboutdialog.hpp"
using namespace std;

//******************************************************************************
AboutDialog::AboutDialog(QWidget* parent)
: QDialog(parent, Qt::Dialog)
, ui(make_unique<Ui::AboutDialog>()) {
ui->setupUi(this);
ui->l_version->setText(ui->l_version->text() + VERSION);
// Font size x-large does not work in UI file stylesheet. Rather setting it
// here than using a fixed size in px, that actually works there.
ui->l_title->setText(QString("<span style='font-size:x-large; font-weight:bold;'>") + ui->l_title->text() + "</span>");

static QString const changelog_md(QString(changelog.data())
.replace(QRegularExpression(" \\*"), "-") // Bullet points
.replace(QRegularExpression(" \\*"), " -") // Bullet points
.replace(QRegularExpression("#([0-9]+)"), "[#\\1](" QRFL_BUGREPORT "/\\1)") // Issues
.replace(QRegularExpression(" -- ([^<]+)<.*> +(.*)"), "*\\1 - \\2*\n\n---") // Signature/Date line
.replace(QRegularExpression("(qucsrflayout \\([0-9.]+\\))"), "### \\1") // Release title line
.replace(QRegularExpression(" \\[ (.*) \\]"), "#### \\1")); // Category line

ui->tb_changelog->setMarkdown(changelog_md);
//ui->tb_changelog->setPlainText(changelog_md); // For converter debug.

ui->tb_contact->setMarkdown(
"Homepage: " QRFL_HOMEPAGE "\n\n"
"Bug report: " QRFL_BUGREPORT "\n\n"
"Main developer: <[email protected]>\n\n"
"Funding: " QRFL_FUNDING);
}

//******************************************************************************
void AboutDialog::on_pb_ok_clicked() {
accept();
}
32 changes: 32 additions & 0 deletions src/aboutdialog.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
///*****************************************************************************
/// @date Oct 2018
/// @copyright GPL-3.0-or-later
/// @author Thomas Lepoix <[email protected]>
///*****************************************************************************

#pragma once

#ifndef QRFL_MINIMAL

#include <QDialog>
#include <QObject>

#include <memory>

#include "ui_aboutdialog.h"

//******************************************************************************
class AboutDialog : public QDialog {
Q_OBJECT
private:
std::unique_ptr<Ui::AboutDialog> ui;

private slots:
void on_pb_ok_clicked();

public:
explicit AboutDialog(QWidget* parent=0);
~AboutDialog()=default;
};

#endif // QRFL_MINIMAL
154 changes: 154 additions & 0 deletions src/aboutdialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="Dialog">
<property name="windowTitle">
<string>About Qucs-RFlayout</string>
</property>
<layout class="QVBoxLayout" name="vb_main">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>

<item>
<layout class="QHBoxLayout" name="hb_about">
<property name="leftMargin">
<number>20</number>
</property>
<property name="topMargin">
<number>20</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QLabel" name="l_icon">
<property name="pixmap">
<pixmap>:/qucsrflayout.128.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>

<item>
<layout class="QVBoxLayout" name="vb_about_text">
<property name="leftMargin">
<number>40</number>
</property>
<property name="rightMargin">
<number>40</number>
</property>
<item>
<widget class="QLabel" name="l_title">
<property name="text">
<string>Radio Frequency Layout</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="styleSheet">
<string notr="true">font-weight:bold;</string>
<!--string notr="true">font-size:20px; font-weight:bold;</string-->
<!--string notr="true">font-size:x-large; font-weight:bold;</string-->
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="l_version">
<property name="text">
<string>Version </string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="l_copyright">
<property name="text">
<string>Copyright © 2018 Thomas Lepoix</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>

<item>
<widget class="QLabel" name="l_disclaimer">
<property name="text">
<string>This software is distributed under the terms of
the GPL license version 3 or later.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>20</number>
</property>
</widget>
</item>

<item>
<widget class="QTabWidget" name="tw_more">
<widget class="QTextBrowser" name="tb_changelog">
<attribute name="title">
<string>Changelog</string>
</attribute>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
<widget class="QTextBrowser" name="tb_contact">
<attribute name="title">
<string>Contact</string>
</attribute>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</widget>
</item>

<item>
<layout class="QHBoxLayout" name="hb_ok">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>

</layout>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>
10 changes: 10 additions & 0 deletions src/changelog.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
///*****************************************************************************
/// @date Oct 2018
/// @copyright GPL-3.0-or-later
/// @author Thomas Lepoix <[email protected]>
///*****************************************************************************

#include <string>

// Workaround CPP not providing C23 #embed : use CMake configure step instead.
inline std::string_view constexpr changelog = R"(@QRFL_CHANGELOG@)";
7 changes: 7 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "logger.hpp"
#include "preview.hpp"
#include "aboutdialog.hpp"
#include "mainwindow.hpp"
using namespace std;

Expand Down Expand Up @@ -201,6 +202,12 @@ void MainWindow::write() {
}
}

//******************************************************************************
void MainWindow::on_a_about_triggered() {
AboutDialog about(this);
about.exec();
}

//******************************************************************************
static void open_doc_file(QString const& name) {
static QString const docdir = QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../share/doc/qucsrflayout");
Expand Down
3 changes: 2 additions & 1 deletion src/mainwindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MainWindow : public QMainWindow, public Loggable {
void log(std::stringstream& in) override;

private slots:
void on_a_about_triggered();
void on_a_detail_mcorn_triggered();
void on_a_detail_mcoupled_triggered();
void on_a_detail_mcross_triggered();
Expand Down Expand Up @@ -103,7 +104,7 @@ private slots:
void on_rb_export_whole_toggled(bool const is_checked);

public:
explicit MainWindow(Data& _data, std::string const& gui_theme, QWidget* parent=0);
MainWindow(Data& _data, std::string const& gui_theme, QWidget* parent=0);
~MainWindow()=default;
};

Expand Down
6 changes: 6 additions & 0 deletions src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,14 @@ Should be a component label</string>
</widget>
<addaction name="m_view"/>
<addaction name="m_help"/>
<addaction name="a_about"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="a_about">
<property name="text">
<string>About</string>
</property>
</action>
<action name="a_detail_mcorn">
<property name="text">
<string>MCORN - Microstrip corner</string>
Expand Down
1 change: 1 addition & 0 deletions src/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
qucsrflayout.16x16.png \
qucsrflayout.ico
-->
<file alias="qucsrflayout.128.png">../pack/icons/qucsrflayout.128x128.png</file>
<file alias="qucsrflayout.ico">../pack/icons/qucsrflayout.ico</file>
<file alias="mcorn.png">./icons/mcorn.png</file>
<file alias="mcoupled.png">./icons/mcoupled.png</file>
Expand Down

0 comments on commit a2eb3c3

Please sign in to comment.