From 2f40ae7913ce78dbac1ccc61df9a096aeb756e2d Mon Sep 17 00:00:00 2001 From: arcan1s Date: Mon, 14 Jul 2014 18:31:35 +0400 Subject: [PATCH] added about window --- sources/CMakeLists.txt | 3 +- sources/gui/src/about.ui | 105 +++++++++++++++++++++++++++++ sources/gui/src/aboutwindow.cpp | 92 +++++++++++++++++++++++++ sources/gui/src/aboutwindow.h | 51 ++++++++++++++ sources/gui/src/aboutwindow.ui | 22 ++++++ sources/gui/src/main.cpp | 88 +++++++++++++++++------- sources/gui/src/mainwindow.cpp | 7 ++ sources/gui/src/mainwindow.h | 9 ++- sources/gui/src/mainwindow.ui | 25 +++++-- sources/gui/src/settingswindow.cpp | 6 +- sources/gui/src/settingswindow.h | 3 +- sources/plasmoid/about.ui | 1 + sources/plasmoid/netctl.cpp | 22 ++++-- sources/plasmoid/netctl.h | 2 + sources/version.h.in | 22 +++++- 15 files changed, 412 insertions(+), 46 deletions(-) create mode 100644 sources/gui/src/about.ui create mode 100644 sources/gui/src/aboutwindow.cpp create mode 100644 sources/gui/src/aboutwindow.h create mode 100644 sources/gui/src/aboutwindow.ui create mode 120000 sources/plasmoid/about.ui diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 230a4f9..327a432 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -12,7 +12,6 @@ set (PROJECT_VERSION_PATCH 0) set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) string (TIMESTAMP CURRENT_DATE UTC) string (TIMESTAMP CURRENT_YEAR "%Y") -configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) message (STATUS "Project: ${PROJECT_NAME}") message (STATUS "Version: ${PROJECT_VERSION}") @@ -41,6 +40,8 @@ else () message (STATUS "Unknown compiler") endif () +configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) + # resources set (PROJECT_LIBRARY netctlgui) set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources) diff --git a/sources/gui/src/about.ui b/sources/gui/src/about.ui new file mode 100644 index 0000000..4a77167 --- /dev/null +++ b/sources/gui/src/about.ui @@ -0,0 +1,105 @@ + + + About + + + + 0 + 0 + 398 + 298 + + + + Form + + + + + + + + + Qt::AlignJustify|Qt::AlignVCenter + + + Qt::TextBrowserInteraction + + + + + + + + + + Qt::AlignCenter + + + Qt::TextBrowserInteraction + + + + + + + + + + Qt::AlignCenter + + + Qt::TextBrowserInteraction + + + + + + + + + + Qt::RichText + + + Qt::AlignCenter + + + Qt::TextBrowserInteraction + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Qt::RichText + + + true + + + Qt::TextBrowserInteraction + + + + + + + + diff --git a/sources/gui/src/aboutwindow.cpp b/sources/gui/src/aboutwindow.cpp new file mode 100644 index 0000000..8695e61 --- /dev/null +++ b/sources/gui/src/aboutwindow.cpp @@ -0,0 +1,92 @@ +/*************************************************************************** + * This file is part of netctl-gui * + * * + * netctl-gui is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * netctl-gui is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with netctl-gui. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "aboutwindow.h" +#include "ui_aboutwindow.h" + +#include +#include +#include + +#include "version.h" + + +AboutWindow::AboutWindow(QWidget *parent, const bool debugCmd) + : QMainWindow(parent), + ui(new Ui::AboutWindow), + debug(debugCmd) +{ + ui->setupUi(this); + + createUi(); +} + + +AboutWindow::~AboutWindow() +{ + if (debug) qDebug() << "[AboutWindow]" << "[~AboutWindow]"; + + delete uiAbout; + delete ui; +} + + +void AboutWindow::createText() +{ + if (debug) qDebug() << "[AboutWindow]" << "[createText]"; + + uiAbout->label_name->setText(QString(NAME)); + uiAbout->label_version->setText(QApplication::translate("AboutWindow", "Version %1\n(build date %2)") + .arg(QString(VERSION)).arg(QString(BUILD_DATE))); + uiAbout->label_description->setText(QApplication::translate("AboutWindow", "Qt-based graphical interface for netctl.")); + uiAbout->label_links->setText(QApplication::translate("AboutWindow", "Links:") + QString("
") + + QString("%2
").arg(QString(HOMEPAGE)).arg(QApplication::translate("AboutWindow", "Homepage")) + + QString("%2
").arg(QString(REPOSITORY)).arg(QApplication::translate("AboutWindow", "Repository")) + + QString("%2
").arg(QString(BUGTRACKER)).arg(QApplication::translate("AboutWindow", "Bugtracker")) + + QString("%2
").arg(QString(TRANSLATION)).arg(QApplication::translate("AboutWindow", "Translation issue")) +\ + QString("%2").arg(QString(AUR_PACKAGES)).arg(QApplication::translate("AboutWindow", "AUR packages"))); + uiAbout->label_license->setText(QString("© %1 %2
").arg(QString(DATE)).arg(QString(AUTHOR)) + + QApplication::translate("AboutWindow", "This software is licensed under %1").arg(QString(LICENSE)) + + QString("
")); +} + + +void AboutWindow::createUi() +{ + if (debug) qDebug() << "[AboutWindow]" << "[createUi]"; + + QWidget *aboutWidget = new QWidget; + uiAbout = new Ui::About; + uiAbout->setupUi(aboutWidget); + ui->verticalLayout->addWidget(aboutWidget); + createText(); + + QDialogButtonBox *buttonBox = new QDialogButtonBox; + buttonBox->addButton(QDialogButtonBox::Close); + ui->verticalLayout->addWidget(buttonBox); + connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close())); +} + + +// ESC press event +void AboutWindow::keyPressEvent(QKeyEvent *pressedKey) +{ + if (debug) qDebug() << "[AboutWindow]" << "[keyPressEvent]"; + + if (pressedKey->key() == Qt::Key_Escape) + close(); +} diff --git a/sources/gui/src/aboutwindow.h b/sources/gui/src/aboutwindow.h new file mode 100644 index 0000000..5a46741 --- /dev/null +++ b/sources/gui/src/aboutwindow.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * This file is part of netctl-gui * + * * + * netctl-gui is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * netctl-gui is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with netctl-gui. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#ifndef ABOUTWINDOW_H +#define ABOUTWINDOW_H + +#include +#include + +#include "ui_about.h" + + +namespace Ui { +class AboutWindow; +} + +class AboutWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit AboutWindow(QWidget *parent = 0, + const bool debugCmd = false); + ~AboutWindow(); + +private: + Ui::AboutWindow *ui; + Ui::About *uiAbout; + bool debug; + void createText(); + void createUi(); + // ESC pressed event + void keyPressEvent(QKeyEvent *pressedKey); +}; + + +#endif /* ABOUTWINDOW_H */ diff --git a/sources/gui/src/aboutwindow.ui b/sources/gui/src/aboutwindow.ui new file mode 100644 index 0000000..bc66642 --- /dev/null +++ b/sources/gui/src/aboutwindow.ui @@ -0,0 +1,22 @@ + + + AboutWindow + + + + 0 + 0 + 380 + 307 + + + + About + + + + + + + + diff --git a/sources/gui/src/main.cpp b/sources/gui/src/main.cpp index 4257e59..a759314 100644 --- a/sources/gui/src/main.cpp +++ b/sources/gui/src/main.cpp @@ -55,14 +55,20 @@ int main(int argc, char *argv[]) bool debug = false; bool defaultSettings = false; bool error = false; + bool showAbout = false; bool showHelp = false; + bool showInfo = false; bool showNetctlAuto = false; bool showSettings = false; bool showVersion = false; int tabNumber = 1; for (int i=1; i #include +#include "aboutwindow.h" #include "bridgewidget.h" #include "errorwindow.h" #include "ethernetwidget.h" @@ -47,6 +48,7 @@ MainWindow::MainWindow(QWidget *parent, const bool debugCmd, const bool defaultSettings, + const bool showAbout, const bool showNetctlAuto, const bool showSettings, const int tabNum) @@ -71,6 +73,7 @@ MainWindow::MainWindow(QWidget *parent, configuration = settingsWin->getSettings(); // gui + aboutWin = new AboutWindow(this, debug); netctlAutoWin = new NetctlAutoWindow(this, debug, configuration); generalWid = new GeneralWidget(this, configuration); ui->scrollAreaWidgetContents->layout()->addWidget(generalWid); @@ -104,6 +107,8 @@ MainWindow::MainWindow(QWidget *parent, updateTabs(ui->tabWidget->currentIndex()); ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready")); + if (showAbout) + aboutWin->show(); if (showNetctlAuto) netctlAutoWin->showWindow(); if (showSettings) @@ -131,6 +136,7 @@ MainWindow::~MainWindow() delete vlanWid; delete wirelessWid; + delete aboutWin; delete netctlAutoWin; delete settingsWin; delete ui; @@ -191,6 +197,7 @@ void MainWindow::createActions() connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int))); connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateMenu(int))); + connect(ui->actionAbout, SIGNAL(triggered(bool)), aboutWin, SLOT(show())); connect(ui->actionNetctlAuto, SIGNAL(triggered(bool)), netctlAutoWin, SLOT(showWindow())); ui->actionNetctlAuto->setVisible(checkExternalApps(QString("all"))); connect(ui->actionSettings, SIGNAL(triggered(bool)), settingsWin, SLOT(showWindow())); diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h index 10f84fb..0ba4d23 100644 --- a/sources/gui/src/mainwindow.h +++ b/sources/gui/src/mainwindow.h @@ -23,6 +23,7 @@ #include +class AboutWindow; class BridgeWidget; class ErrorWindow; class EthernetWidget; @@ -54,6 +55,7 @@ public: explicit MainWindow(QWidget *parent = 0, const bool debugCmd = false, const bool defaultSettings = false, + const bool showAbout = false, const bool showNetctlAuto = false, const bool showSettings = false, const int tabNum = 1); @@ -99,7 +101,11 @@ private slots: private: // ui Ui::MainWindow *ui; + AboutWindow *aboutWin; + ErrorWindow *errorWin; NetctlAutoWindow *netctlAutoWin; + PasswdWidget *passwdWid; + SettingsWindow *settingsWin; BridgeWidget *bridgeWid; EthernetWidget *ethernetWid; GeneralWidget *generalWid; @@ -115,9 +121,6 @@ private: Netctl *netctlCommand; NetctlProfile *netctlProfile; WpaSup *wpaCommand; - ErrorWindow *errorWin; - PasswdWidget *passwdWid; - SettingsWindow *settingsWin; bool checkExternalApps(const QString apps); bool checkState(const QString state, const QString item); void createActions(); diff --git a/sources/gui/src/mainwindow.ui b/sources/gui/src/mainwindow.ui index 3ce3444..4033fc4 100644 --- a/sources/gui/src/mainwindow.ui +++ b/sources/gui/src/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 481 - 509 + 479 + 507 @@ -206,8 +206,8 @@ 0 0 - 449 - 353 + 96 + 26 @@ -367,7 +367,7 @@ 0 0 - 481 + 479 22 @@ -398,8 +398,15 @@ + + + Help + + + + @@ -553,6 +560,14 @@ netctl-auto + + + + + + About + + tabWidget diff --git a/sources/gui/src/settingswindow.cpp b/sources/gui/src/settingswindow.cpp index 97d8966..9198479 100644 --- a/sources/gui/src/settingswindow.cpp +++ b/sources/gui/src/settingswindow.cpp @@ -24,12 +24,10 @@ #include #include "language.h" -#include "mainwindow.h" -SettingsWindow::SettingsWindow(MainWindow *wid, const bool debugCmd, const QString configFile) - : QMainWindow(wid), - parent(wid), +SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile) + : QMainWindow(parent), debug(debugCmd), file(configFile), ui(new Ui::SettingsWindow) diff --git a/sources/gui/src/settingswindow.h b/sources/gui/src/settingswindow.h index 1dc3683..8ab7e66 100644 --- a/sources/gui/src/settingswindow.h +++ b/sources/gui/src/settingswindow.h @@ -34,7 +34,7 @@ class SettingsWindow : public QMainWindow Q_OBJECT public: - explicit SettingsWindow(MainWindow *wid = 0, + explicit SettingsWindow(QWidget *parent = 0, const bool debugCmd = false, const QString configFile = QString("")); ~SettingsWindow(); @@ -62,7 +62,6 @@ private slots: void selectWpaSupPath(); private: - MainWindow *parent; bool debug; QString file; Ui::SettingsWindow *ui; diff --git a/sources/plasmoid/about.ui b/sources/plasmoid/about.ui new file mode 120000 index 0000000..84f8ecb --- /dev/null +++ b/sources/plasmoid/about.ui @@ -0,0 +1 @@ +../gui/src/about.ui \ No newline at end of file diff --git a/sources/plasmoid/netctl.cpp b/sources/plasmoid/netctl.cpp index 17457e5..20ba517 100644 --- a/sources/plasmoid/netctl.cpp +++ b/sources/plasmoid/netctl.cpp @@ -595,10 +595,8 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent) uiAppConfig.setupUi(appWidget); QWidget *deWidget = new QWidget; uiDEConfig.setupUi(deWidget); - - QString text = QString(NAME) + " - " + QString(VERSION) + "\n" + "(c) " + - QString(DATE) + " " + QString(AUTHOR); - uiWidConfig.label_info->setText(text); + QWidget *aboutWidget = new QWidget; + uiAboutConfig.setupUi(aboutWidget); uiWidConfig.spinBox_autoUpdate->setValue(autoUpdateInterval); uiWidConfig.lineEdit_gui->setText(paths[QString("gui")]); @@ -664,9 +662,23 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent) uiDEConfig.lineEdit_extIp->setText(deSettings[QString("EXTIPCMD")]); setDataEngineExternalIp(); + uiAboutConfig.label_name->setText(QString(NAME)); + uiAboutConfig.label_version->setText(i18n("Version %1\n(build date %2)", QString(VERSION), QString(BUILD_DATE))); + uiAboutConfig.label_description->setText(i18n("KDE widget which interacts with netctl.")); + uiAboutConfig.label_links->setText(i18n("Links:") + QString("
") + + QString("%2
").arg(QString(HOMEPAGE)).arg(i18n("Homepage")) + + QString("%2
").arg(QString(REPOSITORY)).arg(i18n("Repository")) + + QString("%2
").arg(QString(BUGTRACKER)).arg(i18n("Bugtracker")) + + QString("%2
").arg(QString(TRANSLATION)).arg(i18n("Translation issue")) + + QString("%2").arg(QString(AUR_PACKAGES)).arg(i18n("AUR packages"))); + uiAboutConfig.label_license->setText(QString("© %1 %2
").arg(QString(DATE)).arg(QString(AUTHOR)) + + i18n("This software is licensed under %1", QString(LICENSE)) + + QString("
")); + parent->addPage(configWidget, i18n("Netctl plasmoid"), Applet::icon()); parent->addPage(appWidget, i18n("Appearance"), QString("preferences-desktop-theme")); parent->addPage(deWidget, i18n("DataEngine"), Applet::icon()); + parent->addPage(aboutWidget, i18n("About"), QString("help-about")); connect(uiWidConfig.checkBox_showBigInterface, SIGNAL(stateChanged(int)), this, SLOT(setBigInterface())); @@ -678,7 +690,7 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent) connect(uiWidConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectNetctlExe())); connect(uiWidConfig.pushButton_netctlAuto, SIGNAL(clicked()), this, SLOT(selectNetctlAutoExe())); connect(uiWidConfig.pushButton_sudo, SIGNAL(clicked()), this, SLOT(selectSudoExe())); - connect(uiWidConfig.pushButton_wifi, SIGNAL(clicked()), this, SLOT(selecWifiExe())); + connect(uiWidConfig.pushButton_wifi, SIGNAL(clicked()), this, SLOT(selectWifiExe())); connect(uiAppConfig.pushButton_activeIcon, SIGNAL(clicked()), this, SLOT(selectActiveIcon())); connect(uiAppConfig.pushButton_inactiveIcon, SIGNAL(clicked()), this, SLOT(selectInactiveIcon())); connect(uiDEConfig.pushButton_extIp, SIGNAL(clicked()), this, SLOT(selectDataEngineExternalIpExe())); diff --git a/sources/plasmoid/netctl.h b/sources/plasmoid/netctl.h index 1301f27..7506b6a 100644 --- a/sources/plasmoid/netctl.h +++ b/sources/plasmoid/netctl.h @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -111,6 +112,7 @@ private: Ui::AppearanceWindow uiAppConfig; Ui::DataEngineWindow uiDEConfig; Ui::ConfigWindow uiWidConfig; + Ui::About uiAboutConfig; // configuration int autoUpdateInterval; QMap bigInterface; diff --git a/sources/version.h.in b/sources/version.h.in index 2b0ca6d..cfd3afc 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -1,10 +1,26 @@ #ifndef VERSION_H #define VERSION_H -#define AUTHOR "Evgeniy Alekseev" -#define BUILD_DATE "@CURRENT_DATE@" -#define DATE "2014-@CURRENT_YEAR@" #define NAME "Netctl Graphical Interface" #define VERSION "@PROJECT_VERSION@" +#define AUTHOR "Evgeniy Alekseev" +#define LICENSE "GPLv3" + +#define HOMEPAGE "http://arcanis.name/projects/netctl-gui/" +#define REPOSITORY "https://github.com/arcan1s/netctl-gui" +#define BUGTRACKER "https://github.com/arcan1s/netctl-gui/issues" +#define TRANSLATION "https://github.com/arcan1s/netctl-gui/issues/3" +#define AUR_PACKAGES "https://aur.archlinux.org/pkgbase/netctl-gui/" + +#define BUILD_DATE "@CURRENT_DATE@" +#define DATE "2014-@CURRENT_YEAR@" + +#define CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@" +#define CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" +#define PROJECT_BUILD_DATAENGINE "@BUILD_DATAENGINE@" +#define PROJECT_BUILD_GUI "@BUILD_GUI@" +#define PROJECT_BUILD_LIBRARY "@BUILD_LIBRARY@" +#define PROJECT_BUILD_PLASMOID "@BUILD_PLASMOID@" +#define PROJECT_USE_QT5 "@USE_QT5@" #endif /* VERSION_H */