Fix Bug 362152 - Font selection is not honored
[kdepim.git] / sieveeditor / sieveeditorbookmarks.cpp
blobb4141d6227e0299f6b119e782d4427e54a9bf4d8
1 /*
2 Copyright (c) 2015-2016 Montel Laurent <montel@kde.org>
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
21 #include "sieveeditorbookmarks.h"
22 #include "sieveeditormainwindow.h"
23 #include <QStandardPaths>
24 #include <kbookmarkmanager.h>
25 #include <KBookmarkMenu>
26 #include <QDir>
28 SieveEditorBookmarks::SieveEditorBookmarks(SieveEditorMainWindow *mainWindow, KActionCollection *collection, QMenu *menu, QObject *parent)
29 : QObject(parent),
30 KBookmarkOwner(),
31 mBookmarkMenu(Q_NULLPTR),
32 mMenu(menu),
33 mMainWindow(mainWindow)
35 QString bookmarkFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sieveeditor/bookmarks.xml"));
37 if (bookmarkFile.isEmpty()) {
38 bookmarkFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/sieveeditor");
39 QDir().mkpath(bookmarkFile);
40 bookmarkFile += QStringLiteral("/bookmarks.xml");
43 KBookmarkManager *manager = KBookmarkManager::managerForFile(bookmarkFile, QStringLiteral("sieveeditor"));
44 manager->setUpdate(true);
46 mBookmarkMenu = new KBookmarkMenu(manager, this, mMenu, collection);
49 SieveEditorBookmarks::~SieveEditorBookmarks()
51 delete mBookmarkMenu;
54 QMenu *SieveEditorBookmarks::menu() const
56 return mMenu;
59 void SieveEditorBookmarks::openBookmark(const KBookmark &bm, Qt::MouseButtons mb, Qt::KeyboardModifiers km)
61 Q_UNUSED(mb);
62 Q_UNUSED(km);
63 Q_EMIT openUrl(bm.url());
66 QString SieveEditorBookmarks::currentTitle() const
68 return mMainWindow->currentHelpTitle();
71 QUrl SieveEditorBookmarks::currentUrl() const
73 return mMainWindow->currentHelpUrl();