From 6b8a0dabdc750052512446ee6db06d4033320d48 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 6 Aug 2014 14:29:17 +0200 Subject: Fix ApplicationWindow state / content size QML Window is not a plain QQuickWindow, but QQuickWindowQmlImpl that does delayed visibility handling and shows the window in appropriate state. Thus, ApplicationWindow cannot inherit QQuickWindow or it would lose all that magic. QQuickApplicationWindow was added in order for ApplicationWindowStyle to be able to know whether a custom window color had been set. This change gets rid of the QQuickWindow subclass and simply compares the window color to white, which is the default fill color of QQuickWindow. Change-Id: Ibd95ef0717c2db51246c6a71585e9286e61cef0b Reviewed-by: Richard Moe Gustavsen Reviewed-by: Gabriel de Dietrich --- src/controls/ApplicationWindow.qml | 4 +- src/controls/plugin.cpp | 2 - src/controls/plugin.pri | 2 - src/controls/qquickapplicationwindow.cpp | 65 ----------------------------- src/controls/qquickapplicationwindow_p.h | 71 -------------------------------- 5 files changed, 2 insertions(+), 142 deletions(-) delete mode 100644 src/controls/qquickapplicationwindow.cpp delete mode 100644 src/controls/qquickapplicationwindow_p.h (limited to 'src') diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index 42f0d549..0edfe5ea 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -88,7 +88,7 @@ import QtQuick.Controls.Private 1.0 point to explore this type. */ -ApplicationWindowPrivate { +Window { id: root /*! @@ -221,7 +221,7 @@ ApplicationWindowPrivate { sourceComponent: style property var __control: root property QtObject styleData: QtObject { - readonly property bool hasColor: root.__hasColor + readonly property bool hasColor: root.color != "#ffffff" } onStatusChanged: if (status === Loader.Error) console.error("Failed to load Style for", root) } diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp index aaf9fd8e..43831769 100644 --- a/src/controls/plugin.cpp +++ b/src/controls/plugin.cpp @@ -49,7 +49,6 @@ #include "qquickstack_p.h" #include "qquickdesktopiconprovider_p.h" #include "qquickselectionmode_p.h" -#include "qquickapplicationwindow_p.h" #include "Private/qquickcalendarmodel_p.h" #include "Private/qquickrangeddate_p.h" @@ -151,7 +150,6 @@ void QtQuickControlsPlugin::initializeEngine(QQmlEngine *engine, const char *uri qmlRegisterType(private_uri, 1, 0, "MenuPrivate"); qmlRegisterType(private_uri, 1, 0, "MenuBarPrivate"); qmlRegisterType(private_uri, 1, 0, "PopupWindow"); - qmlRegisterType(private_uri, 1, 0, "ApplicationWindowPrivate"); #ifdef QT_WIDGETS_LIB qmlRegisterType(private_uri, 1, 0, "StyleItem"); diff --git a/src/controls/plugin.pri b/src/controls/plugin.pri index 1504e5dc..2d2bb4d6 100644 --- a/src/controls/plugin.pri +++ b/src/controls/plugin.pri @@ -1,6 +1,5 @@ HEADERS += \ $$PWD/qquickaction_p.h \ - $$PWD/qquickapplicationwindow_p.h \ $$PWD/qquickexclusivegroup_p.h \ $$PWD/qquickmenu_p.h \ $$PWD/qquickmenubar_p.h \ @@ -14,7 +13,6 @@ HEADERS += \ SOURCES += \ $$PWD/qquickaction.cpp \ - $$PWD/qquickapplicationwindow.cpp \ $$PWD/qquickexclusivegroup.cpp \ $$PWD/qquickmenu.cpp \ $$PWD/qquickmenubar.cpp \ diff --git a/src/controls/qquickapplicationwindow.cpp b/src/controls/qquickapplicationwindow.cpp deleted file mode 100644 index 4bdf1066..00000000 --- a/src/controls/qquickapplicationwindow.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Quick Controls module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickapplicationwindow_p.h" - -QT_BEGIN_NAMESPACE - -QQuickApplicationWindow::QQuickApplicationWindow(QWindow *parent) : - QQuickWindow(parent), m_hasColor(false) -{ - connect(this, SIGNAL(colorChanged(QColor)), this, SLOT(setHasColor())); -} - -bool QQuickApplicationWindow::hasColor() const -{ - return m_hasColor; -} - -void QQuickApplicationWindow::setHasColor(bool hasColor) -{ - if (m_hasColor != hasColor) { - m_hasColor = hasColor; - emit hasColorChanged(hasColor); - } -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickapplicationwindow_p.h b/src/controls/qquickapplicationwindow_p.h deleted file mode 100644 index 7165fe38..00000000 --- a/src/controls/qquickapplicationwindow_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Quick Controls module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKAPPLICATIONWINDOW_H -#define QQUICKAPPLICATIONWINDOW_H - -#include - -QT_BEGIN_NAMESPACE - -class QQuickApplicationWindow : public QQuickWindow -{ - Q_OBJECT - Q_PROPERTY(bool __hasColor READ hasColor NOTIFY hasColorChanged) - -public: - QQuickApplicationWindow(QWindow *parent = 0); - - bool hasColor() const; - -Q_SIGNALS: - void hasColorChanged(bool hasColor); - -private Q_SLOTS: - void setHasColor(bool hasColor = true); - -private: - bool m_hasColor; -}; - -QT_END_NAMESPACE - -#endif // QQUICKAPPLICATIONWINDOW_H -- cgit v1.2.1