properties on wether apply various sub parts

wilder-5.14
Marco Martin 12 years ago
parent 0a6c6aeb57
commit 80d9b3f96b
  1. 138
      kcms/lookandfeel/kcm.cpp
  2. 25
      kcms/lookandfeel/kcm.h

@ -46,6 +46,10 @@ KCMLookandFeel::KCMLookandFeel(QWidget* parent, const QVariantList& args)
: KCModule(parent, args)
, m_config("kdeglobals")
, m_configGroup(m_config.group("KDE"))
, m_applyColors(false)
, m_applyWidgetStyle(false)
, m_applyIcons(false)
, m_applyPlasmaTheme(false)
{
qmlRegisterType<QStandardItemModel>();
KAboutData* about = new KAboutData("kcm_lookandfeel", i18n("Configure Splash screen details"),
@ -152,29 +156,40 @@ void KCMLookandFeel::save()
if (!package.filePath("defaults").isEmpty()) {
KSharedConfigPtr conf = KSharedConfig::openConfig(package.filePath("defaults"));
KConfigGroup cg(conf, "KDE");
setWidgetStyle(cg.readEntry("widgetStyle", QString()));
QString colorsFile = package.filePath("colors");
QString colorScheme = cg.readEntry("ColorScheme", QString());
if (!colorsFile.isEmpty()) {
if (!colorScheme.isEmpty()) {
setColors(colorScheme, colorsFile);
} else {
setColors(package.metadata().name(), colorsFile);
if (m_applyWidgetStyle) {
setWidgetStyle(cg.readEntry("widgetStyle", QString()));
}
if (m_applyColors) {
QString colorsFile = package.filePath("colors");
QString colorScheme = cg.readEntry("ColorScheme", QString());
if (!colorsFile.isEmpty()) {
if (!colorScheme.isEmpty()) {
setColors(colorScheme, colorsFile);
} else {
setColors(package.metadata().name(), colorsFile);
}
} else if (!colorScheme.isEmpty()) {
colorScheme.remove('\''); // So Foo's does not become FooS
QRegExp fixer("[\\W,.-]+(.?)");
int offset;
while ((offset = fixer.indexIn(colorScheme)) >= 0)
colorScheme.replace(offset, fixer.matchedLength(), fixer.cap(1).toUpper());
colorScheme.replace(0, 1, colorScheme.at(0).toUpper());
QString src = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "color-schemes/" + colorScheme + ".colors");
setColors(colorScheme, src);
}
} else if (!colorScheme.isEmpty()) {
colorScheme.remove('\''); // So Foo's does not become FooS
QRegExp fixer("[\\W,.-]+(.?)");
int offset;
while ((offset = fixer.indexIn(colorScheme)) >= 0)
colorScheme.replace(offset, fixer.matchedLength(), fixer.cap(1).toUpper());
colorScheme.replace(0, 1, colorScheme.at(0).toUpper());
QString src = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "color-schemes/" + colorScheme + ".colors");
setColors(colorScheme, src);
}
cg = KConfigGroup(conf, "Icons");
setIcons(cg.readEntry("Theme", QString()));
if (m_applyIcons) {
cg = KConfigGroup(conf, "Icons");
setIcons(cg.readEntry("Theme", QString()));
}
if (m_applyPlasmaTheme) {
cg = KConfigGroup(conf, "PlasmaTheme");
setPlasmaTheme(cg.readEntry("name", QString()));
}
}
m_configGroup.sync();
@ -187,11 +202,19 @@ void KCMLookandFeel::defaults()
void KCMLookandFeel::setWidgetStyle(const QString &style)
{
if (style.isEmpty()) {
return;
}
m_configGroup.writeEntry("widgetStyle", style);
}
void KCMLookandFeel::setColors(const QString &scheme, const QString &colorFile)
{
if (scheme.isEmpty() || colorFile.isEmpty()) {
return;
}
m_configGroup.writeEntry("ColorScheme", scheme);
KSharedConfigPtr conf = KSharedConfig::openConfig(colorFile);
@ -204,8 +227,83 @@ void KCMLookandFeel::setColors(const QString &scheme, const QString &colorFile)
void KCMLookandFeel::setIcons(const QString &theme)
{
if (theme.isEmpty()) {
return;
}
KConfigGroup cg(&m_config, "Icons");
cg.writeEntry("Theme", theme);
}
void KCMLookandFeel::setPlasmaTheme(const QString &theme)
{
if (theme.isEmpty()) {
return;
}
KConfig config("plasmarc");
KConfigGroup cg(&config, "Theme");
cg.writeEntry("name", theme);
}
void KCMLookandFeel::setApplyColors(bool apply)
{
if (m_applyColors == apply) {
return;
}
m_applyColors = apply;
emit applyColorsChanged();
}
bool KCMLookandFeel::applyColors() const
{
return m_applyColors;
}
void KCMLookandFeel::setApplyWidgetStyle(bool apply)
{
if (m_applyWidgetStyle == apply) {
return;
}
m_applyWidgetStyle = apply;
emit applyWidgetStyleChanged();
}
bool KCMLookandFeel::applyWidgetStyle() const
{
return m_applyWidgetStyle;
}
void KCMLookandFeel::setApplyIcons(bool apply)
{
if (m_applyIcons == apply) {
return;
}
m_applyIcons = apply;
emit applyIconsChanged();
}
bool KCMLookandFeel::applyIcons() const
{
return m_applyIcons;
}
void KCMLookandFeel::setApplyPlasmaTheme(bool apply)
{
if (m_applyPlasmaTheme == apply) {
return;
}
m_applyPlasmaTheme = apply;
emit applyPlasmaThemeChanged();
}
bool KCMLookandFeel::applyPlasmaTheme() const
{
return m_applyPlasmaTheme;
}
#include "kcm.moc"

@ -36,6 +36,11 @@ class KCMLookandFeel : public KCModule
Q_PROPERTY(QStandardItemModel *lookAndFeelModel READ lookAndFeelModel CONSTANT)
Q_PROPERTY(QString selectedPlugin READ selectedPlugin WRITE setSelectedPlugin NOTIFY selectedPluginChanged)
Q_PROPERTY(bool applyColors READ applyColors WRITE setApplyColors NOTIFY applyColorsChanged)
Q_PROPERTY(bool applyWidgetStyle READ applyWidgetStyle WRITE setApplyWidgetStyle NOTIFY applyWidgetStyleChanged)
Q_PROPERTY(bool applyIcons READ applyIcons WRITE setApplyIcons NOTIFY applyIconsChanged)
Q_PROPERTY(bool applyPlasmaTheme READ applyPlasmaTheme WRITE setApplyPlasmaTheme NOTIFY applyPlasmaThemeChanged)
public:
enum Roles {
PluginNameRole = Qt::UserRole +1,
@ -59,6 +64,16 @@ public:
void setWidgetStyle(const QString &style);
void setColors(const QString &scheme, const QString &colorFile);
void setIcons(const QString &theme);
void setPlasmaTheme(const QString &theme);
void setApplyColors(bool apply);
bool applyColors() const;
void setApplyWidgetStyle(bool apply);
bool applyWidgetStyle() const;
void setApplyIcons(bool apply);
bool applyIcons() const;
void setApplyPlasmaTheme(bool apply);
bool applyPlasmaTheme() const;
public Q_SLOTS:
void load();
@ -68,6 +83,11 @@ public Q_SLOTS:
Q_SIGNALS:
void selectedPluginChanged();
void applyColorsChanged();
void applyWidgetStyleChanged();
void applyIconsChanged();
void applyPlasmaThemeChanged();
private:
QQuickWidget *m_quickWidget;
QStandardItemModel *m_model;
@ -76,6 +96,11 @@ private:
KConfig m_config;
KConfigGroup m_configGroup;
bool m_applyColors : 1;
bool m_applyWidgetStyle : 1;
bool m_applyIcons : 1;
bool m_applyPlasmaTheme : 1;
};
#endif

Loading…
Cancel
Save