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 +++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 146 insertions(+), 49 deletions(-) (limited to 'lib/about') 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 + + + + + + -- cgit v1.2.1