From d9d213c80353b843c18af6e49db61fa77039f056 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 21 Jun 2018 15:32:05 +0200 Subject: Add Browser::about --- lib/about/CMakeLists.txt | 2 - lib/about/aboutdialog.cpp | 74 ++++++++----------- lib/about/aboutdialog.h | 2 + lib/about/aboutdialog.ui | 117 ++++++++++++++++++++++++++++++- plugins/ProfileEditor/ProfileEditor.json | 2 +- src/CMakeLists.txt | 2 +- src/browser.cpp | 11 +++ src/browser.h | 4 ++ src/mainwindow/mainwindow.cpp | 8 +-- 9 files changed, 165 insertions(+), 57 deletions(-) diff --git a/lib/about/CMakeLists.txt b/lib/about/CMakeLists.txt index 7f53e8d..be506fe 100644 --- a/lib/about/CMakeLists.txt +++ b/lib/about/CMakeLists.txt @@ -15,8 +15,6 @@ add_library(about target_include_directories(about PRIVATE ${Boost_INCLUDE_DIRS} PRIVATE ${CMAKE_BINARY_DIR}/src - PRIVATE ${CMAKE_SOURCE_DIR}/src - PRIVATE ${CMAKE_SOURCE_DIR}/plugins ) target_link_libraries(about Qt5::Widgets) diff --git a/lib/about/aboutdialog.cpp b/lib/about/aboutdialog.cpp index 9b4d3bc..4fb7a27 100644 --- a/lib/about/aboutdialog.cpp +++ b/lib/about/aboutdialog.cpp @@ -8,10 +8,9 @@ #include "aboutdialog.h" #include "ui_aboutdialog.h" +#include "version.h" #include #include -#include "version.h" -#include // compiler // clang also defines __GNUC__, so we need to check for clang first @@ -25,21 +24,6 @@ #define compiler "unknown compiler" #endif -inline QString getPluginList() -{ - auto *browser = qobject_cast(qApp); - Q_CHECK_PTR(browser); - - QString plugins; - for(const Plugin &p : browser->plugins()) { - plugins.append(QString("
  • %1 (%2)
  • ").arg(p.name, p.author)); - } - if(!plugins.isEmpty()) - plugins = "Loaded plugins:
      " + plugins + "icon->setPixmap(qApp->windowIcon().pixmap(72, 72)); - auto *aboutLabel = new QLabel(this); - aboutLabel->setWordWrap(true); - aboutLabel->setText(tr("

      smolbote %1

      " - "

      yet another no-frills browser

      " - "

      This program is free software, see License for more information.

      " - "

      This program uses free software: Qt " QT_VERSION_STR " and Boost " BOOST_LIB_VERSION "

      ") - .arg(qApp->applicationVersion())); - ui->toolBox->addItem(aboutLabel, tr("About")); + ui->aboutLabel->setText(tr("

      smolbote %1

      " + "

      yet another no-frills browser

      " + "

      This program is free software, see License for more information.

      " + "

      This program uses free software: Qt " QT_VERSION_STR " and Boost " BOOST_LIB_VERSION "

      ") + .arg(qApp->applicationVersion())); - auto *licenseLabel = new QLabel(this); - licenseLabel->setWordWrap(true); - licenseLabel->setText(tr("

      Copyright 2017 - 2018 aqua

      " - "

      This program is free software, and you are welcome to use it under the conditions set by the GNU GPLv3.
      " - "This is a short summary:

        " - "
      • the freedom to use the software for any purpose,
      • " - "
      • the freedom to change the software to suit your needs,
      • " - "
      • the freedom to share the software with anyone,
      • " - "
      • the freedom to share the changes you make, and
      • " - "
      • the responsibility to grant the same freedoms when sharing the software.
      • " - "
      " - "

      This program is distributed in the hope that it will be useful, but without any warranty.

      ")); - ui->toolBox->addItem(licenseLabel, tr("License")); + ui->licenseLabel->setText(tr("

      Copyright 2017 - 2018 aqua

      " + "

      This program is free software, and you are welcome to use it under the conditions set by the GNU GPLv3.
      " + "This is a short summary:

        " + "
      • the freedom to use the software for any purpose,
      • " + "
      • the freedom to change the software to suit your needs,
      • " + "
      • the freedom to share the software with anyone,
      • " + "
      • the freedom to share the changes you make, and
      • " + "
      • the responsibility to grant the same freedoms when sharing the software.
      • " + "
      " + "

      This program is distributed in the hope that it will be useful, but without any warranty.

      ")); + ui->detailsLabel->setText(tr("

      Build " SMOLBOTE_BRANCH ":" SMOLBOTE_COMMIT "

      " + "

      Compiled with " compiler "

      ")); - - - auto *detailsLabel = new QLabel(this); - detailsLabel->setWordWrap(true); - detailsLabel->setText(tr("

      Build " SMOLBOTE_BRANCH ":" SMOLBOTE_COMMIT "

      " - "

      Compiled with " compiler "

      " - "

      %1

      ").arg(getPluginList())); - ui->toolBox->addItem(detailsLabel, tr("Details")); } AboutDialog::~AboutDialog() { delete ui; } + +void AboutDialog::addPlugin(const QString &name, const QString &author, const QString &shortcut) +{ + auto index = ui->pluginsTable->rowCount(); + ui->pluginsTable->setRowCount(index + 1); + + ui->pluginsTable->setItem(index, 0, new QTableWidgetItem(name)); + ui->pluginsTable->setItem(index, 1, new QTableWidgetItem(author)); + ui->pluginsTable->setItem(index, 2, new QTableWidgetItem(shortcut)); +} diff --git a/lib/about/aboutdialog.h b/lib/about/aboutdialog.h index 265f3c9..8a750ae 100644 --- a/lib/about/aboutdialog.h +++ b/lib/about/aboutdialog.h @@ -24,6 +24,8 @@ public: explicit AboutDialog(QWidget *parent = nullptr); ~AboutDialog() override; + void addPlugin(const QString &name, const QString &author, const QString &shortcut); + private: Ui::AboutDialog *ui; }; diff --git a/lib/about/aboutdialog.ui b/lib/about/aboutdialog.ui index f7fe21e..e6a37cf 100644 --- a/lib/about/aboutdialog.ui +++ b/lib/about/aboutdialog.ui @@ -49,8 +49,123 @@ - -1 + 0 + + + + 0 + 0 + 400 + 452 + + + + About + + + + + + TextLabel + + + true + + + + + + + + + 0 + 0 + 400 + 452 + + + + License + + + + + + TextLabel + + + true + + + + + + + + + 0 + 0 + 400 + 452 + + + + Details + + + + + + TextLabel + + + true + + + + + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContents + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + true + + + false + + + + Name + + + + + Author + + + + + Shortcut + + + + + + diff --git a/plugins/ProfileEditor/ProfileEditor.json b/plugins/ProfileEditor/ProfileEditor.json index ffb1c32..504eea4 100644 --- a/plugins/ProfileEditor/ProfileEditor.json +++ b/plugins/ProfileEditor/ProfileEditor.json @@ -1,5 +1,5 @@ { "name": "Profile Editor", "author": "Aqua-sama", - "shortcut": "Ctrl+F2" + "shortcut": "Ctrl+Shift+P" } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf66a53..00b556f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,7 +70,7 @@ endif(Plasma) target_compile_definitions(poi PRIVATE QTBUG_65223_WORKAROUND - PRIVATE QTBUG_68224_WORKAROUND + #PRIVATE QTBUG_68224_WORKAROUND ) install(TARGETS poi RUNTIME DESTINATION bin CONFIGURATIONS Release) diff --git a/src/browser.cpp b/src/browser.cpp index e3857dc..e55d063 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -22,6 +22,7 @@ #include #include #include +#include inline Plugin loadPluginFromPath(const QString &path) { @@ -103,6 +104,15 @@ Browser::~Browser() } +void Browser::about() +{ + auto *dlg = new AboutDialog; + for(const Plugin &plugin : qAsConst(m_plugins)) { + dlg->addPlugin(plugin.name, plugin.author, plugin.shortcut.toString()); + } + dlg->exec(); +} + void Browser::setConfiguration(std::shared_ptr &config) { Q_ASSERT(config); @@ -266,6 +276,7 @@ MainWindow *Browser::createWindow() if(p.instance->inherits("ProfileInterface")) { auto *profileEditor = qobject_cast(p.instance.get()); auto *profileAction = new QAction(tr("Profile"), window); + profileAction->setShortcut(p.shortcut); connect(profileAction, &QAction::triggered, window, [profileEditor]() { profileEditor->createWidget(nullptr)->show(); }); diff --git a/src/browser.h b/src/browser.h index b727059..7163c8f 100644 --- a/src/browser.h +++ b/src/browser.h @@ -33,6 +33,10 @@ public: ~Browser() final; Q_DISABLE_COPY(Browser) +public slots: + void about(); + +public: void setConfiguration(std::shared_ptr &config); void setup(const QString &defaultProfile); diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 48c9e9e..2b6eb07 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -12,6 +12,7 @@ #include "widgets/navigationbar.h" #include "widgets/searchform.h" #include "subwindow.h" +#include "browser.h" #include #include #include "widgets/dockwidget.h" @@ -24,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -157,11 +157,7 @@ void MainWindow::createMenuBar() smolboteMenu->addSeparator(); - smolboteMenu->addAction(tr("About"), this, [this]() { - auto *dlg = new AboutDialog(this); - dlg->exec(); - }, - QKeySequence(m_config->value("mainwindow.shortcuts.about").value().c_str())); + smolboteMenu->addAction(tr("About"), qobject_cast(qApp), &Browser::about, QKeySequence(m_config->value("mainwindow.shortcuts.about").value().c_str())); smolboteMenu->addAction(tr("About Qt"), qApp, &QApplication::aboutQt); smolboteMenu->addSeparator(); -- cgit v1.2.1