You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
585 lines
22 KiB
585 lines
22 KiB
15 years ago
|
/***************************************************************************
|
||
11 years ago
|
tdestylepage.cpp - description
|
||
15 years ago
|
-------------------
|
||
|
begin : Tue May 22 2001
|
||
|
copyright : (C) 2001 by Ralf Nolden
|
||
|
email : nolden@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 <stdlib.h>
|
||
|
|
||
14 years ago
|
#include <tqdir.h>
|
||
|
#include <tqlabel.h>
|
||
|
#include <tqlistview.h>
|
||
|
#include <tqcolor.h>
|
||
|
#include <tqstylefactory.h>
|
||
|
#include <tqpixmapcache.h>
|
||
|
#include <tqstyle.h>
|
||
|
#include <tqobjectlist.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
15 years ago
|
#include <kstandarddirs.h>
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
12 years ago
|
#include <tdeglobal.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
|
#include <kdesktopfile.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
12 years ago
|
#include <tdelistview.h>
|
||
15 years ago
|
#include <kipc.h>
|
||
|
#include <ksimpleconfig.h>
|
||
|
#include <dcopclient.h>
|
||
12 years ago
|
#include <tdestyle.h>
|
||
15 years ago
|
#include <kicontheme.h>
|
||
|
#include <kiconloader.h>
|
||
|
|
||
|
#include "stylepreview.h"
|
||
11 years ago
|
#include "tdestylepage.h"
|
||
15 years ago
|
|
||
12 years ago
|
TDEStylePage::TDEStylePage(TQWidget *parent, const char *name ) : TDEStylePageDlg(parent,name) {
|
||
15 years ago
|
|
||
|
px_stylesSidebar->setPixmap(UserIcon("step4.png"));
|
||
|
|
||
|
klv_styles->addColumn(i18n("Style"));
|
||
|
klv_styles->addColumn( i18n( "Description" ) );
|
||
|
klv_styles->setAllColumnsShowFocus(true);
|
||
|
|
||
14 years ago
|
kde = new TQListViewItem( klv_styles);
|
||
|
kde->setText( 0, TQPixmap::defaultDepth() > 8 ? i18n( "Plastik" ) : i18n( "Light" ) );
|
||
13 years ago
|
kde->setText( 1, i18n( "TDE default style" ) );
|
||
15 years ago
|
|
||
14 years ago
|
classic = new TQListViewItem( klv_styles);
|
||
15 years ago
|
classic->setText( 0, i18n( "KDE Classic" ) );
|
||
|
classic->setText( 1, i18n( "Classic KDE style" ) );
|
||
|
|
||
14 years ago
|
keramik = new TQListViewItem( klv_styles );
|
||
15 years ago
|
keramik->setText( 0, i18n( "Keramik" ) );
|
||
|
keramik->setText( 1, i18n( "The previous default style" ) );
|
||
|
|
||
14 years ago
|
cde = new TQListViewItem( klv_styles);
|
||
15 years ago
|
cde->setText( 0, i18n( "Sunshine" ) );
|
||
|
cde->setText( 1, i18n( "A very common desktop" ) );
|
||
|
|
||
14 years ago
|
win = new TQListViewItem( klv_styles );
|
||
15 years ago
|
win->setText( 0, i18n( "Redmond" ) );
|
||
|
win->setText( 1, i18n( "A style from the northwest of the USA" ) );
|
||
|
|
||
14 years ago
|
platinum = new TQListViewItem( klv_styles );
|
||
15 years ago
|
platinum->setText( 0, i18n( "Platinum" ) );
|
||
|
platinum->setText( 1, i18n( "The platinum style" ) );
|
||
|
|
||
14 years ago
|
connect(klv_styles, TQT_SIGNAL(selectionChanged()),
|
||
|
this, TQT_SLOT(slotCurrentChanged()));
|
||
15 years ago
|
|
||
13 years ago
|
// Note: if the default is changed here it needs to be changed in tdebase/twin/plugins.cpp
|
||
|
// and tdebase/twin/kcmtwin/twindecoration/twindecoration.cpp as well.
|
||
13 years ago
|
defaultKWinStyle = TQPixmap::defaultDepth() > 8 ? "twin_plastik" : "twin_quartz";
|
||
15 years ago
|
appliedStyle = NULL;
|
||
|
|
||
|
getAvailability();
|
||
|
getUserDefaults();
|
||
|
initColors();
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEStylePage::~TDEStylePage(){
|
||
13 years ago
|
delete ctwin;
|
||
15 years ago
|
delete appliedStyle;
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEStylePage::save(bool curSettings){
|
||
|
kdDebug() << "TDEStylePage::save()" << endl;
|
||
15 years ago
|
// First, the style, then the colors as styles overwrite color settings
|
||
|
saveStyle(curSettings);
|
||
|
saveColors(curSettings);
|
||
|
saveKWin(curSettings);
|
||
|
saveIcons(curSettings);
|
||
|
liveUpdate();
|
||
|
}
|
||
|
|
||
|
/** save the widget-style */
|
||
12 years ago
|
void TDEStylePage::saveStyle(bool curSettings){
|
||
14 years ago
|
TQString style = curSettings ? currentStyle : origStyle;
|
||
12 years ago
|
TDEConfig cfg( "kdeglobals" );
|
||
15 years ago
|
cfg.setGroup("General");
|
||
|
cfg.writeEntry( "widgetStyle", style, true, true );
|
||
|
cfg.sync();
|
||
12 years ago
|
kdDebug() << "TDEStylePage::saveStyle(): " << style << endl;
|
||
15 years ago
|
}
|
||
|
|
||
|
/** save the KWin-style*/
|
||
12 years ago
|
void TDEStylePage::saveKWin(bool curSettings){
|
||
13 years ago
|
TQString twin = origKWinStyle;
|
||
15 years ago
|
if(curSettings) {
|
||
|
KDesktopFile* kdf = 0L;
|
||
12 years ago
|
TDEStandardDirs* kstd = TDEGlobal::dirs();
|
||
13 years ago
|
if (cde->isSelected() && twin_cde_exist)
|
||
|
kdf = new KDesktopFile(kstd->findResource("data", "twin/cde.desktop"));
|
||
|
else if (win->isSelected() && twin_win_exist)
|
||
|
kdf = new KDesktopFile(kstd->findResource("data", "twin/redmond.desktop"));
|
||
|
else if (platinum->isSelected() && twin_system_exist)
|
||
|
kdf = new KDesktopFile(kstd->findResource("data", "twin/system.desktop"));
|
||
|
else if (keramik->isSelected() && twin_keramik_exist)
|
||
|
kdf = new KDesktopFile(kstd->findResource("data", "twin/keramik.desktop"));
|
||
15 years ago
|
else if (kde->isSelected()) {
|
||
13 years ago
|
if (twin_plastik_exist && (TQColor::numBitPlanes() > 8))
|
||
|
kdf = new KDesktopFile(kstd->findResource("data", "twin/plastik.desktop"));
|
||
|
else if (twin_quartz_exist)
|
||
|
kdf = new KDesktopFile(kstd->findResource("data", "twin/quartz.desktop"));
|
||
15 years ago
|
}
|
||
|
|
||
|
if (kdf) {
|
||
|
kdf->setGroup("Desktop Entry");
|
||
13 years ago
|
twin = kdf->readEntry("X-TDE-Library", defaultKWinStyle);
|
||
15 years ago
|
delete kdf;
|
||
|
}
|
||
|
else {
|
||
|
// if we get here classic is selected (there's no .desktop file for the
|
||
13 years ago
|
// kde2 twin style), or none of the other twin styles were found.
|
||
|
twin = "twin_default";
|
||
15 years ago
|
}
|
||
|
}
|
||
13 years ago
|
ctwin->writeEntry("PluginLib", twin);
|
||
|
ctwin->sync();
|
||
12 years ago
|
kdDebug() << "TDEStylePage::saveKWin(): " << twin << endl;
|
||
15 years ago
|
}
|
||
|
|
||
|
/** Save the color-scheme */
|
||
12 years ago
|
void TDEStylePage::saveColors(bool curSettings){
|
||
15 years ago
|
struct colorSet* toSave;
|
||
|
if(curSettings)
|
||
|
toSave=¤tColors; // set the color struct to save as the style colors
|
||
|
else
|
||
|
toSave=&usrColors;
|
||
|
|
||
|
// the GLOBAL config entries must be taken from the kcsrc file and written to it. Use the default values
|
||
|
// equals that the file is <default> which is no file. TODO: use the default values in that case (kde selected)
|
||
12 years ago
|
TDEConfig *config = TDEGlobal::config();
|
||
15 years ago
|
config->setGroup( "General" );
|
||
|
config->writeEntry("foreground", toSave->foreground, true, true);
|
||
|
config->writeEntry("background", toSave->background, true, true);
|
||
|
config->writeEntry("windowForeground", toSave->windowForeground, true, true);
|
||
|
config->writeEntry("windowBackground", toSave->windowBackground, true, true);
|
||
|
config->writeEntry("selectForeground", toSave->selectForeground, true, true);
|
||
|
config->writeEntry("selectBackground", toSave->selectBackground, true, true);
|
||
|
config->writeEntry("buttonForeground", toSave->buttonForeground, true, true);
|
||
|
config->writeEntry("buttonBackground", toSave->buttonBackground, true, true);
|
||
|
config->writeEntry("linkColor", toSave->linkColor, true, true);
|
||
|
config->writeEntry("visitedLinkColor", toSave->visitedLinkColor, true, true);
|
||
|
|
||
12 years ago
|
// set to the WM group, *only* the TDEGlobal one, a kcsrc file only has the group "Color Scheme" hmpf...
|
||
15 years ago
|
config->setGroup( "WM" );
|
||
|
config->writeEntry("activeForeground", toSave->activeForeground, true, true);
|
||
|
config->writeEntry("inactiveForeground", toSave->inactiveForeground, true, true);
|
||
|
config->writeEntry("activeBackground", toSave->activeBackground, true, true);
|
||
|
config->writeEntry("inactiveBackground", toSave->inactiveBackground, true, true);
|
||
|
config->writeEntry("activeBlend", toSave->activeBlend, true, true);
|
||
|
config->writeEntry("inactiveBlend", toSave->inactiveBlend, true, true);
|
||
|
config->writeEntry("activeTitleBtnBg", toSave->activeTitleBtnBg, true, true);
|
||
|
config->writeEntry("inactiveTitleBtnBg", toSave->inactiveTitleBtnBg, true, true);
|
||
|
config->writeEntry("alternateBackground", toSave->alternateBackground, true, true);
|
||
|
|
||
|
////////////////////////////////////////////////////
|
||
|
// KDE-1.x support
|
||
12 years ago
|
KSimpleConfig *tdeconfig =
|
||
12 years ago
|
new KSimpleConfig( TQDir::homeDirPath() + "/.tderc" );
|
||
12 years ago
|
tdeconfig->setGroup( "General" );
|
||
|
tdeconfig->writeEntry("background", toSave->background );
|
||
|
tdeconfig->writeEntry("selectBackground", toSave->selectBackground );
|
||
|
tdeconfig->writeEntry("foreground", toSave->foreground );
|
||
|
tdeconfig->writeEntry("windowForeground", toSave->windowForeground );
|
||
|
tdeconfig->writeEntry("windowBackground", toSave->windowBackground );
|
||
|
tdeconfig->writeEntry("selectForeground", toSave->selectForeground );
|
||
|
tdeconfig->sync();
|
||
|
delete tdeconfig;
|
||
15 years ago
|
|
||
|
config->setGroup("KDE");
|
||
|
// write the color scheme filename and the contrast, default 7, otherwise from file
|
||
|
config->writeEntry("colorScheme", toSave->colorFile,true, true);
|
||
|
config->writeEntry("contrast", toSave->contrast, true, true);
|
||
|
config->sync();
|
||
|
|
||
|
// background color changes
|
||
12 years ago
|
TDEConfig kdesktop("kdesktoprc");
|
||
15 years ago
|
kdesktop.setGroup("Desktop0"); // we only need to set one desktop
|
||
|
|
||
|
kdesktop.writeEntry("BackgroundMode", toSave->bgMode);
|
||
|
kdesktop.writeEntry("Color1", toSave->usrCol1);
|
||
|
kdesktop.writeEntry("Color2", toSave->usrCol2);
|
||
|
kdesktop.sync();
|
||
12 years ago
|
kdDebug() << "TDEStylePage::saveColors(): colorFile: " << toSave->colorFile << endl;
|
||
15 years ago
|
}
|
||
|
|
||
|
/** save the icon-theme*/
|
||
12 years ago
|
void TDEStylePage::saveIcons(bool curSettings) {
|
||
14 years ago
|
TQString theme = origIcons;
|
||
15 years ago
|
if (curSettings) {
|
||
|
if ( (kde->isSelected() || platinum->isSelected() || keramik->isSelected())
|
||
|
&& icon_crystalsvg_exist)
|
||
|
theme = "crystalsvg";
|
||
|
else if ( (classic->isSelected() || cde->isSelected() || win->isSelected())
|
||
14 years ago
|
&& (TQColor::numBitPlanes() > 8) && icon_kdeclassic_exist)
|
||
15 years ago
|
theme = "kdeclassic";
|
||
|
else if ( (classic->isSelected() || cde->isSelected() || win->isSelected())
|
||
14 years ago
|
&& (TQColor::numBitPlanes() <= 8) && icon_Locolor_exist)
|
||
15 years ago
|
theme = "Locolor";
|
||
|
}
|
||
|
// save, what we got
|
||
12 years ago
|
TDEGlobal::config()->setGroup("Icons");
|
||
|
TDEGlobal::config()->writeEntry("Theme", theme, true, true);
|
||
12 years ago
|
TDEIconTheme icontheme(theme);
|
||
15 years ago
|
const char * const groups[] = { "Desktop", "Toolbar", "MainToolbar", "Small", 0L };
|
||
12 years ago
|
for (TDEIcon::Group i=TDEIcon::FirstGroup; i<TDEIcon::LastGroup; i++) {
|
||
15 years ago
|
if (groups[i] == 0L)
|
||
|
break;
|
||
12 years ago
|
TDEGlobal::config()->setGroup(TQString::fromLatin1(groups[i]) + "Icons");
|
||
|
TDEGlobal::config()->writeEntry("Size", icontheme.defaultSize(i));
|
||
15 years ago
|
}
|
||
12 years ago
|
TDEGlobal::config()->sync();
|
||
12 years ago
|
kdDebug() << "TDEStylePage::saveIcons(): " << theme << endl;
|
||
15 years ago
|
}
|
||
|
|
||
|
/** called whenever the selection in the listview changes */
|
||
12 years ago
|
void TDEStylePage::slotCurrentChanged() {
|
||
15 years ago
|
// fill the currentColors-struct with the selected color-scheme
|
||
|
getColors(¤tColors, true);
|
||
|
// fill the currentStyle-string with the selected style-name
|
||
|
changeCurrentStyle();
|
||
|
switchPrevStyle();
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEStylePage::changeCurrentStyle() {
|
||
15 years ago
|
// set the style
|
||
|
if (cde->isSelected() && cde_exist) {
|
||
|
currentStyle="Motif";
|
||
|
}
|
||
|
else if (win->isSelected() && win_exist) {
|
||
|
currentStyle="Windows";
|
||
|
}
|
||
|
else if (platinum->isSelected() && platinum_exist) {
|
||
|
currentStyle="Platinum";
|
||
|
}
|
||
|
else if (keramik->isSelected() && kde_plastik_exist) {
|
||
|
currentStyle="Keramik";
|
||
|
}
|
||
|
else if (classic->isSelected()) {
|
||
|
// Use the highcolor style if the display supports it
|
||
14 years ago
|
if ( (TQColor::numBitPlanes() > 8) && kde_hc_exist ) {
|
||
15 years ago
|
currentStyle="HighColor";
|
||
|
}
|
||
|
else if (kde_def_exist) {
|
||
|
currentStyle="Default";
|
||
|
}
|
||
|
}
|
||
|
else if (kde->isSelected()) {
|
||
|
// Use the plastik style if the display supports it
|
||
14 years ago
|
if ( (TQColor::numBitPlanes() > 8) && kde_plastik_exist ) {
|
||
15 years ago
|
currentStyle="Plastik";
|
||
|
}
|
||
|
else if (kde_light_exist) {
|
||
|
currentStyle="Light, 3rd revision";
|
||
|
}
|
||
|
// We should never get here
|
||
|
else if (kde_def_exist) {
|
||
|
currentStyle="Default";
|
||
|
}
|
||
|
}
|
||
|
// update the preview-widget
|
||
12 years ago
|
kdDebug() << "TDEStylePage::changeCurrentStyle(): "<< currentStyle << endl;
|
||
15 years ago
|
}
|
||
|
|
||
|
/** to be connected to the OS page. Catches
|
||
|
* either KDE, CDE, win or mac and pre-sets the style.
|
||
|
*/
|
||
12 years ago
|
void TDEStylePage::presetStyle(const TQString& style){
|
||
|
kdDebug() << "TDEStylePage::presetStyle(): "<< style << endl;
|
||
15 years ago
|
if(style=="KDE") {
|
||
|
if (kde_plastik_exist)
|
||
|
klv_styles->setSelected(kde,true);
|
||
|
else if (kde_hc_exist || kde_def_exist)
|
||
|
klv_styles->setSelected(classic,true);
|
||
|
}
|
||
|
else if(style=="CDE" && cde_exist)
|
||
|
klv_styles->setSelected(cde,true);
|
||
|
else if(style=="win" && win_exist)
|
||
|
klv_styles->setSelected(win,true);
|
||
|
else if(style=="mac") {
|
||
|
klv_styles->setSelected(platinum,true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/** set the defaults for this page */
|
||
12 years ago
|
void TDEStylePage::setDefaults(){
|
||
15 years ago
|
}
|
||
|
|
||
|
/** Fill a colorSet with a colorfile, or the default. */
|
||
12 years ago
|
void TDEStylePage::getColors(colorSet *set, bool colorfile ){
|
||
12 years ago
|
TDEConfig* config;
|
||
15 years ago
|
bool deleteConfig = false;
|
||
|
// get the color scheme file and go to the color scheme group
|
||
|
if(colorfile){
|
||
12 years ago
|
TDEGlobal::dirs()->addResourceType("colors", TDEStandardDirs::kde_default("data")+"tdedisplay/color-schemes");
|
||
15 years ago
|
// set the style
|
||
|
if (kde->isSelected()) {
|
||
|
set->bgMode="Flat";
|
||
|
set->usrCol1.setNamedColor("#003082");
|
||
|
set->usrCol2.setNamedColor("#6C8BB9");
|
||
|
set->colorFile="<default>";
|
||
|
}
|
||
|
else if(classic->isSelected()){
|
||
|
set->bgMode="VerticalGradient";
|
||
|
set->usrCol1.setNamedColor ("#1E72A0");
|
||
|
set->usrCol2.setNamedColor ("#C0C0C0");
|
||
|
set->colorFile=locate("colors", "KDETwo.kcsrc");
|
||
|
}
|
||
|
else if(keramik->isSelected()){
|
||
|
set->bgMode="VerticalGradient";
|
||
|
set->usrCol1.setNamedColor ("#1E72A0");
|
||
|
set->usrCol2.setNamedColor ("#C0C0C0");
|
||
|
set->colorFile=locate("colors","Keramik.kcsrc");
|
||
|
}
|
||
|
else if(cde->isSelected()){
|
||
|
set->bgMode="Flat";
|
||
|
set->usrCol1.setNamedColor("#718BA5");
|
||
|
set->usrCol2.setNamedColor ("#C0C0C0");
|
||
|
set->colorFile=locate("colors","SolarisCDE.kcsrc");
|
||
|
}
|
||
|
else if(win->isSelected()){
|
||
|
set->bgMode="Flat";
|
||
|
set->usrCol1.setNamedColor("#008183");
|
||
|
set->usrCol2.setNamedColor ("#C0C0C0");
|
||
|
set->colorFile=locate("colors","Windows2000.kcsrc");
|
||
|
}
|
||
|
else if(platinum->isSelected()){
|
||
|
set->bgMode="VerticalGradient";
|
||
|
set->usrCol1.setNamedColor("#2A569D");
|
||
|
set->usrCol2.setNamedColor("#6C8BB9");
|
||
|
set->colorFile=locate("colors","EveX.kcsrc");
|
||
|
}
|
||
|
set->contrast=7;
|
||
|
config = new KSimpleConfig(set->colorFile, true);
|
||
|
config->setGroup("Color Scheme");
|
||
12 years ago
|
kdDebug() << "TDEStylePage::getColors(): schemefile: " << set->colorFile << endl;
|
||
15 years ago
|
deleteConfig = true;
|
||
|
}
|
||
|
else {
|
||
12 years ago
|
TDEConfig kdesktop("kdesktoprc");
|
||
15 years ago
|
kdesktop.setGroup("Desktop0");
|
||
|
// set Background (userSettings if available, else default)
|
||
|
set->bgMode=kdesktop.readEntry("BackgroundMode", "Flat");
|
||
14 years ago
|
TQColor tmp1("#003082");
|
||
|
TQColor tmp2("#C0C0C0");
|
||
15 years ago
|
set->usrCol1=kdesktop.readColorEntry("Color1", &tmp1);
|
||
|
set->usrCol2=kdesktop.readColorEntry("Color2", &tmp2);
|
||
|
// write the color scheme filename and the contrast, default 7, otherwise from file
|
||
12 years ago
|
config=TDEGlobal::config();
|
||
15 years ago
|
config->setGroup("KDE");
|
||
|
set->colorFile=config->readEntry("colorScheme", "<default>");
|
||
|
set->contrast=config->readNumEntry("contrast", 7);
|
||
|
config->setGroup( "General" );
|
||
12 years ago
|
kdDebug() << "TDEStylePage::getColors(): schemefile: "<< set->colorFile << endl;
|
||
15 years ago
|
}
|
||
|
set->foreground=config->readColorEntry( "foreground", &black );
|
||
|
set->background=config->readColorEntry( "background", &widget );
|
||
|
set->windowForeground=config->readColorEntry( "windowForeground", &black );
|
||
|
set->windowBackground=config->readColorEntry( "windowBackground", &white );
|
||
|
set->selectForeground=config->readColorEntry( "selectForeground", &white );
|
||
13 years ago
|
set->selectBackground=config->readColorEntry( "selectBackground", &trinity4Blue );
|
||
15 years ago
|
set->buttonForeground=config->readColorEntry( "buttonForeground", &black );
|
||
|
set->buttonBackground=config->readColorEntry( "buttonBackground", &button );
|
||
|
set->linkColor=config->readColorEntry( "linkColor", &link );
|
||
|
set->visitedLinkColor=config->readColorEntry( "visitedLinkColor", &visitedLink );
|
||
|
// it's necessary to set the group, when reading from globalrc
|
||
|
if(!colorfile)
|
||
|
config->setGroup( "WM" );
|
||
|
set->activeForeground=config->readColorEntry("activeForeground", &white);
|
||
|
set->inactiveForeground=config->readColorEntry("inactiveForeground", &inactiveForeground);
|
||
|
set->activeBackground=config->readColorEntry("activeBackground", &activeBackground);
|
||
|
set->inactiveBackground=config->readColorEntry("inactiveBackground", &inactiveBackground);
|
||
|
set->activeBlend=config->readColorEntry("activeBlend", &activeBlend);
|
||
|
set->inactiveBlend=config->readColorEntry("inactiveBlend", &inactiveBackground);
|
||
|
set->activeTitleBtnBg=config->readColorEntry("activeTitleBtnBg", &activeTitleBtnBg);
|
||
|
set->inactiveTitleBtnBg=config->readColorEntry("inactiveTitleBtnBg", &inactiveTitleBtnBg);
|
||
|
set->alternateBackground=config->readColorEntry("alternateBackground", &alternateBackground);
|
||
|
if ( deleteConfig)
|
||
|
delete config;
|
||
|
}
|
||
|
|
||
13 years ago
|
/** Test widget- and twin- styles for availability */
|
||
12 years ago
|
void TDEStylePage::getAvailability() {
|
||
15 years ago
|
// test, wich styles are available
|
||
|
kde_keramik_exist = kde_hc_exist = kde_def_exist = cde_exist
|
||
|
= kde_plastik_exist = win_exist = platinum_exist = false;
|
||
14 years ago
|
TQStringList styles = TQStyleFactory::keys();
|
||
|
for (TQStringList::iterator it = styles.begin(); it != styles.end(); it++) {
|
||
15 years ago
|
if (*it == "Keramik") kde_keramik_exist = true;
|
||
|
else if (*it == "HighColor") kde_hc_exist = true;
|
||
|
else if (*it == "Default") kde_def_exist = true;
|
||
|
else if (*it == "Plastik") kde_plastik_exist = true;
|
||
|
else if (*it == "Motif") cde_exist = true;
|
||
|
else if (*it == "Windows") win_exist = true;
|
||
|
else if (*it == "Platinum") platinum_exist = true;
|
||
|
else if (*it == "Light, 3rd revision") kde_light_exist = true;
|
||
|
}
|
||
|
// and disable the ListItems, if they are not.
|
||
13 years ago
|
if ( !(kde_plastik_exist || kde_light_exist) ) kde->setVisible(false);
|
||
|
if ( !(kde_hc_exist || kde_def_exist) ) classic->setVisible(false);
|
||
|
if (!kde_keramik_exist || TQPixmap::defaultDepth() <= 8) keramik->setVisible(false);
|
||
|
if (!cde_exist) cde->setVisible(false);
|
||
|
if (!win_exist) win->setVisible(false);
|
||
|
if (!platinum_exist) platinum->setVisible(false);
|
||
15 years ago
|
|
||
|
// test, wich KWin-styles are available
|
||
13 years ago
|
twin_keramik_exist = twin_system_exist = twin_plastik_exist
|
||
|
= twin_default_exist = twin_win_exist
|
||
|
= twin_cde_exist = twin_quartz_exist = false;
|
||
12 years ago
|
TDEStandardDirs* kstd = TDEGlobal::dirs();
|
||
13 years ago
|
if (!kstd->findResource("data", "twin/keramik.desktop").isNull())
|
||
|
twin_keramik_exist = true;
|
||
|
if (!kstd->findResource("data", "twin/plastik.desktop").isNull())
|
||
|
twin_plastik_exist = true;
|
||
|
if (!kstd->findResource("data", "twin/system.desktop").isNull())
|
||
|
twin_system_exist = true;
|
||
|
if (!kstd->findResource("data", "twin/redmond.desktop").isNull())
|
||
|
twin_win_exist = true;
|
||
|
if (!kstd->findResource("data", "twin/cde.desktop").isNull())
|
||
|
twin_cde_exist = true;
|
||
|
if (!kstd->findResource("data", "twin/quartz.desktop").isNull())
|
||
|
twin_quartz_exist = true;
|
||
|
twin_default_exist = true; // we can't check for a .desktop-file for the old default because there is none
|
||
15 years ago
|
|
||
|
// check, wich Icon-themes are available
|
||
|
icon_crystalsvg_exist = icon_kdeclassic_exist = icon_Locolor_exist = false;
|
||
12 years ago
|
TQStringList icons(TDEIconTheme::list());
|
||
14 years ago
|
for (TQStringList::iterator it=icons.begin(); it != icons.end(); it++) {
|
||
12 years ago
|
TDEIconTheme icontheme(*it);
|
||
15 years ago
|
if (icontheme.isHidden() || !icontheme.isValid()) continue;
|
||
|
if (*it == "crystalsvg") icon_crystalsvg_exist = true;
|
||
|
else if (*it == "kdeclassic") icon_kdeclassic_exist = true;
|
||
|
else if (*it == "Locolor") icon_Locolor_exist = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/** get the user's former settings */
|
||
12 years ago
|
void TDEStylePage::getUserDefaults() {
|
||
15 years ago
|
// Get the user's current widget-style
|
||
12 years ago
|
TDEGlobal::config()->setGroup("General");
|
||
12 years ago
|
origStyle = TDEGlobal::config()->readEntry( "widgetStyle", TDEStyle::defaultStyle() );
|
||
15 years ago
|
|
||
|
// get the user's current KWin-style
|
||
12 years ago
|
ctwin = new TDEConfig("twinrc");
|
||
13 years ago
|
ctwin->setGroup("Style");
|
||
|
origKWinStyle = ctwin->readEntry("PluginLib", defaultKWinStyle);
|
||
15 years ago
|
|
||
|
// get the users current colors
|
||
|
getColors(&usrColors, false);
|
||
|
|
||
|
// Get the user's current iconset
|
||
12 years ago
|
TDEGlobal::config()->setGroup("Icons");
|
||
|
origIcons = TDEGlobal::config()->readEntry("Theme");
|
||
15 years ago
|
|
||
12 years ago
|
kdDebug() << "TDEStylePage::getUserDefaults(): style: " << origStyle << endl;
|
||
|
kdDebug() << "TDEStylePage::getUserDefaults(): KWinStyle: " << origKWinStyle << endl;
|
||
|
kdDebug() << "TDEStylePage::getUserDefaults(): Colors: " << usrColors.colorFile << endl;
|
||
|
kdDebug() << "TDEStylePage::getUserDefaults(): Icons: " << origIcons << endl;
|
||
15 years ago
|
}
|
||
|
|
||
|
/** initialize KDE default color values */
|
||
12 years ago
|
void TDEStylePage::initColors() {
|
||
15 years ago
|
widget.setRgb(239, 239, 239);
|
||
13 years ago
|
trinity4Blue.setRgb(103,141,178);
|
||
15 years ago
|
inactiveBackground.setRgb(157,170,186);
|
||
|
activeBackground.setRgb(65,142,220);
|
||
|
inactiveForeground.setRgb(221,221,221);
|
||
|
activeBlend.setRgb(107,145,184);
|
||
|
activeTitleBtnBg.setRgb(127,158,200);
|
||
|
inactiveTitleBtnBg.setRgb(167,181,199);
|
||
|
alternateBackground.setRgb(237,244,249);
|
||
|
|
||
14 years ago
|
if (TQPixmap::defaultDepth() > 8)
|
||
15 years ago
|
button.setRgb(221, 223, 228);
|
||
|
else
|
||
|
button.setRgb(220, 220, 220);
|
||
|
|
||
|
link.setRgb(0, 0, 238);
|
||
|
visitedLink.setRgb(82, 24, 139);
|
||
|
}
|
||
|
|
||
|
/** live-update the system */
|
||
12 years ago
|
void TDEStylePage::liveUpdate() {
|
||
15 years ago
|
// tell all apps about the changed icons
|
||
12 years ago
|
for (int i=0; i<TDEIcon::LastGroup; i++) {
|
||
15 years ago
|
KIPC::sendMessageAll(KIPC::IconChanged, i);
|
||
|
}
|
||
|
// tell all apps about the changed style
|
||
|
KIPC::sendMessageAll(KIPC::StyleChanged);
|
||
|
// color palette changes
|
||
|
KIPC::sendMessageAll(KIPC::PaletteChanged);
|
||
13 years ago
|
// twin-style
|
||
|
kapp->dcopClient()->send("twin*", "", "reconfigure()", TQString(""));
|
||
15 years ago
|
// kdesktop-background
|
||
14 years ago
|
kapp->dcopClient()->send("kdesktop", "KBackgroundIface", "configure()", TQString(""));
|
||
15 years ago
|
}
|
||
|
|
||
|
/** show the previewWidget styled with the selected one */
|
||
12 years ago
|
void TDEStylePage::switchPrevStyle() {
|
||
14 years ago
|
TQStyle* style = TQStyleFactory::create(currentStyle);
|
||
15 years ago
|
if (!style) return;
|
||
|
|
||
|
stylePreview->unsetPalette();
|
||
14 years ago
|
TQPalette palette = createPalette();
|
||
15 years ago
|
style->polish(palette);
|
||
|
stylePreview->setPalette(palette);
|
||
|
|
||
|
// Prevent Qt from wrongly caching radio button images
|
||
14 years ago
|
TQPixmapCache::clear();
|
||
15 years ago
|
// go ahead
|
||
|
setStyleRecursive( stylePreview, palette, style );
|
||
|
// this flickers, but reliably draws the widgets corretly.
|
||
13 years ago
|
stylePreview->resize( stylePreview->sizeHint() );
|
||
15 years ago
|
|
||
|
delete appliedStyle;
|
||
|
appliedStyle = style;
|
||
|
}
|
||
|
|
||
12 years ago
|
void TDEStylePage::setStyleRecursive(TQWidget* w, TQPalette &palette, TQStyle* s) {
|
||
15 years ago
|
// Apply the new style.
|
||
|
w->setStyle(s);
|
||
|
// Recursively update all children.
|
||
14 years ago
|
const TQObjectList children = w->childrenListObject();
|
||
|
if (children.isEmpty())
|
||
15 years ago
|
return;
|
||
|
// Apply the style to each child widget.
|
||
14 years ago
|
TQPtrListIterator<TQObject> childit(children);
|
||
14 years ago
|
TQObject *child;
|
||
15 years ago
|
while ((child = childit.current()) != 0) {
|
||
|
++childit;
|
||
|
if (child->isWidgetType())
|
||
14 years ago
|
setStyleRecursive((TQWidget *) child, palette, s);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
/** create a TQPalette of our current colorset */
|
||
12 years ago
|
TQPalette TDEStylePage::createPalette() {
|
||
15 years ago
|
colorSet *cc = ¤tColors;
|
||
14 years ago
|
TQColorGroup disabledgrp(cc->windowForeground, cc->background, cc->background.light(150),
|
||
15 years ago
|
cc->background.dark(), cc->background.dark(120), cc->background.dark(120),
|
||
|
cc->windowBackground);
|
||
14 years ago
|
TQColorGroup colgrp(cc->windowForeground, cc->background, cc->background.light(150),
|
||
15 years ago
|
cc->background.dark(), cc->background.dark(120), cc->foreground,
|
||
|
cc->windowBackground);
|
||
14 years ago
|
colgrp.setColor(TQColorGroup::Highlight, cc->selectBackground);
|
||
|
colgrp.setColor(TQColorGroup::HighlightedText, cc->selectForeground);
|
||
|
colgrp.setColor(TQColorGroup::Button, cc->buttonBackground);
|
||
|
colgrp.setColor(TQColorGroup::ButtonText, cc->buttonForeground);
|
||
|
return TQPalette( colgrp, disabledgrp, colgrp);
|
||
15 years ago
|
}
|
||
|
|
||
11 years ago
|
#include "tdestylepage.moc"
|