diff --git a/kcmkwin/kwindecoration/Makefile.am b/kcmkwin/kwindecoration/Makefile.am new file mode 100644 index 0000000000..331f909dfd --- /dev/null +++ b/kcmkwin/kwindecoration/Makefile.am @@ -0,0 +1,21 @@ +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = libkcm_kwindecoration.la + +libkcm_kwindecoration_la_SOURCES = kwindecoration.cpp buttons.cpp kwindecorationIface.skel +noinst_HEADERS = kwindecoration.h kwindecorationIface.h buttons.h + +libkcm_kwindecoration_la_LDFLAGS = \ + -module -avoid-version $(all_libraries) -no-undefined + +libkcm_kwindecoration_la_LIBADD = $(LIB_KDEUI) + +METASOURCES = AUTO + +messages: + $(XGETTEXT) *.cpp -o $(podir)/kcmkwindecoration.pot + +lnf_DATA = kwindecoration.desktop +lnfdir = $(kde_appsdir)/Settings/LookNFeel + +EXTRA_DIST = $(lnf_DATA) diff --git a/kcmkwin/kwindecoration/buttons.cpp b/kcmkwin/kwindecoration/buttons.cpp new file mode 100644 index 0000000000..3b6a51e009 --- /dev/null +++ b/kcmkwin/kwindecoration/buttons.cpp @@ -0,0 +1,561 @@ +/* + $Id$ + + This is the new kwindecoration kcontrol module + + Copyright (c) 2001 + Karol Szwed + http://gallium.n3.net/ + + Supports new kwin configuration plugins, and titlebar button position + modification via dnd interface. + + Based on original "kwintheme" (Window Borders) + Copyright (C) 2001 Rik Hemsley (rikkus) +*/ + +#include +#include +#include "buttons.h" +#include "pixmaps.h" + + +// General purpose button globals (I know I shouldn't use them :) +//=============================================================== + +enum Buttons{ BtnMenu=0, BtnSticky, BtnSpacer, BtnHelp, + BtnMinimize, BtnMaximize, BtnClose, BtnCount }; +QListBoxPixmap* buttons[ BtnCount ]; +QPixmap* pixmaps[ BtnCount ]; +QPixmap* miniSpacer; + + +//============================================================== + +ButtonDrag::ButtonDrag( char btn, QWidget* parent, const char* name) + : QStoredDrag( "kcontrol/kwindecoration_buttons", parent, name) +{ + QByteArray payload(1); + payload[0] = btn; + setEncodedData( payload ); +} + + +bool ButtonDrag::canDecode( QDragMoveEvent* e ) +{ + return e->provides( "kcontrol/kwindecoration_buttons" ); +} + + +bool ButtonDrag::decode( QDropEvent* e, char& btn ) +{ + QByteArray payload = e->data( "kcontrol/kwindecoration_buttons" ); + if ( payload.size() ) + { + e->accept(); + btn = payload[0]; + return TRUE; + } + return FALSE; +} + + + +///////////////////////////////////////////////////////////////////////// +// Implements the button drag source list box +///////////////////////////////////////////////////////////////////////// + +// Converts the button character value to its index +static int btnIndex( char btn ) +{ + switch (btn) + { + case 'M': + return BtnMenu; + break; + case 'S': + return BtnSticky; + break; + case '_': + return BtnSpacer; + break; + case 'H': + return BtnHelp; + break; + case 'I': + return BtnMinimize; + break; + case 'A': + return BtnMaximize; + break; + case 'X': + return BtnClose; + break; + default: + return -1; // Not found... + } +} + + +// Returns the pixmap of a button item +const QPixmap* btnPixmap( char btn ) +{ + if (btn == '_') + return miniSpacer; + + int btnindex = btnIndex( btn ); + if (btnindex == -1) + return NULL; + + return buttons[btnindex]->pixmap(); +} + + + +ButtonSource::ButtonSource( QWidget* parent, const char* name ) + : QListBox( parent, name) +{ + // Create the listbox pixmaps + pixmaps[ BtnMenu ] = new QPixmap( button_menu_xpm ); + pixmaps[ BtnSticky ] = new QPixmap( button_sticky_xpm ); + pixmaps[ BtnSpacer ] = new QPixmap( button_spacer_xpm ); + pixmaps[ BtnHelp ] = new QPixmap( button_help_xpm ); + pixmaps[ BtnMinimize ] = new QPixmap( button_minimize_xpm ); + pixmaps[ BtnMaximize ] = new QPixmap( button_maximize_xpm ); + pixmaps[ BtnClose ] = new QPixmap( button_close_xpm ); + miniSpacer = new QPixmap( titlebarspacer_xpm ); + + // Add all possible button/spacer types to the list box. + buttons[ BtnMenu ] = new QListBoxPixmap( this, *pixmaps[BtnMenu], i18n("Menu") ); + buttons[ BtnSticky] = new QListBoxPixmap( this, *pixmaps[BtnSticky], i18n("Sticky") ); + buttons[ BtnSpacer ] = new QListBoxPixmap( this, *pixmaps[BtnSpacer], i18n("Spacer") ); + buttons[ BtnHelp ] = new QListBoxPixmap( this, *pixmaps[BtnHelp], i18n("Help") ); + buttons[ BtnMinimize ] = new QListBoxPixmap( this, *pixmaps[BtnMinimize], i18n("Minimize") ); + buttons[ BtnMaximize ] = new QListBoxPixmap( this, *pixmaps[BtnMaximize], i18n("Maximize") ); + buttons[ BtnClose ] = new QListBoxPixmap( this, *pixmaps[BtnClose], i18n("Close") ); + + spacerCount = 0; // No spacers inserted yet + setAcceptDrops( TRUE ); +}; + + +ButtonSource::~ButtonSource() +{ + for( int i = 0; i < BtnCount; i++) + if (pixmaps[i]) + delete pixmaps[i]; + + if (miniSpacer) + delete miniSpacer; +} + + +void ButtonSource::hideAllButtons() +{ + // Hide all listbox items which are visible + if (index( buttons[BtnMenu] ) != -1) + takeItem( buttons[BtnMenu] ); + if (index( buttons[BtnSticky] )!= -1) + takeItem( buttons[BtnSticky] ); + if (index( buttons[BtnHelp] ) != -1) + takeItem( buttons[BtnHelp] ); + if (index( buttons[BtnMinimize] ) != -1) + takeItem( buttons[BtnMinimize] ); + if (index( buttons[BtnMaximize] ) != -1) + takeItem( buttons[BtnMaximize] ); + if (index( buttons[BtnClose] ) != -1) + takeItem( buttons[BtnClose] ); + if (index( buttons[BtnSpacer] ) != -1) + takeItem( buttons[BtnSpacer] ); + + spacerCount = 10; // 10 inserted spacers (max) +} + +void ButtonSource::showAllButtons() +{ + // Hide all listbox items which are visible + if (index( buttons[BtnMenu] ) == -1) + insertItem( buttons[BtnMenu] ); + if (index( buttons[BtnSticky] )== -1) + insertItem( buttons[BtnSticky] ); + if (index( buttons[BtnHelp] ) == -1) + insertItem( buttons[BtnHelp] ); + if (index( buttons[BtnMinimize] ) == -1) + insertItem( buttons[BtnMinimize] ); + if (index( buttons[BtnMaximize] ) == -1) + insertItem( buttons[BtnMaximize] ); + if (index( buttons[BtnClose] ) == -1) + insertItem( buttons[BtnClose] ); + if (index( buttons[BtnSpacer] ) == -1) + insertItem( buttons[BtnSpacer] ); + + spacerCount = 0; // No inserted spacers +} + + +void ButtonSource::showButton( char btn ) +{ + // Ignore spacers (max 10) + if (btn == '_') + spacerCount--; + + int btnindex = btnIndex(btn); + + // Check if the item is already inserted... + if ( (btnindex != -1) && (index( buttons[btnindex] ) == -1) ) + { + setUpdatesEnabled( FALSE ); + insertItem( buttons[ btnindex ] ); + setUpdatesEnabled( TRUE ); + sort(); + } +} + + +void ButtonSource::hideButton( char btn ) +{ + // Ignore spacers (max 10) + if (btn == '_') + { + spacerCount++; + if (spacerCount != 10) + return; + } + + int btnindex = btnIndex(btn); + + // Check if the item is already removed... + if ( (btnindex != -1) && (index( buttons[btnindex] ) != -1) ) + { + setUpdatesEnabled( FALSE ); + // De-select before removal + setSelected( buttons[ btnindex ], false ); + takeItem( buttons[ btnindex ] ); + setUpdatesEnabled( TRUE ); + sort(); + } +} + + +char ButtonSource::convertToChar( QString s ) +{ + // Convert the item to its character representation + if (s == i18n("Menu")) + return 'M'; + else if (s == i18n("Sticky")) + return 'S'; + else if (s == i18n("Spacer")) + return '_'; + else if (s == i18n("Help")) + return 'H'; + else if (s == i18n("Minimize")) + return 'I'; + else if (s == i18n("Maximize")) + return 'A'; + else if (s == i18n("Close")) + return 'X'; + else + return '?'; +} + + +void ButtonSource::mousePressEvent( QMouseEvent* e ) +{ + // Make a selection before moving the mouse + QListBox::mousePressEvent( e ); + + // Make sure we have at laest 1 item in the listbox + if ( count() > 0 ) + { + // Obtain currently selected item + char btn = convertToChar( currentText() ); + ButtonDrag* bd = new ButtonDrag( btn, this ); + bd->dragCopy(); + } +} + + +void ButtonSource::dragMoveEvent( QDragMoveEvent* /* e */ ) +{ + // Do nothing... +} + + +void ButtonSource::dragEnterEvent( QDragEnterEvent* e ) +{ + if ( ButtonDrag::canDecode( e ) ) + e->accept(); +} + + +void ButtonSource::dragLeaveEvent( QDragLeaveEvent* /* e */ ) +{ + // Do nothing... +} + + +void ButtonSource::dropEvent( QDropEvent* /* e */ ) +{ + // Allow the button to be removed from the ButtonDropSite + emit buttonDropped(); +} + + +///////////////////////////////////////////////////////////////////////// +// This class renders and handles the demo titlebar dropsite +///////////////////////////////////////////////////////////////////////// + +ButtonDropSite::ButtonDropSite( QWidget* parent, const char* name ) + : QFrame( parent, name ) +{ + setAcceptDrops( TRUE ); + setFrameShape( WinPanel ); + setFrameShadow( Raised ); + setMinimumHeight( 26 ); + setMaximumHeight( 26 ); + setMinimumWidth( 250 ); // Ensure buttons will fit + + mouseClickPoint.setX(0); + mouseClickPoint.setY(0); +} + + +ButtonDropSite::~ButtonDropSite() +{ + // Do nothing... +} + + +void ButtonDropSite::dragMoveEvent( QDragMoveEvent* /* e */ ) +{ + // Do nothing... +} + + +void ButtonDropSite::dragEnterEvent( QDragEnterEvent* e ) +{ + if ( ButtonDrag::canDecode( e ) ) + e->accept(); +} + + +void ButtonDropSite::dragLeaveEvent( QDragLeaveEvent* /* e */ ) +{ + // Do nothing... +} + + +void ButtonDropSite::dropEvent( QDropEvent* e ) +{ + char btn; + if ( ButtonDrag::decode(e, btn) ) + { + bool isleft; + int strPos; + + // If we are moving buttons around, remove the old item first. + if (btn == '*') + { + btn = removeButtonAtPoint( mouseClickPoint ); + if (btn != '?') + emit buttonRemoved( btn ); + } + + if (btn != '?') + { + // Add the button to our button strings + buttonInsertedAtPoint( e->pos(), isleft, strPos ); + + if (isleft) + buttonsLeft.insert( strPos, btn ); + else + buttonsRight.insert( strPos, btn ); + + repaint(false); + + // Allow listbox to update itself + emit buttonAdded( btn ); + emit changed(); + } + } +} + + +// Starts dragging a button... +void ButtonDropSite::mousePressEvent( QMouseEvent* e ) +{ + mouseClickPoint = e->pos(); + + ButtonDrag* bd = new ButtonDrag( '*', this ); + bd->dragCopy(); +} + + +int ButtonDropSite::buttonWidth( char btn ) +{ + if (btn == '_') + return 6; // ensure this matches with the pixmap widths + else + return 20; // Assume characters given are all valid +} + + +// Computes the total space the buttons will take in the titlebar +int ButtonDropSite::calcButtonStringWidth( const QString& s ) +{ + QChar ch; + unsigned int offset = 0; + + for(unsigned int i = 0; i < s.length(); i++) + { + ch = s[i]; + offset += buttonWidth( ch.latin1() ); + } + return (int)offset; +} + + +// This slot is called after we drop on the item listbox... +void ButtonDropSite::removeClickedButton() +{ + if ( !mouseClickPoint.isNull() ) + { + char btn = removeButtonAtPoint( mouseClickPoint ); + mouseClickPoint.setX(0); + mouseClickPoint.setY(0); + repaint(false); + + emit buttonRemoved( btn ); + emit changed(); + } +} + + +// Find the string and position at which to insert the new button... +void ButtonDropSite::buttonInsertedAtPoint( QPoint p, bool& isleft, int& strPos ) +{ + int leftoffset = calcButtonStringWidth( buttonsLeft ); + int rightoffset = calcButtonStringWidth( buttonsRight ); + int posx = p.x() - 3; + + // The centre of the titlebar text tells us whether to add to the left or right + if ( posx < ( leftoffset - rightoffset + ((geometry().width() - 6) / 2))) + isleft = true; + else + isleft = false; + + QString s = isleft ? buttonsLeft : buttonsRight; + int offset = isleft ? 0 : geometry().width() - 6 - rightoffset; + QChar ch; + + strPos = s.length(); + + for (unsigned int i = 0; i < s.length(); i++) + { + if ( posx < (offset + 5 )) + { + strPos = i; + break; + } + ch = s[i]; + offset += buttonWidth( ch.latin1() ); + } +} + + +char ButtonDropSite::removeButtonAtPoint( QPoint p ) +{ + int offset = -1; + bool isleft = false; + + // Shrink contents rect by 1 to fit in the titlebar border + QRect r = contentsRect(); + r.moveBy(1 , 1); + r.setWidth( r.width() - 2 ); + r.setHeight( r.height() - 2 ); + + // Bail out if the borders were clicked + if ( !r.contains(p) ) + return '?'; + + int posx = p.x(); + + // Is the point in the LHS/RHS button area? + if ( (!buttonsLeft.isEmpty()) && (posx <= (calcButtonStringWidth( buttonsLeft )+3)) ) + { + offset = 3; + isleft = true; + } + else if ( (!buttonsRight.isEmpty()) && (posx >= geometry().width() - calcButtonStringWidth(buttonsRight) - 3)) + { + offset = geometry().width() - calcButtonStringWidth(buttonsRight) - 3; + isleft = false; + } + + // Step through the button strings and remove the appropriate button + if (offset != -1) + { + QChar ch; + QString s = isleft ? buttonsLeft : buttonsRight; + + // Step through the items, to find the appropriate one to remove. + for (unsigned int i = 0; i < s.length(); i++) + { + ch = s[i]; + offset += buttonWidth( ch.latin1() ); + if (posx <= offset) + { + s.remove( i, 1 ); // Remove the current button item + if (isleft) + buttonsLeft = s; + else + buttonsRight = s; + return ch.latin1(); + } + } + } + + return '?'; +} + + +void ButtonDropSite::drawButtonString( QPainter* p, QString& s, int offset ) +{ + QChar ch; + + for(unsigned int i = 0; i < s.length(); i++) + { + ch = s[i]; + p->drawPixmap( offset, 3, *btnPixmap(ch.latin1()) ); + offset += buttonWidth(ch.latin1()); + } +} + + +void ButtonDropSite::drawContents( QPainter* p ) +{ + int leftoffset = calcButtonStringWidth( buttonsLeft ); + int rightoffset = calcButtonStringWidth( buttonsRight ); + int offset = 3; + + QRect r = contentsRect(); + + // Shrink by 1 + r.moveBy(1 + leftoffset, 1); + r.setWidth( r.width() - 2 - leftoffset - rightoffset ); + r.setHeight( r.height() - 2 ); + + drawButtonString( p, buttonsLeft, offset ); + + QColor c1( 0x0A, 0x5F, 0x89 ); // KDE 2 titlebar default colour + p->fillRect( r, c1 ); + p->setPen( Qt::white ); + p->setFont( QFont( "helvetica", 12, QFont::Bold) ); + p->drawText( r, AlignLeft | AlignVCenter, i18n("KDE") ); + + offset = geometry().width() - 3 - rightoffset; + drawButtonString( p, buttonsRight, offset ); +} + +#include "buttons.moc" +// vim: ts=4 diff --git a/kcmkwin/kwindecoration/buttons.h b/kcmkwin/kwindecoration/buttons.h new file mode 100644 index 0000000000..414c151cf4 --- /dev/null +++ b/kcmkwin/kwindecoration/buttons.h @@ -0,0 +1,115 @@ +/* + $Id$ + + This is the new kwindecoration kcontrol module + + Copyright (c) 2001 + Karol Szwed + http://gallium.n3.net/ + + Supports new kwin configuration plugins, and titlebar button position + modification via dnd interface. + + Based on original "kwintheme" (Window Borders) + Copyright (C) 2001 Rik Hemsley (rikkus) +*/ + +#ifndef __BUTTONS_H_ +#define __BUTTONS_H_ + +#include +#include +#include + + +///////////////////////////////////////////////////////////////////////// + +class ButtonDrag: public QStoredDrag +{ + public: + ButtonDrag( char btn, QWidget* parent, const char* name=0 ); + ~ButtonDrag() {}; + + static bool canDecode( QDragMoveEvent* e ); + static bool decode( QDropEvent* e, char& btn ); +}; + + +///////////////////////////////////////////////////////////////////////// + +class ButtonSource: public QListBox +{ + Q_OBJECT + + public: + ButtonSource( QWidget* parent=0, const char* name=0 ); + ~ButtonSource(); + + void hideAllButtons(); + void showAllButtons(); + + signals: + void buttonDropped(); + + public slots: + void hideButton( char btn ); + void showButton( char btn ); + + protected: + void dragEnterEvent( QDragEnterEvent* e ); + void dragMoveEvent( QDragMoveEvent* e ); + void dragLeaveEvent( QDragLeaveEvent* e ); + void dropEvent( QDropEvent* e ); + void mousePressEvent( QMouseEvent* e ); + + private: + char convertToChar( QString s ); + QString convertToString( char btn ); + + int spacerCount; +}; + + +///////////////////////////////////////////////////////////////////////// + +class ButtonDropSite: public QFrame +{ + Q_OBJECT + + public: + ButtonDropSite( QWidget* parent=0, const char* name=0 ); + ~ButtonDropSite(); + + // Allow external classes access our buttons - ensure buttons are + // not duplicated however. + QString buttonsLeft; + QString buttonsRight; + + signals: + void buttonAdded( char c ); + void buttonRemoved( char c ); + void changed(); + + public slots: + void removeClickedButton(); + + protected: + void dragEnterEvent( QDragEnterEvent* e ); + void dragMoveEvent( QDragMoveEvent* e ); + void dragLeaveEvent( QDragLeaveEvent* e ); + void dropEvent( QDropEvent* e ); + void mousePressEvent( QMouseEvent* e ); + + void drawContents( QPainter* p ); + int buttonWidth( char btn ); + int calcButtonStringWidth( const QString& s ); + char removeButtonAtPoint( QPoint p ); + void buttonInsertedAtPoint( QPoint p, bool& isleft, int& strPos ); + void drawButtonString( QPainter* p, QString& s, int offset ); + + QPoint mouseClickPoint; +}; + + +#endif +// vim: ts=4 diff --git a/kcmkwin/kwindecoration/kwindecoration.cpp b/kcmkwin/kwindecoration/kwindecoration.cpp new file mode 100644 index 0000000000..22d3e4d32d --- /dev/null +++ b/kcmkwin/kwindecoration/kwindecoration.cpp @@ -0,0 +1,486 @@ +/* + $Id$ + + This is the new kwindecoration kcontrol module + + Copyright (c) 2001 + Karol Szwed + http://gallium.n3.net/ + + Supports new kwin configuration plugins, and titlebar button position + modification via dnd interface. + + Based on original "kwintheme" (Window Borders) + Copyright (C) 2001 Rik Hemsley (rikkus) +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kwindecoration.h" + + +// KCModule plugin interface +// ========================= +typedef KGenericFactory KWinDecoFactory; +K_EXPORT_COMPONENT_FACTORY( libkcm_kwindecoration, KWinDecoFactory("kcmkwindecoration") ); + +KWinDecorationModule::KWinDecorationModule(QWidget* parent, const char* name, const QStringList &) + : KCModule(parent, name), DCOPObject("KWinClientDecoration") +{ + KConfig kwinConfig("kwinrc"); + kwinConfig.setGroup("Style"); + + QVBoxLayout* layout = new QVBoxLayout(this); + tabWidget = new QTabWidget( this ); + layout->addWidget( tabWidget ); + + // Page 1 (General Options) + QVBox* page1 = new QVBox( tabWidget ); + page1->setSpacing( KDialog::spacingHint() ); + page1->setMargin( KDialog::marginHint() ); + + QGroupBox* btnGroup = new QGroupBox( 1, Qt::Horizontal, i18n("Window Decoration"), page1 ); + QWhatsThis::add( btnGroup, + i18n("Select the window decoration. This is the look and feel of both " + "the window borders and the window handle.") ); + decorationListBox = new QListBox( btnGroup ); + + QGroupBox* checkGroup = new QGroupBox( 1, Qt::Horizontal, + i18n("General options (if available)"), page1 ); + cbUseCustomButtonPositions = new QCheckBox( + i18n("Use custom titlebar button &positions"), checkGroup ); + 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!" ) ); + cbShowToolTips = new QCheckBox( + i18n("&Show window button tooltips"), checkGroup ); + QWhatsThis::add( cbShowToolTips, + i18n( "Enabling this checkbox will show window button tooltips. " + "If this checkbox is off, no window button tooltips will be shown.")); +// 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!" ) ); + + // Page 2 (Button Selector) + buttonPage = new QVBox( tabWidget ); + buttonPage->setSpacing( KDialog::spacingHint() ); + buttonPage->setMargin( KDialog::marginHint() ); + + QGroupBox* buttonBox = new QGroupBox( 1, Qt::Horizontal, + i18n("Titlebar Button Position"), buttonPage ); + + // Add nifty dnd button modification widgets + QLabel* label = new QLabel( buttonBox ); + dropSite = new ButtonDropSite( buttonBox ); + label->setText( i18n( "To add or remove titlebar buttons, simply drag 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 ); + + // Page 3 (Configure decoration via client plugin page) + pluginPage = new QVBox( tabWidget ); + pluginPage->setSpacing( KDialog::spacingHint() ); + pluginPage->setMargin( KDialog::marginHint() ); + pluginObject = NULL; + + // Load all installed decorations into memory + // Set up the decoration lists and other UI settings + findDecorations(); + createDecorationList(); + readConfig( &kwinConfig ); + resetPlugin( &kwinConfig ); + + tabWidget->insertTab( page1, i18n("&General") ); + tabWidget->insertTab( buttonPage, i18n("&Buttons") ); + tabWidget->insertTab( pluginPage, i18n("&Configure [") + + decorationListBox->currentText() + i18n("]") ); + + tabWidget->setTabEnabled( buttonPage, cbUseCustomButtonPositions->isChecked() ); + + 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()) ); + connect( decorationListBox, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); + connect( decorationListBox, SIGNAL(highlighted(const QString&)), + SLOT(slotDecorationHighlighted(const QString&)) ); + connect( cbUseCustomButtonPositions, SIGNAL(clicked()), SLOT(slotSelectionChanged()) ); + connect( cbUseCustomButtonPositions, SIGNAL(toggled(bool)), SLOT(slotEnableButtonTab(bool)) ); + connect( cbShowToolTips, SIGNAL(clicked()), SLOT(slotSelectionChanged()) ); +// connect( cbUseMiniWindows, SIGNAL(clicked()), SLOT(slotSelectionChanged()) ); + + // Allow kwin dcop signal to update our selection list + connectDCOPSignal("kwin", 0, "dcopResetAllClients()", "dcopUpdateClientList()", false); +} + + +KWinDecorationModule::~KWinDecorationModule() +{ +} + + +// 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"); + + if (!libName.isEmpty()) + { + DecorationInfo di; + di.name = desktopFile.readName(); + di.libraryName = libName; + decorations.append( di ); + } + } + } + } +} + + +// Fills the decorationListBox with a list of available kwin decorations +void KWinDecorationModule::createDecorationList() +{ + QValueList::ConstIterator it; + + // Sync with kwin hardcoded KDE2 style which has no desktop item + decorationListBox->insertItem( i18n("KDE2 default") ); + + for (it = decorations.begin(); it != decorations.end(); ++it) + { + DecorationInfo info = *it; + decorationListBox->insertItem( info.name ); + } +} + + +// Reset the decoration plugin to what the user just selected +void KWinDecorationModule::slotDecorationHighlighted( const QString& s ) +{ + KConfig kwinConfig("kwinrc"); + kwinConfig.setGroup("Style"); + + // Let the user see config options for the currently selected decoration + resetPlugin( &kwinConfig, &s ); + tabWidget->changeTab( pluginPage, i18n("&Configure [") + + decorationListBox->currentText() + i18n("]") ); +} + + +// This is the selection handler setting +void KWinDecorationModule::slotSelectionChanged() +{ + emit changed(true); +} + + +void KWinDecorationModule::slotEnableButtonTab(bool on) +{ + tabWidget->setTabEnabled( buttonPage, on ); +} + + +QString KWinDecorationModule::decorationName( QString& libName ) +{ + QString decoName; + + QValueList::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::Iterator it; + for( it = decorations.begin(); it != decorations.end(); ++it ) + if ( (*it).name == name ) + { + libName = (*it).libraryName; + break; + } + + if (libName.isEmpty()) + libName = "libkwindefault"; + + return libName; +} + + +// Loads/unloads and inserts the decoration config plugin into the +// pluginPage, allowing for dynamic configuration of decorations +void KWinDecorationModule::resetPlugin( KConfig* conf, const QString* currentDecoName ) +{ + // Config names are "libkwinicewm_config" + // for "libkwinicewm" kwin client + + QString oldName = oldLibraryName; + oldName += "_config"; + + QString currentName; + if (currentDecoName) + currentName = decorationLibName( *currentDecoName ); // Use what the user selected + else + currentName = currentLibraryName; // Use what was read from readConfig() + + currentName += "_config"; + + // Delete old plugin widget if it exists + if (pluginObject) + delete pluginObject; + + // 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) + { + void* alloc_ptr = library->symbol("allocate_config"); + + if (alloc_ptr != NULL) + { + allocatePlugin = (QObject* (*)(KConfig* conf, QWidget* parent))alloc_ptr; + pluginObject = allocatePlugin( conf, pluginPage ); + + // connect required signals and slots together... + connect( pluginObject, SIGNAL(changed()), this, SLOT(slotSelectionChanged()) ); + 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()) ); + + return; + } + } + + // Display a message telling the user that the current decoration + // does not have any configurable options (extended plugin interface not found) + QWidget* plugin = new QGroupBox( 1, Qt::Horizontal, "", pluginPage ); + (void) new QLabel( + i18n("

No Configurable Options Available

" + "Sorry, no configurable options are available for the " + "currently selected decoration."), plugin ); + + plugin->show(); + pluginObject = plugin; +} + + + +// 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 + // ============ + cbUseCustomButtonPositions->setChecked( conf->readBoolEntry("CustomButtonPositions", false)); + tabWidget->setTabEnabled( buttonPage, cbUseCustomButtonPositions->isChecked() ); + 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; + currentLibraryName = conf->readEntry("PluginLib", "libkwindefault"); + QString decoName = decorationName( currentLibraryName ); + + // If we are using the "default" kde client, use the "default" entry. + if (decoName.isEmpty()) + decorationListBox->setSelected( 0, true ); + else + // Update the decoration listbox + decorationListBox->setSelected( decorationListBox->findItem( decoName ), true); + + // Buttons tab + // ============ + // Menu and sticky buttons are default on LHS + 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() ); + + emit changed(false); +} + + +// Writes the selected user configuration to the kwin config file +void KWinDecorationModule::writeConfig( KConfig* conf ) +{ + QString name = decorationListBox->currentText(); + QString libName = decorationLibName( name ); + + KConfig kwinConfig("kwinrc"); + kwinConfig.setGroup("Style"); + + // 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 ); + + oldLibraryName = currentLibraryName; + currentLibraryName = libName; + + // We saved, so tell kcmodule that there have been no new user changes made. + emit changed(false); +} + + +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"); + + // Reset by re-reading the config + // 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 ); + cbShowToolTips->setChecked( true ); +// cbUseMiniWindows->setChecked( false); +// Don't set default for now +// decorationListBox->setSelected( 0, true ); // KDE2 default client + + 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'); + + // Set plugin defaults + emit pluginDefaults(); +} + + +QString KWinDecorationModule::quickHelp() const +{ + return i18n( "

Window Manager Decoration

" + "This module allows you to choose the window border decorations, " + "as well as titlebar button positions and custom decoration options."); +} + + +const KAboutData* KWinDecorationModule::aboutData() const +{ + KAboutData* about = + 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()); + if (!ok) + kdDebug() << "kcmkwindecoration: Could not reconfigure kwin" << endl; +} + +#include "kwindecoration.moc" +// vim: ts=4 + diff --git a/kcmkwin/kwindecoration/kwindecoration.desktop b/kcmkwin/kwindecoration/kwindecoration.desktop new file mode 100644 index 0000000000..0a4a7420a2 --- /dev/null +++ b/kcmkwin/kwindecoration/kwindecoration.desktop @@ -0,0 +1,117 @@ +[Desktop Entry] +Exec=kcmshell kwindecoration +Icon=kcmkwm +Type=Application +DocPath=kcontrol/window-deco.html + +X-KDE-ModuleType=Library +X-KDE-Library=kwindecoration +X-KDE-FactoryName=kwindecoration + +Name=Window Decoration +Name[af]=VENSTER VERSIERING +Name[az]=Pəncərə Dekorasiyası +Name[bg]=Декорация на прозорец +Name[cs]=Dekorace okna +Name[da]=Vinduesdekoration +Name[de]=Fensterdekorationen +Name[el]=Διακόσμηση Παραθύρων +Name[eo]=Fenestroaspekto +Name[es]=Decoración de ventanas +Name[et]=Akna dekoratsioonid +Name[fi]=Ikkunoiden kehys +Name[fr]=Décoration des fenêtres +Name[he]=תונולח יטושיק +Name[hu]=Ablakstílus +Name[is]=Gluggaskreyting +Name[it]=Decorazione finestra +Name[ja]=ウィンドウ装飾 +Name[ko]=창 모양새 +Name[lt]=Lango dekoracija +Name[lv]=Loga Dekorācija +Name[mt]=Dekorazzjoni tal-Windows +Name[nl]=Vensterdecoratie +Name[no_NY]=Vindaugsdekorasjon +Name[pl]=Dekoracja okna +Name[pt_BR]=Decoração da Janela +Name[pt]=Decoração da Janela +Name[ru]=Оформление окон +Name[sk]=Dekorácia okna +Name[sl]=Okraski okna +Name[sr]=Okviri prozora +Name[sv]=Fönsterdekoration +Name[ta]=º¡Çà «Äí¸¡Ãõ +Name[tr]=Pencere Dekorasyonu +Name[uk]=Обрамлення вікон +Name[vi]=BềEtrí cửa sềE +Name[zh_CN.GB2312]=窗口修饰 + +Comment=Window border theme +Comment[af]=VENSTER GRENS TEMA +Comment[az]=Pəncərə kənarı örtüsü +Comment[bg]=Тема за рамката на прозорец +Comment[cs]=Motiv okraje oken +Comment[da]=Vindues kanttema +Comment[de]=Design für Fensterrahmen +Comment[el]=θέμα περιθωρίων παραθύρου +Comment[eo]=Fenestrorando-etoso +Comment[es]=Tema de bordes de ventanas +Comment[et]=Akna dekoratsioonide teemad +Comment[fi]=Ikkunoiden reunojen teema +Comment[fr]=Thème de bordure des fenêtres +Comment[he]=תונולחה תולובג ןונגס יוניש +Comment[hu]=Ablakszegély-téma +Comment[is]=Þema fyrir gluggakanta +Comment[it]=Tema bordo finestre +Comment[ja]=ウィンドウ枠テーマ +Comment[ko]=창 테두리 테마 +Comment[lt]=Langų ribų tema +Comment[lv]=Loga rāmja tēma +Comment[mt]=Tema tal-bordura tal-windows +Comment[nl]=Vensterrandthema +Comment[no_NY]=Tema for vindaugskantar +Comment[pl]=Motyw brzegu okna +Comment[pt_BR]=Tema do contorno da janela +Comment[pt]=Tema do contorno da janela +Comment[ru]=тема границ окон +Comment[sk]=Téma okraja okien +Comment[sl]=Tema robov oken +Comment[sv]=Tema för fönsterkanter +Comment[ta]=º¡ÇàµÃ ¯Õ¸Õ +Comment[tr]=Pencere kenarı teması +Comment[uk]=Тема для країв вікон +Comment[vi]=Theme của viền Cửa sềE +Comment[zh_CN.GB2312]=Windows 边框主题 +Comment[zh_TW.Big5]=Windows 邊界佈景 + +Keywords=kwin,window,manager,border,style,theme,look,feel,layout,button,handle,edge,kwm,decoration +Keywords[af]=KWIN,VENSTER,BESTUURDER,GRENS,STYL,TEMA,KYK,GEVOEL,UITLEG,KNOPPIE,HANDVATSELe,RAND,KWM,VERSIERING +Keywords[az]=kwin,pəncərə,idarəçi,kənar,tərz,örtü,görünüş,toxuma,yer,düymə,applet,kənar,kwm,dekorasiya,bəzək +Keywords[cs]=kwin,okno,správce,okraj,styl,motiv,vzhled,rozvržení,tlačítko,úchytka,hrana,kwm,dekorace +Keywords[da]=kwin,vindue,håndtering,kant,stil,tema,udseende,fornemmelse,layout,knapper,håndtag,kant,kwm,dekoration +Keywords[de]=KWin,Kwm,Fenster,Manager,Rahmen,Design,Stil,Theme,Optik,Erscheinungsbild,Layout,Knöpfe,Ränder,Dekorationen +Keywords[eo]=kwin,fenestro,administrilo,rando,stilo,etoso,aspekto,konduto,aranĝo,butono,eĝo,kwm,ornamo +Keywords[es]=kwin,ventana,administrador,borde,estilo,tema,aspecto,comportamiento,disposición,botón,asa,esquina,kwm,decoración +Keywords[et]=kwin,aken,haldur,piire,stiil,teema,välimus,kasutamine,nupud,serv,kwm,dekoratsioon +Keywords[fi]=kwin,ikkuna,ikkunamanageri,ikkunoinnin hallintaohjelma,tausta,tyyli,teema,ulkonäkö,tuntuma,ulkoasu,painike,kahva,kulma,kwm,kehys +Keywords[fr]=kwin,fenêtre,gestionnaire,bordure,style,thème,apparence,ergonomie,disposition,bouton,poignée,bord,kwm,décoration +Keywords[he]=טושיק,הצק,תידי,רותפכ,הגוצת,הסירפ,השוחת,הארמ,אשונ תכרע,הכרע,ןונגס,תרגסמ,לובג,להנמ,תונולח,תונולחה להנמ +Keywords[hu]=KWin,ablak,kezelő,szegély,stílus,téma,kinézet,megjelenés,elrendezés,nyomógomb,fogantyú,perem,kwm,ablakstílus +Keywords[is]=kwin,gluggi,gluggastjóri,gluggar,kantar,rammi,skreyting,þema,stíll,útlit,takki,kwm,skraut +Keywords[it]=kwin,window,manager,bordo,stile,tema,aspetto,feel,layout,pulsante,kwm,decorazione +Keywords[ja]=kwin, ウィンドウ, マネージャ, 枠, スタイル, テーマ, ルック, フィール, レイアウト, ボタン, ハンドル エッジ, kwm, 装飾 +Keywords[lt]=kwin,window,manager,border,style,theme,look,feel,layout,buttons,handle,edge,kwm,decoration,langas,tvarkyklė,rėmelis,stilius,tema,žiūrėti,jausti,išdėstymas,mygtukai,kraštas,dekoracija +Keywords[lv]=kwin, logs, menedžeris, rāmis, stils, tēma, skats, gars, izkārtojums, poga, rokturis, stūris, kwm, dekorācija +Keywords[mt]=kwin, window, manager, border, bordura, stil, tema, apparenza, style, theme, look, feel, layout, tqassim, użu, button, handle, edge, kwm, decoration +Keywords[nl]=kwin,window,manager,rand,stijl,theme,thema.look,uiterlijk,gedrag,feel,layout,opmaak,button,knoppen,handle,rand,kwm,decoratie,window manager,venster,vensterbeheer +Keywords[no_NY]=kwin,vindauge,kant,bord,stil,tema,utsjånad,bunad,knapp,handtak,kwm,dekorasjon +Keywords[pl]=kwin,okno,menedżer,brzeg,styl,motyw,wygląd,zachowanie,układ,przycisk,uchwyt,krawędź,kwm,dekoracja +Keywords[pt_BR]=kwin, janela, gestor, contorno, estilo, tema, aparência, comportamento, visual, botão, pega, extremo, kwm, decoração +Keywords[pt]=kwin, janela, gestor, contorno, estilo, tema, aparência, comportamento, visual, botão, pega, extremo, kwm, decoração +Keywords[sk]=kwin,okno,správa,okraj,štýl,téma,vzhľad,rozloženie,tlačidlo,hrana,kwm,dekorácia,oblasť +Keywords[sl]=kwin,okno,upravljalnik,rob,meja,slog,stil,tema,pogled,občutek,gumb,ročaj,rob,kwm,okrasek +Keywords[sv]=kwin,fönster,hanterare,kant,stil,tema,utseende,känsla,layout,knapp,hantera,kant,kwm,dekoration +Keywords[tr]=kwin,pencere,yönetici,kenar,stil,tema,görünüş,doku,yerleşim,düğme,tutamaç,kenar,kwm,dekorasyon +Keywords[uk]=kwin,вікно,менеджер,границя,стиль,тема,вигляд,поведінка,розклад,кнопка,handle,край,kwm,обрамлення +Keywords[vi]=kwin,window,manager,border,style,theme,look,feel,layout,button,handle,edge,kwm,decoration,cửa sềEtrình quản lí,viền,kiểu,cạnh,bềEtrí +Keywords[zh_CN.GB2312]=kwin,window,manager,border,style,theme,look,feel,layout,button,handle,edge,kwm,decoration,窗口,管理器,边界,风格,主题,观感,部局,按钮,边缘,装饰 diff --git a/kcmkwin/kwindecoration/kwindecoration.h b/kcmkwin/kwindecoration/kwindecoration.h new file mode 100644 index 0000000000..6a2a5ddcb0 --- /dev/null +++ b/kcmkwin/kwindecoration/kwindecoration.h @@ -0,0 +1,105 @@ +/* + $Id$ + + This is the new kwindecoration kcontrol module + + Copyright (c) 2001 + Karol Szwed + http://gallium.n3.net/ + + Supports new kwin configuration plugins, and titlebar button position + modification via dnd interface. + + Based on original "kwintheme" (Window Borders) + Copyright (C) 2001 Rik Hemsley (rikkus) +*/ + +#ifndef KWINDECORATION_H +#define KWINDECORATION_H + +#include +#include +#include +#include +#include + +#include "kwindecorationIface.h" + +class QListBox; +class QCheckBox; +class QTabWidget; +class QVBox; + +// Stores themeName and its corresponding library Name +struct DecorationInfo +{ + QString name; + QString libraryName; +}; + + +class KWinDecorationModule : public KCModule, virtual public KWinDecorationIface +{ + Q_OBJECT + + public: + KWinDecorationModule(QWidget* parent, const char* name, const QStringList &); + ~KWinDecorationModule(); + + virtual void load(); + virtual void save(); + virtual void defaults(); + + QString quickHelp() const; + const KAboutData* aboutData() const; + + virtual void dcopUpdateClientList(); + + signals: + void changed(bool); + void pluginLoad( KConfig* conf ); + void pluginSave( KConfig* conf ); + void pluginDefaults(); + + protected slots: + // Allows us to turn "save" on + void slotSelectionChanged(); + void slotEnableButtonTab(bool on); + void slotDecorationHighlighted( const QString& s ); + + private: + void readConfig( KConfig* conf ); + void writeConfig( KConfig* conf ); + void findDecorations(); + void createDecorationList(); + void updateSelection(); + QString decorationLibName( const QString& name ); + QString decorationName ( QString& libName ); + void resetPlugin( KConfig* conf, const QString* currentDecoName = 0 ); + void resetKWin(); + + QTabWidget* tabWidget; + + // Page 1 + QListBox* decorationListBox; + QValueList decorations; + QCheckBox* cbUseCustomButtonPositions; + // QCheckBox* cbUseMiniWindows; + QCheckBox* cbShowToolTips; + + // Page 2 + ButtonDropSite* dropSite; + ButtonSource* buttonSource; + + // Page 3 + QObject* pluginObject; + QString currentLibraryName; + QString oldLibraryName; + QVBox* pluginPage; + QVBox* buttonPage; + QObject* (*allocatePlugin)( KConfig* conf, QWidget* parent ); +}; + + +#endif +// vim: ts=4 diff --git a/kcmkwin/kwindecoration/kwindecorationIface.h b/kcmkwin/kwindecoration/kwindecorationIface.h new file mode 100644 index 0000000000..ae8c712c6b --- /dev/null +++ b/kcmkwin/kwindecoration/kwindecorationIface.h @@ -0,0 +1,29 @@ +/* + This is the new kwindecoration kcontrol module + + Copyright (c) 2001 + Karol Szwed (gallium) + http://gallium.n3.net/ + + Supports new kwin configuration plugins, and titlebar button position + modification via dnd interface. + + Based on original "kwintheme" (Window Borders) + Copyright (C) 2001 Rik Hemsley (rikkus) +*/ + +#ifndef __KWINDECORATIONIFACE_H +#define __KWINDECORATIONIFACE_H + +#include + +class KWinDecorationIface: virtual public DCOPObject +{ + K_DCOP + public: + + k_dcop: + virtual void dcopUpdateClientList()=0; +}; + +#endif diff --git a/kcmkwin/kwindecoration/pixmaps.h b/kcmkwin/kwindecoration/pixmaps.h new file mode 100644 index 0000000000..cb61a1c4d1 --- /dev/null +++ b/kcmkwin/kwindecoration/pixmaps.h @@ -0,0 +1,339 @@ +/* + $Id$ + + This is the new kwindecoration kcontrol module + + Copyright (c) 2001 + Karol Szwed + http://gallium.n3.net/ + + Supports new kwin configuration plugins, and titlebar button position + modification via dnd interface. + + Based on original "kwintheme" (Window Borders) + Copyright (C) 2001 Rik Hemsley (rikkus) +*/ + + +// Button pixmaps (screenshots of kde1 buttons which all people know well now) +// ============================================================================ + +/* XPM */ +const char * button_close_xpm[] = { +"20 20 16 1", +" c None", +". c #F3F3F3", +"+ c #F2F2F2", +"@ c #F1F1F1", +"# c #FFFFFF", +"$ c #6E6E6E", +"% c #F0F0F0", +"& c #EFEFEF", +"* c #EEEEEE", +"= c #EDEDED", +"- c #ECECEC", +"; c #EBEBEB", +"> c #EAEAEA", +", c #E9E9E9", +"' c #E8E8E8", +") c #E7E7E7", +"....................", +"....................", +"++++++++++++++++++++", +"@@@@@@@@@@@@@@@@@@@@", +"@@@@#$@@@@@@@@#$@@@@", +"%%%%#$$%%%%%%#$$%%%%", +"&&&&&#$$&&&&#$$&&&&&", +"&&&&&&#$$&&#$$&&&&&&", +"*******#$$#$$*******", +"========#$$$========", +"========#$$$========", +"-------#$$#$$-------", +";;;;;;#$$;;#$$;;;;;;", +";;;;;#$$;;;;#$$;;;;;", +">>>>#$$>>>>>>#$$>>>>", +",,,,#$,,,,,,,,#$,,,,", +",,,,,,,,,,,,,,,,,,,,", +"''''''''''''''''''''", +"))))))))))))))))))))", +"))))))))))))))))))))"}; + + +/* XPM */ +const char * button_help_xpm[] = { +"20 20 16 1", +" c None", +". c #F3F3F3", +"+ c #F2F2F2", +"@ c #F1F1F1", +"# c #6E6E6E", +"$ c #F0F0F0", +"% c #FFFFFF", +"& c #EFEFEF", +"* c #EEEEEE", +"= c #EDEDED", +"- c #ECECEC", +"; c #EBEBEB", +"> c #EAEAEA", +", c #E9E9E9", +"' c #E8E8E8", +") c #E7E7E7", +"....................", +"....................", +"++++++++++++++++++++", +"@@@@@@@@@@@@@@@@@@@@", +"@@@@@@@@#####@@@@@@@", +"$$$$$$$##%%%##$$$$$$", +"&&&&&&&##%&&##%&&&&&", +"&&&&&&&&%%&&##%&&&&&", +"***********##%%*****", +"==========##%%======", +"=========##%%=======", +"---------##%--------", +";;;;;;;;;;%%;;;;;;;;", +";;;;;;;;;##;;;;;;;;;", +">>>>>>>>>##%>>>>>>>>", +",,,,,,,,,,%%,,,,,,,,", +",,,,,,,,,,,,,,,,,,,,", +"''''''''''''''''''''", +"))))))))))))))))))))", +"))))))))))))))))))))"}; + +/* XPM */ +const char * button_maximize_xpm[] = { +"20 20 16 1", +" c None", +". c #F3F3F3", +"+ c #F2F2F2", +"@ c #F1F1F1", +"# c #FFFFFF", +"$ c #F0F0F0", +"% c #6E6E6E", +"& c #EFEFEF", +"* c #EEEEEE", +"= c #EDEDED", +"- c #ECECEC", +"; c #EBEBEB", +"> c #EAEAEA", +", c #E9E9E9", +"' c #E8E8E8", +") c #E7E7E7", +"....................", +"....................", +"++++++++++++++++++++", +"@@@@@@@@@@@@@@@@@@@@", +"@@@@###########@@@@@", +"$$$$#%%%%%%%%%%$$$$$", +"&&&&#%&&&&&&&#%&&&&&", +"&&&&#%&&&&&&&#%&&&&&", +"****#%*******#%*****", +"====#%=======#%=====", +"====#%=======#%=====", +"----#%-------#%-----", +";;;;#%;;;;;;;#%;;;;;", +";;;;#%########%;;;;;", +">>>>#%%%%%%%%%%>>>>>", +",,,,,,,,,,,,,,,,,,,,", +",,,,,,,,,,,,,,,,,,,,", +"''''''''''''''''''''", +"))))))))))))))))))))", +"))))))))))))))))))))"}; + +/* XPM */ +const char * button_menu_xpm[] = { +"20 20 21 1", +" c None", +". c #F3F3F3", +"+ c #F2F2F2", +"@ c #000000", +"# c #F1F1F1", +"$ c #FFFFFF", +"% c #C3C3C3", +"& c #F0F0F0", +"* c #EFEFEF", +"= c #FFFFC0", +"- c #FFDCA8", +"; c #EEEEEE", +"> c #C05800", +", c #EDEDED", +"' c #ECECEC", +") c #EBEBEB", +"! c #808080", +"~ c #EAEAEA", +"{ c #E9E9E9", +"] c #E8E8E8", +"^ c #E7E7E7", +"....................", +"....................", +"+++++++++@@+++++++++", +"####@@@@@$$@@@@@####", +"####@$$@%%%%@$$@####", +"&&&@@$$@@@@@@$$@&&&&", +"***@=@$$$$$$$$$@****", +"***@-@$%%%%%%$$@****", +";;;;>=@$$$$$$$$@;;;;", +",,,,@-@$%%%%%$$@,,,,", +",,,,@>=@$$$$$$$@,,,,", +"''''@@-@$%%%%$$@''''", +"))))@!>=@$$$$$$@))))", +"))))@$@-@$$$$$$@))))", +"~~~~@$!>@$$$$$$@~~~~", +"{{{{@$$!@$$$$$$@{{{{", +"{{{{@!!!!!!!!!!@{{{{", +"]]]]@@@@@@@@@@@@]]]]", +"^^^^^^^^^^^^^^^^^^^^", +"^^^^^^^^^^^^^^^^^^^^"}; + +/* XPM */ +const char * button_minimize_xpm[] = { +"20 20 16 1", +" c None", +". c #F3F3F3", +"+ c #F2F2F2", +"@ c #F1F1F1", +"# c #F0F0F0", +"$ c #EFEFEF", +"% c #EEEEEE", +"& c #FFFFFF", +"* c #EDEDED", +"= c #6E6E6E", +"- c #ECECEC", +"; c #EBEBEB", +"> c #EAEAEA", +", c #E9E9E9", +"' c #E8E8E8", +") c #E7E7E7", +"....................", +"....................", +"++++++++++++++++++++", +"@@@@@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@@@@@", +"####################", +"$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$", +"%%%%%%%%%&&&%%%%%%%%", +"*********&*=********", +"*********&==********", +"--------------------", +";;;;;;;;;;;;;;;;;;;;", +";;;;;;;;;;;;;;;;;;;;", +">>>>>>>>>>>>>>>>>>>>", +",,,,,,,,,,,,,,,,,,,,", +",,,,,,,,,,,,,,,,,,,,", +"''''''''''''''''''''", +"))))))))))))))))))))", +"))))))))))))))))))))"}; + + +/* XPM */ +const char * button_sticky_xpm[] = { +"20 20 17 1", +" c None", +". c #F3F3F3", +"+ c #F2F2F2", +"@ c #F1F1F1", +"# c #F0F0F0", +"$ c #6E6E6E", +"% c #EFEFEF", +"& c #FFFFFF", +"* c #EEEEEE", +"= c #B7B7B7", +"- c #EDEDED", +"; c #ECECEC", +"> c #EBEBEB", +", c #EAEAEA", +"' c #E9E9E9", +") c #E8E8E8", +"! c #E7E7E7", +"....................", +"....................", +"++++++++++++++++++++", +"@@@@@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@@@@@", +"########$$#####$####", +"%%%%%%%%$&$%%%$$%%%%", +"%%%%%%%%$&&$$$&$%%%%", +"**&&&&&&$=&=&=&$****", +"--======$=&=&=&$----", +"--$$$$$$$==$=$=$----", +";;;;;;;;$=$$$$$$;;;;", +">>>>>>>>$$$>>>$$>>>>", +">>>>>>>>$$>>>>>$>>>>", +",,,,,,,,,,,,,,,,,,,,", +"''''''''''''''''''''", +"''''''''''''''''''''", +"))))))))))))))))))))", +"!!!!!!!!!!!!!!!!!!!!", +"!!!!!!!!!!!!!!!!!!!!"}; + +/* XPM */ +const char * button_spacer_xpm[] = { +"20 20 15 1", +" c None", +". c #F3F3F3", +"+ c #F2F2F2", +"@ c #F1F1F1", +"# c #F0F0F0", +"$ c #6E6E6E", +"% c #EFEFEF", +"& c #EEEEEE", +"* c #EDEDED", +"= c #ECECEC", +"- c #EBEBEB", +"; c #EAEAEA", +"> c #E9E9E9", +", c #E8E8E8", +"' c #E7E7E7", +"....................", +"....................", +"++++++++++++++++++++", +"@@@@@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@@@@@", +"######$######$######", +"%%%%%$$%%%%%%$$%%%%%", +"%%%%$$%%%%%%%%$$%%%%", +"&&&$$&&&&&&&&&&$$&&&", +"**$$************$$**", +"***$$**********$$***", +"====$$========$$====", +"-----$$------$$-----", +"------$------$------", +";;;;;;;;;;;;;;;;;;;;", +">>>>>>>>>>>>>>>>>>>>", +">>>>>>>>>>>>>>>>>>>>", +",,,,,,,,,,,,,,,,,,,,", +"''''''''''''''''''''", +"''''''''''''''''''''"}; + +/* XPM */ +const char * titlebarspacer_xpm[] = { +"6 20 7 1", +" c None", +". c #FFFFFF", +"+ c #E9E9E9", +"@ c #D3D3D3", +"# c #BEBEBE", +"$ c #A8A8A8", +"% c #929292", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%", +".+@#$%"}; + +// vim: ts=4 diff --git a/kcmkwin/kwinoptions/AUTHORS b/kcmkwin/kwinoptions/AUTHORS new file mode 100644 index 0000000000..0615c59db4 --- /dev/null +++ b/kcmkwin/kwinoptions/AUTHORS @@ -0,0 +1,12 @@ +Please use http://bugs.kde.org to report bugs. +The following authors may have retired by the time you read this :-) + +KWM Configuration Module: + + Pat Dowler (dowler@pt1B1106.FSH.UVic.CA) + + Bernd Wuebben + +Conversion to kcontrol applet: + + Matthias Hoelzer (hoelzer@physik.uni-wuerzburg.de) diff --git a/kcmkwin/kwinoptions/ChangeLog b/kcmkwin/kwinoptions/ChangeLog new file mode 100644 index 0000000000..0b923864ca --- /dev/null +++ b/kcmkwin/kwinoptions/ChangeLog @@ -0,0 +1,51 @@ +1999-03-06 Mario Weilguni + + * changes for Qt 2.0 + +1998-11-29 Alex Zepeda + + * pics/Makefile.am, pics/mini/Makefile.am: Install icons from their + "proper" subdirectories. + +1998-11-20 Cristian Tibirna + + * advanced.[cpp,h]: fixed bugs. Mostly a disgusting one: + no lists saving for the special options (Decor, Focus a.o.) + +1998-11-09 Cristian Tibirna + + * advanced.[cpp,h] : new tab for some of the last of the + kwm's options which remained out of the GUI config: + CtrlTab, TraverseAll, AltTabeMode, Button3Grab and + the filter lists for decorations, focus, stickyness, + session management ignore ( I kinda disklike the solution + I got for the latest) + +1998-11-06 Cristian Tibirna + + * titlebar.[cpp,h] : added title alignment config + +1998-10-23 Cristian Tibirna + + * titlebar.cpp: completed what Matthias started (took out + useless checks) + * widows.cpp: make autoRaise toggling clearer + +1998-10-22 Matthias Ettrich + + * titlebar.cpp: less options on titlebar doubleclick + +1998-10-21 Cristian Tibirna + + * desktop.[cpp,h]: now with consistent layout use + resizeEvent() deleted + +1998-10-19 Cristian Tibirna + + * windows.[cpp,h]: now with consistent layout use + resizeEvent() deleted + +1998-10-18 Cristian Tibirna + + * titlebar.[cpp,h]: fixed the (in)activetitleebar pixmap selection + 1998-10-21 (still buggy, don't quite understand why) diff --git a/kcmkwin/kwinoptions/Makefile.am b/kcmkwin/kwinoptions/Makefile.am new file mode 100644 index 0000000000..d63cef86a2 --- /dev/null +++ b/kcmkwin/kwinoptions/Makefile.am @@ -0,0 +1,25 @@ +# $Id$ +# kdebase/kcontrol/kwm + +METASOURCES = AUTO +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = libkcm_kwinoptions.la + +libkcm_kwinoptions_la_SOURCES = windows.cpp mouse.cpp main.cpp +libkcm_kwinoptions_la_LDFLAGS = -module -avoid-version $(all_libraries) -no-undefined +libkcm_kwinoptions_la_LIBADD = $(LIB_KDEUI) + +noinst_HEADERS = windows.h mouse.h main.h + +messages: + $(XGETTEXT) *.cpp -o $(podir)/kcmkwm.pot + +data_DATA = kwinoptions.desktop +datadir = $(kde_appsdir)/Settings/LookNFeel + +install-data-local: uninstall.desktop + $(mkinstalldirs) $(kde_appsdir)/Settings/LookNFeel/Windows + $(INSTALL_DATA) $(srcdir)/uninstall.desktop $(kde_appsdir)/Settings/LookNFeel/Windows/actions.desktop + $(INSTALL_DATA) $(srcdir)/uninstall.desktop $(kde_appsdir)/Settings/LookNFeel/Windows/kwinmouse.desktop + $(INSTALL_DATA) $(srcdir)/uninstall.desktop $(kde_appsdir)/Settings/LookNFeel/Windows/mouse.desktop diff --git a/kcmkwin/kwinoptions/kwinoptions.desktop b/kcmkwin/kwinoptions/kwinoptions.desktop new file mode 100644 index 0000000000..a7bd0512ce --- /dev/null +++ b/kcmkwin/kwinoptions/kwinoptions.desktop @@ -0,0 +1,92 @@ +[Desktop Entry] +Icon=kcmkwm +Type=Application +Exec=kcmshell kwinoptions +DocPath=kcontrol/window-behavior.html + +X-KDE-ModuleType=Library +X-KDE-Library=kwinoptions +X-KDE-FactoryName=kwinoptions + +Name=Window Behavior +Name[af]=VENSTER GEDRAG +Name[az]=Pəncərə Davranışı +Name[bg]=Поведение на прозореца +Name[br]=Emzalc'h ar prenester +Name[bs]=Funkcioniranje prozora +Name[ca]=Comportament de les finestres +Name[cs]=Chování oken +Name[da]=Vinduesopførsel +Name[de]=Fenstereigenschaften +Name[el]=Συμπεριφορά Παραθύρων +Name[en_GB]=Window Behaviour +Name[eo]=Fenestrokonduto +Name[es]=Comportamiento de ventanas +Name[et]=Akende käitumine +Name[eu]=Lehioen Portamoldea +Name[fi]=Ikkunoiden toiminta +Name[fr]=Comportement des fenêtres +Name[gl]=Comportamento das Fiestras +Name[he]=תונולח +Name[hr]=Funkcioniranje prozora +Name[hu]=Ablakbeállítások +Name[is]=Hegðun Glugga +Name[it]=Comportamento delle finestre +Name[ja]=ウィンドウの挙動 +Name[ko]=창 움직임 +Name[lt]=Langų elgsena +Name[lv]=Loga izturēšanās +Name[mi]=Whanonga Matapihi +Name[mk]=Прозорци +Name[mt]=Imġieba tal-Window +Name[nl]=Venstergedrag +Name[no]=Vindu-oppførsel +Name[no_NY]=Vindaugsåtferd +Name[oc]=Comportament de las finestras +Name[pl]=Zachowanie okna +Name[pt_BR]=Comportamento das Janelas +Name[pt]=Comportamento das Janelas +Name[ru]=Поведение окна +Name[sk]=Spôsob režimu okna +Name[sl]=Obnašanje oken +Name[sr]=Ponašanje prozora +Name[sv]=Fönsterbeteende +Name[ta]=º¡Çà ¿¼ò¨¾ +Name[tr]=Pencere Davranışı +Name[uk]=Поведінка вікон +Name[vi]=Thái đềEcủa cửa sềEbehavior) +Name[zh_CN.GB2312]=窗口行为 +Name[zh_TW.Big5]=視窗行為 + +Keywords=focus,placement,window behaviour,animation,raise,auto raise,windows,frame,titlebar,doubleclick +Keywords[af]=FOKUS,PLASING,VENSTER OPTREDE,ANIMASIE,LIG,OUTO LIG,VENSTERs,RAAM,TITELBAR,DUBBEL KLIEK +Keywords[az]=fokus,fokus davranış şəkli,pəncərə yeri,pəncərə davranışı,Yer davranış şəkli,animasiya,Qaldır,Avtomatik Qaldır,çərçicə,cüt tıqla +Keywords[cs]=Zaměření,Umístění oken,Chování oken,Animace,Okna,Rámeček,Titulek,Dvojklik +Keywords[da]=fokus,placering,vinduesopførsel,animering,Hæv,autohæv,vinduer,ramme,titellinie,dobbeltklik +Keywords[de]=Fokus,Aktivierung,Fensterplatzierung,Fensterverhalten,Vordergrund,Animation,Autom. im Vordergrund,Fenster,Rahmen,Titelleiste,Doppelklick +Keywords[el]=εστίαση,τοποθέτηση,συμπεριφορά παραθύρων,animation,ανύψωση,αυτόματη ανύψωση,παράθυρα,πλαίσιο,γραμμή τίτλου,διπλό κλικ +Keywords[eo]=fokuso,lokigo,fenestrokonduto,spektaklo,malfonigo,aŭtomalfonigo,fenestro,kadro,titollistelo,duklako +Keywords[es]=foco,ubicación,comportamiento de ventanas,animación,subir,auto subir,ventanas,marco,barra de título,doble pulsación +Keywords[et]=fookus,asetus,akende käitumine,animatsioon,tõstmine,automaatne tõstmine,aknad,raam,tiitliriba,topeltklikk +Keywords[fi]=fokus,sijoittaminen,ikkunan toiminta,animaatio,nosto,automaattinosto,ikkunat,kehys,otsikkorivi,tuplanapsautus +Keywords[fr]=focus,gestion du focus,fenêtre,placement des fenêtres,comportement des fenêtres,animation,fenêtres,barre de titre,double clic,souris,boutons de la souris,dessus,dessous,raise,auto raise +Keywords[he]=הלופכ הציחל,תרתוכ תרוש,תרגסמ,תונולח,המדקל תיטמוטוא האבה,המדקל האבה,השפנה,היצמינא,תונולח תוגהנתה,םוקימ,תודקמתה +Keywords[hu]=fókuszálási módszer,ablakelhelyezés,az ablakok viselkedése,animáció,felemelés,automatikus felemelés,ablakok,keret,címsor,dupla kattintás +Keywords[is]=virkni glugga,staðsetning,hegðun,högun glugga,hækka,hækka sjálfkrafa,gluggar,titilslá,titilrönd,tvísmella +Keywords[it]=politica focus, piazzamento finestre, comportamento finestre,animazione,alza,alza automaticamente,finestre,cornice,barra titolo,doppio clic +Keywords[ja]=フォーカス,配置,ウィンドウの挙動,アニメーション,前へ,自動的に前へ,ウィンドウ,フレーム,タイトルバー,ダブルクリック +Keywords[ko]=focus,placement,window behaviour,animation,raise,auto raise,windows,frame,titlebar,doubleclick,포커스,촛점,초점,창 움직임,숨김,올리기,내리기,스스로 올리기,창,제목줄,타이틀 바,두번 누르기,더블 클릭 +Keywords[lt]=focus,placement,window behaviour,animation,raise,auto raise,windows,frame,titlebar,doubleclick,lango išdėstymas,elgesys,langai,rėmelis,lango antraštė +Keywords[lv]=fokuss,novietojums,loga izturēšanās,animācija,celt,auto celt,logi,kadrs,titlujosla,dubultklikšķis +Keywords[nl]=focusbeleid,vensterplaatsing,venstergedrag,focus,window,plaatsing,plaatsingbeleid,animatie,voorgrond,vensters,frame,kader,dubbelklikken +Keywords[no]=fokuspolitikk,vinduplassering,vinduoppfrsel +Keywords[no_NY]=fokus,vindaugsplassering,vindaugsåtferd,plassering,animasjon,hev,autohev,vindauge,ramme,tittellinje,dobbelklikk +Keywords[pl]=ognisko,układanie okien,zachowanie okien,animacja,podniesienie,automatyczne podniesienie,okna,ramka,belka tytułowa,podwójne kliknięcie +Keywords[pt_BR]=foco,posicionamento,comportamento das janelas,política de foco,posicionamento de janelas,Política de posicionamento,animação,elevar,auto-elevar,clique duplo,barra de título,moldura,frame,janelas +Keywords[pt]=política de primeiro plano,colocação das janelas,comportamento das janelas,animação,elevar,auto-elevar,janelas,moldura,título,duplo 'click' +Keywords[sk]=umiestnenie okna, spôsob práce okna,fokus,chovanie okna,animácia,automatické vyzdvihnutie,dvojklik,titulok,rám +Keywords[sl]=politika fokusiranja,postavitev oken,obnašanje oken,animacija,dvig,samodejni dvig,okna,okvir,naslovna letev,dvojni klik +Keywords[sv]=fokus,placering,fönsterbeteende,animering,höj,höj automatiskt,fönster,ram,titelrad,dubbelklick +Keywords[tr]=odak,odak davranış biçimi,pencere yerleşimi,pencere davranışı,Yerleşim davranış biçimi,animasyon,Kaldır,Otomatik Kaldır,çerçeve,çift tıkla +Keywords[uk]=фокуса,вікна,поведінка вікна,розташовування,анімація,підняти,підніматиавтоматично,вікна,рамки,заголовок,подвійне клацання +Keywords[zh_CN.GB2312]=focus,placement,window behaviour,animation,raise,auto raise,windows,frame,titlebar,doubleclick,焦点,窗口放置,窗口行为,动画,窗口 diff --git a/kcmkwin/kwinoptions/main.cpp b/kcmkwin/kwinoptions/main.cpp new file mode 100644 index 0000000000..b3984e981b --- /dev/null +++ b/kcmkwin/kwinoptions/main.cpp @@ -0,0 +1,123 @@ +/* + * + * Copyright (c) 2001 Waldo Bastian + * + * 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. + */ + +#include + +#include + +#include +#include +#include +#include +#include + +#include "mouse.h" +#include "windows.h" + +#include "main.h" + +typedef KGenericFactory KWinOptFactory; +K_EXPORT_COMPONENT_FACTORY( libkcm_kwinoptions, KWinOptFactory("kcmkwm") ); +/* +extern "C" { + KCModule *create_kwinoptions ( QWidget *parent, const char* name) + { + //CT there's need for decision: kwm or kwin? + KGlobal::locale()->insertCatalogue("kcmkwm"); + return new KWinOptions( parent, name); + } +} +*/ +KWinOptions::KWinOptions(QWidget *parent, const char *name, const QStringList &) + : KCModule(parent, name) +{ + mConfig = new KConfig("kwinrc", false, true); + + QVBoxLayout *layout = new QVBoxLayout(this); + tab = new QTabWidget(this); + layout->addWidget(tab); + + mFocus = new KFocusConfig(mConfig, this, "KWin Focus Config"); + tab->addTab(mFocus, i18n("&Focus")); + connect(mFocus, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); + + mActions = new KActionsConfig(mConfig, this, "KWin Actions"); + tab->addTab(mActions, i18n("&Actions")); + connect(mActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); + + mMoving = new KMovingConfig(mConfig, this, "KWin Moving"); + tab->addTab(mMoving, i18n("&Moving")); + connect(mMoving, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); + + mAdvanced = new KAdvancedConfig(mConfig, this, "KWin Advanced"); + tab->addTab(mAdvanced, i18n("Ad&vanced")); + connect(mAdvanced, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); +} + + +void KWinOptions::load() +{ + mConfig->reparseConfiguration(); + mFocus->load(); + mActions->load(); + mMoving->load(); + mAdvanced->load(); +} + + +void KWinOptions::save() +{ + mFocus->save(); + mActions->save(); + mMoving->save(); + mAdvanced->save(); + + // Send signal to kwin + mConfig->sync(); + if ( !kapp->dcopClient()->isAttached() ) + kapp->dcopClient()->attach(); + kapp->dcopClient()->send("kwin*", "", "reconfigure()", ""); +} + + +void KWinOptions::defaults() +{ + mFocus->defaults(); + mActions->defaults(); + mMoving->defaults(); + mAdvanced->defaults(); +} + +QString KWinOptions::quickHelp() const +{ + return i18n("

Window Behavior

Here you can customize the way windows behave when being" + " moved, resized or clicked on. You can also specify a focus policy as well as a placement" + " policy for new windows. " + "

Please note that this configuration will not take effect if you don't use" + " KWin as your window manager. If you do use a different window manager, please refer to its documentation" + " for how to customize window behavior."); +} + +void KWinOptions::moduleChanged(bool state) +{ + emit changed(state); +} + + +#include "main.moc" diff --git a/kcmkwin/kwinoptions/main.h b/kcmkwin/kwinoptions/main.h new file mode 100644 index 0000000000..752c633cb8 --- /dev/null +++ b/kcmkwin/kwinoptions/main.h @@ -0,0 +1,67 @@ +/* + * main.h + * + * Copyright (c) 2001 Waldo Bastian + * + * Requires the Qt widget libraries, available at no cost at + * http://www.troll.no/ + * + * 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. + */ + + +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#include +#include + +class KConfig; +class KFocusConfig; +class KActionsConfig; +class KAdvancedConfig; + +class KWinOptions : public KCModule +{ + Q_OBJECT + +public: + + KWinOptions(QWidget *parent, const char *name, const QStringList &); + + void load(); + void save(); + void defaults(); + QString quickHelp() const; + + +protected slots: + + void moduleChanged(bool state); + + +private: + + QTabWidget *tab; + + KFocusConfig *mFocus; + KActionsConfig *mActions; + KMovingConfig *mMoving; + KAdvancedConfig *mAdvanced; + + KConfig *mConfig; +}; + +#endif diff --git a/kcmkwin/kwinoptions/mouse.cpp b/kcmkwin/kwinoptions/mouse.cpp new file mode 100644 index 0000000000..8978eb7302 --- /dev/null +++ b/kcmkwin/kwinoptions/mouse.cpp @@ -0,0 +1,506 @@ +/* + * + * Copyright (c) 1998 Matthias Ettrich + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include // For KKeyNative::keyboardHasMetaKey() + +#include +#include +#include + +#include "mouse.h" +#include "mouse.moc" + + +KActionsConfig::~KActionsConfig () +{ + +} + +KActionsConfig::KActionsConfig (KConfig *_config, QWidget * parent, const char *name) + : KCModule (parent, name), config(_config) +{ + QString strWin1, strWin2, strWin3, strAllKey, strAll1, strAll2, strAll3; + QVBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint()); + QGrid *grid; + QGroupBox *box; + QLabel *label; + QString strMouseButton1, strMouseButton3; + QString txtButton1, txtButton3; + QStringList items; + bool leftHandedMouse = ( KGlobalSettings::mouseSettings().handed == KGlobalSettings::KMouseSettings::LeftHanded); + +/** Titlebar doubleclick ************/ + + QHBoxLayout *hlayout = new QHBoxLayout(layout); + + label = new QLabel(i18n("&Titlebar double-click:"), this); + hlayout->addWidget(label); + QWhatsThis::add( label, i18n("Here you can customize mouse click behavior when double clicking on the" + " titlebar of a window.") ); + + QComboBox* combo = new QComboBox(this); + combo->insertItem(i18n("Maximize")); + combo->insertItem(i18n("Maximize (vertical only)")); + combo->insertItem(i18n("Maximize (horizontal only)")); + combo->insertItem(i18n("Shade")); + combo->insertItem(i18n("Lower")); + combo->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + hlayout->addWidget(combo); + coTiDbl = combo; + QWhatsThis::add(combo, i18n("Behavior on double click into the titlebar.")); + + label->setBuddy(combo); + +/** Titlebar and frame **************/ + + box = new QVGroupBox( i18n("Titlebar and frame"), this, "Titlebar and frame"); + box->layout()->setMargin(KDialog::marginHint()); + box->layout()->setSpacing(KDialog::spacingHint()); + layout->addWidget(box); + QWhatsThis::add( box, i18n("Here you can customize mouse click behavior when clicking on the" + " titlebar or the frame of a window.") ); + + grid = new QGrid(4, Qt::Vertical, box); + + + new QLabel(grid); // dummy + + strMouseButton1 = i18n("Left Button:"); + txtButton1 = i18n("In this row you can customize left click behavior when clicking into" + " the titlebar or the frame."); + + strMouseButton3 = i18n("Right Button:"); + txtButton3 = i18n("In this row you can customize right click behavior when clicking into" + " the titlebar or the frame." ); + + if ( leftHandedMouse ) + { + qSwap(strMouseButton1, strMouseButton3); + qSwap(txtButton1, txtButton3); + } + + label = new QLabel(strMouseButton1, grid); + QWhatsThis::add( label, txtButton1); + + label = new QLabel(i18n("Middle Button:"), grid); + QWhatsThis::add( label, i18n("In this row you can customize middle click behavior when clicking into" + " the titlebar or the frame.") ); + + label = new QLabel(strMouseButton3, grid); + QWhatsThis::add( label, txtButton3); + + + label = new QLabel(i18n("Active"), grid); + label->setAlignment(AlignCenter); + QWhatsThis::add( label, i18n("In this column you can customize mouse clicks into the titlebar" + " or the frame of an active window.") ); + + // Titlebar and frame, active, mouse button 1 + combo = new QComboBox(grid); + combo->insertItem(i18n("Raise")); + combo->insertItem(i18n("Lower")); + combo->insertItem(i18n("Operations menu")); + combo->insertItem(i18n("Toggle raise and lower")); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coTiAct1 = combo; + + txtButton1 = i18n("Behavior on left click into the titlebar or frame of an " + "active window."); + + txtButton3 = i18n("Behavior on right click into the titlebar or frame of an " + "active window."); + + // Be nice to left handed users + if ( leftHandedMouse ) qSwap(txtButton1, txtButton3); + + QWhatsThis::add(combo, txtButton1); + + // Titlebar and frame, active, mouse button 2 + + items << i18n("Raise") + << i18n("Lower") + << i18n("Operations menu") + << i18n("Toggle raise and lower") + << i18n("Nothing") + << i18n("Shade"); + + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coTiAct2 = combo; + QWhatsThis::add(combo, i18n("Behavior on middle click into the titlebar or frame of an active window.")); + + // Titlebar and frame, active, mouse button 3 + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coTiAct3 = combo; + QWhatsThis::add(combo, txtButton3 ); + + txtButton1 = i18n("Behavior on left click into the titlebar or frame of an " + "inactive window."); + + txtButton3 = i18n("Behavior on right click into the titlebar or frame of an " + "inactive window."); + + // Be nice to left handed users + if ( leftHandedMouse ) qSwap(txtButton1, txtButton3); + + label = new QLabel(i18n("Inactive"), grid); + label->setAlignment(AlignCenter); + QWhatsThis::add( label, i18n("In this column you can customize mouse clicks into the titlebar" + " or the frame of an inactive window.") ); + + items.clear(); + items << i18n("Activate and raise") + << i18n("Activate and lower") + << i18n("Activate") + << i18n("Shade"); + + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coTiInAct1 = combo; + QWhatsThis::add(combo, txtButton1); + + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coTiInAct2 = combo; + QWhatsThis::add(combo, i18n("Behavior on middle click into the titlebar or frame of an inactive window.")); + + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coTiInAct3 = combo; + QWhatsThis::add(combo, txtButton3); + +/** Inactive inner window ******************/ + + box = new QVGroupBox(i18n("Inactive inner window"), this, "Inactive inner window"); + box->layout()->setMargin(KDialog::marginHint()); + box->layout()->setSpacing(KDialog::spacingHint()); + layout->addWidget(box); + QWhatsThis::add( box, i18n("Here you can customize mouse click behavior when clicking on an inactive" + " inner window ('inner' means: not titlebar, not frame).") ); + + grid = new QGrid(3, Qt::Vertical, box); + + strMouseButton1 = i18n("Left Button:"); + txtButton1 = i18n("In this row you can customize left click behavior when clicking into" + " the titlebar or the frame."); + + strMouseButton3 = i18n("Right Button:"); + txtButton3 = i18n("In this row you can customize right click behavior when clicking into" + " the titlebar or the frame." ); + + if ( leftHandedMouse ) + { + qSwap(strMouseButton1, strMouseButton3); + qSwap(txtButton1, txtButton3); + } + + strWin1 = i18n("In this row you can customize left click behavior when clicking into" + " an inactive inner window ('inner' means: not titlebar, not frame)."); + + strWin3 = i18n("In this row you can customize right click behavior when clicking into" + " an inactive inner window ('inner' means: not titlebar, not frame)."); + + // Be nice to lefties + if ( leftHandedMouse ) qSwap(strWin1, strWin3); + + label = new QLabel(strMouseButton1, grid); + QWhatsThis::add( label, strWin1 ); + + label = new QLabel(i18n("Middle Button:"), grid); + strWin2 = i18n("In this row you can customize middle click behavior when clicking into" + " an inactive inner window ('inner' means: not titlebar, not frame)."); + QWhatsThis::add( label, strWin2 ); + + label = new QLabel(strMouseButton3, grid); + QWhatsThis::add( label, strWin3 ); + + items.clear(); + items << i18n("Activate, raise and pass click") + << i18n("Activate and pass click") + << i18n("Activate") + << i18n("Activate and raise"); + + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coWin1 = combo; + QWhatsThis::add( combo, strWin1 ); + + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coWin2 = combo; + QWhatsThis::add( combo, strWin2 ); + + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coWin3 = combo; + QWhatsThis::add( combo, strWin3 ); + + +/** Inner window, titlebar and frame **************/ + + box = new QVGroupBox(i18n("Inner window, titlebar and frame"), this, "Inner window, titlebar and frame"); + box->layout()->setMargin(KDialog::marginHint()); + box->layout()->setSpacing(KDialog::spacingHint()); + layout->addWidget(box); + QWhatsThis::add( box, i18n("Here you can customize KDE's behavior when clicking somewhere into" + " a window while pressing a modifier key.")); + + grid = new QGrid(4, Qt::Vertical, box); + + // Labels + label = new QLabel(i18n("Modifier Key:"), grid); + + strAllKey = i18n("Here you select whether holding the Meta key or Alt key " + "will allow you to perform the following actions."); + QWhatsThis::add( label, strAllKey ); + + label = new QLabel(i18n("Modifier Key + Middle Button:"), grid); + strAll2 = i18n("Here you can customize KDE's behavior when middle clicking into a window" + " while pressing the modifier key."); + QWhatsThis::add( label, strAll2 ); + + + strMouseButton1 = i18n("Modifier Key + Left Button:"); + strAll1 = i18n("In this row you can customize left click behavior when clicking into" + " the titlebar or the frame."); + + strMouseButton3 = i18n("Modifier Key + Right Button:"); + strAll3 = i18n("In this row you can customize right click behavior when clicking into" + " the titlebar or the frame." ); + + if ( leftHandedMouse ) + { + qSwap(strMouseButton1, strMouseButton3); + qSwap(strAll1, strAll3); + } + + label = new QLabel(strMouseButton1, grid); + QWhatsThis::add( label, strAll1); + + label = new QLabel(strMouseButton3, grid); + QWhatsThis::add( label, strAll3); + + // Combo's + combo = new QComboBox(grid); + combo->insertItem(i18n("Meta")); + combo->insertItem(i18n("Alt")); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coAllKey = combo; + QWhatsThis::add( combo, strAllKey ); + + items.clear(); + items << i18n("Move") + << i18n("Toggle raise and lower") + << i18n("Resize") + << i18n("Raise") + << i18n("Lower") + << i18n("Nothing"); + + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coAll1 = combo; + QWhatsThis::add( combo, strAll1 ); + + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coAll2 = combo; + QWhatsThis::add( combo, strAll2 ); + + combo = new QComboBox(grid); + combo->insertStringList(items); + connect(combo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + coAll3 = combo; + QWhatsThis::add( combo, strAll3 ); + + layout->addStretch(); + + load(); +} + +void KActionsConfig::setComboText(QComboBox* combo, const char* text){ + int i; + QString s = i18n(text); // no problem. These are already translated! + for (i=0;icount();i++){ + if (s==combo->text(i)){ + combo->setCurrentItem(i); + return; + } + } +} + +const char* KActionsConfig::functionTiDbl(int i) +{ + switch (i){ + case 0: return "Maximize"; break; + case 1: return "Maximize (vertical only)"; break; + case 2: return "Maximize (horizontal only)"; break; + case 3: return "Shade"; break; + case 4: return "Lower"; break; + } + return ""; +} + +const char* KActionsConfig::functionTiAc(int i) +{ + switch (i){ + case 0: return "Raise"; break; + case 1: return "Lower"; break; + case 2: return "Operations menu"; break; + case 3: return "Toggle raise and lower"; break; + case 4: return "Nothing"; break; + case 5: return "Shade"; break; + } + return ""; +} +const char* KActionsConfig::functionTiInAc(int i) +{ + switch (i){ + case 0: return "Activate and raise"; break; + case 1: return "Activate and lower"; break; + case 2: return "Activate"; break; + case 3: return "Shade"; break; + case 4: return ""; break; + case 5: return ""; break; + } + return ""; +} +const char* KActionsConfig::functionWin(int i) +{ + switch (i){ + case 0: return "Activate, raise and pass click"; break; + case 1: return "Activate and pass click"; break; + case 2: return "Activate"; break; + case 3: return "Activate and raise"; break; + case 4: return ""; break; + case 5: return ""; break; + } + return ""; +} +const char* KActionsConfig::functionAllKey(int i) +{ + switch (i){ + case 0: return "Meta"; break; + case 1: return "Alt"; break; + } + return ""; +} +const char* KActionsConfig::functionAll(int i) +{ + switch (i){ + case 0: return "Move"; break; + case 1: return "Toggle raise and lower"; break; + case 2: return "Resize"; break; + case 3: return "Raise"; break; + case 4: return "Lower"; break; + case 5: return "Nothing"; break; + } + return ""; +} + + +void KActionsConfig::load() +{ + config->setGroup("Windows"); + setComboText(coTiDbl, config->readEntry("TitlebarDoubleClickCommand","Shade").ascii()); + + config->setGroup( "MouseBindings"); + setComboText(coTiAct1,config->readEntry("CommandActiveTitlebar1","Raise").ascii()); + setComboText(coTiAct2,config->readEntry("CommandActiveTitlebar2","Lower").ascii()); + setComboText(coTiAct3,config->readEntry("CommandActiveTitlebar3","Operations menu").ascii()); + setComboText(coTiInAct1,config->readEntry("CommandInactiveTitlebar1","Activate and raise").ascii()); + setComboText(coTiInAct2,config->readEntry("CommandInactiveTitlebar2","Activate and lower").ascii()); + setComboText(coTiInAct3,config->readEntry("CommandInactiveTitlebar3","Activate").ascii()); + setComboText(coWin1,config->readEntry("CommandWindow1","Activate, raise and pass click").ascii()); + setComboText(coWin2,config->readEntry("CommandWindow2","Activate and pass click").ascii()); + setComboText(coWin3,config->readEntry("CommandWindow3","Activate and pass click").ascii()); + setComboText(coAllKey,config->readEntry("CommandAllKey","Alt").ascii()); + setComboText(coAll1,config->readEntry("CommandAll1","Move").ascii()); + setComboText(coAll2,config->readEntry("CommandAll2","Toggle raise and lower").ascii()); + setComboText(coAll3,config->readEntry("CommandAll3","Resize").ascii()); +} + +// many widgets connect to this slot +void KActionsConfig::slotChanged() +{ + emit changed(true); +} + +void KActionsConfig::save() +{ + config->setGroup("Windows"); + config->writeEntry("TitlebarDoubleClickCommand", functionTiDbl( coTiDbl->currentItem() ) ); + + config->setGroup("MouseBindings"); + config->writeEntry("CommandActiveTitlebar1", functionTiAc(coTiAct1->currentItem())); + config->writeEntry("CommandActiveTitlebar2", functionTiAc(coTiAct2->currentItem())); + config->writeEntry("CommandActiveTitlebar3", functionTiAc(coTiAct3->currentItem())); + config->writeEntry("CommandInactiveTitlebar1", functionTiInAc(coTiInAct1->currentItem())); + config->writeEntry("CommandInactiveTitlebar2", functionTiInAc(coTiInAct2->currentItem())); + config->writeEntry("CommandInactiveTitlebar3", functionTiInAc(coTiInAct3->currentItem())); + config->writeEntry("CommandWindow1", functionWin(coWin1->currentItem())); + config->writeEntry("CommandWindow2", functionWin(coWin2->currentItem())); + config->writeEntry("CommandWindow3", functionWin(coWin3->currentItem())); + config->writeEntry("CommandAllKey", functionAllKey(coAllKey->currentItem())); + config->writeEntry("CommandAll1", functionAll(coAll1->currentItem())); + config->writeEntry("CommandAll2", functionAll(coAll2->currentItem())); + config->writeEntry("CommandAll3", functionAll(coAll3->currentItem())); +} + +void KActionsConfig::defaults() +{ + setComboText(coTiAct1,"Raise"); + setComboText(coTiAct2,"Lower"); + setComboText(coTiAct3,"Operations menu"); + setComboText(coTiInAct1,"Activate and raise"); + setComboText(coTiInAct2,"Activate and lower"); + setComboText(coTiInAct3,"Activate"); + setComboText(coWin1,"Activate, raise and pass click"); + setComboText(coWin2,"Activate and pass click"); + setComboText(coWin3,"Activate and pass click"); + setComboText(coAllKey, KKeyNative::keyboardHasMetaKey() ? "Meta" : "Alt"); + setComboText (coAll1,"Move"); + setComboText(coAll2,"Toggle raise and lower"); + setComboText(coAll3,"Resize"); +} diff --git a/kcmkwin/kwinoptions/mouse.h b/kcmkwin/kwinoptions/mouse.h new file mode 100644 index 0000000000..bd09d748ea --- /dev/null +++ b/kcmkwin/kwinoptions/mouse.h @@ -0,0 +1,79 @@ +/* + * mouse.h + * + * Copyright (c) 1998 Matthias Ettrich + * + * + * 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. + */ + +#ifndef __KKWMMOUSECONFIG_H__ +#define __KKWMMOUSECONFIG_H__ + +class QComboBox; +class KConfig; + +#include + +class KActionsConfig : public KCModule +{ + Q_OBJECT + +public: + + KActionsConfig( KConfig *_config, QWidget *parent=0, const char* name=0 ); + ~KActionsConfig( ); + + void load(); + void save(); + void defaults(); + +private slots: + void slotChanged(); + +private: + QComboBox* coTiDbl; + + QComboBox* coTiAct1; + QComboBox* coTiAct2; + QComboBox* coTiAct3; + QComboBox* coTiInAct1; + QComboBox* coTiInAct2; + QComboBox* coTiInAct3; + + QComboBox* coWin1; + QComboBox* coWin2; + QComboBox* coWin3; + + QComboBox* coAllKey; + QComboBox* coAll1; + QComboBox* coAll2; + QComboBox* coAll3; + + KConfig *config; + + const char* functionTiDbl(int); + const char* functionTiAc(int); + const char* functionTiInAc(int); + const char* functionWin(int); + const char* functionAllKey(int); + const char* functionAll(int); + + void setComboText(QComboBox* combo, const char* text); + +}; + +#endif + diff --git a/kcmkwin/kwinoptions/uninstall.desktop b/kcmkwin/kwinoptions/uninstall.desktop new file mode 100644 index 0000000000..e1e3e17323 --- /dev/null +++ b/kcmkwin/kwinoptions/uninstall.desktop @@ -0,0 +1,2 @@ +[Desktop Entry] +Hidden=true diff --git a/kcmkwin/kwinoptions/windows.cpp b/kcmkwin/kwinoptions/windows.cpp new file mode 100644 index 0000000000..47f0d0d78b --- /dev/null +++ b/kcmkwin/kwinoptions/windows.cpp @@ -0,0 +1,1045 @@ +/* + * windows.cpp + * + * Copyright (c) 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca + * Copyright (c) 2001 Waldo Bastian bastian@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. + * + * 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. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifdef HAVE_XINERAMA +#include +#endif + +#include +#include +#include + +#include "windows.h" + + +// kwin config keywords +#define KWIN_FOCUS "FocusPolicy" +#define KWIN_PLACEMENT "Placement" +#define KWIN_MOVE "MoveMode" +#define KWIN_MINIMIZE_ANIM "AnimateMinimize" +#define KWIN_MINIMIZE_ANIM_SPEED "AnimateMinimizeSpeed" +#define KWIN_RESIZE_OPAQUE "ResizeMode" +#define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval" +#define KWIN_AUTORAISE "AutoRaise" +#define KWIN_CLICKRAISE "ClickRaise" +#define KWIN_ANIMSHADE "AnimateShade" +#define KWIN_MOVE_RESIZE_MAXIMIZED "MoveResizeMaximizedWindows" +#define KWIN_ALTTABMODE "AltTabStyle" +#define KWIN_TRAVERSE_ALL "TraverseAll" +#define KWIN_SHADEHOVER "ShadeHover" +#define KWIN_SHADEHOVER_INTERVAL "ShadeHoverInterval" +#define KWIN_XINERAMA "XineramaEnabled" +#define KWIN_XINERAMA_MOVEMENT "XineramaMovementEnabled" +#define KWIN_XINERAMA_PLACEMENT "XineramaPlacementEnabled" +#define KWIN_XINERAMA_MAXIMIZE "XineramaMaximizeEnabled" + +// kwm config keywords +#define KWM_ELECTRIC_BORDER "ElectricBorders" +#define KWM_ELECTRIC_BORDER_DELAY "ElectricBorderDelay" + +//CT 15mar 98 - magics +#define KWM_BRDR_SNAP_ZONE "BorderSnapZone" +#define KWM_BRDR_SNAP_ZONE_DEFAULT 10 +#define KWM_WNDW_SNAP_ZONE "WindowSnapZone" +#define KWM_WNDW_SNAP_ZONE_DEFAULT 10 + +#define MAX_BRDR_SNAP 100 +#define MAX_WNDW_SNAP 100 +#define MAX_EDGE_RES 1000 + + +KFocusConfig::~KFocusConfig () +{ +} + +// removed the LCD display over the slider - this is not good GUI design :) RNolden 051701 +KFocusConfig::KFocusConfig (KConfig *_config, QWidget * parent, const char *name) + : KCModule (parent, name), config(_config) +{ + QString wtstr; + QBoxLayout *lay = new QVBoxLayout (this, KDialog::marginHint(), + KDialog::spacingHint()); + + //iTLabel = new QLabel(i18n(" Allowed overlap:\n" + // "(% of desktop space)"), + // plcBox); + //iTLabel->setAlignment(AlignTop|AlignHCenter); + //pLay->addWidget(iTLabel,1,1); + + //interactiveTrigger = new QSpinBox(0, 500, 1, plcBox); + //pLay->addWidget(interactiveTrigger,1,2); + + //pLay->addRowSpacing(2,KDialog::spacingHint()); + + //lay->addWidget(plcBox); + + // focus policy + fcsBox = new QButtonGroup(i18n("Focus policy"),this); + + QGridLayout *fLay = new QGridLayout(fcsBox,5,3, + KDialog::marginHint(), + KDialog::spacingHint()); + fLay->addRowSpacing(0,fontMetrics().lineSpacing()); + fLay->setColStretch(0,0); + fLay->setColStretch(1,1); + fLay->setColStretch(2,1); + + + focusCombo = new QComboBox(false, fcsBox); + focusCombo->insertItem(i18n("Click to focus"), CLICK_TO_FOCUS); + focusCombo->insertItem(i18n("Focus follows mouse"), FOCUS_FOLLOWS_MOUSE); + focusCombo->insertItem(i18n("Focus under mouse"), FOCUS_UNDER_MOUSE); + focusCombo->insertItem(i18n("Focus strictly under mouse"), FOCUS_STRICTLY_UNDER_MOUSE); + fLay->addMultiCellWidget(focusCombo,1,1,0,1); + + // FIXME, when more policies have been added to KWin + QWhatsThis::add( focusCombo, i18n("The focus policy is used to determine the active window, i.e." + " the window you can work in.

    " + "
  • Click to focus: A window becomes active when you click into it. This is the behavior" + " you might know from other operating systems.
  • " + "
  • Focus follows mouse: Moving the mouse pointer actively on to a" + " normal window activates it. Very practical if you are using the mouse a lot.
  • " + "
  • Focus under mouse: The window that happens to be under the" + " mouse pointer becomes active. If the mouse points nowhere, the last window" + " that was under the mouse has focus.
  • " + "
  • Focus strictly under mouse: This is even worse than" + " 'Focus under mouse'. Only the window under the mouse pointer is" + " active. If the mouse points nowhere, nothing has focus. " + "
" + " Note that 'Focus under mouse' and 'Focus strictly under mouse' are not" + " particularly useful. They are only provided for old-fashioned" + " die-hard UNIX people ;-)" + ) ); + + connect(focusCombo, SIGNAL(activated(int)),this, + SLOT(setAutoRaiseEnabled()) ); + + // autoraise delay + + autoRaiseOn = new QCheckBox(i18n("Auto Raise"), fcsBox); + fLay->addWidget(autoRaiseOn,2,0); + connect(autoRaiseOn,SIGNAL(toggled(bool)), this, SLOT(autoRaiseOnTog(bool))); + + clickRaiseOn = new QCheckBox(i18n("Click Raise"), fcsBox); + fLay->addWidget(clickRaiseOn,4,0); + + connect(clickRaiseOn,SIGNAL(toggled(bool)), this, SLOT(clickRaiseOnTog(bool))); + + alabel = new QLabel(i18n("Delay (ms)"), fcsBox); + alabel->setAlignment(AlignVCenter|AlignHCenter); + fLay->addWidget(alabel,3,0,AlignLeft); + + autoRaise = new KIntNumInput(500, fcsBox); + autoRaise->setRange(0, 3000, 100, true); + autoRaise->setSteps(100,100); + fLay->addMultiCellWidget(autoRaise,3,3,1,2); + + fLay->addColSpacing(0,QMAX(autoRaiseOn->sizeHint().width(), + clickRaiseOn->sizeHint().width()) + 15); + + QWhatsThis::add( autoRaiseOn, i18n("If Auto Raise is enabled, a window in the background will automatically" + " come to the front when the mouse pointer has been over it for some time.") ); + wtstr = i18n("This is the delay after which the window that the mouse pointer is over will automatically" + " come to the front."); + QWhatsThis::add( autoRaise, wtstr ); +// QWhatsThis::add( s, wtstr ); + QWhatsThis::add( alabel, wtstr ); + + QWhatsThis::add( clickRaiseOn, i18n("When this option is enabled, your windows will be brought to the" + " front when you click somewhere into the window contents.") ); + + lay->addWidget(fcsBox); + + kbdBox = new QButtonGroup(i18n("Keyboard"), this); + QGridLayout *kLay = new QGridLayout(kbdBox, 3, 3, + KDialog::marginHint(), + KDialog::spacingHint()); + kLay->addRowSpacing(0,fontMetrics().lineSpacing()); + QLabel *altTabLabel = new QLabel( i18n("Walk through windows mode:"), kbdBox); + kLay->addWidget(altTabLabel, 1, 0); + kdeMode = new QRadioButton(i18n("KDE"), kbdBox); + kLay->addWidget(kdeMode, 1, 1); + cdeMode = new QRadioButton(i18n("CDE"), kbdBox); + kLay->addWidget(cdeMode, 1, 2); + + wtstr = i18n("Keep the Alt key pressed and hit the Tab key repeatedly to walk" + " through the windows on the current desktop (the Alt+Tab" + " combination can be reconfigured). The two different modes mean:
    " + "
  • KDE: a nice widget is shown, displaying the icons of all windows to" + " walk through and the title of the currently selected one;" + "
  • CDE: the focus is passed to a new window each time Tab is hit." + " No fancy widget.
"); + QWhatsThis::add( altTabLabel, wtstr ); + QWhatsThis::add( kdeMode, wtstr ); + QWhatsThis::add( cdeMode, wtstr ); + + traverseAll = new QCheckBox( i18n( "Traverse windows on all desktops" ), kbdBox ); + kLay->addMultiCellWidget( traverseAll, 2, 2, 0, 2 ); + + wtstr = i18n( "Leave this option disabled if you want to limit walking through" + " windows to the current desktop." ); + QWhatsThis::add( traverseAll, wtstr ); + + lay->addWidget(kbdBox); + + lay->addStretch(); + + // Any changes goes to slotChanged() + connect(focusCombo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + connect(fcsBox, SIGNAL(clicked(int)), this, SLOT(slotChanged())); + connect(autoRaise, SIGNAL(valueChanged(int)), this, SLOT(slotChanged())); + connect(kdeMode, SIGNAL(clicked()), this, SLOT(slotChanged())); + connect(cdeMode, SIGNAL(clicked()), this, SLOT(slotChanged())); + connect(traverseAll, SIGNAL(clicked()), this, SLOT(slotChanged())); + + load(); +} + +// many widgets connect to this slot +void KFocusConfig::slotChanged() +{ + emit changed(true); +} + +int KFocusConfig::getFocus() +{ + return focusCombo->currentItem(); +} + +void KFocusConfig::setFocus(int foc) +{ + focusCombo->setCurrentItem(foc); + + // this will disable/hide the auto raise delay widget if focus==click + setAutoRaiseEnabled(); +} + +void KFocusConfig::setAutoRaiseInterval(int tb) +{ + autoRaise->setValue(tb); +} + +int KFocusConfig::getAutoRaiseInterval() +{ + return autoRaise->value(); +} + +void KFocusConfig::setAutoRaise(bool on) +{ + autoRaiseOn->setChecked(on); +} + +void KFocusConfig::setClickRaise(bool on) +{ + clickRaiseOn->setChecked(on); +} + +void KFocusConfig::setAutoRaiseEnabled() +{ + // the auto raise related widgets are: autoRaise, alabel, s, sec + if ( focusCombo->currentItem() != CLICK_TO_FOCUS ) + { + clickRaiseOn->setEnabled(true); + clickRaiseOnTog(clickRaiseOn->isChecked()); + autoRaiseOn->setEnabled(true); + autoRaiseOnTog(autoRaiseOn->isChecked()); + } + else + { + autoRaiseOn->setEnabled(false); + autoRaiseOnTog(false); + clickRaiseOn->setEnabled(false); + clickRaiseOnTog(false); + } +} + + +//CT 23Oct1998 make AutoRaise toggling much clear +void KFocusConfig::autoRaiseOnTog(bool a) { + autoRaise->setEnabled(a); + alabel->setEnabled(a); + clickRaiseOn->setEnabled( !a ); + if ( a ) + clickRaiseOn->setChecked( TRUE ); + +} +//CT + +void KFocusConfig::clickRaiseOnTog(bool ) { +} + +void KFocusConfig::setAltTabMode(bool a) { + kdeMode->setChecked(a); + cdeMode->setChecked(!a); +} + +void KFocusConfig::setTraverseAll(bool a) { + traverseAll->setChecked(a); +} + +void KFocusConfig::load( void ) +{ + QString key; + + config->setGroup( "Windows" ); + + key = config->readEntry(KWIN_FOCUS); + if( key == "ClickToFocus") + setFocus(CLICK_TO_FOCUS); + else if( key == "FocusFollowsMouse") + setFocus(FOCUS_FOLLOWS_MOUSE); + else if(key == "FocusUnderMouse") + setFocus(FOCUS_UNDER_MOUSE); + else if(key == "FocusStrictlyUnderMouse") + setFocus(FOCUS_STRICTLY_UNDER_MOUSE); + + int k = config->readNumEntry(KWIN_AUTORAISE_INTERVAL,0); + setAutoRaiseInterval(k); + + key = config->readEntry(KWIN_AUTORAISE); + setAutoRaise(key == "on"); + key = config->readEntry(KWIN_CLICKRAISE); + setClickRaise(key != "off"); + setAutoRaiseEnabled(); // this will disable/hide the auto raise delay widget if focus==click + + key = config->readEntry(KWIN_ALTTABMODE, "KDE"); + setAltTabMode(key == "KDE"); + + config->setGroup( "TabBox" ); + setTraverseAll( config->readBoolEntry(KWIN_TRAVERSE_ALL, false )); + + config->setGroup("Desktops"); +} + +void KFocusConfig::save( void ) +{ + int v; + + config->setGroup( "Windows" ); + + v = getFocus(); + if (v == CLICK_TO_FOCUS) + config->writeEntry(KWIN_FOCUS,"ClickToFocus"); + else if (v == FOCUS_UNDER_MOUSE) + config->writeEntry(KWIN_FOCUS,"FocusUnderMouse"); + else if (v == FOCUS_STRICTLY_UNDER_MOUSE) + config->writeEntry(KWIN_FOCUS,"FocusStrictlyUnderMouse"); + else + config->writeEntry(KWIN_FOCUS,"FocusFollowsMouse"); + + v = getAutoRaiseInterval(); + if (v <0) v = 0; + config->writeEntry(KWIN_AUTORAISE_INTERVAL,v); + + if (autoRaiseOn->isChecked()) + config->writeEntry(KWIN_AUTORAISE, "on"); + else + config->writeEntry(KWIN_AUTORAISE, "off"); + + if (clickRaiseOn->isChecked()) + config->writeEntry(KWIN_CLICKRAISE, "on"); + else + config->writeEntry(KWIN_CLICKRAISE, "off"); + + if (kdeMode->isChecked()) + config->writeEntry(KWIN_ALTTABMODE, "KDE"); + else + config->writeEntry(KWIN_ALTTABMODE, "CDE"); + + config->setGroup( "TabBox" ); + config->writeEntry( KWIN_TRAVERSE_ALL , traverseAll->isChecked()); + + config->setGroup("Desktops"); +} + +void KFocusConfig::defaults() +{ + setFocus(CLICK_TO_FOCUS); + setAutoRaise(false); + setClickRaise(false); + setAltTabMode(true); + setTraverseAll( false ); +} + +KAdvancedConfig::~KAdvancedConfig () +{ +} + +KAdvancedConfig::KAdvancedConfig (KConfig *_config, QWidget *parent, const char *name) + : KCModule (parent, name), config(_config) +{ + QString wtstr; + QBoxLayout *lay = new QVBoxLayout (this, KDialog::marginHint(), + KDialog::spacingHint()); + + //iTLabel = new QLabel(i18n(" Allowed overlap:\n" + // "(% of desktop space)"), + // plcBox); + //iTLabel->setAlignment(AlignTop|AlignHCenter); + //pLay->addWidget(iTLabel,1,1); + + //interactiveTrigger = new QSpinBox(0, 500, 1, plcBox); + //pLay->addWidget(interactiveTrigger,1,2); + + //pLay->addRowSpacing(2,KDialog::spacingHint()); + + //lay->addWidget(plcBox); + + shBox = new QButtonGroup(i18n("Shading"), this); + QGridLayout *shLay = new QGridLayout(shBox, 3, 3, + KDialog::marginHint(), + KDialog::spacingHint()); + + shLay->addRowSpacing(0,fontMetrics().lineSpacing()); + animateShade = new QCheckBox(i18n("Animate"), shBox); + QWhatsThis::add(animateShade, i18n("Animate the action of reducing the window to its titlebar (shading)" + " as well as the expansion of a shaded window") ); + shLay->addWidget(animateShade, 1, 0); + + shadeHoverOn = new QCheckBox(i18n("Enable Hover"), shBox); + shLay->addWidget(shadeHoverOn, 2, 0); + + connect(shadeHoverOn, SIGNAL(toggled(bool)), this, SLOT(shadeHoverChanged(bool))); + + shlabel = new QLabel(i18n("Delay (ms)"), shBox); + shlabel->setAlignment(AlignVCenter | AlignHCenter); + shLay->addWidget(shlabel, 3, 0, AlignLeft); + + shadeHover = new KIntNumInput(500, shBox); + shadeHover->setRange(0, 3000, 100, true); + shadeHover->setSteps(100, 100); + shLay->addMultiCellWidget(shadeHover, 3, 3, 1, 2); + + QWhatsThis::add(shadeHoverOn, i18n("If Shade Hover is enabled, a shaded window will un-shade automatically " + "when the mouse pointer has been over the title bar for some time.")); + + wtstr = i18n("Sets the time in milliseconds before the window unshades " + "when the mouse pointer goes over the shaded window."); + QWhatsThis::add(shadeHover, wtstr); + QWhatsThis::add(shlabel, wtstr); + + lay->addWidget(shBox); + + // Any changes goes to slotChanged() + connect(animateShade, SIGNAL(toggled(bool)), this, SLOT(slotChanged())); + connect(shadeHoverOn, SIGNAL(toggled(bool)), this, SLOT(slotChanged())); + connect(shadeHover, SIGNAL(valueChanged(int)), this, SLOT(slotChanged())); + +#ifdef HAVE_XINERAMA + xineramaBox = new QVButtonGroup(i18n("Xinerama"), this); + + xineramaEnable = new QCheckBox(i18n("Enable Xinerama Support"), xineramaBox); + QWhatsThis::add(xineramaEnable, i18n("Enable support for Xinerama.")); + connect(xineramaEnable, SIGNAL(toggled(bool)), this, SLOT(setXinerama(bool))); + xineramaMovementEnable = new QCheckBox(i18n("Enable Window Resistance Support"), xineramaBox); + QWhatsThis::add(xineramaMovementEnable, i18n("Turn on resistance when moving a window from one physical screen to the other.")); + xineramaPlacementEnable = new QCheckBox(i18n("Enable Window Placement Support"), xineramaBox); + QWhatsThis::add(xineramaPlacementEnable, i18n("This option opens new windows on the physical screen on which the cursor is present.")); + xineramaMaximizeEnable = new QCheckBox(i18n("Enable Window Maximize Support"), xineramaBox); + QWhatsThis::add(xineramaMaximizeEnable, i18n("When this option is turned on, windows will only maximize up to the physical screen size.")); + + lay->addWidget(xineramaBox); +#endif + + electricBox = new QVButtonGroup(i18n("Active Desktop Borders"), this); + electricBox->setMargin(15); + + QWhatsThis::add( electricBox, i18n("If this option is enabled, moving the mouse to a screen border" + " will change your desktop. This is e.g. useful if you want to drag windows from one desktop" + " to the other.") ); + active_disable = new QRadioButton(i18n("&Disabled"), electricBox); + active_move = new QRadioButton(i18n("Only when &moving windows"), electricBox); + active_always = new QRadioButton(i18n("&Always enabled"), electricBox); + + delays = new KIntNumInput(10, electricBox); + delays->setRange(0, MAX_EDGE_RES, 50, true); + delays->setSuffix(i18n("ms.")); + delays->setLabel(i18n("Desktop &switch delay:")); + QWhatsThis::add( delays, i18n("Here you can set a delay for switching desktops using the active" + " borders feature. Desktops will be switched after the mouse has been pushed against a screen border" + " for the specified number of milliseconds.") ); + + connect( electricBox, SIGNAL(clicked(int)), this, SLOT(setEBorders())); + + // Any changes goes to slotChanged() + connect(electricBox, SIGNAL(clicked(int)), this, SLOT(slotChanged())); + connect(delays, SIGNAL(valueChanged(int)), this, SLOT(slotChanged())); + + lay->addWidget(electricBox); + + lay->addStretch(); + load(); + +#ifdef HAVE_XINERAMA + connect( xineramaEnable, SIGNAL(clicked()), this, SLOT(slotChanged())); + connect( xineramaMovementEnable, SIGNAL(clicked()), this, SLOT(slotChanged())); + connect( xineramaPlacementEnable, SIGNAL(clicked()), this, SLOT(slotChanged())); + connect( xineramaMaximizeEnable, SIGNAL(clicked()), this, SLOT(slotChanged())); +#endif + + +} + +// many widgets connect to this slot +void KAdvancedConfig::slotChanged() +{ + emit changed(true); +} + +void KAdvancedConfig::setShadeHover(bool on) { + shadeHoverOn->setChecked(on); + shadeHover->setEnabled(on); + shlabel->setEnabled(on); +} + +void KAdvancedConfig::setShadeHoverInterval(int k) { + shadeHover->setValue(k); +} + +int KAdvancedConfig::getShadeHoverInterval() { + + return shadeHover->value(); +} + +void KAdvancedConfig::shadeHoverChanged(bool a) { + shadeHover->setEnabled(a); + shlabel->setEnabled(a); +} + +void KAdvancedConfig::setXinerama(bool on) { +#ifdef HAVE_XINERAMA + if (KApplication::desktop()->isVirtualDesktop()) + xineramaEnable->setChecked(on); + else + xineramaEnable->setEnabled(false); + + xineramaMovementEnable->setEnabled(on); + xineramaPlacementEnable->setEnabled(on); + xineramaMaximizeEnable->setEnabled(on); +#endif +} + +void KAdvancedConfig::setAnimateShade(bool a) { + animateShade->setChecked(a); +} + +void KAdvancedConfig::load( void ) +{ + config->setGroup( "Windows" ); + + setAnimateShade(config->readBoolEntry(KWIN_ANIMSHADE, true)); + setShadeHover(config->readBoolEntry(KWIN_SHADEHOVER, false)); + setShadeHoverInterval(config->readNumEntry(KWIN_SHADEHOVER_INTERVAL, 250)); + +#ifdef HAVE_XINERAMA + setXinerama(config->readBoolEntry(KWIN_XINERAMA, false)); + xineramaMovementEnable->setChecked( config->readBoolEntry(KWIN_XINERAMA_MOVEMENT, false)); + xineramaPlacementEnable->setChecked(config->readBoolEntry(KWIN_XINERAMA_PLACEMENT, false)); + xineramaMaximizeEnable->setChecked(config->readBoolEntry(KWIN_XINERAMA_MAXIMIZE, false)); +#endif + + setElectricBorders(config->readNumEntry(KWM_ELECTRIC_BORDER, false)); + setElectricBorderDelay(config->readNumEntry(KWM_ELECTRIC_BORDER_DELAY, 150)); +} + +void KAdvancedConfig::save( void ) +{ + int v; + + config->setGroup( "Windows" ); + config->writeEntry(KWIN_ANIMSHADE, animateShade->isChecked()); + if (shadeHoverOn->isChecked()) + config->writeEntry(KWIN_SHADEHOVER, "on"); + else + config->writeEntry(KWIN_SHADEHOVER, "off"); + + v = getShadeHoverInterval(); + if (v<0) v = 0; + config->writeEntry(KWIN_SHADEHOVER_INTERVAL, v); + +#ifdef HAVE_XINERAMA + config->writeEntry(KWIN_XINERAMA, xineramaEnable->isChecked()); + config->writeEntry(KWIN_XINERAMA_MOVEMENT, xineramaMovementEnable->isChecked()); + config->writeEntry(KWIN_XINERAMA_PLACEMENT, xineramaPlacementEnable->isChecked()); + config->writeEntry(KWIN_XINERAMA_MAXIMIZE, xineramaMaximizeEnable->isChecked()); +#endif + + config->writeEntry(KWM_ELECTRIC_BORDER, getElectricBorders()); + config->writeEntry(KWM_ELECTRIC_BORDER_DELAY,getElectricBorderDelay()); +} + +void KAdvancedConfig::defaults() +{ + setAnimateShade(true); + setShadeHover(false); + setShadeHoverInterval(250); + setXinerama(false); + setElectricBorders(0); + setElectricBorderDelay(150); +} + +void KAdvancedConfig::setEBorders() +{ + delays->setEnabled(!active_disable->isChecked()); +} + +int KAdvancedConfig::getElectricBorders() +{ + if (active_move->isChecked()) + return 1; + if (active_always->isChecked()) + return 2; + return 0; +} + +int KAdvancedConfig::getElectricBorderDelay() +{ + return delays->value(); +} + +void KAdvancedConfig::setElectricBorders(int i){ + switch(i) + { + case 1: active_move->setChecked(true); break; + case 2: active_always->setChecked(true); break; + default: active_disable->setChecked(true); break; + } + setEBorders(); +} + +void KAdvancedConfig::setElectricBorderDelay(int delay) +{ + delays->setValue(delay); +} + + +KMovingConfig::~KMovingConfig () +{ +} + +KMovingConfig::KMovingConfig (KConfig *_config, QWidget *parent, const char *name) + : KCModule (parent, name), config(_config) +{ + QString wtstr; + QBoxLayout *lay = new QVBoxLayout (this, KDialog::marginHint(), + KDialog::spacingHint()); + + windowsBox = new QButtonGroup(i18n("Windows"), this); + + QBoxLayout *wLay = new QVBoxLayout (windowsBox,KDialog::marginHint(), + KDialog::spacingHint()); + wLay->addSpacing(fontMetrics().lineSpacing()); + + QBoxLayout *bLay = new QVBoxLayout; + wLay->addLayout(bLay); + + opaque = new QCheckBox(i18n("Display content in moving windows"), windowsBox); + bLay->addWidget(opaque); + QWhatsThis::add( opaque, i18n("Enable this option if you want a window's content to be fully shown" + " while moving it, instead of just showing a window 'skeleton'. The result may not be satisfying" + " on slow machines without graphic acceleration.") ); + + resizeOpaqueOn = new QCheckBox(i18n("Display content in resizing windows"), windowsBox); + bLay->addWidget(resizeOpaqueOn); + QWhatsThis::add( resizeOpaqueOn, i18n("Enable this option if you want a window's content to be shown" + " while resizing it, instead of just showing a window 'skeleton'. The result may not be satisfying" + " on slow machines.") ); + + QGridLayout *rLay = new QGridLayout(2,3); + bLay->addLayout(rLay); + rLay->setColStretch(0,0); + rLay->setColStretch(1,1); + + minimizeAnimOn = new QCheckBox(i18n("Animate Minimize and Restore"), + windowsBox); + QWhatsThis::add( minimizeAnimOn, i18n("Enable this option if you want an animation shown when" + " windows are minimized or restored." ) ); + rLay->addWidget(minimizeAnimOn,0,0); + + minimizeAnimSlider = new QSlider(0,10,10,0,QSlider::Horizontal, windowsBox); + minimizeAnimSlider->setSteps(10,1); + rLay->addMultiCellWidget(minimizeAnimSlider,0,0,1,2); + + minimizeAnimSlowLabel= new QLabel(i18n("Slow"),windowsBox); + minimizeAnimSlowLabel->setAlignment(AlignTop|AlignLeft); + rLay->addWidget(minimizeAnimSlowLabel,1,1); + + minimizeAnimFastLabel= new QLabel(i18n("Fast"),windowsBox); + minimizeAnimFastLabel->setAlignment(AlignTop|AlignRight); + rLay->addWidget(minimizeAnimFastLabel,1,2); + + wtstr = i18n("Here you can set the speed of the animation shown when windows are" + " minimized and restored. "); + QWhatsThis::add( minimizeAnimSlider, wtstr ); + QWhatsThis::add( minimizeAnimSlowLabel, wtstr ); + QWhatsThis::add( minimizeAnimFastLabel, wtstr ); + + moveResizeMaximized = new QCheckBox( i18n("Allow Moving and Resizing of maximized windows"), windowsBox); + bLay->addWidget(moveResizeMaximized); + QWhatsThis::add(moveResizeMaximized, i18n("When enabled, this feature activates the border of maximized windows" + " and allows you to move or resize them," + " just like for normal windows")); + + + rLay = new QGridLayout(1,3); + bLay->addLayout(rLay); + rLay->setColStretch(0,1); + rLay->setColStretch(1,3); + rLay->setColStretch(2,2); + + QLabel *plcLabel = new QLabel(i18n("Placement:"),windowsBox); + + placementCombo = new QComboBox(false, windowsBox); + placementCombo->insertItem(i18n("Smart"), SMART_PLACEMENT); + placementCombo->insertItem(i18n("Cascade"), CASCADE_PLACEMENT); + placementCombo->insertItem(i18n("Random"), RANDOM_PLACEMENT); + // CT: disabling is needed as long as functionality misses in kwin + //placementCombo->insertItem(i18n("Interactive"), INTERACTIVE_PLACEMENT); + //placementCombo->insertItem(i18n("Manual"), MANUAL_PLACEMENT); + placementCombo->setCurrentItem(SMART_PLACEMENT); + + // FIXME, when more policies have been added to KWin + wtstr = i18n("The placement policy determines where a new window" + " will appear on the desktop. For now, there are three different policies:" + "
  • Smart will try to achieve a minimum overlap of windows
  • " + "
  • Cascade will cascade the windows
  • " + "
  • Random will use a random position
") ; + + QWhatsThis::add( plcLabel, wtstr); + QWhatsThis::add( placementCombo, wtstr); + + plcLabel->setBuddy(placementCombo); + rLay->addWidget(plcLabel, 0, 0); + rLay->addWidget(placementCombo, 0, 1); + + bLay->addSpacing(10); + + lay->addWidget(windowsBox); + + //iTLabel = new QLabel(i18n(" Allowed overlap:\n" + // "(% of desktop space)"), + // plcBox); + //iTLabel->setAlignment(AlignTop|AlignHCenter); + //pLay->addWidget(iTLabel,1,1); + + //interactiveTrigger = new QSpinBox(0, 500, 1, plcBox); + //pLay->addWidget(interactiveTrigger,1,2); + + //pLay->addRowSpacing(2,KDialog::spacingHint()); + + //lay->addWidget(plcBox); + + + //CT 15mar98 - add EdgeResistance, BorderAttractor, WindowsAttractor config + MagicBox = new QVButtonGroup(i18n("Snap Zones"), this); + MagicBox->setMargin(15); + + BrdrSnap = new KIntNumInput(10, MagicBox); + BrdrSnap->setSpecialValueText( i18n("none") ); + BrdrSnap->setRange( 0, MAX_BRDR_SNAP); + BrdrSnap->setLabel(i18n("&Border snap zone:")); + BrdrSnap->setSuffix(i18n(" pixels")); + BrdrSnap->setSteps(1,1); + QWhatsThis::add( BrdrSnap, i18n("Here you can set the snap zone for screen borders, i.e." + " the 'strength' of the magnetic field which will make windows snap to the border when" + " moved near it.") ); + + WndwSnap = new KIntNumInput(10, MagicBox); + WndwSnap->setSpecialValueText( i18n("none") ); + WndwSnap->setRange( 0, MAX_WNDW_SNAP); + WndwSnap->setLabel(i18n("&Window snap zone:")); + WndwSnap->setSuffix( i18n(" pixels")); + BrdrSnap->setSteps(1,1); + QWhatsThis::add( WndwSnap, i18n("Here you can set the snap zone for windows, i.e." + " the 'strength' of the magnetic field which will make windows snap to each other when" + " they're moved near another window.") ); + + OverlapSnap=new QCheckBox(i18n("Snap windows only when &overlapping"),MagicBox); + QWhatsThis::add( OverlapSnap, i18n("Here you can set that windows will be only" + " snapped if you try to overlap them, i.e. they won't be snapped if the windows" + " comes only near another window or border.") ); + + lay->addWidget(MagicBox); + lay->addStretch(); + + load(); + + // Any changes goes to slotChanged() + connect( opaque, SIGNAL(clicked()), this, SLOT(slotChanged())); + connect( resizeOpaqueOn, SIGNAL(clicked()), this, SLOT(slotChanged())); + connect( minimizeAnimOn, SIGNAL(clicked() ), SLOT(slotChanged())); + connect( minimizeAnimSlider, SIGNAL(valueChanged(int)), this, SLOT(slotChanged())); + connect( moveResizeMaximized, SIGNAL(toggled(bool)), this, SLOT(slotChanged())); + connect( placementCombo, SIGNAL(activated(int)), this, SLOT(slotChanged())); + connect( BrdrSnap, SIGNAL(valueChanged(int)), this, SLOT(slotChanged())); + connect( WndwSnap, SIGNAL(valueChanged(int)), this, SLOT(slotChanged())); + connect( OverlapSnap, SIGNAL(clicked()), this, SLOT(slotChanged())); +} + +// many widgets connect to this slot +void KMovingConfig::slotChanged() +{ + emit changed(true); +} + +int KMovingConfig::getMove() +{ + if (opaque->isChecked()) + return OPAQUE; + else + return TRANSPARENT; +} + +void KMovingConfig::setMove(int trans) +{ + if (trans == TRANSPARENT) + opaque->setChecked(false); + else + opaque->setChecked(true); +} + +// placement policy --- CT 31jan98 --- +int KMovingConfig::getPlacement() +{ + return placementCombo->currentItem(); +} + +void KMovingConfig::setPlacement(int plac) +{ + placementCombo->setCurrentItem(plac); +} + +bool KMovingConfig::getMinimizeAnim() +{ + return minimizeAnimOn->isChecked(); +} + +int KMovingConfig::getMinimizeAnimSpeed() +{ + return minimizeAnimSlider->value(); +} + +void KMovingConfig::setMinimizeAnim(bool anim, int speed) +{ + minimizeAnimOn->setChecked( anim ); + minimizeAnimSlider->setValue(speed); + minimizeAnimSlider->setEnabled( anim ); + minimizeAnimSlowLabel->setEnabled( anim ); + minimizeAnimFastLabel->setEnabled( anim ); +} + +int KMovingConfig::getResizeOpaque() +{ + if (resizeOpaqueOn->isChecked()) + return RESIZE_OPAQUE; + else + return RESIZE_TRANSPARENT; +} + +void KMovingConfig::setResizeOpaque(int opaque) +{ + if (opaque == RESIZE_OPAQUE) + resizeOpaqueOn->setChecked(true); + else + resizeOpaqueOn->setChecked(false); +} + +void KMovingConfig::setMoveResizeMaximized(bool a) { + moveResizeMaximized->setChecked(a); +} + +void KMovingConfig::load( void ) +{ + QString key; + + config->setGroup( "Windows" ); + + key = config->readEntry(KWIN_MOVE, "Opaque"); + if( key == "Transparent") + setMove(TRANSPARENT); + else if( key == "Opaque") + setMove(OPAQUE); + + //CT 17Jun1998 - variable animation speed from 0 (none!!) to 10 (max) + int anim = 1; + if (config->hasKey(KWIN_MINIMIZE_ANIM_SPEED)) { + anim = config->readNumEntry(KWIN_MINIMIZE_ANIM_SPEED); + if( anim < 1 ) anim = 0; + if( anim > 10 ) anim = 10; + setMinimizeAnim( config->readBoolEntry(KWIN_MINIMIZE_ANIM, true ), anim ); + } + else{ + config->writeEntry(KWIN_MINIMIZE_ANIM, true ); + config->writeEntry(KWIN_MINIMIZE_ANIM_SPEED, 5); + setMinimizeAnim(true, 5); + } + + // DF: please keep the default consistent with kwin (options.cpp line 145) + key = config->readEntry(KWIN_RESIZE_OPAQUE, "Opaque"); + if( key == "Opaque") + setResizeOpaque(RESIZE_OPAQUE); + else if ( key == "Transparent") + setResizeOpaque(RESIZE_TRANSPARENT); + + // placement policy --- CT 19jan98 --- + key = config->readEntry(KWIN_PLACEMENT); + //CT 13mar98 interactive placement +// if( key.left(11) == "interactive") { +// setPlacement(INTERACTIVE_PLACEMENT); +// int comma_pos = key.find(','); +// if (comma_pos < 0) +// interactiveTrigger->setValue(0); +// else +// interactiveTrigger->setValue (key.right(key.length() +// - comma_pos).toUInt(0)); +// iTLabel->setEnabled(true); +// interactiveTrigger->show(); +// } +// else { +// interactiveTrigger->setValue(0); +// iTLabel->setEnabled(false); +// interactiveTrigger->hide(); + if( key == "Random") + setPlacement(RANDOM_PLACEMENT); + else if( key == "Cascade") + setPlacement(CASCADE_PLACEMENT); //CT 31jan98 + //CT 31mar98 manual placement + else if( key == "manual") + setPlacement(MANUAL_PLACEMENT); + + else + setPlacement(SMART_PLACEMENT); +// } + + setMoveResizeMaximized(config->readBoolEntry(KWIN_MOVE_RESIZE_MAXIMIZED, true)); + + int v; + + v = config->readNumEntry(KWM_BRDR_SNAP_ZONE, KWM_BRDR_SNAP_ZONE_DEFAULT); + if (v > MAX_BRDR_SNAP) setBorderSnapZone(MAX_BRDR_SNAP); + else if (v < 0) setBorderSnapZone (0); + else setBorderSnapZone(v); + + v = config->readNumEntry(KWM_WNDW_SNAP_ZONE, KWM_WNDW_SNAP_ZONE_DEFAULT); + if (v > MAX_WNDW_SNAP) setWindowSnapZone(MAX_WNDW_SNAP); + else if (v < 0) setWindowSnapZone (0); + else setWindowSnapZone(v); + + OverlapSnap->setChecked(config->readBoolEntry("SnapOnlyWhenOverlapping",false)); +} + +void KMovingConfig::save( void ) +{ + int v; + + config->setGroup( "Windows" ); + + v = getMove(); + if (v == TRANSPARENT) + config->writeEntry(KWIN_MOVE,"Transparent"); + else + config->writeEntry(KWIN_MOVE,"Opaque"); + + + // placement policy --- CT 31jan98 --- + v =getPlacement(); + if (v == RANDOM_PLACEMENT) + config->writeEntry(KWIN_PLACEMENT, "Random"); + else if (v == CASCADE_PLACEMENT) + config->writeEntry(KWIN_PLACEMENT, "Cascade"); +//CT 13mar98 manual and interactive placement +// else if (v == MANUAL_PLACEMENT) +// config->writeEntry(KWIN_PLACEMENT, "Manual"); +// else if (v == INTERACTIVE_PLACEMENT) { +// QString tmpstr = QString("Interactive,%1").arg(interactiveTrigger->value()); +// config->writeEntry(KWIN_PLACEMENT, tmpstr); +// } + else + config->writeEntry(KWIN_PLACEMENT, "Smart"); + + config->writeEntry(KWIN_MINIMIZE_ANIM, getMinimizeAnim()); + config->writeEntry(KWIN_MINIMIZE_ANIM_SPEED, getMinimizeAnimSpeed()); + + if ( getMinimizeAnim() > 0 ) + config->writeEntry("AnimateMinimize", true ); + + + v = getResizeOpaque(); + if (v == RESIZE_OPAQUE) + config->writeEntry(KWIN_RESIZE_OPAQUE, "Opaque"); + else + config->writeEntry(KWIN_RESIZE_OPAQUE, "Transparent"); + + config->writeEntry(KWIN_MOVE_RESIZE_MAXIMIZED, moveResizeMaximized->isChecked()); + + + config->writeEntry(KWM_BRDR_SNAP_ZONE,getBorderSnapZone()); + config->writeEntry(KWM_WNDW_SNAP_ZONE,getWindowSnapZone()); + config->writeEntry("SnapOnlyWhenOverlapping",OverlapSnap->isChecked()); +} + +void KMovingConfig::defaults() +{ + setMove(OPAQUE); + setResizeOpaque(RESIZE_TRANSPARENT); + setPlacement(SMART_PLACEMENT); + setMoveResizeMaximized(true); + + //copied from kcontrol/konq/kwindesktop, aleXXX + setWindowSnapZone(KWM_WNDW_SNAP_ZONE_DEFAULT); + setBorderSnapZone(KWM_BRDR_SNAP_ZONE_DEFAULT); + OverlapSnap->setChecked(false); +} + +int KMovingConfig::getBorderSnapZone() { + return BrdrSnap->value(); +} + +void KMovingConfig::setBorderSnapZone(int pxls) { + BrdrSnap->setValue(pxls); +} + +int KMovingConfig::getWindowSnapZone() { + return WndwSnap->value(); +} + +void KMovingConfig::setWindowSnapZone(int pxls) { + WndwSnap->setValue(pxls); +} + +#include "windows.moc" diff --git a/kcmkwin/kwinoptions/windows.h b/kcmkwin/kwinoptions/windows.h new file mode 100644 index 0000000000..c18179004b --- /dev/null +++ b/kcmkwin/kwinoptions/windows.h @@ -0,0 +1,218 @@ +/* + * windows.h + * + * Copyright (c) 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca + * Copyright (c) 2001 Waldo Bastian bastian@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. + * + * 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. + */ + +#ifndef __KWINDOWCONFIG_H__ +#define __KWINDOWCONFIG_H__ + +#include +#include + +class QRadioButton; +class QCheckBox; +class QPushButton; +class QComboBox; +class QLabel; +class QSlider; +class QButtonGroup; +class QSpinBox; +class QVButtonGroup; + +class KIntNumInput; + +#define TRANSPARENT 0 +#define OPAQUE 1 + +#define CLICK_TO_FOCUS 0 +#define FOCUS_FOLLOW_MOUSE 1 + +#define TITLEBAR_PLAIN 0 +#define TITLEBAR_SHADED 1 + +#define RESIZE_TRANSPARENT 0 +#define RESIZE_OPAQUE 1 + +#define SMART_PLACEMENT 0 +#define CASCADE_PLACEMENT 1 +#define RANDOM_PLACEMENT 2 +#define INTERACTIVE_PLACEMENT 3 +#define MANUAL_PLACEMENT 4 + +#define CLICK_TO_FOCUS 0 +#define FOCUS_FOLLOWS_MOUSE 1 +#define FOCUS_UNDER_MOUSE 2 +#define FOCUS_STRICTLY_UNDER_MOUSE 3 + +class QSpinBox; + +class KFocusConfig : public KCModule +{ + Q_OBJECT +public: + KFocusConfig( KConfig *_config, QWidget *parent=0, const char* name=0 ); + ~KFocusConfig(); + + void load(); + void save(); + void defaults(); + +private slots: + void setAutoRaiseEnabled(); + void autoRaiseOnTog(bool);//CT 23Oct1998 + void clickRaiseOnTog(bool); + void slotChanged(); + +private: + + int getFocus( void ); + int getAutoRaiseInterval( void ); + + void setFocus(int); + void setAutoRaiseInterval(int); + void setAutoRaise(bool); + void setClickRaise(bool); + void setAltTabMode(bool); + void setTraverseAll(bool); + + QButtonGroup *fcsBox; + QComboBox *focusCombo; + QCheckBox *autoRaiseOn; + QCheckBox *clickRaiseOn; + KIntNumInput *autoRaise; + QLabel *alabel; + //CT QLabel *sec; + + QButtonGroup *kbdBox; + QRadioButton *kdeMode; + QRadioButton *cdeMode; + QCheckBox *traverseAll; + + KConfig *config; +}; + +class KMovingConfig : public KCModule +{ + Q_OBJECT +public: + KMovingConfig( KConfig *config, QWidget *parent=0, const char* name=0 ); + ~KMovingConfig(); + + void load(); + void save(); + void defaults(); + +private slots: + void slotChanged(); + +private: + + int getMove( void ); + bool getMinimizeAnim( void ); + int getMinimizeAnimSpeed( void ); + int getResizeOpaque ( void ); + int getPlacement( void ); //CT + + void setMove(int); + void setMinimizeAnim(bool,int); + void setResizeOpaque(int); + void setPlacement(int); //CT + void setMoveResizeMaximized(bool); + + QButtonGroup *windowsBox; + QCheckBox *opaque; + + QCheckBox *resizeOpaqueOn; + QCheckBox* minimizeAnimOn; + QSlider *minimizeAnimSlider; + QLabel *minimizeAnimSlowLabel, *minimizeAnimFastLabel; + QCheckBox *moveResizeMaximized; + + QComboBox *placementCombo; + + KConfig *config; + + int getBorderSnapZone(); + void setBorderSnapZone( int ); + int getWindowSnapZone(); + void setWindowSnapZone( int ); + + QVButtonGroup *MagicBox; + KIntNumInput *BrdrSnap, *WndwSnap; + QCheckBox *OverlapSnap; + +}; + +class KAdvancedConfig : public KCModule +{ + Q_OBJECT +public: + KAdvancedConfig( KConfig *config, QWidget *parent=0, const char* name=0 ); + ~KAdvancedConfig(); + + void load(); + void save(); + void defaults(); + +private slots: + void slotChanged(); + void shadeHoverChanged(bool); + + //copied from kcontrol/konq/kwindesktop, aleXXX + void setEBorders(); + + void setXinerama(bool); + +private: + + int getShadeHoverInterval (void ); + void setAnimateShade(bool); + void setShadeHover(bool); + void setShadeHoverInterval(int); + + QCheckBox *animateShade; + QButtonGroup *shBox; + QCheckBox *shadeHoverOn; + KIntNumInput *shadeHover; + QLabel *shlabel; + +#ifdef HAVE_XINERAMA + QButtonGroup *xineramaBox; + QCheckBox *xineramaEnable; + QCheckBox *xineramaMovementEnable; + QCheckBox *xineramaPlacementEnable; + QCheckBox *xineramaMaximizeEnable; +#endif + + KConfig *config; + + int getElectricBorders( void ); + int getElectricBorderDelay(); + void setElectricBorders( int ); + void setElectricBorderDelay( int ); + + QVButtonGroup *electricBox; + QRadioButton *active_disable; + QRadioButton *active_move; + QRadioButton *active_always; + KIntNumInput *delays; +}; + +#endif +