2004-06-21 16:25:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
*
|
|
|
|
* 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, write to the Free Software
|
2005-12-21 06:45:09 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-06-21 16:25:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ruleswidget.h"
|
|
|
|
|
|
|
|
#include <klineedit.h>
|
|
|
|
#include <krestrictedline.h>
|
|
|
|
#include <kcombobox.h>
|
2006-05-11 08:04:23 +00:00
|
|
|
#include <QCheckBox>
|
2004-06-21 16:25:24 +00:00
|
|
|
#include <kpushbutton.h>
|
2006-05-11 08:04:23 +00:00
|
|
|
#include <QLabel>
|
2004-06-21 16:25:24 +00:00
|
|
|
#include <kwinmodule.h>
|
|
|
|
#include <klocale.h>
|
2006-05-11 08:04:23 +00:00
|
|
|
#include <QRegExp>
|
2005-07-28 14:59:42 +00:00
|
|
|
|
2004-06-22 16:31:57 +00:00
|
|
|
#include <assert.h>
|
2004-06-28 14:28:11 +00:00
|
|
|
#include <kmessagebox.h>
|
2006-05-13 16:33:18 +00:00
|
|
|
#include <QTabWidget>
|
2006-05-11 08:04:23 +00:00
|
|
|
#include <QTimer>
|
2004-06-21 16:25:24 +00:00
|
|
|
|
|
|
|
#include "../../rules.h"
|
|
|
|
|
2004-06-22 16:31:57 +00:00
|
|
|
#include "detectwidget.h"
|
|
|
|
|
2004-06-21 16:25:24 +00:00
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
2004-06-22 12:23:42 +00:00
|
|
|
#define SETUP( var, type ) \
|
2004-06-21 16:25:24 +00:00
|
|
|
connect( enable_##var, SIGNAL( toggled( bool )), rule_##var, SLOT( setEnabled( bool ))); \
|
|
|
|
connect( enable_##var, SIGNAL( toggled( bool )), this, SLOT( updateEnable##var())); \
|
2004-06-22 12:23:42 +00:00
|
|
|
connect( rule_##var, SIGNAL( activated( int )), this, SLOT( updateEnable##var())); \
|
2005-07-28 14:59:42 +00:00
|
|
|
enable_##var->setWhatsThis( enableDesc ); \
|
|
|
|
rule_##var->setWhatsThis( type##RuleDesc );
|
2004-06-21 16:25:24 +00:00
|
|
|
|
2006-01-09 21:34:47 +00:00
|
|
|
RulesWidget::RulesWidget( QWidget* parent )
|
|
|
|
: RulesWidgetBase( parent )
|
2004-06-22 16:31:57 +00:00
|
|
|
, detect_dlg( NULL )
|
2004-06-21 16:25:24 +00:00
|
|
|
{
|
2004-06-22 12:23:42 +00:00
|
|
|
QString enableDesc =
|
|
|
|
i18n( "Enable this checkbox to alter this window property for the specified window(s)." );
|
|
|
|
QString setRuleDesc =
|
|
|
|
i18n( "Specify how the window property should be affected:<ul>"
|
|
|
|
"<li><em>Do Not Affect:</em> The window property will not be affected and therefore"
|
|
|
|
" the default handling for it will be used. Specifying this will block more generic"
|
|
|
|
" window settings from taking effect.</li>"
|
|
|
|
"<li><em>Apply Initially:</em> The window property will be only set to the given value"
|
|
|
|
" after the window is created. No further changes will be affected.</li>"
|
|
|
|
"<li><em>Remember:</em> The value of the window property will be remembered and every time"
|
|
|
|
" time the window is created, the last remembered value will be applied.</li>"
|
2005-06-07 15:31:15 +00:00
|
|
|
"<li><em>Force:</em> The window property will be always forced to the given value.</li>"
|
2005-06-08 11:11:28 +00:00
|
|
|
"<li><em>Apply Now:</em> The window property will be set to the given value immediately"
|
|
|
|
" and will not be affected later (this action will be deleted afterwards).</li>"
|
2005-06-07 15:31:15 +00:00
|
|
|
"<li><em>Force temporarily:</em> The window property will be forced to the given value"
|
2005-06-08 12:20:24 +00:00
|
|
|
" until it is hidden (this action will be deleted after the window is hidden).</li>"
|
2005-06-07 15:31:15 +00:00
|
|
|
"</ul>" );
|
2004-06-22 12:23:42 +00:00
|
|
|
QString forceRuleDesc =
|
|
|
|
i18n( "Specify how the window property should be affected:<ul>"
|
|
|
|
"<li><em>Do Not Affect:</em> The window property will not be affected and therefore"
|
|
|
|
" the default handling for it will be used. Specifying this will block more generic"
|
|
|
|
" window settings from taking effect.</li>"
|
2005-06-07 15:31:15 +00:00
|
|
|
"<li><em>Force:</em> The window property will be always forced to the given value.</li>"
|
|
|
|
"<li><em>Force temporarily:</em> The window property will be forced to the given value"
|
2005-06-08 11:11:28 +00:00
|
|
|
" until it is hidden (this action will be deleted after the window is hidden).</li>"
|
2005-06-07 15:31:15 +00:00
|
|
|
"</ul>" );
|
2004-06-21 16:25:24 +00:00
|
|
|
// window tabs have enable signals done in designer
|
|
|
|
// geometry tab
|
2004-06-22 12:23:42 +00:00
|
|
|
SETUP( position, set );
|
|
|
|
SETUP( size, set );
|
|
|
|
SETUP( desktop, set );
|
|
|
|
SETUP( maximizehoriz, set );
|
|
|
|
SETUP( maximizevert, set );
|
|
|
|
SETUP( minimize, set );
|
|
|
|
SETUP( shade, set );
|
|
|
|
SETUP( fullscreen, set );
|
|
|
|
SETUP( placement, force );
|
2004-06-21 16:25:24 +00:00
|
|
|
// preferences tab
|
2004-06-22 12:23:42 +00:00
|
|
|
SETUP( above, set );
|
|
|
|
SETUP( below, set );
|
|
|
|
SETUP( noborder, set );
|
|
|
|
SETUP( skiptaskbar, set );
|
|
|
|
SETUP( skippager, set );
|
|
|
|
SETUP( acceptfocus, force );
|
|
|
|
SETUP( closeable, force );
|
2005-01-17 13:16:47 +00:00
|
|
|
SETUP( opacityactive, force );
|
|
|
|
SETUP( opacityinactive, force );
|
2005-01-17 15:53:14 +00:00
|
|
|
SETUP( shortcut, force );
|
2004-06-21 16:25:24 +00:00
|
|
|
// workarounds tab
|
2004-06-22 12:23:42 +00:00
|
|
|
SETUP( fsplevel, force );
|
|
|
|
SETUP( moveresizemode, force );
|
|
|
|
SETUP( type, force );
|
|
|
|
SETUP( ignoreposition, force );
|
|
|
|
SETUP( minsize, force );
|
|
|
|
SETUP( maxsize, force );
|
2005-01-17 13:35:48 +00:00
|
|
|
SETUP( strictgeometry, force );
|
2005-08-02 13:25:20 +00:00
|
|
|
SETUP( disableglobalshortcuts, force );
|
2004-06-21 16:25:24 +00:00
|
|
|
KWinModule module;
|
|
|
|
int i;
|
|
|
|
for( i = 1;
|
|
|
|
i <= module.numberOfDesktops();
|
|
|
|
++i )
|
2006-04-12 15:13:31 +00:00
|
|
|
desktop->addItem( QString::number( i ).rightJustified( 2 ) + ":" + module.desktopName( i ));
|
|
|
|
desktop->addItem( i18n( "All Desktops" ));
|
2004-06-21 16:25:24 +00:00
|
|
|
}
|
|
|
|
|
2004-06-22 12:23:42 +00:00
|
|
|
#undef SETUP
|
2004-06-21 16:25:24 +00:00
|
|
|
|
|
|
|
#define UPDATE_ENABLE_SLOT( var ) \
|
|
|
|
void RulesWidget::updateEnable##var() \
|
|
|
|
{ \
|
2006-03-06 15:51:12 +00:00
|
|
|
/* leave the label readable label_##var->setEnabled( enable_##var->isChecked() && rule_##var->currentIndex() != 0 );*/ \
|
|
|
|
Ui_RulesWidgetBase::var->setEnabled( enable_##var->isChecked() && rule_##var->currentIndex() != 0 ); \
|
2004-06-21 16:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// geometry tab
|
|
|
|
UPDATE_ENABLE_SLOT( position )
|
|
|
|
UPDATE_ENABLE_SLOT( size )
|
|
|
|
UPDATE_ENABLE_SLOT( desktop )
|
|
|
|
UPDATE_ENABLE_SLOT( maximizehoriz )
|
|
|
|
UPDATE_ENABLE_SLOT( maximizevert )
|
|
|
|
UPDATE_ENABLE_SLOT( minimize )
|
|
|
|
UPDATE_ENABLE_SLOT( shade )
|
|
|
|
UPDATE_ENABLE_SLOT( fullscreen )
|
|
|
|
UPDATE_ENABLE_SLOT( placement )
|
|
|
|
// preferences tab
|
|
|
|
UPDATE_ENABLE_SLOT( above )
|
|
|
|
UPDATE_ENABLE_SLOT( below )
|
|
|
|
UPDATE_ENABLE_SLOT( noborder )
|
|
|
|
UPDATE_ENABLE_SLOT( skiptaskbar )
|
|
|
|
UPDATE_ENABLE_SLOT( skippager )
|
|
|
|
UPDATE_ENABLE_SLOT( acceptfocus )
|
|
|
|
UPDATE_ENABLE_SLOT( closeable )
|
2005-01-17 13:16:47 +00:00
|
|
|
UPDATE_ENABLE_SLOT( opacityactive )
|
|
|
|
UPDATE_ENABLE_SLOT( opacityinactive )
|
2005-01-17 15:53:14 +00:00
|
|
|
void RulesWidget::updateEnableshortcut()
|
|
|
|
{
|
2006-03-06 15:51:12 +00:00
|
|
|
shortcut->setEnabled( enable_shortcut->isChecked() && rule_shortcut->currentIndex() != 0 );
|
|
|
|
shortcut_edit->setEnabled( enable_shortcut->isChecked() && rule_shortcut->currentIndex() != 0 );
|
2005-01-17 15:53:14 +00:00
|
|
|
}
|
2004-06-21 16:25:24 +00:00
|
|
|
// workarounds tab
|
|
|
|
UPDATE_ENABLE_SLOT( fsplevel )
|
|
|
|
UPDATE_ENABLE_SLOT( moveresizemode )
|
|
|
|
UPDATE_ENABLE_SLOT( type )
|
|
|
|
UPDATE_ENABLE_SLOT( ignoreposition )
|
|
|
|
UPDATE_ENABLE_SLOT( minsize )
|
|
|
|
UPDATE_ENABLE_SLOT( maxsize )
|
2005-01-17 13:35:48 +00:00
|
|
|
UPDATE_ENABLE_SLOT( strictgeometry )
|
2005-08-02 13:25:20 +00:00
|
|
|
UPDATE_ENABLE_SLOT( disableglobalshortcuts )
|
2004-06-21 16:25:24 +00:00
|
|
|
|
|
|
|
#undef UPDATE_ENABLE_SLOT
|
|
|
|
|
|
|
|
static const int set_rule_to_combo[] =
|
|
|
|
{
|
|
|
|
0, // Unused
|
|
|
|
0, // Don't Affect
|
|
|
|
3, // Force
|
|
|
|
1, // Apply
|
|
|
|
2, // Remember
|
2005-06-07 15:31:15 +00:00
|
|
|
4, // ApplyNow
|
|
|
|
5 // ForceTemporarily
|
2004-06-21 16:25:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const Rules::SetRule combo_to_set_rule[] =
|
|
|
|
{
|
|
|
|
( Rules::SetRule )Rules::DontAffect,
|
|
|
|
( Rules::SetRule )Rules::Apply,
|
|
|
|
( Rules::SetRule )Rules::Remember,
|
2005-06-07 15:31:15 +00:00
|
|
|
( Rules::SetRule )Rules::Force,
|
|
|
|
( Rules::SetRule )Rules::ApplyNow,
|
|
|
|
( Rules::SetRule )Rules::ForceTemporarily
|
2004-06-21 16:25:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const int force_rule_to_combo[] =
|
|
|
|
{
|
|
|
|
0, // Unused
|
|
|
|
0, // Don't Affect
|
2005-06-07 15:31:15 +00:00
|
|
|
1, // Force
|
|
|
|
0, // Apply
|
|
|
|
0, // Remember
|
|
|
|
0, // ApplyNow
|
|
|
|
2 // ForceTemporarily
|
2004-06-21 16:25:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const Rules::ForceRule combo_to_force_rule[] =
|
|
|
|
{
|
|
|
|
( Rules::ForceRule )Rules::DontAffect,
|
2005-06-07 15:31:15 +00:00
|
|
|
( Rules::ForceRule )Rules::Force,
|
|
|
|
( Rules::ForceRule )Rules::ForceTemporarily
|
2004-06-21 16:25:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static QString positionToStr( const QPoint& p )
|
|
|
|
{
|
2004-07-29 16:44:20 +00:00
|
|
|
if( p == invalidPoint )
|
2006-01-02 16:27:55 +00:00
|
|
|
return QString();
|
2004-06-21 16:25:24 +00:00
|
|
|
return QString::number( p.x()) + "," + QString::number( p.y());
|
|
|
|
}
|
|
|
|
|
|
|
|
static QPoint strToPosition( const QString& str )
|
|
|
|
{ // two numbers, with + or -, separated by any of , x X :
|
2004-07-19 14:06:27 +00:00
|
|
|
QRegExp reg( "\\s*([+-]?[0-9]*)\\s*[,xX:]\\s*([+-]?[0-9]*)\\s*" );
|
2004-06-21 16:25:24 +00:00
|
|
|
if( !reg.exactMatch( str ))
|
|
|
|
return invalidPoint;
|
|
|
|
return QPoint( reg.cap( 1 ).toInt(), reg.cap( 2 ).toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString sizeToStr( const QSize& s )
|
|
|
|
{
|
2004-06-28 13:47:33 +00:00
|
|
|
if( !s.isValid())
|
2006-01-02 16:27:55 +00:00
|
|
|
return QString();
|
2004-06-21 16:25:24 +00:00
|
|
|
return QString::number( s.width()) + "," + QString::number( s.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
static QSize strToSize( const QString& str )
|
|
|
|
{ // two numbers, with + or -, separated by any of , x X :
|
2004-07-19 14:06:27 +00:00
|
|
|
QRegExp reg( "\\s*([+-]?[0-9]*)\\s*[,xX:]\\s*([+-]?[0-9]*)\\s*" );
|
2004-06-21 16:25:24 +00:00
|
|
|
if( !reg.exactMatch( str ))
|
|
|
|
return QSize();
|
|
|
|
return QSize( reg.cap( 1 ).toInt(), reg.cap( 2 ).toInt());
|
|
|
|
}
|
|
|
|
|
2005-01-15 17:07:48 +00:00
|
|
|
//used for opacity settings
|
|
|
|
static QString intToStr( const int& s )
|
|
|
|
{
|
|
|
|
if( s < 1 || s > 100 )
|
2006-01-02 16:27:55 +00:00
|
|
|
return QString();
|
2005-01-15 17:07:48 +00:00
|
|
|
return QString::number(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int strToInt( const QString& str )
|
|
|
|
{
|
|
|
|
int tmp = str.toInt();
|
|
|
|
if( tmp < 1 || tmp > 100 )
|
|
|
|
return 100;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2004-10-12 15:08:31 +00:00
|
|
|
int RulesWidget::desktopToCombo( int d ) const
|
2004-06-21 16:25:24 +00:00
|
|
|
{
|
2004-10-12 15:08:31 +00:00
|
|
|
if( d >= 1 && d < desktop->count())
|
|
|
|
return d - 1;
|
|
|
|
return desktop->count() - 1; // on all desktops
|
2004-06-21 16:25:24 +00:00
|
|
|
}
|
|
|
|
|
2004-10-12 15:08:31 +00:00
|
|
|
int RulesWidget::comboToDesktop( int val ) const
|
2004-06-21 16:25:24 +00:00
|
|
|
{
|
2004-10-12 15:08:31 +00:00
|
|
|
if( val == desktop->count() - 1 )
|
2004-06-21 16:25:24 +00:00
|
|
|
return NET::OnAllDesktops;
|
|
|
|
return val + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int placementToCombo( Placement::Policy placement )
|
|
|
|
{
|
|
|
|
static const int conv[] =
|
|
|
|
{
|
|
|
|
1, // NoPlacement
|
|
|
|
0, // Default
|
2005-08-08 14:25:41 +00:00
|
|
|
0, // Unknown
|
2005-08-08 14:22:52 +00:00
|
|
|
6, // Random
|
2004-06-21 16:25:24 +00:00
|
|
|
2, // Smart
|
2005-08-08 14:22:52 +00:00
|
|
|
4, // Cascade
|
|
|
|
5, // Centered
|
|
|
|
7, // ZeroCornered
|
|
|
|
8, // UnderMouse
|
|
|
|
9, // OnMainWindow
|
|
|
|
3 // Maximizing
|
2004-06-21 16:25:24 +00:00
|
|
|
};
|
|
|
|
return conv[ placement ];
|
|
|
|
}
|
|
|
|
|
|
|
|
static Placement::Policy comboToPlacement( int val )
|
|
|
|
{
|
|
|
|
static const Placement::Policy conv[] =
|
|
|
|
{
|
|
|
|
Placement::Default,
|
|
|
|
Placement::NoPlacement,
|
|
|
|
Placement::Smart,
|
2005-08-08 14:22:52 +00:00
|
|
|
Placement::Maximizing,
|
2004-06-21 16:25:24 +00:00
|
|
|
Placement::Cascade,
|
|
|
|
Placement::Centered,
|
|
|
|
Placement::Random,
|
|
|
|
Placement::ZeroCornered,
|
|
|
|
Placement::UnderMouse,
|
|
|
|
Placement::OnMainWindow
|
2005-08-08 14:25:41 +00:00
|
|
|
// no Placement::Unknown
|
2004-06-21 16:25:24 +00:00
|
|
|
};
|
|
|
|
return conv[ val ];
|
|
|
|
}
|
|
|
|
|
|
|
|
static int moveresizeToCombo( Options::MoveResizeMode mode )
|
|
|
|
{
|
|
|
|
return mode == Options::Opaque ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Options::MoveResizeMode comboToMoveResize( int val )
|
|
|
|
{
|
|
|
|
return val == 0 ? Options::Opaque : Options::Transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int typeToCombo( NET::WindowType type )
|
|
|
|
{
|
|
|
|
if( type < NET::Normal || type > NET::Splash )
|
|
|
|
return 0; // Normal
|
|
|
|
static const int conv[] =
|
|
|
|
{
|
|
|
|
0, // Normal
|
|
|
|
7, // Desktop
|
|
|
|
3, // Dock
|
|
|
|
4, // Toolbar
|
|
|
|
5, // Menu
|
|
|
|
1, // Dialog
|
|
|
|
8, // Override
|
|
|
|
9, // TopMenu
|
|
|
|
2, // Utility
|
|
|
|
6 // Splash
|
|
|
|
};
|
|
|
|
return conv[ type ];
|
|
|
|
}
|
|
|
|
|
|
|
|
static NET::WindowType comboToType( int val )
|
|
|
|
{
|
|
|
|
static const NET::WindowType conv[] =
|
|
|
|
{
|
|
|
|
NET::Normal,
|
|
|
|
NET::Dialog,
|
|
|
|
NET::Utility,
|
|
|
|
NET::Dock,
|
|
|
|
NET::Toolbar,
|
|
|
|
NET::Menu,
|
|
|
|
NET::Splash,
|
|
|
|
NET::Desktop,
|
|
|
|
NET::Override,
|
|
|
|
NET::TopMenu
|
|
|
|
};
|
|
|
|
return conv[ val ];
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GENERIC_RULE( var, func, Type, type, uimethod, uimethod0 ) \
|
|
|
|
if( rules->var##rule == Rules::Unused##Type##Rule ) \
|
|
|
|
{ \
|
|
|
|
enable_##var->setChecked( false ); \
|
2006-02-22 10:12:16 +00:00
|
|
|
rule_##var->setCurrentIndex( 0 ); \
|
2005-07-28 14:59:42 +00:00
|
|
|
Ui_RulesWidgetBase::var->uimethod0; \
|
2004-06-21 16:25:24 +00:00
|
|
|
updateEnable##var(); \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
enable_##var->setChecked( true ); \
|
2006-02-22 10:12:16 +00:00
|
|
|
rule_##var->setCurrentIndex( type##_rule_to_combo[ rules->var##rule ] ); \
|
2005-07-28 14:59:42 +00:00
|
|
|
Ui_RulesWidgetBase::var->uimethod( func( rules->var )); \
|
2004-06-21 16:25:24 +00:00
|
|
|
updateEnable##var(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECKBOX_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, setChecked, setChecked( false ))
|
|
|
|
#define LINEEDIT_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, setText, setText( "" ))
|
2006-02-22 10:12:16 +00:00
|
|
|
#define COMBOBOX_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, setCurrentIndex, setCurrentIndex( 0 ))
|
2004-06-21 16:25:24 +00:00
|
|
|
#define CHECKBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, setChecked, setChecked( false ))
|
|
|
|
#define LINEEDIT_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, setText, setText( "" ))
|
2006-02-22 10:12:16 +00:00
|
|
|
#define COMBOBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, setCurrentIndex, setCurrentIndex( 0 ))
|
2004-06-21 16:25:24 +00:00
|
|
|
|
|
|
|
void RulesWidget::setRules( Rules* rules )
|
|
|
|
{
|
|
|
|
Rules tmp;
|
|
|
|
if( rules == NULL )
|
|
|
|
rules = &tmp; // empty
|
|
|
|
description->setText( rules->description );
|
|
|
|
wmclass->setText( rules->wmclass );
|
|
|
|
whole_wmclass->setChecked( rules->wmclasscomplete );
|
2006-02-22 10:12:16 +00:00
|
|
|
wmclass_match->setCurrentIndex( rules->wmclassmatch );
|
2004-06-25 11:28:17 +00:00
|
|
|
wmclassMatchChanged();
|
2004-06-21 16:25:24 +00:00
|
|
|
role->setText( rules->windowrole );
|
2006-02-22 10:12:16 +00:00
|
|
|
role_match->setCurrentIndex( rules->windowrolematch );
|
2004-06-25 11:28:17 +00:00
|
|
|
roleMatchChanged();
|
2004-06-21 16:25:24 +00:00
|
|
|
types->setSelected( 0, rules->types & NET::NormalMask );
|
|
|
|
types->setSelected( 1, rules->types & NET::DialogMask );
|
|
|
|
types->setSelected( 2, rules->types & NET::UtilityMask );
|
|
|
|
types->setSelected( 3, rules->types & NET::DockMask );
|
|
|
|
types->setSelected( 4, rules->types & NET::ToolbarMask );
|
|
|
|
types->setSelected( 5, rules->types & NET::MenuMask );
|
|
|
|
types->setSelected( 6, rules->types & NET::SplashMask );
|
|
|
|
types->setSelected( 7, rules->types & NET::DesktopMask );
|
|
|
|
types->setSelected( 8, rules->types & NET::OverrideMask );
|
|
|
|
types->setSelected( 9, rules->types & NET::TopMenuMask );
|
|
|
|
title->setText( rules->title );
|
2006-02-22 10:12:16 +00:00
|
|
|
title_match->setCurrentIndex( rules->titlematch );
|
2004-06-25 11:28:17 +00:00
|
|
|
titleMatchChanged();
|
2004-06-21 16:25:24 +00:00
|
|
|
extra->setText( rules->extrarole );
|
2006-02-22 10:12:16 +00:00
|
|
|
extra_match->setCurrentIndex( rules->extrarolematch );
|
2004-06-25 11:28:17 +00:00
|
|
|
extraMatchChanged();
|
2004-06-21 16:25:24 +00:00
|
|
|
machine->setText( rules->clientmachine );
|
2006-02-22 10:12:16 +00:00
|
|
|
machine_match->setCurrentIndex( rules->clientmachinematch );
|
2004-06-25 11:28:17 +00:00
|
|
|
machineMatchChanged();
|
2004-06-21 16:25:24 +00:00
|
|
|
LINEEDIT_SET_RULE( position, positionToStr );
|
|
|
|
LINEEDIT_SET_RULE( size, sizeToStr );
|
|
|
|
COMBOBOX_SET_RULE( desktop, desktopToCombo );
|
|
|
|
CHECKBOX_SET_RULE( maximizehoriz, );
|
|
|
|
CHECKBOX_SET_RULE( maximizevert, );
|
|
|
|
CHECKBOX_SET_RULE( minimize, );
|
|
|
|
CHECKBOX_SET_RULE( shade, );
|
|
|
|
CHECKBOX_SET_RULE( fullscreen, );
|
|
|
|
COMBOBOX_FORCE_RULE( placement, placementToCombo );
|
|
|
|
CHECKBOX_SET_RULE( above, );
|
|
|
|
CHECKBOX_SET_RULE( below, );
|
|
|
|
CHECKBOX_SET_RULE( noborder, );
|
|
|
|
CHECKBOX_SET_RULE( skiptaskbar, );
|
|
|
|
CHECKBOX_SET_RULE( skippager, );
|
|
|
|
CHECKBOX_FORCE_RULE( acceptfocus, );
|
|
|
|
CHECKBOX_FORCE_RULE( closeable, );
|
2005-01-17 13:16:47 +00:00
|
|
|
LINEEDIT_FORCE_RULE( opacityactive, intToStr );
|
|
|
|
LINEEDIT_FORCE_RULE( opacityinactive, intToStr );
|
2005-01-17 15:53:14 +00:00
|
|
|
LINEEDIT_SET_RULE( shortcut, );
|
2004-06-21 16:25:24 +00:00
|
|
|
COMBOBOX_FORCE_RULE( fsplevel, );
|
|
|
|
COMBOBOX_FORCE_RULE( moveresizemode, moveresizeToCombo );
|
|
|
|
COMBOBOX_FORCE_RULE( type, typeToCombo );
|
|
|
|
CHECKBOX_FORCE_RULE( ignoreposition, );
|
|
|
|
LINEEDIT_FORCE_RULE( minsize, sizeToStr );
|
|
|
|
LINEEDIT_FORCE_RULE( maxsize, sizeToStr );
|
2005-01-17 13:35:48 +00:00
|
|
|
CHECKBOX_FORCE_RULE( strictgeometry, );
|
2005-08-02 13:25:20 +00:00
|
|
|
CHECKBOX_FORCE_RULE( disableglobalshortcuts, );
|
2004-06-21 16:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef GENERIC_RULE
|
|
|
|
#undef CHECKBOX_SET_RULE
|
|
|
|
#undef LINEEDIT_SET_RULE
|
|
|
|
#undef COMBOBOX_SET_RULE
|
|
|
|
#undef CHECKBOX_FORCE_RULE
|
|
|
|
#undef LINEEDIT_FORCE_RULE
|
|
|
|
#undef COMBOBOX_FORCE_RULE
|
|
|
|
|
|
|
|
#define GENERIC_RULE( var, func, Type, type, uimethod ) \
|
2006-04-18 16:33:11 +00:00
|
|
|
if( enable_##var->isChecked() && rule_##var->currentIndex() >= 0) \
|
2004-06-21 16:25:24 +00:00
|
|
|
{ \
|
2006-03-06 15:51:12 +00:00
|
|
|
rules->var##rule = combo_to_##type##_rule[ rule_##var->currentIndex() ]; \
|
2005-07-28 14:59:42 +00:00
|
|
|
rules->var = func( Ui_RulesWidgetBase::var->uimethod()); \
|
2004-06-21 16:25:24 +00:00
|
|
|
} \
|
|
|
|
else \
|
|
|
|
rules->var##rule = Rules::Unused##Type##Rule;
|
|
|
|
|
|
|
|
#define CHECKBOX_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, isChecked )
|
|
|
|
#define LINEEDIT_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, text )
|
2006-04-11 18:59:35 +00:00
|
|
|
#define COMBOBOX_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, currentIndex )
|
2004-06-21 16:25:24 +00:00
|
|
|
#define CHECKBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, isChecked )
|
|
|
|
#define LINEEDIT_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, text )
|
2006-04-11 18:59:35 +00:00
|
|
|
#define COMBOBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, currentIndex )
|
2004-06-21 16:25:24 +00:00
|
|
|
|
|
|
|
Rules* RulesWidget::rules() const
|
|
|
|
{
|
|
|
|
Rules* rules = new Rules();
|
|
|
|
rules->description = description->text();
|
2005-09-24 12:26:22 +00:00
|
|
|
rules->wmclass = wmclass->text().toUtf8();
|
2004-06-21 16:25:24 +00:00
|
|
|
rules->wmclasscomplete = whole_wmclass->isChecked();
|
2006-03-06 15:51:12 +00:00
|
|
|
rules->wmclassmatch = static_cast< Rules::StringMatch >( wmclass_match->currentIndex());
|
2005-09-24 12:26:22 +00:00
|
|
|
rules->windowrole = role->text().toUtf8();
|
2006-03-06 15:51:12 +00:00
|
|
|
rules->windowrolematch = static_cast< Rules::StringMatch >( role_match->currentIndex());
|
2004-06-21 16:25:24 +00:00
|
|
|
rules->types = 0;
|
|
|
|
bool all_types = true;
|
2004-07-14 14:27:47 +00:00
|
|
|
for( unsigned int i = 0;
|
2004-06-28 14:28:11 +00:00
|
|
|
i < types->count();
|
2004-06-21 16:25:24 +00:00
|
|
|
++i )
|
|
|
|
if( !types->isSelected( i ))
|
|
|
|
all_types = false;
|
|
|
|
if( all_types ) // if all types are selected, use AllTypesMask (for future expansion)
|
|
|
|
rules->types = NET::AllTypesMask;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rules->types |= types->isSelected( 0 ) ? NET::NormalMask : 0;
|
|
|
|
rules->types |= types->isSelected( 1 ) ? NET::DialogMask : 0;
|
|
|
|
rules->types |= types->isSelected( 2 ) ? NET::UtilityMask : 0;
|
|
|
|
rules->types |= types->isSelected( 3 ) ? NET::DockMask : 0;
|
|
|
|
rules->types |= types->isSelected( 4 ) ? NET::ToolbarMask : 0;
|
|
|
|
rules->types |= types->isSelected( 5 ) ? NET::MenuMask : 0;
|
|
|
|
rules->types |= types->isSelected( 6 ) ? NET::SplashMask : 0;
|
|
|
|
rules->types |= types->isSelected( 7 ) ? NET::DesktopMask : 0;
|
|
|
|
rules->types |= types->isSelected( 8 ) ? NET::OverrideMask : 0;
|
|
|
|
rules->types |= types->isSelected( 9 ) ? NET::TopMenuMask : 0;
|
|
|
|
}
|
|
|
|
rules->title = title->text();
|
2006-03-06 15:51:12 +00:00
|
|
|
rules->titlematch = static_cast< Rules::StringMatch >( title_match->currentIndex());
|
2005-09-24 12:26:22 +00:00
|
|
|
rules->extrarole = extra->text().toUtf8();
|
2006-03-06 15:51:12 +00:00
|
|
|
rules->extrarolematch = static_cast< Rules::StringMatch >( extra_match->currentIndex());
|
2005-09-24 12:26:22 +00:00
|
|
|
rules->clientmachine = machine->text().toUtf8();
|
2006-03-06 15:51:12 +00:00
|
|
|
rules->clientmachinematch = static_cast< Rules::StringMatch >( machine_match->currentIndex());
|
2004-06-21 16:25:24 +00:00
|
|
|
LINEEDIT_SET_RULE( position, strToPosition );
|
|
|
|
LINEEDIT_SET_RULE( size, strToSize );
|
|
|
|
COMBOBOX_SET_RULE( desktop, comboToDesktop );
|
|
|
|
CHECKBOX_SET_RULE( maximizehoriz, );
|
|
|
|
CHECKBOX_SET_RULE( maximizevert, );
|
|
|
|
CHECKBOX_SET_RULE( minimize, );
|
|
|
|
CHECKBOX_SET_RULE( shade, );
|
|
|
|
CHECKBOX_SET_RULE( fullscreen, );
|
|
|
|
COMBOBOX_FORCE_RULE( placement, comboToPlacement );
|
|
|
|
CHECKBOX_SET_RULE( above, );
|
|
|
|
CHECKBOX_SET_RULE( below, );
|
|
|
|
CHECKBOX_SET_RULE( noborder, );
|
|
|
|
CHECKBOX_SET_RULE( skiptaskbar, );
|
|
|
|
CHECKBOX_SET_RULE( skippager, );
|
|
|
|
CHECKBOX_FORCE_RULE( acceptfocus, );
|
|
|
|
CHECKBOX_FORCE_RULE( closeable, );
|
2005-01-17 13:16:47 +00:00
|
|
|
LINEEDIT_FORCE_RULE( opacityactive, strToInt );
|
|
|
|
LINEEDIT_FORCE_RULE( opacityinactive, strToInt );
|
2005-01-17 15:53:14 +00:00
|
|
|
LINEEDIT_SET_RULE( shortcut, );
|
2004-06-21 16:25:24 +00:00
|
|
|
COMBOBOX_FORCE_RULE( fsplevel, );
|
|
|
|
COMBOBOX_FORCE_RULE( moveresizemode, comboToMoveResize );
|
|
|
|
COMBOBOX_FORCE_RULE( type, comboToType );
|
|
|
|
CHECKBOX_FORCE_RULE( ignoreposition, );
|
|
|
|
LINEEDIT_FORCE_RULE( minsize, strToSize );
|
|
|
|
LINEEDIT_FORCE_RULE( maxsize, strToSize );
|
2005-01-17 13:35:48 +00:00
|
|
|
CHECKBOX_FORCE_RULE( strictgeometry, );
|
2005-08-02 13:25:20 +00:00
|
|
|
CHECKBOX_FORCE_RULE( disableglobalshortcuts, );
|
2004-06-21 16:25:24 +00:00
|
|
|
return rules;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef GENERIC_RULE
|
|
|
|
#undef CHECKBOX_SET_RULE
|
|
|
|
#undef LINEEDIT_SET_RULE
|
|
|
|
#undef COMBOBOX_SET_RULE
|
|
|
|
#undef CHECKBOX_FORCE_RULE
|
|
|
|
#undef LINEEDIT_FORCE_RULE
|
|
|
|
#undef COMBOBOX_FORCE_RULE
|
|
|
|
|
2004-06-25 11:28:17 +00:00
|
|
|
#define STRING_MATCH_COMBO( type ) \
|
|
|
|
void RulesWidget::type##MatchChanged() \
|
|
|
|
{ \
|
2006-03-06 15:51:12 +00:00
|
|
|
edit_reg_##type->setEnabled( type##_match->currentIndex() == Rules::RegExpMatch ); \
|
|
|
|
type->setEnabled( type##_match->currentIndex() != Rules::UnimportantMatch ); \
|
2004-06-25 11:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
STRING_MATCH_COMBO( wmclass )
|
|
|
|
STRING_MATCH_COMBO( role )
|
|
|
|
STRING_MATCH_COMBO( title )
|
|
|
|
STRING_MATCH_COMBO( extra )
|
|
|
|
STRING_MATCH_COMBO( machine )
|
|
|
|
|
|
|
|
#undef STRING_MATCH_COMBO
|
|
|
|
|
2004-06-22 16:31:57 +00:00
|
|
|
void RulesWidget::detectClicked()
|
|
|
|
{
|
|
|
|
assert( detect_dlg == NULL );
|
|
|
|
detect_dlg = new DetectDialog;
|
|
|
|
connect( detect_dlg, SIGNAL( detectionDone( bool )), this, SLOT( detected( bool )));
|
|
|
|
detect_dlg->detect( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void RulesWidget::detected( bool ok )
|
|
|
|
{
|
2004-06-22 18:10:21 +00:00
|
|
|
if( ok )
|
|
|
|
{
|
|
|
|
wmclass->setText( detect_dlg->selectedClass());
|
2006-02-22 10:12:16 +00:00
|
|
|
wmclass_match->setCurrentIndex( Rules::ExactMatch );
|
2004-06-25 11:28:17 +00:00
|
|
|
wmclassMatchChanged(); // grrr
|
2004-06-22 18:10:21 +00:00
|
|
|
whole_wmclass->setChecked( detect_dlg->selectedWholeClass());
|
|
|
|
role->setText( detect_dlg->selectedRole());
|
2006-02-22 10:12:16 +00:00
|
|
|
role_match->setCurrentIndex( detect_dlg->selectedRole().isEmpty()
|
2004-06-25 11:28:17 +00:00
|
|
|
? Rules::UnimportantMatch : Rules::ExactMatch );
|
|
|
|
roleMatchChanged();
|
2004-07-30 13:35:55 +00:00
|
|
|
if( detect_dlg->selectedWholeApp())
|
|
|
|
{
|
|
|
|
for( unsigned int i = 0;
|
|
|
|
i < types->count();
|
|
|
|
++i )
|
|
|
|
types->setSelected( i, true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NET::WindowType type = detect_dlg->selectedType();
|
|
|
|
for( unsigned int i = 0;
|
|
|
|
i < types->count();
|
|
|
|
++i )
|
|
|
|
types->setSelected( i, false );
|
|
|
|
types->setSelected( typeToCombo( type ), true );
|
|
|
|
}
|
|
|
|
title->setText( detect_dlg->selectedTitle());
|
2006-02-22 10:12:16 +00:00
|
|
|
title_match->setCurrentIndex( detect_dlg->titleMatch());
|
2004-07-30 13:35:55 +00:00
|
|
|
titleMatchChanged();
|
|
|
|
machine->setText( detect_dlg->selectedMachine());
|
2006-02-22 10:12:16 +00:00
|
|
|
machine_match->setCurrentIndex( Rules::UnimportantMatch );
|
2004-07-30 13:35:55 +00:00
|
|
|
machineMatchChanged();
|
2004-08-04 11:00:40 +00:00
|
|
|
// prefill values from to window to settings which already set
|
|
|
|
const KWin::WindowInfo& info = detect_dlg->windowInfo();
|
2004-11-10 11:41:12 +00:00
|
|
|
prefillUnusedValues( info );
|
2004-06-22 18:10:21 +00:00
|
|
|
}
|
2004-06-22 16:31:57 +00:00
|
|
|
delete detect_dlg;
|
|
|
|
detect_dlg = NULL;
|
2004-07-29 17:08:25 +00:00
|
|
|
detect_dlg_ok = ok;
|
2004-06-22 16:31:57 +00:00
|
|
|
}
|
|
|
|
|
2004-11-10 11:41:12 +00:00
|
|
|
#define GENERIC_PREFILL( var, func, info, uimethod ) \
|
|
|
|
if( !enable_##var->isChecked()) \
|
|
|
|
{ \
|
2005-07-28 14:59:42 +00:00
|
|
|
Ui_RulesWidgetBase::var->uimethod( func( info )); \
|
2004-11-10 11:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECKBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setChecked )
|
|
|
|
#define LINEEDIT_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setText )
|
2006-02-22 10:12:16 +00:00
|
|
|
#define COMBOBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setCurrentIndex )
|
2004-11-10 11:41:12 +00:00
|
|
|
|
|
|
|
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, );
|
2005-01-17 13:16:47 +00:00
|
|
|
LINEEDIT_PREFILL( opacityactive, intToStr, 100 /*get the actual opacity somehow*/);
|
|
|
|
LINEEDIT_PREFILL( opacityinactive, intToStr, 100 /*get the actual opacity somehow*/);
|
2005-01-17 15:53:14 +00:00
|
|
|
//LINEEDIT_PREFILL( shortcut, );
|
2004-11-10 11:41:12 +00:00
|
|
|
//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() );
|
2005-01-17 13:35:48 +00:00
|
|
|
//CHECKBOX_PREFILL( strictgeometry, );
|
2005-08-02 13:25:20 +00:00
|
|
|
//CHECKBOX_PREFILL( disableglobalshortcuts, );
|
2004-11-10 11:41:12 +00:00
|
|
|
}
|
|
|
|
|
2004-08-04 11:00:40 +00:00
|
|
|
#undef GENERIC_PREFILL
|
|
|
|
#undef CHECKBOX_PREFILL
|
|
|
|
#undef LINEEDIT_PREFILL
|
|
|
|
#undef COMBOBOX_PREFILL
|
|
|
|
|
2004-06-28 14:28:11 +00:00
|
|
|
bool RulesWidget::finalCheck()
|
|
|
|
{
|
2004-07-14 14:27:47 +00:00
|
|
|
if( description->text().isEmpty())
|
|
|
|
{
|
|
|
|
if( !wmclass->text().isEmpty())
|
2006-04-10 11:57:13 +00:00
|
|
|
description->setText( i18n( "Settings for %1", wmclass->text()));
|
2004-07-14 14:27:47 +00:00
|
|
|
else
|
|
|
|
description->setText( i18n( "Unnamed entry" ));
|
|
|
|
}
|
2004-06-28 14:28:11 +00:00
|
|
|
bool all_types = true;
|
2004-07-14 14:27:47 +00:00
|
|
|
for( unsigned int i = 0;
|
2004-06-28 14:28:11 +00:00
|
|
|
i < types->count();
|
|
|
|
++i )
|
|
|
|
if( !types->isSelected( i ))
|
|
|
|
all_types = false;
|
2006-03-06 15:51:12 +00:00
|
|
|
if( wmclass_match->currentIndex() == Rules::UnimportantMatch && all_types )
|
2004-06-28 14:28:11 +00:00
|
|
|
{
|
|
|
|
if( KMessageBox::warningContinueCancel( topLevelWidget(),
|
|
|
|
i18n( "You have specified the window class as unimportant.\n"
|
|
|
|
"This means the settings will possibly apply to windows from all applications. "
|
|
|
|
"If you really want to create a generic setting, it is recommended you at least "
|
|
|
|
"limit the window types to avoid special window types." )) != KMessageBox::Continue )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-11-10 11:41:12 +00:00
|
|
|
void RulesWidget::prepareWindowSpecific( WId window )
|
2004-11-10 11:07:51 +00:00
|
|
|
{
|
2006-04-12 15:13:31 +00:00
|
|
|
tabs->setCurrentIndex( 2 ); // geometry tab, skip tabs for window identification
|
2004-11-10 11:41:12 +00:00
|
|
|
KWin::WindowInfo info( window, -1U, -1U ); // read everything
|
|
|
|
prefillUnusedValues( info );
|
2004-11-10 11:07:51 +00:00
|
|
|
}
|
|
|
|
|
2005-01-17 15:53:14 +00:00
|
|
|
void RulesWidget::shortcutEditClicked()
|
|
|
|
{
|
2005-02-02 18:57:21 +00:00
|
|
|
EditShortcutDialog dlg( topLevelWidget());
|
|
|
|
dlg.setShortcut( shortcut->text());
|
|
|
|
if( dlg.exec() == QDialog::Accepted )
|
|
|
|
shortcut->setText( dlg.shortcut());
|
2005-01-17 15:53:14 +00:00
|
|
|
}
|
|
|
|
|
2004-06-21 16:25:24 +00:00
|
|
|
RulesDialog::RulesDialog( QWidget* parent, const char* name )
|
2006-04-12 15:13:31 +00:00
|
|
|
: KDialogBase( Swallow, 0, parent, name, true, i18n( "Edit Window-Specific Settings" ), Ok | Cancel )
|
2004-06-21 16:25:24 +00:00
|
|
|
{
|
|
|
|
widget = new RulesWidget( this );
|
|
|
|
setMainWidget( widget );
|
|
|
|
}
|
|
|
|
|
2004-11-10 11:41:12 +00:00
|
|
|
// window is set only for Alt+F3/Window-specific settings, because the dialog
|
|
|
|
// is then related to one specific window
|
2005-08-19 13:46:45 +00:00
|
|
|
Rules* RulesDialog::edit( Rules* r, WId window, bool show_hints )
|
2004-06-21 16:25:24 +00:00
|
|
|
{
|
|
|
|
rules = r;
|
|
|
|
widget->setRules( rules );
|
2004-11-10 11:41:12 +00:00
|
|
|
if( window != 0 )
|
|
|
|
widget->prepareWindowSpecific( window );
|
2005-08-19 13:46:45 +00:00
|
|
|
if( show_hints )
|
|
|
|
QTimer::singleShot( 0, this, SLOT( displayHints()));
|
2004-06-21 16:25:24 +00:00
|
|
|
exec();
|
|
|
|
return rules;
|
|
|
|
}
|
|
|
|
|
2005-08-19 13:46:45 +00:00
|
|
|
void RulesDialog::displayHints()
|
|
|
|
{
|
|
|
|
QString str = "<qt><p>";
|
|
|
|
str += i18n( "This configuration dialog allows altering settings only for the selected window"
|
|
|
|
" or application. Find the setting you want to affect, enable the setting using the checkbox,"
|
|
|
|
" select in what way the setting should be affected and to which value." );
|
|
|
|
#if 0 // maybe later
|
|
|
|
str += "</p><p>" + i18n( "Consult the documentation for more details." );
|
|
|
|
#endif
|
|
|
|
str += "</p></qt>";
|
2006-01-02 16:27:55 +00:00
|
|
|
KMessageBox::information( this, str, QString(), "displayhints" );
|
2005-08-19 13:46:45 +00:00
|
|
|
}
|
|
|
|
|
2004-06-21 16:25:24 +00:00
|
|
|
void RulesDialog::accept()
|
|
|
|
{
|
2004-06-28 14:28:11 +00:00
|
|
|
if( !widget->finalCheck())
|
|
|
|
return;
|
2004-06-21 16:25:24 +00:00
|
|
|
rules = widget->rules();
|
2004-06-28 14:28:11 +00:00
|
|
|
KDialogBase::accept();
|
2004-06-21 16:25:24 +00:00
|
|
|
}
|
|
|
|
|
2006-01-09 21:34:47 +00:00
|
|
|
EditShortcut::EditShortcut( QWidget* parent )
|
|
|
|
: EditShortcutBase( parent )
|
2005-02-02 18:57:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditShortcut::editShortcut()
|
|
|
|
{
|
|
|
|
ShortcutDialog dlg( KShortcut( shortcut->text()), topLevelWidget());
|
|
|
|
if( dlg.exec() == QDialog::Accepted )
|
|
|
|
shortcut->setText( dlg.shortcut().toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditShortcut::clearShortcut()
|
|
|
|
{
|
|
|
|
shortcut->setText( "" );
|
|
|
|
}
|
|
|
|
|
|
|
|
EditShortcutDialog::EditShortcutDialog( QWidget* parent, const char* name )
|
2006-04-12 15:13:31 +00:00
|
|
|
: KDialogBase( Swallow, 0, parent, name, true, i18n( "Edit Shortcut" ), Ok | Cancel )
|
2005-02-02 18:57:21 +00:00
|
|
|
{
|
|
|
|
widget = new EditShortcut( this );
|
|
|
|
setMainWidget( widget );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditShortcutDialog::setShortcut( const QString& cut )
|
|
|
|
{
|
|
|
|
widget->shortcut->setText( cut );
|
|
|
|
}
|
|
|
|
|
|
|
|
QString EditShortcutDialog::shortcut() const
|
|
|
|
{
|
|
|
|
return widget->shortcut->text();
|
|
|
|
}
|
|
|
|
|
2006-01-09 21:34:47 +00:00
|
|
|
ShortcutDialog::ShortcutDialog( const KShortcut& cut, QWidget* parent )
|
2006-04-10 11:57:13 +00:00
|
|
|
: KShortcutDialog( cut, parent )
|
2005-02-02 18:57:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShortcutDialog::accept()
|
|
|
|
{
|
|
|
|
for( int i = 0;
|
|
|
|
;
|
|
|
|
++i )
|
|
|
|
{
|
2006-04-10 11:57:13 +00:00
|
|
|
QKeySequence seq = shortcut().seq( i );
|
|
|
|
if( seq.isEmpty())
|
2005-02-02 18:57:21 +00:00
|
|
|
break;
|
2006-04-10 11:57:13 +00:00
|
|
|
if( seq[0] == Qt::Key_Escape )
|
2005-02-02 18:57:21 +00:00
|
|
|
{
|
|
|
|
reject();
|
|
|
|
return;
|
|
|
|
}
|
2006-04-10 11:57:13 +00:00
|
|
|
if( seq[0] == Qt::Key_Space )
|
2005-02-02 18:57:21 +00:00
|
|
|
{ // clear
|
|
|
|
setShortcut( KShortcut());
|
|
|
|
KShortcutDialog::accept();
|
|
|
|
return;
|
|
|
|
}
|
2006-04-10 11:57:13 +00:00
|
|
|
if( (seq[0] & Qt::KeyboardModifierMask) == 0 )
|
2005-02-02 18:57:21 +00:00
|
|
|
{ // no shortcuts without modifiers
|
|
|
|
KShortcut cut = shortcut();
|
2006-04-10 11:57:13 +00:00
|
|
|
cut.setSeq( i, QKeySequence());
|
2005-02-02 18:57:21 +00:00
|
|
|
setShortcut( cut );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
KShortcutDialog::accept();
|
|
|
|
}
|
|
|
|
|
2004-06-21 16:25:24 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "ruleswidget.moc"
|