Browse Source

Merge pull request #1603 from nonlinear-chaos-order-etc-etal/openssl-custom

qt: added about box
pull/1605/head
orignal 4 years ago committed by GitHub
parent
commit
f2059947bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      qt/i2pd_qt/AboutDialog.cpp
  2. 22
      qt/i2pd_qt/AboutDialog.h
  3. 194
      qt/i2pd_qt/AboutDialog.ui
  4. 7
      qt/i2pd_qt/BuildDateTimeQt.h
  5. 21
      qt/i2pd_qt/i2pd_qt.pro
  6. 47
      qt/i2pd_qt/mainwindow.cpp
  7. 1
      qt/i2pd_qt/mainwindow.h
  8. 67
      qt/i2pd_qt/mainwindow.ui
  9. 4
      qt/i2pd_qt/routercommandswidget.ui

23
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;
}

22
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

194
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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;About i2pd_qt&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>

7
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

21
qt/i2pd_qt/i2pd_qt.pro

@ -36,7 +36,8 @@ SOURCES += DaemonQT.cpp mainwindow.cpp \
../../daemon/HTTPServer.cpp \ ../../daemon/HTTPServer.cpp \
../../daemon/I2PControl.cpp \ ../../daemon/I2PControl.cpp \
../../daemon/i2pd.cpp \ ../../daemon/i2pd.cpp \
../../daemon/UPnP.cpp ../../daemon/UPnP.cpp \
AboutDialog.cpp
HEADERS += DaemonQT.h mainwindow.h \ HEADERS += DaemonQT.h mainwindow.h \
ClientTunnelPane.h \ ClientTunnelPane.h \
@ -59,8 +60,9 @@ HEADERS += DaemonQT.h mainwindow.h \
../../daemon/Daemon.h \ ../../daemon/Daemon.h \
../../daemon/HTTPServer.h \ ../../daemon/HTTPServer.h \
../../daemon/I2PControl.h \ ../../daemon/I2PControl.h \
../../daemon/UPnP.h ../../daemon/UPnP.h \
AboutDialog.h \
BuildDateTimeQt.h
INCLUDEPATH += ../../libi2pd INCLUDEPATH += ../../libi2pd
INCLUDEPATH += ../../libi2pd_client INCLUDEPATH += ../../libi2pd_client
@ -71,7 +73,8 @@ FORMS += mainwindow.ui \
tunnelform.ui \ tunnelform.ui \
statusbuttons.ui \ statusbuttons.ui \
routercommandswidget.ui \ routercommandswidget.ui \
generalsettingswidget.ui generalsettingswidget.ui \
AboutDialog.ui
LIBS += $$PWD/../../libi2pd.a $$PWD/../../libi2pdclient.a -lz 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.commands = cd $$PWD/../../ && CC=$$QMAKE_CC CXX=$$QMAKE_CXX $(MAKE) clean
cleani2pd.depends = 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 PRE_TARGETDEPS += $$PWD/../../libi2pd.a $$PWD/../../libi2pdclient.a
QMAKE_EXTRA_TARGETS += cleani2pd i2pd libi2pd QMAKE_EXTRA_TARGETS += cleani2pd i2pd libi2pd
CLEAN_DEPS += cleani2pd CLEAN_DEPS += cleani2pd

47
qt/i2pd_qt/mainwindow.cpp

@ -1,4 +1,5 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "AboutDialog.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "ui_statusbuttons.h" #include "ui_statusbuttons.h"
#include "ui_routercommandswidget.h" #include "ui_routercommandswidget.h"
@ -8,6 +9,13 @@
#include <QTimer> #include <QTimer>
#include <QFile> #include <QFile>
#include <QFileDialog> #include <QFileDialog>
#include <QApplication>
#include <QScreen>
#include <QStyleHints>
#include <QScreen>
#include <QWindow>
#include "RouterContext.h" #include "RouterContext.h"
#include "Config.h" #include "Config.h"
#include "FS.h" #include "FS.h"
@ -65,6 +73,10 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
statusButtonsUI->setupUi(ui->statusButtonsPane); statusButtonsUI->setupUi(ui->statusButtonsPane);
routerCommandsUI->setupUi(routerCommandsParent); routerCommandsUI->setupUi(routerCommandsParent);
uiSettings->setupUi(ui->settingsContents); 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(); routerCommandsParent->hide();
ui->verticalLayout_2->addWidget(routerCommandsParent); ui->verticalLayout_2->addWidget(routerCommandsParent);
//,statusHtmlUI(new Ui::StatusHtmlPaneForm) //,statusHtmlUI(new Ui::StatusHtmlPaneForm)
@ -76,15 +88,16 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
setWindowTitle(QApplication::translate("AppTitle","I2PD")); setWindowTitle(QApplication::translate("AppTitle","I2PD"));
//TODO handle resizes and change the below into resize() call //TODO handle resizes and change the below into resize() call
setFixedHeight(550); constexpr auto WINDOW_HEIGHT = 610;
ui->centralWidget->setFixedHeight(550); setFixedHeight(WINDOW_HEIGHT);
ui->centralWidget->setFixedHeight(WINDOW_HEIGHT);
onResize(); onResize();
ui->stackedWidget->setCurrentIndex(0); ui->stackedWidget->setCurrentIndex(0);
ui->settingsScrollArea->resize(uiSettings->settingsContentsQVBoxLayout->sizeHint().width()+10,380); ui->settingsScrollArea->resize(uiSettings->settingsContentsQVBoxLayout->sizeHint().width()+10,380);
//QScrollBar* const barSett = ui->settingsScrollArea->verticalScrollBar(); //QScrollBar* const barSett = ui->settingsScrollArea->verticalScrollBar();
int w = 683; constexpr auto w = 683;
int h = 4550; constexpr auto h = 4550;
ui->settingsContents->setFixedSize(w, h); ui->settingsContents->setFixedSize(w, h);
ui->settingsContents->setGeometry(QRect(0,0,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->acceptTransitTunnelsPushButton, SIGNAL(released()), this, SLOT(enableTransit()));
QObject::connect(routerCommandsUI->declineTransitTunnelsPushButton, SIGNAL(released()), this, SLOT(disableTransit())); 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->logViewerPushButton, SIGNAL(released()), this, SLOT(showLogViewerPage()));
QObject::connect(ui->settingsPagePushButton, SIGNAL(released()), this, SLOT(showSettingsPage())); QObject::connect(ui->settingsPagePushButton, SIGNAL(released()), this, SLOT(showSettingsPage()));
@ -400,6 +415,30 @@ void MainWindow::showStatusPage(StatusPage newStatusPage){
} }
wasSelectingAtStatusMainPage=false; wasSelectingAtStatusMainPage=false;
} }
void MainWindow::showAboutBox(const QString & href) {
qDebug() << "MainWindow::showAboutBox(), href:" << href << endl;
AboutDialog dialog(this);
/*
//doesn't work on older qt5: ‘class QStyleHints’ has no member named ‘showIsMaximized’
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);
}
}
*/
(void) dialog.exec();
}
void MainWindow::showLogViewerPage(){ui->stackedWidget->setCurrentIndex(1);setStatusButtonsVisible(false);} void MainWindow::showLogViewerPage(){ui->stackedWidget->setCurrentIndex(1);setStatusButtonsVisible(false);}
void MainWindow::showSettingsPage(){ui->stackedWidget->setCurrentIndex(2);setStatusButtonsVisible(false);} void MainWindow::showSettingsPage(){ui->stackedWidget->setCurrentIndex(2);setStatusButtonsVisible(false);}
void MainWindow::showTunnelsPage(){ui->stackedWidget->setCurrentIndex(3);setStatusButtonsVisible(false);} void MainWindow::showTunnelsPage(){ui->stackedWidget->setCurrentIndex(3);setStatusButtonsVisible(false);}

1
qt/i2pd_qt/mainwindow.h

@ -442,6 +442,7 @@ public slots:
void showTunnelsPage(); void showTunnelsPage();
void showRestartPage(); void showRestartPage();
void showQuitPage(); void showQuitPage();
void showAboutBox(const QString & href);
private: private:
StatusPage statusPage; StatusPage statusPage;

67
qt/i2pd_qt/mainwindow.ui

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>908</width> <width>908</width>
<height>554</height> <height>604</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -35,13 +35,13 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>908</width> <width>908</width>
<height>550</height> <height>600</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>908</width> <width>908</width>
<height>550</height> <height>600</height>
</size> </size>
</property> </property>
<widget class="QWidget" name="horizontalLayoutWidget"> <widget class="QWidget" name="horizontalLayoutWidget">
@ -50,7 +50,7 @@
<x>10</x> <x>10</x>
<y>10</y> <y>10</y>
<width>888</width> <width>888</width>
<height>531</height> <height>596</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
@ -58,7 +58,7 @@
<enum>QLayout::SetMaximumSize</enum> <enum>QLayout::SetMaximumSize</enum>
</property> </property>
<item> <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"> <property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum> <enum>QLayout::SetMinimumSize</enum>
</property> </property>
@ -67,7 +67,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>170</width> <width>170</width>
<height>496</height> <height>596</height>
</rect> </rect>
</property> </property>
<item> <item>
@ -172,6 +172,33 @@
</property> </property>
</spacer> </spacer>
</item> </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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;about:i2pd_qt&quot;&gt;&lt;span style=&quot;text-decoration: none; color:#a0a0a0;&quot;&gt;&lt;span style=&quot;font-weight: 500;&quot;&gt;i2pd_qt&lt;/span&gt;&lt;br/&gt;Version SHORT_VERSION · About...&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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> </layout>
</item> </item>
<item> <item>
@ -629,7 +656,7 @@
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>713</width> <width>707</width>
<height>713</height> <height>713</height>
</size> </size>
</property> </property>
@ -648,8 +675,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>713</width> <width>707</width>
<height>531</height> <height>586</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
@ -690,8 +717,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>711</width> <width>707</width>
<height>531</height> <height>586</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4_logViewer"> <layout class="QVBoxLayout" name="verticalLayout_4_logViewer">
@ -753,8 +780,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>711</width> <width>707</width>
<height>531</height> <height>586</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
@ -798,8 +825,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>81</width> <width>693</width>
<height>28</height> <height>498</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -820,8 +847,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>711</width> <width>707</width>
<height>531</height> <height>586</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
@ -903,8 +930,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>711</width> <width>707</width>
<height>531</height> <height>586</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
@ -958,7 +985,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>711</width> <width>707</width>
<height>531</height> <height>531</height>
</rect> </rect>
</property> </property>

4
qt/i2pd_qt/routercommandswidget.ui

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>711</width> <width>707</width>
<height>300</height> <height>300</height>
</rect> </rect>
</property> </property>
@ -24,7 +24,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>711</width> <width>707</width>
<height>301</height> <height>301</height>
</rect> </rect>
</property> </property>

Loading…
Cancel
Save