[plasmalnf] Add auto-detection of Plasma theme.
- Although it's not necessarily accurate for an extensively-modified Plasma configuration, we can read the Look-and-Feel from the configuration files. Allows auto-detection.
This commit is contained in:
parent
11652c5856
commit
c2efae765d
@ -4,8 +4,13 @@ find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
|
|||||||
# needs a runtime support component (which we don't test for).
|
# needs a runtime support component (which we don't test for).
|
||||||
set( lnf_ver 5.41 )
|
set( lnf_ver 5.41 )
|
||||||
|
|
||||||
|
find_package( KF5Config ${lnf_ver} )
|
||||||
find_package( KF5Plasma ${lnf_ver} )
|
find_package( KF5Plasma ${lnf_ver} )
|
||||||
find_package( KF5Package ${lnf_ver} )
|
find_package( KF5Package ${lnf_ver} )
|
||||||
|
set_package_properties(
|
||||||
|
KF5Config PROPERTIES
|
||||||
|
PURPOSE "For finding default Plasma Look-and-Feel"
|
||||||
|
)
|
||||||
set_package_properties(
|
set_package_properties(
|
||||||
KF5Plasma PROPERTIES
|
KF5Plasma PROPERTIES
|
||||||
PURPOSE "For Plasma Look-and-Feel selection"
|
PURPOSE "For Plasma Look-and-Feel selection"
|
||||||
@ -16,11 +21,19 @@ set_package_properties(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if ( KF5Plasma_FOUND AND KF5Package_FOUND )
|
if ( KF5Plasma_FOUND AND KF5Package_FOUND )
|
||||||
find_package( KF5 ${lnf_ver} REQUIRED CoreAddons Plasma Package )
|
if ( KF5Config_FOUND )
|
||||||
|
set( option_kf5 Config )
|
||||||
|
set( option_defs WITH_KCONFIG )
|
||||||
|
# set( option_libs KF5::Config ) # Not needed anyway
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package( KF5 ${lnf_ver} REQUIRED CoreAddons Plasma Package ${option_kf5} )
|
||||||
|
|
||||||
calamares_add_plugin( plasmalnf
|
calamares_add_plugin( plasmalnf
|
||||||
TYPE viewmodule
|
TYPE viewmodule
|
||||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||||
|
COMPILE_DEFINITIONS
|
||||||
|
${option_defs}
|
||||||
SOURCES
|
SOURCES
|
||||||
PlasmaLnfViewStep.cpp
|
PlasmaLnfViewStep.cpp
|
||||||
PlasmaLnfPage.cpp
|
PlasmaLnfPage.cpp
|
||||||
@ -32,6 +45,7 @@ if ( KF5Plasma_FOUND AND KF5Package_FOUND )
|
|||||||
page_plasmalnf.ui
|
page_plasmalnf.ui
|
||||||
LINK_PRIVATE_LIBRARIES
|
LINK_PRIVATE_LIBRARIES
|
||||||
calamaresui
|
calamaresui
|
||||||
|
${option_libs}
|
||||||
KF5::Package
|
KF5::Package
|
||||||
KF5::Plasma
|
KF5::Plasma
|
||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
|
@ -26,8 +26,25 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
#ifdef WITH_KCONFIG
|
||||||
|
#include <KConfigGroup>
|
||||||
|
#include <KSharedConfig>
|
||||||
|
#endif
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfViewStepFactory, registerPlugin<PlasmaLnfViewStep>(); )
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfViewStepFactory, registerPlugin<PlasmaLnfViewStep>(); )
|
||||||
|
|
||||||
|
static QString
|
||||||
|
currentPlasmaTheme()
|
||||||
|
{
|
||||||
|
#ifdef WITH_KCONFIG
|
||||||
|
KConfigGroup cg( KSharedConfig::openConfig( QStringLiteral( "kdeglobals" ) ), "KDE" );
|
||||||
|
return cg.readEntry( "LookAndFeelPackage", QString() );
|
||||||
|
#else
|
||||||
|
cWarning() << "No KConfig support, cannot determine Plasma theme.";
|
||||||
|
return QString();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
PlasmaLnfViewStep::PlasmaLnfViewStep( QObject* parent )
|
PlasmaLnfViewStep::PlasmaLnfViewStep( QObject* parent )
|
||||||
: Calamares::ViewStep( parent )
|
: Calamares::ViewStep( parent )
|
||||||
, m_widget( new PlasmaLnfPage )
|
, m_widget( new PlasmaLnfPage )
|
||||||
@ -140,6 +157,8 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
QString preselect;
|
QString preselect;
|
||||||
if ( configurationMap.contains( "preselect" ) && configurationMap.value( "preselect" ).type() == QVariant::String )
|
if ( configurationMap.contains( "preselect" ) && configurationMap.value( "preselect" ).type() == QVariant::String )
|
||||||
preselect = configurationMap.value( "preselect" ).toString();
|
preselect = configurationMap.value( "preselect" ).toString();
|
||||||
|
if ( preselect == QStringLiteral( "*" ) )
|
||||||
|
preselect = currentPlasmaTheme();
|
||||||
if ( !preselect.isEmpty() )
|
if ( !preselect.isEmpty() )
|
||||||
m_widget->setPreselect( preselect );
|
m_widget->setPreselect( preselect );
|
||||||
|
|
||||||
|
@ -38,4 +38,8 @@ themes:
|
|||||||
# If this key is present, its value should be the id of the theme
|
# If this key is present, its value should be the id of the theme
|
||||||
# which should be pre-selected. If absent, empty, or the pre-selected
|
# which should be pre-selected. If absent, empty, or the pre-selected
|
||||||
# theme is not found on the live system, no theme will be pre-selected.
|
# theme is not found on the live system, no theme will be pre-selected.
|
||||||
preselect: org.kde.breeze.desktop
|
#
|
||||||
|
# As a special setting, use "*", to try to find the currently-
|
||||||
|
# selected theme by reading the Plasma configuration. This requires
|
||||||
|
# KF5::Config at build- and run-time.
|
||||||
|
preselect: "*"
|
||||||
|
Loading…
Reference in New Issue
Block a user