From e4f237152d5581ebb7dc25fec1ba60cf2655f2e9 Mon Sep 17 00:00:00 2001
From: Aqua-sama
Date: Tue, 30 Jan 2018 12:25:32 +0100
Subject: Added profile and plugin list to About dialog
---
src/browser.cpp | 2 +-
src/browser.h | 10 +++++++++-
src/commandline.cpp | 6 +++---
src/commandline.h | 4 ++--
src/forms/aboutdialog.cpp | 33 +++++++++++++++++++++++++++++----
src/forms/aboutdialog.h | 6 +++---
src/forms/aboutdialog.ui | 4 ++--
src/main.cpp | 6 +++---
8 files changed, 52 insertions(+), 19 deletions(-)
(limited to 'src')
diff --git a/src/browser.cpp b/src/browser.cpp
index 53ca5d6..4782512 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -131,7 +131,7 @@ MainWindow *Browser::createSession(const QString &profileName, bool newWindow, c
return window;
}
-std::shared_ptr Browser::profile(const QString storageName)
+std::shared_ptr Browser::profile(const QString &storageName)
{
if(m_profiles.contains(storageName)) {
return m_profiles[storageName];
diff --git a/src/browser.h b/src/browser.h
index f58dce7..cc4cbb8 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -37,7 +37,15 @@ public:
void setConfiguration(std::shared_ptr &config);
- std::shared_ptr profile(const QString storageName);
+ std::shared_ptr profile(const QString &storageName);
+
+ const QList profiles() const {
+ return m_profiles.keys();
+ }
+
+ const QVector plugins() const {
+ return m_plugins;
+ }
public slots:
MainWindow *createSession(const QString &profileName, bool newWindow, const QStringList &urls);
diff --git a/src/commandline.cpp b/src/commandline.cpp
index adfdf52..e10e638 100644
--- a/src/commandline.cpp
+++ b/src/commandline.cpp
@@ -73,11 +73,11 @@ void CommandLine::parseCommandLine(const QCoreApplication &app)
for(const QString &opt : unknownOptionNames()) {
QCommandLineOption o(opt, "dummy desc", "dummy value");
- opts.append(o);
+ unknownOptions.append(o);
}
// add list and reparse to set the new options
- addOptions(opts);
+ addOptions(unknownOptions);
parse(app.arguments());
}
void CommandLine::printHelp(int exitCode)
@@ -108,7 +108,7 @@ void CommandLine::printHelp(int exitCode)
<< std::endl
<< std::endl;
- exit(0);
+ exit(exitCode);
}
void CommandLine::printVersion()
{
diff --git a/src/commandline.h b/src/commandline.h
index 99aa1cb..81063d3 100644
--- a/src/commandline.h
+++ b/src/commandline.h
@@ -29,10 +29,10 @@ public:
const QCommandLineOption socketOption;
const QCommandLineOption newWindowOption;
- QList opts;
+ QList unknownOptions;
private:
QCoreApplication *application;
};
-#endif //SMOLBOTE_COMMANDLINE_H
+#endif // SMOLBOTE_COMMANDLINE_H
diff --git a/src/forms/aboutdialog.cpp b/src/forms/aboutdialog.cpp
index 5b788bd..93cb688 100644
--- a/src/forms/aboutdialog.cpp
+++ b/src/forms/aboutdialog.cpp
@@ -7,6 +7,7 @@
*/
#include "aboutdialog.h"
+#include "browser.h"
#include "ui_aboutdialog.h"
#include "version.h"
#include
@@ -28,10 +29,9 @@ AboutDialog::AboutDialog(QWidget *parent)
setAttribute(Qt::WA_DeleteOnClose, true);
ui->setupUi(this);
- // clang-tidy: don't use static_cast to downcast from a base to a derived class,
- // use dynamic_cast instead
- //ui->icon->setPixmap(qApp->windowIcon().pixmap(72, 72));
- ui->icon->setPixmap(dynamic_cast(QApplication::instance())->windowIcon().pixmap(72, 72));
+ auto *browser = dynamic_cast(QApplication::instance());
+
+ ui->icon->setPixmap(dynamic_cast(browser)->windowIcon().pixmap(72, 72));
auto *aboutLabel = new QLabel(this);
aboutLabel->setWordWrap(true);
@@ -63,6 +63,31 @@ AboutDialog::AboutDialog(QWidget *parent)
"Boost " BOOST_LIB_VERSION " "
"
"));
ui->toolBox->addItem(libsLabel, tr("Details"));
+
+ // list profiles
+ if(!browser->profiles().isEmpty()) {
+ QString profilesText = tr("Profile list:
"
+ "");
+ for(const QString &name : browser->profiles()) {
+ if(name.isEmpty())
+ profilesText += tr("- Off-the-record
");
+ else
+ profilesText += tr("- %1
").arg(name);
+ }
+ profilesText += tr("
");
+ libsLabel->setText(libsLabel->text() + profilesText);
+ }
+
+ // list plugins
+ if(!browser->plugins().isEmpty()) {
+ QString pluginText = tr("Plugin list:
"
+ "");
+ for(const Browser::Plugin &plugin : browser->plugins()) {
+ pluginText += tr("- %1 (%2)
").arg(plugin.meta["name"].toString(), plugin.meta["author"].toString());
+ }
+ pluginText += tr("
");
+ libsLabel->setText(libsLabel->text() + pluginText);
+ }
}
AboutDialog::~AboutDialog()
diff --git a/src/forms/aboutdialog.h b/src/forms/aboutdialog.h
index 3175939..265f3c9 100644
--- a/src/forms/aboutdialog.h
+++ b/src/forms/aboutdialog.h
@@ -6,8 +6,8 @@
* SPDX-License-Identifier: GPL-3.0
*/
-#ifndef ABOUTDIALOG_H
-#define ABOUTDIALOG_H
+#ifndef SMOLBOTE_ABOUTDIALOG_H
+#define SMOLBOTE_ABOUTDIALOG_H
#include
@@ -28,4 +28,4 @@ private:
Ui::AboutDialog *ui;
};
-#endif // ABOUTDIALOG_H
+#endif // SMOLBOTE_ABOUTDIALOG_H
diff --git a/src/forms/aboutdialog.ui b/src/forms/aboutdialog.ui
index 60fd875..f7fe21e 100644
--- a/src/forms/aboutdialog.ui
+++ b/src/forms/aboutdialog.ui
@@ -6,8 +6,8 @@
0
0
- 550
- 320
+ 500
+ 600
diff --git a/src/main.cpp b/src/main.cpp
index 51087ae..e29e547 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -62,15 +62,15 @@ int main(int argc, char **argv)
// unfortunately, QCommandLineParser will only give us the unknown option
// names, so we need to build a list, add them as options, reparse, and then
// we get their values
- if(!parser.opts.isEmpty()) {
- int _argc = parser.opts.length() + 1;
+ if(!parser.unknownOptions.isEmpty()) {
+ int _argc = parser.unknownOptions.length() + 1;
const char *_argv[_argc];
// program_options requires 0 to be the program name, otherwise it seems to fail
_argv[0] = qUtf8Printable(instance.arguments().at(0));
for(int i = 1; i < _argc; ++i) {
- _argv[i] = qUtf8Printable(QString("--%1=%2").arg(parser.opts[i - 1].names().at(0), parser.value(parser.opts[i - 1])));
+ _argv[i] = qUtf8Printable(QString("--%1=%2").arg(parser.unknownOptions[i - 1].names().at(0), parser.value(parser.unknownOptions[i - 1])));
}
qDebug("Parsing command-line overrides: %s", config->parse(_argc, _argv) ? "ok" : "failed");
--
cgit v1.2.1