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:
parent
d0a2d63fdf
commit
ced8835dfa
4 changed files with 53 additions and 42 deletions
|
@ -199,7 +199,7 @@ static int edit( Window wid )
|
||||||
Rules* orig_rule = findRule( rules, wid );
|
Rules* orig_rule = findRule( rules, wid );
|
||||||
RulesDialog dlg;
|
RulesDialog dlg;
|
||||||
// dlg.edit() creates new Rules instance if edited
|
// 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())
|
if( edited_rule == NULL || edited_rule->isEmpty())
|
||||||
{
|
{
|
||||||
rules.remove( orig_rule );
|
rules.remove( orig_rule );
|
||||||
|
|
|
@ -74,7 +74,7 @@ void KCMRulesList::activeChanged( QListBoxItem* item )
|
||||||
void KCMRulesList::newClicked()
|
void KCMRulesList::newClicked()
|
||||||
{
|
{
|
||||||
RulesDialog dlg;
|
RulesDialog dlg;
|
||||||
Rules* rule = dlg.edit( NULL, false );
|
Rules* rule = dlg.edit( NULL, 0 );
|
||||||
if( rule == NULL )
|
if( rule == NULL )
|
||||||
return;
|
return;
|
||||||
int pos = rules_listbox->currentItem() + 1;
|
int pos = rules_listbox->currentItem() + 1;
|
||||||
|
@ -90,7 +90,7 @@ void KCMRulesList::modifyClicked()
|
||||||
if ( pos == -1 )
|
if ( pos == -1 )
|
||||||
return;
|
return;
|
||||||
RulesDialog dlg;
|
RulesDialog dlg;
|
||||||
Rules* rule = dlg.edit( rules[ pos ], false );
|
Rules* rule = dlg.edit( rules[ pos ], 0 );
|
||||||
if( rule == rules[ pos ] )
|
if( rule == rules[ pos ] )
|
||||||
return;
|
return;
|
||||||
delete rules[ pos ];
|
delete rules[ pos ];
|
||||||
|
|
|
@ -493,16 +493,6 @@ void RulesWidget::detectClicked()
|
||||||
detect_dlg->detect( 0 );
|
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 )
|
void RulesWidget::detected( bool ok )
|
||||||
{
|
{
|
||||||
if( ok )
|
if( ok )
|
||||||
|
@ -539,35 +529,50 @@ void RulesWidget::detected( bool ok )
|
||||||
machineMatchChanged();
|
machineMatchChanged();
|
||||||
// prefill values from to window to settings which already set
|
// prefill values from to window to settings which already set
|
||||||
const KWin::WindowInfo& info = detect_dlg->windowInfo();
|
const KWin::WindowInfo& info = detect_dlg->windowInfo();
|
||||||
LINEEDIT_PREFILL( position, positionToStr, info.frameGeometry().topLeft() );
|
prefillUnusedValues( info );
|
||||||
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() );
|
|
||||||
}
|
}
|
||||||
delete detect_dlg;
|
delete detect_dlg;
|
||||||
detect_dlg = NULL;
|
detect_dlg = NULL;
|
||||||
detect_dlg_ok = ok;
|
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 GENERIC_PREFILL
|
||||||
#undef CHECKBOX_PREFILL
|
#undef CHECKBOX_PREFILL
|
||||||
#undef LINEEDIT_PREFILL
|
#undef LINEEDIT_PREFILL
|
||||||
|
@ -600,9 +605,11 @@ bool RulesWidget::finalCheck()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RulesWidget::focusSettings()
|
void RulesWidget::prepareWindowSpecific( WId window )
|
||||||
{
|
{
|
||||||
tabs->setCurrentPage( 2 ); // geometry tab, skip tabs for window identification
|
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 )
|
RulesDialog::RulesDialog( QWidget* parent, const char* name )
|
||||||
|
@ -612,12 +619,14 @@ RulesDialog::RulesDialog( QWidget* parent, const char* name )
|
||||||
setMainWidget( widget );
|
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;
|
rules = r;
|
||||||
widget->setRules( rules );
|
widget->setRules( rules );
|
||||||
if( focus_settings )
|
if( window != 0 )
|
||||||
widget->focusSettings();
|
widget->prepareWindowSpecific( window );
|
||||||
exec();
|
exec();
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define __RULESWIDGET_H__
|
#define __RULESWIDGET_H__
|
||||||
|
|
||||||
#include <kdialogbase.h>
|
#include <kdialogbase.h>
|
||||||
|
#include <kwin.h>
|
||||||
|
|
||||||
#include "ruleswidgetbase.h"
|
#include "ruleswidgetbase.h"
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ class RulesWidget
|
||||||
void setRules( Rules* r );
|
void setRules( Rules* r );
|
||||||
Rules* rules() const;
|
Rules* rules() const;
|
||||||
bool finalCheck();
|
bool finalCheck();
|
||||||
void focusSettings();
|
void prepareWindowSpecific( WId window );
|
||||||
signals:
|
signals:
|
||||||
void changed( bool state );
|
void changed( bool state );
|
||||||
protected slots:
|
protected slots:
|
||||||
|
@ -80,6 +81,7 @@ class RulesWidget
|
||||||
private:
|
private:
|
||||||
int desktopToCombo( int d ) const;
|
int desktopToCombo( int d ) const;
|
||||||
int comboToDesktop( int val ) const;
|
int comboToDesktop( int val ) const;
|
||||||
|
void prefillUnusedValues( const KWin::WindowInfo& info );
|
||||||
DetectDialog* detect_dlg;
|
DetectDialog* detect_dlg;
|
||||||
bool detect_dlg_ok;
|
bool detect_dlg_ok;
|
||||||
};
|
};
|
||||||
|
@ -90,7 +92,7 @@ class RulesDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
RulesDialog( QWidget* parent = NULL, const char* name = NULL );
|
RulesDialog( QWidget* parent = NULL, const char* name = NULL );
|
||||||
Rules* edit( Rules* r, bool focus_settings );
|
Rules* edit( Rules* r, WId window );
|
||||||
protected:
|
protected:
|
||||||
virtual void accept();
|
virtual void accept();
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue