diff --git a/qt/i2pd_qt/AboutDialog.cpp b/qt/i2pd_qt/AboutDialog.cpp new file mode 100644 index 00000000..2428c2da --- /dev/null +++ b/qt/i2pd_qt/AboutDialog.cpp @@ -0,0 +1,23 @@ +#include "AboutDialog.h" +#include "ui_AboutDialog.h" +#include <QDebug> +#include "version.h" +#include "BuildDateTimeQt.h" + +AboutDialog::AboutDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::AboutDialog) +{ + qDebug() << "AboutDialog::AboutDialog()" << endl; + ui->setupUi(this); + ui->i2pdVersionLabel->setText(I2PD_VERSION); + ui->i2pVersionLabel->setText(I2P_VERSION); + ui->buildDateTimeLabel->setText(BUILD_DATE_TIME_QT); + ui->vcsCommitInfoLabel->setText(VCS_COMMIT_INFO); +} + +AboutDialog::~AboutDialog() +{ + qDebug() << "AboutDialog::~AboutDialog()" << endl; + delete ui; +} diff --git a/qt/i2pd_qt/AboutDialog.h b/qt/i2pd_qt/AboutDialog.h new file mode 100644 index 00000000..d462de28 --- /dev/null +++ b/qt/i2pd_qt/AboutDialog.h @@ -0,0 +1,22 @@ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include <QDialog> + +namespace Ui { +class AboutDialog; +} + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = 0); + ~AboutDialog(); + +private: + Ui::AboutDialog *ui; +}; + +#endif // ABOUTDIALOG_H diff --git a/qt/i2pd_qt/AboutDialog.ui b/qt/i2pd_qt/AboutDialog.ui new file mode 100644 index 00000000..6e662706 --- /dev/null +++ b/qt/i2pd_qt/AboutDialog.ui @@ -0,0 +1,194 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>AboutDialog</class> + <widget class="QDialog" name="AboutDialog"> + <property name="windowModality"> + <enum>Qt::WindowModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>199</height> + </rect> + </property> + <property name="windowTitle"> + <string>About i2pd_qt</string> + </property> + <property name="windowIcon"> + <iconset resource="i2pd.qrc"> + <normaloff>:/icons/mask</normaloff>:/icons/mask</iconset> + </property> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="geometry"> + <rect> + <x>10</x> + <y>160</y> + <width>381</width> + <height>32</height> + </rect> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Ok</set> + </property> + </widget> + <widget class="QLabel" name="label"> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>381</width> + <height>17</height> + </rect> + </property> + <property name="text"> + <string><html><head/><body><p><span style=" font-weight:600;">About i2pd_qt</span></p></body></html></string> + </property> + </widget> + <widget class="QLabel" name="label_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>40</y> + <width>131</width> + <height>17</height> + </rect> + </property> + <property name="text"> + <string>i2pd Version:</string> + </property> + </widget> + <widget class="QLabel" name="label_3"> + <property name="geometry"> + <rect> + <x>10</x> + <y>70</y> + <width>131</width> + <height>17</height> + </rect> + </property> + <property name="text"> + <string>Build Date/Time:</string> + </property> + </widget> + <widget class="QLabel" name="i2pdVersionLabel"> + <property name="geometry"> + <rect> + <x>150</x> + <y>40</y> + <width>241</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>I2PD_VERSION_LABEL</string> + </property> + </widget> + <widget class="QLabel" name="label_4"> + <property name="geometry"> + <rect> + <x>10</x> + <y>130</y> + <width>131</width> + <height>17</height> + </rect> + </property> + <property name="text"> + <string>I2P Version:</string> + </property> + </widget> + <widget class="QLabel" name="i2pVersionLabel"> + <property name="geometry"> + <rect> + <x>150</x> + <y>130</y> + <width>241</width> + <height>17</height> + </rect> + </property> + <property name="text"> + <string>I2P_VERSION_LABEL</string> + </property> + </widget> + <widget class="QLabel" name="buildDateTimeLabel"> + <property name="geometry"> + <rect> + <x>150</x> + <y>70</y> + <width>241</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>BUILD_DATE_TIME_LABEL</string> + </property> + </widget> + <widget class="QLabel" name="label_5"> + <property name="geometry"> + <rect> + <x>10</x> + <y>100</y> + <width>131</width> + <height>17</height> + </rect> + </property> + <property name="text"> + <string>Version Control:</string> + </property> + </widget> + <widget class="QLabel" name="vcsCommitInfoLabel"> + <property name="geometry"> + <rect> + <x>150</x> + <y>100</y> + <width>241</width> + <height>17</height> + </rect> + </property> + <property name="text"> + <string>VCS_COMMIT_INFO_LABEL</string> + </property> + </widget> + </widget> + <resources> + <include location="i2pd.qrc"/> + </resources> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>AboutDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>AboutDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/qt/i2pd_qt/BuildDateTimeQt.h b/qt/i2pd_qt/BuildDateTimeQt.h new file mode 100644 index 00000000..139e2083 --- /dev/null +++ b/qt/i2pd_qt/BuildDateTimeQt.h @@ -0,0 +1,7 @@ +#ifndef BUILDDATETIMEQT_H +#define BUILDDATETIMEQT_H + +#include <QString> +const QString BUILD_DATE_TIME_QT = QStringLiteral(__DATE__ " " __TIME__); + +#endif // BUILDDATETIMEQT_H diff --git a/qt/i2pd_qt/i2pd_qt.pro b/qt/i2pd_qt/i2pd_qt.pro index 004b6273..a572e454 100644 --- a/qt/i2pd_qt/i2pd_qt.pro +++ b/qt/i2pd_qt/i2pd_qt.pro @@ -36,7 +36,8 @@ SOURCES += DaemonQT.cpp mainwindow.cpp \ ../../daemon/HTTPServer.cpp \ ../../daemon/I2PControl.cpp \ ../../daemon/i2pd.cpp \ - ../../daemon/UPnP.cpp + ../../daemon/UPnP.cpp \ + AboutDialog.cpp HEADERS += DaemonQT.h mainwindow.h \ ClientTunnelPane.h \ @@ -59,8 +60,9 @@ HEADERS += DaemonQT.h mainwindow.h \ ../../daemon/Daemon.h \ ../../daemon/HTTPServer.h \ ../../daemon/I2PControl.h \ - ../../daemon/UPnP.h - + ../../daemon/UPnP.h \ + AboutDialog.h \ + BuildDateTimeQt.h INCLUDEPATH += ../../libi2pd INCLUDEPATH += ../../libi2pd_client @@ -71,7 +73,8 @@ FORMS += mainwindow.ui \ tunnelform.ui \ statusbuttons.ui \ routercommandswidget.ui \ - generalsettingswidget.ui + generalsettingswidget.ui \ + AboutDialog.ui LIBS += $$PWD/../../libi2pd.a $$PWD/../../libi2pdclient.a -lz @@ -86,6 +89,16 @@ i2pd.depends = FORCE cleani2pd.commands = cd $$PWD/../../ && CC=$$QMAKE_CC CXX=$$QMAKE_CXX $(MAKE) clean cleani2pd.depends = clean +BuildDateTimeQtTarget.target = BuildDateTimeQt.h +BuildDateTimeQtTarget.depends = FORCE +# 'touch' is unix-only; will probably break on non-unix, TBD +BuildDateTimeQtTarget.commands = touch $$PWD/BuildDateTimeQt.h +PRE_TARGETDEPS += BuildDateTimeQt.h +QMAKE_EXTRA_TARGETS += BuildDateTimeQtTarget + +# git only, port to other VCS, too. TBD +DEFINES += VCS_COMMIT_INFO="\\\"git:$(shell git -C \""$$_PRO_FILE_PWD_"\" describe)\\\"" + PRE_TARGETDEPS += $$PWD/../../libi2pd.a $$PWD/../../libi2pdclient.a QMAKE_EXTRA_TARGETS += cleani2pd i2pd libi2pd CLEAN_DEPS += cleani2pd diff --git a/qt/i2pd_qt/mainwindow.cpp b/qt/i2pd_qt/mainwindow.cpp index 89178ee0..925992a5 100644 --- a/qt/i2pd_qt/mainwindow.cpp +++ b/qt/i2pd_qt/mainwindow.cpp @@ -1,4 +1,5 @@ #include "mainwindow.h" +#include "AboutDialog.h" #include "ui_mainwindow.h" #include "ui_statusbuttons.h" #include "ui_routercommandswidget.h" @@ -8,6 +9,13 @@ #include <QTimer> #include <QFile> #include <QFileDialog> + +#include <QApplication> +#include <QScreen> +#include <QStyleHints> +#include <QScreen> +#include <QWindow> + #include "RouterContext.h" #include "Config.h" #include "FS.h" @@ -65,6 +73,10 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren statusButtonsUI->setupUi(ui->statusButtonsPane); routerCommandsUI->setupUi(routerCommandsParent); uiSettings->setupUi(ui->settingsContents); + + ui->aboutHrefLabel->setText("<html><head/><body><p><a href='about:i2pd_qt'><span style='text-decoration:none;color:#a0a0a0;'>" + "<span style='font-weight:500;'>i2pd_qt</span><br/>Version " I2PD_VERSION " · About...</span></a></p></body></html>"); + routerCommandsParent->hide(); ui->verticalLayout_2->addWidget(routerCommandsParent); //,statusHtmlUI(new Ui::StatusHtmlPaneForm) @@ -76,15 +88,16 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren setWindowTitle(QApplication::translate("AppTitle","I2PD")); //TODO handle resizes and change the below into resize() call - setFixedHeight(550); - ui->centralWidget->setFixedHeight(550); + constexpr auto WINDOW_HEIGHT = 610; + setFixedHeight(WINDOW_HEIGHT); + ui->centralWidget->setFixedHeight(WINDOW_HEIGHT); onResize(); ui->stackedWidget->setCurrentIndex(0); ui->settingsScrollArea->resize(uiSettings->settingsContentsQVBoxLayout->sizeHint().width()+10,380); //QScrollBar* const barSett = ui->settingsScrollArea->verticalScrollBar(); - int w = 683; - int h = 4550; + constexpr auto w = 683; + constexpr auto h = 4550; ui->settingsContents->setFixedSize(w, h); ui->settingsContents->setGeometry(QRect(0,0,w,h)); @@ -143,6 +156,8 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren QObject::connect(routerCommandsUI->acceptTransitTunnelsPushButton, SIGNAL(released()), this, SLOT(enableTransit())); QObject::connect(routerCommandsUI->declineTransitTunnelsPushButton, SIGNAL(released()), this, SLOT(disableTransit())); + QObject::connect(ui->aboutHrefLabel, SIGNAL(linkActivated(const QString &)), this, SLOT(showAboutBox(const QString &))); + QObject::connect(ui->logViewerPushButton, SIGNAL(released()), this, SLOT(showLogViewerPage())); QObject::connect(ui->settingsPagePushButton, SIGNAL(released()), this, SLOT(showSettingsPage())); @@ -400,6 +415,27 @@ void MainWindow::showStatusPage(StatusPage newStatusPage){ } wasSelectingAtStatusMainPage=false; } + +void MainWindow::showAboutBox(const QString & href) { + qDebug() << "MainWindow::showAboutBox(), href:" << href << endl; + AboutDialog dialog(this); + + if (!QGuiApplication::styleHints()->showIsFullScreen() && !QGuiApplication::styleHints()->showIsMaximized()) { + const QWindow * windowHandle = dialog.windowHandle(); + qDebug()<<"AboutDialog windowHandle ptr: "<<(size_t)windowHandle<<endl; + const QScreen * screen = windowHandle?windowHandle->screen():nullptr; //Qt 5.14+: dialog.screen() + qDebug()<<"AboutDialog screen ptr: "<<(size_t)screen<<endl; + if (screen) { + const QRect availableGeometry = screen->availableGeometry(); + //dialog.resize(availableGeometry.width() / 3, availableGeometry.height() * 2 / 3); + dialog.move((availableGeometry.width() - dialog.width()) / 2, + (availableGeometry.height() - dialog.height()) / 2); + } + } + //dialog.show(); + (void) dialog.exec(); +} + void MainWindow::showLogViewerPage(){ui->stackedWidget->setCurrentIndex(1);setStatusButtonsVisible(false);} void MainWindow::showSettingsPage(){ui->stackedWidget->setCurrentIndex(2);setStatusButtonsVisible(false);} void MainWindow::showTunnelsPage(){ui->stackedWidget->setCurrentIndex(3);setStatusButtonsVisible(false);} diff --git a/qt/i2pd_qt/mainwindow.h b/qt/i2pd_qt/mainwindow.h index 77c8826b..2114155b 100644 --- a/qt/i2pd_qt/mainwindow.h +++ b/qt/i2pd_qt/mainwindow.h @@ -442,6 +442,7 @@ public slots: void showTunnelsPage(); void showRestartPage(); void showQuitPage(); + void showAboutBox(const QString & href); private: StatusPage statusPage; diff --git a/qt/i2pd_qt/mainwindow.ui b/qt/i2pd_qt/mainwindow.ui index dcdf88bd..8f942b08 100644 --- a/qt/i2pd_qt/mainwindow.ui +++ b/qt/i2pd_qt/mainwindow.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>908</width> - <height>554</height> + <height>604</height> </rect> </property> <property name="minimumSize"> @@ -35,13 +35,13 @@ <property name="minimumSize"> <size> <width>908</width> - <height>550</height> + <height>600</height> </size> </property> <property name="maximumSize"> <size> <width>908</width> - <height>550</height> + <height>600</height> </size> </property> <widget class="QWidget" name="horizontalLayoutWidget"> @@ -50,7 +50,7 @@ <x>10</x> <y>10</y> <width>888</width> - <height>531</height> + <height>596</height> </rect> </property> <layout class="QHBoxLayout" name="horizontalLayout"> @@ -58,7 +58,7 @@ <enum>QLayout::SetMaximumSize</enum> </property> <item> - <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0,0,0"> + <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0,0,0,0"> <property name="sizeConstraint"> <enum>QLayout::SetMinimumSize</enum> </property> @@ -67,7 +67,7 @@ <x>0</x> <y>0</y> <width>170</width> - <height>496</height> + <height>596</height> </rect> </property> <item> @@ -172,6 +172,33 @@ </property> </spacer> </item> + <item> + <widget class="QLabel" name="aboutHrefLabel"> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="contextMenuPolicy"> + <enum>Qt::NoContextMenu</enum> + </property> + <property name="toolTip"> + <string>Show app name, version and build date</string> + </property> + <property name="text"> + <string><html><head/><body><p><a href="about:i2pd_qt"><span style="text-decoration: none; color:#a0a0a0;"><span style="font-weight: 500;">i2pd_qt</span><br/>Version SHORT_VERSION · About...</span></a></p></body></html></string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <property name="margin"> + <number>6</number> + </property> + <property name="indent"> + <number>0</number> + </property> + </widget> + </item> </layout> </item> <item> @@ -629,7 +656,7 @@ </property> <property name="maximumSize"> <size> - <width>713</width> + <width>707</width> <height>713</height> </size> </property> @@ -648,8 +675,8 @@ <rect> <x>0</x> <y>0</y> - <width>713</width> - <height>531</height> + <width>707</width> + <height>586</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_5"> @@ -690,8 +717,8 @@ <rect> <x>0</x> <y>0</y> - <width>711</width> - <height>531</height> + <width>707</width> + <height>586</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_4_logViewer"> @@ -753,8 +780,8 @@ <rect> <x>0</x> <y>0</y> - <width>711</width> - <height>531</height> + <width>707</width> + <height>586</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_4"> @@ -798,8 +825,8 @@ <rect> <x>0</x> <y>0</y> - <width>81</width> - <height>28</height> + <width>693</width> + <height>498</height> </rect> </property> <property name="sizePolicy"> @@ -820,8 +847,8 @@ <rect> <x>0</x> <y>0</y> - <width>711</width> - <height>531</height> + <width>707</width> + <height>586</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_6"> @@ -903,8 +930,8 @@ <rect> <x>0</x> <y>0</y> - <width>711</width> - <height>531</height> + <width>707</width> + <height>586</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -958,7 +985,7 @@ <rect> <x>0</x> <y>0</y> - <width>711</width> + <width>707</width> <height>531</height> </rect> </property> diff --git a/qt/i2pd_qt/routercommandswidget.ui b/qt/i2pd_qt/routercommandswidget.ui index c5098e8e..f95db1fd 100644 --- a/qt/i2pd_qt/routercommandswidget.ui +++ b/qt/i2pd_qt/routercommandswidget.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>711</width> + <width>707</width> <height>300</height> </rect> </property> @@ -24,7 +24,7 @@ <rect> <x>0</x> <y>0</y> - <width>711</width> + <width>707</width> <height>301</height> </rect> </property>