moved QDialog layout to ui for DetectWidget.

This commit is contained in:
Hugo Pereira Da Costa 2013-08-01 17:04:58 +02:00
parent d90d0f5c8e
commit 965aaabda8
3 changed files with 71 additions and 35 deletions

View file

@ -34,7 +34,8 @@
#include <QButtonGroup>
#include <QLayout>
#include <QGroupBox>
#include <QtGui/QMouseEvent>
#include <QMouseEvent>
#include <QPushButton>
#include <QtGui/QX11Info>
#include <X11/Xlib.h>
@ -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<Window>( QX11Info::appRootWindow() );
Atom wm_state = XInternAtom( QX11Info::display(), "WM_STATE", False );
// why is there a loop of only 10 here

View file

@ -33,10 +33,10 @@
#include "oxygenconfiguration.h"
#include "ui_oxygendetectwidget.h"
#include <KDialog>
#include <QEvent>
#include <QByteArray>
#include <QCheckBox>
#include <QDialog>
#include <QEvent>
#include <QLabel>
#include <kwindowsystem.h>
@ -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;

View file

@ -1,15 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DetectWidget</class>
<widget class="QWidget" name="DetectWidget">
<class>OxygenDetectWidget</class>
<widget class="QDialog" name="OxygenDetectWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>331</width>
<height>183</height>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
@ -80,8 +83,51 @@
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>OxygenDetectWidget</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>OxygenDetectWidget</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>