From 965aaabda8e23edfa602bf451734bf7c75d25878 Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Thu, 1 Aug 2013 17:04:58 +0200 Subject: [PATCH] moved QDialog layout to ui for DetectWidget. --- clients/oxygen/config/oxygendetectwidget.cpp | 32 +++++------ clients/oxygen/config/oxygendetectwidget.h | 18 ++---- .../oxygen/config/ui/oxygendetectwidget.ui | 56 +++++++++++++++++-- 3 files changed, 71 insertions(+), 35 deletions(-) diff --git a/clients/oxygen/config/oxygendetectwidget.cpp b/clients/oxygen/config/oxygendetectwidget.cpp index 69e5120b65..576c9ab836 100644 --- a/clients/oxygen/config/oxygendetectwidget.cpp +++ b/clients/oxygen/config/oxygendetectwidget.cpp @@ -34,7 +34,8 @@ #include #include #include -#include +#include +#include #include #include @@ -47,19 +48,15 @@ namespace Oxygen //_________________________________________________________ DetectDialog::DetectDialog( QWidget* parent ): - KDialog( parent ), + QDialog( parent ), _grabber( 0 ) { - // define buttons - setButtons( Ok|Cancel ); + // setup + setupUi( this ); - QWidget* local( new QWidget( this ) ); - ui.setupUi( local ); - ui.windowClassCheckBox->setChecked( true ); - - // central widget - setMainWidget( local ); + connect( buttonBox->button( QDialogButtonBox::Cancel ), SIGNAL(clicked()), this, SLOT(close()) ); + windowClassCheckBox->setChecked( true ); } @@ -87,13 +84,12 @@ namespace Oxygen return; } - QString wmClassClass = _info.windowClassClass(); - QString wmClassName = _info.windowClassName(); - QString title = _info.name(); + const QString wmClassClass( QString::fromUtf8( _info.windowClassClass() ) ); + const QString wmClassName( QString::fromUtf8( _info.windowClassName() ) ); - ui.windowClass->setText( wmClassClass + " (" + wmClassName + ' ' + wmClassClass + ')' ); - ui.windowTitle->setText( title ); - emit detectionDone( exec() == KDialog::Accepted ); + windowClass->setText( QStringLiteral( "%1 (%2 %3)" ).arg( wmClassClass ).arg( wmClassName ).arg( wmClassClass ) ); + Ui::OxygenDetectWidget::windowTitle->setText( _info.name() ); + emit detectionDone( exec() == QDialog::Accepted ); return; @@ -106,7 +102,7 @@ namespace Oxygen // use a dialog, so that all user input is blocked // use WX11BypassWM and moving away so that it's not actually visible // grab only mouse, so that keyboard can be used e.g. for switching windows - _grabber = new KDialog( 0, Qt::X11BypassWindowManagerHint ); + _grabber = new QDialog( 0, Qt::X11BypassWindowManagerHint ); _grabber->move( -1000, -1000 ); _grabber->setModal( true ); _grabber->show(); @@ -143,7 +139,7 @@ namespace Oxygen Window child; uint mask; int rootX, rootY, x, y; - Window parent = QX11Info::appRootWindow(); + Window parent = reinterpret_cast( QX11Info::appRootWindow() ); Atom wm_state = XInternAtom( QX11Info::display(), "WM_STATE", False ); // why is there a loop of only 10 here diff --git a/clients/oxygen/config/oxygendetectwidget.h b/clients/oxygen/config/oxygendetectwidget.h index 7aaf98cd5b..f9daabe07d 100644 --- a/clients/oxygen/config/oxygendetectwidget.h +++ b/clients/oxygen/config/oxygendetectwidget.h @@ -33,10 +33,10 @@ #include "oxygenconfiguration.h" #include "ui_oxygendetectwidget.h" -#include -#include #include #include +#include +#include #include #include @@ -44,7 +44,7 @@ namespace Oxygen { - class DetectDialog : public KDialog + class DetectDialog : public QDialog, Ui::OxygenDetectWidget { Q_OBJECT @@ -67,8 +67,8 @@ namespace Oxygen //! exception type Configuration::EnumExceptionType exceptionType() const { - if( ui.windowClassCheckBox->isChecked() ) return Configuration::ExceptionWindowClassName; - else if( ui.windowTitleCheckBox->isChecked() ) return Configuration::ExceptionWindowTitle; + if( windowClassCheckBox->isChecked() ) return Configuration::ExceptionWindowClassName; + else if( windowTitleCheckBox->isChecked() ) return Configuration::ExceptionWindowTitle; else return Configuration::ExceptionWindowClassName; } @@ -94,14 +94,8 @@ namespace Oxygen //! execute void executeDialog( void ); - //! window machine - QString machine; - - //! main widget - Ui_DetectWidget ui; - //! invisible dialog used to grab mouse - KDialog* _grabber; + QDialog* _grabber; //! current window information KWindowInfo _info; diff --git a/clients/oxygen/config/ui/oxygendetectwidget.ui b/clients/oxygen/config/ui/oxygendetectwidget.ui index 0b38dab270..b002082aa5 100644 --- a/clients/oxygen/config/ui/oxygendetectwidget.ui +++ b/clients/oxygen/config/ui/oxygendetectwidget.ui @@ -1,15 +1,18 @@ - DetectWidget - + OxygenDetectWidget + 0 0 - 331 - 183 + 400 + 300 + + Dialog + @@ -80,8 +83,51 @@ + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + - + + + buttonBox + accepted() + OxygenDetectWidget + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + OxygenDetectWidget + reject() + + + 316 + 260 + + + 286 + 274 + + + +