summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2012-07-03 15:15:05 +0200
committerJens Bache-Wiig <jens.bache-wiig@nokia.com>2012-07-04 16:26:04 +0200
commitdb21c0018548f933bde1722521679453ec960bb6 (patch)
tree9968b4fad1c106135e10efa766f57bcfcd21fc8b
parentde26780ee0bb337c1ec6bcdb7bd25ef4c5f46227 (diff)
downloadqtquickcontrols-db21c0018548f933bde1722521679453ec960bb6.tar.gz
Remove Qt 4 support in QWindowItem
There's a separate branch for Qt 4. Change-Id: I2d89b169f6a8eece7b4f2f3ff78ee2e3f72b7cc0 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
-rw-r--r--src/qtoplevelwindow.cpp40
-rw-r--r--src/qtoplevelwindow.h13
-rw-r--r--src/qwindowitem.cpp50
-rw-r--r--src/qwindowitem.h22
4 files changed, 3 insertions, 122 deletions
diff --git a/src/qtoplevelwindow.cpp b/src/qtoplevelwindow.cpp
index 58e113e0..b9a9213c 100644
--- a/src/qtoplevelwindow.cpp
+++ b/src/qtoplevelwindow.cpp
@@ -41,43 +41,23 @@
#include "qtoplevelwindow.h"
#include <QDesktopWidget>
-#if QT_VERSION >= 0x050000
#include <QtWidgets/QMenuBar>
-#endif
QTopLevelWindow::QTopLevelWindow()
-#if QT_VERSION < 0x050000
- : QMainWindow(), _view(new QDeclarativeView), _positionIsDefined(false) {
-#else
- : QQuickView(), _menuBar(new QMenuBar), _positionIsDefined(false) {
-#endif
-
+ : QQuickView(), _menuBar(new QMenuBar), _positionIsDefined(false)
+{
setVisible(false);
- // Ensure that we have a default size, otherwise an empty window statement will
- // result in no window
-// resize(QSize(100, 100));
-#if QT_VERSION < 0x050000
- _view->setBackgroundBrush(palette().window());
- setCentralWidget(_view);
-#endif
}
-#if QT_VERSION >= 0x050000
QMenuBar *QTopLevelWindow::menuBar()
{
return _menuBar;
}
-#endif
-
QTopLevelWindow::~QTopLevelWindow()
{
foreach (QTopLevelWindow* child, findChildren<QTopLevelWindow*>())
child->setParent(0);
- //we need this to break the parental loop of QWindowItem and QTopLevelWindow
-#if QT_VERSION < 0x050000
- _view->scene()->setParent(0);
-#endif
}
void QTopLevelWindow::registerChildWindow(QTopLevelWindow* child)
@@ -103,13 +83,7 @@ void QTopLevelWindow::initPosition()
void QTopLevelWindow::center()
{
- QPoint parentCenter;
-#if QT_VERSION < 0x050000
- if (parentWidget())
- parentCenter = parentWidget()->geometry().center();
- else
-#endif
- parentCenter = QDesktopWidget().screenGeometry().center();
+ QPoint parentCenter = QDesktopWidget().screenGeometry().center();
QRect thisGeometry = geometry();
thisGeometry.moveCenter(parentCenter);
setGeometry(thisGeometry);
@@ -124,19 +98,11 @@ void QTopLevelWindow::move(int x, int y)
void QTopLevelWindow::move(const QPoint &point)
{
_positionIsDefined = true;
-#if QT_VERSION < 0x050000
- QMainWindow::move(point);
-#else
QQuickView::setPos(point);
-#endif
}
void QTopLevelWindow::setWindowFlags(Qt::WindowFlags type)
{
-#if QT_VERSION < 0x050000
- QWidget::setWindowFlags(type | Qt::Window);
-#else
QQuickView::setWindowFlags(type | Qt::Window);
-#endif
}
diff --git a/src/qtoplevelwindow.h b/src/qtoplevelwindow.h
index 6f5b5ed4..1891bdb9 100644
--- a/src/qtoplevelwindow.h
+++ b/src/qtoplevelwindow.h
@@ -44,11 +44,7 @@
#include <QtCore/qglobal.h>
#include <QMainWindow>
-#if QT_VERSION < 0x050000
-#include <QDeclarativeView>
-#else
#include <QtQuick/QQuickView>
-#endif
#include <QWindowStateChangeEvent>
#include <QDebug>
@@ -62,13 +58,8 @@ public:
QTopLevelWindow();
~QTopLevelWindow();
-#if QT_VERSION < 0x050000
- QGraphicsScene *scene() { return _view->scene(); }
- QDeclarativeView *view() { return _view; }
-#else
QQuickView * view() { return this; }
QMenuBar *menuBar();
-#endif
void registerChildWindow(QTopLevelWindow* child);
void hideChildWindows();
void initPosition();
@@ -85,11 +76,7 @@ Q_SIGNALS:
void sizeChanged(QSize newSize);
private:
-#if QT_VERSION < 0x050000
- QDeclarativeView *_view;
-#else
QMenuBar *_menuBar;
-#endif
bool _positionIsDefined;
};
diff --git a/src/qwindowitem.cpp b/src/qwindowitem.cpp
index 66e276ea..67b6a44b 100644
--- a/src/qwindowitem.cpp
+++ b/src/qwindowitem.cpp
@@ -50,11 +50,7 @@ QWindowItem::QWindowItem()
connect(_window, SIGNAL(windowStateChanged()), this, SIGNAL(windowStateChanged()));
connect(_window, SIGNAL(sizeChanged(QSize)), this, SLOT(updateSize(QSize)));
-#if QT_VERSION < 0x050000
- view()->setResizeMode(QDeclarativeView::SizeRootObjectToView);
-#else
view()->setResizeMode(QQuickView::SizeRootObjectToView);
-#endif
_window->installEventFilter(this);
}
@@ -95,11 +91,7 @@ void QWindowItem::registerChildWindow(QWindowItem *child) {
}
void QWindowItem::updateParentWindow() {
-#if QT_VERSION < 0x050000
- QDeclarativeItem *p = parentItem();
-#else
QQuickItem *p = parentItem();
-#endif
while (p) {
if (QWindowItem *w = qobject_cast<QWindowItem*>(p)) {
w->registerChildWindow(this);
@@ -112,17 +104,10 @@ void QWindowItem::updateParentWindow() {
void QWindowItem::componentComplete()
{
updateParentWindow();
-#if QT_VERSION < 0x050000
- _window->scene()->addItem(this);
- if (!_window->parentWidget())
- _window->initPosition();
- QDeclarativeItem::componentComplete();
-#else
this->setParentItem(_window->view()->rootItem());
if (_window->isTopLevel())
_window->initPosition();
QQuickItem::componentComplete();
-#endif
if (_delayedVisible) {
setVisible(true);
}
@@ -130,11 +115,7 @@ void QWindowItem::componentComplete()
void QWindowItem::updateSize(QSize newSize)
{
-#if QT_VERSION < 0x050000
- QDeclarativeItem::setSize(newSize);
-#else
QQuickItem::setSize(newSize);
-#endif
emit sizeChanged();
}
@@ -164,65 +145,34 @@ void QWindowItem::moveWindow(int x,int y, int lx, int ly)
void QWindowItem::setHeight(int height)
{
-#if QT_VERSION < 0x050000
- int menuBarHeight = _window->menuBar()->sizeHint().height();
- if (menuBarHeight) menuBarHeight++;
- _window->resize(width(), height+menuBarHeight);
- QDeclarativeItem::setHeight(_window->height());
-#else
_window->resize(width(), height);
QQuickItem::setHeight(_window->height());
-#endif
}
void QWindowItem::setMinimumHeight(int height)
{
-#if QT_VERSION < 0x050000
- int menuBarHeight = _window->menuBar()->sizeHint().height();
- if (menuBarHeight) menuBarHeight++;
- _window->setMinimumHeight(height+menuBarHeight);
-#else
_window->setMinimumSize(QSize(_window->minimumSize().width(), height));
-#endif
}
void QWindowItem::setMaximumHeight(int height)
{
-#if QT_VERSION < 0x050000
- int menuBarHeight = _window->menuBar()->sizeHint().height();
- if (menuBarHeight) menuBarHeight++;
- _window->setMaximumHeight(height+menuBarHeight);
-#else
_window->setMaximumSize(QSize(_window->maximumSize().width(), height));
-#endif
}
void QWindowItem::setWidth(int width)
{
_window->resize(width, height());
-#if QT_VERSION < 0x050000
- QDeclarativeItem::setWidth(_window->width());
-#else
QQuickItem::setWidth(_window->width());
-#endif
}
void QWindowItem::setMinimumWidth(int width)
{
-#if QT_VERSION < 0x050000
- _window->setMinimumWidth(width);
-#else
_window->setMinimumSize(QSize(width, _window->minimumSize().height()));
-#endif
}
void QWindowItem::setMaximumWidth(int width)
{
-#if QT_VERSION < 0x050000
- _window->setMaximumWidth(width);
-#else
_window->setMinimumSize(QSize(width, _window->maximumSize().height()));
-#endif
}
void QWindowItem::setTitle(QString title)
diff --git a/src/qwindowitem.h b/src/qwindowitem.h
index f3ead8c2..3cd50a2d 100644
--- a/src/qwindowitem.h
+++ b/src/qwindowitem.h
@@ -44,20 +44,11 @@
#include "qtoplevelwindow.h"
#include <QtGui/QGuiApplication>
-#if QT_VERSION < 0x050000
-#include <QDeclarativeItem>
-#include <QDeclarativeView>
-#else
#include <QtQuick/QQuickItem>
#include <QtQuick/QQuickView>
-#endif
#include <QMenuBar>
-#if QT_VERSION < 0x050000
-class QWindowItem : public QDeclarativeItem
-#else
class QWindowItem : public QQuickItem
-#endif
{
Q_OBJECT
Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged)
@@ -79,28 +70,15 @@ public:
QWindowItem();
~QWindowItem();
QTopLevelWindow *window() { return _window; }
-#if QT_VERSION < 0x050000
- QDeclarativeView *view() { return _window->view(); }
-#else
QQuickView *view() { return _window->view(); }
-#endif
int x() const { return _window->x(); }
int y() const { return _window->y(); }
-#if QT_VERSION < 0x050000
- int height() const { return _window->height(); }
- int minimumHeight() const { return _window->minimumHeight(); }
- int maximumHeight() const { return _window->maximumHeight(); }
- int width() const { return _window->width(); }
- int minimumWidth() const { return _window->minimumWidth(); }
- int maximumWidth() const { return _window->maximumWidth(); }
-#else
int height() const { return _window->size().height(); }
int minimumHeight() const { return _window->minimumSize().height(); }
int maximumHeight() const { return _window->maximumSize().height(); }
int width() const { return _window->size().width(); }
int minimumWidth() const { return _window->minimumSize().width(); }
int maximumWidth() const { return _window->maximumSize().width(); }
-#endif
bool isVisible() const { return _window->isVisible(); }
bool windowDecoration() const { return !(_window->windowFlags() & Qt::FramelessWindowHint); }
Qt::WindowState windowState() const { return static_cast<Qt::WindowState>(static_cast<int>(_window->windowState()) & ~Qt::WindowActive); }