2002-01-16 12:26:03 +00:00
|
|
|
/*
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
This is the new kwindecoration kcontrol module
|
|
|
|
|
|
|
|
Copyright (c) 2001
|
|
|
|
Karol Szwed <gallium@kde.org>
|
|
|
|
http://gallium.n3.net/
|
|
|
|
|
|
|
|
Supports new kwin configuration plugins, and titlebar button position
|
|
|
|
modification via dnd interface.
|
|
|
|
|
2003-06-30 08:14:54 +00:00
|
|
|
Based on original "kwintheme" (Window Borders)
|
2002-01-16 12:26:03 +00:00
|
|
|
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
|
2003-09-19 11:14:41 +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; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
2002-01-16 12:26:03 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-24 12:41:56 +00:00
|
|
|
#include <assert.h>
|
2002-01-16 12:26:03 +00:00
|
|
|
#include <qdir.h>
|
|
|
|
#include <qfileinfo.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qwhatsthis.h>
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qtabwidget.h>
|
|
|
|
#include <qvbox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qfile.h>
|
2003-09-24 12:41:56 +00:00
|
|
|
#include <qslider.h>
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
#include <kapplication.h>
|
2003-06-30 08:14:54 +00:00
|
|
|
#include <kcombobox.h>
|
2002-01-16 12:26:03 +00:00
|
|
|
#include <kdebug.h>
|
|
|
|
#include <kdesktopfile.h>
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
#include <kglobal.h>
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kdialog.h>
|
|
|
|
#include <kgenericfactory.h>
|
|
|
|
#include <kaboutdata.h>
|
|
|
|
#include <dcopclient.h>
|
|
|
|
|
|
|
|
#include "kwindecoration.h"
|
2003-09-16 19:34:03 +00:00
|
|
|
#include "preview.h"
|
|
|
|
#include <kdecoration_plugins_p.h>
|
2003-09-24 12:41:56 +00:00
|
|
|
#include <kdecorationfactory.h>
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
// KCModule plugin interface
|
|
|
|
// =========================
|
|
|
|
typedef KGenericFactory<KWinDecorationModule, QWidget> KWinDecoFactory;
|
2003-07-26 10:41:28 +00:00
|
|
|
K_EXPORT_COMPONENT_FACTORY( kcm_kwindecoration, KWinDecoFactory("kcmkwindecoration") )
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
KWinDecorationModule::KWinDecorationModule(QWidget* parent, const char* name, const QStringList &)
|
2003-09-16 19:34:03 +00:00
|
|
|
: DCOPObject("KWinClientDecoration"),
|
|
|
|
KCModule(KWinDecoFactory::instance(), parent, name),
|
|
|
|
kwinConfig("kwinrc"),
|
|
|
|
pluginObject(0)
|
2002-01-16 12:26:03 +00:00
|
|
|
{
|
|
|
|
kwinConfig.setGroup("Style");
|
2003-09-16 19:34:03 +00:00
|
|
|
plugins = new KDecorationPlugins( &kwinConfig );
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
|
|
tabWidget = new QTabWidget( this );
|
|
|
|
layout->addWidget( tabWidget );
|
|
|
|
|
|
|
|
// Page 1 (General Options)
|
2003-06-30 08:14:54 +00:00
|
|
|
QWidget *pluginPage = new QWidget( tabWidget );
|
|
|
|
|
|
|
|
QHBox *hbox = new QHBox(pluginPage);
|
|
|
|
hbox->setSpacing(KDialog::spacingHint());
|
|
|
|
// QLabel *lbl = new QLabel( i18n("&Decoration:"), hbox );
|
|
|
|
decorationList = new KComboBox( hbox );
|
|
|
|
// lbl->setBuddy(decorationList);
|
|
|
|
QString whatsThis = i18n("Select the window decoration. This is the look and feel of both "
|
|
|
|
"the window borders and the window handle.");
|
|
|
|
// QWhatsThis::add(lbl, whatsThis);
|
|
|
|
QWhatsThis::add(decorationList, whatsThis);
|
|
|
|
|
|
|
|
QVBoxLayout* pluginLayout = new QVBoxLayout(pluginPage, KDialog::marginHint(), KDialog::spacingHint());
|
|
|
|
pluginLayout->addWidget(hbox);
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
// Save this for later...
|
|
|
|
// cbUseMiniWindows = new QCheckBox( i18n( "Render mini &titlebars for all windows"), checkGroup );
|
|
|
|
// QWhatsThis::add( cbUseMiniWindows, i18n( "Note that this option is not available on all styles yet!" ) );
|
|
|
|
|
2003-10-23 14:56:44 +00:00
|
|
|
QFrame* preview_frame = new QFrame( pluginPage );
|
|
|
|
preview_frame->setFrameShape( QFrame::NoFrame );
|
|
|
|
QVBoxLayout* preview_layout = new QVBoxLayout( preview_frame, 0 );
|
|
|
|
preview = new KDecorationPreview( preview_frame );
|
|
|
|
preview_layout->addWidget( preview );
|
|
|
|
pluginLayout->addWidget( preview_frame );
|
|
|
|
pluginLayout->setStretchFactor( preview_frame, 10 );
|
|
|
|
|
|
|
|
pluginSettingsGrp = new QGroupBox( i18n("Decoration Options"), pluginPage );
|
|
|
|
pluginSettingsGrp->setColumnLayout( 0, Vertical );
|
|
|
|
pluginSettingsGrp->setFlat( true );
|
|
|
|
pluginSettingsGrp->layout()->setMargin( 0 );
|
|
|
|
pluginSettingsGrp->layout()->setSpacing( KDialog::spacingHint() );
|
|
|
|
pluginLayout->addWidget( pluginSettingsGrp );
|
|
|
|
|
|
|
|
pluginConfigWidget = new QVBox(pluginSettingsGrp);
|
|
|
|
pluginSettingsGrp->layout()->add( pluginConfigWidget );
|
2003-09-16 19:34:03 +00:00
|
|
|
|
2002-01-16 12:26:03 +00:00
|
|
|
// Page 2 (Button Selector)
|
2003-09-16 19:34:03 +00:00
|
|
|
QVBox* buttonPage = new QVBox( tabWidget );
|
2002-01-16 12:26:03 +00:00
|
|
|
buttonPage->setSpacing( KDialog::spacingHint() );
|
|
|
|
buttonPage->setMargin( KDialog::marginHint() );
|
|
|
|
|
2003-05-31 17:40:57 +00:00
|
|
|
cbShowToolTips = new QCheckBox(
|
|
|
|
i18n("&Show window button tooltips"), buttonPage );
|
|
|
|
QWhatsThis::add( cbShowToolTips,
|
|
|
|
i18n( "Enabling this checkbox will show window button tooltips. "
|
|
|
|
"If this checkbox is off, no window button tooltips will be shown."));
|
2002-01-16 12:26:03 +00:00
|
|
|
|
2003-09-24 12:41:56 +00:00
|
|
|
lBorder = new QLabel( buttonPage );
|
|
|
|
slBorder = new QSlider( Horizontal, buttonPage );
|
|
|
|
QWhatsThis::add( slBorder, i18n( "This slider shows all border sizes supported by this decoration." ));
|
|
|
|
lBorder->setBuddy( slBorder );
|
|
|
|
lBorder->hide();
|
|
|
|
slBorder->hide();
|
2003-10-23 14:56:44 +00:00
|
|
|
|
2003-05-31 17:40:57 +00:00
|
|
|
cbUseCustomButtonPositions = new QCheckBox(
|
|
|
|
i18n("Use custom titlebar button &positions"), buttonPage );
|
|
|
|
QWhatsThis::add( cbUseCustomButtonPositions,
|
|
|
|
i18n( "The appropriate settings can be found in the \"Buttons\" Tab. "
|
|
|
|
"Please note that this option is not available on all styles yet!" ) );
|
|
|
|
|
|
|
|
buttonBox = new QGroupBox( 1, Qt::Horizontal,
|
|
|
|
i18n("Titlebar Button Positions"), buttonPage );
|
|
|
|
|
|
|
|
// Add nifty dnd button modification widgets
|
2002-01-16 12:26:03 +00:00
|
|
|
QLabel* label = new QLabel( buttonBox );
|
|
|
|
dropSite = new ButtonDropSite( buttonBox );
|
2003-10-10 12:56:02 +00:00
|
|
|
label->setAlignment( int( QLabel::WordBreak ) );
|
2002-01-16 12:26:03 +00:00
|
|
|
label->setText( i18n( "To add or remove titlebar buttons, simply <i>drag</i> items "
|
|
|
|
"between the available item list and the titlebar preview. Similarly, "
|
|
|
|
"drag items within the titlebar preview to re-position them.") );
|
|
|
|
buttonSource = new ButtonSource( buttonBox );
|
|
|
|
|
|
|
|
// Load all installed decorations into memory
|
|
|
|
// Set up the decoration lists and other UI settings
|
|
|
|
findDecorations();
|
|
|
|
createDecorationList();
|
|
|
|
readConfig( &kwinConfig );
|
2002-05-10 02:12:51 +00:00
|
|
|
resetPlugin( &kwinConfig );
|
2002-01-16 12:26:03 +00:00
|
|
|
|
2003-06-30 08:14:54 +00:00
|
|
|
tabWidget->insertTab( pluginPage, i18n("&Window Decoration") );
|
2002-01-16 12:26:03 +00:00
|
|
|
tabWidget->insertTab( buttonPage, i18n("&Buttons") );
|
|
|
|
|
|
|
|
connect( dropSite, SIGNAL(buttonAdded(char)), buttonSource, SLOT(hideButton(char)) );
|
|
|
|
connect( dropSite, SIGNAL(buttonRemoved(char)), buttonSource, SLOT(showButton(char)) );
|
|
|
|
connect( buttonSource, SIGNAL(buttonDropped()), dropSite, SLOT(removeClickedButton()) );
|
|
|
|
connect( dropSite, SIGNAL(changed()), this, SLOT(slotSelectionChanged()) );
|
|
|
|
connect( buttonSource, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()) );
|
2003-06-30 08:14:54 +00:00
|
|
|
connect( decorationList, SIGNAL(activated(const QString&)), SLOT(slotSelectionChanged()) );
|
|
|
|
connect( decorationList, SIGNAL(activated(const QString&)),
|
|
|
|
SLOT(slotChangeDecoration(const QString&)) );
|
2002-01-16 12:26:03 +00:00
|
|
|
connect( cbUseCustomButtonPositions, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
|
2003-05-31 17:40:57 +00:00
|
|
|
connect(cbUseCustomButtonPositions, SIGNAL(toggled(bool)), buttonBox, SLOT(setEnabled(bool)));
|
2002-01-16 12:26:03 +00:00
|
|
|
connect( cbShowToolTips, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
|
2003-09-24 12:41:56 +00:00
|
|
|
connect( slBorder, SIGNAL( valueChanged( int )), SLOT( slotBorderChanged( int )));
|
2002-01-16 12:26:03 +00:00
|
|
|
// connect( cbUseMiniWindows, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
|
|
|
|
|
|
|
|
// Allow kwin dcop signal to update our selection list
|
|
|
|
connectDCOPSignal("kwin", 0, "dcopResetAllClients()", "dcopUpdateClientList()", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KWinDecorationModule::~KWinDecorationModule()
|
|
|
|
{
|
2003-09-16 19:34:03 +00:00
|
|
|
delete preview; // needs to be destroyed before plugins
|
|
|
|
delete plugins;
|
2002-01-16 12:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Find all theme desktop files in all 'data' dirs owned by kwin.
|
|
|
|
// And insert these into a DecorationInfo structure
|
|
|
|
void KWinDecorationModule::findDecorations()
|
|
|
|
{
|
|
|
|
QStringList dirList = KGlobal::dirs()->findDirs("data", "kwin");
|
|
|
|
QStringList::ConstIterator it;
|
|
|
|
|
|
|
|
for (it = dirList.begin(); it != dirList.end(); it++)
|
|
|
|
{
|
|
|
|
QDir d(*it);
|
|
|
|
if (d.exists())
|
|
|
|
for (QFileInfoListIterator it(*d.entryInfoList()); it.current(); ++it)
|
|
|
|
{
|
|
|
|
QString filename(it.current()->absFilePath());
|
|
|
|
if (KDesktopFile::isDesktopFile(filename))
|
|
|
|
{
|
|
|
|
KDesktopFile desktopFile(filename);
|
|
|
|
QString libName = desktopFile.readEntry("X-KDE-Library");
|
|
|
|
|
2003-09-16 19:34:03 +00:00
|
|
|
if (!libName.isEmpty() && libName.startsWith( "kwin3_" ))
|
2002-01-16 12:26:03 +00:00
|
|
|
{
|
|
|
|
DecorationInfo di;
|
|
|
|
di.name = desktopFile.readName();
|
|
|
|
di.libraryName = libName;
|
|
|
|
decorations.append( di );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-30 08:14:54 +00:00
|
|
|
// Fills the decorationList with a list of available kwin decorations
|
2002-01-16 12:26:03 +00:00
|
|
|
void KWinDecorationModule::createDecorationList()
|
|
|
|
{
|
|
|
|
QValueList<DecorationInfo>::ConstIterator it;
|
|
|
|
|
|
|
|
// Sync with kwin hardcoded KDE2 style which has no desktop item
|
2003-06-30 08:14:54 +00:00
|
|
|
QStringList decorationNames;
|
|
|
|
decorationNames.append( i18n("KDE 2") );
|
2002-01-16 12:26:03 +00:00
|
|
|
for (it = decorations.begin(); it != decorations.end(); ++it)
|
|
|
|
{
|
2003-06-30 08:14:54 +00:00
|
|
|
decorationNames.append((*it).name);
|
2002-01-16 12:26:03 +00:00
|
|
|
}
|
2003-06-30 08:14:54 +00:00
|
|
|
decorationNames.sort();
|
|
|
|
decorationList->insertStringList(decorationNames);
|
2002-01-16 12:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Reset the decoration plugin to what the user just selected
|
2003-06-30 08:14:54 +00:00
|
|
|
void KWinDecorationModule::slotChangeDecoration( const QString & text)
|
2002-01-16 12:26:03 +00:00
|
|
|
{
|
|
|
|
KConfig kwinConfig("kwinrc");
|
|
|
|
kwinConfig.setGroup("Style");
|
|
|
|
|
|
|
|
// Let the user see config options for the currently selected decoration
|
2003-06-30 08:14:54 +00:00
|
|
|
resetPlugin( &kwinConfig, text );
|
2002-01-16 12:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This is the selection handler setting
|
|
|
|
void KWinDecorationModule::slotSelectionChanged()
|
|
|
|
{
|
2003-09-16 19:34:03 +00:00
|
|
|
setChanged(true);
|
2002-01-16 12:26:03 +00:00
|
|
|
}
|
|
|
|
|
2003-09-24 12:41:56 +00:00
|
|
|
static const char* const border_names[ KDecorationDefines::BordersCount ] =
|
|
|
|
{
|
|
|
|
I18N_NOOP( "Border size: Tiny" ),
|
|
|
|
I18N_NOOP( "Border size: Normal" ),
|
|
|
|
I18N_NOOP( "Border size: Large" ),
|
|
|
|
I18N_NOOP( "Border size: Very Large" ),
|
|
|
|
I18N_NOOP( "Border size: Huge" ),
|
|
|
|
I18N_NOOP( "Border size: Very Huge" ),
|
|
|
|
I18N_NOOP( "Border size: Oversized" )
|
|
|
|
};
|
|
|
|
|
|
|
|
int KWinDecorationModule::borderSizeToIndex( BorderSize size, QValueList< BorderSize > sizes )
|
|
|
|
{
|
|
|
|
int pos = 0;
|
|
|
|
for( QValueList< BorderSize >::ConstIterator it = sizes.begin();
|
|
|
|
it != sizes.end();
|
|
|
|
++it, ++pos )
|
|
|
|
if( size <= *it )
|
|
|
|
break;
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
KDecorationDefines::BorderSize KWinDecorationModule::indexToBorderSize( int index,
|
|
|
|
QValueList< BorderSize > sizes )
|
|
|
|
{
|
|
|
|
QValueList< BorderSize >::ConstIterator it = sizes.begin();
|
|
|
|
for(;
|
|
|
|
it != sizes.end();
|
|
|
|
++it, --index )
|
|
|
|
if( index == 0 )
|
|
|
|
break;
|
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinDecorationModule::slotBorderChanged( int size )
|
|
|
|
{
|
|
|
|
if( lBorder->isHidden())
|
|
|
|
return;
|
|
|
|
setChanged( true );
|
|
|
|
QValueList< BorderSize > sizes;
|
|
|
|
if( plugins->factory() != NULL )
|
|
|
|
sizes = plugins->factory()->borderSizes();
|
|
|
|
assert( sizes.count() >= 2 );
|
|
|
|
border_size = indexToBorderSize( size, sizes );
|
|
|
|
lBorder->setText( i18n( border_names[ border_size ] ));
|
|
|
|
}
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
QString KWinDecorationModule::decorationName( QString& libName )
|
|
|
|
{
|
|
|
|
QString decoName;
|
|
|
|
|
|
|
|
QValueList<DecorationInfo>::Iterator it;
|
|
|
|
for( it = decorations.begin(); it != decorations.end(); ++it )
|
|
|
|
if ( (*it).libraryName == libName )
|
|
|
|
{
|
|
|
|
decoName = (*it).name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return decoName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString KWinDecorationModule::decorationLibName( const QString& name )
|
|
|
|
{
|
|
|
|
QString libName;
|
|
|
|
|
|
|
|
// Find the corresponding library name to that of
|
|
|
|
// the current plugin name
|
|
|
|
QValueList<DecorationInfo>::Iterator it;
|
|
|
|
for( it = decorations.begin(); it != decorations.end(); ++it )
|
|
|
|
if ( (*it).name == name )
|
|
|
|
{
|
|
|
|
libName = (*it).libraryName;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (libName.isEmpty())
|
2003-06-30 08:14:54 +00:00
|
|
|
libName = "kwin_default"; // KDE 2
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
return libName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Loads/unloads and inserts the decoration config plugin into the
|
2003-06-30 08:14:54 +00:00
|
|
|
// pluginConfigWidget, allowing for dynamic configuration of decorations
|
|
|
|
void KWinDecorationModule::resetPlugin( KConfig* conf, const QString& currentDecoName )
|
2002-01-16 12:26:03 +00:00
|
|
|
{
|
2002-02-19 16:56:16 +00:00
|
|
|
// Config names are "kwin_icewm_config"
|
2003-09-16 19:34:03 +00:00
|
|
|
// for "kwin3_icewm" kwin client
|
2002-01-16 12:26:03 +00:00
|
|
|
|
2003-09-16 19:34:03 +00:00
|
|
|
QString oldName = styleToConfigLib( oldLibraryName );
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
QString currentName;
|
2003-06-30 08:14:54 +00:00
|
|
|
if (!currentDecoName.isEmpty())
|
|
|
|
currentName = decorationLibName( currentDecoName ); // Use what the user selected
|
2002-01-16 12:26:03 +00:00
|
|
|
else
|
|
|
|
currentName = currentLibraryName; // Use what was read from readConfig()
|
|
|
|
|
2003-09-16 19:34:03 +00:00
|
|
|
if( plugins->loadPlugin( currentName )
|
|
|
|
&& preview->recreateDecoration( plugins ))
|
|
|
|
preview->enablePreview();
|
|
|
|
else
|
|
|
|
preview->disablePreview();
|
|
|
|
plugins->destroyPreviousPlugin();
|
2003-09-24 12:41:56 +00:00
|
|
|
|
|
|
|
checkSupportedBorderSizes();
|
|
|
|
|
2003-09-16 19:34:03 +00:00
|
|
|
currentName = styleToConfigLib( currentName );
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
// Delete old plugin widget if it exists
|
2003-07-14 23:39:12 +00:00
|
|
|
delete pluginObject;
|
2003-07-28 19:08:15 +00:00
|
|
|
pluginObject = 0;
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
// Use klibloader for library manipulation
|
|
|
|
KLibLoader* loader = KLibLoader::self();
|
|
|
|
|
|
|
|
// Free the old library if possible
|
|
|
|
if (!oldLibraryName.isNull())
|
|
|
|
loader->unloadLibrary( QFile::encodeName(oldName) );
|
|
|
|
|
|
|
|
KLibrary* library = loader->library( QFile::encodeName(currentName) );
|
|
|
|
if (library != NULL)
|
2003-06-30 08:14:54 +00:00
|
|
|
{
|
2002-01-16 12:26:03 +00:00
|
|
|
void* alloc_ptr = library->symbol("allocate_config");
|
|
|
|
|
|
|
|
if (alloc_ptr != NULL)
|
|
|
|
{
|
|
|
|
allocatePlugin = (QObject* (*)(KConfig* conf, QWidget* parent))alloc_ptr;
|
2003-07-29 13:12:39 +00:00
|
|
|
pluginObject = (QObject*)(allocatePlugin( conf, pluginConfigWidget ));
|
2003-06-30 08:14:54 +00:00
|
|
|
|
2002-01-16 12:26:03 +00:00
|
|
|
// connect required signals and slots together...
|
2003-06-30 08:14:54 +00:00
|
|
|
connect( pluginObject, SIGNAL(changed()), this, SLOT(slotSelectionChanged()) );
|
2002-01-16 12:26:03 +00:00
|
|
|
connect( this, SIGNAL(pluginLoad(KConfig*)), pluginObject, SLOT(load(KConfig*)) );
|
|
|
|
connect( this, SIGNAL(pluginSave(KConfig*)), pluginObject, SLOT(save(KConfig*)) );
|
|
|
|
connect( this, SIGNAL(pluginDefaults()), pluginObject, SLOT(defaults()) );
|
2003-10-23 14:56:44 +00:00
|
|
|
pluginSettingsGrp->show();
|
2002-01-16 12:26:03 +00:00
|
|
|
return;
|
2003-06-30 08:14:54 +00:00
|
|
|
}
|
2002-01-16 12:26:03 +00:00
|
|
|
}
|
|
|
|
|
2003-10-23 14:56:44 +00:00
|
|
|
pluginSettingsGrp->hide();
|
2002-01-16 12:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Reads the kwin config settings, and sets all UI controls to those settings
|
|
|
|
// Updating the config plugin if required
|
|
|
|
void KWinDecorationModule::readConfig( KConfig* conf )
|
|
|
|
{
|
|
|
|
// General tab
|
|
|
|
// ============
|
|
|
|
cbShowToolTips->setChecked( conf->readBoolEntry("ShowToolTips", true ));
|
|
|
|
// cbUseMiniWindows->setChecked( conf->readBoolEntry("MiniWindowBorders", false));
|
|
|
|
|
|
|
|
// Find the corresponding decoration name to that of
|
|
|
|
// the current plugin library name
|
|
|
|
|
|
|
|
oldLibraryName = currentLibraryName;
|
2003-06-30 08:14:54 +00:00
|
|
|
currentLibraryName = conf->readEntry("PluginLib",
|
2002-10-26 14:34:46 +00:00
|
|
|
((QPixmap::defaultDepth() > 8) ? "kwin_keramik" : "kwin_quartz"));
|
2002-01-16 12:26:03 +00:00
|
|
|
QString decoName = decorationName( currentLibraryName );
|
|
|
|
|
|
|
|
// If we are using the "default" kde client, use the "default" entry.
|
|
|
|
if (decoName.isEmpty())
|
2003-06-30 08:14:54 +00:00
|
|
|
decoName = i18n("KDE 2");
|
|
|
|
|
|
|
|
int numDecos = decorationList->count();
|
|
|
|
for (int i = 0; i < numDecos; ++i)
|
|
|
|
{
|
|
|
|
if (decorationList->text(i) == decoName)
|
|
|
|
{
|
|
|
|
decorationList->setCurrentItem(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
// Buttons tab
|
|
|
|
// ============
|
2003-05-31 17:40:57 +00:00
|
|
|
bool customPositions = conf->readBoolEntry("CustomButtonPositions", false);
|
|
|
|
cbUseCustomButtonPositions->setChecked( customPositions );
|
|
|
|
buttonBox->setEnabled( customPositions );
|
2003-09-16 19:34:03 +00:00
|
|
|
// Menu and onAllDesktops buttons are default on LHS
|
2002-01-16 12:26:03 +00:00
|
|
|
dropSite->buttonsLeft = conf->readEntry("ButtonsOnLeft", "MS");
|
|
|
|
// Help, Minimize, Maximize and Close are default on RHS
|
|
|
|
dropSite->buttonsRight = conf->readEntry("ButtonsOnRight", "HIAX");
|
|
|
|
dropSite->repaint(false);
|
|
|
|
|
|
|
|
buttonSource->showAllButtons();
|
|
|
|
|
|
|
|
// Step through the button lists, and hide the dnd button source items
|
|
|
|
unsigned int i;
|
|
|
|
for(i = 0; i < dropSite->buttonsLeft.length(); i++)
|
|
|
|
buttonSource->hideButton( dropSite->buttonsLeft[i].latin1() );
|
|
|
|
for(i = 0; i < dropSite->buttonsRight.length(); i++)
|
|
|
|
buttonSource->hideButton( dropSite->buttonsRight[i].latin1() );
|
|
|
|
|
2003-09-24 12:41:56 +00:00
|
|
|
int bsize = conf->readNumEntry( "BorderSize", BorderNormal );
|
|
|
|
if( bsize >= BorderTiny && bsize < BordersCount )
|
|
|
|
border_size = static_cast< BorderSize >( bsize );
|
|
|
|
else
|
|
|
|
border_size = BorderNormal;
|
|
|
|
checkSupportedBorderSizes();
|
|
|
|
|
2003-09-16 19:34:03 +00:00
|
|
|
setChanged(false);
|
2002-01-16 12:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Writes the selected user configuration to the kwin config file
|
|
|
|
void KWinDecorationModule::writeConfig( KConfig* conf )
|
|
|
|
{
|
2003-06-30 08:14:54 +00:00
|
|
|
QString name = decorationList->currentText();
|
2002-01-16 12:26:03 +00:00
|
|
|
QString libName = decorationLibName( name );
|
|
|
|
|
|
|
|
KConfig kwinConfig("kwinrc");
|
|
|
|
kwinConfig.setGroup("Style");
|
2003-06-30 08:14:54 +00:00
|
|
|
|
2002-01-16 12:26:03 +00:00
|
|
|
// General settings
|
|
|
|
conf->writeEntry("PluginLib", libName);
|
|
|
|
conf->writeEntry("CustomButtonPositions", cbUseCustomButtonPositions->isChecked());
|
|
|
|
conf->writeEntry("ShowToolTips", cbShowToolTips->isChecked());
|
|
|
|
// conf->writeEntry("MiniWindowBorders", cbUseMiniWindows->isChecked());
|
|
|
|
|
|
|
|
// Button settings
|
|
|
|
conf->writeEntry("ButtonsOnLeft", dropSite->buttonsLeft );
|
|
|
|
conf->writeEntry("ButtonsOnRight", dropSite->buttonsRight );
|
2003-09-24 12:41:56 +00:00
|
|
|
conf->writeEntry("BorderSize", border_size );
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
oldLibraryName = currentLibraryName;
|
|
|
|
currentLibraryName = libName;
|
|
|
|
|
|
|
|
// We saved, so tell kcmodule that there have been no new user changes made.
|
2003-09-16 19:34:03 +00:00
|
|
|
setChanged(false);
|
2002-01-16 12:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KWinDecorationModule::dcopUpdateClientList()
|
|
|
|
{
|
|
|
|
// Changes the current active ListBox item, and
|
|
|
|
// Loads a new plugin configuration tab if required.
|
|
|
|
KConfig kwinConfig("kwinrc");
|
|
|
|
kwinConfig.setGroup("Style");
|
|
|
|
|
|
|
|
readConfig( &kwinConfig );
|
|
|
|
resetPlugin( &kwinConfig );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Virutal functions required by KCModule
|
|
|
|
void KWinDecorationModule::load()
|
|
|
|
{
|
|
|
|
KConfig kwinConfig("kwinrc");
|
|
|
|
kwinConfig.setGroup("Style");
|
|
|
|
|
2003-06-30 08:14:54 +00:00
|
|
|
// Reset by re-reading the config
|
2002-01-16 12:26:03 +00:00
|
|
|
// The plugin doesn't need changing, as we have not saved
|
|
|
|
readConfig( &kwinConfig );
|
|
|
|
emit pluginLoad( &kwinConfig );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KWinDecorationModule::save()
|
|
|
|
{
|
|
|
|
KConfig kwinConfig("kwinrc");
|
|
|
|
kwinConfig.setGroup("Style");
|
|
|
|
|
|
|
|
writeConfig( &kwinConfig );
|
|
|
|
emit pluginSave( &kwinConfig );
|
|
|
|
|
|
|
|
kwinConfig.sync();
|
|
|
|
resetKWin();
|
|
|
|
// resetPlugin() will get called via the above DCOP function
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KWinDecorationModule::defaults()
|
|
|
|
{
|
|
|
|
// Set the KDE defaults
|
|
|
|
cbUseCustomButtonPositions->setChecked( false );
|
2003-05-31 17:40:57 +00:00
|
|
|
buttonBox->setEnabled( false );
|
2002-01-16 12:26:03 +00:00
|
|
|
cbShowToolTips->setChecked( true );
|
|
|
|
// cbUseMiniWindows->setChecked( false);
|
|
|
|
// Don't set default for now
|
2003-06-30 08:14:54 +00:00
|
|
|
// decorationList->setSelected(
|
|
|
|
// decorationList->findItem( i18n("KDE 2") ), true ); // KDE classic client
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
dropSite->buttonsLeft = "MS";
|
|
|
|
dropSite->buttonsRight= "HIAX";
|
|
|
|
dropSite->repaint(false);
|
|
|
|
|
|
|
|
buttonSource->showAllButtons();
|
|
|
|
buttonSource->hideButton('M');
|
|
|
|
buttonSource->hideButton('S');
|
|
|
|
buttonSource->hideButton('H');
|
|
|
|
buttonSource->hideButton('I');
|
|
|
|
buttonSource->hideButton('A');
|
|
|
|
buttonSource->hideButton('X');
|
2003-10-23 14:56:44 +00:00
|
|
|
|
2003-09-24 12:41:56 +00:00
|
|
|
border_size = BorderNormal;
|
|
|
|
checkSupportedBorderSizes();
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
// Set plugin defaults
|
|
|
|
emit pluginDefaults();
|
|
|
|
}
|
|
|
|
|
2003-09-24 12:41:56 +00:00
|
|
|
void KWinDecorationModule::checkSupportedBorderSizes()
|
|
|
|
{
|
|
|
|
QValueList< BorderSize > sizes;
|
|
|
|
slBorder->hide();
|
|
|
|
lBorder->hide();
|
|
|
|
if( plugins->factory() != NULL )
|
|
|
|
sizes = plugins->factory()->borderSizes();
|
|
|
|
if( sizes.count() < 2 )
|
|
|
|
return;
|
|
|
|
slBorder->setRange( 0, sizes.count() - 1 );
|
|
|
|
int pos = borderSizeToIndex( border_size, sizes );
|
|
|
|
lBorder->show();
|
|
|
|
slBorder->show();
|
|
|
|
slBorder->setValue( pos );
|
|
|
|
slotBorderChanged( pos );
|
|
|
|
}
|
|
|
|
|
2003-09-16 19:34:03 +00:00
|
|
|
QString KWinDecorationModule::styleToConfigLib( QString& styleLib )
|
|
|
|
{
|
|
|
|
if( styleLib.startsWith( "kwin3_" ))
|
|
|
|
return "kwin_" + styleLib.mid( 6 ) + "_config";
|
|
|
|
else
|
|
|
|
return styleLib + "_config";
|
|
|
|
}
|
2002-01-16 12:26:03 +00:00
|
|
|
|
|
|
|
QString KWinDecorationModule::quickHelp() const
|
|
|
|
{
|
2003-09-16 19:34:03 +00:00
|
|
|
return i18n( "<h1>Window Manager Decoration</h1>"
|
|
|
|
"<p>This module allows you to choose the window border decorations, "
|
|
|
|
"as well as titlebar button positions and custom decoration options.</p>"
|
2003-05-10 09:13:36 +00:00
|
|
|
"To choose a theme for your window decoration click on its name and apply your choice by clicking the \"Apply\" button below."
|
|
|
|
" If you don't want to apply your choice you can click the \"Reset\" button to discard your changes."
|
|
|
|
"<p>You can configure each theme in the \"Configure [...]\" tab. There are different options specific for each theme.</p>"
|
|
|
|
"<p>In \"General Options (if available)\" you can activate the \"Buttons\" tab by checking the \"Use custom titlebar button positions\" box."
|
|
|
|
" In the \"Buttons\" tab you can change the positions of the buttons to your liking.</p>" );
|
2002-01-16 12:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const KAboutData* KWinDecorationModule::aboutData() const
|
|
|
|
{
|
2003-06-30 08:14:54 +00:00
|
|
|
KAboutData* about =
|
2002-01-16 12:26:03 +00:00
|
|
|
new KAboutData(I18N_NOOP("kcmkwindecoration"),
|
|
|
|
I18N_NOOP("Window Decoration Control Module"),
|
|
|
|
0, 0, KAboutData::License_GPL,
|
|
|
|
I18N_NOOP("(c) 2001 Karol Szwed"));
|
|
|
|
about->addAuthor("Karol Szwed", 0, "gallium@kde.org");
|
|
|
|
return about;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KWinDecorationModule::resetKWin()
|
|
|
|
{
|
|
|
|
bool ok = kapp->dcopClient()->send("kwin", "KWinInterface",
|
|
|
|
"reconfigure()", QByteArray());
|
2003-06-30 08:14:54 +00:00
|
|
|
if (!ok)
|
2002-01-16 12:26:03 +00:00
|
|
|
kdDebug() << "kcmkwindecoration: Could not reconfigure kwin" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "kwindecoration.moc"
|
|
|
|
// vim: ts=4
|
|
|
|
|