diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/application.cpp | 25 | ||||
-rw-r--r-- | src/plugins/test/pluginloader.cpp | 2 | ||||
-rw-r--r-- | src/rekonq.kcfg | 4 | ||||
-rw-r--r-- | src/rekonq_defines.h | 18 | ||||
-rw-r--r-- | src/rekonqwindow.cpp | 69 | ||||
-rw-r--r-- | src/rekonqwindow.hpp | 12 | ||||
-rw-r--r-- | src/settings/test/rekonqrc | 5 | ||||
-rw-r--r-- | src/settings/test/test_settings.cpp | 6 |
8 files changed, 57 insertions, 84 deletions
diff --git a/src/application.cpp b/src/application.cpp index 944d6ea1..295d2708 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -20,10 +20,6 @@ #include <QStandardPaths> #include <spdlog/spdlog.h> -#ifdef QT_DEBUG -#include "test/rview_fake.h" -#endif - // --------------------------------------------------------------------------------------------------------------- // Ctor and Dtor @@ -388,20 +384,19 @@ RekonqWindow *Application::newWindow() RekonqView *Application::newView(const QUrl &url, RekonqWindow *window) { RekonqView *view = nullptr; + const auto _url = url.isEmpty() ? m_settings->value("homepage").toUrl() : url; -#ifdef QT_DEBUG - if (url.isEmpty()) view = new RekonqView_fake(window); -#endif - - if (view == nullptr) - for (const auto &plugin : m_plugins) { - if (plugin->hasScheme(url.scheme())) { - view = plugin->interface()->view(url.isEmpty() ? m_settings->value("homepage").toUrl() : url); - break; - } + for (const auto &plugin : m_plugins) { + if (plugin->hasScheme(_url.scheme())) { + view = plugin->interface()->view(_url); + break; } + } - if (view == nullptr) return view; + if (view == nullptr) { + spdlog::error("Cannot find plugin for url={}", qUtf8Printable(_url.toString())); + return view; + } Q_CHECK_PTR(view); // tab->installEventFilter(this); diff --git a/src/plugins/test/pluginloader.cpp b/src/plugins/test/pluginloader.cpp index 7c2791a4..0a11246e 100644 --- a/src/plugins/test/pluginloader.cpp +++ b/src/plugins/test/pluginloader.cpp @@ -28,6 +28,8 @@ TEST_F(PluginLoaderTest, InterfaceTest) // check available schemes EXPECT_FALSE(loader->schemes().isEmpty()); + // all plugins should be able to display an about:blank page + EXPECT_TRUE(loader->hasScheme("about")); // check interface cast EXPECT_FALSE(loader->interface() == nullptr); diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 0b23782e..f3013859 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -18,10 +18,10 @@ <default>TODO: change type to StringList</default> </entry> <entry name="Home page URL" key="homepage" type="String"> - <default>http://www.kde.org/</default> + <default>about:blank</default> </entry> <entry name="New tab URL" key="newtab" type="String"> - <default>http://www.kde.org/</default> + <default>about:blank</default> </entry> <entry name="Default Search Engine" key="searchUrl" type="String"> <default>https://duckduckgo.com/?q=%1</default> diff --git a/src/rekonq_defines.h b/src/rekonq_defines.h index f56cb5fa..088478bd 100644 --- a/src/rekonq_defines.h +++ b/src/rekonq_defines.h @@ -12,7 +12,7 @@ #pragma once -// ---------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------ // UNIT TESTS NEED #ifdef REKONQ_TEST #define REKONQ_TEST_VIRTUAL virtual @@ -22,25 +22,19 @@ #define REKONQ_TEST_PURE #endif -// ---------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------ // Defines #define QL1S(x) QLatin1String(x) #define QL1C(x) QLatin1Char(x) -#ifndef ASSERT_NOT_REACHED -# ifndef QT_NO_DEBUG -# define ASSERT_NOT_REACHED(msg) qt_assert(#msg,__FILE__,__LINE__); kDebug() << #msg -# else -# define ASSERT_NOT_REACHED(msg) kDebug() << #msg -# endif -#endif //ASSERT_NOT_REACHED - -// -------------------------------------------------------------------------------------- +// ------------------------------------------------------------ // Enums namespace rekonq { +enum DefaultUrl { NewTabPage, HomePage, AboutBlank }; + /** * @short Open link options * Different modes of opening new tab @@ -68,5 +62,3 @@ enum SyncData }; } // namespace rekonq - -// ---------------------------------------------------------------------------------------------------- diff --git a/src/rekonqwindow.cpp b/src/rekonqwindow.cpp index 094dc1ff..ef772936 100644 --- a/src/rekonqwindow.cpp +++ b/src/rekonqwindow.cpp @@ -15,6 +15,10 @@ #include <rsettings.hpp> #include <rview.hpp> +#ifdef QT_DEBUG +#include "test/rview_fake.h" +#endif + RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::RekonqWindow) { ui->setupUi(this); @@ -31,16 +35,19 @@ RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Re connect(ui->back, &QToolButton::clicked, this, [this]() { currentView()->back(); }); connect(ui->forward, &QToolButton::clicked, this, [this]() { currentView()->forward(); }); connect(ui->refresh, &QToolButton::clicked, this, [this]() { currentView()->refresh(); }); - connect(ui->home, &QToolButton::clicked, this, [this]() { loadUrl(QUrl()); }); + connect(ui->home, &QToolButton::clicked, this, [this]() { loadUrl(rekonq::HomePage, rekonq::CurrentTab); }); // connect menu actions // file menu - connect(ui->actionNewTab, &QAction::triggered, this, [this]() { - auto *app = Application::instance(); - Q_CHECK_PTR(app); - auto newTabUrl = app->settings()->value("newtab").toUrl(); - loadUrl(newTabUrl, rekonq::NewFocusedTab); - }); +#ifdef QT_DEBUG + { + auto *actionNewDebugTab = new QAction(tr("New Debug Tab"), ui->menuFile); + connect(actionNewDebugTab, &QAction::triggered, this, [this]() { addView(new RekonqView_fake(this)); }); + ui->menuFile->insertAction(ui->actionNewTab, actionNewDebugTab); + } +#endif + connect(ui->actionNewTab, &QAction::triggered, this, + [this]() { loadUrl(rekonq::NewTabPage, rekonq::NewFocusedTab); }); connect(ui->actionCloseTab, &QAction::triggered, this, [this]() { emit ui->tabs->tabCloseRequested(ui->tabs->currentIndex()); }); connect(ui->actionQuit, &QAction::triggered, qApp, &QApplication::quit); @@ -55,8 +62,7 @@ RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Re // help menu connect(ui->actionAboutQt, &QAction::triggered, qApp, &QApplication::aboutQt); - connect(ui->newTab, &QToolButton::clicked, this, - [this]() { Application::instance()->newView(QUrl("about:blank"), this); }); + connect(ui->newTab, &QToolButton::clicked, ui->actionNewTab, &QAction::trigger); } RekonqWindow::~RekonqWindow() { delete ui; } @@ -95,6 +101,22 @@ int RekonqWindow::addView(RekonqView *view) return index; } +void RekonqWindow::loadUrl(rekonq::DefaultUrl url, rekonq::OpenType type) +{ + auto *settings = Application::instance()->settings(); + switch (url) { + case rekonq::NewTabPage: + loadUrl(settings->value("newtab").toUrl(), type); + break; + case rekonq::HomePage: + loadUrl(settings->value("homepage").toUrl(), type); + break; + case rekonq::AboutBlank: + loadUrl(QUrl("about:blank"), type); + break; + } +} + void RekonqWindow::loadUrl(const QUrl &url, rekonq::OpenType type) { switch (type) { @@ -122,35 +144,6 @@ void RekonqWindow::loadUrl(const QUrl &url, rekonq::OpenType type) // -------------------------------------------------------------------------------------------------- /* -bool RekonqWindow::isPrivateBrowsingMode() -{ - return _tabWidget->isPrivateBrowsingWindowMode(); -} - - - - -void RekonqWindow::loadUrl(const KUrl &url, Rekonq::OpenType type, TabHistory *history) -{ - switch (type) - { - case Rekonq::NewWindow: - case Rekonq::NewPrivateWindow: - case Rekonq::WebApp: - rApp->loadUrl(url, type); - return; - - case Rekonq::NewTab: - case Rekonq::NewBackGroundTab: - case Rekonq::NewFocusedTab: - case Rekonq::CurrentTab: - default: - _tabWidget->loadUrl(url, type, history); - break; - }; -} - - void RekonqWindow::showBookmarksPanel(bool on) { if (on) diff --git a/src/rekonqwindow.hpp b/src/rekonqwindow.hpp index ba1fd70f..742adbdb 100644 --- a/src/rekonqwindow.hpp +++ b/src/rekonqwindow.hpp @@ -12,18 +12,11 @@ #pragma once #include "rekonq.hpp" -//#include "rwindow.h" -//#include "tabwidget.h" -//#include "bookmarkspanel.h" -//#include "historypanel.h" #include <QMainWindow> #include <QSplitter> // Forward Declarations class RekonqView; -// class TabBar; -// class WebPage; -// class WebWindow; namespace Ui { class RekonqWindow; @@ -38,10 +31,9 @@ public: [[nodiscard]] RekonqView *currentView(); - // bool isPrivateBrowsingMode(); - public slots: int addView(RekonqView *view); + void loadUrl(rekonq::DefaultUrl url, rekonq::OpenType type = rekonq::CurrentTab); void loadUrl(const QUrl &url, rekonq::OpenType type = rekonq::CurrentTab); // void loadUrl(const KUrl &, Rekonq::OpenType type = Rekonq::CurrentTab, TabHistory *history = 0); @@ -51,10 +43,8 @@ private slots: private: Ui::RekonqWindow *ui; - // TabWidget *_tabWidget; QSplitter *_splitter = nullptr; - // QWeakPointer<HistoryPanel> _historyPanel; // QWeakPointer<BookmarksPanel> _bookmarksPanel; }; diff --git a/src/settings/test/rekonqrc b/src/settings/test/rekonqrc index 97329a6d..fe67194c 100644 --- a/src/settings/test/rekonqrc +++ b/src/settings/test/rekonqrc @@ -1,8 +1,8 @@ [General] FirstRun=true lang=TODO: change type to StringList -homepage=http://www.kde.org/ -newtab=http://www.kde.org/ +homepage=about:blank +newtab=about:blank searchUrl=https://duckduckgo.com/?q=%1 pluginPath=TODO: change type to Path @@ -12,6 +12,7 @@ downloadPathAsk=true userAgent=TODO [Appearance] +IconTheme=tabler defaultFontSize=16 minFontSize=7 defaultEncoding=ISO 8859-1 diff --git a/src/settings/test/test_settings.cpp b/src/settings/test/test_settings.cpp index 24bbf349..6efc64c3 100644 --- a/src/settings/test/test_settings.cpp +++ b/src/settings/test/test_settings.cpp @@ -86,14 +86,14 @@ TEST(settings, SettingsDialog) // 1 setting is hidden and won't be set by the dialog // save and reset will both call setValue on all non-hidden settings EXPECT_CALL(mockSettings, setValue(_, _)).Times(n_settings * 2 - 3); - EXPECT_CALL(mockSettings, setValue(QStringEq("homepage"), QVariantEq("about:blank"))); + EXPECT_CALL(mockSettings, setValue(QStringEq("homepage"), QVariantEq("https://kde.org"))); // change setting { SettingsDialog dlg(&mockSettings); auto *homepage = dlg.findChild<QLineEdit *>("homepage"); - EXPECT_TRUE(homepage->text() == QLatin1String("http://www.kde.org/")) << qUtf8Printable(homepage->text()); - homepage->setText("about:blank"); + EXPECT_TRUE(homepage->text() == QLatin1String("about:blank")) << qUtf8Printable(homepage->text()); + homepage->setText("https://kde.org"); dlg.accept(); } |