Make the detect button a bit more useful.
svn path=/trunk/kdebase/kwin/; revision=322872
This commit is contained in:
parent
389771f957
commit
e8d21fc0cd
4 changed files with 162 additions and 54 deletions
|
@ -24,10 +24,12 @@
|
||||||
#include <kxerrorhandler.h>
|
#include <kxerrorhandler.h>
|
||||||
#include <kwin.h>
|
#include <kwin.h>
|
||||||
#include <qlabel.h>
|
#include <qlabel.h>
|
||||||
|
#include <qradiobutton.h>
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
#include <fixx11h.h>
|
||||||
|
|
||||||
namespace KWinInternal
|
namespace KWinInternal
|
||||||
{
|
{
|
||||||
|
@ -38,7 +40,7 @@ DetectWidget::DetectWidget( QWidget* parent, const char* name )
|
||||||
}
|
}
|
||||||
|
|
||||||
DetectDialog::DetectDialog( 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 )
|
, grabber( NULL )
|
||||||
{
|
{
|
||||||
widget = new DetectWidget( this );
|
widget = new DetectWidget( this );
|
||||||
|
@ -140,6 +142,26 @@ void DetectDialog::executeDialog()
|
||||||
emit detectionDone( exec() == QDialog::Accepted );
|
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()
|
void DetectDialog::selectWindow()
|
||||||
{
|
{
|
||||||
// use a dialog, so that all user input is blocked
|
// use a dialog, so that all user input is blocked
|
||||||
|
@ -160,6 +182,11 @@ bool DetectDialog::eventFilter( QObject* o, QEvent* e )
|
||||||
return false;
|
return false;
|
||||||
delete grabber;
|
delete grabber;
|
||||||
grabber = NULL;
|
grabber = NULL;
|
||||||
|
if( static_cast< QMouseEvent* >( e )->button() != LeftButton )
|
||||||
|
{
|
||||||
|
emit detectionDone( false );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
readWindow( findWindow());
|
readWindow( findWindow());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,9 @@ class DetectDialog
|
||||||
public:
|
public:
|
||||||
DetectDialog( QWidget* parent = NULL, const char* name = NULL );
|
DetectDialog( QWidget* parent = NULL, const char* name = NULL );
|
||||||
void detect( WId window );
|
void detect( WId window );
|
||||||
|
QCString selectedClass() const;
|
||||||
|
bool selectedWholeClass() const;
|
||||||
|
QCString selectedRole() const;
|
||||||
signals:
|
signals:
|
||||||
void detectionDone( bool );
|
void detectionDone( bool );
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>600</width>
|
<width>557</width>
|
||||||
<height>480</height>
|
<height>335</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="caption">
|
<property name="caption">
|
||||||
|
@ -27,38 +27,28 @@
|
||||||
<string>Information about the selected window:</string>
|
<string>Information about the selected window:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</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">
|
<widget class="QLayoutWidget">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>layout1</cstring>
|
<cstring>layout2</cstring>
|
||||||
</property>
|
</property>
|
||||||
<grid>
|
<grid>
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>unnamed</cstring>
|
<cstring>unnamed</cstring>
|
||||||
</property>
|
</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">
|
<widget class="QLabel" row="4" column="0">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>textLabel11</cstring>
|
<cstring>textLabel11</cstring>
|
||||||
|
@ -67,25 +57,25 @@
|
||||||
<string>Extra role:</string>
|
<string>Extra role:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" row="3" column="1">
|
<widget class="QLabel" row="0" column="0">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>title_label</cstring>
|
<cstring>textLabel1</cstring>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string></string>
|
<string>Class:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" row="0" column="1">
|
<widget class="QLabel" row="1" column="0">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>class_label</cstring>
|
<cstring>textLabel3</cstring>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string></string>
|
<string>Role:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" row="4" column="1">
|
<widget class="QLabel" row="2" column="1">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>extrarole_label</cstring>
|
<cstring>type_label</cstring>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string></string>
|
<string></string>
|
||||||
|
@ -99,30 +89,14 @@
|
||||||
<string>Title:</string>
|
<string>Title:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" row="5" column="1">
|
<widget class="QLabel" row="0" column="1">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>machine_label</cstring>
|
<cstring>class_label</cstring>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string></string>
|
<string></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</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">
|
<widget class="QLabel" row="1" column="1">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>role_label</cstring>
|
<cstring>role_label</cstring>
|
||||||
|
@ -131,8 +105,106 @@
|
||||||
<string></string>
|
<string></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</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>
|
</grid>
|
||||||
</widget>
|
</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 &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 &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 &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>
|
<spacer>
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>spacer1</cstring>
|
<cstring>spacer1</cstring>
|
||||||
|
|
|
@ -473,6 +473,12 @@ void RulesWidget::detectClicked()
|
||||||
|
|
||||||
void RulesWidget::detected( bool ok )
|
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;
|
delete detect_dlg;
|
||||||
detect_dlg = NULL;
|
detect_dlg = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue