Track window state in manual test windowflags.
Change-Id: Ief6cd4b29ddcc946e1ccac75b352da80bbf647d0 Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
This commit is contained in:
parent
150284198b
commit
8683ee14cc
@ -52,7 +52,7 @@
|
|||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
ControllerWindow::ControllerWindow()
|
ControllerWindow::ControllerWindow() : previewWidget(0)
|
||||||
{
|
{
|
||||||
parentWindow = new QMainWindow;
|
parentWindow = new QMainWindow;
|
||||||
parentWindow->setWindowTitle(tr("Preview parent window"));
|
parentWindow->setWindowTitle(tr("Preview parent window"));
|
||||||
@ -60,7 +60,9 @@ ControllerWindow::ControllerWindow()
|
|||||||
parentWindow->setCentralWidget(label);
|
parentWindow->setCentralWidget(label);
|
||||||
|
|
||||||
previewWindow = new PreviewWindow;
|
previewWindow = new PreviewWindow;
|
||||||
|
previewWindow->installEventFilter(this);
|
||||||
previewDialog = new PreviewDialog;
|
previewDialog = new PreviewDialog;
|
||||||
|
previewDialog->installEventFilter(this);
|
||||||
|
|
||||||
createTypeGroupBox();
|
createTypeGroupBox();
|
||||||
|
|
||||||
@ -69,6 +71,11 @@ ControllerWindow::ControllerWindow()
|
|||||||
|
|
||||||
QHBoxLayout *bottomLayout = new QHBoxLayout;
|
QHBoxLayout *bottomLayout = new QHBoxLayout;
|
||||||
bottomLayout->addStretch();
|
bottomLayout->addStretch();
|
||||||
|
|
||||||
|
QPushButton *updateControlsButton = new QPushButton(tr("&Update"));
|
||||||
|
connect(updateControlsButton, SIGNAL(clicked()), this, SLOT(updateStateControl()));
|
||||||
|
|
||||||
|
bottomLayout->addWidget(updateControlsButton);
|
||||||
bottomLayout->addWidget(quitButton);
|
bottomLayout->addWidget(quitButton);
|
||||||
|
|
||||||
hintsControl = new HintControl;
|
hintsControl = new HintControl;
|
||||||
@ -103,45 +110,58 @@ ControllerWindow::ControllerWindow()
|
|||||||
updatePreview();
|
updatePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ControllerWindow::eventFilter(QObject *o, QEvent *e)
|
||||||
|
{
|
||||||
|
if (e->type() == QEvent::WindowStateChange)
|
||||||
|
updateStateControl();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerWindow::updateStateControl()
|
||||||
|
{
|
||||||
|
if (previewWidget)
|
||||||
|
statesControl->setStates(previewWidget->windowState());
|
||||||
|
}
|
||||||
|
|
||||||
void ControllerWindow::updatePreview()
|
void ControllerWindow::updatePreview()
|
||||||
{
|
{
|
||||||
const Qt::WindowFlags flags = typeControl->type() | hintsControl->hints();
|
const Qt::WindowFlags flags = typeControl->type() | hintsControl->hints();
|
||||||
|
|
||||||
previewWindow->hide();
|
previewWindow->hide();
|
||||||
previewDialog->hide();
|
previewDialog->hide();
|
||||||
QWidget *widget = 0;
|
|
||||||
if (previewWidgetButton->isChecked())
|
if (previewWidgetButton->isChecked())
|
||||||
widget = previewWindow;
|
previewWidget = previewWindow;
|
||||||
else
|
else
|
||||||
widget = previewDialog;
|
previewWidget = previewDialog;
|
||||||
|
|
||||||
if (modalWindowCheckBox->isChecked()) {
|
if (modalWindowCheckBox->isChecked()) {
|
||||||
parentWindow->show();
|
parentWindow->show();
|
||||||
widget->setWindowModality(Qt::WindowModal);
|
previewWidget->setWindowModality(Qt::WindowModal);
|
||||||
widget->setParent(parentWindow);
|
previewWidget->setParent(parentWindow);
|
||||||
} else {
|
} else {
|
||||||
widget->setWindowModality(Qt::NonModal);
|
previewWidget->setWindowModality(Qt::NonModal);
|
||||||
widget->setParent(0);
|
previewWidget->setParent(0);
|
||||||
parentWindow->hide();
|
parentWindow->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->setWindowFlags(flags);
|
previewWidget->setWindowFlags(flags);
|
||||||
|
|
||||||
if (fixedSizeWindowCheckBox->isChecked()) {
|
if (fixedSizeWindowCheckBox->isChecked()) {
|
||||||
widget->setFixedSize(300, 300);
|
previewWidget->setFixedSize(300, 300);
|
||||||
} else {
|
} else {
|
||||||
widget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
previewWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint pos = widget->pos();
|
QPoint pos = previewWidget->pos();
|
||||||
if (pos.x() < 0)
|
if (pos.x() < 0)
|
||||||
pos.setX(0);
|
pos.setX(0);
|
||||||
if (pos.y() < 0)
|
if (pos.y() < 0)
|
||||||
pos.setY(0);
|
pos.setY(0);
|
||||||
widget->move(pos);
|
previewWidget->move(pos);
|
||||||
|
|
||||||
widget->setWindowState(statesControl->states());
|
previewWidget->setWindowState(statesControl->states());
|
||||||
widget->setVisible(statesControl->visibleValue());
|
previewWidget->setVisible(statesControl->visibleValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerWindow::createTypeGroupBox()
|
void ControllerWindow::createTypeGroupBox()
|
||||||
|
@ -67,8 +67,11 @@ class ControllerWindow : public QWidget
|
|||||||
public:
|
public:
|
||||||
ControllerWindow();
|
ControllerWindow();
|
||||||
|
|
||||||
|
virtual bool eventFilter(QObject *o, QEvent *e);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatePreview();
|
void updatePreview();
|
||||||
|
void updateStateControl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createTypeGroupBox();
|
void createTypeGroupBox();
|
||||||
@ -78,6 +81,7 @@ private:
|
|||||||
QMainWindow *parentWindow;
|
QMainWindow *parentWindow;
|
||||||
PreviewWindow *previewWindow;
|
PreviewWindow *previewWindow;
|
||||||
PreviewDialog *previewDialog;
|
PreviewDialog *previewDialog;
|
||||||
|
QWidget *previewWidget;
|
||||||
QGroupBox *widgetTypeGroupBox;
|
QGroupBox *widgetTypeGroupBox;
|
||||||
QGroupBox *additionalOptionsGroupBox;
|
QGroupBox *additionalOptionsGroupBox;
|
||||||
TypeControl *typeControl;
|
TypeControl *typeControl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user