2001-06-04 11:49:35 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* This file contains the IceWM configuration widget
|
|
|
|
*
|
|
|
|
* Copyright (c) 2001
|
|
|
|
* Karol Szwed <gallium@kde.org>
|
|
|
|
* http://gallium.n3.net/
|
2001-07-02 05:35:31 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*
|
2001-06-04 11:49:35 +00:00
|
|
|
*/
|
2001-04-16 14:55:07 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <qdir.h>
|
|
|
|
#include <qregexp.h>
|
2001-04-21 08:59:53 +00:00
|
|
|
#include <qwhatsthis.h>
|
2001-07-15 12:14:54 +00:00
|
|
|
#include <kglobal.h>
|
2001-04-16 14:55:07 +00:00
|
|
|
#include <klocale.h>
|
|
|
|
#include <kstddirs.h>
|
2001-07-02 05:35:31 +00:00
|
|
|
#include <kdirwatch.h>
|
2001-04-16 14:55:07 +00:00
|
|
|
#include <kapp.h>
|
|
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
QObject* allocate_config( KConfig* conf, QWidget* parent )
|
|
|
|
{
|
|
|
|
return(new IceWMConfig(conf, parent));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE:
|
|
|
|
// ==========================================================================
|
|
|
|
// 'conf' is a pointer to the kwindecoration modules open kwin config,
|
|
|
|
// and is by default set to the "Style" group.
|
|
|
|
//
|
|
|
|
// 'parent' is the parent of the QObject, which is a VBox inside the
|
|
|
|
// Configure tab in kwindecoration
|
|
|
|
// ==========================================================================
|
|
|
|
|
|
|
|
IceWMConfig::IceWMConfig( KConfig* conf, QWidget* parent )
|
|
|
|
: QObject( parent )
|
|
|
|
{
|
2001-06-04 11:49:35 +00:00
|
|
|
icewmConfig = new KConfig("kwinicewmrc");
|
2001-07-15 12:14:54 +00:00
|
|
|
KGlobal::locale()->insertCatalogue("libkwinicewm_config");
|
2001-06-04 11:49:35 +00:00
|
|
|
|
|
|
|
gb1 = new QGroupBox( 1, Qt::Horizontal,
|
|
|
|
i18n("IceWM Theme Selector"), parent );
|
|
|
|
|
2001-04-16 14:55:07 +00:00
|
|
|
themeListBox = new QListBox( gb1 );
|
2001-06-04 11:49:35 +00:00
|
|
|
QWhatsThis::add( themeListBox,
|
|
|
|
i18n("Make your IceWM selection by clicking on a theme here. ") );
|
|
|
|
|
|
|
|
themeLabel = new QLabel(
|
|
|
|
i18n("To manage your IceWM themes, simply click on the "
|
|
|
|
"link below to open a Konqueror window. Once shown, you "
|
|
|
|
"will be able to add or remove native IceWM themes, by "
|
|
|
|
"uncompressing <b>http://icewm.themes.org/</b> theme files "
|
|
|
|
"into this directory, or creating directory symlinks to "
|
|
|
|
"existing IceWM themes on your system."), parent );
|
2001-04-21 08:59:53 +00:00
|
|
|
|
2001-04-16 14:55:07 +00:00
|
|
|
urlLabel = new KURLLabel( parent );
|
2001-06-04 11:49:35 +00:00
|
|
|
urlLabel->setText(
|
|
|
|
i18n("Open Konqueror Window at KDE's IceWM theme directory") );
|
|
|
|
|
|
|
|
gb2 = new QGroupBox( 1, Qt::Horizontal,
|
|
|
|
i18n("IceWM Decoration Settings"), parent );
|
|
|
|
|
|
|
|
cbThemeTitleTextColors = new QCheckBox(
|
|
|
|
i18n("Use theme &title text colors"), gb2 );
|
|
|
|
|
|
|
|
QWhatsThis::add( cbThemeTitleTextColors,
|
|
|
|
i18n("When selected, titlebar colors will follow those set "
|
|
|
|
"in the IceWM theme. If not selected, the current KDE "
|
|
|
|
"titlebar colors will be used instead.") );
|
2001-04-16 14:55:07 +00:00
|
|
|
|
2001-06-04 11:49:35 +00:00
|
|
|
cbTitleBarOnTop = new QCheckBox(
|
|
|
|
i18n("&Show title bar on top of windows"), gb2 );
|
2001-04-21 08:59:53 +00:00
|
|
|
|
2001-06-04 11:49:35 +00:00
|
|
|
QWhatsThis::add( cbTitleBarOnTop,
|
|
|
|
i18n("When selected, all window titlebars will be shown "
|
|
|
|
"at the top of each window, otherwise they will be "
|
|
|
|
"shown at the bottom.") );
|
2001-04-21 08:59:53 +00:00
|
|
|
|
2001-06-04 11:49:35 +00:00
|
|
|
cbShowMenuButtonIcon = new QCheckBox(
|
|
|
|
i18n("&Menu button always shows application mini icon"), gb2 );
|
|
|
|
|
|
|
|
QWhatsThis::add( cbShowMenuButtonIcon,
|
|
|
|
i18n("When selected, all titlebar menu buttons will have "
|
|
|
|
"the application icon shown. If not selected, the current "
|
|
|
|
"theme's defaults are used instead.") );
|
2001-04-16 14:55:07 +00:00
|
|
|
|
|
|
|
// Load configuration options
|
|
|
|
load( conf );
|
|
|
|
|
|
|
|
// Ensure we track user changes properly
|
2001-06-04 11:49:35 +00:00
|
|
|
connect( themeListBox, SIGNAL(selectionChanged()),
|
|
|
|
this, SLOT(slotSelectionChanged()) );
|
|
|
|
|
|
|
|
connect( urlLabel, SIGNAL(leftClickedURL(const QString&)),
|
|
|
|
this, SLOT(callURL(const QString&)));
|
|
|
|
|
|
|
|
connect( cbThemeTitleTextColors, SIGNAL(clicked()),
|
|
|
|
this, SLOT(slotSelectionChanged()) );
|
|
|
|
|
|
|
|
connect( cbTitleBarOnTop, SIGNAL(clicked()),
|
|
|
|
this, SLOT(slotSelectionChanged()) );
|
|
|
|
|
|
|
|
connect( cbShowMenuButtonIcon, SIGNAL(clicked()),
|
|
|
|
this, SLOT(slotSelectionChanged()) );
|
2001-04-16 14:55:07 +00:00
|
|
|
|
2001-04-18 03:33:01 +00:00
|
|
|
// Create the theme directory (if not found) ... and obtain the path as we do so.
|
2001-07-02 05:35:31 +00:00
|
|
|
localThemeString = KGlobal::dirs()->saveLocation("data", "kwin");
|
2001-04-16 14:55:07 +00:00
|
|
|
localThemeString += "/icewm-themes";
|
|
|
|
if (!QFile::exists(localThemeString))
|
|
|
|
QDir().mkdir(localThemeString);
|
|
|
|
|
2001-07-02 05:35:31 +00:00
|
|
|
// Watch the icewm theme directory for theme additions/removals
|
|
|
|
KDirWatch::self()->addDir(localThemeString);
|
|
|
|
connect( KDirWatch::self(), SIGNAL(dirty(const QString&)), this, SLOT(findIceWMThemes()) );
|
|
|
|
|
2001-04-16 14:55:07 +00:00
|
|
|
// Set the konqui link url
|
2001-07-02 05:35:31 +00:00
|
|
|
QString urlThemeString = QString("file://") + localThemeString;
|
|
|
|
urlThemeString.replace( QRegExp("~"), "$HOME" );
|
|
|
|
urlLabel->setURL( urlThemeString );
|
2001-04-16 14:55:07 +00:00
|
|
|
|
|
|
|
// Make the widgets visible in kwindecoration
|
|
|
|
gb1->show();
|
|
|
|
themeLabel->show();
|
|
|
|
urlLabel->show();
|
|
|
|
gb2->show();
|
2001-07-02 05:35:31 +00:00
|
|
|
|
|
|
|
KDirWatch::self()->startScan();
|
2001-04-16 14:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IceWMConfig::~IceWMConfig()
|
|
|
|
{
|
2001-07-02 05:35:31 +00:00
|
|
|
KDirWatch::self()->removeDir(localThemeString);
|
|
|
|
KDirWatch::self()->stopScan();
|
2001-04-16 14:55:07 +00:00
|
|
|
delete gb2;
|
|
|
|
delete urlLabel;
|
|
|
|
delete themeLabel;
|
|
|
|
delete gb1;
|
2001-06-04 11:49:35 +00:00
|
|
|
delete icewmConfig;
|
2001-04-16 14:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Searches for all installed IceWM themes, and adds them to the listBox.
|
|
|
|
void IceWMConfig::findIceWMThemes()
|
|
|
|
{
|
|
|
|
QStringList dirList = KGlobal::dirs()->findDirs("data", "kwin/icewm-themes");
|
|
|
|
QStringList::ConstIterator it;
|
|
|
|
|
|
|
|
// Remove any old themes in the list (if any)
|
|
|
|
themeListBox->clear();
|
|
|
|
themeListBox->insertItem( i18n("Infadel #2 (default)") );
|
|
|
|
|
|
|
|
// Step through all kwin/icewm-themes directories...
|
|
|
|
for( it = dirList.begin(); it != dirList.end(); it++)
|
|
|
|
{
|
|
|
|
// List all directory names only...
|
|
|
|
QDir d(*it, QString("*"), QDir::Unsorted, QDir::Dirs | QDir::Readable );
|
|
|
|
if (d.exists())
|
|
|
|
{
|
|
|
|
QFileInfoListIterator it2( *d.entryInfoList() );
|
|
|
|
QFileInfo* finfo;
|
|
|
|
|
|
|
|
// Step through all directories within the kwin/icewm-themes directory
|
|
|
|
while( (finfo = it2.current()) )
|
|
|
|
{
|
|
|
|
// Ignore . and .. directories
|
|
|
|
if ( (finfo->fileName() == ".") || (finfo->fileName() == "..") )
|
|
|
|
{
|
|
|
|
++it2;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !themeListBox->findItem( finfo->fileName()) )
|
|
|
|
themeListBox->insertItem( finfo->fileName() );
|
|
|
|
|
|
|
|
++it2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort the items
|
|
|
|
themeListBox->sort();
|
2001-07-02 05:35:31 +00:00
|
|
|
|
|
|
|
// Select the currently used IceWM theme
|
|
|
|
QString themeName = icewmConfig->readEntry("CurrentTheme", "");
|
|
|
|
|
|
|
|
// Provide a theme alias
|
|
|
|
if (themeName == "default")
|
|
|
|
themeName = "";
|
|
|
|
|
|
|
|
if (themeName == "")
|
|
|
|
themeListBox->setCurrentItem(
|
|
|
|
themeListBox->findItem( i18n("Infadel #2 (default)") ) );
|
|
|
|
else
|
|
|
|
themeListBox->setCurrentItem( themeListBox->findItem(themeName) );
|
2001-04-16 14:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void IceWMConfig::callURL( const QString& s )
|
|
|
|
{
|
|
|
|
kapp->invokeBrowser( s );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void IceWMConfig::slotSelectionChanged()
|
|
|
|
{
|
|
|
|
emit changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 11:49:35 +00:00
|
|
|
// Loads the configurable options from the kwinicewmrc config file
|
|
|
|
void IceWMConfig::load( KConfig* )
|
2001-04-16 14:55:07 +00:00
|
|
|
{
|
2001-06-04 11:49:35 +00:00
|
|
|
icewmConfig->setGroup("General");
|
2001-04-16 14:55:07 +00:00
|
|
|
|
2001-06-04 11:49:35 +00:00
|
|
|
bool override = icewmConfig->readBoolEntry( "ThemeTitleTextColors", true );
|
2001-04-16 14:55:07 +00:00
|
|
|
cbThemeTitleTextColors->setChecked( override );
|
|
|
|
|
2001-06-04 11:49:35 +00:00
|
|
|
override = icewmConfig->readBoolEntry( "TitleBarOnTop", true );
|
2001-04-16 14:55:07 +00:00
|
|
|
cbTitleBarOnTop->setChecked( override );
|
|
|
|
|
2001-06-04 11:49:35 +00:00
|
|
|
override = icewmConfig->readBoolEntry( "ShowMenuButtonIcon", false );
|
2001-04-16 14:55:07 +00:00
|
|
|
cbShowMenuButtonIcon->setChecked( override );
|
|
|
|
|
|
|
|
findIceWMThemes();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-04 11:49:35 +00:00
|
|
|
// Saves the configurable options to the kwinicewmrc config file
|
|
|
|
void IceWMConfig::save( KConfig* )
|
2001-04-16 14:55:07 +00:00
|
|
|
{
|
2001-06-04 11:49:35 +00:00
|
|
|
icewmConfig->setGroup("General");
|
|
|
|
icewmConfig->writeEntry( "ThemeTitleTextColors", cbThemeTitleTextColors->isChecked() );
|
|
|
|
icewmConfig->writeEntry( "TitleBarOnTop", cbTitleBarOnTop->isChecked() );
|
|
|
|
icewmConfig->writeEntry( "ShowMenuButtonIcon", cbShowMenuButtonIcon->isChecked() );
|
2001-04-16 14:55:07 +00:00
|
|
|
|
|
|
|
if (themeListBox->currentText() == i18n("Infadel #2 (default)"))
|
2001-06-04 11:49:35 +00:00
|
|
|
icewmConfig->writeEntry("CurrentTheme", "default");
|
2001-04-16 14:55:07 +00:00
|
|
|
else
|
2001-06-04 11:49:35 +00:00
|
|
|
icewmConfig->writeEntry("CurrentTheme", themeListBox->currentText() );
|
|
|
|
|
|
|
|
icewmConfig->sync();
|
2001-04-16 14:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Sets UI widget defaults which must correspond to config defaults
|
|
|
|
void IceWMConfig::defaults()
|
|
|
|
{
|
|
|
|
cbThemeTitleTextColors->setChecked( true );
|
|
|
|
cbTitleBarOnTop->setChecked( true );
|
|
|
|
cbShowMenuButtonIcon->setChecked( false );
|
|
|
|
themeListBox->setCurrentItem( themeListBox->findItem(i18n("Infadel #2 (default)")) );
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "config.moc"
|
2001-06-04 11:49:35 +00:00
|
|
|
// vim: ts=4
|