diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-02-14 17:55:00 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-02-14 17:55:00 +0100 |
commit | 883a502cc1cee3b596cef9645a6832804d6cb67f (patch) | |
tree | fa137ec26a2965ac6f16272841f75d4945e1f571 | |
parent | Settings changes (diff) | |
download | smolbote-883a502cc1cee3b596cef9645a6832804d6cb67f.tar.xz |
Global bookmarks and downloads dialogs
-rw-r--r-- | src/browser.cpp | 18 | ||||
-rw-r--r-- | src/browser.h | 8 | ||||
-rw-r--r-- | src/forms/bookmarksdialog.cpp | 13 | ||||
-rw-r--r-- | src/forms/bookmarksdialog.h | 8 | ||||
-rw-r--r-- | src/mainwindow.cpp | 12 | ||||
-rw-r--r-- | src/mainwindow.h | 4 | ||||
-rw-r--r-- | test/blocklist.txt | 23 | ||||
-rw-r--r-- | test/config.ini | 3 |
8 files changed, 56 insertions, 33 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index 6531070..1ca9abb 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -24,16 +24,20 @@ #include <QtWebEngine> Browser::Browser(int &argc, char *argv[]) : - QApplication(argc, argv) + QApplication(argc, argv), + m_bookmarksManager(new BookmarksDialog), + m_downloadManager(new DownloadDialog) { QtWebEngine::initialize(); } Browser::~Browser() { - // cleanup qDeleteAll(m_windows); m_windows.clear(); + + delete m_bookmarksManager; + delete m_downloadManager; } Browser *Browser::instance() @@ -41,6 +45,16 @@ Browser *Browser::instance() return static_cast<Browser *>(QCoreApplication::instance()); } +BookmarksDialog *Browser::bookmarks() +{ + return m_bookmarksManager; +} + +DownloadDialog *Browser::downloads() +{ + return m_downloadManager; +} + void Browser::setConfigPath(const QString &path) { if(path.isEmpty()) { diff --git a/src/browser.h b/src/browser.h index 4230e7f..2344997 100644 --- a/src/browser.h +++ b/src/browser.h @@ -23,6 +23,8 @@ #include <QApplication> #include <QVector> +#include "forms/bookmarksdialog.h" +#include "forms/downloaddialog.h" class MainWindow; class Browser : public QApplication @@ -34,6 +36,10 @@ public: ~Browser(); static Browser *instance(); + + BookmarksDialog *bookmarks(); + DownloadDialog *downloads(); + void setConfigPath(const QString &path); void addWindow(MainWindow* window); @@ -42,6 +48,8 @@ public slots: private: QVector<MainWindow*> m_windows; + BookmarksDialog *m_bookmarksManager; + DownloadDialog *m_downloadManager; }; diff --git a/src/forms/bookmarksdialog.cpp b/src/forms/bookmarksdialog.cpp index c8a0425..c088fd8 100644 --- a/src/forms/bookmarksdialog.cpp +++ b/src/forms/bookmarksdialog.cpp @@ -24,11 +24,10 @@ #include "xbel/xbel.h" #include "mainwindow.h" -BookmarksDialog::BookmarksDialog(MainWindow *parent) : +BookmarksDialog::BookmarksDialog(QWidget *parent) : QDialog(parent), ui(new Ui::BookmarksDialog) { - parentWindow = parent; ui->setupUi(this); ui->treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch); @@ -68,6 +67,12 @@ BookmarksDialog::~BookmarksDialog() delete ui; } +void BookmarksDialog::show(MainWindow *window) +{ + w = window; + QDialog::show(); +} + void BookmarksDialog::deleteCurrentItem() { delete ui->treeWidget->currentItem(); @@ -77,7 +82,9 @@ void BookmarksDialog::openItem(QTreeWidgetItem *item, int column) { Q_UNUSED(column) - parentWindow->addNewTab(QUrl::fromUserInput(item->text(1))); + if(w) { + w->addNewTab(QUrl::fromUserInput(item->text(1))); + } } void BookmarksDialog::showItemDetails() diff --git a/src/forms/bookmarksdialog.h b/src/forms/bookmarksdialog.h index e2387d7..17f4df7 100644 --- a/src/forms/bookmarksdialog.h +++ b/src/forms/bookmarksdialog.h @@ -34,10 +34,14 @@ class BookmarksDialog : public QDialog Q_OBJECT public: - explicit BookmarksDialog(MainWindow *parent = 0); + explicit BookmarksDialog(QWidget *parent = 0); ~BookmarksDialog(); +signals: + void openUrl(const QUrl &url); + public slots: + void show(MainWindow *window); // void addFolder(const QString &title); // void addBookmark(const QString &title, const QString &href); // void addSeparator(); @@ -48,7 +52,7 @@ private slots: void showItemDetails(); private: - MainWindow *parentWindow; + MainWindow *w; Ui::BookmarksDialog *ui; Xbel *xbel; }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 29b7e66..45d0b55 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -34,9 +34,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : QMainWindow(parent), - downloadManager(new DownloadDialog(this)), blocklistManager(new BlockerDialog(this)), - bookmarkManager(new BookmarksDialog(this)), ui(new Ui::MainWindow), navigationToolBar(new QToolBar(tr("Navigation"), this)), tabToolBar(new QToolBar(tr("Tab bar"), this)), @@ -65,9 +63,13 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : // Tools menu QMenu *toolsMenu = new QMenu(tr("Tools"), ui->menuBar); ui->menuBar->addMenu(toolsMenu); - toolsMenu->addAction(tr("Downloads"), downloadManager, SLOT(show())); + toolsMenu->addAction(tr("Downloads"), Browser::instance()->downloads(), SLOT(show())); toolsMenu->addAction(tr("Blocker"), blocklistManager, SLOT(show())); - toolsMenu->addAction(tr("Bookmarks"), bookmarkManager, SLOT(show())); + QAction *bookmarksAction = toolsMenu->addAction(tr("Bookmarks")); + bookmarksAction->setShortcut(QKeySequence(settings.value("shortcuts/bookmarks").toString())); + connect(bookmarksAction, &QAction::triggered, [this](){ + Browser::instance()->bookmarks()->show(this); + }); // Profile menu QMenu *profileMenu = new QMenu(tr("Profile"), ui->menuBar); @@ -160,7 +162,7 @@ void MainWindow::loadProfile(const QString &name) UrlRequestInterceptor *interceptor = new UrlRequestInterceptor(this); interceptor->setSubscription(blocklistManager->subscription()); profile->setRequestInterceptor(interceptor); - connect(profile, SIGNAL(downloadRequested(QWebEngineDownloadItem*)), downloadManager, SLOT(addDownload(QWebEngineDownloadItem*))); + connect(profile, SIGNAL(downloadRequested(QWebEngineDownloadItem*)), Browser::instance()->downloads(), SLOT(addDownload(QWebEngineDownloadItem*))); } void MainWindow::loadProfileGUI() diff --git a/src/mainwindow.h b/src/mainwindow.h index bee1aab..a93935b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -28,11 +28,9 @@ #include "webengine/webengineprofile.h" #include <QUrl> #include "widgets/webviewtabbar.h" -#include "forms/downloaddialog.h" #include "webengine/urlinterceptor.h" #include "forms/blockerdialog.h" #include "widgets/loadingbar.h" -#include "forms/bookmarksdialog.h" namespace Ui { class MainWindow; @@ -66,9 +64,7 @@ private slots: void handleTitleUpdated(const QString &title); private: - DownloadDialog *downloadManager; BlockerDialog *blocklistManager; - BookmarksDialog *bookmarkManager; QString profileName; WebEngineProfile *profile = nullptr; diff --git a/test/blocklist.txt b/test/blocklist.txt index 1c3af75..f67b77c 100644 --- a/test/blocklist.txt +++ b/test/blocklist.txt @@ -1,20 +1,9 @@ [Adblock Plus 2.0] -! Version: 201701171603 -! Title: EasyList -! Last modified: 17 Jan 2017 16:03 UTC +! Version: 0 +! Title: Test blocklist +! Last modified: 5 Feb 2017 00:00 UTC ! Expires: 4 days (update frequency) -! Homepage: https://easylist.to/ -! Licence: https://easylist.to/pages/licence.html -! -! Please report any unblocked adverts or problems -! in the forums (https://forums.lanik.us/) -! or via e-mail (easylist.subscription@gmail.com). -! -! -----------------------General advert blocking filters-----------------------! -!css -!@@s1256.css -!@@t1256.css +! Homepage: https://gitlab.com/xiannox/smolbote +! Licence: n/a -!font/*woff - -!duckduckgo.com^ +||duckduckgo.com^t1256.css diff --git a/test/config.ini b/test/config.ini index db6c896..afba450 100644 --- a/test/config.ini +++ b/test/config.ini @@ -12,3 +12,6 @@ path=bookmarks.xbel [window] height=720 width=1280 + +[shortcuts] +bookmarks=Ctrl+Shift+B |