//
// C++ Implementation: komposepreferences
//
// Description:
//
//
// Author: Hans Oischinger <oisch@sourceforge.net>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
# include "komposepreferences.h"
# include "komposesettings.h"
# include <tqlayout.h>
# include <tqcheckbox.h>
# include <tqlabel.h>
# include <tdeapplication.h>
# include <tqwhatsthis.h>
# include <tqtooltip.h>
# include <tqspinbox.h>
# include <tqgroupbox.h>
# include <tqbuttongroup.h>
# include <tqhbox.h>
# include <tqslider.h>
# include <tqpushbutton.h>
# include <tqgrid.h>
# include <tqvgroupbox.h>
# include <tqradiobutton.h>
# include <kiconloader.h>
# include <kcolorbutton.h>
# include <tdefontdialog.h>
KomposePreferences : : KomposePreferences ( )
: KDialogBase ( IconList , i18n ( TQString : : fromUtf8 ( " Komposé Preferences " ) . utf8 ( ) ) , Ok | Apply | Cancel , Ok )
{
TQFrame * page1 = addPage ( i18n ( " Behavior " ) , TQString : : null , DesktopIcon ( " winprops " , TDEIcon : : SizeMedium ) ) ;
TQFrame * page2 = addPage ( i18n ( " Appearance " ) , TQString : : null , DesktopIcon ( " appearance " , TDEIcon : : SizeMedium ) ) ;
TQFrame * page3 = addPage ( i18n ( " Layouts " ) , TQString : : null , DesktopIcon ( " window_list " , TDEIcon : : SizeMedium ) ) ;
TQVBoxLayout * page1Layout = new TQVBoxLayout ( page1 , 0 , KDialog : : spacingHint ( ) ) ;
defaultViewBtnGroup = new TQButtonGroup ( 2 , Horizontal , i18n ( " Default Layout " ) , page1 ) ;
defaultViewBtnGroup - > setExclusive ( true ) ;
TQString defaultViewBtnGroupHelp = i18n ( " Determines which view should be started by default (e.g. when you click on the systray icon). " ) ;
TQWhatsThis : : add ( defaultViewBtnGroup , defaultViewBtnGroupHelp ) ;
TQToolTip : : add ( defaultViewBtnGroup , defaultViewBtnGroupHelp ) ;
defaultViewWorld = new TQRadioButton ( i18n ( " Ungrouped " ) , defaultViewBtnGroup ) ;
TQString defaultViewWorldHelp = i18n ( " Fullscreen layout that shows all windows in no specific order " ) ;
TQWhatsThis : : add ( defaultViewWorld , defaultViewWorldHelp ) ;
TQToolTip : : add ( defaultViewWorld , defaultViewWorldHelp ) ;
defaultViewVirtualDesks = new TQRadioButton ( i18n ( " Grouped by virtual desktops " ) , defaultViewBtnGroup ) ;
TQString defaultViewVirtualDesksHelp = i18n ( " Fullscreen layout that shows a representation of your virtual desktops \n and places the windows inside. " ) ;
TQWhatsThis : : add ( defaultViewVirtualDesks , defaultViewVirtualDesksHelp ) ;
TQToolTip : : add ( defaultViewVirtualDesks , defaultViewVirtualDesksHelp ) ;
page1Layout - > addWidget ( defaultViewBtnGroup ) ;
TQGroupBox * screenshotsGroupBox = new TQGroupBox ( 3 , Vertical , i18n ( " Screenshots " ) , page1 ) ;
passiveScreenshots = new TQCheckBox ( i18n ( " Passive screenshots " ) , screenshotsGroupBox ) ;
TQString passiveScreenshotsHelp = i18n ( TQString : : fromUtf8 ( " Create a screenshot whenever you raise or active a window. \n When selected the amount the annoying popup-effect before every Komposé activation will be minimized to nearly zero. \n The drawback is that the screenshots are not so recent and may not display the actual content. " ) . utf8 ( ) ) ;
TQWhatsThis : : add ( passiveScreenshots , passiveScreenshotsHelp ) ;
TQToolTip : : add ( passiveScreenshots , passiveScreenshotsHelp ) ;
// onlyOneScreenshot = new TQCheckBox(i18n("Only grab a screenshot when none exists"), screenshotsGroupBox);
// TQString onlyOneScreenshotHelp = i18n("When disabled new screenshots will be taken whenever possible.\nEnabling will only create a screenshot once the application is first activated and will never update it.");
// TQWhatsThis::add( onlyOneScreenshot, onlyOneScreenshotHelp );
// TQToolTip::add( onlyOneScreenshot, onlyOneScreenshotHelp );
TQHBox * hLayScreenshotGrabDelay = new TQHBox ( screenshotsGroupBox ) ;
TQLabel * screenshotGrabDelayLabel = new TQLabel ( i18n ( " Delay between screenshots (ms): " ) , hLayScreenshotGrabDelay ) ;
screenshotGrabDelay = new TQSpinBox ( 0 , 2000 , 1 , hLayScreenshotGrabDelay ) ;
screenshotGrabDelayLabel - > setBuddy ( screenshotGrabDelay ) ;
TQString screenshotGrabDelayHelp = i18n ( " Specifies the time to wait between the activation of a window and the screenshot taking. \n Increase it when your windows need more time to draw themselves after activation. \n Values below 300ms are not recommended, but may work in some cases. " ) ;
TQWhatsThis : : add ( screenshotGrabDelay , screenshotGrabDelayHelp ) ;
TQToolTip : : add ( screenshotGrabDelay , screenshotGrabDelayHelp ) ;
TQWhatsThis : : add ( screenshotGrabDelayLabel , screenshotGrabDelayHelp ) ;
TQToolTip : : add ( screenshotGrabDelayLabel , screenshotGrabDelayHelp ) ;
page1Layout - > addWidget ( screenshotsGroupBox ) ;
page1Layout - > insertStretch ( - 1 ) ;
TQVBoxLayout * page2Layout = new TQVBoxLayout ( page2 , 0 , KDialog : : spacingHint ( ) ) ;
imageEffects = new TQCheckBox ( i18n ( " Enable image effects " ) , page2 ) ;
TQString imageEffectsHelp = i18n ( " Lighten windows when the mouse moves over it or gray out minimized windows. \n Depending on your system specs this can be a bit slower. " ) ;
TQWhatsThis : : add ( imageEffects , imageEffectsHelp ) ;
TQToolTip : : add ( imageEffects , imageEffectsHelp ) ;
page2Layout - > addWidget ( imageEffects ) ;
TQGroupBox * windowTitleGroupBox = new TQGroupBox ( 3 , Vertical , i18n ( " Window Titles " ) , page2 ) ;
TQHBox * hBoxWindowTitles = new TQHBox ( windowTitleGroupBox ) ;
showWindowTitles = new TQCheckBox ( i18n ( " Show window titles " ) , hBoxWindowTitles ) ;
windowTitleFontBtn = new TQPushButton ( i18n ( " Select Font... " ) , hBoxWindowTitles ) ;
TQString showWindowTitlesHelp = i18n ( TQString : : fromUtf8 ( " Display the name of every window in Komposé " ) ) ;
TQWhatsThis : : add ( showWindowTitles , showWindowTitlesHelp ) ;
TQToolTip : : add ( showWindowTitles , showWindowTitlesHelp ) ;
connect ( showWindowTitles , SIGNAL ( toggled ( bool ) ) , windowTitleFontBtn , SLOT ( setEnabled ( bool ) ) ) ;
connect ( windowTitleFontBtn , SIGNAL ( clicked ( ) ) , this , SLOT ( showWindowTitleFontDialog ( ) ) ) ;
TQGrid * gridWindowTitlesColor = new TQGrid ( 2 , windowTitleGroupBox ) ;
// windowTitleFontColorLabel = new TQLabel(windowTitleFontColor, i18n("Text color: "), gridWindowTitlesColor); // FIXME: How to link to a buddy that doesn't yet exist?
windowTitleFontColorLabel = new TQLabel ( i18n ( " Text color: " ) , gridWindowTitlesColor ) ;
windowTitleFontColor = new KColorButton ( TQt : : black , gridWindowTitlesColor ) ;
connect ( showWindowTitles , SIGNAL ( toggled ( bool ) ) , windowTitleFontColorLabel , SLOT ( setEnabled ( bool ) ) ) ;
connect ( showWindowTitles , SIGNAL ( toggled ( bool ) ) , windowTitleFontColor , SLOT ( setEnabled ( bool ) ) ) ;
showWindowTitleShadow = new TQCheckBox ( i18n ( " Shadow color: " ) , gridWindowTitlesColor ) ;
windowTitleFontShadowColor = new KColorButton ( TQt : : lightGray , gridWindowTitlesColor ) ;
connect ( showWindowTitles , SIGNAL ( toggled ( bool ) ) , showWindowTitleShadow , SLOT ( setEnabled ( bool ) ) ) ;
connect ( showWindowTitles , SIGNAL ( toggled ( bool ) ) , windowTitleFontShadowColor , SLOT ( setEnabled ( bool ) ) ) ;
connect ( showWindowTitleShadow , SIGNAL ( toggled ( bool ) ) , windowTitleFontShadowColor , SLOT ( setEnabled ( bool ) ) ) ;
page2Layout - > addWidget ( windowTitleGroupBox ) ;
TQGroupBox * iconGroupBox = new TQGroupBox ( 3 , Vertical , i18n ( " Task Icons " ) , page2 ) ;
showIcons = new TQCheckBox ( i18n ( " Show icons " ) , iconGroupBox ) ;
iconSize = new TQSlider ( 0 , 3 , 1 , 0 , TQt : : Horizontal , iconGroupBox ) ;
iconSizeDescription = new TQLabel ( iconSize , " " , iconGroupBox ) ;
connect ( iconSize , SIGNAL ( sliderMoved ( int ) ) , this , SLOT ( updateIconSliderDesc ( int ) ) ) ;
connect ( iconSize , SIGNAL ( valueChanged ( int ) ) , this , SLOT ( updateIconSliderDesc ( int ) ) ) ;
connect ( showIcons , SIGNAL ( toggled ( bool ) ) , iconSize , SLOT ( setEnabled ( bool ) ) ) ;
connect ( showIcons , SIGNAL ( toggled ( bool ) ) , iconSizeDescription , SLOT ( setEnabled ( bool ) ) ) ;
page2Layout - > addWidget ( iconGroupBox ) ;
page2Layout - > insertStretch ( - 1 ) ;
TQVBoxLayout * page3Layout = new TQVBoxLayout ( page3 , 0 , KDialog : : spacingHint ( ) ) ;
TQVGroupBox * virtDesksLayoutGroupBox = new TQVGroupBox ( i18n ( " Grouped by Virtual Desktops " ) , page3 ) ;
dynamicVirtDeskLayout = new TQCheckBox ( i18n ( " Layout empty virtual desktops minimized " ) , virtDesksLayoutGroupBox ) ;
TQString dynamicVirtDeskLayoutHelp = i18n ( " Check this if you want empty virtual desktops to take less space on the screen. \n Uncheck it if you want them to be arranged statically, each of the same size. " ) ;
TQWhatsThis : : add ( dynamicVirtDeskLayout , dynamicVirtDeskLayoutHelp ) ;
TQToolTip : : add ( dynamicVirtDeskLayout , dynamicVirtDeskLayoutHelp ) ;
TQGrid * desktopColorsGroupBox = new TQGrid ( 2 , virtDesksLayoutGroupBox ) ;
desktopColorsGroupBox - > setSpacing ( 4 ) ;
tintVirtDesks = new TQCheckBox ( i18n ( " Tint virtual desktop widgets: " ) , desktopColorsGroupBox ) ;
tintVirtDesksColor = new KColorButton ( TQt : : blue , desktopColorsGroupBox ) ;
TQString tintVirtDesksHelp = i18n ( " Colorize the transparent background of the virtual desktop widgets " ) ;
TQWhatsThis : : add ( tintVirtDesks , tintVirtDesksHelp ) ;
TQToolTip : : add ( tintVirtDesks , tintVirtDesksHelp ) ;
TQWhatsThis : : add ( tintVirtDesksColor , tintVirtDesksHelp ) ;
TQToolTip : : add ( tintVirtDesksColor , tintVirtDesksHelp ) ;
connect ( tintVirtDesks , SIGNAL ( toggled ( bool ) ) , tintVirtDesksColor , SLOT ( setEnabled ( bool ) ) ) ;
desktopTitleFontColorLabel = new TQLabel ( i18n ( " Desktop frame color: " ) , desktopColorsGroupBox ) ;
desktopTitleFontColor = new KColorButton ( TQt : : black , desktopColorsGroupBox ) ;
desktopTitleFontHighlightColorLabel = new TQLabel ( i18n ( " Desktop frame highlight color: " ) , desktopColorsGroupBox ) ;
desktopTitleFontHighlightColor = new KColorButton ( TQt : : black , desktopColorsGroupBox ) ;
page3Layout - > addWidget ( virtDesksLayoutGroupBox ) ;
desktopTitleFontBtn = new TQPushButton ( i18n ( " Select Desktop Names Font... " ) , virtDesksLayoutGroupBox ) ;
connect ( desktopTitleFontBtn , SIGNAL ( clicked ( ) ) , this , SLOT ( showDesktopTitleFontDialog ( ) ) ) ;
page3Layout - > insertStretch ( - 1 ) ;
fillPages ( ) ;
}
KomposePreferences : : ~ KomposePreferences ( )
{ }
void KomposePreferences : : updateIconSliderDesc ( int val )
{
switch ( val )
{
case 0 :
iconSizeDescription - > setText ( i18n ( " 16x16 " ) ) ;
break ;
case 1 :
iconSizeDescription - > setText ( i18n ( " 32x32 " ) ) ;
break ;
case 2 :
iconSizeDescription - > setText ( i18n ( " 64x64 " ) ) ;
break ;
case 3 :
iconSizeDescription - > setText ( i18n ( " Don't scale, show as they are (preferably bigger) " ) ) ;
break ;
}
}
void KomposePreferences : : showWindowTitleFontDialog ( )
{
TDEFontDialog : : getFont ( * windowTitleFont ) ;
// if ( result == TDEFontDialog::Accepted )
}
void KomposePreferences : : showDesktopTitleFontDialog ( )
{
TDEFontDialog : : getFont ( * desktopTitleFont ) ;
}
void KomposePreferences : : fillPages ( )
{
// Sync Settings to Preferences dialog
switch ( KomposeSettings : : instance ( ) - > getDefaultView ( ) )
{
case KOMPOSEDISPLAY_VIRTUALDESKS :
defaultViewVirtualDesks - > setChecked ( true ) ;
break ;
case KOMPOSEDISPLAY_WORLD :
defaultViewWorld - > setChecked ( true ) ;
break ;
}
passiveScreenshots - > setChecked ( KomposeSettings : : instance ( ) - > getPassiveScreenshots ( ) ) ;
screenshotGrabDelay - > setValue ( KomposeSettings : : instance ( ) - > getScreenshotGrabDelay ( ) / 1000000 ) ;
dynamicVirtDeskLayout - > setChecked ( KomposeSettings : : instance ( ) - > getDynamicVirtDeskLayout ( ) ) ;
imageEffects - > setChecked ( KomposeSettings : : instance ( ) - > getImageEffects ( ) ) ;
tintVirtDesks - > setChecked ( KomposeSettings : : instance ( ) - > getTintVirtDesks ( ) ) ;
tintVirtDesksColor - > setColor ( KomposeSettings : : instance ( ) - > getTintVirtDesksColor ( ) ) ;
tintVirtDesksColor - > setEnabled ( KomposeSettings : : instance ( ) - > getTintVirtDesks ( ) ) ;
showWindowTitles - > setChecked ( KomposeSettings : : instance ( ) - > getShowWindowTitles ( ) ) ;
windowTitleFont = new TQFont ( KomposeSettings : : instance ( ) - > getWindowTitleFont ( ) ) ;
windowTitleFontColor - > setColor ( KomposeSettings : : instance ( ) - > getWindowTitleFontColor ( ) ) ;
windowTitleFontShadowColor - > setColor ( KomposeSettings : : instance ( ) - > getWindowTitleFontShadowColor ( ) ) ;
showWindowTitleShadow - > setChecked ( KomposeSettings : : instance ( ) - > getShowWindowTitleShadow ( ) ) ;
// Disable dependant widgets
windowTitleFontBtn - > setEnabled ( KomposeSettings : : instance ( ) - > getShowWindowTitles ( ) ) ;
windowTitleFontColorLabel - > setEnabled ( KomposeSettings : : instance ( ) - > getShowWindowTitles ( ) ) ;
windowTitleFontColor - > setEnabled ( KomposeSettings : : instance ( ) - > getShowWindowTitles ( ) ) ;
showWindowTitleShadow - > setEnabled ( KomposeSettings : : instance ( ) - > getShowWindowTitles ( ) ) ;
windowTitleFontShadowColor - > setEnabled ( KomposeSettings : : instance ( ) - > getShowWindowTitles ( ) | | KomposeSettings : : instance ( ) - > getShowWindowTitleShadow ( ) ) ;
desktopTitleFont = new TQFont ( KomposeSettings : : instance ( ) - > getDesktopTitleFont ( ) ) ;
desktopTitleFontColor - > setColor ( KomposeSettings : : instance ( ) - > getDesktopTitleFontColor ( ) ) ;
desktopTitleFontHighlightColor - > setColor ( KomposeSettings : : instance ( ) - > getDesktopTitleFontHighlightColor ( ) ) ;
showIcons - > setChecked ( KomposeSettings : : instance ( ) - > getShowIcons ( ) ) ;
iconSize - > setValue ( KomposeSettings : : instance ( ) - > getIconSize ( ) ) ;
iconSize - > setEnabled ( showIcons - > isChecked ( ) ) ;
iconSizeDescription - > setEnabled ( showIcons - > isChecked ( ) ) ;
updateIconSliderDesc ( iconSize - > value ( ) ) ;
}
void KomposePreferences : : slotApply ( )
{
KomposeSettings : : instance ( ) - > setDefaultView ( defaultViewBtnGroup - > selectedId ( ) ) ;
KomposeSettings : : instance ( ) - > setPassiveScreenshots ( passiveScreenshots - > isChecked ( ) ) ;
KomposeSettings : : instance ( ) - > setScreenshotGrabDelay ( screenshotGrabDelay - > value ( ) * 1000000 ) ;
KomposeSettings : : instance ( ) - > setDynamicVirtDeskLayout ( dynamicVirtDeskLayout - > isChecked ( ) ) ;
KomposeSettings : : instance ( ) - > setImageEffects ( imageEffects - > isChecked ( ) ) ;
KomposeSettings : : instance ( ) - > setTintVirtDesks ( tintVirtDesks - > isChecked ( ) ) ;
KomposeSettings : : instance ( ) - > setTintVirtDesksColor ( tintVirtDesksColor - > color ( ) ) ;
KomposeSettings : : instance ( ) - > setShowWindowTitles ( showWindowTitles - > isChecked ( ) ) ;
KomposeSettings : : instance ( ) - > setWindowTitleFont ( * windowTitleFont ) ;
KomposeSettings : : instance ( ) - > setWindowTitleFontColor ( windowTitleFontColor - > color ( ) ) ;
KomposeSettings : : instance ( ) - > setWindowTitleFontShadowColor ( windowTitleFontShadowColor - > color ( ) ) ;
KomposeSettings : : instance ( ) - > setShowWindowTitleShadow ( showWindowTitleShadow - > isChecked ( ) ) ;
KomposeSettings : : instance ( ) - > setDesktopTitleFont ( * desktopTitleFont ) ;
KomposeSettings : : instance ( ) - > setDesktopTitleFontColor ( desktopTitleFontColor - > color ( ) ) ;
KomposeSettings : : instance ( ) - > setDesktopTitleFontHighlightColor ( desktopTitleFontHighlightColor - > color ( ) ) ;
KomposeSettings : : instance ( ) - > setShowIcons ( showIcons - > isChecked ( ) ) ;
KomposeSettings : : instance ( ) - > setIconSize ( iconSize - > value ( ) ) ;
KomposeSettings : : instance ( ) - > writeConfig ( ) ;
KDialogBase : : slotApply ( ) ;
}
void KomposePreferences : : slotOk ( )
{
slotApply ( ) ;
KDialogBase : : slotOk ( ) ;
}
# include "komposepreferences.moc"