From e8d21fc0cdb7a062dd14b767bc1e4d7cabb57a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Tue, 22 Jun 2004 18:10:21 +0000 Subject: [PATCH] Make the detect button a bit more useful. svn path=/trunk/kdebase/kwin/; revision=322872 --- kcmkwin/kwinrules/detectwidget.cpp | 29 ++++- kcmkwin/kwinrules/detectwidget.h | 3 + kcmkwin/kwinrules/detectwidgetbase.ui | 178 ++++++++++++++++++-------- kcmkwin/kwinrules/ruleswidget.cpp | 6 + 4 files changed, 162 insertions(+), 54 deletions(-) diff --git a/kcmkwin/kwinrules/detectwidget.cpp b/kcmkwin/kwinrules/detectwidget.cpp index b1b05b944e..b92bd151a8 100644 --- a/kcmkwin/kwinrules/detectwidget.cpp +++ b/kcmkwin/kwinrules/detectwidget.cpp @@ -24,10 +24,12 @@ #include #include #include +#include #include #include #include +#include namespace KWinInternal { @@ -38,7 +40,7 @@ DetectWidget::DetectWidget( QWidget* parent, const char* name ) } DetectDialog::DetectDialog( QWidget* parent, const char* name ) -: KDialogBase( parent, name, true, "", Ok /*| Cancel*/ ) +: KDialogBase( parent, name, true, "", Ok | Cancel ) , grabber( NULL ) { widget = new DetectWidget( this ); @@ -140,6 +142,26 @@ void DetectDialog::executeDialog() emit detectionDone( exec() == QDialog::Accepted ); } +QCString DetectDialog::selectedClass() const + { + if( widget->use_class->isChecked() || widget->use_role->isChecked()) + return wmclass_class; + return wmclass_name + ' ' + wmclass_class; + } + +bool DetectDialog::selectedWholeClass() const + { + return widget->use_whole_class->isChecked(); + } + +QCString DetectDialog::selectedRole() const + { + if( widget->use_role->isChecked()) + return role; + return ""; + } + + void DetectDialog::selectWindow() { // use a dialog, so that all user input is blocked @@ -160,6 +182,11 @@ bool DetectDialog::eventFilter( QObject* o, QEvent* e ) return false; delete grabber; grabber = NULL; + if( static_cast< QMouseEvent* >( e )->button() != LeftButton ) + { + emit detectionDone( false ); + return true; + } readWindow( findWindow()); return true; } diff --git a/kcmkwin/kwinrules/detectwidget.h b/kcmkwin/kwinrules/detectwidget.h index 509082a52c..3841b34ecf 100644 --- a/kcmkwin/kwinrules/detectwidget.h +++ b/kcmkwin/kwinrules/detectwidget.h @@ -43,6 +43,9 @@ class DetectDialog public: DetectDialog( QWidget* parent = NULL, const char* name = NULL ); void detect( WId window ); + QCString selectedClass() const; + bool selectedWholeClass() const; + QCString selectedRole() const; signals: void detectionDone( bool ); protected: diff --git a/kcmkwin/kwinrules/detectwidgetbase.ui b/kcmkwin/kwinrules/detectwidgetbase.ui index c110a18f95..f5469081c0 100644 --- a/kcmkwin/kwinrules/detectwidgetbase.ui +++ b/kcmkwin/kwinrules/detectwidgetbase.ui @@ -8,8 +8,8 @@ 0 0 - 600 - 480 + 557 + 335 @@ -27,38 +27,28 @@ Information about the selected window: + + + line1 + + + HLine + + + Sunken + + + Horizontal + + - layout1 + layout2 unnamed - - - textLabel1 - - - Class: - - - - - textLabel13 - - - Machine: - - - - - textLabel4 - - - Type: - - textLabel11 @@ -67,25 +57,25 @@ Extra role: - + - title_label + textLabel1 - + Class: - + - class_label + textLabel3 - + Role: - + - extrarole_label + type_label @@ -99,30 +89,14 @@ Title: - + - machine_label + class_label - - - type_label - - - - - - - - textLabel3 - - - Role: - - role_label @@ -131,8 +105,106 @@ + + + title_label + + + + + + + + machine_label + + + + + + + + textLabel4 + + + Type: + + + + + extrarole_label + + + + + + + + textLabel13 + + + Machine: + + + + + buttonGroup1 + + + + + + + unnamed + + + + use_class + + + Use window &class (whole application) + + + Alt+C + + + true + + + For selecting all windows belonging to a specific application, selecting only window class should usually work. + + + + + use_role + + + Use window class and window &role (specific window) + + + Alt+R + + + For selecting a specific window in an application, both window class and window role should be selected. Window class will determine the application and window role the specific window in the application. Many applications don't provide useful window roles though. + + + + + use_whole_class + + + Use &whole window class (specific window) + + + Alt+W + + + With some (non-KDE) applications whole window class can be sufficient for selecting a specific window in an application, as they set whole window class to contain both application and window role. + + + + spacer1 diff --git a/kcmkwin/kwinrules/ruleswidget.cpp b/kcmkwin/kwinrules/ruleswidget.cpp index a77662cf14..c61bf2d5b6 100644 --- a/kcmkwin/kwinrules/ruleswidget.cpp +++ b/kcmkwin/kwinrules/ruleswidget.cpp @@ -473,6 +473,12 @@ void RulesWidget::detectClicked() void RulesWidget::detected( bool ok ) { + if( ok ) + { + wmclass->setText( detect_dlg->selectedClass()); + whole_wmclass->setChecked( detect_dlg->selectedWholeClass()); + role->setText( detect_dlg->selectedRole()); + } delete detect_dlg; detect_dlg = NULL; }