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.
272 lines
8.2 KiB
272 lines
8.2 KiB
15 years ago
|
/*
|
||
|
* $Id$
|
||
|
*
|
||
|
* This file contains the IceWM configuration widget
|
||
|
*
|
||
|
* Copyright (c) 2001
|
||
|
* Karol Szwed <gallium@kde.org>
|
||
|
* http://gallium.n3.net/
|
||
|
*
|
||
|
* 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., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#include "config.h"
|
||
15 years ago
|
#include <tqdir.h>
|
||
|
#include <tqregexp.h>
|
||
|
#include <tqvbox.h>
|
||
|
#include <tqwhatsthis.h>
|
||
15 years ago
|
#include <kglobal.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kstandarddirs.h>
|
||
|
#include <kdialog.h>
|
||
|
#include <kdirwatch.h>
|
||
|
#include <kapplication.h>
|
||
|
|
||
|
|
||
|
extern "C"
|
||
|
{
|
||
15 years ago
|
KDE_EXPORT TQObject* allocate_config( KConfig* conf, TQWidget* parent )
|
||
15 years ago
|
{
|
||
|
return(new IceWMConfig(conf, parent));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
// NOTE:
|
||
|
// ==========================================================================
|
||
13 years ago
|
// 'conf' is a pointer to the twindecoration modules open twin config,
|
||
15 years ago
|
// and is by default set to the "Style" group.
|
||
|
//
|
||
15 years ago
|
// 'parent' is the parent of the TQObject, which is a VBox inside the
|
||
13 years ago
|
// Configure tab in twindecoration
|
||
15 years ago
|
// ==========================================================================
|
||
|
|
||
15 years ago
|
IceWMConfig::IceWMConfig( KConfig* conf, TQWidget* parent )
|
||
|
: TQObject( parent )
|
||
15 years ago
|
{
|
||
13 years ago
|
icewmConfig = new KConfig("twinicewmrc");
|
||
|
KGlobal::locale()->insertCatalogue("twin_art_clients");
|
||
15 years ago
|
|
||
15 years ago
|
mainWidget = new TQVBox( parent );
|
||
15 years ago
|
mainWidget->setSpacing( KDialog::spacingHint() );
|
||
|
|
||
15 years ago
|
themeListBox = new TQListBox( mainWidget );
|
||
|
TQWhatsThis::add( themeListBox,
|
||
15 years ago
|
i18n("Make your IceWM selection by clicking on a theme here. ") );
|
||
|
|
||
15 years ago
|
cbThemeTitleTextColors = new TQCheckBox(
|
||
15 years ago
|
i18n("Use theme &title text colors"), mainWidget );
|
||
|
|
||
15 years ago
|
TQWhatsThis::add( cbThemeTitleTextColors,
|
||
15 years ago
|
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.") );
|
||
|
|
||
15 years ago
|
cbTitleBarOnTop = new TQCheckBox(
|
||
15 years ago
|
i18n("&Show title bar on top of windows"), mainWidget );
|
||
|
|
||
15 years ago
|
TQWhatsThis::add( cbTitleBarOnTop,
|
||
15 years ago
|
i18n("When selected, all window titlebars will be shown "
|
||
|
"at the top of each window, otherwise they will be "
|
||
|
"shown at the bottom.") );
|
||
|
|
||
15 years ago
|
cbShowMenuButtonIcon = new TQCheckBox(
|
||
15 years ago
|
i18n("&Menu button always shows application mini icon"), mainWidget );
|
||
|
|
||
15 years ago
|
TQWhatsThis::add( cbShowMenuButtonIcon,
|
||
15 years ago
|
i18n("When selected, all titlebar menu buttons will have "
|
||
|
"the application icon shown. If not selected, the current "
|
||
|
"theme's defaults are used instead.") );
|
||
|
|
||
|
urlLabel = new KURLLabel( mainWidget );
|
||
|
urlLabel->setText( i18n("Open KDE's IceWM theme folder") );
|
||
|
|
||
15 years ago
|
themeLabel = new TQLabel(
|
||
15 years ago
|
i18n("Clicking on the link above will cause a window to appear "
|
||
|
"showing the KDE IceWM theme folder. You can "
|
||
|
"add or remove native IceWM themes by "
|
||
|
"uncompressing <b>http://icewm.themes.org/</b> theme files "
|
||
|
"into this folder, or by creating folder symlinks to "
|
||
|
"existing IceWM themes on your system."), mainWidget );
|
||
|
|
||
|
// Load configuration options
|
||
|
load( conf );
|
||
|
|
||
|
// Ensure we track user changes properly
|
||
15 years ago
|
connect( themeListBox, TQT_SIGNAL(selectionChanged()),
|
||
|
this, TQT_SLOT(slotSelectionChanged()) );
|
||
15 years ago
|
|
||
15 years ago
|
connect( urlLabel, TQT_SIGNAL(leftClickedURL(const TQString&)),
|
||
|
this, TQT_SLOT(callURL(const TQString&)));
|
||
15 years ago
|
|
||
15 years ago
|
connect( cbThemeTitleTextColors, TQT_SIGNAL(clicked()),
|
||
|
this, TQT_SLOT(slotSelectionChanged()) );
|
||
15 years ago
|
|
||
15 years ago
|
connect( cbTitleBarOnTop, TQT_SIGNAL(clicked()),
|
||
|
this, TQT_SLOT(slotSelectionChanged()) );
|
||
15 years ago
|
|
||
15 years ago
|
connect( cbShowMenuButtonIcon, TQT_SIGNAL(clicked()),
|
||
|
this, TQT_SLOT(slotSelectionChanged()) );
|
||
15 years ago
|
|
||
|
// Create the theme directory (if not found) ... and obtain the path as we do so.
|
||
13 years ago
|
localThemeString = KGlobal::dirs()->saveLocation("data", "twin");
|
||
15 years ago
|
localThemeString += "/icewm-themes";
|
||
15 years ago
|
if (!TQFile::exists(localThemeString))
|
||
|
TQDir().mkdir(localThemeString);
|
||
15 years ago
|
|
||
|
// Watch the icewm theme directory for theme additions/removals
|
||
|
KDirWatch::self()->addDir(localThemeString);
|
||
15 years ago
|
connect( KDirWatch::self(), TQT_SIGNAL(dirty(const TQString&)), this, TQT_SLOT(findIceWMThemes()) );
|
||
|
connect( KDirWatch::self(), TQT_SIGNAL(created(const TQString&)), this, TQT_SLOT(findIceWMThemes()) );
|
||
|
connect( KDirWatch::self(), TQT_SIGNAL(deleted(const TQString&)), this, TQT_SLOT(findIceWMThemes()) );
|
||
15 years ago
|
|
||
|
// Set the konqui link url
|
||
15 years ago
|
TQString urlThemeString = TQString("file://") + localThemeString;
|
||
|
urlThemeString.replace( TQRegExp("~"), "$HOME" );
|
||
15 years ago
|
urlLabel->setURL( urlThemeString );
|
||
|
|
||
13 years ago
|
// Make the widgets visible in twindecoration
|
||
15 years ago
|
mainWidget->show();
|
||
|
|
||
|
KDirWatch::self()->startScan();
|
||
|
}
|
||
|
|
||
|
|
||
|
IceWMConfig::~IceWMConfig()
|
||
|
{
|
||
|
KDirWatch::self()->removeDir(localThemeString);
|
||
|
KDirWatch::self()->stopScan();
|
||
|
delete icewmConfig;
|
||
|
delete mainWidget;
|
||
|
}
|
||
|
|
||
|
|
||
|
// Searches for all installed IceWM themes, and adds them to the listBox.
|
||
|
void IceWMConfig::findIceWMThemes()
|
||
|
{
|
||
13 years ago
|
TQStringList dirList = KGlobal::dirs()->findDirs("data", "twin/icewm-themes");
|
||
15 years ago
|
TQStringList::ConstIterator it;
|
||
15 years ago
|
|
||
|
// Remove any old themes in the list (if any)
|
||
|
themeListBox->clear();
|
||
|
themeListBox->insertItem( i18n("Infadel #2 (default)") );
|
||
|
|
||
13 years ago
|
// Step through all twin/icewm-themes directories...
|
||
15 years ago
|
for( it = dirList.begin(); it != dirList.end(); it++)
|
||
|
{
|
||
|
// List all directory names only...
|
||
15 years ago
|
TQDir d(*it, TQString("*"), TQDir::Unsorted, TQDir::Dirs | TQDir::Readable );
|
||
15 years ago
|
if (d.exists())
|
||
|
{
|
||
13 years ago
|
TQFileInfoListIterator it2( *d.entryInfoList() );
|
||
15 years ago
|
TQFileInfo* finfo;
|
||
15 years ago
|
|
||
13 years ago
|
// Step through all directories within the twin/icewm-themes directory
|
||
15 years ago
|
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();
|
||
|
|
||
|
// Select the currently used IceWM theme
|
||
15 years ago
|
TQString themeName = icewmConfig->readEntry("CurrentTheme");
|
||
15 years ago
|
|
||
|
// Provide a theme alias
|
||
|
if (themeName == "default")
|
||
|
themeName = "";
|
||
|
|
||
|
if (themeName.isEmpty())
|
||
|
themeListBox->setCurrentItem(
|
||
|
themeListBox->findItem( i18n("Infadel #2 (default)") ) );
|
||
|
else
|
||
|
themeListBox->setCurrentItem( themeListBox->findItem(themeName) );
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
void IceWMConfig::callURL( const TQString& s )
|
||
15 years ago
|
{
|
||
|
kapp->invokeBrowser( s );
|
||
|
}
|
||
|
|
||
|
|
||
|
void IceWMConfig::slotSelectionChanged()
|
||
|
{
|
||
|
emit changed();
|
||
|
}
|
||
|
|
||
|
|
||
13 years ago
|
// Loads the configurable options from the twinicewmrc config file
|
||
15 years ago
|
void IceWMConfig::load( KConfig* )
|
||
|
{
|
||
|
icewmConfig->setGroup("General");
|
||
|
|
||
|
bool override = icewmConfig->readBoolEntry( "ThemeTitleTextColors", true );
|
||
|
cbThemeTitleTextColors->setChecked( override );
|
||
|
|
||
|
override = icewmConfig->readBoolEntry( "TitleBarOnTop", true );
|
||
|
cbTitleBarOnTop->setChecked( override );
|
||
|
|
||
|
override = icewmConfig->readBoolEntry( "ShowMenuButtonIcon", false );
|
||
|
cbShowMenuButtonIcon->setChecked( override );
|
||
|
|
||
|
findIceWMThemes();
|
||
|
}
|
||
|
|
||
|
|
||
13 years ago
|
// Saves the configurable options to the twinicewmrc config file
|
||
15 years ago
|
void IceWMConfig::save( KConfig* )
|
||
|
{
|
||
|
icewmConfig->setGroup("General");
|
||
|
icewmConfig->writeEntry( "ThemeTitleTextColors", cbThemeTitleTextColors->isChecked() );
|
||
|
icewmConfig->writeEntry( "TitleBarOnTop", cbTitleBarOnTop->isChecked() );
|
||
|
icewmConfig->writeEntry( "ShowMenuButtonIcon", cbShowMenuButtonIcon->isChecked() );
|
||
|
|
||
|
if (themeListBox->currentText() == i18n("Infadel #2 (default)"))
|
||
|
icewmConfig->writeEntry("CurrentTheme", "default");
|
||
|
else
|
||
|
icewmConfig->writeEntry("CurrentTheme", themeListBox->currentText() );
|
||
|
|
||
|
icewmConfig->sync();
|
||
|
}
|
||
|
|
||
|
|
||
|
// 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"
|
||
|
// vim: ts=4
|