Commit 74f7e064 authored by Mikhail Zolotukhin's avatar Mikhail Zolotukhin
Browse files

[App Style KCM] Hide preview buttons, if previewers are not found

Summary:
BUG: 416343
FIXED-IN: 5.18.0

Test Plan:
# Open GTK page of Application Style KCM, the preview buttons should be present
# Delete `usr/lib/libexec/gtk_preview` file or rename it to something else
# Reopen GTK page of KCM - the GTK2 preview button should disappear
# Delete `usr/lib/libexec/gtk3_preview` file or rename it to something else
# Reopen GTK page of KCM - the GTK3 preview button should disappear too
# Bring back the deleted/renamed files
# Reopen KCM, the buttons should be present

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26770
parent 81e9f43d
...@@ -21,6 +21,8 @@ kconfig_add_kcfg_files(kcm_style_PART_SRCS stylesettings.kcfgc GENERATE_MOC) ...@@ -21,6 +21,8 @@ kconfig_add_kcfg_files(kcm_style_PART_SRCS stylesettings.kcfgc GENERATE_MOC)
add_library(kcm_style MODULE ${kcm_style_PART_SRCS}) add_library(kcm_style MODULE ${kcm_style_PART_SRCS})
target_compile_definitions(kcm_style PUBLIC CMAKE_INSTALL_FULL_LIBEXECDIR="${CMAKE_INSTALL_FULL_LIBEXECDIR}")
target_link_libraries(kcm_style target_link_libraries(kcm_style
Qt5::X11Extras Qt5::X11Extras
Qt5::DBus Qt5::DBus
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QUrl> #include <QUrl>
#include <QDBusInterface> #include <QDBusInterface>
#include <QDBusReply> #include <QDBusReply>
#include <QStandardPaths>
#include <KTar> #include <KTar>
#include <KLocalizedString> #include <KLocalizedString>
...@@ -69,6 +70,16 @@ QString GtkPage::gtk3ThemeFromConfig() ...@@ -69,6 +70,16 @@ QString GtkPage::gtk3ThemeFromConfig()
return dbusReply.value(); return dbusReply.value();
} }
bool GtkPage::gtk2PreviewAvailable()
{
return !QStandardPaths::findExecutable(QStringLiteral("gtk_preview"), {CMAKE_INSTALL_FULL_LIBEXECDIR}).isEmpty();
}
bool GtkPage::gtk3PreviewAvailable()
{
return !QStandardPaths::findExecutable(QStringLiteral("gtk3_preview"), {CMAKE_INSTALL_FULL_LIBEXECDIR}).isEmpty();
}
void GtkPage::showGtk2Preview() void GtkPage::showGtk2Preview()
{ {
gtkConfigInterface.call(QStringLiteral("showGtk2ThemePreview"), m_gtk2ThemesModel->selectedTheme()); gtkConfigInterface.call(QStringLiteral("showGtk2ThemePreview"), m_gtk2ThemesModel->selectedTheme());
......
...@@ -45,6 +45,9 @@ public Q_SLOTS: ...@@ -45,6 +45,9 @@ public Q_SLOTS:
QString gtk2ThemeFromConfig(); QString gtk2ThemeFromConfig();
QString gtk3ThemeFromConfig(); QString gtk3ThemeFromConfig();
bool gtk2PreviewAvailable();
bool gtk3PreviewAvailable();
void showGtk2Preview(); void showGtk2Preview();
void showGtk3Preview(); void showGtk3Preview();
......
...@@ -89,6 +89,7 @@ Kirigami.Page { ...@@ -89,6 +89,7 @@ Kirigami.Page {
icon.name: "preview" icon.name: "preview"
text: i18n("Preview...") text: i18n("Preview...")
onClicked: kcm.gtkPage.showGtk2Preview() onClicked: kcm.gtkPage.showGtk2Preview()
visible: kcm.gtkPage.gtk2PreviewAvailable()
} }
} }
} }
...@@ -128,6 +129,7 @@ Kirigami.Page { ...@@ -128,6 +129,7 @@ Kirigami.Page {
icon.name: "preview" icon.name: "preview"
text: i18n("Preview...") text: i18n("Preview...")
onClicked: kcm.gtkPage.showGtk3Preview() onClicked: kcm.gtkPage.showGtk3Preview()
visible: kcm.gtkPage.gtk3PreviewAvailable()
} }
} }
......
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