Warning, file /frameworks/kbookmarks/src/kbookmarkaction.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 1998, 1999 Torben Weis <weis@kde.org>
0004     SPDX-FileCopyrightText: 2006 Daniel Teske <teske@squorn.de>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include "kbookmarkaction.h"
0010 #include "kbookmarkowner.h"
0011 
0012 #include <QApplication>
0013 #include <QDesktopServices>
0014 
0015 KBookmarkAction::KBookmarkAction(const KBookmark &bk, KBookmarkOwner *owner, QObject *parent)
0016     : QAction(bk.text().replace(QLatin1Char('&'), QLatin1String("&&")), parent)
0017     , KBookmarkActionInterface(bk)
0018     , m_pOwner(owner)
0019 {
0020     setIcon(QIcon::fromTheme(bookmark().icon()));
0021     setIconText(text());
0022     setToolTip(bookmark().url().toDisplayString(QUrl::PreferLocalFile));
0023     setStatusTip(toolTip());
0024     setWhatsThis(toolTip());
0025     const QString description = bk.description();
0026     if (!description.isEmpty()) {
0027         setToolTip(description);
0028     }
0029     connect(this, &QAction::triggered, this, &KBookmarkAction::slotTriggered);
0030 }
0031 
0032 KBookmarkAction::~KBookmarkAction()
0033 {
0034 }
0035 
0036 void KBookmarkAction::slotTriggered()
0037 {
0038     slotSelected(QApplication::mouseButtons(), QApplication::keyboardModifiers());
0039 }
0040 
0041 void KBookmarkAction::slotSelected(Qt::MouseButtons mb, Qt::KeyboardModifiers km)
0042 {
0043     if (!m_pOwner) {
0044         QDesktopServices::openUrl(bookmark().url());
0045     } else {
0046         m_pOwner->openBookmark(bookmark(), mb, km);
0047     }
0048 }