diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-12-14 15:27:32 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-12-14 15:45:21 +0200 |
commit | d970b1e28a11223b6dd1cd4a32918cfa9271e283 (patch) | |
tree | f2978d0d0f4f31cc3b6e5d65aec35173ca9eda74 | |
parent | Update PKGBUILD to build with cmake (diff) | |
download | smolbote-d970b1e28a11223b6dd1cd4a32918cfa9271e283.tar.xz |
Code cleanup
-rw-r--r-- | include/singleton.hpp | 27 | ||||
-rw-r--r-- | src/applicationmenu.cpp | 13 | ||||
-rw-r--r-- | src/browser.cpp | 10 | ||||
-rw-r--r-- | src/browser.h | 4 | ||||
-rw-r--r-- | src/webengine/webprofilemanager.h | 15 |
5 files changed, 26 insertions, 43 deletions
diff --git a/include/singleton.hpp b/include/singleton.hpp deleted file mode 100644 index d13e29e..0000000 --- a/include/singleton.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SMOLBOTE_SINGLETON_HPP -#define SMOLBOTE_SINGLETON_HPP - -/* - * Clang consumed semantics - * States can be: unconsumed, consumed, unknown - * Mark classes with consumable(unconsumed) - * Mark constructors with return_typestate(unconsumed) - * Mark invalidating functions with set_typestate(consumed) - */ - -#if defined(__clang__) -#define consumable(X) [[clang::consumable(X)]] -#define return_typestate(X) [[clang::return_typestate(X)]] -#define set_typestate(X) [[clang::set_typestate(X)]] -#define callable_when(X) [[clang::callable_when(X)]] -#define param_typestate(X) [[clang::param_typestate(X)]] - -#else -#define consumable(X) -#define return_typestate(X) -#define set_typestate(X) -#define callable_when(X) -#define param_typestate(X) -#endif - -#endif // SMOLBOTE_SINGLETON_HPP diff --git a/src/applicationmenu.cpp b/src/applicationmenu.cpp index f69260d..e6cc538 100644 --- a/src/applicationmenu.cpp +++ b/src/applicationmenu.cpp @@ -8,6 +8,7 @@ #include "applicationmenu.h" #include "about/aboutdialog.h" +#include "about/aboutplugin.h" #include "browser.h" #include "configuration.h" #include "session/savesessiondialog.h" @@ -20,7 +21,7 @@ ApplicationMenu::ApplicationMenu(Browser *app, QWidget *parent) : QMenu(parent) { m_app = app; - setTitle(qApp->applicationName()); + setTitle(QApplication::applicationName()); Configuration conf; const auto sessionPath = conf.value<QString>("session.path").value(); @@ -41,12 +42,18 @@ ApplicationMenu::ApplicationMenu(Browser *app, QWidget *parent) bottom_pluginSeparator = addSeparator(); auto *actionAbout = addAction(tr("About"), app, []() { - auto *dlg = new AboutDialog(qApp->activeWindow()); + auto *dlg = new AboutDialog(QApplication::activeWindow()); dlg->show(); }); conf.shortcut<QAction>(*actionAbout, "shortcuts.window.about"); - auto *action_aboutPlugins = addAction(tr("About Plugins"), app, &Browser::aboutPlugins); + auto *action_aboutPlugins = addAction(tr("About Plugins"), app, [app]() { + auto *dlg = new AboutPluginDialog(QApplication::activeWindow()); + for(auto *info : qAsConst(app->m_plugins)) { + dlg->add(info->loader); + } + dlg->show(); + }); conf.shortcut(*action_aboutPlugins, "app.shortcuts.about.plugins"); auto *actionQuit = addAction(tr("Quit"), app, &Browser::quit); diff --git a/src/browser.cpp b/src/browser.cpp index c9ed395..de5cdcf 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -7,7 +7,6 @@ */ #include "browser.h" -#include "about/aboutplugin.h" #include "applicationmenu.h" #include "bookmarks/bookmarkswidget.h" #include "configuration.h" @@ -49,15 +48,6 @@ Browser::~Browser() m_windows.clear(); } -void Browser::aboutPlugins() -{ - auto *dlg = new AboutPluginDialog; - for(auto *info : qAsConst(m_plugins)) { - dlg->add(info->loader); - } - dlg->exec(); -} - void Browser::loadConfiguration(const QString &path) { auto ctx = init_conf(path.toStdString()); diff --git a/src/browser.h b/src/browser.h index 740eec8..63b280b 100644 --- a/src/browser.h +++ b/src/browser.h @@ -24,9 +24,11 @@ class Configuration; class BookmarksWidget; class DownloadsWidget; class MainWindow; +class ApplicationMenu; class Browser final : public SingleApplication { Q_OBJECT + friend class ApplicationMenu; public: explicit Browser(int &argc, char *argv[], bool allowSecondary = true); @@ -54,8 +56,6 @@ signals: void pluginAdded(QPluginLoader *); public slots: - [[deprecated]] void aboutPlugins(); - [[deprecated]] void showWidget(QWidget *widget, MainWindow *where) const; void open(const QVector<Session::MainWindow> &data, bool merge = true); diff --git a/src/webengine/webprofilemanager.h b/src/webengine/webprofilemanager.h index a356506..e5df6d5 100644 --- a/src/webengine/webprofilemanager.h +++ b/src/webengine/webprofilemanager.h @@ -9,7 +9,6 @@ #ifndef SMOLBOTE_WEBPROFILEMANAGER_H #define SMOLBOTE_WEBPROFILEMANAGER_H -#include "singleton.hpp" #include "webprofile.h" #include <QDir> #include <QFile> @@ -18,6 +17,20 @@ #include <QMenu> #include <functional> +#if defined(__clang__) +#define consumable(X) [[clang::consumable(X)]] +#define return_typestate(X) [[clang::return_typestate(X)]] +#define set_typestate(X) [[clang::set_typestate(X)]] +#define callable_when(X) [[clang::callable_when(X)]] +#define param_typestate(X) [[clang::param_typestate(X)]] +#else +#define consumable(X) +#define return_typestate(X) +#define set_typestate(X) +#define callable_when(X) +#define param_typestate(X) +#endif + void profileMenu(QMenu *menu, const std::function<void(WebProfile *)> &callback, WebProfile *current = nullptr, bool checkable = false); template <bool use_global = true> |