KBookmarks

kbookmarkaction.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 1998, 1999 Torben Weis <[email protected]>
3  Copyright (C) 2006 Daniel Teske <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "kbookmarkaction.h"
22 #include "kbookmarkowner.h"
23 #include <QDesktopServices>
24 #include <QApplication>
25 
26 KBookmarkAction::KBookmarkAction(const KBookmark &bk, KBookmarkOwner *owner, QObject *parent)
27  : QAction(bk.text().replace(QLatin1Char('&'), QLatin1String("&&")), parent),
28  KBookmarkActionInterface(bk),
29  m_pOwner(owner)
30 {
31  setIcon(QIcon::fromTheme(bookmark().icon()));
32  setIconText(text());
33  setToolTip(bookmark().url().toDisplayString(QUrl::PreferLocalFile));
34  setStatusTip(toolTip());
35  setWhatsThis(toolTip());
36  const QString description = bk.description();
37  if (!description.isEmpty()) {
38  setToolTip(description);
39  }
40  connect(this, &QAction::triggered, this, &KBookmarkAction::slotTriggered);
41 }
42 
43 KBookmarkAction::~KBookmarkAction()
44 {
45 }
46 
47 void KBookmarkAction::slotTriggered()
48 {
50 }
51 
52 void KBookmarkAction::slotSelected(Qt::MouseButtons mb, Qt::KeyboardModifiers km)
53 {
54  if (!m_pOwner) {
55  QDesktopServices::openUrl(bookmark().url());
56  } else {
57  m_pOwner->openBookmark(bookmark(), mb, km);
58  }
59 }
60 
typedef KeyboardModifiers
void triggered(bool checked)
typedef MouseButtons
Qt::KeyboardModifiers keyboardModifiers()
bool isEmpty() const const
Qt::MouseButtons mouseButtons()
The KBookmarkMenu and KBookmarkBar classes gives the user the ability to either edit bookmarks or add...
const QList< QKeySequence > & replace()
QIcon fromTheme(const QString &name)
bool openUrl(const QUrl &url)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 1 2020 22:43:39 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.