KBookmarks

kbookmarkaction.cpp
1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 1998, 1999 Torben Weis <weis@kde.org>
4 SPDX-FileCopyrightText: 2006 Daniel Teske <teske@squorn.de>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#include "kbookmarkaction.h"
10#include "kbookmarkowner.h"
11
12#include <QDesktopServices>
13#include <QGuiApplication>
14
15KBookmarkAction::KBookmarkAction(const KBookmark &bk, KBookmarkOwner *owner, QObject *parent)
16 : QAction(bk.text().replace(QLatin1Char('&'), QLatin1String("&&")), parent)
18 , m_pOwner(owner)
19{
20 setIcon(QIcon::fromTheme(bookmark().icon()));
21 setIconText(text());
22 setToolTip(bookmark().url().toDisplayString(QUrl::PreferLocalFile));
23 setStatusTip(toolTip());
24 setWhatsThis(toolTip());
25 const QString description = bk.description();
26 if (!description.isEmpty()) {
27 setToolTip(description);
28 }
29 connect(this, &QAction::triggered, this, &KBookmarkAction::slotTriggered);
30}
31
32KBookmarkAction::~KBookmarkAction()
33{
34}
35
36void KBookmarkAction::slotTriggered()
37{
39}
40
41void KBookmarkAction::slotSelected(Qt::MouseButtons mb, Qt::KeyboardModifiers km)
42{
43 if (!m_pOwner) {
44 QDesktopServices::openUrl(bookmark().url());
45 } else {
46 m_pOwner->openBookmark(bookmark(), mb, km);
47 }
48}
49
50#include "moc_kbookmarkaction.cpp"
The interface to implement by actions and menus which represent a bookimark.
The KBookmarkMenu and KBookmarkBar classes gives the user the ability to either edit bookmarks or add...
virtual void openBookmark(const KBookmark &bm, Qt::MouseButtons mb, Qt::KeyboardModifiers km)=0
Called if a bookmark is selected.
A class representing a bookmark.
Definition kbookmark.h:27
QString description() const
const QList< QKeySequence > & replace()
void triggered(bool checked)
bool openUrl(const QUrl &url)
Qt::KeyboardModifiers keyboardModifiers()
Qt::MouseButtons mouseButtons()
QIcon fromTheme(const QString &name)
bool isEmpty() const const
typedef KeyboardModifiers
typedef MouseButtons
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
PreferLocalFile
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.