2002-01-16 12:26:03 +00:00
/*
* 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
2005-12-21 06:45:09 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2002-12-02 10:08:09 +00:00
*
*
2002-01-16 12:26:03 +00:00
*/
# include <config.h>
2006-05-11 08:04:23 +00:00
# include <QDir>
# include <QLayout>
2006-05-13 16:33:18 +00:00
# include <QSlider>
2005-07-28 14:59:42 +00:00
# include <Q3ButtonGroup>
2006-05-11 08:04:23 +00:00
# include <QCheckBox>
2006-05-13 16:33:18 +00:00
# include <QRadioButton>
2006-05-11 08:04:23 +00:00
# include <QLabel>
# include <QComboBox>
2005-07-28 14:59:42 +00:00
//Added by qt3to4:
# include <QGridLayout>
# include <QHBoxLayout>
# include <QBoxLayout>
# include <QVBoxLayout>
2005-01-18 15:31:37 +00:00
# include <kmessagebox.h>
2002-01-16 12:26:03 +00:00
2006-07-06 18:01:52 +00:00
# include <qlabel.h>
2002-01-16 12:26:03 +00:00
# include <klocale.h>
2005-01-18 15:31:37 +00:00
# include <kcolorbutton.h>
2002-01-16 12:26:03 +00:00
# include <kconfig.h>
# include <knuminput.h>
2002-07-07 00:38:19 +00:00
# include <kapplication.h>
2002-01-16 12:26:03 +00:00
# include <kdialog.h>
2003-09-29 11:23:14 +00:00
# include <kglobal.h>
2005-01-15 17:07:48 +00:00
# include <kprocess.h>
2006-05-13 16:33:18 +00:00
# include <QTabWidget>
2006-07-02 18:31:00 +00:00
# include <QtDBus/QtDBus>
2002-01-16 12:26:03 +00:00
# include <X11/X.h>
# include <X11/Xlib.h>
# include <X11/Xutil.h>
# 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"
2004-06-29 00:55:16 +00:00
# define KWIN_GEOMETRY "GeometryTip"
2002-01-16 12:26:03 +00:00
# define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval"
# define KWIN_AUTORAISE "AutoRaise"
2004-05-28 08:53:44 +00:00
# define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval"
# define KWIN_DELAYFOCUS "DelayFocus"
2002-01-16 12:26:03 +00:00
# define KWIN_CLICKRAISE "ClickRaise"
# define KWIN_ANIMSHADE "AnimateShade"
# define KWIN_MOVE_RESIZE_MAXIMIZED "MoveResizeMaximizedWindows"
# define KWIN_ALTTABMODE "AltTabStyle"
# define KWIN_TRAVERSE_ALL "TraverseAll"
2002-04-11 01:06:33 +00:00
# define KWIN_SHOW_POPUP "ShowPopup"
2002-04-07 20:47:45 +00:00
# define KWIN_ROLL_OVER_DESKTOPS "RollOverDesktops"
2002-01-16 12:26:03 +00:00
# define KWIN_SHADEHOVER "ShadeHover"
# define KWIN_SHADEHOVER_INTERVAL "ShadeHoverInterval"
2003-09-29 11:23:14 +00:00
# define KWIN_FOCUS_STEALING "FocusStealingPreventionLevel"
2005-05-11 14:49:01 +00:00
# define KWIN_HIDE_UTILITY "HideUtilityWindowsForInactive"
2002-01-16 12:26:03 +00:00
// 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 ( )
{
2002-09-16 20:54:23 +00:00
if ( standAlone )
delete config ;
2002-01-16 12:26:03 +00:00
}
// removed the LCD display over the slider - this is not good GUI design :) RNolden 051701
2005-10-22 19:12:01 +00:00
KFocusConfig : : KFocusConfig ( bool _standAlone , KConfig * _config , KInstance * inst , QWidget * parent )
: KCModule ( inst , parent ) , config ( _config ) , standAlone ( _standAlone )
2002-01-16 12:26:03 +00:00
{
QString wtstr ;
2006-04-12 15:13:31 +00:00
QBoxLayout * lay = new QVBoxLayout ( this ) ;
lay - > setMargin ( 0 ) ;
lay - > setSpacing ( KDialog : : spacingHint ( ) ) ;
2002-01-16 12:26:03 +00:00
//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
2005-07-28 14:59:42 +00:00
fcsBox = new Q3ButtonGroup ( i18n ( " Focus " ) , this ) ;
2003-04-06 21:32:24 +00:00
fcsBox - > setColumnLayout ( 0 , Qt : : Horizontal ) ;
2002-01-16 12:26:03 +00:00
2006-04-12 15:13:31 +00:00
QBoxLayout * fLay = new QVBoxLayout ( ) ;
fLay - > setSpacing ( KDialog : : spacingHint ( ) ) ;
fcsBox - > layout ( ) - > addItem ( fLay ) ;
2002-01-16 12:26:03 +00:00
2006-04-12 15:13:31 +00:00
QBoxLayout * cLay = new QHBoxLayout ( ) ;
fLay - > addLayout ( cLay ) ;
2002-04-26 01:39:18 +00:00
QLabel * fLabel = new QLabel ( i18n ( " &Policy: " ) , fcsBox ) ;
cLay - > addWidget ( fLabel , 0 ) ;
2006-04-12 15:13:31 +00:00
focusCombo = new QComboBox ( fcsBox ) ;
focusCombo - > setEditable ( false ) ;
focusCombo - > addItem ( i18n ( " Click to Focus " ) , CLICK_TO_FOCUS ) ;
focusCombo - > addItem ( i18n ( " Focus Follows Mouse " ) , FOCUS_FOLLOWS_MOUSE ) ;
focusCombo - > addItem ( i18n ( " Focus Under Mouse " ) , FOCUS_UNDER_MOUSE ) ;
focusCombo - > addItem ( i18n ( " Focus Strictly Under Mouse " ) , FOCUS_STRICTLY_UNDER_MOUSE ) ;
2002-04-26 01:39:18 +00:00
cLay - > addWidget ( focusCombo , 1 , Qt : : AlignLeft ) ;
fLabel - > setBuddy ( focusCombo ) ;
2002-01-16 12:26:03 +00:00
// FIXME, when more policies have been added to KWin
2002-04-26 01:39:18 +00:00
wtstr = i18n ( " The focus policy is used to determine the active window, i.e. "
2002-01-16 12:26:03 +00:00
" the window you can work in. <ul> "
2004-03-04 14:21:53 +00:00
" <li><em>Click to focus:</em> A window becomes active when you click into it. "
" This is the behavior you might know from other operating systems.</li> "
2002-01-16 12:26:03 +00:00
" <li><em>Focus follows mouse:</em> Moving the mouse pointer actively on to a "
2004-03-04 14:21:53 +00:00
" normal window activates it. New windows will receive the focus, "
" without you having to point the mouse at them explicitly. "
" Very practical if you are using the mouse a lot.</li> "
2002-01-16 12:26:03 +00:00
" <li><em>Focus under mouse:</em> The window that happens to be under the "
2004-03-04 14:21:53 +00:00
" mouse pointer is active. If the mouse points nowhere, the last window "
" that was under the mouse has focus. "
" New windows will not automatically receive the focus.</li> "
" <li><em>Focus strictly under mouse:</em> Only the window under the mouse pointer is "
2002-01-23 02:32:52 +00:00
" active. If the mouse points nowhere, nothing has focus. "
2002-01-16 12:26:03 +00:00
" </ul> "
2004-04-16 15:31:56 +00:00
" Note that 'Focus under mouse' and 'Focus strictly under mouse' prevent certain "
" features such as the Alt+Tab walk through windows dialog in the KDE mode "
" from working properly. "
2002-04-26 01:39:18 +00:00
) ;
2005-07-28 14:59:42 +00:00
focusCombo - > setWhatsThis ( wtstr ) ;
fLabel - > setWhatsThis ( wtstr ) ;
2002-01-16 12:26:03 +00:00
2002-04-26 01:39:18 +00:00
connect ( focusCombo , SIGNAL ( activated ( int ) ) , this , SLOT ( setAutoRaiseEnabled ( ) ) ) ;
2002-01-16 12:26:03 +00:00
// autoraise delay
2002-04-26 01:39:18 +00:00
autoRaiseOn = new QCheckBox ( i18n ( " Auto &raise " ) , fcsBox ) ;
fLay - > addWidget ( autoRaiseOn ) ;
2002-01-16 12:26:03 +00:00
connect ( autoRaiseOn , SIGNAL ( toggled ( bool ) ) , this , SLOT ( autoRaiseOnTog ( bool ) ) ) ;
autoRaise = new KIntNumInput ( 500 , fcsBox ) ;
2002-04-26 01:39:18 +00:00
autoRaise - > setLabel ( i18n ( " Dela&y: " ) , Qt : : AlignVCenter | Qt : : AlignLeft ) ;
2002-01-16 12:26:03 +00:00
autoRaise - > setRange ( 0 , 3000 , 100 , true ) ;
autoRaise - > setSteps ( 100 , 100 ) ;
2002-04-10 18:58:57 +00:00
autoRaise - > setSuffix ( i18n ( " msec " ) ) ;
2002-04-26 01:39:18 +00:00
fLay - > addWidget ( autoRaise ) ;
2002-01-16 12:26:03 +00:00
2004-05-28 08:53:44 +00:00
connect ( focusCombo , SIGNAL ( activated ( int ) ) , this , SLOT ( setDelayFocusEnabled ( ) ) ) ;
2005-01-18 15:31:37 +00:00
2004-05-28 08:53:44 +00:00
delayFocusOn = new QCheckBox ( i18n ( " Delay focus " ) , fcsBox ) ;
fLay - > addWidget ( delayFocusOn ) ;
connect ( delayFocusOn , SIGNAL ( toggled ( bool ) ) , this , SLOT ( delayFocusOnTog ( bool ) ) ) ;
delayFocus = new KIntNumInput ( 500 , fcsBox ) ;
delayFocus - > setLabel ( i18n ( " Dela&y: " ) , Qt : : AlignVCenter | Qt : : AlignLeft ) ;
delayFocus - > setRange ( 0 , 3000 , 100 , true ) ;
delayFocus - > setSteps ( 100 , 100 ) ;
delayFocus - > setSuffix ( i18n ( " msec " ) ) ;
fLay - > addWidget ( delayFocus ) ;
2005-01-18 15:31:37 +00:00
2003-09-16 19:34:03 +00:00
clickRaiseOn = new QCheckBox ( i18n ( " C&lick raise active window " ) , fcsBox ) ;
2002-04-26 01:39:18 +00:00
connect ( clickRaiseOn , SIGNAL ( toggled ( bool ) ) , this , SLOT ( clickRaiseOnTog ( bool ) ) ) ;
fLay - > addWidget ( clickRaiseOn ) ;
2006-02-17 21:54:55 +00:00
// fLay->addColSpacing(0,qMax(autoRaiseOn->sizeHint().width(),
2002-04-26 01:39:18 +00:00
// clickRaiseOn->sizeHint().width()) + 15);
2002-01-16 12:26:03 +00:00
2005-07-28 14:59:42 +00:00
autoRaiseOn - > setWhatsThis ( i18n ( " When this option is enabled, a window in the background will automatically "
2002-01-16 12:26:03 +00:00
" 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. " ) ;
2005-07-28 14:59:42 +00:00
autoRaise - > setWhatsThis ( wtstr ) ;
2002-01-16 12:26:03 +00:00
2005-07-28 14:59:42 +00:00
clickRaiseOn - > setWhatsThis ( i18n ( " When this option is enabled, the active window will be brought to the "
2003-09-16 19:34:03 +00:00
" front when you click somewhere into the window contents. To change "
" it for inactive windows, you need to change the settings "
" in the Actions tab. " ) ) ;
2002-01-16 12:26:03 +00:00
2005-07-28 14:59:42 +00:00
delayFocusOn - > setWhatsThis ( i18n ( " When this option is enabled, there will be a delay after which the "
2004-05-28 08:53:44 +00:00
" window the mouse pointer is over will become active (receive focus). " ) ) ;
2005-07-28 14:59:42 +00:00
delayFocus - > setWhatsThis ( i18n ( " This is the delay after which the window the mouse pointer is over "
2004-05-28 08:53:44 +00:00
" will automatically receive focus. " ) ) ;
2002-01-16 12:26:03 +00:00
lay - > addWidget ( fcsBox ) ;
2005-07-28 14:59:42 +00:00
kbdBox = new Q3ButtonGroup ( i18n ( " Navigation " ) , this ) ;
2003-04-06 21:32:24 +00:00
kbdBox - > setColumnLayout ( 0 , Qt : : Horizontal ) ;
2006-04-12 15:13:31 +00:00
QVBoxLayout * kLay = new QVBoxLayout ( ) ;
kLay - > setSpacing ( KDialog : : spacingHint ( ) ) ;
kbdBox - > layout ( ) - > addItem ( kLay ) ;
2004-06-29 00:55:16 +00:00
altTabPopup = new QCheckBox ( i18n ( " Show window list while switching windows " ) , kbdBox ) ;
kLay - > addWidget ( altTabPopup ) ;
2002-01-16 12:26:03 +00:00
2002-09-04 02:37:06 +00:00
wtstr = i18n ( " Hold down the Alt key and press the Tab key repeatedly to walk "
2002-01-16 12:26:03 +00:00
" through the windows on the current desktop (the Alt+Tab "
2004-06-29 00:55:16 +00:00
" combination can be reconfigured). \n \n "
" If this checkbox is checked "
" a popup widget is shown, displaying the icons of all windows to "
" walk through and the title of the currently selected one. \n \n "
" Otherwise, the focus is passed to a new window each time Tab "
" is pressed, with no popup widget. In addition, the previously "
" activated window will be sent to the back in this mode. " ) ;
2005-07-28 14:59:42 +00:00
altTabPopup - > setWhatsThis ( wtstr ) ;
2006-04-11 12:59:59 +00:00
connect ( focusCombo , SIGNAL ( activated ( int ) ) , this , SLOT ( updateAltTabMode ( ) ) ) ;
2002-01-16 12:26:03 +00:00
2002-04-26 01:39:18 +00:00
traverseAll = new QCheckBox ( i18n ( " &Traverse windows on all desktops " ) , kbdBox ) ;
2004-06-29 00:55:16 +00:00
kLay - > addWidget ( traverseAll ) ;
2002-01-16 12:26:03 +00:00
wtstr = i18n ( " Leave this option disabled if you want to limit walking through "
" windows to the current desktop. " ) ;
2005-07-28 14:59:42 +00:00
traverseAll - > setWhatsThis ( wtstr ) ;
2002-01-16 12:26:03 +00:00
2002-04-26 01:39:18 +00:00
rollOverDesktops = new QCheckBox ( i18n ( " Desktop navi&gation wraps around " ) , kbdBox ) ;
2004-06-29 00:55:16 +00:00
kLay - > addWidget ( rollOverDesktops ) ;
2002-04-07 20:47:45 +00:00
2003-06-16 17:49:41 +00:00
wtstr = i18n ( " Enable this option if you want keyboard or active desktop border navigation beyond "
2003-10-22 12:34:04 +00:00
" the edge of a desktop to take you to the opposite edge of the new desktop. " ) ;
2005-07-28 14:59:42 +00:00
rollOverDesktops - > setWhatsThis ( wtstr ) ;
2002-04-07 20:47:45 +00:00
2002-04-26 01:39:18 +00:00
showPopupinfo = new QCheckBox ( i18n ( " Popup desktop name on desktop &switch " ) , kbdBox ) ;
2004-06-29 00:55:16 +00:00
kLay - > addWidget ( showPopupinfo ) ;
2002-04-10 22:53:40 +00:00
wtstr = i18n ( " Enable this option if you wish to see the current desktop "
2002-04-11 01:06:33 +00:00
" name popup whenever the current desktop is changed. " ) ;
2005-07-28 14:59:42 +00:00
showPopupinfo - > setWhatsThis ( wtstr ) ;
2002-04-10 22:53:40 +00:00
2002-01-16 12:26:03 +00:00
lay - > addWidget ( kbdBox ) ;
lay - > addStretch ( ) ;
// Any changes goes to slotChanged()
2002-07-07 00:38:19 +00:00
connect ( focusCombo , SIGNAL ( activated ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( fcsBox , SIGNAL ( clicked ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( autoRaise , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
2004-05-28 08:53:44 +00:00
connect ( delayFocus , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
2004-06-29 00:55:16 +00:00
connect ( altTabPopup , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
2002-07-07 00:38:19 +00:00
connect ( traverseAll , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
connect ( rollOverDesktops , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
connect ( showPopupinfo , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
2002-01-16 12:26:03 +00:00
load ( ) ;
}
int KFocusConfig : : getFocus ( )
{
2006-03-06 15:51:12 +00:00
return focusCombo - > currentIndex ( ) ;
2002-01-16 12:26:03 +00:00
}
void KFocusConfig : : setFocus ( int foc )
{
2006-03-06 16:25:27 +00:00
focusCombo - > setCurrentIndex ( foc ) ;
2002-01-16 12:26:03 +00:00
// this will disable/hide the auto raise delay widget if focus==click
setAutoRaiseEnabled ( ) ;
2006-04-11 12:59:59 +00:00
updateAltTabMode ( ) ;
}
void KFocusConfig : : updateAltTabMode ( )
{
// not KDE-style Alt+Tab with unreasonable focus policies
2006-04-11 18:59:35 +00:00
altTabPopup - > setEnabled ( focusCombo - > currentIndex ( ) = = 0 | | focusCombo - > currentIndex ( ) = = 1 ) ;
2002-01-16 12:26:03 +00:00
}
void KFocusConfig : : setAutoRaiseInterval ( int tb )
{
autoRaise - > setValue ( tb ) ;
}
2004-05-28 08:53:44 +00:00
void KFocusConfig : : setDelayFocusInterval ( int tb )
{
delayFocus - > setValue ( tb ) ;
}
2002-01-16 12:26:03 +00:00
int KFocusConfig : : getAutoRaiseInterval ( )
{
return autoRaise - > value ( ) ;
}
2004-05-28 08:53:44 +00:00
int KFocusConfig : : getDelayFocusInterval ( )
{
return delayFocus - > value ( ) ;
}
2002-01-16 12:26:03 +00:00
void KFocusConfig : : setAutoRaise ( bool on )
{
autoRaiseOn - > setChecked ( on ) ;
}
2004-05-28 08:53:44 +00:00
void KFocusConfig : : setDelayFocus ( bool on )
{
delayFocusOn - > setChecked ( on ) ;
}
2002-01-16 12:26:03 +00:00
void KFocusConfig : : setClickRaise ( bool on )
{
clickRaiseOn - > setChecked ( on ) ;
}
void KFocusConfig : : setAutoRaiseEnabled ( )
{
2002-04-26 01:39:18 +00:00
// the auto raise related widgets are: autoRaise
2006-03-06 15:51:12 +00:00
if ( focusCombo - > currentIndex ( ) ! = CLICK_TO_FOCUS )
2002-01-16 12:26:03 +00:00
{
autoRaiseOn - > setEnabled ( true ) ;
autoRaiseOnTog ( autoRaiseOn - > isChecked ( ) ) ;
}
else
{
autoRaiseOn - > setEnabled ( false ) ;
autoRaiseOnTog ( false ) ;
}
}
2004-05-28 08:53:44 +00:00
void KFocusConfig : : setDelayFocusEnabled ( )
{
// the delayed focus related widgets are: delayFocus
2006-03-06 15:51:12 +00:00
if ( focusCombo - > currentIndex ( ) ! = CLICK_TO_FOCUS )
2004-05-28 08:53:44 +00:00
{
delayFocusOn - > setEnabled ( true ) ;
delayFocusOnTog ( delayFocusOn - > isChecked ( ) ) ;
}
else
{
delayFocusOn - > setEnabled ( false ) ;
delayFocusOnTog ( false ) ;
}
}
2002-01-16 12:26:03 +00:00
void KFocusConfig : : autoRaiseOnTog ( bool a ) {
autoRaise - > setEnabled ( a ) ;
clickRaiseOn - > setEnabled ( ! a ) ;
}
2004-05-28 08:53:44 +00:00
void KFocusConfig : : delayFocusOnTog ( bool a ) {
delayFocus - > setEnabled ( a ) ;
}
2002-01-16 12:26:03 +00:00
void KFocusConfig : : clickRaiseOnTog ( bool ) {
}
void KFocusConfig : : setAltTabMode ( bool a ) {
2004-06-29 00:55:16 +00:00
altTabPopup - > setChecked ( a ) ;
2002-01-16 12:26:03 +00:00
}
void KFocusConfig : : setTraverseAll ( bool a ) {
traverseAll - > setChecked ( a ) ;
}
2002-04-07 20:47:45 +00:00
void KFocusConfig : : setRollOverDesktops ( bool a ) {
rollOverDesktops - > setChecked ( a ) ;
}
2002-04-10 22:53:40 +00:00
void KFocusConfig : : setShowPopupinfo ( bool a ) {
showPopupinfo - > setChecked ( a ) ;
}
2002-01-16 12:26:03 +00:00
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 ) ;
2006-01-21 19:36:31 +00:00
int k = config - > readEntry ( KWIN_AUTORAISE_INTERVAL , 750 ) ;
2002-01-16 12:26:03 +00:00
setAutoRaiseInterval ( k ) ;
2006-01-21 19:36:31 +00:00
k = config - > readEntry ( KWIN_DELAYFOCUS_INTERVAL , 750 ) ;
2004-05-28 08:53:44 +00:00
setDelayFocusInterval ( k ) ;
2005-01-18 15:31:37 +00:00
2002-01-16 12:26:03 +00:00
key = config - > readEntry ( KWIN_AUTORAISE ) ;
setAutoRaise ( key = = " on " ) ;
2004-05-28 08:53:44 +00:00
key = config - > readEntry ( KWIN_DELAYFOCUS ) ;
setDelayFocus ( key = = " on " ) ;
2002-01-16 12:26:03 +00:00
key = config - > readEntry ( KWIN_CLICKRAISE ) ;
setClickRaise ( key ! = " off " ) ;
setAutoRaiseEnabled ( ) ; // this will disable/hide the auto raise delay widget if focus==click
2004-05-28 08:53:44 +00:00
setDelayFocusEnabled ( ) ;
2002-01-16 12:26:03 +00:00
key = config - > readEntry ( KWIN_ALTTABMODE , " KDE " ) ;
setAltTabMode ( key = = " KDE " ) ;
2006-01-03 14:01:15 +00:00
setRollOverDesktops ( config - > readEntry ( KWIN_ROLL_OVER_DESKTOPS , QVariant ( true ) ) . toBool ( ) ) ;
2002-04-07 20:47:45 +00:00
2002-04-10 22:53:40 +00:00
config - > setGroup ( " PopupInfo " ) ;
2006-01-03 14:01:15 +00:00
setShowPopupinfo ( config - > readEntry ( KWIN_SHOW_POPUP , QVariant ( false ) ) . toBool ( ) ) ;
2002-04-10 22:53:40 +00:00
2002-01-16 12:26:03 +00:00
config - > setGroup ( " TabBox " ) ;
2006-01-03 14:01:15 +00:00
setTraverseAll ( config - > readEntry ( KWIN_TRAVERSE_ALL , QVariant ( false ) ) . toBool ( ) ) ;
2002-01-16 12:26:03 +00:00
config - > setGroup ( " Desktops " ) ;
2003-11-08 23:43:53 +00:00
emit KCModule : : changed ( false ) ;
2002-01-16 12:26:03 +00:00
}
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 ) ;
2004-05-28 08:53:44 +00:00
v = getDelayFocusInterval ( ) ;
if ( v < 0 ) v = 0 ;
config - > writeEntry ( KWIN_DELAYFOCUS_INTERVAL , v ) ;
2005-01-18 15:31:37 +00:00
2002-01-16 12:26:03 +00:00
if ( autoRaiseOn - > isChecked ( ) )
config - > writeEntry ( KWIN_AUTORAISE , " on " ) ;
else
config - > writeEntry ( KWIN_AUTORAISE , " off " ) ;
2004-05-28 08:53:44 +00:00
if ( delayFocusOn - > isChecked ( ) )
config - > writeEntry ( KWIN_DELAYFOCUS , " on " ) ;
else
config - > writeEntry ( KWIN_DELAYFOCUS , " off " ) ;
2002-01-16 12:26:03 +00:00
if ( clickRaiseOn - > isChecked ( ) )
config - > writeEntry ( KWIN_CLICKRAISE , " on " ) ;
else
config - > writeEntry ( KWIN_CLICKRAISE , " off " ) ;
2004-06-29 00:55:16 +00:00
if ( altTabPopup - > isChecked ( ) )
2002-01-16 12:26:03 +00:00
config - > writeEntry ( KWIN_ALTTABMODE , " KDE " ) ;
else
config - > writeEntry ( KWIN_ALTTABMODE , " CDE " ) ;
2002-04-07 20:47:45 +00:00
config - > writeEntry ( KWIN_ROLL_OVER_DESKTOPS , rollOverDesktops - > isChecked ( ) ) ;
2002-04-10 22:53:40 +00:00
config - > setGroup ( " PopupInfo " ) ;
2002-04-11 01:06:33 +00:00
config - > writeEntry ( KWIN_SHOW_POPUP , showPopupinfo - > isChecked ( ) ) ;
2002-04-10 22:53:40 +00:00
2002-01-16 12:26:03 +00:00
config - > setGroup ( " TabBox " ) ;
config - > writeEntry ( KWIN_TRAVERSE_ALL , traverseAll - > isChecked ( ) ) ;
config - > setGroup ( " Desktops " ) ;
2002-07-07 00:38:19 +00:00
2002-09-16 20:54:23 +00:00
if ( standAlone )
{
config - > sync ( ) ;
2006-07-02 18:31:00 +00:00
QDBusInterface kwin ( " org.kde.kwin " , " /KWin " , " org.kde.KWin " ) ;
kwin . call ( " reconfigure " ) ;
2002-09-16 20:54:23 +00:00
}
2003-11-08 23:43:53 +00:00
emit KCModule : : changed ( false ) ;
2002-01-16 12:26:03 +00:00
}
void KFocusConfig : : defaults ( )
{
2003-10-13 20:27:31 +00:00
setAutoRaiseInterval ( 0 ) ;
2004-05-28 08:53:44 +00:00
setDelayFocusInterval ( 0 ) ;
2002-01-16 12:26:03 +00:00
setFocus ( CLICK_TO_FOCUS ) ;
setAutoRaise ( false ) ;
2004-05-28 08:53:44 +00:00
setDelayFocus ( false ) ;
2003-09-16 19:34:03 +00:00
setClickRaise ( true ) ;
2002-01-16 12:26:03 +00:00
setAltTabMode ( true ) ;
setTraverseAll ( false ) ;
2002-04-07 20:47:45 +00:00
setRollOverDesktops ( true ) ;
2002-04-10 22:53:40 +00:00
setShowPopupinfo ( false ) ;
2003-11-08 23:43:53 +00:00
emit KCModule : : changed ( true ) ;
2002-01-16 12:26:03 +00:00
}
KAdvancedConfig : : ~ KAdvancedConfig ( )
{
2002-09-16 20:54:23 +00:00
if ( standAlone )
delete config ;
2002-01-16 12:26:03 +00:00
}
2005-10-22 19:12:01 +00:00
KAdvancedConfig : : KAdvancedConfig ( bool _standAlone , KConfig * _config , KInstance * inst , QWidget * parent )
: KCModule ( inst , parent ) , config ( _config ) , standAlone ( _standAlone )
2002-01-16 12:26:03 +00:00
{
QString wtstr ;
2006-04-12 15:13:31 +00:00
QBoxLayout * lay = new QVBoxLayout ( this ) ;
lay - > setMargin ( 0 ) ;
lay - > setSpacing ( KDialog : : spacingHint ( ) ) ;
2002-01-16 12:26:03 +00:00
//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);
2005-07-28 14:59:42 +00:00
shBox = new Q3VButtonGroup ( i18n ( " Shading " ) , this ) ;
2002-01-16 12:26:03 +00:00
2002-04-26 01:39:18 +00:00
animateShade = new QCheckBox ( i18n ( " Anima&te " ) , shBox ) ;
2005-07-28 14:59:42 +00:00
animateShade - > setWhatsThis ( i18n ( " Animate the action of reducing the window to its titlebar (shading) "
2002-01-16 12:26:03 +00:00
" as well as the expansion of a shaded window " ) ) ;
2002-04-10 18:58:57 +00:00
shadeHoverOn = new QCheckBox ( i18n ( " &Enable hover " ) , shBox ) ;
2002-01-16 12:26:03 +00:00
connect ( shadeHoverOn , SIGNAL ( toggled ( bool ) ) , this , SLOT ( shadeHoverChanged ( bool ) ) ) ;
shadeHover = new KIntNumInput ( 500 , shBox ) ;
2002-04-26 01:39:18 +00:00
shadeHover - > setLabel ( i18n ( " Dela&y: " ) , Qt : : AlignVCenter | Qt : : AlignLeft ) ;
2002-01-16 12:26:03 +00:00
shadeHover - > setRange ( 0 , 3000 , 100 , true ) ;
shadeHover - > setSteps ( 100 , 100 ) ;
2002-04-10 18:58:57 +00:00
shadeHover - > setSuffix ( i18n ( " msec " ) ) ;
2002-01-16 12:26:03 +00:00
2005-07-28 14:59:42 +00:00
shadeHoverOn - > setWhatsThis ( i18n ( " If Shade Hover is enabled, a shaded window will un-shade automatically "
2002-01-16 12:26:03 +00:00
" 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. " ) ;
2005-07-28 14:59:42 +00:00
shadeHover - > setWhatsThis ( wtstr ) ;
2002-01-16 12:26:03 +00:00
lay - > addWidget ( shBox ) ;
// Any changes goes to slotChanged()
2002-07-07 00:38:19 +00:00
connect ( animateShade , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
connect ( shadeHoverOn , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
connect ( shadeHover , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
2002-01-16 12:26:03 +00:00
2005-07-28 14:59:42 +00:00
electricBox = new Q3VButtonGroup ( i18n ( " Active Desktop Borders " ) , this ) ;
electricBox - > layout ( ) - > setMargin ( 15 ) ;
2002-01-16 12:26:03 +00:00
2005-07-28 14:59:42 +00:00
electricBox - > setWhatsThis ( i18n ( " If this option is enabled, moving the mouse to a screen border "
2002-01-16 12:26:03 +00:00
" will change your desktop. This is e.g. useful if you want to drag windows from one desktop "
" to the other. " ) ) ;
2002-04-10 18:58:57 +00:00
active_disable = new QRadioButton ( i18n ( " D&isabled " ) , electricBox ) ;
2002-04-26 01:39:18 +00:00
active_move = new QRadioButton ( i18n ( " Only &when moving windows " ) , electricBox ) ;
2002-04-10 18:58:57 +00:00
active_always = new QRadioButton ( i18n ( " A&lways enabled " ) , electricBox ) ;
2002-01-16 12:26:03 +00:00
delays = new KIntNumInput ( 10 , electricBox ) ;
delays - > setRange ( 0 , MAX_EDGE_RES , 50 , true ) ;
2002-04-10 18:58:57 +00:00
delays - > setSuffix ( i18n ( " msec " ) ) ;
2002-01-16 12:26:03 +00:00
delays - > setLabel ( i18n ( " Desktop &switch delay: " ) ) ;
2005-07-28 14:59:42 +00:00
delays - > setWhatsThis ( i18n ( " Here you can set a delay for switching desktops using the active "
2002-01-16 12:26:03 +00:00
" 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()
2002-07-07 00:38:19 +00:00
connect ( electricBox , SIGNAL ( clicked ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( delays , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
2002-01-16 12:26:03 +00:00
lay - > addWidget ( electricBox ) ;
2006-04-12 15:13:31 +00:00
QHBoxLayout * focusStealingLayout = new QHBoxLayout ( ) ;
focusStealingLayout - > setSpacing ( KDialog : : spacingHint ( ) ) ;
lay - > addLayout ( focusStealingLayout ) ;
2003-10-05 15:12:49 +00:00
QLabel * focusStealingLabel = new QLabel ( i18n ( " Focus stealing prevention level: " ) , this ) ;
2003-09-29 11:23:14 +00:00
focusStealing = new QComboBox ( this ) ;
2006-04-12 15:13:31 +00:00
focusStealing - > addItem ( i18nc ( " Focus Stealing Prevention Level " , " None " ) ) ;
focusStealing - > addItem ( i18nc ( " Focus Stealing Prevention Level " , " Low " ) ) ;
focusStealing - > addItem ( i18nc ( " Focus Stealing Prevention Level " , " Normal " ) ) ;
focusStealing - > addItem ( i18nc ( " Focus Stealing Prevention Level " , " High " ) ) ;
focusStealing - > addItem ( i18nc ( " Focus Stealing Prevention Level " , " Extreme " ) ) ;
2003-09-29 11:23:14 +00:00
focusStealingLabel - > setBuddy ( focusStealing ) ;
focusStealingLayout - > addWidget ( focusStealingLabel ) ;
2005-07-28 14:59:42 +00:00
focusStealingLayout - > addWidget ( focusStealing , Qt : : AlignLeft ) ;
2005-05-30 13:31:33 +00:00
wtstr = i18n ( " <p>This option specifies how much KWin will try to prevent unwanted focus stealing "
2004-05-19 13:27:23 +00:00
" caused by unexpected activation of new windows. (Note: This feature does not "
2004-02-02 17:02:11 +00:00
" work with the Focus Under Mouse or Focus Strictly Under Mouse focus policies.) "
" <ul> "
2004-06-11 15:12:07 +00:00
" <li><em>None:</em> Prevention is turned off "
2003-10-22 12:34:04 +00:00
" and new windows always become activated.</li> "
2004-05-19 13:27:23 +00:00
" <li><em>Low:</em> Prevention is enabled; when some window does not have support "
2003-09-29 11:23:14 +00:00
" for the underlying mechanism and KWin cannot reliably decide whether to "
2003-10-23 17:47:16 +00:00
" activate the window or not, it will be activated. This setting may have both "
2003-10-22 12:34:04 +00:00
" worse and better results than normal level, depending on the applications.</li> "
2004-06-11 15:12:07 +00:00
" <li><em>Normal:</em> Prevention is enabled.</li> "
2003-09-29 11:23:14 +00:00
" <li><em>High:</em> New windows get activated only if no window is currently active "
" or if they belong to the currently active application. This setting is probably "
2003-10-22 12:34:04 +00:00
" not really usable when not using mouse focus policy.</li> "
2003-09-29 11:23:14 +00:00
" <li><em>Extreme:</em> All windows must be explicitly activated by the user.</li> "
2005-05-30 13:31:33 +00:00
" </ul></p> "
" <p>Windows that are prevented from stealing focus are marked as demanding attention, "
" which by default means their taskbar entry will be highlighted. This can be changed "
" in the Notifications control module.</p> " ) ;
2005-07-28 14:59:42 +00:00
focusStealing - > setWhatsThis ( wtstr ) ;
focusStealingLabel - > setWhatsThis ( wtstr ) ;
2003-09-29 11:23:14 +00:00
connect ( focusStealing , SIGNAL ( activated ( int ) ) , SLOT ( changed ( ) ) ) ;
2005-05-11 14:49:01 +00:00
hideUtilityWindowsForInactive = new QCheckBox ( i18n ( " Hide utility windows for inactive applications " ) , this ) ;
2005-07-28 14:59:42 +00:00
hideUtilityWindowsForInactive - > setWhatsThis (
2005-05-11 14:49:01 +00:00
i18n ( " When turned on, utility windows (tool windows, torn-off menus,...) of inactive applications will be "
" hidden and will be shown only when the application becomes active. Note that applications "
" have to mark the windows with the proper window type for this feature to work. " ) ) ;
connect ( hideUtilityWindowsForInactive , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
lay - > addWidget ( hideUtilityWindowsForInactive ) ;
2003-10-13 20:27:31 +00:00
2002-01-16 12:26:03 +00:00
lay - > addStretch ( ) ;
load ( ) ;
}
void KAdvancedConfig : : setShadeHover ( bool on ) {
shadeHoverOn - > setChecked ( on ) ;
shadeHover - > setEnabled ( on ) ;
}
void KAdvancedConfig : : setShadeHoverInterval ( int k ) {
shadeHover - > setValue ( k ) ;
}
int KAdvancedConfig : : getShadeHoverInterval ( ) {
return shadeHover - > value ( ) ;
}
void KAdvancedConfig : : shadeHoverChanged ( bool a ) {
shadeHover - > setEnabled ( a ) ;
}
void KAdvancedConfig : : setAnimateShade ( bool a ) {
animateShade - > setChecked ( a ) ;
}
2003-09-29 11:23:14 +00:00
void KAdvancedConfig : : setFocusStealing ( int l ) {
2005-10-22 11:35:06 +00:00
l = qMax ( 0 , qMin ( 4 , l ) ) ;
2006-03-06 16:25:27 +00:00
focusStealing - > setCurrentIndex ( l ) ;
2003-09-29 11:23:14 +00:00
}
2005-05-11 14:49:01 +00:00
void KAdvancedConfig : : setHideUtilityWindowsForInactive ( bool s ) {
hideUtilityWindowsForInactive - > setChecked ( s ) ;
}
2002-01-16 12:26:03 +00:00
void KAdvancedConfig : : load ( void )
{
config - > setGroup ( " Windows " ) ;
2006-01-03 14:01:15 +00:00
setAnimateShade ( config - > readEntry ( KWIN_ANIMSHADE , QVariant ( true ) ) . toBool ( ) ) ;
setShadeHover ( config - > readEntry ( KWIN_SHADEHOVER , QVariant ( false ) ) . toBool ( ) ) ;
2006-01-21 19:36:31 +00:00
setShadeHoverInterval ( config - > readEntry ( KWIN_SHADEHOVER_INTERVAL , 250 ) ) ;
2002-01-16 12:26:03 +00:00
2006-01-21 19:36:31 +00:00
setElectricBorders ( config - > readEntry ( KWM_ELECTRIC_BORDER , false ) ) ;
setElectricBorderDelay ( config - > readEntry ( KWM_ELECTRIC_BORDER_DELAY , 150 ) ) ;
2003-09-29 11:23:14 +00:00
2006-01-21 19:36:31 +00:00
// setFocusStealing( config->readEntry(KWIN_FOCUS_STEALING, 2 ));
2003-12-09 14:10:13 +00:00
// TODO default to low for now
2006-01-21 19:36:31 +00:00
setFocusStealing ( config - > readEntry ( KWIN_FOCUS_STEALING , 1 ) ) ;
2006-01-03 14:01:15 +00:00
setHideUtilityWindowsForInactive ( config - > readEntry ( KWIN_HIDE_UTILITY , QVariant ( true ) ) . toBool ( ) ) ;
2003-09-29 11:23:14 +00:00
2003-11-08 23:43:53 +00:00
emit KCModule : : changed ( false ) ;
2002-01-16 12:26:03 +00:00
}
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 ) ;
config - > writeEntry ( KWM_ELECTRIC_BORDER , getElectricBorders ( ) ) ;
config - > writeEntry ( KWM_ELECTRIC_BORDER_DELAY , getElectricBorderDelay ( ) ) ;
2003-10-13 20:27:31 +00:00
2006-03-06 15:51:12 +00:00
config - > writeEntry ( KWIN_FOCUS_STEALING , focusStealing - > currentIndex ( ) ) ;
2005-05-11 14:49:01 +00:00
config - > writeEntry ( KWIN_HIDE_UTILITY , hideUtilityWindowsForInactive - > isChecked ( ) ) ;
2003-01-01 11:38:06 +00:00
2002-09-16 20:54:23 +00:00
if ( standAlone )
{
config - > sync ( ) ;
2006-07-02 18:31:00 +00:00
QDBusInterface kwin ( " org.kde.kwin " , " /KWin " , " org.kde.KWin " ) ;
kwin . call ( " reconfigure " ) ;
2002-09-16 20:54:23 +00:00
}
2003-11-08 23:43:53 +00:00
emit KCModule : : changed ( false ) ;
2002-01-16 12:26:03 +00:00
}
void KAdvancedConfig : : defaults ( )
{
setAnimateShade ( true ) ;
setShadeHover ( false ) ;
setShadeHoverInterval ( 250 ) ;
setElectricBorders ( 0 ) ;
setElectricBorderDelay ( 150 ) ;
2003-12-09 14:10:13 +00:00
// setFocusStealing(2);
// TODO default to low for now
setFocusStealing ( 1 ) ;
2005-05-11 14:49:01 +00:00
setHideUtilityWindowsForInactive ( true ) ;
2003-11-08 23:43:53 +00:00
emit KCModule : : changed ( true ) ;
2002-01-16 12:26:03 +00:00
}
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 ( )
{
2002-09-16 20:54:23 +00:00
if ( standAlone )
delete config ;
2002-01-16 12:26:03 +00:00
}
2005-10-22 19:12:01 +00:00
KMovingConfig : : KMovingConfig ( bool _standAlone , KConfig * _config , KInstance * inst , QWidget * parent )
: KCModule ( inst , parent ) , config ( _config ) , standAlone ( _standAlone )
2002-01-16 12:26:03 +00:00
{
QString wtstr ;
2006-04-12 15:13:31 +00:00
QBoxLayout * lay = new QVBoxLayout ( this ) ;
lay - > setMargin ( 0 ) ;
lay - > setSpacing ( KDialog : : spacingHint ( ) ) ;
2002-01-16 12:26:03 +00:00
2005-07-28 14:59:42 +00:00
windowsBox = new Q3ButtonGroup ( i18n ( " Windows " ) , this ) ;
2003-04-06 21:32:24 +00:00
windowsBox - > setColumnLayout ( 0 , Qt : : Horizontal ) ;
2002-01-16 12:26:03 +00:00
2006-04-12 15:13:31 +00:00
QBoxLayout * wLay = new QVBoxLayout ( ) ;
wLay - > setSpacing ( KDialog : : spacingHint ( ) ) ;
windowsBox - > layout ( ) - > addItem ( wLay ) ;
2002-01-16 12:26:03 +00:00
QBoxLayout * bLay = new QVBoxLayout ;
wLay - > addLayout ( bLay ) ;
2002-04-26 01:39:18 +00:00
opaque = new QCheckBox ( i18n ( " Di&splay content in moving windows " ) , windowsBox ) ;
2002-01-16 12:26:03 +00:00
bLay - > addWidget ( opaque ) ;
2005-07-28 14:59:42 +00:00
opaque - > setWhatsThis ( i18n ( " Enable this option if you want a window's content to be fully shown "
2002-01-16 12:26:03 +00:00
" while moving it, instead of just showing a window 'skeleton'. The result may not be satisfying "
" on slow machines without graphic acceleration. " ) ) ;
2002-04-26 01:39:18 +00:00
resizeOpaqueOn = new QCheckBox ( i18n ( " Display content in &resizing windows " ) , windowsBox ) ;
2002-01-16 12:26:03 +00:00
bLay - > addWidget ( resizeOpaqueOn ) ;
2005-07-28 14:59:42 +00:00
resizeOpaqueOn - > setWhatsThis ( i18n ( " Enable this option if you want a window's content to be shown "
2002-01-16 12:26:03 +00:00
" while resizing it, instead of just showing a window 'skeleton'. The result may not be satisfying "
" on slow machines. " ) ) ;
2003-01-14 06:23:03 +00:00
geometryTipOn = new QCheckBox ( i18n ( " Display window &geometry when moving or resizing " ) , windowsBox ) ;
2003-01-10 10:54:57 +00:00
bLay - > addWidget ( geometryTipOn ) ;
2005-07-28 14:59:42 +00:00
geometryTipOn - > setWhatsThis ( i18n ( " Enable this option if you want a window's geometry to be displayed "
2004-06-29 00:55:16 +00:00
" while it is being moved or resized. The window position relative "
" to the top-left corner of the screen is displayed together with "
" its size. " ) ) ;
2003-01-10 10:54:57 +00:00
2006-04-12 15:13:31 +00:00
QGridLayout * rLay = new QGridLayout ( ) ;
2002-01-16 12:26:03 +00:00
bLay - > addLayout ( rLay ) ;
2006-04-12 15:13:31 +00:00
rLay - > setColumnStretch ( 0 , 0 ) ;
rLay - > setColumnStretch ( 1 , 1 ) ;
2002-01-16 12:26:03 +00:00
2002-04-26 01:39:18 +00:00
minimizeAnimOn = new QCheckBox ( i18n ( " Animate minimi&ze and restore " ) ,
2002-01-16 12:26:03 +00:00
windowsBox ) ;
2005-07-28 14:59:42 +00:00
minimizeAnimOn - > setWhatsThis ( i18n ( " Enable this option if you want an animation shown when "
2002-01-16 12:26:03 +00:00
" windows are minimized or restored. " ) ) ;
rLay - > addWidget ( minimizeAnimOn , 0 , 0 ) ;
2006-04-12 15:13:31 +00:00
minimizeAnimSlider = new QSlider ( windowsBox ) ;
minimizeAnimSlider - > setRange ( 0 , 10 ) ;
minimizeAnimSlider - > setSingleStep ( 1 ) ;
minimizeAnimSlider - > setPageStep ( 1 ) ;
minimizeAnimSlider - > setValue ( 0 ) ;
minimizeAnimSlider - > setOrientation ( Qt : : Horizontal ) ;
minimizeAnimSlider - > setTickPosition ( QSlider : : TicksBelow ) ;
rLay - > addWidget ( minimizeAnimSlider , 0 , 0 , 1 , 2 ) ;
2002-01-16 12:26:03 +00:00
2002-03-01 11:38:40 +00:00
connect ( minimizeAnimOn , SIGNAL ( toggled ( bool ) ) , this , SLOT ( setMinimizeAnim ( bool ) ) ) ;
connect ( minimizeAnimSlider , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( setMinimizeAnimSpeed ( int ) ) ) ;
2002-01-16 12:26:03 +00:00
minimizeAnimSlowLabel = new QLabel ( i18n ( " Slow " ) , windowsBox ) ;
2002-04-26 01:39:18 +00:00
minimizeAnimSlowLabel - > setAlignment ( Qt : : AlignTop | Qt : : AlignLeft ) ;
2002-01-16 12:26:03 +00:00
rLay - > addWidget ( minimizeAnimSlowLabel , 1 , 1 ) ;
minimizeAnimFastLabel = new QLabel ( i18n ( " Fast " ) , windowsBox ) ;
2002-04-26 01:39:18 +00:00
minimizeAnimFastLabel - > setAlignment ( Qt : : AlignTop | Qt : : AlignRight ) ;
2002-01-16 12:26:03 +00:00
rLay - > addWidget ( minimizeAnimFastLabel , 1 , 2 ) ;
wtstr = i18n ( " Here you can set the speed of the animation shown when windows are "
" minimized and restored. " ) ;
2005-07-28 14:59:42 +00:00
minimizeAnimSlider - > setWhatsThis ( wtstr ) ;
minimizeAnimSlowLabel - > setWhatsThis ( wtstr ) ;
minimizeAnimFastLabel - > setWhatsThis ( wtstr ) ;
2002-01-16 12:26:03 +00:00
2002-04-26 01:39:18 +00:00
moveResizeMaximized = new QCheckBox ( i18n ( " Allow moving and resizing o&f maximized windows " ) , windowsBox ) ;
2002-01-16 12:26:03 +00:00
bLay - > addWidget ( moveResizeMaximized ) ;
2005-07-28 14:59:42 +00:00
moveResizeMaximized - > setWhatsThis ( i18n ( " When enabled, this feature activates the border of maximized windows "
2002-01-16 12:26:03 +00:00
" and allows you to move or resize them, "
" just like for normal windows " ) ) ;
2006-04-12 15:13:31 +00:00
QBoxLayout * vLay = new QHBoxLayout ( ) ;
bLay - > addLayout ( vLay ) ;
2002-01-16 12:26:03 +00:00
2002-04-26 01:39:18 +00:00
QLabel * plcLabel = new QLabel ( i18n ( " &Placement: " ) , windowsBox ) ;
2002-01-16 12:26:03 +00:00
2006-04-12 15:13:31 +00:00
placementCombo = new QComboBox ( windowsBox ) ;
placementCombo - > setEditable ( false ) ;
placementCombo - > addItem ( i18n ( " Smart " ) , SMART_PLACEMENT ) ;
placementCombo - > addItem ( i18n ( " Maximizing " ) , MAXIMIZING_PLACEMENT ) ;
placementCombo - > addItem ( i18n ( " Cascade " ) , CASCADE_PLACEMENT ) ;
placementCombo - > addItem ( i18n ( " Random " ) , RANDOM_PLACEMENT ) ;
placementCombo - > addItem ( i18n ( " Centered " ) , CENTERED_PLACEMENT ) ;
placementCombo - > addItem ( i18n ( " Zero-Cornered " ) , ZEROCORNERED_PLACEMENT ) ;
2002-01-16 12:26:03 +00:00
// CT: disabling is needed as long as functionality misses in kwin
2006-04-12 15:13:31 +00:00
//placementCombo->addItem(i18n("Interactive"), INTERACTIVE_PLACEMENT);
//placementCombo->addItem(i18n("Manual"), MANUAL_PLACEMENT);
2006-03-06 16:25:27 +00:00
placementCombo - > setCurrentIndex ( SMART_PLACEMENT ) ;
2002-01-16 12:26:03 +00:00
// FIXME, when more policies have been added to KWin
wtstr = i18n ( " The placement policy determines where a new window "
2004-10-13 16:07:35 +00:00
" will appear on the desktop. "
" <ul> "
" <li><em>Smart</em> will try to achieve a minimum overlap of windows</li> "
2005-08-08 14:22:52 +00:00
" <li><em>Maximizing</em> will try to maximize every window to fill the whole screen. "
" It might be useful to selectively affect placement of some windows using "
" the window-specific settings.</li> "
2002-01-16 12:26:03 +00:00
" <li><em>Cascade</em> will cascade the windows</li> "
2004-10-13 16:07:35 +00:00
" <li><em>Random</em> will use a random position</li> "
" <li><em>Centered</em> will place the window centered</li> "
" <li><em>Zero-Cornered</em> will place the window in the top-left corner</li> "
" </ul> " ) ;
2002-01-16 12:26:03 +00:00
2005-07-28 14:59:42 +00:00
plcLabel - > setWhatsThis ( wtstr ) ;
placementCombo - > setWhatsThis ( wtstr ) ;
2002-01-16 12:26:03 +00:00
plcLabel - > setBuddy ( placementCombo ) ;
2002-04-26 01:39:18 +00:00
vLay - > addWidget ( plcLabel , 0 ) ;
vLay - > addWidget ( placementCombo , 1 , Qt : : AlignLeft ) ;
2002-01-16 12:26:03 +00:00
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
2005-07-28 14:59:42 +00:00
MagicBox = new Q3VButtonGroup ( i18n ( " Snap Zones " ) , this ) ;
MagicBox - > layout ( ) - > setMargin ( 15 ) ;
2002-01-16 12:26:03 +00:00
BrdrSnap = new KIntNumInput ( 10 , MagicBox ) ;
BrdrSnap - > setSpecialValueText ( i18n ( " none " ) ) ;
BrdrSnap - > setRange ( 0 , MAX_BRDR_SNAP ) ;
BrdrSnap - > setLabel ( i18n ( " &Border snap zone: " ) ) ;
2002-04-26 01:39:18 +00:00
BrdrSnap - > setSteps ( 1 , 10 ) ;
2005-07-28 14:59:42 +00:00
BrdrSnap - > setWhatsThis ( i18n ( " Here you can set the snap zone for screen borders, i.e. "
2002-01-16 12:26:03 +00:00
" 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: " ) ) ;
2002-04-26 01:39:18 +00:00
BrdrSnap - > setSteps ( 1 , 10 ) ;
2005-07-28 14:59:42 +00:00
WndwSnap - > setWhatsThis ( i18n ( " Here you can set the snap zone for windows, i.e. "
2002-01-16 12:26:03 +00:00
" the 'strength' of the magnetic field which will make windows snap to each other when "
" they're moved near another window. " ) ) ;
2002-04-26 01:39:18 +00:00
OverlapSnap = new QCheckBox ( i18n ( " Snap windows onl&y when overlapping " ) , MagicBox ) ;
2005-07-28 14:59:42 +00:00
OverlapSnap - > setWhatsThis ( i18n ( " Here you can set that windows will be only "
2004-05-19 13:27:23 +00:00
" snapped if you try to overlap them, i.e. they will not be snapped if the windows "
2002-01-16 12:26:03 +00:00
" comes only near another window or border. " ) ) ;
lay - > addWidget ( MagicBox ) ;
lay - > addStretch ( ) ;
load ( ) ;
// Any changes goes to slotChanged()
2002-07-07 00:38:19 +00:00
connect ( opaque , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
connect ( resizeOpaqueOn , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
2003-01-10 10:54:57 +00:00
connect ( geometryTipOn , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
2002-07-07 00:38:19 +00:00
connect ( minimizeAnimOn , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
connect ( minimizeAnimSlider , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( moveResizeMaximized , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
connect ( placementCombo , SIGNAL ( activated ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( BrdrSnap , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
2006-03-26 21:03:17 +00:00
connect ( BrdrSnap , SIGNAL ( valueChanged ( int ) ) , SLOT ( slotBrdrSnapChanged ( int ) ) ) ;
2002-07-07 00:38:19 +00:00
connect ( WndwSnap , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
2006-03-26 21:03:17 +00:00
connect ( WndwSnap , SIGNAL ( valueChanged ( int ) ) , SLOT ( slotWndwSnapChanged ( int ) ) ) ;
2002-07-07 00:38:19 +00:00
connect ( OverlapSnap , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
2006-03-26 21:03:17 +00:00
// To get suffix to BrdrSnap and WndwSnap inputs with default values.
slotBrdrSnapChanged ( BrdrSnap - > value ( ) ) ;
slotWndwSnapChanged ( WndwSnap - > value ( ) ) ;
2002-01-16 12:26:03 +00:00
}
int KMovingConfig : : getMove ( )
{
2002-03-01 11:38:40 +00:00
return ( opaque - > isChecked ( ) ) ? OPAQUE : TRANSPARENT ;
2002-01-16 12:26:03 +00:00
}
void KMovingConfig : : setMove ( int trans )
{
2002-03-01 11:38:40 +00:00
opaque - > setChecked ( trans = = OPAQUE ) ;
2002-01-16 12:26:03 +00:00
}
2003-01-10 10:54:57 +00:00
void KMovingConfig : : setGeometryTip ( bool showGeometryTip )
{
geometryTipOn - > setChecked ( showGeometryTip ) ;
}
bool KMovingConfig : : getGeometryTip ( )
{
return geometryTipOn - > isChecked ( ) ;
}
2002-01-16 12:26:03 +00:00
// placement policy --- CT 31jan98 ---
int KMovingConfig : : getPlacement ( )
{
2006-03-06 15:51:12 +00:00
return placementCombo - > currentIndex ( ) ;
2002-01-16 12:26:03 +00:00
}
void KMovingConfig : : setPlacement ( int plac )
{
2006-03-06 16:25:27 +00:00
placementCombo - > setCurrentIndex ( plac ) ;
2002-01-16 12:26:03 +00:00
}
bool KMovingConfig : : getMinimizeAnim ( )
{
return minimizeAnimOn - > isChecked ( ) ;
}
int KMovingConfig : : getMinimizeAnimSpeed ( )
{
return minimizeAnimSlider - > value ( ) ;
}
2002-03-01 11:38:40 +00:00
void KMovingConfig : : setMinimizeAnim ( bool anim )
2002-01-16 12:26:03 +00:00
{
minimizeAnimOn - > setChecked ( anim ) ;
minimizeAnimSlider - > setEnabled ( anim ) ;
minimizeAnimSlowLabel - > setEnabled ( anim ) ;
minimizeAnimFastLabel - > setEnabled ( anim ) ;
}
2002-03-01 11:38:40 +00:00
void KMovingConfig : : setMinimizeAnimSpeed ( int speed )
{
minimizeAnimSlider - > setValue ( speed ) ;
}
2002-01-16 12:26:03 +00:00
int KMovingConfig : : getResizeOpaque ( )
{
2002-03-01 11:38:40 +00:00
return ( resizeOpaqueOn - > isChecked ( ) ) ? RESIZE_OPAQUE : RESIZE_TRANSPARENT ;
2002-01-16 12:26:03 +00:00
}
void KMovingConfig : : setResizeOpaque ( int opaque )
{
2002-03-01 11:38:40 +00:00
resizeOpaqueOn - > setChecked ( opaque = = RESIZE_OPAQUE ) ;
2002-01-16 12:26:03 +00:00
}
void KMovingConfig : : setMoveResizeMaximized ( bool a ) {
moveResizeMaximized - > setChecked ( a ) ;
}
2006-03-26 21:03:17 +00:00
void KMovingConfig : : slotBrdrSnapChanged ( int value ) {
2006-04-10 11:57:13 +00:00
BrdrSnap - > setSuffix ( i18np ( " pixel " , " pixels " , value ) ) ;
2006-03-26 21:03:17 +00:00
}
void KMovingConfig : : slotWndwSnapChanged ( int value ) {
2006-04-10 11:57:13 +00:00
WndwSnap - > setSuffix ( i18np ( " pixel " , " pixels " , value ) ) ;
2006-03-26 21:03:17 +00:00
}
2002-01-16 12:26:03 +00:00
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)
2006-01-03 14:01:15 +00:00
bool anim = config - > readEntry ( KWIN_MINIMIZE_ANIM , QVariant ( true ) ) . toBool ( ) ;
2006-01-21 19:36:31 +00:00
int animSpeed = config - > readEntry ( KWIN_MINIMIZE_ANIM_SPEED , 5 ) ;
2002-03-01 11:38:40 +00:00
if ( animSpeed < 1 ) animSpeed = 0 ;
if ( animSpeed > 10 ) animSpeed = 10 ;
setMinimizeAnim ( anim ) ;
setMinimizeAnimSpeed ( animSpeed ) ;
2002-01-16 12:26:03 +00:00
// 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 ) ;
2003-01-10 10:54:57 +00:00
//KS 10Jan2003 - Geometry Tip during window move/resize
2006-01-03 14:01:15 +00:00
bool showGeomTip = config - > readEntry ( KWIN_GEOMETRY , QVariant ( false ) ) . toBool ( ) ;
2003-01-10 10:54:57 +00:00
setGeometryTip ( showGeomTip ) ;
2002-01-16 12:26:03 +00:00
// 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 ) ;
2002-07-16 13:59:33 +00:00
else if ( key = = " Centered " )
setPlacement ( CENTERED_PLACEMENT ) ;
else if ( key = = " ZeroCornered " )
setPlacement ( ZEROCORNERED_PLACEMENT ) ;
2005-08-08 14:22:52 +00:00
else if ( key = = " Maximizing " )
setPlacement ( MAXIMIZING_PLACEMENT ) ;
2002-01-16 12:26:03 +00:00
else
setPlacement ( SMART_PLACEMENT ) ;
// }
2006-01-03 14:01:15 +00:00
setMoveResizeMaximized ( config - > readEntry ( KWIN_MOVE_RESIZE_MAXIMIZED , QVariant ( false ) ) . toBool ( ) ) ;
2002-01-16 12:26:03 +00:00
int v ;
2006-01-21 19:36:31 +00:00
v = config - > readEntry ( KWM_BRDR_SNAP_ZONE , KWM_BRDR_SNAP_ZONE_DEFAULT ) ;
2002-01-16 12:26:03 +00:00
if ( v > MAX_BRDR_SNAP ) setBorderSnapZone ( MAX_BRDR_SNAP ) ;
else if ( v < 0 ) setBorderSnapZone ( 0 ) ;
else setBorderSnapZone ( v ) ;
2006-01-21 19:36:31 +00:00
v = config - > readEntry ( KWM_WNDW_SNAP_ZONE , KWM_WNDW_SNAP_ZONE_DEFAULT ) ;
2002-01-16 12:26:03 +00:00
if ( v > MAX_WNDW_SNAP ) setWindowSnapZone ( MAX_WNDW_SNAP ) ;
else if ( v < 0 ) setWindowSnapZone ( 0 ) ;
else setWindowSnapZone ( v ) ;
2006-01-03 14:01:15 +00:00
OverlapSnap - > setChecked ( config - > readEntry ( " SnapOnlyWhenOverlapping " , QVariant ( false ) ) . toBool ( ) ) ;
2003-11-08 23:43:53 +00:00
emit KCModule : : changed ( false ) ;
2002-01-16 12:26:03 +00:00
}
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 " ) ;
2003-01-10 10:54:57 +00:00
config - > writeEntry ( KWIN_GEOMETRY , getGeometryTip ( ) ) ;
2002-01-16 12:26:03 +00:00
// 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 " ) ;
2002-07-16 13:59:33 +00:00
else if ( v = = CENTERED_PLACEMENT )
config - > writeEntry ( KWIN_PLACEMENT , " Centered " ) ;
else if ( v = = ZEROCORNERED_PLACEMENT )
config - > writeEntry ( KWIN_PLACEMENT , " ZeroCornered " ) ;
2005-08-08 14:22:52 +00:00
else if ( v = = MAXIMIZING_PLACEMENT )
config - > writeEntry ( KWIN_PLACEMENT , " Maximizing " ) ;
2002-01-16 12:26:03 +00:00
//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 ( ) ) ;
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 ( ) ) ;
2002-07-16 13:59:33 +00:00
2002-09-16 20:54:23 +00:00
if ( standAlone )
{
config - > sync ( ) ;
2006-07-02 18:31:00 +00:00
QDBusInterface kwin ( " org.kde.kwin " , " /KWin " , " org.kde.KWin " ) ;
kwin . call ( " reconfigure " ) ;
2002-09-16 20:54:23 +00:00
}
2003-11-08 23:43:53 +00:00
emit KCModule : : changed ( false ) ;
2002-01-16 12:26:03 +00:00
}
void KMovingConfig : : defaults ( )
{
setMove ( OPAQUE ) ;
setResizeOpaque ( RESIZE_TRANSPARENT ) ;
2003-01-10 10:54:57 +00:00
setGeometryTip ( false ) ;
2002-01-16 12:26:03 +00:00
setPlacement ( SMART_PLACEMENT ) ;
2005-04-13 10:59:58 +00:00
setMoveResizeMaximized ( false ) ;
2002-01-16 12:26:03 +00:00
//copied from kcontrol/konq/kwindesktop, aleXXX
setWindowSnapZone ( KWM_WNDW_SNAP_ZONE_DEFAULT ) ;
setBorderSnapZone ( KWM_BRDR_SNAP_ZONE_DEFAULT ) ;
OverlapSnap - > setChecked ( false ) ;
2002-07-13 07:27:54 +00:00
setMinimizeAnim ( true ) ;
setMinimizeAnimSpeed ( 5 ) ;
2003-11-08 23:43:53 +00:00
emit KCModule : : changed ( true ) ;
2002-01-16 12:26:03 +00:00
}
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 ) ;
}
2005-01-15 17:07:48 +00:00
KTranslucencyConfig : : ~ KTranslucencyConfig ( )
{
if ( standAlone )
delete config ;
if ( kompmgr )
kompmgr - > detach ( ) ;
}
2005-10-22 19:12:01 +00:00
KTranslucencyConfig : : KTranslucencyConfig ( bool _standAlone , KConfig * _config , KInstance * inst , QWidget * parent )
: KCModule ( inst , parent ) , config ( _config ) , standAlone ( _standAlone )
2005-01-15 17:07:48 +00:00
{
kompmgr = 0L ;
2006-02-19 01:33:48 +00:00
resetKompmgr_ = false ;
2005-01-15 17:07:48 +00:00
QVBoxLayout * lay = new QVBoxLayout ( this ) ;
2005-01-28 23:13:32 +00:00
kompmgrAvailable_ = kompmgrAvailable ( ) ;
if ( ! kompmgrAvailable_ ) {
2006-07-06 18:01:52 +00:00
QLabel * label = new QLabel ( i18n ( " <qt><b>It seems that alpha channel support is not available.</b><br><br> "
2005-01-17 12:50:27 +00:00
" Please make sure you have "
" <a href= \" http://www.freedesktop.org/ \" >Xorg ≥ 6.8</a>, "
2005-11-22 00:47:29 +00:00
" and have installed the kompmgr that came with kwin.<br> "
2005-01-18 15:31:37 +00:00
" Also, make sure you have the following entries in your XConfig (e.g. /etc/X11/xorg.conf):<br><br> "
2005-01-15 17:07:48 +00:00
" <i>Section \" Extensions \" <br> "
" Option \" Composite \" \" Enable \" <br> "
" EndSection</i><br><br> "
2005-01-17 12:50:27 +00:00
" And if your GPU provides hardware-accelerated Xrender support (mainly nVidia cards):<br><br> "
2005-01-15 17:07:48 +00:00
" <i>Option \" RenderAccel \" \" true \" </i><br> "
2005-01-16 21:03:59 +00:00
" In <i>Section \" Device \" </i></qt> " ) , this ) ;
2006-07-06 18:01:52 +00:00
label - > setOpenExternalLinks ( true ) ;
label - > setTextInteractionFlags ( Qt : : LinksAccessibleByMouse ) ;
label - > setTextInteractionFlags ( Qt : : TextInteractionFlags ( style ( ) - > styleHint ( QStyle : : SH_MessageBox_TextInteractionFlags ) ) ) ;
2005-01-15 17:07:48 +00:00
lay - > addWidget ( label ) ;
}
else
{
QTabWidget * tabW = new QTabWidget ( this ) ;
QWidget * tGroup = new QWidget ( tabW ) ;
2006-04-12 15:13:31 +00:00
QVBoxLayout * vLay = new QVBoxLayout ( tGroup ) ;
vLay - > setMargin ( KDialog : : marginHint ( ) ) ;
vLay - > setSpacing ( KDialog : : spacingHint ( ) ) ;
2005-01-15 17:07:48 +00:00
vLay - > addSpacing ( 11 ) ; // to get the proper gb top offset
2005-02-09 18:31:35 +00:00
2005-07-01 19:55:06 +00:00
onlyDecoTranslucent = new QCheckBox ( i18n ( " Apply translucency only to decoration " ) , tGroup ) ;
vLay - > addWidget ( onlyDecoTranslucent ) ;
2005-02-09 18:31:35 +00:00
2005-02-27 20:44:44 +00:00
vLay - > addSpacing ( 11 ) ;
2005-02-09 18:31:35 +00:00
2006-04-12 15:13:31 +00:00
QGridLayout * gLay = new QGridLayout ( ) ;
gLay - > setSpacing ( KDialog : : spacingHint ( ) ) ;
gLay - > setColumnStretch ( 1 , 1 ) ;
vLay - > addLayout ( gLay ) ;
2005-01-18 15:31:37 +00:00
2005-01-22 09:56:29 +00:00
activeWindowTransparency = new QCheckBox ( i18n ( " Active windows: " ) , tGroup ) ;
2005-01-15 17:07:48 +00:00
gLay - > addWidget ( activeWindowTransparency , 0 , 0 ) ;
activeWindowOpacity = new KIntNumInput ( 100 , tGroup ) ;
activeWindowOpacity - > setRange ( 0 , 100 ) ;
activeWindowOpacity - > setSuffix ( " % " ) ;
gLay - > addWidget ( activeWindowOpacity , 0 , 1 ) ;
2005-01-18 15:31:37 +00:00
2005-01-22 09:56:29 +00:00
inactiveWindowTransparency = new QCheckBox ( i18n ( " Inactive windows: " ) , tGroup ) ;
2005-01-15 17:07:48 +00:00
gLay - > addWidget ( inactiveWindowTransparency , 1 , 0 ) ;
inactiveWindowOpacity = new KIntNumInput ( 100 , tGroup ) ;
inactiveWindowOpacity - > setRange ( 0 , 100 ) ;
inactiveWindowOpacity - > setSuffix ( " % " ) ;
gLay - > addWidget ( inactiveWindowOpacity , 1 , 1 ) ;
2005-01-18 15:31:37 +00:00
2005-01-22 09:56:29 +00:00
movingWindowTransparency = new QCheckBox ( i18n ( " Moving windows: " ) , tGroup ) ;
2005-01-15 17:07:48 +00:00
gLay - > addWidget ( movingWindowTransparency , 2 , 0 ) ;
movingWindowOpacity = new KIntNumInput ( 100 , tGroup ) ;
movingWindowOpacity - > setRange ( 0 , 100 ) ;
movingWindowOpacity - > setSuffix ( " % " ) ;
gLay - > addWidget ( movingWindowOpacity , 2 , 1 ) ;
2005-01-18 15:31:37 +00:00
2005-01-22 09:56:29 +00:00
dockWindowTransparency = new QCheckBox ( i18n ( " Dock windows: " ) , tGroup ) ;
2005-01-15 17:07:48 +00:00
gLay - > addWidget ( dockWindowTransparency , 3 , 0 ) ;
dockWindowOpacity = new KIntNumInput ( 100 , tGroup ) ;
dockWindowOpacity - > setRange ( 0 , 100 ) ;
dockWindowOpacity - > setSuffix ( " % " ) ;
gLay - > addWidget ( dockWindowOpacity , 3 , 1 ) ;
2005-02-09 18:31:35 +00:00
vLay - > addSpacing ( 11 ) ;
2005-01-18 15:31:37 +00:00
2005-01-16 21:03:59 +00:00
keepAboveAsActive = new QCheckBox ( i18n ( " Treat 'keep above' windows as active ones " ) , tGroup ) ;
2005-01-15 17:07:48 +00:00
vLay - > addWidget ( keepAboveAsActive ) ;
2005-01-24 07:56:41 +00:00
disableARGB = new QCheckBox ( i18n ( " Disable ARGB windows (ignores window alpha maps, fixes gtk1 apps) " ) , tGroup ) ;
vLay - > addWidget ( disableARGB ) ;
2005-01-15 17:07:48 +00:00
vLay - > addStretch ( ) ;
2005-02-27 20:44:44 +00:00
tabW - > addTab ( tGroup , i18n ( " Opacity " ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
QWidget * sGroup = new QWidget ( tabW ) ;
2006-02-19 01:33:48 +00:00
// sGroup->setCheckable(true);
2006-04-12 15:13:31 +00:00
QVBoxLayout * vLay2 = new QVBoxLayout ( sGroup ) ;
vLay2 - > setMargin ( 11 ) ;
vLay2 - > setSpacing ( 6 ) ;
2005-01-15 17:07:48 +00:00
vLay2 - > addSpacing ( 11 ) ; // to get the proper gb top offset
2005-01-16 21:03:59 +00:00
useShadows = new QCheckBox ( i18n ( " Use shadows " ) , sGroup ) ;
2005-01-15 17:07:48 +00:00
vLay2 - > addWidget ( useShadows ) ;
2005-02-09 18:31:35 +00:00
vLay2 - > addSpacing ( 11 ) ;
2005-01-18 15:31:37 +00:00
2006-04-12 15:13:31 +00:00
QGridLayout * gLay2 = new QGridLayout ( ) ;
gLay2 - > setColumnStretch ( 1 , 1 ) ;
vLay2 - > addLayout ( gLay2 ) ;
2005-01-18 15:31:37 +00:00
2005-01-22 09:56:29 +00:00
QLabel * label1 = new QLabel ( i18n ( " Active window size: " ) , sGroup ) ;
2005-01-15 17:07:48 +00:00
gLay2 - > addWidget ( label1 , 0 , 0 ) ;
activeWindowShadowSize = new KIntNumInput ( 12 , sGroup ) ;
activeWindowShadowSize - > setRange ( 0 , 32 ) ;
// activeWindowShadowSize->setSuffix("px");
gLay2 - > addWidget ( activeWindowShadowSize , 0 , 1 ) ;
2005-01-18 15:31:37 +00:00
2005-01-22 09:56:29 +00:00
QLabel * label2 = new QLabel ( i18n ( " Inactive window size: " ) , sGroup ) ;
2005-01-15 17:07:48 +00:00
gLay2 - > addWidget ( label2 , 1 , 0 ) ;
inactiveWindowShadowSize = new KIntNumInput ( 6 , sGroup ) ;
inactiveWindowShadowSize - > setRange ( 0 , 32 ) ;
// inactiveWindowShadowSize->setSuffix("px");
gLay2 - > addWidget ( inactiveWindowShadowSize , 1 , 1 ) ;
2005-01-18 15:31:37 +00:00
2005-01-22 09:56:29 +00:00
QLabel * label3 = new QLabel ( i18n ( " Dock window size: " ) , sGroup ) ;
2005-01-15 17:07:48 +00:00
gLay2 - > addWidget ( label3 , 2 , 0 ) ;
dockWindowShadowSize = new KIntNumInput ( 6 , sGroup ) ;
dockWindowShadowSize - > setRange ( 0 , 32 ) ;
// dockWindowShadowSize->setSuffix("px");
gLay2 - > addWidget ( dockWindowShadowSize , 2 , 1 ) ;
2005-01-18 15:31:37 +00:00
2005-01-22 09:56:29 +00:00
QLabel * label4 = new QLabel ( i18n ( " Vertical offset: " ) , sGroup ) ;
2005-01-15 17:07:48 +00:00
gLay2 - > addWidget ( label4 , 3 , 0 ) ;
shadowTopOffset = new KIntNumInput ( 80 , sGroup ) ;
shadowTopOffset - > setSuffix ( " % " ) ;
shadowTopOffset - > setRange ( - 200 , 200 ) ;
gLay2 - > addWidget ( shadowTopOffset , 3 , 1 ) ;
2005-01-18 15:31:37 +00:00
2005-01-22 09:56:29 +00:00
QLabel * label5 = new QLabel ( i18n ( " Horizontal offset: " ) , sGroup ) ;
2005-01-15 17:07:48 +00:00
gLay2 - > addWidget ( label5 , 4 , 0 ) ;
shadowLeftOffset = new KIntNumInput ( 0 , sGroup ) ;
shadowLeftOffset - > setSuffix ( " % " ) ;
shadowLeftOffset - > setRange ( - 200 , 200 ) ;
gLay2 - > addWidget ( shadowLeftOffset , 4 , 1 ) ;
2005-01-18 15:31:37 +00:00
2005-01-22 09:56:29 +00:00
QLabel * label6 = new QLabel ( i18n ( " Shadow color: " ) , sGroup ) ;
2005-01-15 17:07:48 +00:00
gLay2 - > addWidget ( label6 , 5 , 0 ) ;
shadowColor = new KColorButton ( Qt : : black , sGroup ) ;
gLay2 - > addWidget ( shadowColor , 5 , 1 ) ;
2006-04-12 15:13:31 +00:00
gLay2 - > setColumnStretch ( 1 , 1 ) ;
2005-02-09 18:31:35 +00:00
vLay2 - > addSpacing ( 11 ) ;
2005-01-28 23:13:32 +00:00
removeShadowsOnMove = new QCheckBox ( i18n ( " Remove shadows on move " ) , sGroup ) ;
vLay2 - > addWidget ( removeShadowsOnMove ) ;
2005-01-21 16:08:39 +00:00
removeShadowsOnResize = new QCheckBox ( i18n ( " Remove shadows on resize " ) , sGroup ) ;
vLay2 - > addWidget ( removeShadowsOnResize ) ;
2005-01-15 17:07:48 +00:00
vLay2 - > addStretch ( ) ;
tabW - > addTab ( sGroup , i18n ( " Shadows " ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
QWidget * eGroup = new QWidget ( this ) ;
2006-04-12 15:13:31 +00:00
QVBoxLayout * vLay3 = new QVBoxLayout ( eGroup ) ;
vLay3 - > setMargin ( 11 ) ;
vLay3 - > setSpacing ( 6 ) ;
2005-01-15 17:07:48 +00:00
2005-01-16 21:03:59 +00:00
fadeInWindows = new QCheckBox ( i18n ( " Fade-in windows (including popups) " ) , eGroup ) ;
2005-01-15 17:07:48 +00:00
fadeOnOpacityChange = new QCheckBox ( i18n ( " Fade between opacity changes " ) , eGroup ) ;
fadeInSpeed = new KIntNumInput ( 100 , eGroup ) ;
fadeInSpeed - > setRange ( 1 , 100 ) ;
2005-01-22 09:56:29 +00:00
fadeInSpeed - > setLabel ( " Fade-in speed: " ) ;
2005-01-15 17:07:48 +00:00
fadeOutSpeed = new KIntNumInput ( 100 , eGroup ) ;
fadeOutSpeed - > setRange ( 1 , 100 ) ;
2005-01-22 09:56:29 +00:00
fadeOutSpeed - > setLabel ( " Fade-out speed: " ) ;
2005-01-15 17:07:48 +00:00
vLay3 - > addWidget ( fadeInWindows ) ;
vLay3 - > addWidget ( fadeOnOpacityChange ) ;
vLay3 - > addWidget ( fadeInSpeed ) ;
vLay3 - > addWidget ( fadeOutSpeed ) ;
vLay3 - > addStretch ( ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
tabW - > addTab ( eGroup , i18n ( " Effects " ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-16 21:03:59 +00:00
useTranslucency = new QCheckBox ( i18n ( " Use translucency/shadows " ) , this ) ;
2005-01-15 17:07:48 +00:00
lay - > addWidget ( useTranslucency ) ;
lay - > addWidget ( tabW ) ;
connect ( useTranslucency , SIGNAL ( toggled ( bool ) ) , tabW , SLOT ( setEnabled ( bool ) ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
connect ( activeWindowTransparency , SIGNAL ( toggled ( bool ) ) , activeWindowOpacity , SLOT ( setEnabled ( bool ) ) ) ;
connect ( inactiveWindowTransparency , SIGNAL ( toggled ( bool ) ) , inactiveWindowOpacity , SLOT ( setEnabled ( bool ) ) ) ;
connect ( movingWindowTransparency , SIGNAL ( toggled ( bool ) ) , movingWindowOpacity , SLOT ( setEnabled ( bool ) ) ) ;
connect ( dockWindowTransparency , SIGNAL ( toggled ( bool ) ) , dockWindowOpacity , SLOT ( setEnabled ( bool ) ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
connect ( useTranslucency , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
2005-07-01 19:55:06 +00:00
connect ( onlyDecoTranslucent , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
2005-01-15 17:07:48 +00:00
connect ( activeWindowTransparency , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
connect ( inactiveWindowTransparency , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
connect ( movingWindowTransparency , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
connect ( dockWindowTransparency , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
connect ( keepAboveAsActive , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
2005-01-24 07:56:41 +00:00
connect ( disableARGB , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
2005-01-15 17:07:48 +00:00
connect ( useShadows , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
2005-01-21 16:08:39 +00:00
connect ( removeShadowsOnResize , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
2005-01-28 23:13:32 +00:00
connect ( removeShadowsOnMove , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
connect ( activeWindowOpacity , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( inactiveWindowOpacity , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( movingWindowOpacity , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( dockWindowOpacity , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( dockWindowShadowSize , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( activeWindowShadowSize , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( inactiveWindowShadowSize , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( shadowTopOffset , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( shadowLeftOffset , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( shadowColor , SIGNAL ( changed ( const QColor & ) ) , SLOT ( changed ( ) ) ) ;
connect ( fadeInWindows , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
connect ( fadeOnOpacityChange , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
connect ( fadeInSpeed , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( fadeOutSpeed , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
connect ( useShadows , SIGNAL ( toggled ( bool ) ) , dockWindowShadowSize , SLOT ( setEnabled ( bool ) ) ) ;
connect ( useShadows , SIGNAL ( toggled ( bool ) ) , activeWindowShadowSize , SLOT ( setEnabled ( bool ) ) ) ;
connect ( useShadows , SIGNAL ( toggled ( bool ) ) , inactiveWindowShadowSize , SLOT ( setEnabled ( bool ) ) ) ;
connect ( useShadows , SIGNAL ( toggled ( bool ) ) , shadowTopOffset , SLOT ( setEnabled ( bool ) ) ) ;
connect ( useShadows , SIGNAL ( toggled ( bool ) ) , shadowLeftOffset , SLOT ( setEnabled ( bool ) ) ) ;
connect ( useShadows , SIGNAL ( toggled ( bool ) ) , shadowColor , SLOT ( setEnabled ( bool ) ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
load ( ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
tabW - > setEnabled ( useTranslucency - > isChecked ( ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
connect ( useTranslucency , SIGNAL ( toggled ( bool ) ) , this , SLOT ( showWarning ( bool ) ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
// handle kompmgr restarts if necessary
2005-01-18 15:31:37 +00:00
connect ( useTranslucency , SIGNAL ( toggled ( bool ) ) , SLOT ( resetKompmgr ( ) ) ) ;
2005-01-24 07:56:41 +00:00
connect ( disableARGB , SIGNAL ( toggled ( bool ) ) , SLOT ( resetKompmgr ( ) ) ) ;
2005-01-15 17:07:48 +00:00
connect ( useShadows , SIGNAL ( toggled ( bool ) ) , SLOT ( resetKompmgr ( ) ) ) ;
connect ( inactiveWindowShadowSize , SIGNAL ( valueChanged ( int ) ) , SLOT ( resetKompmgr ( ) ) ) ;
connect ( shadowTopOffset , SIGNAL ( valueChanged ( int ) ) , SLOT ( resetKompmgr ( ) ) ) ;
connect ( shadowLeftOffset , SIGNAL ( valueChanged ( int ) ) , SLOT ( resetKompmgr ( ) ) ) ;
connect ( shadowColor , SIGNAL ( changed ( const QColor & ) ) , SLOT ( resetKompmgr ( ) ) ) ;
connect ( fadeInWindows , SIGNAL ( toggled ( bool ) ) , SLOT ( resetKompmgr ( ) ) ) ;
connect ( fadeOnOpacityChange , SIGNAL ( toggled ( bool ) ) , SLOT ( resetKompmgr ( ) ) ) ;
connect ( fadeInSpeed , SIGNAL ( valueChanged ( int ) ) , SLOT ( resetKompmgr ( ) ) ) ;
connect ( fadeOutSpeed , SIGNAL ( valueChanged ( int ) ) , SLOT ( resetKompmgr ( ) ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
}
}
void KTranslucencyConfig : : resetKompmgr ( )
{
2006-02-19 01:33:48 +00:00
resetKompmgr_ = true ;
2005-01-15 17:07:48 +00:00
}
void KTranslucencyConfig : : load ( void )
{
2005-01-28 23:13:32 +00:00
if ( ! kompmgrAvailable_ )
return ;
2006-07-06 18:01:52 +00:00
config - > setGroup ( " Notification Messages " ) ;
2006-07-05 21:46:01 +00:00
useTranslucency - > setChecked ( config - > readEntry ( " UseTranslucency " , QVariant ( false ) ) . toBool ( ) ) ;
2006-07-06 18:01:52 +00:00
config - > setGroup ( " Translucency " ) ;
2006-01-03 14:01:15 +00:00
activeWindowTransparency - > setChecked ( config - > readEntry ( " TranslucentActiveWindows " , QVariant ( false ) ) . toBool ( ) ) ;
inactiveWindowTransparency - > setChecked ( config - > readEntry ( " TranslucentInactiveWindows " , QVariant ( true ) ) . toBool ( ) ) ;
movingWindowTransparency - > setChecked ( config - > readEntry ( " TranslucentMovingWindows " , QVariant ( false ) ) . toBool ( ) ) ;
removeShadowsOnMove - > setChecked ( config - > readEntry ( " RemoveShadowsOnMove " , QVariant ( false ) ) . toBool ( ) ) ;
removeShadowsOnResize - > setChecked ( config - > readEntry ( " RemoveShadowsOnResize " , QVariant ( false ) ) . toBool ( ) ) ;
dockWindowTransparency - > setChecked ( config - > readEntry ( " TranslucentDocks " , QVariant ( true ) ) . toBool ( ) ) ;
keepAboveAsActive - > setChecked ( config - > readEntry ( " TreatKeepAboveAsActive " , QVariant ( true ) ) . toBool ( ) ) ;
onlyDecoTranslucent - > setChecked ( config - > readEntry ( " OnlyDecoTranslucent " , QVariant ( false ) ) . toBool ( ) ) ;
2005-01-18 15:31:37 +00:00
2006-01-21 19:36:31 +00:00
activeWindowOpacity - > setValue ( config - > readEntry ( " ActiveWindowOpacity " , 100 ) ) ;
inactiveWindowOpacity - > setValue ( config - > readEntry ( " InactiveWindowOpacity " , 75 ) ) ;
movingWindowOpacity - > setValue ( config - > readEntry ( " MovingWindowOpacity " , 25 ) ) ;
dockWindowOpacity - > setValue ( config - > readEntry ( " DockOpacity " , 80 ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
int ass , iss , dss ;
2006-01-21 19:36:31 +00:00
dss = config - > readEntry ( " DockShadowSize " , 33 ) ;
ass = config - > readEntry ( " ActiveWindowShadowSize " , 133 ) ;
iss = config - > readEntry ( " InactiveWindowShadowSize " , 67 ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
activeWindowOpacity - > setEnabled ( activeWindowTransparency - > isChecked ( ) ) ;
inactiveWindowOpacity - > setEnabled ( inactiveWindowTransparency - > isChecked ( ) ) ;
movingWindowOpacity - > setEnabled ( movingWindowTransparency - > isChecked ( ) ) ;
dockWindowOpacity - > setEnabled ( dockWindowTransparency - > isChecked ( ) ) ;
2005-01-18 15:31:37 +00:00
2005-11-08 10:20:07 +00:00
KConfig conf_ ( QDir : : homePath ( ) + " /.xcompmgrrc " ) ;
2005-01-15 17:07:48 +00:00
conf_ . setGroup ( " xcompmgr " ) ;
2005-01-24 07:56:41 +00:00
2006-02-19 01:33:48 +00:00
disableARGB - > setChecked ( conf_ . readEntry ( " DisableARGB " , QVariant ( false ) ) . toBool ( ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
useShadows - > setChecked ( conf_ . readEntry ( " Compmode " , " CompClientShadows " ) . compare ( " CompClientShadows " ) = = 0 ) ;
2006-01-21 19:36:31 +00:00
shadowTopOffset - > setValue ( - 1 * ( conf_ . readEntry ( " ShadowOffsetY " , - 80 ) ) ) ;
shadowLeftOffset - > setValue ( - 1 * ( conf_ . readEntry ( " ShadowOffsetX " , 0 ) ) ) ;
2005-01-18 15:31:37 +00:00
2006-01-21 19:36:31 +00:00
int ss = conf_ . readEntry ( " ShadowRadius " , 6 ) ;
2005-01-15 17:07:48 +00:00
dockWindowShadowSize - > setValue ( ( int ) ( dss * ss / 100.0 ) ) ;
activeWindowShadowSize - > setValue ( ( int ) ( ass * ss / 100.0 ) ) ;
inactiveWindowShadowSize - > setValue ( ( int ) ( iss * ss / 100.0 ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
QString hex = conf_ . readEntry ( " ShadowColor " , " #000000 " ) ;
uint r , g , b ;
r = g = b = 256 ;
2006-04-12 15:13:31 +00:00
if ( sscanf ( hex . toLatin1 ( ) , " 0x%02x%02x%02x " , & r , & g , & b ) ! = 3 | | r > 255 | | g > 255 | | b > 255 )
2005-01-15 17:07:48 +00:00
shadowColor - > setColor ( Qt : : black ) ;
else
shadowColor - > setColor ( QColor ( r , g , b ) ) ;
2005-01-18 15:31:37 +00:00
2006-02-19 01:33:48 +00:00
fadeInWindows - > setChecked ( conf_ . readEntry ( " FadeWindows " , QVariant ( true ) ) . toBool ( ) ) ;
fadeOnOpacityChange - > setChecked ( conf_ . readEntry ( " FadeTrans " , QVariant ( false ) ) . toBool ( ) ) ;
2006-01-21 19:36:31 +00:00
fadeInSpeed - > setValue ( ( int ) ( conf_ . readEntry ( " FadeInStep " , 0.020 ) * 1000.0 ) ) ;
fadeOutSpeed - > setValue ( ( int ) ( conf_ . readEntry ( " FadeOutStep " , 0.070 ) * 1000.0 ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
emit KCModule : : changed ( false ) ;
}
void KTranslucencyConfig : : save ( void )
{
2005-01-28 23:13:32 +00:00
if ( ! kompmgrAvailable_ )
return ;
2006-07-06 18:01:52 +00:00
config - > setGroup ( " Notification Messages " ) ;
2006-07-05 21:46:01 +00:00
config - > writeEntry ( " UseTranslucency " , useTranslucency - > isChecked ( ) ) ;
2006-07-06 18:01:52 +00:00
config - > setGroup ( " Translucency " ) ;
2005-01-15 17:07:48 +00:00
config - > writeEntry ( " TranslucentActiveWindows " , activeWindowTransparency - > isChecked ( ) ) ;
config - > writeEntry ( " TranslucentInactiveWindows " , inactiveWindowTransparency - > isChecked ( ) ) ;
config - > writeEntry ( " TranslucentMovingWindows " , movingWindowTransparency - > isChecked ( ) ) ;
config - > writeEntry ( " TranslucentDocks " , dockWindowTransparency - > isChecked ( ) ) ;
config - > writeEntry ( " TreatKeepAboveAsActive " , keepAboveAsActive - > isChecked ( ) ) ;
config - > writeEntry ( " ActiveWindowOpacity " , activeWindowOpacity - > value ( ) ) ;
config - > writeEntry ( " InactiveWindowOpacity " , inactiveWindowOpacity - > value ( ) ) ;
config - > writeEntry ( " MovingWindowOpacity " , movingWindowOpacity - > value ( ) ) ;
config - > writeEntry ( " DockOpacity " , dockWindowOpacity - > value ( ) ) ;
// for simplification:
// xcompmgr supports a general shadow radius and additionally lets external apps set a multiplicator for each window
// (speed reasons, so the shadow matrix hasn't to be recreated for every window)
// we set inactive windows to 100%, the radius to the inactive window value and adjust the multiplicators for docks and active windows
// this way the user can set the three values without caring about the radius/multiplicator stuff
2005-07-01 19:55:06 +00:00
// additionally we find a value between big and small values to have a more smooth appereance
config - > writeEntry ( " DockShadowSize " , ( int ) ( 200.0 * dockWindowShadowSize - > value ( ) / ( activeWindowShadowSize - > value ( ) + inactiveWindowShadowSize - > value ( ) ) ) ) ;
config - > writeEntry ( " ActiveWindowShadowSize " , ( int ) ( 200.0 * activeWindowShadowSize - > value ( ) / ( activeWindowShadowSize - > value ( ) + inactiveWindowShadowSize - > value ( ) ) ) ) ;
config - > writeEntry ( " InctiveWindowShadowSize " , ( int ) ( 200.0 * inactiveWindowShadowSize - > value ( ) / ( activeWindowShadowSize - > value ( ) + inactiveWindowShadowSize - > value ( ) ) ) ) ;
2005-01-28 23:13:32 +00:00
config - > writeEntry ( " RemoveShadowsOnMove " , removeShadowsOnMove - > isChecked ( ) ) ;
2005-01-21 16:08:39 +00:00
config - > writeEntry ( " RemoveShadowsOnResize " , removeShadowsOnResize - > isChecked ( ) ) ;
2005-07-01 19:55:06 +00:00
config - > writeEntry ( " OnlyDecoTranslucent " , onlyDecoTranslucent - > isChecked ( ) ) ;
2005-01-15 17:07:48 +00:00
config - > writeEntry ( " ResetKompmgr " , resetKompmgr_ ) ;
2005-01-18 15:31:37 +00:00
2005-11-08 10:20:07 +00:00
KConfig * conf_ = new KConfig ( QDir : : homePath ( ) + " /.xcompmgrrc " ) ;
2005-01-15 17:07:48 +00:00
conf_ - > setGroup ( " xcompmgr " ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
conf_ - > writeEntry ( " Compmode " , useShadows - > isChecked ( ) ? " CompClientShadows " : " " ) ;
2005-01-24 07:56:41 +00:00
conf_ - > writeEntry ( " DisableARGB " , disableARGB - > isChecked ( ) ) ;
2005-01-15 17:07:48 +00:00
conf_ - > writeEntry ( " ShadowOffsetY " , - 1 * shadowTopOffset - > value ( ) ) ;
conf_ - > writeEntry ( " ShadowOffsetX " , - 1 * shadowLeftOffset - > value ( ) ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
int r , g , b ;
2006-02-22 08:31:58 +00:00
shadowColor - > color ( ) . getRgb ( & r , & g , & b ) ;
2005-01-15 17:07:48 +00:00
QString hex ;
hex . sprintf ( " 0x%02X%02X%02X " , r , g , b ) ;
conf_ - > writeEntry ( " ShadowColor " , hex ) ;
2005-07-01 19:55:06 +00:00
conf_ - > writeEntry ( " ShadowRadius " , ( activeWindowShadowSize - > value ( ) + inactiveWindowShadowSize - > value ( ) ) / 2 ) ;
2005-01-15 17:07:48 +00:00
conf_ - > writeEntry ( " FadeWindows " , fadeInWindows - > isChecked ( ) ) ;
conf_ - > writeEntry ( " FadeTrans " , fadeOnOpacityChange - > isChecked ( ) ) ;
conf_ - > writeEntry ( " FadeInStep " , fadeInSpeed - > value ( ) / 1000.0 ) ;
conf_ - > writeEntry ( " FadeOutStep " , fadeOutSpeed - > value ( ) / 1000.0 ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
delete conf_ ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
if ( standAlone )
{
config - > sync ( ) ;
2006-07-02 18:31:00 +00:00
QDBusInterface kwin ( " org.kde.kwin " , " /KWin " , " org.kde.KWin " ) ;
kwin . call ( " reconfigure " ) ;
2005-01-15 17:07:48 +00:00
}
emit KCModule : : changed ( false ) ;
}
void KTranslucencyConfig : : defaults ( )
{
2005-01-28 23:13:32 +00:00
if ( ! kompmgrAvailable_ )
return ;
2005-01-15 17:07:48 +00:00
useTranslucency - > setChecked ( false ) ;
2005-07-01 19:55:06 +00:00
onlyDecoTranslucent - > setChecked ( false ) ;
2005-01-15 17:07:48 +00:00
activeWindowTransparency - > setChecked ( false ) ;
inactiveWindowTransparency - > setChecked ( true ) ;
movingWindowTransparency - > setChecked ( false ) ;
dockWindowTransparency - > setChecked ( true ) ;
keepAboveAsActive - > setChecked ( true ) ;
2005-01-24 07:56:41 +00:00
disableARGB - > setChecked ( false ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
activeWindowOpacity - > setValue ( 100 ) ;
2005-02-09 18:31:35 +00:00
inactiveWindowOpacity - > setValue ( 75 ) ;
2005-01-15 17:07:48 +00:00
movingWindowOpacity - > setValue ( 25 ) ;
dockWindowOpacity - > setValue ( 80 ) ;
2005-01-18 15:31:37 +00:00
2005-01-15 17:07:48 +00:00
dockWindowShadowSize - > setValue ( 6 ) ;
activeWindowShadowSize - > setValue ( 12 ) ;
inactiveWindowShadowSize - > setValue ( 6 ) ;
shadowTopOffset - > setValue ( 80 ) ;
shadowLeftOffset - > setValue ( 0 ) ;
activeWindowOpacity - > setEnabled ( false ) ;
inactiveWindowOpacity - > setEnabled ( true ) ;
movingWindowOpacity - > setEnabled ( false ) ;
dockWindowOpacity - > setEnabled ( true ) ;
2006-02-19 01:33:48 +00:00
useShadows - > setChecked ( true ) ;
removeShadowsOnMove - > setChecked ( false ) ;
removeShadowsOnResize - > setChecked ( false ) ;
2005-01-15 17:07:48 +00:00
shadowColor - > setColor ( Qt : : black ) ;
2006-02-19 01:33:48 +00:00
fadeInWindows - > setChecked ( true ) ;
fadeOnOpacityChange - > setChecked ( false ) ;
2005-02-09 18:31:35 +00:00
fadeInSpeed - > setValue ( 70 ) ;
fadeOutSpeed - > setValue ( 20 ) ;
2005-01-15 17:07:48 +00:00
emit KCModule : : changed ( true ) ;
}
bool KTranslucencyConfig : : kompmgrAvailable ( )
{
bool ret ;
KProcess proc ;
proc < < " kompmgr " < < " -v " ;
ret = proc . start ( KProcess : : DontCare , KProcess : : AllOutput ) ;
proc . detach ( ) ;
return ret ;
}
void KTranslucencyConfig : : showWarning ( bool alphaActivated )
{
if ( alphaActivated )
2005-01-29 10:40:39 +00:00
KMessageBox : : information ( this , i18n ( " <qt>Translucency support is new and may cause problems<br> including crashes (sometimes the translucency engine, seldom even X).</qt> " ) , i18n ( " Warning " ) ) ;
2005-01-15 17:07:48 +00:00
}
2002-01-16 12:26:03 +00:00
# include "windows.moc"