1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
/*
This file is part of the KDE project
SPDX-FileCopyrightText: 1998, 1999 Torben Weis <weis@kde.org>
SPDX-FileCopyrightText: 2006 Daniel Teske <teske@squorn.de>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kbookmarkaction.h"
#include "kbookmarkowner.h"
#include <QDesktopServices>
#include <QGuiApplication>
KBookmarkAction::KBookmarkAction(const KBookmark &bk, KBookmarkOwner *owner, QObject *parent)
: QAction(bk.text().replace(QLatin1Char('&'), QLatin1String("&&")), parent)
, KBookmarkActionInterface(bk)
, m_pOwner(owner)
{
setIcon(QIcon::fromTheme(bookmark().icon()));
setIconText(text());
setToolTip(bookmark().url().toDisplayString(QUrl::PreferLocalFile));
setStatusTip(toolTip());
setWhatsThis(toolTip());
const QString description = bk.description();
if (!description.isEmpty()) {
setToolTip(description);
}
connect(this, &QAction::triggered, this, &KBookmarkAction::slotTriggered);
}
KBookmarkAction::~KBookmarkAction()
{
}
void KBookmarkAction::slotTriggered()
{
slotSelected(QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
}
void KBookmarkAction::slotSelected(Qt::MouseButtons mb, Qt::KeyboardModifiers km)
{
if (!m_pOwner) {
QDesktopServices::openUrl(bookmark().url());
} else {
m_pOwner->openBookmark(bookmark(), mb, km);
}
}
#include "moc_kbookmarkaction.cpp"
|