From af01b788dc57c5d53bc079efb098f7b0492e08b5 Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Thu, 29 Oct 2009 02:55:41 +0000 Subject: [PATCH] used ui file for detectWidget svn path=/trunk/KDE/kdebase/workspace/; revision=1042063 --- clients/oxygen/config/CMakeLists.txt | 2 + clients/oxygen/config/oxygendetectwidget.cpp | 60 ++----------- clients/oxygen/config/oxygendetectwidget.h | 44 ++-------- clients/oxygen/config/oxygendetectwidget.ui | 90 ++++++++++++++++++++ 4 files changed, 105 insertions(+), 91 deletions(-) create mode 100644 clients/oxygen/config/oxygendetectwidget.ui diff --git a/clients/oxygen/config/CMakeLists.txt b/clients/oxygen/config/CMakeLists.txt index 53eade8931..0f57511717 100644 --- a/clients/oxygen/config/CMakeLists.txt +++ b/clients/oxygen/config/CMakeLists.txt @@ -16,6 +16,8 @@ set(kwin_oxygen_config_PART_SRCS oxygenshadowconfigurationui.cpp ) +kde4_add_ui_files(kwin_oxygen_config_PART_SRCS oxygendetectwidget.ui) + kde4_add_plugin(kwin_oxygen_config ${kwin_oxygen_config_PART_SRCS}) target_link_libraries( diff --git a/clients/oxygen/config/oxygendetectwidget.cpp b/clients/oxygen/config/oxygendetectwidget.cpp index 932b45b9d8..fcd60cee56 100644 --- a/clients/oxygen/config/oxygendetectwidget.cpp +++ b/clients/oxygen/config/oxygendetectwidget.cpp @@ -46,57 +46,6 @@ namespace Oxygen { - //_________________________________________________________ - DetectWidget::DetectWidget( QWidget* parent ): - QWidget( parent ) - { - - QVBoxLayout* vboxLayout = new QVBoxLayout(); - vboxLayout->setMargin( 0 ); - setLayout( vboxLayout ); - - QGroupBox* box( new QGroupBox( i18n( "Information about Selected Window" ), this ) ); - vboxLayout->addWidget( box ); - - // display layout - QGridLayout *gridLayout = new QGridLayout(); - box->setLayout( gridLayout ); - - // class - gridLayout->addWidget( new QLabel( i18n( "Class: " ), box ), 0, 0, 1, 1, Qt::AlignRight|Qt::AlignVCenter ); - gridLayout->addWidget( windowClass = new QLabel( box ), 0, 1, 1, 1 ); - - // title - gridLayout->addWidget( new QLabel( i18n( "Title: " ), box ), 1, 0, 1, 1, Qt::AlignRight|Qt::AlignVCenter ); - gridLayout->addWidget( windowTitle = new QLabel( box ), 1, 1, 1, 1 ); - - box = new QGroupBox( i18n( "Window Property Selection" ), this ); - QButtonGroup* group( new QButtonGroup( this ) ); - box->setLayout( new QVBoxLayout() ); - vboxLayout->addWidget( box ); - - QCheckBox* checkbox; - group->addButton( checkbox = new QCheckBox( i18n( "Use window class (whole application)" ) ) ); - checkboxes.insert( std::make_pair( checkbox, OxygenException::WindowClassName ) ); - checkbox->setChecked( true ); - box->layout()->addWidget( checkbox ); - - group->addButton( checkbox = new QCheckBox( i18n( "Use window title" ) ) ); - checkboxes.insert( std::make_pair( checkbox, OxygenException::WindowTitle ) ); - box->layout()->addWidget( checkbox ); - - } - - //_________________________________________________________ - OxygenException::Type DetectWidget::exceptionType( void ) const - { - for( CheckBoxMap::const_iterator iter = checkboxes.begin(); iter != checkboxes.end(); ++iter ) - { if( iter->first->isChecked() ) return iter->second; } - - assert( false ); - return OxygenException::WindowClassName; - } - //_________________________________________________________ DetectDialog::DetectDialog( QWidget* parent ): KDialog( parent ), @@ -107,8 +56,11 @@ namespace Oxygen setButtons( Ok|Cancel ); showButtonSeparator( false ); + QWidget* local( new QWidget( this ) ); + widget.setupUi( local ); + // central widget - setMainWidget( widget = new DetectWidget( this ) ); + setMainWidget( local ); } @@ -140,8 +92,8 @@ namespace Oxygen QString wmclass_name = info.windowClassName(); QString title = info.name(); - widget->setWindowClass( wmclass_class + " (" + wmclass_name + ' ' + wmclass_class + ')' ); - widget->setWindowTitle( title ); + widget.windowClass->setText( wmclass_class + " (" + wmclass_name + ' ' + wmclass_class + ')' ); + widget.windowTitle->setText( title ); emit detectionDone( exec() == KDialog::Accepted ); return; diff --git a/clients/oxygen/config/oxygendetectwidget.h b/clients/oxygen/config/oxygendetectwidget.h index 24e633c6b2..e9c56218da 100644 --- a/clients/oxygen/config/oxygendetectwidget.h +++ b/clients/oxygen/config/oxygendetectwidget.h @@ -40,45 +40,11 @@ #include #include "../oxygenexception.h" +#include "ui_oxygendetectwidget.h" namespace Oxygen { - class DetectWidget: public QWidget - { - - public: - - //! constructor - DetectWidget( QWidget* ); - - //! window class - void setWindowClass( QString value ) - { windowClass->setText( value ); } - - //! window title - void setWindowTitle( QString value ) - { windowTitle->setText( value ); } - - //! window machine - void setWindowMachine( QString value ) - { windowMachine->setText( value ); } - - //! type - OxygenException::Type exceptionType( void ) const; - - private: - - QLabel* windowClass; - QLabel* windowTitle; - QLabel* windowMachine; - - // map checkboxes against exception type - typedef std::map CheckBoxMap; - CheckBoxMap checkboxes; - - }; - class DetectDialog : public KDialog { @@ -101,7 +67,11 @@ namespace Oxygen //! exception type OxygenException::Type exceptionType() const - { return widget->exceptionType(); } + { + if( widget.windowClassCheckBox->isChecked() ) return OxygenException::WindowClassName; + else if( widget.windowTitleCheckBox->isChecked() ) return OxygenException::WindowTitle; + else return OxygenException::WindowClassName; + } signals: @@ -129,7 +99,7 @@ namespace Oxygen QString machine; //! main widget - DetectWidget* widget; + Ui_DetectWidget widget; //! invisible dialog used to grab mouse KDialog* grabber; diff --git a/clients/oxygen/config/oxygendetectwidget.ui b/clients/oxygen/config/oxygendetectwidget.ui new file mode 100644 index 0000000000..e3482eea79 --- /dev/null +++ b/clients/oxygen/config/oxygendetectwidget.ui @@ -0,0 +1,90 @@ + + + DetectWidget + + + + 0 + 0 + 331 + 183 + + + + Form + + + + + + Information about Selected Window + + + + + + Class: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + TextLabel + + + + + + + Title: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + TextLabel + + + + + + + + + + Window Property Selection + + + + + + Use window class (whole application) + + + + + + + + + + Use window title + + + + + + + + + + +