**
****************************************************************************/
-#include <QtWidgets/QMainWindow>
-#include <QtWidgets/QLabel>
-#include <QtWidgets/QPushButton>
-#include <QtWidgets/QRadioButton>
-#include <QtWidgets/QCheckBox>
-#include <QtWidgets/QGroupBox>
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QHBoxLayout>
+#include <QMainWindow>
+#include <QLabel>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QApplication>
+#include <QHBoxLayout>
#include "controllerwindow.h"
#include "controls.h"
hintsControl->setHints(previewWindow->windowFlags());
connect(hintsControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(updatePreview()));
- statesControl = new WindowStatesControl(WindowStatesControl::WantVisibleCheckBox);
+ statesControl = new WindowStatesControl(WindowStatesControl::WantVisibleCheckBox|WindowStatesControl::WantActiveCheckBox);
statesControl->setStates(previewWindow->windowState());
statesControl->setVisibleValue(true);
connect(statesControl, SIGNAL(changed()), this, SLOT(updatePreview()));
setLayout(mainLayout);
setWindowTitle(tr("Window Flags (Qt version %1, %2)")
- .arg(QLatin1String(qVersion()), qApp->platformName()));
+ .arg(QLatin1String(qVersion()),
+#if QT_VERSION >= 0x050000
+ qApp->platformName()));
+#else
+ QLatin1String("<unknown>")));
+#endif
updatePreview();
}
#ifndef CONTROLLERWINDOW_H
#define CONTROLLERWINDOW_H
-#include <QtWidgets/QWidget>
+#include <QWidget>
#include "previewwindow.h"
layout->addWidget(windowStaysOnBottomCheckBox, 6, 1);
layout->addWidget(customizeWindowHintCheckBox, 5, 0);
layout->addWidget(transparentForInputCheckBox, 6, 0);
+#if QT_VERSION < 0x050000
+ transparentForInputCheckBox->setEnabled(false);
+#endif
}
Qt::WindowFlags HintControl::hints() const
flags |= Qt::WindowStaysOnBottomHint;
if (customizeWindowHintCheckBox->isChecked())
flags |= Qt::CustomizeWindowHint;
+#if QT_VERSION >= 0x050000
if (transparentForInputCheckBox->isChecked())
flags |= Qt::WindowTransparentForInput;
+#endif
return flags;
}
windowStaysOnTopCheckBox->setChecked(flags & Qt::WindowStaysOnTopHint);
windowStaysOnBottomCheckBox->setChecked(flags & Qt::WindowStaysOnBottomHint);
customizeWindowHintCheckBox->setChecked(flags & Qt::CustomizeWindowHint);
+#if QT_VERSION >= 0x050000
transparentForInputCheckBox->setChecked(flags & Qt::WindowTransparentForInput);
+#endif
}
void HintControl::slotCheckBoxChanged()
WindowStatesControl::WindowStatesControl(unsigned flags, QWidget *parent)
: QGroupBox(tr("States"), parent)
, visibleCheckBox(0)
+ , activeCheckBox(0)
, minimizeCheckBox(new QCheckBox(tr("Minimized")))
, stateControl(new WindowStateControl(0))
{
connect(visibleCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
layout->addWidget(visibleCheckBox);
}
+ if (flags & WantActiveCheckBox) {
+ activeCheckBox = new QCheckBox(tr("Active"));
+ connect(activeCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ layout->addWidget(activeCheckBox);
+ }
layout->addWidget(minimizeCheckBox);
layout->addWidget(stateControl);
connect(stateControl, SIGNAL(changed()), this, SIGNAL(changed()));
Qt::WindowStates s = stateControl->state();
if (minimizeCheckBox->isChecked())
s |= Qt::WindowMinimized;
+ if (activeValue())
+ s |= Qt::WindowActive;
return s;
}
minimizeCheckBox->blockSignals(false);
s &= ~Qt::WindowMinimized;
stateControl->setState(Qt::WindowState(int(s)));
+ setActiveValue(s & Qt::WindowActive);
}
bool WindowStatesControl::visibleValue() const
}
}
+bool WindowStatesControl::activeValue() const
+{
+ return activeCheckBox && activeCheckBox->isChecked();
+}
+
+void WindowStatesControl::setActiveValue(bool v)
+{
+ if (activeCheckBox) {
+ activeCheckBox->blockSignals(true);
+ activeCheckBox->setChecked(v);
+ activeCheckBox->blockSignals(false);
+ }
+}
+
TypeControl::TypeControl(QWidget *parent)
: QGroupBox(tr("Type"), parent)
, group(new QButtonGroup)
Q_OBJECT
public:
enum Flags {
- WantVisibleCheckBox = 0x1
+ WantVisibleCheckBox = 0x1,
+ WantActiveCheckBox = 0x2
};
explicit WindowStatesControl(unsigned flags, QWidget *parent= 0);
bool visibleValue() const;
void setVisibleValue(bool);
+ bool activeValue() const;
+ void setActiveValue(bool v);
signals:
void changed();
private:
QCheckBox *visibleCheckBox;
+ QCheckBox *activeCheckBox;
QCheckBox *minimizeCheckBox;
WindowStateControl *stateControl;
};
**
****************************************************************************/
-#include <QtWidgets/QTextEdit>
-#include <QtWidgets/QPushButton>
-#include <QtWidgets/QVBoxLayout>
+#include <QTextEdit>
+#include <QPushButton>
+#include <QVBoxLayout>
#include "previewwindow.h"
#ifndef PREVIEWWINDOW_H
#define PREVIEWWINDOW_H
-#include <QtWidgets/QWidget>
-#include <QtWidgets/QDialog>
+#include <QDialog>
QT_BEGIN_NAMESPACE
class QPushButton;
-QT += widgets
-
HEADERS = controllerwindow.h \
previewwindow.h \
controls.h
main.cpp \
controls.cpp
-QT += widgets
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
WidgetWindowControl::WidgetWindowControl(QWidget *w )
: BaseWindowControl(w)
- , m_statesControl(new WindowStatesControl(WindowStatesControl::WantVisibleCheckBox))
+ , m_statesControl(new WindowStatesControl(WindowStatesControl::WantVisibleCheckBox | WindowStatesControl::WantActiveCheckBox))
{
setTitle(w->windowTitle());
m_layout->addWidget(m_statesControl, 2, 0);
x += 800;
m_testWidget->setWindowTitle(tr("TestWidget"));
+ if (args.contains(QLatin1String("-layout"))) {
+ QVBoxLayout *layout = new QVBoxLayout(m_testWidget.data());
+ QLabel *label = new QLabel("Hallo");
+ layout->addWidget(label);
+ }
m_testWidget->move(x, y);
m_testWidget->resize(200, 200);
m_testWidget->show();