From 3d8255c70e71e3d4d23a7c798c94b16ab7e970f6 Mon Sep 17 00:00:00 2001 From: aqua Date: Sat, 10 Sep 2022 16:47:56 +0300 Subject: Add Bookmarks panel --- src/application.cpp | 54 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) (limited to 'src/application.cpp') diff --git a/src/application.cpp b/src/application.cpp index 38ad7477..0f86feec 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -5,13 +5,11 @@ * Copyright (C) 2012-2013 by Andrea Diamantini * SPDX-License-Identifier: GPL-3.0-only * Copyright (C) 2022 aqua - * ============================================================ - * Description: Application Main Class * ============================================================ */ #include "application.hpp" +#include "bookmarks/bookmarkstreemodel.hpp" #include "plugins/pluginloader.h" -#include "plugins/rplugininterface.hpp" #include "rekonqwindow.hpp" #include "settings/settings.hpp" #include "settings/settingsdialog.h" @@ -59,11 +57,6 @@ Application::Application(int &argc, char *argv[]) : SingleApplication(argc, argv Application::~Application() { - // ok, we are closing well: don't recover on next load.. - // ReKonfig::setRecoverOnCrash(0); - // saveConfiguration(); - delete m_settings; - // Destroy all windows... for (const auto &window : m_windows) delete window; @@ -75,6 +68,11 @@ Application::~Application() plugin->unload(); delete plugin; } + + // ok, we are closing well: don't recover on next load.. + // ReKonfig::setRecoverOnCrash(0); + // saveConfiguration(); + delete m_settings; } // --------------------------------------------------------------------------------------------------------------- @@ -95,7 +93,31 @@ bool Application::registerPlugin(const QString &path) m_plugins.append(loader); return true; } + // --------------------------------------------------------------------------------------------------------------- +// Bookmarks + +struct BookmarksModelPrivate { + + BookmarksModelPrivate() + { + model = new BookmarkModel; + const auto path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/bookmarks.xbel"; + spdlog::debug("Loading bookmarks from {}", qUtf8Printable(path)); + QFile f(path); + if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { + model->load(&f); + f.close(); + } + } + ~BookmarksModelPrivate() noexcept { delete model; } + + BookmarkModel *model; +}; +Q_GLOBAL_STATIC(BookmarksModelPrivate, bookmarks_d); + +QAbstractItemModel *Application::bookmarks() const { return bookmarks_d->model; } + /* int Application::newInstance() { @@ -409,22 +431,8 @@ RekonqView *Application::newView(const QUrl &url, RekonqWindow *window) return view; } -/* -RekonqWindowList Application::rekonqWindowList() -{ - return m_rekonqWindows; -} - - -WebAppList Application::webAppList() -{ - return m_webApps; -} - - // ------------------------------------------------------------------------------------------------------------------ - - +/* bool Application::eventFilter(QObject* watched, QEvent* event) { // Track which window was activated most recently to prefer it on window choosing -- cgit v1.2.1