Commit 05db635c authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[applets/comic] Replace associated application URL with explicit action

Replace the 'Run the associated application' action with a 'View in $browser' action

This is more descriptive and avoids using a deprecated Plasma concept
parent ffd12608
Pipeline #207195 passed with stage
in 1 minute and 18 seconds
......@@ -28,9 +28,11 @@
#include <QWindow>
#include <KActionCollection>
#include <KApplicationTrader>
#include <KConfigDialog>
#include <KIO/OpenUrlJob>
#include <KNotification>
#include <KService>
#include <KStandardShortcut>
#include <kuiserverjobtracker.h>
......@@ -101,6 +103,18 @@ void ComicApplet::init()
mActions.append(mActionGoJump);
connect(mActionGoJump, &QAction::triggered, this, &ComicApplet::slotGoJump);
mActionWebsite = new QAction(i18nc("@action", "Visit the Website"), this);
KService::Ptr browser = KApplicationTrader::preferredService(QStringLiteral("x-scheme-handler/https"));
if (browser) {
mActionWebsite->setText(i18nc("@action:inmenu %1 is the name of a web browser", "View in %1", browser->name()));
mActionWebsite->setIcon(QIcon::fromTheme(browser->icon()));
}
mActionWebsite->setEnabled(false);
mActions.append(mActionWebsite);
connect(mActionWebsite, &QAction::triggered, this, &ComicApplet::slotWebsite);
mActionShop = new QAction(i18nc("@action", "Visit the Shop &Website"), this);
mActionShop->setEnabled(false);
mActions.append(mActionShop);
......@@ -186,8 +200,6 @@ void ComicApplet::dataUpdated(const ComicMetaData &data)
mCurrent.setData(data);
setAssociatedApplicationUrls(QList<QUrl>() << mCurrent.websiteUrl());
// looking at the last index, thus not mark it as new
KConfigGroup cg = config();
if (!mCurrent.hasNext() && mCheckNewComicStripsInterval) {
......@@ -411,6 +423,12 @@ void ComicApplet::slotStorePosition()
mCurrent.storePosition(mActionStorePosition->isChecked());
}
void ComicApplet::slotWebsite()
{
auto *job = new KIO::OpenUrlJob(mCurrent.websiteUrl());
job->start();
}
void ComicApplet::slotShop()
{
auto *job = new KIO::OpenUrlJob(mCurrent.shopUrl());
......@@ -503,6 +521,7 @@ void ComicApplet::updateContextMenu()
mActionGoFirst->setEnabled(false);
mActionGoLast->setEnabled(false);
mActionScaleContent->setEnabled(false);
mActionWebsite->setEnabled(false);
mActionShop->setEnabled(false);
mActionStorePosition->setEnabled(false);
mActionGoJump->setEnabled(false);
......@@ -513,6 +532,7 @@ void ComicApplet::updateContextMenu()
mActionGoFirst->setVisible(mCurrent.hasFirst());
mActionGoFirst->setEnabled(mCurrent.hasPrev());
mActionGoLast->setEnabled(true);
mActionWebsite->setEnabled(true);
mActionShop->setEnabled(mCurrent.shopUrl().isValid());
mActionScaleContent->setEnabled(true);
mActionStorePosition->setEnabled(true);
......
......@@ -131,6 +131,7 @@ private Q_SLOTS:
void slotSaveComicAs();
void slotScaleToContent();
void slotShop();
void slotWebsite();
void slotStorePosition();
void checkDayChanged();
void createComicBook();
......@@ -208,6 +209,7 @@ private:
QAction *mActionGoLast;
QAction *mActionGoJump;
QAction *mActionScaleContent;
QAction *mActionWebsite;
QAction *mActionShop;
QAction *mActionStorePosition;
QAction *mActionNextNewStripTab;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment