Make sure unused settings have prefilled values also with Alt+F3/Window-specific settings.

svn path=/trunk/kdebase/kwin/; revision=361970
This commit is contained in:
Luboš Luňák 2004-11-10 11:41:12 +00:00
parent d0a2d63fdf
commit ced8835dfa
4 changed files with 53 additions and 42 deletions

View file

@ -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 );

View file

@ -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 ];

View file

@ -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;
}

View file

@ -21,6 +21,7 @@
#define __RULESWIDGET_H__
#include <kdialogbase.h>
#include <kwin.h>
#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: