From ac9c37c64dc0b82093b7cf3720c085df9f45052a Mon Sep 17 00:00:00 2001 From: Lucas Murray Date: Fri, 27 Feb 2009 15:40:53 +0000 Subject: [PATCH] Merged "active screen edges" and "active desktop borders" into a single GUI panel. This panel is currently located in System Settings -> Desktop -> Screen Edges. BUG: 174709 svn path=/trunk/KDE/kdebase/workspace/; revision=932929 --- kcmkwin/CMakeLists.txt | 9 +- kcmkwin/kwincompositing/CMakeLists.txt | 1 - kcmkwin/kwincompositing/main.cpp | 154 +----- kcmkwin/kwincompositing/main.h | 18 - kcmkwin/kwincompositing/main.ui | 466 +++++++----------- kcmkwin/kwinoptions/windows.cpp | 92 +--- kcmkwin/kwinoptions/windows.h | 15 - kcmkwin/kwinscreenedges/CMakeLists.txt | 40 ++ kcmkwin/kwinscreenedges/Messages.sh | 4 + .../kwinscreenedges/kwinscreenedges.desktop | 18 + kcmkwin/kwinscreenedges/main.cpp | 418 ++++++++++++++++ kcmkwin/kwinscreenedges/main.h | 95 ++++ kcmkwin/kwinscreenedges/main.ui | 277 +++++++++++ .../monitor.cpp | 27 + .../monitor.h | 6 + 15 files changed, 1076 insertions(+), 564 deletions(-) create mode 100644 kcmkwin/kwinscreenedges/CMakeLists.txt create mode 100644 kcmkwin/kwinscreenedges/Messages.sh create mode 100644 kcmkwin/kwinscreenedges/kwinscreenedges.desktop create mode 100644 kcmkwin/kwinscreenedges/main.cpp create mode 100644 kcmkwin/kwinscreenedges/main.h create mode 100644 kcmkwin/kwinscreenedges/main.ui rename kcmkwin/{kwincompositing => kwinscreenedges}/monitor.cpp (88%) rename kcmkwin/{kwincompositing => kwinscreenedges}/monitor.h (89%) diff --git a/kcmkwin/CMakeLists.txt b/kcmkwin/CMakeLists.txt index 4b17ed9b52..db24789b86 100644 --- a/kcmkwin/CMakeLists.txt +++ b/kcmkwin/CMakeLists.txt @@ -1,6 +1,7 @@ -add_subdirectory( kwinoptions ) -add_subdirectory( kwindecoration ) -add_subdirectory( kwinrules ) +add_subdirectory( kwinoptions ) +add_subdirectory( kwindecoration ) +add_subdirectory( kwinrules ) add_subdirectory( kwincompositing ) -add_subdirectory( kwindesktop ) +add_subdirectory( kwindesktop ) +add_subdirectory( kwinscreenedges ) diff --git a/kcmkwin/kwincompositing/CMakeLists.txt b/kcmkwin/kwincompositing/CMakeLists.txt index 5c079d26cc..98ca6e54cf 100644 --- a/kcmkwin/kwincompositing/CMakeLists.txt +++ b/kcmkwin/kwincompositing/CMakeLists.txt @@ -5,7 +5,6 @@ include_directories( ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin ) set(kcm_kwincompositing_PART_SRCS main.cpp ktimerdialog.cpp - monitor.cpp ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin/compositingprefs.cpp ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin/lib/kwinglobals.cpp ) diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp index e715a96e17..3f6b976d8c 100644 --- a/kcmkwin/kwincompositing/main.cpp +++ b/kcmkwin/kwincompositing/main.cpp @@ -79,7 +79,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList layout()->setMargin(0); ui.tabWidget->setCurrentIndex(0); ui.statusTitleWidget->hide(); - setupElectricBorders(); #define OPENGL_INDEX 0 #define XRENDER_INDEX 1 @@ -111,9 +110,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList connect(ui.desktopSwitchingCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); connect(ui.animationSpeedCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(ui.edges_monitor, SIGNAL(changed()), this, SLOT(changed())); - connect(ui.edges_monitor, SIGNAL(edgeSelectionChanged(int,int)), this, SLOT(electricBorderSelectionChanged(int,int))); - connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(compositingModeChanged())); connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); connect(ui.windowThumbnails, SIGNAL(activated(int)), this, SLOT(changed())); @@ -215,7 +211,6 @@ void KWinCompositingConfig::compositingEnabled( bool enabled ) ui.compositingOptionsContainer->setEnabled(enabled); ui.tabWidget->setTabEnabled(1, enabled); ui.tabWidget->setTabEnabled(2, enabled); - ui.tabWidget->setTabEnabled(3, enabled); } void KWinCompositingConfig::showConfirmDialog( bool reinitCompositing ) @@ -288,7 +283,7 @@ void KWinCompositingConfig::currentTabChanged(int tab) saveEffectsTab(); loadGeneralTab(); } - else if ( tab == 2 ) + else if ( tab == 1 ) { // Effects tab was activated saveGeneralTab(); @@ -397,7 +392,6 @@ void KWinCompositingConfig::load() tmpconfig.writeEntry(it.key(), it.value()); loadGeneralTab(); - loadElectricBorders(); loadEffectsTab(); loadAdvancedTab(); @@ -563,7 +557,6 @@ void KWinCompositingConfig::save() loadGeneralTab(); saveGeneralTab(); } - saveElectricBorders(); bool advancedChanged = saveAdvancedTab(); // Copy Plugins group from temp config to real config @@ -649,14 +642,6 @@ void KWinCompositingConfig::defaults() ui.glDirect->setChecked( mDefaultPrefs.enableDirectRendering() ); ui.glVSync->setChecked( mDefaultPrefs.enableVSync() ); ui.xrenderSmoothScale->setChecked( false ); - - for( int i=0; i<8; i++ ) - { - // set all edges to no effect - ui.edges_monitor->selectEdgeItem( i, 0 ); - } - // set top left to present windows - ui.edges_monitor->selectEdgeItem( (int)Monitor::TopLeft, (int)PresentWindowsAll ); } QString KWinCompositingConfig::quickHelp() const @@ -664,143 +649,6 @@ QString KWinCompositingConfig::quickHelp() const return i18n("

Desktop Effects

"); } -void KWinCompositingConfig::setupElectricBorders() - { - addItemToEdgesMonitor( i18n("No Effect")); - - // search the effect names - KServiceTypeTrader* trader = KServiceTypeTrader::self(); - KService::List services; - services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_presentwindows'"); - if( !services.isEmpty() ) - { - addItemToEdgesMonitor( services.first()->name() + " - " + i18n( "All Desktops" )); - addItemToEdgesMonitor( services.first()->name() + " - " + i18n( "Current Desktop" )); - } - services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_desktopgrid'"); - if( !services.isEmpty() ) - addItemToEdgesMonitor( services.first()->name()); - services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_cube'"); - if( !services.isEmpty() ) - { - addItemToEdgesMonitor( services.first()->name() + " - " + i18n( "Cube") ); - addItemToEdgesMonitor( services.first()->name() + " - " + i18n( "Cylinder") ); - addItemToEdgesMonitor( services.first()->name() + " - " + i18n( "Sphere") ); - } - } - -void KWinCompositingConfig::addItemToEdgesMonitor(const QString& item) - { - for( int i=0; i<8; i++ ) - ui.edges_monitor->addEdgeItem( i, item ); - } - -void KWinCompositingConfig::electricBorderSelectionChanged(int edge, int index) - { - if( index == (int)NoEffect ) - return; - for( int i=0; i<8; i++) - { - if( i == edge ) - continue; - if( ui.edges_monitor->selectedEdgeItem( i ) == index ) - ui.edges_monitor->selectEdgeItem( i, (int)NoEffect ); - } - } - - -void KWinCompositingConfig::loadElectricBorders() - { - // Present Windows - KConfigGroup presentwindowsconfig(mKWinConfig, "Effect-PresentWindows"); - changeElectricBorder( (ElectricBorder)presentwindowsconfig.readEntry( "BorderActivateAll", - int( ElectricTopLeft )), (int)PresentWindowsAll ); - changeElectricBorder( (ElectricBorder)presentwindowsconfig.readEntry( "BorderActivate", - int( ElectricNone )), (int)PresentWindowsCurrent ); - // Desktop Grid - KConfigGroup gridconfig(mKWinConfig, "Effect-DesktopGrid"); - changeElectricBorder( (ElectricBorder)gridconfig.readEntry( "BorderActivate", - int( ElectricNone )), (int)DesktopGrid ); - // Desktop Cube - KConfigGroup cubeconfig(mKWinConfig, "Effect-Cube"); - changeElectricBorder( (ElectricBorder)cubeconfig.readEntry( "BorderActivate", - int( ElectricNone )), (int)Cube ); - changeElectricBorder( (ElectricBorder)cubeconfig.readEntry( "BorderActivateCylinder", - int( ElectricNone )), (int)Cylinder ); - changeElectricBorder( (ElectricBorder)cubeconfig.readEntry( "BorderActivateSphere", - int( ElectricNone )), (int)Sphere ); - } - -void KWinCompositingConfig::changeElectricBorder( ElectricBorder border, int index ) - { - switch (border) - { - case ElectricTop: - ui.edges_monitor->selectEdgeItem( (int)Monitor::Top, index ); - break; - case ElectricTopRight: - ui.edges_monitor->selectEdgeItem( (int)Monitor::TopRight, index ); - break; - case ElectricRight: - ui.edges_monitor->selectEdgeItem( (int)Monitor::Right, index ); - break; - case ElectricBottomRight: - ui.edges_monitor->selectEdgeItem( (int)Monitor::BottomRight, index ); - break; - case ElectricBottom: - ui.edges_monitor->selectEdgeItem( (int)Monitor::Bottom, index ); - break; - case ElectricBottomLeft: - ui.edges_monitor->selectEdgeItem( (int)Monitor::BottomLeft, index ); - break; - case ElectricLeft: - ui.edges_monitor->selectEdgeItem( (int)Monitor::Left, index ); - break; - case ElectricTopLeft: - ui.edges_monitor->selectEdgeItem( (int)Monitor::TopLeft, index ); - break; - default: - // nothing - break; - } - } - -ElectricBorder KWinCompositingConfig::checkEffectHasElectricBorder( int index ) - { - if( ui.edges_monitor->selectedEdgeItem( (int)Monitor::Top ) == index ) - return ElectricTop; - if( ui.edges_monitor->selectedEdgeItem( (int)Monitor::TopRight ) == index ) - return ElectricTopRight; - if( ui.edges_monitor->selectedEdgeItem( (int)Monitor::Right ) == index ) - return ElectricRight; - if( ui.edges_monitor->selectedEdgeItem( (int)Monitor::BottomRight ) == index ) - return ElectricBottomRight; - if( ui.edges_monitor->selectedEdgeItem( (int)Monitor::Bottom ) == index ) - return ElectricBottom; - if( ui.edges_monitor->selectedEdgeItem( (int)Monitor::BottomLeft ) == index ) - return ElectricBottomLeft; - if( ui.edges_monitor->selectedEdgeItem( (int)Monitor::Left ) == index ) - return ElectricLeft; - if( ui.edges_monitor->selectedEdgeItem( (int)Monitor::TopLeft ) == index ) - return ElectricTopLeft; - return ElectricNone; - } - -void KWinCompositingConfig::saveElectricBorders() -{ - KConfigGroup presentwindowsconfig(mKWinConfig, "Effect-PresentWindows"); - presentwindowsconfig.writeEntry( "BorderActivateAll", (int)checkEffectHasElectricBorder( (int)PresentWindowsAll )); - presentwindowsconfig.writeEntry( "BorderActivate", (int)checkEffectHasElectricBorder( (int)PresentWindowsCurrent )); - - KConfigGroup gridconfig(mKWinConfig, "Effect-DesktopGrid"); - gridconfig.writeEntry( "BorderActivate", (int)checkEffectHasElectricBorder( (int)DesktopGrid )); - - KConfigGroup cubeconfig(mKWinConfig, "Effect-Cube"); - cubeconfig.writeEntry( "BorderActivate", (int)checkEffectHasElectricBorder( (int)Cube )); - cubeconfig.writeEntry( "BorderActivateCylinder", (int)checkEffectHasElectricBorder( (int)Cylinder )); - cubeconfig.writeEntry( "BorderActivateSphere", (int)checkEffectHasElectricBorder( (int)Sphere )); -} - } // namespace #include "main.moc" diff --git a/kcmkwin/kwincompositing/main.h b/kcmkwin/kwincompositing/main.h index 6e9c0dfe87..d9b7db9693 100644 --- a/kcmkwin/kwincompositing/main.h +++ b/kcmkwin/kwincompositing/main.h @@ -65,22 +65,15 @@ class KWinCompositingConfig : public KCModule void loadGeneralTab(); void loadEffectsTab(); void loadAdvancedTab(); - void loadElectricBorders(); void saveGeneralTab(); void saveEffectsTab(); bool saveAdvancedTab(); - void electricBorderSelectionChanged(int edge, int index); void configChanged(bool reinitCompositing); void initEffectSelector(); private: bool effectEnabled( const QString& effect, const KConfigGroup& cfg ) const; - void setupElectricBorders(); - void addItemToEdgesMonitor(const QString& item); - void changeElectricBorder( ElectricBorder border, int index ); - ElectricBorder checkEffectHasElectricBorder( int index ); - void saveElectricBorders(); KSharedConfigPtr mKWinConfig; Ui::KWinCompositingConfig ui; @@ -90,17 +83,6 @@ class KWinCompositingConfig : public KCModule KTemporaryFile mTmpConfigFile; KSharedConfigPtr mTmpConfig; bool m_showConfirmDialog; - - enum ElectricBorderEffects - { - NoEffect, - PresentWindowsAll, - PresentWindowsCurrent, - DesktopGrid, - Cube, - Cylinder, - Sphere - }; }; } // namespace diff --git a/kcmkwin/kwincompositing/main.ui b/kcmkwin/kwincompositing/main.ui index 5d7e35dbb9..179ff901c0 100644 --- a/kcmkwin/kwincompositing/main.ui +++ b/kcmkwin/kwincompositing/main.ui @@ -1,7 +1,8 @@ - + + KWinCompositingConfig - - + + 0 0 @@ -9,78 +10,78 @@ 554 - + - - + + 0 - - + + General - + - + - - - Enable desktop effects + + + Enable desktop effects - + true - - - - - + + + + + Common Settings - - - - + + + + Improved window management - + true - - - + + + Shadows - + true - - - + + + Various animations - + true - - - + + + Qt::Vertical - + QSizePolicy::Fixed - + 20 20 @@ -88,71 +89,71 @@ - - - - You can find more effects, as well as effect-specific settings, in the "All Effects" tab above. + + + + You can find more effects, as well as effect-specific settings, in the "All Effects" tab above. - + true - - - + + + Effect for window switching: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + windowSwitchingCombo - - - - + + + + 0 0 - - - + + + Effect for desktop switching: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + desktopSwitchingCombo - - - - + + + + 0 0 - - - + + + Qt::Vertical - + QSizePolicy::Fixed - + 20 20 @@ -160,63 +161,63 @@ - - - - + + + + 0 0 - + 3 - + Instant - + Very Fast - + Fast - + Normal - + Slow - + Very Slow - + Extremely Slow - - - + + + Animation speed: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + animationSpeedCombo @@ -225,17 +226,14 @@ - groupBox - - advancedOptions - + Qt::Vertical - + 20 0 @@ -245,120 +243,25 @@ - - - Screen Edges - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - Qt::StrongFocus - - - - - - - Active screen edges allow you to activate effects by pushing your mouse cursor against the edge of the screen. Here you can configure which effect will get activated on each edge and corner of the screen. - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - If you are looking for the setting to enable switching of desktops by pushing your mouse cursor against the edge of the screen you can find it in the "Window Behavior" advanced tab under the name of "Active Desktop Borders". - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - + + All Effects - + - - + + Hint: To find out or configure how to activate an effect, look at the effect's settings. - + true - - - + + + 0 0 @@ -367,215 +270,215 @@ - - + + Advanced - - - - - + + + + + 0 0 - + Compositing type: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + compositingType - - - - + + + + 1 0 - + OpenGL - + XRender - - - - + + + + 0 0 - + Keep window thumbnails: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + windowThumbnails - - - - + + + + 1 0 - + Always - + Only for Shown Windows - + Never - - - + + + Enabling this option allows compositing to be activated even if some of the internal checks fail. Doing so may make the whole desktop unusable and its use is not recommened. Use only if KWin refuses to activate compositing on a system that should be capable of compositing. - + Disable functionality checks - - - + + + OpenGL Options - - - - - + + + + + 0 0 - + OpenGL mode: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + glMode - - - - + + + + 1 0 - + Texture From Pixmap - + Shared Memory - + Fallback - - - - + + + + 0 0 - + Texture filter: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + glTextureFilter - - - - + + + + 1 0 - + Nearest (fastest) - + Bilinear - + Trilinear (best quality) - - - + + + Enable direct rendering - + false - - - + + + Use VSync - + false @@ -583,15 +486,15 @@ - - - + + + XRender Options - - - - + + + + Smooth scaling (slower) @@ -599,12 +502,12 @@ - - - + + + Qt::Vertical - + 20 0 @@ -630,12 +533,6 @@
kpluginselector.h
1 - - KWin::Monitor - QWidget -
monitor.h
- 1 -
tabWidget @@ -646,7 +543,6 @@ windowSwitchingCombo desktopSwitchingCombo animationSpeedCombo - edges_monitor @@ -656,11 +552,11 @@ groupBox setEnabled(bool) - + 86 66 - + 102 156 diff --git a/kcmkwin/kwinoptions/windows.cpp b/kcmkwin/kwinoptions/windows.cpp index 88e68f5166..2ca66c8739 100644 --- a/kcmkwin/kwinoptions/windows.cpp +++ b/kcmkwin/kwinoptions/windows.cpp @@ -68,10 +68,6 @@ #define KWIN_SEPARATE_SCREEN_FOCUS "SeparateScreenFocus" #define KWIN_ACTIVE_MOUSE_SCREEN "ActiveMouseScreen" -// 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 @@ -605,7 +601,7 @@ KAdvancedConfig::KAdvancedConfig (bool _standAlone, KConfig *_config, const KCom { QString wtstr; QLabel *label; - QGridLayout *lay = new QGridLayout (this); + QVBoxLayout *lay = new QVBoxLayout (this); //iTLabel = new QLabel(i18n(" Allowed overlap:\n" // "(% of desktop space)"), @@ -647,51 +643,14 @@ KAdvancedConfig::KAdvancedConfig (bool _standAlone, KConfig *_config, const KCom kLay->addWidget(shadeHoverLabel, 1, 0); kLay->addWidget(shadeHover, 1, 1); - kLay->setRowStretch(2, 1); - lay->addWidget(shBox, 0, 0); + lay->addWidget(shBox); // Any changes goes to slotChanged() connect(shadeHoverOn, SIGNAL(toggled(bool)), SLOT(changed())); connect(shadeHover, SIGNAL(valueChanged(int)), SLOT(changed())); - electricBox = new KButtonGroup(this); - electricBox->setTitle(i18n("Active Desktop Borders")); - QGridLayout *bLay = new QGridLayout(electricBox); - - electricBox->setWhatsThis( i18n("If this option is enabled, moving the mouse to a screen border" - " will change your desktop. This is e.g. useful if you want to drag windows from one desktop" - " to the other.") ); - active_disable = new QRadioButton(i18n("D&isabled"), electricBox); - bLay->addWidget(active_disable, 0, 0, 1, 2); - active_move = new QRadioButton(i18n("Only &when moving windows"), electricBox); - bLay->addWidget(active_move, 1, 0, 1, 2); - active_always = new QRadioButton(i18n("A&lways enabled"), electricBox); - bLay->addWidget(active_always, 2, 0, 1, 2); - - delays = new KIntNumInput(10, electricBox); - delays->setRange(0, MAX_EDGE_RES, 50); - delays->setSuffix(i18n(" ms")); - delays->setWhatsThis( i18n("Here you can set a delay for switching desktops using the active" - " borders feature. Desktops will be switched after the mouse has been pushed against a screen border" - " for the specified number of milliseconds.") ); - delays->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - delaysLabel = new QLabel(i18n("Desktop &switch delay:"), this); - delaysLabel->setAlignment(Qt::AlignVCenter|Qt::AlignRight); - delaysLabel->setBuddy(delays); - bLay->addWidget(delaysLabel, 3, 0); - bLay->addWidget(delays, 3, 1); - - connect( electricBox, SIGNAL(clicked(int)), this, SLOT(setEBorders())); - - // Any changes goes to slotChanged() - connect(electricBox, SIGNAL(clicked(int)), SLOT(changed())); - connect(delays, SIGNAL(valueChanged(int)), SLOT(changed())); - - lay->addWidget(electricBox, 0, 1); - - QGridLayout *vLay = new QGridLayout(); - lay->addLayout( vLay, 1, 0, 1, 2 ); + lay->addLayout( vLay ); placementCombo = new QComboBox(this); placementCombo->setEditable( false ); @@ -740,7 +699,7 @@ KAdvancedConfig::KAdvancedConfig (bool _standAlone, KConfig *_config, const KCom vLay->addWidget( hideUtilityWindowsForInactive, 1, 0, 1, 2 ); - lay->setRowStretch(2, 1); + lay->addStretch(); load(); } @@ -773,9 +732,6 @@ void KAdvancedConfig::load( void ) setShadeHover(cg.readEntry(KWIN_SHADEHOVER, false)); setShadeHoverInterval(cg.readEntry(KWIN_SHADEHOVER_INTERVAL, 250)); - setElectricBorders(cg.readEntry(KWM_ELECTRIC_BORDER, 0)); - setElectricBorderDelay(cg.readEntry(KWM_ELECTRIC_BORDER_DELAY, 150)); - QString key; // placement policy --- CT 19jan98 --- key = cg.readEntry(KWIN_PLACEMENT); @@ -828,9 +784,6 @@ void KAdvancedConfig::save( void ) if (v<0) v = 0; cg.writeEntry(KWIN_SHADEHOVER_INTERVAL, v); - cg.writeEntry(KWM_ELECTRIC_BORDER, getElectricBorders()); - cg.writeEntry(KWM_ELECTRIC_BORDER_DELAY,getElectricBorderDelay()); - // placement policy --- CT 31jan98 --- v =getPlacement(); if (v == RANDOM_PLACEMENT) @@ -871,8 +824,6 @@ void KAdvancedConfig::defaults() { setShadeHover(false); setShadeHoverInterval(250); - setElectricBorders(0); - setElectricBorderDelay(150); setPlacement(SMART_PLACEMENT); setHideUtilityWindowsForInactive( true ); emit KCModule::changed(true); @@ -890,41 +841,6 @@ void KAdvancedConfig::setPlacement(int plac) } -void KAdvancedConfig::setEBorders() -{ - delaysLabel->setEnabled(!active_disable->isChecked()); - 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); -} - void KAdvancedConfig::setHideUtilityWindowsForInactive(bool s) { hideUtilityWindowsForInactive->setChecked( s ); } diff --git a/kcmkwin/kwinoptions/windows.h b/kcmkwin/kwinoptions/windows.h index d5197e1f98..3c3fbec495 100644 --- a/kcmkwin/kwinoptions/windows.h +++ b/kcmkwin/kwinoptions/windows.h @@ -198,9 +198,6 @@ public: private slots: void shadeHoverChanged(bool); - //copied from kcontrol/konq/kwindesktop, aleXXX - void setEBorders(); - void changed() { emit KCModule::changed(true); } private: @@ -217,18 +214,6 @@ private: KConfig *config; bool standAlone; - int getElectricBorders( void ); - int getElectricBorderDelay(); - void setElectricBorders( int ); - void setElectricBorderDelay( int ); - - KButtonGroup *electricBox; - QRadioButton *active_disable; - QRadioButton *active_move; - QRadioButton *active_always; - QLabel *delaysLabel; - KIntNumInput *delays; - void setHideUtilityWindowsForInactive( bool ); QCheckBox* hideUtilityWindowsForInactive; diff --git a/kcmkwin/kwinscreenedges/CMakeLists.txt b/kcmkwin/kwinscreenedges/CMakeLists.txt new file mode 100644 index 0000000000..60618c831a --- /dev/null +++ b/kcmkwin/kwinscreenedges/CMakeLists.txt @@ -0,0 +1,40 @@ +include_directories( ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin ) + +set( + kcm_kwinscreenedges_PART_SRCS + main.cpp + monitor.cpp + ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin/compositingprefs.cpp + ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin/lib/kwinglobals.cpp + ) +kde4_add_ui_files( kcm_kwinscreenedges_PART_SRCS main.ui ) +kde4_add_plugin( kcm_kwinscreenedges ${kcm_kwinscreenedges_PART_SRCS} ) +target_link_libraries( kcm_kwinscreenedges ${KDE4_KDE3SUPPORT_LIBS} ${X11_LIBRARIES} ) +install( TARGETS kcm_kwinscreenedges DESTINATION ${PLUGIN_INSTALL_DIR} ) + +# CompositingPrefs uses OpenGL +if( OPENGL_FOUND ) + target_link_libraries( kcm_kwinscreenedges ${OPENGL_gl_LIBRARY} ) +# -ldl used by OpenGL code + find_library( DL_LIBRARY dl ) + if( DL_LIBRARY ) + target_link_libraries( kcm_kwinscreenedges ${DL_LIBRARY} ) + endif( DL_LIBRARY ) +endif( OPENGL_FOUND ) +if( X11_Xrender_FOUND ) + target_link_libraries( kcm_kwinscreenedges ${X11_Xrender_LIB} ) +endif( X11_Xrender_FOUND ) +if( X11_Xrandr_FOUND ) + target_link_libraries( kcm_kwinscreenedges ${X11_Xrandr_LIB} ) +endif( X11_Xrandr_FOUND ) +if( X11_Xcomposite_FOUND ) + target_link_libraries( kcm_kwinscreenedges ${X11_Xcomposite_LIB} ) +endif( X11_Xcomposite_FOUND ) +if( X11_Xdamage_FOUND ) + target_link_libraries( kcm_kwinscreenedges ${X11_Xdamage_LIB} ) +endif( X11_Xdamage_FOUND ) +if( X11_Xfixes_FOUND ) + target_link_libraries( kcm_kwinscreenedges ${X11_Xfixes_LIB} ) +endif( X11_Xfixes_FOUND ) + +install( FILES kwinscreenedges.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/kcmkwin/kwinscreenedges/Messages.sh b/kcmkwin/kwinscreenedges/Messages.sh new file mode 100644 index 0000000000..2ab0771d80 --- /dev/null +++ b/kcmkwin/kwinscreenedges/Messages.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash +$EXTRACTRC *.ui >> rc.cpp || exit 11 +$XGETTEXT *.cpp -o $podir/kcmkwinscreenedges.pot +rm -f rc.cpp diff --git a/kcmkwin/kwinscreenedges/kwinscreenedges.desktop b/kcmkwin/kwinscreenedges/kwinscreenedges.desktop new file mode 100644 index 0000000000..bbb9c70cae --- /dev/null +++ b/kcmkwin/kwinscreenedges/kwinscreenedges.desktop @@ -0,0 +1,18 @@ +[Desktop Entry] +Exec=kcmshell4 kwinscreenedges +Icon=preferences-screen-edges +Type=Service +X-KDE-ServiceTypes=KCModule +X-DocPath=kcontrol/kwinscreenedges/index.html + +X-KDE-Library=kcm_kwinscreenedges +X-KDE-ParentApp=kcontrol + +X-KDE-System-Settings-Parent-Category=desktop +X-KDE-Weight=65 + +Name=Screen Edges + +Comment=Configure active screen edges + +X-KDE-Keywords=kwin,window,manager,effect,edge,border,action,switch,desktop diff --git a/kcmkwin/kwinscreenedges/main.cpp b/kcmkwin/kwinscreenedges/main.cpp new file mode 100644 index 0000000000..428ffb48f8 --- /dev/null +++ b/kcmkwin/kwinscreenedges/main.cpp @@ -0,0 +1,418 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2008 Martin Gräßlin +Copyright (C) 2009 Lucas Murray + +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, see . +*********************************************************************/ + +#include "kdebug.h" + +#include "main.h" + +#include + +#include +#include +#include + +K_PLUGIN_FACTORY( KWinScreenEdgesConfigFactory, registerPlugin(); ) +K_EXPORT_PLUGIN( KWinScreenEdgesConfigFactory( "kcmkwinscreenedges" )) + +namespace KWin +{ + +KWinScreenEdgesConfigForm::KWinScreenEdgesConfigForm( QWidget* parent ) + : QWidget( parent ) + { + setupUi( this ); + } + +KWinScreenEdgesConfig::KWinScreenEdgesConfig( QWidget* parent, const QVariantList& args ) + : KCModule( KWinScreenEdgesConfigFactory::componentData(), parent, args ) + , m_config( KSharedConfig::openConfig( "kwinrc" )) + { + m_ui = new KWinScreenEdgesConfigForm( this ); + QVBoxLayout* layout = new QVBoxLayout( this ); + layout->addWidget( m_ui ); + + monitorInit(); + + connect( m_ui->monitor, SIGNAL( changed() ), this, SLOT( changed() )); + connect( m_ui->monitor, SIGNAL( edgeSelectionChanged(int,int) ), + this, SLOT( monitorEdgeChanged(int,int) )); + + connect( m_ui->desktopSwitchCombo, SIGNAL( currentIndexChanged(int) ), this, SLOT( changed() )); + connect( m_ui->quickTileBox, SIGNAL( stateChanged(int) ), this, SLOT( changed() )); + connect( m_ui->quickMaximizeBox, SIGNAL( stateChanged(int) ), this, SLOT( changed() )); + connect( m_ui->activationDelaySpin, SIGNAL( valueChanged(int) ), this, SLOT( changed() )); + connect( m_ui->triggerCooldownSpin, SIGNAL( valueChanged(int) ), this, SLOT( changed() )); + + // Visual feedback of action group conflicts + connect( m_ui->desktopSwitchCombo, SIGNAL( currentIndexChanged(int) ), this, SLOT( groupChanged() )); + connect( m_ui->quickTileBox, SIGNAL( stateChanged(int) ), this, SLOT( groupChanged() )); + connect( m_ui->quickMaximizeBox, SIGNAL( stateChanged(int) ), this, SLOT( groupChanged() )); + + if( CompositingPrefs::compositingPossible() ) + m_defaultPrefs.detect(); // Driver-specific config detection + + load(); + } + +KWinScreenEdgesConfig::~KWinScreenEdgesConfig() + { + } + +void KWinScreenEdgesConfig::groupChanged() + { + // Monitor conflicts + bool hide = false; + if( m_ui->desktopSwitchCombo->currentIndex() == 2 ) + hide = true; + monitorHideEdge( ElectricTop, hide || m_ui->quickMaximizeBox->isChecked() ); + monitorHideEdge( ElectricRight, hide || m_ui->quickTileBox->isChecked() ); + monitorHideEdge( ElectricBottom, hide ); + monitorHideEdge( ElectricLeft, hide || m_ui->quickTileBox->isChecked() ); + + // Desktop switch conflicts + if( m_ui->quickTileBox->isChecked() || m_ui->quickMaximizeBox->isChecked() ) + { + m_ui->desktopSwitchLabel->setEnabled( false ); + m_ui->desktopSwitchCombo->setEnabled( false ); + m_ui->desktopSwitchCombo->setCurrentIndex( 0 ); + } + else + { + m_ui->desktopSwitchLabel->setEnabled( true ); + m_ui->desktopSwitchCombo->setEnabled( true ); + } + } + +void KWinScreenEdgesConfig::load() + { + KCModule::load(); + + monitorLoad(); + + KConfigGroup config( m_config, "Windows" ); + + m_ui->desktopSwitchCombo->setCurrentIndex( config.readEntry( "ElectricBorders", 0 )); + m_ui->quickTileBox->setChecked( config.readEntry( "QuickTile", false )); + m_ui->quickMaximizeBox->setChecked( config.readEntry( "QuickMaximize", false )); + m_ui->activationDelaySpin->setValue( config.readEntry( "ElectricBorderDelay", 150 )); + m_ui->triggerCooldownSpin->setValue( config.readEntry( "ElectricBorderCooldown", 350 )); + + emit changed( false ); + } + +void KWinScreenEdgesConfig::save() + { + KCModule::save(); + + monitorSave(); + + KConfigGroup config( m_config, "Windows" ); + + config.writeEntry( "ElectricBorders", m_ui->desktopSwitchCombo->currentIndex() ); + config.writeEntry( "QuickTile", m_ui->quickTileBox->isChecked() ); + config.writeEntry( "QuickMaximize", m_ui->quickMaximizeBox->isChecked() ); + config.writeEntry( "ElectricBorderDelay", m_ui->activationDelaySpin->value() ); + config.writeEntry( "ElectricBorderCooldown", m_ui->triggerCooldownSpin->value() ); + + config.sync(); + + // Reload KWin. + QDBusMessage message = QDBusMessage::createSignal( "/KWin", "org.kde.KWin", "reloadConfig" ); + QDBusConnection::sessionBus().send( message ); + + emit changed( false ); + } + +void KWinScreenEdgesConfig::defaults() + { + monitorDefaults(); + + m_ui->desktopSwitchCombo->setCurrentIndex( 0 ); + m_ui->quickTileBox->setChecked( false ); + m_ui->quickMaximizeBox->setChecked( false ); + m_ui->activationDelaySpin->setValue( 150 ); + m_ui->triggerCooldownSpin->setValue( 350 ); + + emit changed( true ); + } + +void KWinScreenEdgesConfig::showEvent( QShowEvent* e ) + { + KCModule::showEvent( e ); + + monitorShowEvent(); + } + +// Copied from kcmkwin/kwincompositing/main.cpp +bool KWinScreenEdgesConfig::effectEnabled( const QString& effect, const KConfigGroup& cfg ) const + { + KService::List services = KServiceTypeTrader::self()->query( + "KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_" + effect + "'"); + if( services.isEmpty()) + return false; + QVariant v = services.first()->property("X-KDE-PluginInfo-EnabledByDefault"); + return cfg.readEntry("kwin4_effect_" + effect + "Enabled", v.toBool()); + } + +//----------------------------------------------------------------------------- +// Monitor + +void KWinScreenEdgesConfig::monitorAddItem( const QString& item ) + { + for( int i = 0; i < 8; i++ ) + m_ui->monitor->addEdgeItem( i, item ); + } + +void KWinScreenEdgesConfig::monitorItemSetEnabled( int index, bool enabled ) + { + for( int i = 0; i < 8; i++ ) + m_ui->monitor->setEdgeItemEnabled( i, index, enabled ); + } + +void KWinScreenEdgesConfig::monitorInit() + { + monitorAddItem( i18n( "No Action" )); + + // Search the effect names + KServiceTypeTrader* trader = KServiceTypeTrader::self(); + KService::List services; + services = trader->query( "KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_presentwindows'" ); + if( !services.isEmpty() ) // WARNING: If this is false then all later items will have the wrong IDs + { + monitorAddItem( services.first()->name() + " - " + i18n( "All Desktops" )); + monitorAddItem( services.first()->name() + " - " + i18n( "Current Desktop" )); + } + services = trader->query( "KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_desktopgrid'" ); + if( !services.isEmpty() ) // WARNING: If this is false then all later items will have the wrong IDs + monitorAddItem( services.first()->name()); + services = trader->query( "KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_cube'" ); + if( !services.isEmpty() ) // WARNING: If this is false then all later items will have the wrong IDs + { + monitorAddItem( services.first()->name() + " - " + i18n( "Cube" )); + monitorAddItem( services.first()->name() + " - " + i18n( "Cylinder" )); + monitorAddItem( services.first()->name() + " - " + i18n( "Sphere" )); + } + + monitorShowEvent(); + } + +void KWinScreenEdgesConfig::monitorLoad() + { + // Present Windows + KConfigGroup presentWindowsConfig( m_config, "Effect-PresentWindows" ); + monitorChangeEdge( + ElectricBorder( presentWindowsConfig.readEntry( "BorderActivateAll", int( ElectricTopLeft ))), + int( PresentWindowsAll )); + monitorChangeEdge( + ElectricBorder( presentWindowsConfig.readEntry( "BorderActivate", int( ElectricNone ))), + int( PresentWindowsCurrent )); + + // Desktop Grid + KConfigGroup gridConfig( m_config, "Effect-DesktopGrid" ); + monitorChangeEdge( + ElectricBorder( gridConfig.readEntry( "BorderActivate", int( ElectricNone ))), + int( DesktopGrid )); + + // Desktop Cube + KConfigGroup cubeConfig( m_config, "Effect-Cube" ); + monitorChangeEdge( + ElectricBorder( cubeConfig.readEntry( "BorderActivate", int( ElectricNone ))), + int( Cube )); + monitorChangeEdge( + ElectricBorder( cubeConfig.readEntry( "BorderActivateCylinder", int( ElectricNone ))), + int( Cylinder )); + monitorChangeEdge( + ElectricBorder( cubeConfig.readEntry( "BorderActivateSphere", int( ElectricNone ))), + int( Sphere )); + } + +void KWinScreenEdgesConfig::monitorSave() + { + // Present Windows + KConfigGroup presentWindowsConfig( m_config, "Effect-PresentWindows" ); + presentWindowsConfig.writeEntry( "BorderActivateAll", + int( monitorCheckEffectHasEdge( int( PresentWindowsAll )))); + presentWindowsConfig.writeEntry( "BorderActivate", + int( monitorCheckEffectHasEdge( int( PresentWindowsCurrent )))); + + // Desktop Grid + KConfigGroup gridConfig( m_config, "Effect-DesktopGrid" ); + gridConfig.writeEntry( "BorderActivate", + int( monitorCheckEffectHasEdge( int( DesktopGrid )))); + + // Desktop Cube + KConfigGroup cubeConfig( m_config, "Effect-Cube" ); + cubeConfig.writeEntry( "BorderActivate", + int( monitorCheckEffectHasEdge( int( Cube )))); + cubeConfig.writeEntry( "BorderActivateCylinder", + int( monitorCheckEffectHasEdge( int( Cylinder )))); + cubeConfig.writeEntry( "BorderActivateSphere", + int( monitorCheckEffectHasEdge( int( Sphere )))); + } + +void KWinScreenEdgesConfig::monitorDefaults() + { + // Clear all edges + for( int i = 0; i < 8; i++ ) + m_ui->monitor->selectEdgeItem( i, 0 ); + + // Present windows = Top-left + m_ui->monitor->selectEdgeItem( int( Monitor::TopLeft ), int( PresentWindowsAll )); + } + +void KWinScreenEdgesConfig::monitorEdgeChanged( int edge, int index ) + { + if( index == int( NoEffect )) + return; + for( int i = 0; i < 8; i++ ) + { + if( i == edge ) + continue; + if( m_ui->monitor->selectedEdgeItem( i ) == index ) + m_ui->monitor->selectEdgeItem( i, int( NoEffect )); + } + } + +void KWinScreenEdgesConfig::monitorShowEvent() + { + // Check if they are enabled + KConfigGroup config( m_config, "Compositing" ); + if( config.readEntry( "Enabled", m_defaultPrefs.enableCompositing() )) + { // Compositing enabled + config = KConfigGroup( m_config, "Plugins" ); + + // Present Windows + bool enabled = effectEnabled( "presentwindows", config ); + monitorItemSetEnabled( 1, enabled ); + monitorItemSetEnabled( 2, enabled ); + + // Desktop Grid + enabled = effectEnabled( "desktopgrid", config ); + monitorItemSetEnabled( 3, enabled ); + + // Desktop Cube + enabled = effectEnabled( "cube", config ); + monitorItemSetEnabled( 4, enabled ); + monitorItemSetEnabled( 5, enabled ); + monitorItemSetEnabled( 6, enabled ); + } + else // Compositing disabled + { + monitorItemSetEnabled( 1, false ); + monitorItemSetEnabled( 2, false ); + monitorItemSetEnabled( 3, false ); + monitorItemSetEnabled( 4, false ); + monitorItemSetEnabled( 5, false ); + monitorItemSetEnabled( 6, false ); + } + } + +void KWinScreenEdgesConfig::monitorChangeEdge( ElectricBorder border, int index ) + { + switch( border ) + { + case ElectricTop: + m_ui->monitor->selectEdgeItem( int( Monitor::Top ), index ); + break; + case ElectricTopRight: + m_ui->monitor->selectEdgeItem( int( Monitor::TopRight ), index ); + break; + case ElectricRight: + m_ui->monitor->selectEdgeItem( int( Monitor::Right ), index ); + break; + case ElectricBottomRight: + m_ui->monitor->selectEdgeItem( int( Monitor::BottomRight ), index ); + break; + case ElectricBottom: + m_ui->monitor->selectEdgeItem( int( Monitor::Bottom ), index ); + break; + case ElectricBottomLeft: + m_ui->monitor->selectEdgeItem( int( Monitor::BottomLeft ), index ); + break; + case ElectricLeft: + m_ui->monitor->selectEdgeItem( int( Monitor::Left ), index ); + break; + case ElectricTopLeft: + m_ui->monitor->selectEdgeItem( int( Monitor::TopLeft ), index ); + break; + default: // Nothing + break; + } + } + +void KWinScreenEdgesConfig::monitorHideEdge( ElectricBorder border, bool hidden ) + { + switch( border ) + { + case ElectricTop: + m_ui->monitor->setEdgeHidden( int( Monitor::Top ), hidden ); + break; + case ElectricTopRight: + m_ui->monitor->setEdgeHidden( int( Monitor::TopRight ), hidden ); + break; + case ElectricRight: + m_ui->monitor->setEdgeHidden( int( Monitor::Right ), hidden ); + break; + case ElectricBottomRight: + m_ui->monitor->setEdgeHidden( int( Monitor::BottomRight ), hidden ); + break; + case ElectricBottom: + m_ui->monitor->setEdgeHidden( int( Monitor::Bottom ), hidden ); + break; + case ElectricBottomLeft: + m_ui->monitor->setEdgeHidden( int( Monitor::BottomLeft ), hidden ); + break; + case ElectricLeft: + m_ui->monitor->setEdgeHidden( int( Monitor::Left ), hidden ); + break; + case ElectricTopLeft: + m_ui->monitor->setEdgeHidden( int( Monitor::TopLeft ), hidden ); + break; + default: // Nothing + break; + } + } + +ElectricBorder KWinScreenEdgesConfig::monitorCheckEffectHasEdge( int index ) + { + if( m_ui->monitor->selectedEdgeItem( int( Monitor::Top )) == index ) + return ElectricTop; + if( m_ui->monitor->selectedEdgeItem( int( Monitor::TopRight )) == index ) + return ElectricTopRight; + if( m_ui->monitor->selectedEdgeItem( int( Monitor::Right )) == index ) + return ElectricRight; + if( m_ui->monitor->selectedEdgeItem( int( Monitor::BottomRight )) == index ) + return ElectricBottomRight; + if( m_ui->monitor->selectedEdgeItem( int( Monitor::Bottom )) == index ) + return ElectricBottom; + if( m_ui->monitor->selectedEdgeItem( int( Monitor::BottomLeft )) == index ) + return ElectricBottomLeft; + if( m_ui->monitor->selectedEdgeItem( int( Monitor::Left )) == index ) + return ElectricLeft; + if( m_ui->monitor->selectedEdgeItem( int( Monitor::TopLeft )) == index ) + return ElectricTopLeft; + + return ElectricNone; + } + +} // namespace + +#include "main.moc" diff --git a/kcmkwin/kwinscreenedges/main.h b/kcmkwin/kwinscreenedges/main.h new file mode 100644 index 0000000000..e62ebf6039 --- /dev/null +++ b/kcmkwin/kwinscreenedges/main.h @@ -0,0 +1,95 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2009 Lucas Murray + +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, see . +*********************************************************************/ + +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#include +#include + +#include "kwinglobals.h" +#include "compositingprefs.h" + +#include "ui_main.h" + +class QShowEvent; + +namespace KWin +{ + +class KWinScreenEdgesConfigForm : public QWidget, public Ui::KWinScreenEdgesConfigForm + { + Q_OBJECT + + public: + explicit KWinScreenEdgesConfigForm( QWidget* parent ); + }; + +class KWinScreenEdgesConfig : public KCModule + { + Q_OBJECT + + public: + explicit KWinScreenEdgesConfig( QWidget* parent, const QVariantList& args ); + ~KWinScreenEdgesConfig(); + + public slots: + virtual void groupChanged(); + virtual void save(); + virtual void load(); + virtual void defaults(); + + protected: + virtual void showEvent( QShowEvent* e ); + + private: + KWinScreenEdgesConfigForm* m_ui; + KSharedConfigPtr m_config; + CompositingPrefs m_defaultPrefs; + + enum EffectActions + { + NoEffect, + PresentWindowsAll, + PresentWindowsCurrent, + DesktopGrid, + Cube, + Cylinder, + Sphere + }; + + bool effectEnabled( const QString& effect, const KConfigGroup& cfg ) const; + + void monitorAddItem( const QString& item ); + void monitorItemSetEnabled( int index, bool enabled ); + void monitorInit(); + void monitorLoad(); + void monitorSave(); + void monitorDefaults(); + void monitorShowEvent(); + void monitorEdgeChanged( int edge, int index ); + void monitorChangeEdge( ElectricBorder border, int index ); + void monitorHideEdge( ElectricBorder border, bool hidden ); + ElectricBorder monitorCheckEffectHasEdge( int index ); + }; + +} // namespace + +#endif diff --git a/kcmkwin/kwinscreenedges/main.ui b/kcmkwin/kwinscreenedges/main.ui new file mode 100644 index 0000000000..bede3aab40 --- /dev/null +++ b/kcmkwin/kwinscreenedges/main.ui @@ -0,0 +1,277 @@ + + + KWinScreenEdgesConfigForm + + + + 0 + 0 + 619 + 321 + + + + + + + Active Screen Edge Actions + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + + 10 + 10 + + + + Qt::StrongFocus + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + To trigger an action push your mouse cursor against the edge of the screen in the action's direction. + + + Qt::AlignCenter + + + true + + + + + + + + + + true + + + Other Settings + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + Activation &delay: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + activationDelaySpin + + + + + + + ms + + + 1000 + + + 50 + + + 0 + + + + + + + false + + + Trigger &cooldown: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + triggerCooldownSpin + + + + + + + false + + + ms + + + 1000 + + + 50 + + + 0 + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + Action Groups + + + + + + false + + + &Tile windows by dragging them to the side of the screen + + + + + + + false + + + Ma&ximize windows by dragging them to the top of the screen + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + &Switch desktop on edge: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + desktopSwitchCombo + + + + + + + + Disabled + + + + + Only when moving windows + + + + + Always enabled + + + + + + + + + + + + KWin::Monitor + QWidget +
monitor.h
+ 1 +
+
+ + monitor + desktopSwitchCombo + quickTileBox + quickMaximizeBox + activationDelaySpin + triggerCooldownSpin + + + +
diff --git a/kcmkwin/kwincompositing/monitor.cpp b/kcmkwin/kwinscreenedges/monitor.cpp similarity index 88% rename from kcmkwin/kwincompositing/monitor.cpp rename to kcmkwin/kwinscreenedges/monitor.cpp index e461c65dc6..de1789be11 100644 --- a/kcmkwin/kwincompositing/monitor.cpp +++ b/kcmkwin/kwinscreenedges/monitor.cpp @@ -3,6 +3,7 @@ This file is part of the KDE project. Copyright (C) 2008 Lubos Lunak +Copyright (C) 2009 Lucas Murray 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 @@ -54,6 +55,7 @@ Monitor::Monitor( QWidget* parent ) items[ i ] = new Corner( this ); scene->addItem( items[ i ] ); items[ i ]->setBrush( Qt::red ); // TODO color-scheme dependent? + hidden[ i ] = false; grp[ i ] = new QActionGroup( this ); } checkSize(); @@ -67,6 +69,7 @@ void Monitor::clear() { popups[ i ]->clear(); setEdge( i, false ); + setEdgeHidden( i, false ); delete grp[ i ]; grp[ i ] = new QActionGroup( this ); } @@ -108,6 +111,20 @@ bool Monitor::edge( int edge ) const return items[ edge ]->brush() == Qt::green; } +void Monitor::setEdgeHidden( int edge, bool set ) + { + hidden[ edge ] = set; + if( set ) + items[ edge ]->hide(); + else + items[ edge ]->show(); + } + +bool Monitor::edgeHidden( int edge ) const + { + return hidden[ edge ]; + } + void Monitor::addEdgeItem( int edge, const QString& item ) { QAction* act = popups[ edge ]->addAction( item ); @@ -119,6 +136,16 @@ void Monitor::addEdgeItem( int edge, const QString& item ) setEdge( edge, !popup_actions[ edge ][ 0 ]->isChecked()); } +void Monitor::setEdgeItemEnabled( int edge, int index, bool enabled ) + { + popup_actions[ edge ][ index ]->setEnabled( enabled ); + } + +bool Monitor::edgeItemEnabled( int edge, int index ) const + { + return popup_actions[ edge ][ index ]->isEnabled(); + } + void Monitor::selectEdgeItem( int edge, int index ) { popup_actions[ edge ][ index ]->setChecked( true ); diff --git a/kcmkwin/kwincompositing/monitor.h b/kcmkwin/kwinscreenedges/monitor.h similarity index 89% rename from kcmkwin/kwincompositing/monitor.h rename to kcmkwin/kwinscreenedges/monitor.h index ef7215fb45..e91fd56459 100644 --- a/kcmkwin/kwincompositing/monitor.h +++ b/kcmkwin/kwinscreenedges/monitor.h @@ -3,6 +3,7 @@ This file is part of the KDE project. Copyright (C) 2008 Lubos Lunak +Copyright (C) 2009 Lucas Murray 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 @@ -42,8 +43,12 @@ class Monitor Monitor( QWidget* parent ); void setEdge( int edge, bool set ); bool edge( int edge ) const; + void setEdgeHidden( int edge, bool set ); + bool edgeHidden( int edge ) const; void clear(); void addEdgeItem( int edge, const QString& item ); + void setEdgeItemEnabled( int edge, int index, bool enabled ); + bool edgeItemEnabled( int edge, int index ) const; void selectEdgeItem( int edge, int index ); int selectedEdgeItem( int edge ) const; @@ -71,6 +76,7 @@ class Monitor QGraphicsView* view; QGraphicsScene* scene; QGraphicsRectItem* items[ 8 ]; + bool hidden[ 8 ]; QMenu* popups[ 8 ]; QVector< QAction* > popup_actions[ 8 ]; QActionGroup* grp[ 8 ];