From ced8835dfaee70e204bebd3e669e9f824e8ea699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Wed, 10 Nov 2004 11:41:12 +0000 Subject: [PATCH] Make sure unused settings have prefilled values also with Alt+F3/Window-specific settings. svn path=/trunk/kdebase/kwin/; revision=361970 --- kcmkwin/kwinrules/main.cpp | 2 +- kcmkwin/kwinrules/ruleslist.cpp | 4 +- kcmkwin/kwinrules/ruleswidget.cpp | 83 +++++++++++++++++-------------- kcmkwin/kwinrules/ruleswidget.h | 6 ++- 4 files changed, 53 insertions(+), 42 deletions(-) diff --git a/kcmkwin/kwinrules/main.cpp b/kcmkwin/kwinrules/main.cpp index bf8aa2442c..b27f4326a9 100644 --- a/kcmkwin/kwinrules/main.cpp +++ b/kcmkwin/kwinrules/main.cpp @@ -199,7 +199,7 @@ static int edit( Window wid ) Rules* orig_rule = findRule( rules, wid ); RulesDialog dlg; // dlg.edit() creates new Rules instance if edited - Rules* edited_rule = dlg.edit( orig_rule, true ); + Rules* edited_rule = dlg.edit( orig_rule, wid ); if( edited_rule == NULL || edited_rule->isEmpty()) { rules.remove( orig_rule ); diff --git a/kcmkwin/kwinrules/ruleslist.cpp b/kcmkwin/kwinrules/ruleslist.cpp index cd079cf9bc..53c4094bb2 100644 --- a/kcmkwin/kwinrules/ruleslist.cpp +++ b/kcmkwin/kwinrules/ruleslist.cpp @@ -74,7 +74,7 @@ void KCMRulesList::activeChanged( QListBoxItem* item ) void KCMRulesList::newClicked() { RulesDialog dlg; - Rules* rule = dlg.edit( NULL, false ); + Rules* rule = dlg.edit( NULL, 0 ); if( rule == NULL ) return; int pos = rules_listbox->currentItem() + 1; @@ -90,7 +90,7 @@ void KCMRulesList::modifyClicked() if ( pos == -1 ) return; RulesDialog dlg; - Rules* rule = dlg.edit( rules[ pos ], false ); + Rules* rule = dlg.edit( rules[ pos ], 0 ); if( rule == rules[ pos ] ) return; delete rules[ pos ]; diff --git a/kcmkwin/kwinrules/ruleswidget.cpp b/kcmkwin/kwinrules/ruleswidget.cpp index da19abba6a..b7bc10cc22 100644 --- a/kcmkwin/kwinrules/ruleswidget.cpp +++ b/kcmkwin/kwinrules/ruleswidget.cpp @@ -493,16 +493,6 @@ void RulesWidget::detectClicked() detect_dlg->detect( 0 ); } -#define GENERIC_PREFILL( var, func, info, uimethod ) \ - if( !enable_##var->isChecked()) \ - { \ - var->uimethod( func( info )); \ - } - -#define CHECKBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setChecked ) -#define LINEEDIT_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setText ) -#define COMBOBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setCurrentItem ) - void RulesWidget::detected( bool ok ) { if( ok ) @@ -539,35 +529,50 @@ void RulesWidget::detected( bool ok ) machineMatchChanged(); // prefill values from to window to settings which already set const KWin::WindowInfo& info = detect_dlg->windowInfo(); - LINEEDIT_PREFILL( position, positionToStr, info.frameGeometry().topLeft() ); - LINEEDIT_PREFILL( size, sizeToStr, info.frameGeometry().size() ); - COMBOBOX_PREFILL( desktop, desktopToCombo, info.desktop() ); - CHECKBOX_PREFILL( maximizehoriz,, info.state() & NET::MaxHoriz ); - CHECKBOX_PREFILL( maximizevert,, info.state() & NET::MaxVert ); - CHECKBOX_PREFILL( minimize,, info.isMinimized() ); - CHECKBOX_PREFILL( shade,, info.state() & NET::Shaded ); - CHECKBOX_PREFILL( fullscreen,, info.state() & NET::FullScreen ); - //COMBOBOX_PREFILL( placement, placementToCombo ); - CHECKBOX_PREFILL( above,, info.state() & NET::KeepAbove ); - CHECKBOX_PREFILL( below,, info.state() & NET::KeepBelow ); - // noborder is only internal KWin information, so let's guess - CHECKBOX_PREFILL( noborder,, info.frameGeometry() == info.geometry() ); - CHECKBOX_PREFILL( skiptaskbar,, info.state() & NET::SkipTaskbar ); - CHECKBOX_PREFILL( skippager,, info.state() & NET::SkipPager ); - //CHECKBOX_PREFILL( acceptfocus, ); - //CHECKBOX_PREFILL( closeable, ); - //COMBOBOX_PREFILL( fsplevel, ); - //COMBOBOX_PREFILL( moveresizemode, moveresizeToCombo ); - COMBOBOX_PREFILL( type, typeToCombo, info.windowType( SUPPORTED_WINDOW_TYPES_MASK ) ); - //CHECKBOX_PREFILL( ignoreposition, ); - LINEEDIT_PREFILL( minsize, sizeToStr, info.frameGeometry().size() ); - LINEEDIT_PREFILL( maxsize, sizeToStr, info.frameGeometry().size() ); + prefillUnusedValues( info ); } delete detect_dlg; detect_dlg = NULL; detect_dlg_ok = ok; } +#define GENERIC_PREFILL( var, func, info, uimethod ) \ + if( !enable_##var->isChecked()) \ + { \ + var->uimethod( func( info )); \ + } + +#define CHECKBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setChecked ) +#define LINEEDIT_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setText ) +#define COMBOBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setCurrentItem ) + +void RulesWidget::prefillUnusedValues( const KWin::WindowInfo& info ) + { + LINEEDIT_PREFILL( position, positionToStr, info.frameGeometry().topLeft() ); + LINEEDIT_PREFILL( size, sizeToStr, info.frameGeometry().size() ); + COMBOBOX_PREFILL( desktop, desktopToCombo, info.desktop() ); + CHECKBOX_PREFILL( maximizehoriz,, info.state() & NET::MaxHoriz ); + CHECKBOX_PREFILL( maximizevert,, info.state() & NET::MaxVert ); + CHECKBOX_PREFILL( minimize,, info.isMinimized() ); + CHECKBOX_PREFILL( shade,, info.state() & NET::Shaded ); + CHECKBOX_PREFILL( fullscreen,, info.state() & NET::FullScreen ); + //COMBOBOX_PREFILL( placement, placementToCombo ); + CHECKBOX_PREFILL( above,, info.state() & NET::KeepAbove ); + CHECKBOX_PREFILL( below,, info.state() & NET::KeepBelow ); + // noborder is only internal KWin information, so let's guess + CHECKBOX_PREFILL( noborder,, info.frameGeometry() == info.geometry() ); + CHECKBOX_PREFILL( skiptaskbar,, info.state() & NET::SkipTaskbar ); + CHECKBOX_PREFILL( skippager,, info.state() & NET::SkipPager ); + //CHECKBOX_PREFILL( acceptfocus, ); + //CHECKBOX_PREFILL( closeable, ); + //COMBOBOX_PREFILL( fsplevel, ); + //COMBOBOX_PREFILL( moveresizemode, moveresizeToCombo ); + COMBOBOX_PREFILL( type, typeToCombo, info.windowType( SUPPORTED_WINDOW_TYPES_MASK ) ); + //CHECKBOX_PREFILL( ignoreposition, ); + LINEEDIT_PREFILL( minsize, sizeToStr, info.frameGeometry().size() ); + LINEEDIT_PREFILL( maxsize, sizeToStr, info.frameGeometry().size() ); + } + #undef GENERIC_PREFILL #undef CHECKBOX_PREFILL #undef LINEEDIT_PREFILL @@ -600,9 +605,11 @@ bool RulesWidget::finalCheck() return true; } -void RulesWidget::focusSettings() +void RulesWidget::prepareWindowSpecific( WId window ) { tabs->setCurrentPage( 2 ); // geometry tab, skip tabs for window identification + KWin::WindowInfo info( window, -1U, -1U ); // read everything + prefillUnusedValues( info ); } RulesDialog::RulesDialog( QWidget* parent, const char* name ) @@ -612,12 +619,14 @@ RulesDialog::RulesDialog( QWidget* parent, const char* name ) setMainWidget( widget ); } -Rules* RulesDialog::edit( Rules* r, bool focus_settings ) +// window is set only for Alt+F3/Window-specific settings, because the dialog +// is then related to one specific window +Rules* RulesDialog::edit( Rules* r, WId window ) { rules = r; widget->setRules( rules ); - if( focus_settings ) - widget->focusSettings(); + if( window != 0 ) + widget->prepareWindowSpecific( window ); exec(); return rules; } diff --git a/kcmkwin/kwinrules/ruleswidget.h b/kcmkwin/kwinrules/ruleswidget.h index 17476d20fb..9d200f9eeb 100644 --- a/kcmkwin/kwinrules/ruleswidget.h +++ b/kcmkwin/kwinrules/ruleswidget.h @@ -21,6 +21,7 @@ #define __RULESWIDGET_H__ #include +#include #include "ruleswidgetbase.h" @@ -39,7 +40,7 @@ class RulesWidget void setRules( Rules* r ); Rules* rules() const; bool finalCheck(); - void focusSettings(); + void prepareWindowSpecific( WId window ); signals: void changed( bool state ); protected slots: @@ -80,6 +81,7 @@ class RulesWidget private: int desktopToCombo( int d ) const; int comboToDesktop( int val ) const; + void prefillUnusedValues( const KWin::WindowInfo& info ); DetectDialog* detect_dlg; bool detect_dlg_ok; }; @@ -90,7 +92,7 @@ class RulesDialog Q_OBJECT public: RulesDialog( QWidget* parent = NULL, const char* name = NULL ); - Rules* edit( Rules* r, bool focus_settings ); + Rules* edit( Rules* r, WId window ); protected: virtual void accept(); private: