Commit 369f86ee authored by Laurent Montel's avatar Laurent Montel 😁

Hide action if GHNS is disabled by KIOSK restriction

parent 847614a8
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <KToggleAction> #include <KToggleAction>
#include <KLocalizedString> #include <KLocalizedString>
#include <KNS3/DownloadDialog> #include <KNS3/DownloadDialog>
#include <KAuthorized>
#include <KCoreAddons/kaboutdata.h> #include <KCoreAddons/kaboutdata.h>
#include <KActionMenu> #include <KActionMenu>
#include <QDebug> #include <QDebug>
...@@ -50,15 +51,17 @@ public: ...@@ -50,15 +51,17 @@ public:
{ {
watch = new KDirWatch(q); watch = new KDirWatch(q);
initThemesDirectories(relativePath); initThemesDirectories(relativePath);
downloadThemesAction = new QAction(i18n("Download New Themes..."), q); if (KAuthorized::authorize(QStringLiteral("ghns"))) {
downloadThemesAction->setIcon(QIcon::fromTheme(QStringLiteral("get-hot-new-stuff"))); downloadThemesAction = new QAction(i18n("Download New Themes..."), q);
if (actionCollection) { downloadThemesAction->setIcon(QIcon::fromTheme(QStringLiteral("get-hot-new-stuff")));
actionCollection->addAction(QStringLiteral("download_header_themes"), downloadThemesAction); if (actionCollection) {
actionCollection->addAction(QStringLiteral("download_header_themes"), downloadThemesAction);
}
separatorAction = new QAction(q);
separatorAction->setSeparator(true);
q->connect(downloadThemesAction, SIGNAL(triggered(bool)), q, SLOT(slotDownloadHeaderThemes()));
} }
separatorAction = new QAction(q);
separatorAction->setSeparator(true);
q->connect(downloadThemesAction, SIGNAL(triggered(bool)), q, SLOT(slotDownloadHeaderThemes()));
q->connect(watch, SIGNAL(dirty(QString)), SLOT(directoryChanged())); q->connect(watch, SIGNAL(dirty(QString)), SLOT(directoryChanged()));
updateThemesPath(true); updateThemesPath(true);
...@@ -174,8 +177,10 @@ public: ...@@ -174,8 +177,10 @@ public:
actionCollection->removeAction(action); actionCollection->removeAction(action);
} }
} }
menu->removeAction(separatorAction); if (separatorAction) {
menu->removeAction(downloadThemesAction); menu->removeAction(separatorAction);
menu->removeAction(downloadThemesAction);
}
themesActionList.clear(); themesActionList.clear();
bool themeActivatedFound = false; bool themeActivatedFound = false;
...@@ -203,8 +208,10 @@ public: ...@@ -203,8 +208,10 @@ public:
selectTheme(act); selectTheme(act);
} }
} }
menu->addAction(separatorAction); if (separatorAction) {
menu->addAction(downloadThemesAction); menu->addAction(separatorAction);
menu->addAction(downloadThemesAction);
}
} }
void selectTheme(KToggleAction *act) void selectTheme(KToggleAction *act)
...@@ -267,9 +274,9 @@ public: ...@@ -267,9 +274,9 @@ public:
QActionGroup *actionGroup; QActionGroup *actionGroup;
KActionMenu *menu; KActionMenu *menu;
KActionCollection *actionCollection; KActionCollection *actionCollection;
QAction *separatorAction; QAction *separatorAction = nullptr;
QAction *downloadThemesAction; QAction *downloadThemesAction = nullptr;
QWeakPointer<KNS3::DownloadDialog> downloadThemesDialog; QWeakPointer<KNS3::DownloadDialog> downloadThemesDialog;
ThemeManager *q; ThemeManager *q;
}; };
......
Markdown is supported
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