diff options
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | plugins/ProfileEditor/CMakeLists.txt | 7 | ||||
-rw-r--r-- | plugins/ProfileEditor/ProfileEditor.json | 4 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/profileview.cpp (renamed from src/forms/profileview.cpp) | 83 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/profileview.h (renamed from src/forms/profileview.h) | 15 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/profileview.ui | 374 | ||||
-rw-r--r-- | plugins/ProfileEditor/profileeditorplugin.cpp | 13 | ||||
-rw-r--r-- | plugins/ProfileEditor/profileeditorplugin.h | 4 | ||||
-rw-r--r-- | src/browser.cpp | 41 | ||||
-rw-r--r-- | src/browser.h | 8 | ||||
-rw-r--r-- | src/forms/profileview.ui | 230 | ||||
-rw-r--r-- | src/mainwindow.cpp | 39 | ||||
-rw-r--r-- | src/mainwindow.h | 5 | ||||
-rw-r--r-- | src/widgets/mainwindowmenubar.cpp | 13 |
14 files changed, 476 insertions, 363 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cb59e2..0586b90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,9 +97,6 @@ set(SourceCode "src/forms/aboutdialog.cpp" "src/forms/aboutdialog.h" "src/forms/aboutdialog.ui" - "src/forms/profileview.cpp" - "src/forms/profileview.h" - "src/forms/profileview.ui" # todo: move to src/webengine "src/forms/cookiesform.cpp" "src/forms/cookiesform.h" diff --git a/plugins/ProfileEditor/CMakeLists.txt b/plugins/ProfileEditor/CMakeLists.txt index 3eaa0f5..ee1af7f 100644 --- a/plugins/ProfileEditor/CMakeLists.txt +++ b/plugins/ProfileEditor/CMakeLists.txt @@ -8,10 +8,13 @@ set(CMAKE_AUTOMOC ON) add_library(ProfileEditorPlugin SHARED profileeditorplugin.cpp - profileeditorplugin.h) + profileeditorplugin.h + forms/profileview.cpp + forms/profileview.h + forms/profileview.ui) target_include_directories(ProfileEditorPlugin - PUBLIC ..) + PRIVATE ..) target_link_libraries(ProfileEditorPlugin PRIVATE Qt5::Widgets diff --git a/plugins/ProfileEditor/ProfileEditor.json b/plugins/ProfileEditor/ProfileEditor.json index e371eee..6a4ddea 100644 --- a/plugins/ProfileEditor/ProfileEditor.json +++ b/plugins/ProfileEditor/ProfileEditor.json @@ -1,5 +1,7 @@ { "name": "Profile Editor", + "author": "Aqua-sama <aqua@iserlohn-fortress.net", "shortcut": "Ctrl+F2", - "author": "Aqua-sama <aqua@iserlohn-fortress.net" + "addToMenu": false, + "addToToolbar": true } diff --git a/src/forms/profileview.cpp b/plugins/ProfileEditor/forms/profileview.cpp index 3d85963..ef0fece 100644 --- a/src/forms/profileview.cpp +++ b/plugins/ProfileEditor/forms/profileview.cpp @@ -8,24 +8,32 @@ #include "profileview.h" #include "ui_profileview.h" +#include <QWebEngineSettings> -#include "forms/cookiesform.h" -#include "webengine/webengineprofile.h" -#include <QComboBox> -#include <QLineEdit> -#include <QPlainTextEdit> -#include <QPushButton> - -#include <QDialogButtonBox> +inline void connectCheckBox(QCheckBox *checkBox, QWebEngineSettings *settings, QWebEngineSettings::WebAttribute attr) +{ + QObject::connect(checkBox, &QCheckBox::clicked, [settings, attr](bool checked){ + settings->setAttribute(attr, checked); + }); +} -#include <QFormLayout> -ProfileView::ProfileView(WebEngineProfile *profile, QWidget *parent) +ProfileView::ProfileView(QWebEngineProfile *profile, QWidget *parent) : QDialog(parent) , ui(new Ui::ProfileView) { + Q_CHECK_PTR(profile); + m_profile = profile; ui->setupUi(this); - setProfile(profile); + + QWebEngineSettings *settings = m_profile->settings(); + connectCheckBox(ui->autoloadImages_checkBox, settings, QWebEngineSettings::AutoLoadImages); + connectCheckBox(ui->autoloadIcons_checkBox, settings, QWebEngineSettings::AutoLoadIconsForPage); + + connectCheckBox(ui->javascriptEnabled, settings, QWebEngineSettings::JavascriptEnabled); + connectCheckBox(ui->javascriptCanAccessClipboard, settings, QWebEngineSettings::JavascriptCanAccessClipboard); + connectCheckBox(ui->javascriptCanOpenWindows, settings, QWebEngineSettings::JavascriptCanOpenWindows); + connectCheckBox(ui->javascriptCanActivateWindows, settings, QWebEngineSettings::AllowWindowActivationFromJavaScript); // actions connect(ui->clearCache_pushButton, &QPushButton::clicked, [this]() { @@ -35,8 +43,7 @@ ProfileView::ProfileView(WebEngineProfile *profile, QWidget *parent) this->m_profile->clearAllVisitedLinks(); }); - connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ProfileView::updateProfile); - connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ProfileView::close); + loadProfile(); } ProfileView::~ProfileView() @@ -44,19 +51,12 @@ ProfileView::~ProfileView() delete ui; } -void ProfileView::setProfile(WebEngineProfile *profile) +void ProfileView::loadProfile() { - Q_CHECK_PTR(profile); - - m_profile = profile; - setWindowTitle(m_profile->name()); - - m_cookiesForm = new CookiesForm(m_profile->cookieStore(), this); - //ui->tabWidget->addTab(m_cookiesForm, m_cookiesForm->windowTitle()); - - // general - ui->homepage_lineEdit->setText(m_profile->homepage().toString()); - ui->newtab_lineEdit->setText(m_profile->newtab().toString()); + if(m_profile->storageName().isEmpty()) + setWindowTitle(tr("Off-the-record")); + else + setWindowTitle(m_profile->storageName()); // http ui->userAgent->setPlainText(m_profile->httpUserAgent()); @@ -68,33 +68,22 @@ void ProfileView::setProfile(WebEngineProfile *profile) ui->storagePath_lineEdit->setText(m_profile->persistentStoragePath()); ui->cachePath_lineEdit->setText(m_profile->cachePath()); - // policy - ui->cookiePolicy->setCurrentIndex(m_profile->persistentCookiesPolicy()); - - //ui->formLayout_3->addWidget(m_cookiesForm); - ui->verticalLayout_3->addWidget(m_cookiesForm); -} + // settings + QWebEngineSettings *settings = m_profile->settings(); + ui->autoloadImages_checkBox->setChecked(settings->testAttribute(QWebEngineSettings::AutoLoadImages)); + ui->autoloadIcons_checkBox->setChecked(settings->testAttribute(QWebEngineSettings::AutoLoadIconsForPage)); -void ProfileView::showProfile() -{ - ui->tabWidget->setCurrentIndex(0); - show(); -} + ui->javascriptEnabled->setChecked(settings->testAttribute(QWebEngineSettings::JavascriptEnabled)); + ui->javascriptCanAccessClipboard->setChecked(settings->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard)); + ui->javascriptCanOpenWindows->setChecked(settings->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows)); + ui->javascriptCanActivateWindows->setChecked(settings->testAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript)); -void ProfileView::showCookies() -{ - ui->tabWidget->setCurrentIndex(2); - show(); + // policy + ui->cookiePolicy->setCurrentIndex(m_profile->persistentCookiesPolicy()); } void ProfileView::updateProfile() { - qDebug("Updating profile [%s]...", qUtf8Printable(m_profile->name())); - - // general - m_profile->setHomepage(QUrl::fromUserInput(ui->homepage_lineEdit->text())); - m_profile->setNewtab(QUrl::fromUserInput(ui->newtab_lineEdit->text())); - // http m_profile->setHttpUserAgent(ui->userAgent->toPlainText()); m_profile->setHttpAcceptLanguage(ui->acceptLanguage->toPlainText()); @@ -127,6 +116,4 @@ void ProfileView::updateProfile() default: break; } - - m_profile->saveProfile(); } diff --git a/src/forms/profileview.h b/plugins/ProfileEditor/forms/profileview.h index bf44346..580bee9 100644 --- a/src/forms/profileview.h +++ b/plugins/ProfileEditor/forms/profileview.h @@ -10,33 +10,28 @@ #define PROFILEDIALOG_H #include <QDialog> +#include <QWebEngineProfile> namespace Ui { class ProfileView; } -class WebEngineProfile; -class CookiesForm; class ProfileView : public QDialog { Q_OBJECT public: - explicit ProfileView(WebEngineProfile *profile, QWidget *parent = nullptr); - ~ProfileView(); - - void setProfile(WebEngineProfile *profile); + explicit ProfileView(QWebEngineProfile *profile, QWidget *parent = nullptr); + ~ProfileView() override; public slots: - void showProfile(); - void showCookies(); + void loadProfile(); void updateProfile(); private: Ui::ProfileView *ui; - WebEngineProfile *m_profile; - CookiesForm *m_cookiesForm; + QWebEngineProfile *m_profile; }; #endif // PROFILEDIALOG_H diff --git a/plugins/ProfileEditor/forms/profileview.ui b/plugins/ProfileEditor/forms/profileview.ui new file mode 100644 index 0000000..1e6f94f --- /dev/null +++ b/plugins/ProfileEditor/forms/profileview.ui @@ -0,0 +1,374 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ProfileView</class> + <widget class="QWidget" name="ProfileView"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>640</width> + <height>480</height> + </rect> + </property> + <property name="windowTitle"> + <string>Profile</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="httpTab"> + <attribute name="title"> + <string>HTTP</string> + </attribute> + <layout class="QFormLayout" name="formLayout_2"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>User Agent</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPlainTextEdit" name="userAgent"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Accept Language</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Cache Type</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Cache Size</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPlainTextEdit" name="acceptLanguage"/> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="cacheType"> + <item> + <property name="text"> + <string>Memory Cache</string> + </property> + </item> + <item> + <property name="text"> + <string>Disk Cache</string> + </property> + </item> + <item> + <property name="text"> + <string>Disabled</string> + </property> + </item> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="cacheSize"/> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="storagePath_label"> + <property name="text"> + <string>Storage Path</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QLineEdit" name="storagePath_lineEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="cachePath_label"> + <property name="text"> + <string>Cache Path</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="cachePath_lineEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QPushButton" name="clearCache_pushButton"> + <property name="text"> + <string>Clear Cache</string> + </property> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="cookiePolicy_label"> + <property name="text"> + <string>Cookies</string> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QComboBox" name="cookiePolicy"> + <item> + <property name="text"> + <string>No Persistent Cookies</string> + </property> + </item> + <item> + <property name="text"> + <string>Allow Persistent Cookies</string> + </property> + </item> + <item> + <property name="text"> + <string>Force Persistent Cookies</string> + </property> + </item> + </widget> + </item> + <item row="8" column="1"> + <widget class="QPushButton" name="clearHistory_pushButton"> + <property name="text"> + <string>Clear History</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="settingsTab"> + <attribute name="title"> + <string>Settings</string> + </attribute> + <layout class="QVBoxLayout" name="settings_verticalLayout"> + <item> + <widget class="QScrollArea" name="scrollArea"> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <widget class="QWidget" name="scrollAreaWidgetContents"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>584</width> + <height>724</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QCheckBox" name="autoloadImages_checkBox"> + <property name="text"> + <string>Autoload images</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="autoloadIcons_checkBox"> + <property name="text"> + <string>Autoload icons</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="javascriptEnabled"> + <property name="text"> + <string>JavaScript enabled</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="javascriptCanOpenWindows"> + <property name="text"> + <string>JavaScript can open windows</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="javascriptCanAccessClipboard"> + <property name="text"> + <string>JavaScript can access clipboard</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="javascriptCanActivateWindows"> + <property name="text"> + <string>JavaScript can activate windows</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_11"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_23"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_25"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_24"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_19"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_22"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_21"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_14"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_16"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_18"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_17"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_15"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_13"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_10"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_7"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_8"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_5"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_3"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/plugins/ProfileEditor/profileeditorplugin.cpp b/plugins/ProfileEditor/profileeditorplugin.cpp index 1f4f16e..e0b0af1 100644 --- a/plugins/ProfileEditor/profileeditorplugin.cpp +++ b/plugins/ProfileEditor/profileeditorplugin.cpp @@ -7,21 +7,12 @@ */ #include "profileeditorplugin.h" -#include <QLabel> -#include <QVBoxLayout> +#include "forms/profileview.h" QWidget *ProfileEditorPlugin::createWidget(QWebEngineProfile *profile, QWidget *parent) { - QWidget *widget = new QWidget(parent); + auto *widget = new ProfileView(profile, parent); widget->setWindowFlags(Qt::ToolTip); widget->setVisible(false); - auto *layout = new QVBoxLayout(widget); - widget->setLayout(layout); - - QLabel *storageName_label = new QLabel(profile->storageName(), widget); - if(storageName_label->text().isEmpty()) - storageName_label->setText(tr("Off-the-record")); - layout->addWidget(storageName_label); - return widget; } diff --git a/plugins/ProfileEditor/profileeditorplugin.h b/plugins/ProfileEditor/profileeditorplugin.h index 3115ab2..df2c5c4 100644 --- a/plugins/ProfileEditor/profileeditorplugin.h +++ b/plugins/ProfileEditor/profileeditorplugin.h @@ -9,10 +9,10 @@ #ifndef PROFILEEDITORPLUGIN_H #define PROFILEEDITORPLUGIN_H -#include <QWebEngineProfile> -#include <QWidget> #include <interfaces.h> +class QWebEngineProfile; +class QWidget; class ProfileEditorPlugin : public QObject, public PluginInterface, public ProfileInterface { Q_OBJECT diff --git a/src/browser.cpp b/src/browser.cpp index 542465b..43cee5f 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -13,9 +13,6 @@ #include <bookmarks/bookmarkswidget.h> #include <downloads/downloadswidget.h> -#include <QPluginLoader> -#include <QtPlugin> - Browser::Browser(int &argc, char *argv[]) : SingleApplication(argc, argv) { @@ -29,33 +26,38 @@ Browser::~Browser() { if(m_config) { QtConcurrent::run(QThreadPool::globalInstance(), m_config.get(), &Configuration::writeIfNeeded); - //m_config->writeIfNeeded(); } if(m_bookmarksManager) { QtConcurrent::run(QThreadPool::globalInstance(), m_bookmarksManager.get(), &BookmarksWidget::save); - //m_bookmarksManager->save(); } - qDebug("Waiting for threads to wind down: %s", QThreadPool::globalInstance()->waitForDone() ? "done" : "failed"); - - qDeleteAll(m_plugins); + qDebug("Waiting for threads to wind down..."); + qDebug("Thread pool is done: %s", QThreadPool::globalInstance()->waitForDone() ? "okay" : "failed"); } void Browser::setConfiguration(std::shared_ptr<Configuration> &config) { m_config = config; - // plugin loader - QPluginLoader loader("plugins/ProfileEditor/libProfileEditorPlugin.so"); - qDebug("Trying to load %s: %s", qUtf8Printable(loader.fileName()), loader.load() ? "ok" : "failed"); - if(!loader.isLoaded()) { - qDebug("Error: %s", qUtf8Printable(loader.errorString())); - } else { - PluginInterface *plugin = qobject_cast<PluginInterface *>(loader.instance()); - m_plugins.append(plugin); - //qDebug("author: %s", qUtf8Printable(loader.metaData()["MetaData"].toObject()["author"].toString())); + QDir pluginsDir(QString::fromStdString(m_config->value<std::string>("plugins.path").value())); + if(pluginsDir.exists()) { + const QStringList entries = pluginsDir.entryList(QDir::Files | QDir::Readable); + for (const QString &name : entries) { + QPluginLoader loader(pluginsDir.absoluteFilePath(name)); + qDebug("Loading plugin %s: %s", qUtf8Printable(name), loader.load() ? "ok" : "failed"); + if (!loader.isLoaded()) { + qDebug("Error: %s", qUtf8Printable(loader.errorString())); + } else { + Plugin d; + d.meta = loader.metaData()["MetaData"].toObject(); + d.pointer = loader.instance(); + d.pointer->setParent(this); + m_plugins.append(d); + } + } } + m_bookmarksManager = std::make_shared<BookmarksWidget>(QString::fromStdString(m_config->value<std::string>("bookmarks.path").value())); m_downloadManager = std::make_shared<DownloadsWidget>(QString::fromStdString(m_config->value<std::string>("downloads.path").value())); @@ -141,8 +143,3 @@ std::shared_ptr<WebEngineProfile> Browser::profile(const QString storageName) return _profile; } - -QStringList Browser::profiles() const -{ - return m_profiles.keys(); -} diff --git a/src/browser.h b/src/browser.h index 236b0fb..5b1a760 100644 --- a/src/browser.h +++ b/src/browser.h @@ -26,6 +26,11 @@ class Browser : public SingleApplication Q_OBJECT public: + struct Plugin { + QJsonObject meta; + QObject *pointer; + }; + explicit Browser(int &argc, char *argv[]); ~Browser() final; Q_DISABLE_COPY(Browser) @@ -33,7 +38,6 @@ public: void setConfiguration(std::shared_ptr<Configuration> &config); std::shared_ptr<WebEngineProfile> profile(const QString storageName); - QStringList profiles() const; public slots: MainWindow *createSession(const QString &profileName, bool newWindow, const QStringList &urls); @@ -44,7 +48,7 @@ private: std::shared_ptr<Configuration> m_config; QVector<MainWindow *> m_windows; - QVector<PluginInterface *> m_plugins; + QVector<Plugin> m_plugins; QHash<QString, std::shared_ptr<WebEngineProfile>> m_profiles; std::shared_ptr<WebEngineProfile> m_defaultProfile; diff --git a/src/forms/profileview.ui b/src/forms/profileview.ui deleted file mode 100644 index 7590e87..0000000 --- a/src/forms/profileview.ui +++ /dev/null @@ -1,230 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ProfileView</class> - <widget class="QWidget" name="ProfileView"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>480</width> - <height>640</height> - </rect> - </property> - <property name="minimumSize"> - <size> - <width>200</width> - <height>0</height> - </size> - </property> - <property name="windowTitle"> - <string>Profile</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string>General</string> - </attribute> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Homepage</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="homepage_lineEdit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Newtab</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="newtab_lineEdit"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="httpTab"> - <attribute name="title"> - <string>HTTP</string> - </attribute> - <layout class="QFormLayout" name="formLayout_2"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>User Agent</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QPlainTextEdit" name="userAgent"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Accept Language</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Cache Type</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Cache Size</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPlainTextEdit" name="acceptLanguage"/> - </item> - <item row="2" column="1"> - <widget class="QComboBox" name="cacheType"> - <item> - <property name="text"> - <string>Memory Cache</string> - </property> - </item> - <item> - <property name="text"> - <string>Disk Cache</string> - </property> - </item> - <item> - <property name="text"> - <string>Disabled</string> - </property> - </item> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="cacheSize"/> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="storagePath_label"> - <property name="text"> - <string>Storage Path</string> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="QLineEdit" name="storagePath_lineEdit"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="cachePath_label"> - <property name="text"> - <string>Cache Path</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="cachePath_lineEdit"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QPushButton" name="clearCache_pushButton"> - <property name="text"> - <string>Clear Cache</string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="policiesTab"> - <attribute name="title"> - <string>Cookies</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <layout class="QFormLayout" name="cookies_formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Cookies</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="cookiePolicy"> - <item> - <property name="text"> - <string>No Persistent Cookies</string> - </property> - </item> - <item> - <property name="text"> - <string>Allow Persistent Cookies</string> - </property> - </item> - <item> - <property name="text"> - <string>Force Persistent Cookies</string> - </property> - </item> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QWidget" name="actionsTab"> - <attribute name="title"> - <string>History</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="clearHistory_pushButton"> - <property name="text"> - <string>Clear History</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Close|QDialogButtonBox::Save</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 913885d..4306afd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -308,24 +308,25 @@ void MainWindow::handleTitleUpdated(const QString &title) //setWindowTitle(browser->settings()->value("window.title").toString().replace("title", title).replace("profile", tabBar->profile()->name())); } -void MainWindow::addPlugins(QVector<PluginInterface *> &plugins) { - for(PluginInterface *plugin : plugins) { - ProfileInterface *profilePlugin = dynamic_cast<ProfileInterface *>(plugin); - QWidget *w = profilePlugin->createWidget(m_profile.get(), this); - - QAction *profileAction = new QAction(this); - profileAction->setText("Profile Action"); - ui->navigationToolBar->addAction(profileAction); - connect(profileAction, &QAction::triggered, this, [this, w]() { - w->setVisible(!w->isVisible()); - if(w->isVisible()) { - w->adjustSize(); - QPoint pos = ui->navigationToolBar->pos(); - pos.setX(pos.x() + ui->navigationToolBar->width() - w->width()); - pos.setY(pos.y() + ui->navigationToolBar->height()); - w->move(mapToGlobal(pos)); - w->show(); - } - }); +void MainWindow::addPlugins(const QVector<Browser::Plugin> &plugins) +{ + for(const Browser::Plugin &plugin : plugins) { + ProfileInterface *iProfilePlugin = qobject_cast<ProfileInterface *>(plugin.pointer); + if(iProfilePlugin) { + QWidget *w = iProfilePlugin->createWidget(m_profile.get(), this); + + auto *profileAction = new QAction(tr("Profile Action"), this); + ui->navigationToolBar->addAction(profileAction); + connect(profileAction, &QAction::triggered, this, [this, w]() { + w->setVisible(!w->isVisible()); + if(w->isVisible()) { + QPoint pos = ui->navigationToolBar->pos(); + pos.setX(pos.x() + ui->navigationToolBar->width() - w->width()); + pos.setY(pos.y() + ui->navigationToolBar->height()); + w->move(mapToGlobal(pos)); + w->show(); + } + }); + } } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 6d1e190..79773d3 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -9,14 +9,15 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include "browser.h" #include "lib/navigation/navigationbutton.h" #include "webengine/webengineprofile.h" #include "widgets/loadingbar.h" #include "widgets/mainwindowtabbar.h" #include <QMainWindow> #include <QUrl> -#include <memory> #include <interfaces.h> +#include <memory> namespace Ui { @@ -60,7 +61,7 @@ public slots: void setBookmarksWidget(std::shared_ptr<BookmarksWidget> &widget); void setDownloadsWidget(std::shared_ptr<DownloadsWidget> &widget); - void addPlugins(QVector<PluginInterface *> &plugins); + void addPlugins(const QVector<Browser::Plugin> &plugins); void toggleFullscreen(); diff --git a/src/widgets/mainwindowmenubar.cpp b/src/widgets/mainwindowmenubar.cpp index c0bea4f..f8275c0 100644 --- a/src/widgets/mainwindowmenubar.cpp +++ b/src/widgets/mainwindowmenubar.cpp @@ -7,14 +7,9 @@ */ #include "mainwindowmenubar.h" -#include "forms/profileview.h" +#include "downloads/downloadswidget.h" #include "mainwindow.h" -#include <QApplication> #include <QInputDialog> -#include <settings/configuration.h> - -#include "browser.h" -#include "downloads/downloadswidget.h" MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr<Configuration> config, MainWindow *parent) : QMenuBar(parent) @@ -69,11 +64,7 @@ MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr<Configuration> config, Main // Profile menu QMenu *profileMenu = addMenu(tr("Profile")); m_profileAction = profileMenu->addAction(tr("Current profile")); - connect(m_profileAction, &QAction::triggered, this, [parent]() { - ProfileView *dlg = new ProfileView(parent->profile(), parent); - dlg->exec(); - delete dlg; - }); + m_profileAction->setEnabled(false); QMenu *loadMenu = profileMenu->addMenu(tr("Load")); loadMenu->setEnabled(false); |