Make the detect button a bit more useful.

svn path=/trunk/kdebase/kwin/; revision=322872
This commit is contained in:
Luboš Luňák 2004-06-22 18:10:21 +00:00
parent 389771f957
commit e8d21fc0cd
4 changed files with 162 additions and 54 deletions

View file

@ -24,10 +24,12 @@
#include <kxerrorhandler.h>
#include <kwin.h>
#include <qlabel.h>
#include <qradiobutton.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <fixx11h.h>
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;
}

View file

@ -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:

View file

@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>480</height>
<width>557</width>
<height>335</height>
</rect>
</property>
<property name="caption">
@ -27,38 +27,28 @@
<string>Information about the selected window:</string>
</property>
</widget>
<widget class="Line">
<property name="name">
<cstring>line1</cstring>
</property>
<property name="frameShape">
<enum>HLine</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout1</cstring>
<cstring>layout2</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>textLabel1</cstring>
</property>
<property name="text">
<string>Class:</string>
</property>
</widget>
<widget class="QLabel" row="5" column="0">
<property name="name">
<cstring>textLabel13</cstring>
</property>
<property name="text">
<string>Machine:</string>
</property>
</widget>
<widget class="QLabel" row="2" column="0">
<property name="name">
<cstring>textLabel4</cstring>
</property>
<property name="text">
<string>Type:</string>
</property>
</widget>
<widget class="QLabel" row="4" column="0">
<property name="name">
<cstring>textLabel11</cstring>
@ -67,25 +57,25 @@
<string>Extra role:</string>
</property>
</widget>
<widget class="QLabel" row="3" column="1">
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>title_label</cstring>
<cstring>textLabel1</cstring>
</property>
<property name="text">
<string></string>
<string>Class:</string>
</property>
</widget>
<widget class="QLabel" row="0" column="1">
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>class_label</cstring>
<cstring>textLabel3</cstring>
</property>
<property name="text">
<string></string>
<string>Role:</string>
</property>
</widget>
<widget class="QLabel" row="4" column="1">
<widget class="QLabel" row="2" column="1">
<property name="name">
<cstring>extrarole_label</cstring>
<cstring>type_label</cstring>
</property>
<property name="text">
<string></string>
@ -99,30 +89,14 @@
<string>Title:</string>
</property>
</widget>
<widget class="QLabel" row="5" column="1">
<widget class="QLabel" row="0" column="1">
<property name="name">
<cstring>machine_label</cstring>
<cstring>class_label</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QLabel" row="2" column="1">
<property name="name">
<cstring>type_label</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>textLabel3</cstring>
</property>
<property name="text">
<string>Role:</string>
</property>
</widget>
<widget class="QLabel" row="1" column="1">
<property name="name">
<cstring>role_label</cstring>
@ -131,8 +105,106 @@
<string></string>
</property>
</widget>
<widget class="QLabel" row="3" column="1">
<property name="name">
<cstring>title_label</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QLabel" row="5" column="1">
<property name="name">
<cstring>machine_label</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QLabel" row="2" column="0">
<property name="name">
<cstring>textLabel4</cstring>
</property>
<property name="text">
<string>Type:</string>
</property>
</widget>
<widget class="QLabel" row="4" column="1">
<property name="name">
<cstring>extrarole_label</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QLabel" row="5" column="0">
<property name="name">
<cstring>textLabel13</cstring>
</property>
<property name="text">
<string>Machine:</string>
</property>
</widget>
</grid>
</widget>
<widget class="QButtonGroup">
<property name="name">
<cstring>buttonGroup1</cstring>
</property>
<property name="title">
<string></string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QRadioButton">
<property name="name">
<cstring>use_class</cstring>
</property>
<property name="text">
<string>Use window &amp;class (whole application)</string>
</property>
<property name="accel">
<string>Alt+C</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="whatsThis" stdset="0">
<string>For selecting all windows belonging to a specific application, selecting only window class should usually work.</string>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>use_role</cstring>
</property>
<property name="text">
<string>Use window class and window &amp;role (specific window)</string>
</property>
<property name="accel">
<string>Alt+R</string>
</property>
<property name="whatsThis" stdset="0">
<string>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.</string>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>use_whole_class</cstring>
</property>
<property name="text">
<string>Use &amp;whole window class (specific window)</string>
</property>
<property name="accel">
<string>Alt+W</string>
</property>
<property name="whatsThis" stdset="0">
<string>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.</string>
</property>
</widget>
</vbox>
</widget>
<spacer>
<property name="name">
<cstring>spacer1</cstring>

View file

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