mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
kcontrol: drop support for changing theme details
was coded around assumptions that clock and menu applets use custom backgrounds and such - now that I've rewritten some applets that is no longer the case Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d21a8f77e2
commit
a62e897f42
7 changed files with 17 additions and 1138 deletions
|
@ -2,7 +2,6 @@ project(desktoptheme)
|
|||
|
||||
set(kcmdesktoptheme_SRCS
|
||||
kcmdesktoptheme.cpp
|
||||
desktopthemedetails.cpp
|
||||
thememodel.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -10,56 +10,26 @@
|
|||
<height>460</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QListView" name="m_theme"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>462</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Theme</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QListView" name="m_theme"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>462</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Details</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="DesktopThemeDetails" name="m_detailsWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>DesktopThemeDetails</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>desktopthemedetails.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -1,394 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DesktopThemeItems</class>
|
||||
<widget class="QWidget" name="DesktopThemeItems">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>661</width>
|
||||
<height>487</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>700</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Desktop Theme Details</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="vlayout2"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="4">
|
||||
<widget class="QTableWidget" name="m_themeItemList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Choose an item and customize it by assigning it a theme</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>You can set any theme to any item. The available themes for the item are in the dropdown box on the right.</string>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="4">
|
||||
<widget class="QGroupBox" name="m_groupBox1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gLayout1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_enableAdvanced">
|
||||
<property name="toolTip">
|
||||
<string>Enable more options</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>This will expand the dialog and give you options to export your custom theme as well as to remove a theme.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>More</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="hlayout1">
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_removeThemeButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove the selected theme</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Clicking this button will remove the selected theme. You will be asked for confirmation.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_exportThemeButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save your theme in a zip archive</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>You can save your theme in a zip archive in order to share it with the community.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export Theme to File...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Line" name="m_advancedLine">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="hlayout2">
|
||||
<item>
|
||||
<widget class="QLabel" name="m_newThemeNameLabel">
|
||||
<property name="text">
|
||||
<string>New theme name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_newThemeName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KLineEdit" name="m_newThemeName">
|
||||
<property name="toolTip">
|
||||
<string>Custom theme name</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Give a name to your custom theme.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_newThemeAuthorLabel">
|
||||
<property name="text">
|
||||
<string>Author:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_newThemeAuthor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KLineEdit" name="m_newThemeAuthor">
|
||||
<property name="toolTip">
|
||||
<string>Custom theme author </string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Enter the author name of your custom theme.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_newThemeVersionLabel">
|
||||
<property name="text">
|
||||
<string>Version:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_newThemeVersion</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KLineEdit" name="m_newThemeVersion">
|
||||
<property name="toolTip">
|
||||
<string>Custom theme version number</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Enter the version number of your custom theme.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="hlayout3">
|
||||
<item>
|
||||
<widget class="QLabel" name="m_newThemeDescriptionLabel">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_newThemeDescription</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KLineEdit" name="m_newThemeDescription">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Custom theme description</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Enter a description which will explain your custom theme.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Select theme from above to customize</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QWidget" name="m_widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vlayout1">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="hlayout0">
|
||||
<item>
|
||||
<widget class="QLabel" name="m_themeInfoAuthor">
|
||||
<property name="text">
|
||||
<string>Theme Author</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_themeInfoName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Theme Name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_themeInfoVersion">
|
||||
<property name="text">
|
||||
<string>Theme Version</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_themeInfoDescription">
|
||||
<property name="text">
|
||||
<string>The theme description goes here...</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="4">
|
||||
<widget class="QListView" name="m_theme">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>130</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>187</red>
|
||||
<green>187</green>
|
||||
<blue>187</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>187</red>
|
||||
<green>187</green>
|
||||
<blue>187</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Available themes</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Choose a start theme in this list then customize some items below. All less important items not listed below will use this start theme.</string>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="isWrapping" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QListView::IconMode</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>klineedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,610 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2008 Andrew Lake <jamboarder@yahoo.com>
|
||||
Copyright (c) 2010 Jeremy Whiting <jpwhiting@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "desktopthemedetails.h"
|
||||
|
||||
#include "thememodel.h"
|
||||
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QTextStream>
|
||||
|
||||
#include <KDesktopFile>
|
||||
#include <KFileDialog>
|
||||
#include <KMessageBox>
|
||||
#include <KStandardDirs>
|
||||
#include <KArchive>
|
||||
#include <KLocale>
|
||||
#include <kio/netaccess.h>
|
||||
#include <kio/copyjob.h>
|
||||
#include <kio/deletejob.h>
|
||||
#include <kio/job.h>
|
||||
|
||||
struct ThemeItemNameType {
|
||||
const char* m_type;
|
||||
const char* m_displayItemName;
|
||||
const char* m_themeItemPath;
|
||||
const char* m_iconName;
|
||||
};
|
||||
|
||||
const ThemeItemNameType themeCollectionName[] = {
|
||||
{ "Color Scheme", I18N_NOOP2("plasma name", "Color Scheme"),"colors", "preferences-desktop-color"},
|
||||
{ "Panel Background", I18N_NOOP2("plasma name", "Panel Background"),"widgets/panel-background", "plasma"},
|
||||
{ "Kickoff", I18N_NOOP2("plasma name", "Kickoff"), "dialogs/kickoff", "kde"},
|
||||
{ "Task Items", I18N_NOOP2("plasma name", "Task Items"), "widgets/tasks", "preferences-system-windows"},
|
||||
{ "Widget Background", I18N_NOOP2("plasma name", "Widget Background"), "widgets/background", "plasma"},
|
||||
{ "Translucent Background", I18N_NOOP2("plasma name", "Translucent Background"), "widgets/translucentbackground", "plasma"},
|
||||
{ "Dialog Background", I18N_NOOP2("plasma name", "Dialog Background"), "dialogs/background", "plasma"},
|
||||
{ "Analog Clock", I18N_NOOP2("plasma name", "Analog Clock"), "widgets/clock", "chronometer"},
|
||||
{ "Notes", I18N_NOOP2("plasma name", "Notes"), "widgets/notes", "view-pim-notes"},
|
||||
{ "Tooltip", I18N_NOOP2("plasma name", "Tooltip"), "widgets/tooltip", "plasma"},
|
||||
{ "Pager", I18N_NOOP2("plasma name", "Pager"), "widgets/pager", "plasma"},
|
||||
{ "Run Command Dialog", I18N_NOOP2("plasma name", "Run Command Dialog"), "dialogs/krunner", "system-run"},
|
||||
{ "Shutdown Dialog", I18N_NOOP2("plasma name", "Shutdown Dialog"), "dialogs/shutdowndialog", "system-shutdown"},
|
||||
{ "Icons", I18N_NOOP2("plasma name", "Icons"), "icons/", "preferences-desktop-icons"},
|
||||
{ 0, 0,0,0 } // end of data
|
||||
};
|
||||
|
||||
|
||||
DesktopThemeDetails::DesktopThemeDetails(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_themeModel(nullptr)
|
||||
{
|
||||
setWindowIcon(KIcon("preferences-desktop"));
|
||||
setupUi(this);
|
||||
|
||||
QFont font = QFont();
|
||||
font.setBold(true);
|
||||
font.setPointSize(1.2*font.pointSize());
|
||||
m_themeInfoName->setFont(font);
|
||||
|
||||
m_enableAdvanced->setChecked(false);
|
||||
toggleAdvancedVisible();
|
||||
|
||||
|
||||
m_themeModel = new ThemeModel(this);
|
||||
m_theme->setModel(m_themeModel);
|
||||
m_theme->setItemDelegate(new ThemeDelegate(m_theme));
|
||||
|
||||
reloadConfig();
|
||||
|
||||
connect(
|
||||
m_theme->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||
this, SLOT(themeSelectionChanged(QItemSelection,QItemSelection))
|
||||
);
|
||||
|
||||
connect(m_enableAdvanced, SIGNAL(toggled(bool)), this, SLOT(toggleAdvancedVisible()));
|
||||
connect(m_removeThemeButton, SIGNAL(clicked()), this, SLOT(removeTheme()));
|
||||
connect(m_exportThemeButton, SIGNAL(clicked()), this, SLOT(exportTheme()));
|
||||
|
||||
connect(m_newThemeName, SIGNAL(editingFinished()), this, SLOT(newThemeInfoChanged()));
|
||||
|
||||
m_baseTheme = "default";
|
||||
m_themeCustomized = false;
|
||||
resetThemeDetails();
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
DesktopThemeDetails::~DesktopThemeDetails()
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::reloadConfig()
|
||||
{
|
||||
// Theme
|
||||
KConfigGroup cfg = KConfigGroup(KSharedConfig::openConfig("plasmarc"), "Theme");
|
||||
const QString theme = cfg.readEntry("name", "default");
|
||||
m_theme->setCurrentIndex(m_themeModel->indexOf(theme));
|
||||
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::save()
|
||||
{
|
||||
QString themeRoot;
|
||||
KStandardDirs dirs;
|
||||
if (m_newThemeName->text().isEmpty()) {
|
||||
themeRoot = ".customized";
|
||||
//Toggle customized theme directory name to ensure theme reload
|
||||
if (QDir(dirs.locateLocal("data", "desktoptheme/" + themeRoot + '/', false)).exists()) {
|
||||
themeRoot = themeRoot + '1';
|
||||
}
|
||||
} else {
|
||||
themeRoot = m_newThemeName->text().replace(' ',"_").remove(QRegExp("[^A-Za-z0-9_]"));
|
||||
}
|
||||
|
||||
//Save theme items
|
||||
QFile customSettingsFile;
|
||||
bool customSettingsFileOpen = false;
|
||||
|
||||
if (m_themeCustomized || !m_newThemeName->text().isEmpty()) {
|
||||
|
||||
clearCustomized(themeRoot);
|
||||
|
||||
//Copy all files from the base theme
|
||||
QString baseSource = dirs.locate("data", "desktoptheme/" + m_baseTheme + "/metadata.desktop");
|
||||
baseSource = baseSource.left(baseSource.lastIndexOf('/', -1));
|
||||
KIO::CopyJob *copyBaseTheme = KIO::copyAs(
|
||||
KUrl(baseSource),
|
||||
KUrl(dirs.locateLocal("data", "desktoptheme/" + themeRoot, true)),
|
||||
KIO::HideProgressInfo
|
||||
);
|
||||
KIO::NetAccess::synchronousRun(copyBaseTheme, this);
|
||||
|
||||
//Prepare settings file for customized theme
|
||||
if (isCustomized(themeRoot)) {
|
||||
customSettingsFile.setFileName(dirs.locateLocal("data", "desktoptheme/" + themeRoot + "/settings"));
|
||||
customSettingsFileOpen = customSettingsFile.open(QFile::WriteOnly);
|
||||
if (customSettingsFileOpen) {
|
||||
QTextStream out(&customSettingsFile);
|
||||
out << "baseTheme=" + m_baseTheme + "\r\n";;
|
||||
}
|
||||
}
|
||||
QString settingsSource;
|
||||
|
||||
//Copy each item theme file to new theme folder
|
||||
QHashIterator<int, int> i(m_itemThemeReplacements);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
//Get root directory where item should reside (relative to theme root)
|
||||
QString itemRoot = "";
|
||||
if (m_itemPaths[i.key()].lastIndexOf('/', -1) != -1) {
|
||||
itemRoot= m_itemPaths[i.key()].left(m_itemPaths[i.key()].lastIndexOf('/', -1));
|
||||
}
|
||||
//Setup source and destination
|
||||
QString source;
|
||||
QString dest;
|
||||
if (i.value() != -1) {
|
||||
//Source is a theme
|
||||
source = "desktoptheme/" + m_themeRoots[i.value()] + '/' + m_itemPaths[i.key()] + '*';
|
||||
dest = "desktoptheme/" + themeRoot + '/' + itemRoot + '/';
|
||||
settingsSource = m_themeRoots[i.value()];
|
||||
} else {
|
||||
//Source is a file
|
||||
source = m_itemFileReplacements[i.key()];
|
||||
dest = "desktoptheme/" + themeRoot + '/' + itemRoot + '/';
|
||||
settingsSource = m_itemFileReplacements[i.key()];
|
||||
}
|
||||
|
||||
|
||||
//Delete item files at destination before copying (possibly there from base theme copy)
|
||||
const QStringList deleteFiles = dirs.findAllResources(
|
||||
"data", "desktoptheme/" + themeRoot + '/' + m_itemPaths[i.key()] + '*',
|
||||
KStandardDirs::NoDuplicates
|
||||
);
|
||||
for (int j = 0; j < deleteFiles.size(); ++j) {
|
||||
KIO::DeleteJob *dj = KIO::del(KUrl(deleteFiles.at(j)), KIO::HideProgressInfo);
|
||||
KIO::NetAccess::synchronousRun(dj, this);
|
||||
}
|
||||
|
||||
//Copy item(s)
|
||||
dest = dirs.locateLocal("data", dest, true);
|
||||
QStringList copyFiles;
|
||||
if (i.value() != -1) {
|
||||
copyFiles = dirs.findAllResources("data", source, KStandardDirs::NoDuplicates); //copy from theme
|
||||
} else {
|
||||
copyFiles << source; //copy from file
|
||||
}
|
||||
for (int j = 0; j < copyFiles.size(); ++j) {
|
||||
KIO::CopyJob *cj = KIO::copy(KUrl(copyFiles.at(j)), KUrl(dest), KIO::HideProgressInfo);
|
||||
KIO::NetAccess::synchronousRun(cj, this);
|
||||
}
|
||||
|
||||
//Record settings file
|
||||
if (customSettingsFileOpen) {
|
||||
QTextStream out(&customSettingsFile);
|
||||
out << m_items.key(i.key()) + "=" + settingsSource +"\r\n";
|
||||
}
|
||||
}
|
||||
if (customSettingsFileOpen) customSettingsFile.close();
|
||||
|
||||
// Create new theme FDO desktop file
|
||||
QFile::remove(dirs.locateLocal("data", "desktoptheme/" + themeRoot + "/metadata.desktop", false));
|
||||
KDesktopFile df(dirs.locateLocal("data", "desktoptheme/" + themeRoot + "/metadata.desktop"));
|
||||
KConfigGroup cg = df.desktopGroup();
|
||||
if (isCustomized(themeRoot)) {
|
||||
cg.writeEntry("Name",i18n("(Customized)"));
|
||||
cg.writeEntry("Comment", i18n("User customized theme"));
|
||||
cg.writeEntry("X-KDE-PluginInfo-Name", themeRoot);
|
||||
} else {
|
||||
cg.writeEntry("Name", m_newThemeName->text());
|
||||
cg.writeEntry("Comment", m_newThemeDescription->text());
|
||||
cg.writeEntry("X-KDE-PluginInfo-Author", m_newThemeAuthor->text());
|
||||
cg.writeEntry("X-KDE-PluginInfo-Version", m_newThemeVersion->text());
|
||||
}
|
||||
cg.sync();
|
||||
|
||||
m_themeCustomized = false;
|
||||
}
|
||||
|
||||
m_themeModel->reload();
|
||||
if (m_themeModel->indexOf(themeRoot).isValid()) {
|
||||
m_theme->setCurrentIndex(m_themeModel->indexOf(themeRoot));
|
||||
QString themeName = m_theme->currentIndex().data(Qt::DisplayRole).toString();
|
||||
setDesktopTheme(themeRoot);
|
||||
}
|
||||
resetThemeDetails();
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::removeTheme()
|
||||
{
|
||||
bool removeTheme = true;
|
||||
KConfigGroup cfg = KConfigGroup(KSharedConfig::openConfig("plasmarc"), "Theme");
|
||||
QString activeTheme = cfg.readEntry("name", "default");
|
||||
const QString theme = m_theme->currentIndex().data(ThemeModel::PackageNameRole).toString();
|
||||
const QString themeName = m_theme->currentIndex().data(Qt::DisplayRole).toString();
|
||||
|
||||
|
||||
if (m_themeCustomized) {
|
||||
if(KMessageBox::questionYesNo(this, i18n("Theme items have been changed. Do you still wish remove the \"%1\" theme?", themeName), i18n("Remove Desktop Theme")) == KMessageBox::No) {
|
||||
removeTheme = false;
|
||||
}
|
||||
} else {
|
||||
if (theme == "default") {
|
||||
KMessageBox::information(this, i18n("Removal of the default desktop theme is not allowed."), i18n("Remove Desktop Theme"));
|
||||
removeTheme = false;
|
||||
} else {
|
||||
if (KMessageBox::questionYesNo(this, i18n("Are you sure you wish remove the \"%1\" theme?", themeName), i18n("Remove Desktop Theme")) == KMessageBox::No) {
|
||||
removeTheme = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
KStandardDirs dirs;
|
||||
if (removeTheme) {
|
||||
if (theme == activeTheme) {
|
||||
setDesktopTheme("default");
|
||||
activeTheme = "default";
|
||||
}
|
||||
if (QDir(dirs.locateLocal("data", "desktoptheme/" + theme, false)).exists()) {
|
||||
KIO::DeleteJob *deleteTheme = KIO::del(
|
||||
KUrl(dirs.locateLocal("data", "desktoptheme/" + theme, false)),
|
||||
KIO::HideProgressInfo
|
||||
);
|
||||
KIO::NetAccess::synchronousRun(deleteTheme, this);
|
||||
}
|
||||
}
|
||||
m_themeModel->reload();
|
||||
reloadConfig();
|
||||
m_theme->setCurrentIndex(m_themeModel->indexOf(activeTheme));
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::exportTheme()
|
||||
{
|
||||
const QString theme = m_theme->currentIndex().data(ThemeModel::PackageNameRole).toString();
|
||||
|
||||
if (m_themeCustomized ||
|
||||
(isCustomized(theme) && m_newThemeName->text() == "")) {
|
||||
KMessageBox::information(
|
||||
this,
|
||||
i18n("Please apply theme item changes (with a new theme name) before attempting to export theme."),
|
||||
i18n("Export Desktop Theme")
|
||||
);
|
||||
} else {
|
||||
QString themeStoragePath = theme;
|
||||
|
||||
KStandardDirs dirs;
|
||||
const QString themePath = dirs.findResource("data", "desktoptheme/" + themeStoragePath + "/metadata.desktop");
|
||||
if (!themePath.isEmpty()){
|
||||
QString expFileName = KFileDialog::getSaveFileName(KUrl(), "*.zip", this, i18n("Export theme to file"));
|
||||
if (!expFileName.endsWith(".zip")) {
|
||||
expFileName = expFileName + ".zip";
|
||||
}
|
||||
if (!expFileName.isEmpty()) {
|
||||
KUrl path(themePath);
|
||||
KArchive expFile(expFileName);
|
||||
const bool karchiveresult = expFile.add(
|
||||
QStringList() << (QDir::cleanPath(path.directory()) + QDir::separator()),
|
||||
QFile::encodeName(QDir::cleanPath(path.directory()) + QDir::separator()),
|
||||
QFile::encodeName(themeStoragePath + QDir::separator())
|
||||
);
|
||||
if (!karchiveresult) {
|
||||
KMessageBox::error(this, expFile.errorString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::loadThemeItems()
|
||||
{
|
||||
// Set up items, item paths and icons
|
||||
m_items.clear(); // clear theme items
|
||||
m_itemPaths.clear(); // clear theme item paths
|
||||
m_itemIcons.clear();
|
||||
for (int i = 0; themeCollectionName[i].m_type; ++i) {
|
||||
m_items[themeCollectionName[i].m_type] = i;
|
||||
m_itemPaths[i] = themeCollectionName[i].m_themeItemPath;
|
||||
m_itemIcons[i] = themeCollectionName[i].m_iconName;
|
||||
}
|
||||
|
||||
// Get installed themes
|
||||
m_themes.clear(); // clear installed theme list
|
||||
m_themeRoots.clear(); // clear installed theme root paths
|
||||
KStandardDirs dirs;
|
||||
QStringList themes = dirs.findAllResources(
|
||||
"data", "desktoptheme/*/metadata.desktop",
|
||||
KStandardDirs::NoDuplicates
|
||||
);
|
||||
themes.sort();
|
||||
int j = 0;
|
||||
for (int i = 0; i < themes.size(); ++i) {
|
||||
QString theme = themes.at(i);
|
||||
int themeSepIndex = theme.lastIndexOf('/', -1);
|
||||
QString themeRoot = theme.left(themeSepIndex);
|
||||
int themeNameSepIndex = themeRoot.lastIndexOf('/', -1);
|
||||
QString packageName = themeRoot.right(themeRoot.length() - themeNameSepIndex - 1);
|
||||
KDesktopFile df(theme);
|
||||
QString name = df.readName();
|
||||
if (name.isEmpty()) {
|
||||
name = packageName;
|
||||
}
|
||||
|
||||
if (!isCustomized(packageName) && (m_themeRoots.key(packageName, -1) == -1)) {
|
||||
m_themes[name] = j;
|
||||
m_themeRoots[j] = packageName;
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
||||
// Set up default item replacements
|
||||
m_itemThemeReplacements.clear();
|
||||
m_itemFileReplacements.clear();
|
||||
QString currentTheme = m_theme->currentIndex().data(ThemeModel::PackageNameRole).toString();
|
||||
|
||||
if (!isCustomized(currentTheme)) {
|
||||
// Set default replacements to current theme
|
||||
QHashIterator<QString, int> i(m_items);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
m_itemThemeReplacements[i.value()] = m_themeRoots.key(currentTheme);
|
||||
}
|
||||
m_baseTheme = currentTheme;
|
||||
} else {
|
||||
// Set default replacements to customized theme settings
|
||||
QFile customSettingsFile(dirs.locateLocal("data", "desktoptheme/" + currentTheme +"/settings"));
|
||||
if (customSettingsFile.open(QFile::ReadOnly)) {
|
||||
QTextStream in(&customSettingsFile);
|
||||
QString line;
|
||||
QStringList settingsPair;
|
||||
while (!in.atEnd()) {
|
||||
line = in.readLine();
|
||||
settingsPair = line.split('=');
|
||||
if (settingsPair.at(0) == "baseTheme") {
|
||||
m_baseTheme = settingsPair.at(1);
|
||||
} else {
|
||||
if (m_themeRoots.key(settingsPair.at(1), -1) != -1) { // theme for current item exists
|
||||
m_itemThemeReplacements[m_items[settingsPair.at(0)]] = m_themeRoots.key(settingsPair.at(1));
|
||||
} else if (QFile::exists(settingsPair.at(1))) {
|
||||
m_itemThemeReplacements[m_items[settingsPair.at(0)]] = -1;
|
||||
m_itemFileReplacements[m_items[settingsPair.at(0)]] = settingsPair.at(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
customSettingsFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Build displayed list of theme items
|
||||
m_themeItemList->setRowCount(m_items.size());
|
||||
m_themeItemList->setColumnCount(2);
|
||||
m_themeItemList->setHorizontalHeaderLabels(QStringList()<< i18n("Theme Item")<<i18n("Source"));
|
||||
QString displayedItem;
|
||||
QHashIterator<QString, int> i(m_items);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
displayedItem = displayedItemText(i.value());
|
||||
m_themeItemList->setItem(i.value(), 0, new QTableWidgetItem(displayedItem));
|
||||
m_themeItemList->item(i.value(),0)->setIcon(KIcon(m_itemIcons[i.value()]));
|
||||
m_themeItemList->setCellWidget(i.value(), 1, new QComboBox());
|
||||
updateReplaceItemList(i.value());
|
||||
m_themeItemList->resizeColumnToContents(1);
|
||||
}
|
||||
m_themeItemList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_themeItemList->verticalHeader()->hide();
|
||||
m_themeItemList->horizontalHeader()->setStretchLastSection(true);
|
||||
m_themeItemList->horizontalHeader()->setMinimumSectionSize(120);
|
||||
m_themeItemList->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);;
|
||||
m_themeItemList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);;
|
||||
m_themeItemList->setCurrentCell(0, 1);
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::updateReplaceItemList(const int item)
|
||||
{
|
||||
QString currentTheme = m_theme->currentIndex().data(ThemeModel::PackageNameRole).toString();
|
||||
|
||||
|
||||
// Repopulate combobox droplist
|
||||
QComboBox *itemComboBox = static_cast<QComboBox*>(m_themeItemList->cellWidget(item,1));
|
||||
disconnect(itemComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(replacementItemChanged()));
|
||||
itemComboBox->clear();
|
||||
for (int i = 0; i < m_themes.size(); ++i) {
|
||||
QString displayedDropListItem = i18n("%1 %2", m_themes.key(i), displayedItemText(item));
|
||||
itemComboBox->addItem(displayedDropListItem);
|
||||
}
|
||||
itemComboBox->addItem(i18n("File..."));
|
||||
|
||||
// Set combobox value to current replacement
|
||||
if (m_itemThemeReplacements[item] != -1) {
|
||||
itemComboBox->setCurrentIndex(m_itemThemeReplacements[item]);
|
||||
} else {
|
||||
itemComboBox->addItem(m_itemFileReplacements[item]);
|
||||
itemComboBox->setCurrentIndex(itemComboBox->findText(m_itemFileReplacements[item]));
|
||||
}
|
||||
connect(itemComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(replacementItemChanged()));
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::replacementItemChanged()
|
||||
{
|
||||
//Check items to see if theme has been customized
|
||||
m_themeCustomized = true;
|
||||
QHashIterator<QString, int> i(m_items);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
QComboBox *itemComboBox = static_cast<QComboBox*>(m_themeItemList->cellWidget(i.value(), 1));
|
||||
int replacement = itemComboBox->currentIndex();
|
||||
if (replacement <= (m_themes.size() - 1)) {
|
||||
// Item replacement source is a theme
|
||||
m_itemThemeReplacements[i.value()] = itemComboBox->currentIndex();
|
||||
} else if (replacement > (m_themes.size() - 1)) {
|
||||
// Item replacement source is a file
|
||||
if (itemComboBox->currentText() == i18n("File...")) {
|
||||
//Get the filename for the replacement item
|
||||
QString translated_key = i18nc("plasma name", qPrintable( i.key() ) );
|
||||
QString fileReplacement = KFileDialog::getOpenFileName(
|
||||
KUrl(), QString(), this, i18n("Select File to Use for %1", translated_key)
|
||||
);
|
||||
if (!fileReplacement.isEmpty()) {
|
||||
m_itemFileReplacements[i.value()] = fileReplacement;
|
||||
int index = itemComboBox->findText(fileReplacement);
|
||||
if (index == -1) itemComboBox->addItem(fileReplacement);
|
||||
disconnect(itemComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(replacementItemChanged()));
|
||||
itemComboBox->setCurrentIndex(itemComboBox->findText(fileReplacement));
|
||||
connect(itemComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(replacementItemChanged()));
|
||||
m_itemThemeReplacements[i.value()] = -1; //source is not a theme
|
||||
m_itemFileReplacements[i.value()] = itemComboBox->currentText();
|
||||
} else {
|
||||
// Reset combobox to previous value if no file is selected
|
||||
if (m_itemThemeReplacements[i.value()] != -1) {
|
||||
itemComboBox->setCurrentIndex(m_itemThemeReplacements[i.value()]);
|
||||
} else {
|
||||
itemComboBox->setCurrentIndex(itemComboBox->findText(m_itemFileReplacements[i.value()]));
|
||||
}
|
||||
m_themeCustomized = false;
|
||||
}
|
||||
} else {
|
||||
m_itemThemeReplacements[i.value()] = -1; //source is not a theme
|
||||
m_itemFileReplacements[i.value()] = itemComboBox->currentText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_themeCustomized) emit changed();
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::newThemeInfoChanged()
|
||||
{
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::resetThemeDetails()
|
||||
{
|
||||
QString theme = m_theme->currentIndex().data(ThemeModel::PackageNameRole).toString();
|
||||
|
||||
m_themeInfoName->setText(m_theme->currentIndex().data(Qt::DisplayRole).toString());
|
||||
m_themeInfoDescription->setText(m_theme->currentIndex().data(ThemeModel::PackageDescriptionRole).toString());
|
||||
QString author = m_theme->currentIndex().data(ThemeModel::PackageAuthorRole).toString();
|
||||
|
||||
if (!author.isEmpty()) {
|
||||
m_themeInfoAuthor->setText(i18n(" Author: %1",author));
|
||||
} else {
|
||||
m_themeInfoAuthor->setText("");
|
||||
}
|
||||
QString version = m_theme->currentIndex().data(ThemeModel::PackageVersionRole).toString();
|
||||
if (!version.isEmpty()) {
|
||||
m_themeInfoVersion->setText(i18n("Version: %1",version));
|
||||
} else {
|
||||
m_themeInfoVersion->setText("");
|
||||
}
|
||||
|
||||
loadThemeItems();
|
||||
|
||||
m_newThemeName->clear();
|
||||
m_newThemeAuthor->clear();
|
||||
m_newThemeVersion->clear();
|
||||
m_newThemeDescription->clear();
|
||||
m_themeCustomized = false;
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::toggleAdvancedVisible()
|
||||
{
|
||||
m_newThemeNameLabel->setVisible(m_enableAdvanced->isChecked());
|
||||
m_newThemeName->setVisible(m_enableAdvanced->isChecked());
|
||||
m_newThemeAuthor->setVisible(m_enableAdvanced->isChecked());
|
||||
m_newThemeAuthorLabel->setVisible(m_enableAdvanced->isChecked());
|
||||
m_newThemeVersion->setVisible(m_enableAdvanced->isChecked());
|
||||
m_newThemeVersionLabel->setVisible(m_enableAdvanced->isChecked());
|
||||
m_newThemeDescriptionLabel->setVisible(m_enableAdvanced->isChecked());
|
||||
m_newThemeDescription->setVisible(m_enableAdvanced->isChecked());
|
||||
m_exportThemeButton->setVisible(m_enableAdvanced->isChecked());
|
||||
m_removeThemeButton->setVisible(m_enableAdvanced->isChecked());
|
||||
m_advancedLine->setVisible(m_enableAdvanced->isChecked());
|
||||
}
|
||||
|
||||
bool DesktopThemeDetails::isCustomized(const QString &theme)
|
||||
{
|
||||
if (theme == ".customized" || theme == ".customized1") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::clearCustomized(const QString &themeRoot)
|
||||
{
|
||||
KStandardDirs dirs;
|
||||
|
||||
if ((isCustomized(themeRoot))) {
|
||||
// Remove both possible unnamed customized directories
|
||||
if (QDir(dirs.locateLocal("data", "desktoptheme/.customized", false)).exists()) {
|
||||
KIO::DeleteJob *clearCustom = KIO::del(KUrl(dirs.locateLocal("data", "desktoptheme/.customized", false)), KIO::HideProgressInfo);
|
||||
KIO::NetAccess::synchronousRun(clearCustom, this);
|
||||
}
|
||||
if (QDir(dirs.locateLocal("data", "desktoptheme/.customized1", false)).exists()) {
|
||||
KIO::DeleteJob *clearCustom1 = KIO::del(KUrl(dirs.locateLocal("data", "desktoptheme/.customized1", false)), KIO::HideProgressInfo);
|
||||
KIO::NetAccess::synchronousRun(clearCustom1, this);
|
||||
}
|
||||
} else {
|
||||
if (QDir(dirs.locateLocal("data", "desktoptheme/" + themeRoot, false)).exists()) {
|
||||
KIO::DeleteJob *clearCustom = KIO::del(KUrl(dirs.locateLocal("data", "desktoptheme/" + themeRoot, false)), KIO::HideProgressInfo);
|
||||
KIO::NetAccess::synchronousRun(clearCustom, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString DesktopThemeDetails::displayedItemText(int item)
|
||||
{
|
||||
QString displayedText = m_items.key(item);
|
||||
for (int i = 0; themeCollectionName[i].m_type; ++i) {
|
||||
if (themeCollectionName[i].m_type == m_items.key(item)) {
|
||||
displayedText = i18nc("plasma name", themeCollectionName[i].m_displayItemName);
|
||||
}
|
||||
}
|
||||
return displayedText;
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::themeSelectionChanged(const QItemSelection newSelection, const QItemSelection oldSelection)
|
||||
{
|
||||
QString theme = m_theme->currentIndex().data(ThemeModel::PackageNameRole).toString();
|
||||
if (theme == "default") {
|
||||
m_removeThemeButton->setEnabled(false);
|
||||
} else {
|
||||
m_removeThemeButton->setEnabled(true);
|
||||
}
|
||||
resetThemeDetails();
|
||||
Q_UNUSED(newSelection);
|
||||
Q_UNUSED(oldSelection);
|
||||
}
|
||||
|
||||
void DesktopThemeDetails::setDesktopTheme(QString themeRoot)
|
||||
{
|
||||
KConfig config(KStandardDirs::locate("config", "plasmarc"));
|
||||
KConfigGroup cg = KConfigGroup(&config, "Theme");
|
||||
if (themeRoot == "default") {
|
||||
cg.deleteEntry("name");
|
||||
} else {
|
||||
cg.writeEntry("name", themeRoot);
|
||||
}
|
||||
cg.sync();
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
|
||||
Copyright (c) 2008 by Petri Damsten <damu@iki.fi>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
*/
|
||||
|
||||
#ifndef DESKTOPTHEMEDETAILS_H
|
||||
#define DESKTOPTHEMEDETAILS_H
|
||||
|
||||
#include "ui_DesktopThemeDetails.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
class ThemeModel;
|
||||
|
||||
class DesktopThemeDetails : public QWidget, public Ui::DesktopThemeItems
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DesktopThemeDetails(QWidget* parent);
|
||||
~DesktopThemeDetails();
|
||||
|
||||
void reloadConfig();
|
||||
|
||||
public slots:
|
||||
void replacementItemChanged();
|
||||
void resetThemeDetails();
|
||||
void toggleAdvancedVisible();
|
||||
void save();
|
||||
void removeTheme();
|
||||
void exportTheme();
|
||||
void newThemeInfoChanged();
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed();
|
||||
|
||||
private:
|
||||
void updateReplaceItemList(const int item);
|
||||
void loadThemeItems();
|
||||
QString displayedItemText(int item);
|
||||
bool isCustomized(const QString &theme);
|
||||
void clearCustomized(const QString &themeRoot);
|
||||
void setDesktopTheme(QString themeRoot);
|
||||
|
||||
private slots:
|
||||
void cleanup();
|
||||
void themeSelectionChanged(const QItemSelection newSelection, const QItemSelection oldSelection);
|
||||
|
||||
private:
|
||||
ThemeModel* m_themeModel;
|
||||
|
||||
QHash<QString, int> m_items; // theme items
|
||||
QHash<int, QString> m_itemPaths; // theme item paths
|
||||
QHash<int, QString> m_itemIcons; //theme item icons
|
||||
QHash<QString, int> m_themes; // installed themes
|
||||
QHash<int, QString> m_themeRoots; // installed themes root paths
|
||||
QHash<int, int> m_itemThemeReplacements; // source theme for item replacements
|
||||
QHash<int, QString>m_itemFileReplacements; //non-theme source files for item replacements
|
||||
|
||||
bool m_themeCustomized;
|
||||
QString m_baseTheme;
|
||||
};
|
||||
|
||||
#endif // DESKTOPTHEMEDETAILS_H
|
|
@ -56,7 +56,6 @@ KCMDesktopTheme::KCMDesktopTheme(QWidget *parent, const QVariantList &args)
|
|||
setupUi(this);
|
||||
|
||||
m_bDesktopThemeDirty = false;
|
||||
m_bDetailsDirty = false;
|
||||
|
||||
KGlobal::dirs()->addResourceType("themes", "data", "kstyle/themes");
|
||||
|
||||
|
@ -77,8 +76,6 @@ KCMDesktopTheme::KCMDesktopTheme(QWidget *parent, const QVariantList &args)
|
|||
m_theme->setItemDelegate(new ThemeDelegate(m_theme));
|
||||
m_theme->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
|
||||
connect(m_detailsWidget, SIGNAL(changed()), this, SLOT(detailChanged()));
|
||||
|
||||
connect(
|
||||
m_theme->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
|
||||
this, SLOT(setDesktopThemeDirty())
|
||||
|
@ -97,7 +94,6 @@ void KCMDesktopTheme::load()
|
|||
loadDesktopTheme();
|
||||
|
||||
m_bDesktopThemeDirty = false;
|
||||
m_bDetailsDirty = false;
|
||||
|
||||
emit changed( false );
|
||||
}
|
||||
|
@ -105,8 +101,8 @@ void KCMDesktopTheme::load()
|
|||
|
||||
void KCMDesktopTheme::save()
|
||||
{
|
||||
// Don't do anything if we don't need to.
|
||||
if (!(m_bDesktopThemeDirty) && !(m_bDetailsDirty)) {
|
||||
// Don't do anything if don't need to.
|
||||
if (!m_bDesktopThemeDirty) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -116,13 +112,8 @@ void KCMDesktopTheme::save()
|
|||
Plasma::Theme::defaultTheme()->setThemeName(theme);
|
||||
}
|
||||
|
||||
if (m_bDetailsDirty) {
|
||||
m_detailsWidget->save();
|
||||
}
|
||||
|
||||
// Clean up
|
||||
m_bDesktopThemeDirty = false;
|
||||
m_bDetailsDirty = false;
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
|
@ -146,12 +137,6 @@ void KCMDesktopTheme::loadDesktopTheme()
|
|||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void KCMDesktopTheme::detailChanged()
|
||||
{
|
||||
m_bDetailsDirty = true;
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
#include "moc_kcmdesktoptheme.cpp"
|
||||
|
||||
// vim: set noet ts=4:
|
||||
|
|
|
@ -48,16 +48,13 @@ public:
|
|||
|
||||
protected Q_SLOTS:
|
||||
void loadDesktopTheme();
|
||||
|
||||
void setDesktopThemeDirty();
|
||||
|
||||
void detailChanged();
|
||||
private:
|
||||
static QString toolbarButtonText(int index);
|
||||
static int toolbarButtonIndex(const QString &text);
|
||||
|
||||
bool m_bDesktopThemeDirty;
|
||||
bool m_bDetailsDirty;
|
||||
|
||||
ThemeModel* m_themeModel;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue