diff --git a/components/Button.qml b/components/Button.qml index 9f456d3120b295893e4cceec2e45952866db789a..0f6eb34cc9bd01ebfce38003c564ea7a5f9c0bc9 100644 --- a/components/Button.qml +++ b/components/Button.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 Components.Button { id: button diff --git a/components/CheckBox.qml b/components/CheckBox.qml index 9eed75e834e6146f950a03e742fd38d5f2a0a741..71c3f627696d5e94f770bb2d6be7f074c2fb3a0b 100644 --- a/components/CheckBox.qml +++ b/components/CheckBox.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 // jb : Size should not depend on background, we should make it consistent diff --git a/components/ComboBox.qml b/components/ComboBox.qml index 81fadf1dc85f2a8d4520da373e7284aba149122a..c79be5ac30d447afc1734e1904029229066e426c 100644 --- a/components/ComboBox.qml +++ b/components/ComboBox.qml @@ -1,6 +1,6 @@ import QtQuick 1.1 import "custom" as Custom -import QtDesktop 0.1 +import QtDesktop 0.2 /* * diff --git a/components/ContextMenu.qml b/components/ContextMenu.qml index b26a6f643b95c4f32239830e48afd0fdccdf0455..69b78b1044a7d259f646595c23d76f92d6db1b5e 100644 --- a/components/ContextMenu.qml +++ b/components/ContextMenu.qml @@ -1,21 +1,26 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 -Menu { +Item { id: root property ListModel model property string selectedText: itemTextAt(selectedIndex) property string hoveredText: itemTextAt(hoveredIndex) - property int x - property int y - property bool visible + property list<Item> menuItems + + property int selectedIndex + property int hoveredIndex // 'centerSelectedText' means that the menu will be positioned // so that the selected text' top left corner will be at x, y. property bool centerSelectedText: true visible: false +/* + property int x + property int y + property bool visible onMenuClosed: visible = false onModelChanged: if (Component.status === Component.Ready && model != undefined) rebuildMenu() Component.onCompleted: if (model != undefined) rebuildMenu() @@ -49,4 +54,5 @@ Menu { addMenuItem(model.get(j).text) } } +*/ } diff --git a/components/Dial.qml b/components/Dial.qml index 61a03347b6eb22e53e5406ced55be009bdec5a6d..8b15852db7508fdf6d7911a50910655e96912bda 100644 --- a/components/Dial.qml +++ b/components/Dial.qml @@ -27,7 +27,7 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 // jens: ContainsMouse breaks drag functionality diff --git a/components/Frame.qml b/components/Frame.qml index bc7de579f3f1a1350aa025da987e5838d8c17c37..883a7965197f7cd63bf8223629c51a384296561f 100644 --- a/components/Frame.qml +++ b/components/Frame.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 Item { default property alias data: content.data diff --git a/components/GroupBox.qml b/components/GroupBox.qml index 6837ab1ff245e3a14663090ef8be161083d80679..9bcb65d0bbbe9f09f4a0895b72386b06d4a5886e 100644 --- a/components/GroupBox.qml +++ b/components/GroupBox.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 Components.GroupBox { id: groupbox diff --git a/components/MenuItem.qml b/components/MenuItem.qml index 15abc4dc839c478f62b04e7a7fbf44914b95cd7b..acd00bd40b1a7fb60578296ab8f0f44c3df08616 100644 --- a/components/MenuItem.qml +++ b/components/MenuItem.qml @@ -1,4 +1,4 @@ -import QtQuick 1.1 +import QtQuick 2.0 Item { property string text diff --git a/components/ProgressBar.qml b/components/ProgressBar.qml index 822c13f972c9b9afd5ab82e98c02b63f777a2587..a64355a5e9985c2ddb623bd8617564215d225d9a 100644 --- a/components/ProgressBar.qml +++ b/components/ProgressBar.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 Components.ProgressBar { id:progressbar diff --git a/components/RadioButton.qml b/components/RadioButton.qml index 56a2d227f3d22245607ed4473f4ed98e67c7a546..128d7821d3da6d4f2598695cd60305fa024a0b60 100644 --- a/components/RadioButton.qml +++ b/components/RadioButton.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 // jb : Size should not depend on background, we should make it consistent diff --git a/components/ScrollArea.qml b/components/ScrollArea.qml index 53421729e946fde0325b39c1eb7656430e334a2c..f8c4f979194765be66d969de57d9dd417fe10efc 100644 --- a/components/ScrollArea.qml +++ b/components/ScrollArea.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import "custom" as Components import "private" as Private -import QtDesktop 0.1 +import QtDesktop 0.2 FocusScope { id: root diff --git a/components/ScrollBar.qml b/components/ScrollBar.qml index 1fa0aa172aba4c7d331205df80b69bc499a3a8ce..a36fdbdeca36851df85d5ebc38225eb604258f4c 100644 --- a/components/ScrollBar.qml +++ b/components/ScrollBar.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 Item { id: scrollbar diff --git a/components/Slider.qml b/components/Slider.qml index 0994f7c257012d6711b18199754c8872078d123f..0b61223350652e7fd7ab1a301a318e34f0c1f70e 100644 --- a/components/Slider.qml +++ b/components/Slider.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 // jens: ContainsMouse breaks drag functionality diff --git a/components/SpinBox.qml b/components/SpinBox.qml index 4e6e84b73e84996f82aee9fd292fcdf069c55383..05783b859953ab5188e480ff4b3d2c17dd0b575e 100644 --- a/components/SpinBox.qml +++ b/components/SpinBox.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 Components.SpinBox { id:spinbox diff --git a/components/SplitterRow.qml b/components/SplitterRow.qml index eb0fd17f43d69e1ba0792923f5b6b1bfe441e94e..972fdf06a411fd0e0290f04c635c3d42cc0f553f 100644 --- a/components/SplitterRow.qml +++ b/components/SplitterRow.qml @@ -1,6 +1,6 @@ import QtQuick 1.1 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 /* * diff --git a/components/TabBar.qml b/components/TabBar.qml index ad70fd9c951427abd6f14d57a7fab9c119dd65e8..f42413ec0c5481b1c8006117033f707d392cd054 100644 --- a/components/TabBar.qml +++ b/components/TabBar.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 Item { diff --git a/components/TabFrame.qml b/components/TabFrame.qml index 725bec9181788e1b4a186765386d7852381c2062..4a48d4f96fa6ddca60b79d1c7b675e724ed7fb9f 100644 --- a/components/TabFrame.qml +++ b/components/TabFrame.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 Item { id: tabWidget diff --git a/components/TableView.qml b/components/TableView.qml index 257f370fac5e38a67d71ba2b868f59df32632276..95fc22f549eff6a3ac1ff298537d495ad3a6f710 100644 --- a/components/TableView.qml +++ b/components/TableView.qml @@ -1,5 +1,5 @@ import QtQuick 2.0 -import QtDesktop 0.1 +import QtDesktop 0.2 import "private" as Private /* diff --git a/components/TextArea.qml b/components/TextArea.qml index 66c2ea14e55a2138af88c37dd53c88d5d1a87d24..841b85182f8e2197a2915ab5b19ccb17fb25fa82 100644 --- a/components/TextArea.qml +++ b/components/TextArea.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 ScrollArea { id:area diff --git a/components/TextField.qml b/components/TextField.qml index e6950422ab8c36d0a0799cf9ca04644fe3103e9e..efe86629439f5864f6cb432fda2931c1d22474dc 100644 --- a/components/TextField.qml +++ b/components/TextField.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 Components.TextField { id: textfield diff --git a/components/ToolBar.qml b/components/ToolBar.qml index f2ebc9d7bae9c9ef26572ad82aa03f994c161e43..6aa32bc39ea110096f1bdf726b56fe90690a15f9 100644 --- a/components/ToolBar.qml +++ b/components/ToolBar.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import "." import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 StyleItem { id: toolbar diff --git a/components/ToolButton.qml b/components/ToolButton.qml index 5d597a077189f5900830adf776d632db410565be..76044fd2e030791494985f9a0cb2155f36058e3c 100644 --- a/components/ToolButton.qml +++ b/components/ToolButton.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import "custom" as Components -import QtDesktop 0.1 +import QtDesktop 0.2 Components.Button { id:button diff --git a/components/custom/Slider.qml b/components/custom/Slider.qml index 67179a9bc8bdd482a651942636cffe07342b40c0..7cf76e85b0111b1b0604f9c711d2fbd81b3cdfbf 100644 --- a/components/custom/Slider.qml +++ b/components/custom/Slider.qml @@ -25,7 +25,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtDesktop 0.1 +import QtDesktop 0.2 //import "../" Item { diff --git a/components/custom/Splitter.qml b/components/custom/Splitter.qml index 417a6b31c30abee16a678e52dd134ec171c8e7a9..40fa9eccd7bdbd51b787a36701603b16faf837d0 100644 --- a/components/custom/Splitter.qml +++ b/components/custom/Splitter.qml @@ -1,5 +1,5 @@ import QtQuick 1.1 -import QtDesktop 0.1 +import QtDesktop 0.2 Splitter { id: root diff --git a/components/private/ScrollAreaHelper.qml b/components/private/ScrollAreaHelper.qml index 3ad43e7423e7b254a248fd78038e221ab2e5aa1e..8573ec32e4b52bcac935927b4ed112b84714dd78 100644 --- a/components/private/ScrollAreaHelper.qml +++ b/components/private/ScrollAreaHelper.qml @@ -1,5 +1,5 @@ import QtQuick 1.1 -import QtDesktop 0.1 +import QtDesktop 0.2 WheelArea { id: wheelarea diff --git a/desktop.pro b/desktop.pro index 34fcd3f2086e023a93516324821f29c69cf74b80..d7cfec9c166d95d9f3629c81d212b422391130fe 100644 --- a/desktop.pro +++ b/desktop.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = components src qmldesktopviewer +SUBDIRS = components src diff --git a/examples/Browser.qml b/examples/Browser.qml index 558fc01b40a03d29ad7aac79a632367164ff5217..404b15ef0c5d5363b117807cc44668bf87edae68 100644 --- a/examples/Browser.qml +++ b/examples/Browser.qml @@ -2,7 +2,7 @@ import QtQuick 2.0 ======= import QtQuick 1.0 -import QtDesktop 0.1 +import QtDesktop 0.2 >>>>>>> master import QtWebKit 1.0 import "content" diff --git a/examples/BrowserTab.qml b/examples/BrowserTab.qml index c0564f9cc4da9d666610522e5d1b2f2b11e46895..65dabb09e7d0705ad751bf0009206b1f2189f23b 100644 --- a/examples/BrowserTab.qml +++ b/examples/BrowserTab.qml @@ -1,5 +1,5 @@ import QtQuick 1.0 -import QtDesktop 0.1 +import QtDesktop 0.2 import QtWebKit 1.0 import "content" diff --git a/examples/Gallery.qml b/examples/Gallery.qml index 665bd5e56157ff621a46c290428870006d131771..26dc867d6bb84c840352cff51e0545a6dfccc637 100644 --- a/examples/Gallery.qml +++ b/examples/Gallery.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 //import "../components" -import QtDesktop 0.1 +import QtQuick.Window 2.0 +import QtDesktop 0.2 import "content" @@ -44,12 +45,15 @@ Rectangle { width: 400 height: 400 + /* minimumWidth: 400 minimumHeight: 400 windowDecoration: true modal: modalCheck.checked - title: "child window" + */ + windowTitle: "child window" +/* MenuBar { Menu { text: "File" @@ -87,6 +91,7 @@ Rectangle { } } } +*/ Rectangle { color: syspal.window diff --git a/examples/ModelView.qml b/examples/ModelView.qml index a997399e8af5484ba700093717fdc4476d73a6f9..3998192ff56e7e86eea55da6cf55d4f59fdbc277 100644 --- a/examples/ModelView.qml +++ b/examples/ModelView.qml @@ -1,5 +1,6 @@ import QtQuick 2.0 -import QtDesktop 0.1 +import QtDesktop 0.2 +import QtQuick.XmlListModel 2.0 Item { id: root diff --git a/examples/SplitterGallery.qml b/examples/SplitterGallery.qml index 43cfffa024582d6160fd2d553e19f5f616fa3ebb..ab4bf53dea1c1e587d454e95aa783858d1f03554 100644 --- a/examples/SplitterGallery.qml +++ b/examples/SplitterGallery.qml @@ -1,5 +1,5 @@ import QtQuick 1.1 -import QtDesktop 0.1 +import QtDesktop 0.2 Rectangle { width: 800 diff --git a/examples/TableViewGallery.qml b/examples/TableViewGallery.qml index c199d50fd55df6e8120264f1d2fe7d90d84bbebd..20cf97ab9741587a41ea1ce76a5d482684962682 100644 --- a/examples/TableViewGallery.qml +++ b/examples/TableViewGallery.qml @@ -1,5 +1,5 @@ import QtQuick 1.0 -import QtDesktop 0.1 +import QtDesktop 0.2 Rectangle { diff --git a/examples/TopLevel.qml b/examples/TopLevel.qml index f024083f115d242288c36caff57f2f416472459b..dd0495c562b2224918c304dd030f061e3088c841 100644 --- a/examples/TopLevel.qml +++ b/examples/TopLevel.qml @@ -1,5 +1,5 @@ import QtQuick 1.0 -import QtDesktop 0.1 +import QtDesktop 0.2 import "content" Window { diff --git a/examples/TopLevelBrowser.qml b/examples/TopLevelBrowser.qml index bbefcc4702527ea295689ea92a271ff3f0a277a5..366ff4d703fe30ef1b7f5b0e4aeec098845bea33 100644 --- a/examples/TopLevelBrowser.qml +++ b/examples/TopLevelBrowser.qml @@ -1,5 +1,5 @@ import QtQuick 1.0 -import QtDesktop 0.1 +import QtDesktop 0.2 import "content" Window { diff --git a/src/qstyleitem.cpp b/src/qstyleitem.cpp index 6c82c1461f117a4273c3bf17428c2c2184730a36..5f950951ac628f32abf677d35f360b38977225ae 100644 --- a/src/qstyleitem.cpp +++ b/src/qstyleitem.cpp @@ -54,7 +54,7 @@ QStyleItem::QStyleItem(QQuickPaintedItem *parent) : QQuickPaintedItem(parent), - m_dummywidget(0), + m_dummywidget(new QWidget), m_styleoption(0), m_type(Undefined), m_sunken(false), @@ -862,6 +862,8 @@ void QStyleItem::setElementType(const QString &str) } else if (str == "scrollareacorner") { m_itemType = ScrollAreaCorner; } + if (!m_dummywidget) + m_dummywidget = new QWidget(); if (m_dummywidget) { m_dummywidget->installEventFilter(this); m_dummywidget->setAttribute(Qt::WA_QuitOnClose, false); // dont keep app open diff --git a/src/qstyleitem.h b/src/qstyleitem.h index 5a5d4f40bef230d37bd02d53c5235a8c3df62884..161b60fe28f25c1f12710fd5e27cf9f8e9b6c0ce 100644 --- a/src/qstyleitem.h +++ b/src/qstyleitem.h @@ -40,7 +40,7 @@ #ifndef STYLEWRAPPER_H #define STYLEWRAPPER_H -#include <QtDeclarative/qquickpainteditem.h> +#include <QtQuick/qquickpainteditem.h> //#include <QSGItem> #include <QtWidgets/QStyle> #include <QEvent> diff --git a/src/qstyleplugin.cpp b/src/qstyleplugin.cpp index c23ed701dca6c3191843c4ac72ca5aee43b70d0d..e1f7489427ee64c1b376423b49ca220847bf56c4 100644 --- a/src/qstyleplugin.cpp +++ b/src/qstyleplugin.cpp @@ -41,9 +41,6 @@ #include "qstyleplugin.h" #include "qstyleitem.h" #include "qrangemodel.h" -#include "qtmenu.h" -#include "qtmenubar.h" -#include "qwindowitem.h" #include "qdesktopitem.h" #include "qwheelarea.h" #include "qcursorarea.h" @@ -83,24 +80,16 @@ public: void StylePlugin::registerTypes(const char *uri) { qDebug(uri); - qmlRegisterType<QWindowItem>(uri, 0, 1, "Window"); - qmlRegisterType<QStyleItem>(uri, 0, 1, "StyleItem"); - qmlRegisterType<QCursorArea>(uri, 0, 1, "CursorArea"); - qmlRegisterType<QTooltipArea>(uri, 0, 1, "TooltipArea"); - qmlRegisterType<QRangeModel>(uri, 0, 1, "RangeModel"); - qmlRegisterType<QWheelArea>(uri, 0, 1, "WheelArea"); + qmlRegisterType<QStyleItem>(uri, 0, 2, "StyleItem"); + qmlRegisterType<QCursorArea>(uri, 0, 2, "CursorArea"); + qmlRegisterType<QTooltipArea>(uri, 0, 2, "TooltipArea"); + qmlRegisterType<QRangeModel>(uri, 0, 2, "RangeModel"); + qmlRegisterType<QWheelArea>(uri, 0, 2, "WheelArea"); - qmlRegisterType<QtMenu>(uri, 0, 1, "Menu"); - qmlRegisterType<QtMenuBar>(uri, 0, 1, "MenuBar"); - qmlRegisterType<QtMenuItem>(uri, 0, 1, "MenuItem"); - qmlRegisterType<QtMenuSeparator>(uri, 0, 1, "Separator"); + qmlRegisterType<QFileSystemModel>(uri, 0, 2, "FileSystemModel"); + qmlRegisterType<QtSplitterBase>(uri, 0, 2, "Splitter"); - qmlRegisterType<QFileSystemModel>(uri, 0, 1, "FileSystemModel"); - qmlRegisterType<QtSplitterBase>(uri, 0, 1, "Splitter"); - qmlRegisterType<QWindowItem>("QtQuick", 0, 1, "Window"); - - qmlRegisterUncreatableType<QtMenuBase>("uri", 0, 1, "NativeMenuBase", QLatin1String("Do not create objects of type NativeMenuBase")); - qmlRegisterUncreatableType<QDesktopItem>("QtQuick",2,0,"Desktop", QLatin1String("Do not create objects of type Desktop")); + qmlRegisterUncreatableType<QDesktopItem>(uri, 0,2,"Desktop", QLatin1String("Do not create objects of type Desktop")); } void StylePlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) diff --git a/src/qstyleplugin.h b/src/qstyleplugin.h index 73c7a7e897e6634867afdf6e608e4b26717d2761..28a08b1b86ffe853276194335a654cd535e8b83d 100644 --- a/src/qstyleplugin.h +++ b/src/qstyleplugin.h @@ -41,7 +41,6 @@ #define STYLEPLUGIN_H #include <QDeclarativeExtensionPlugin> -#include <QtScript/QScriptValue> #include <QtCore/QTimer> #include <QtWidgets/QFileSystemModel> #include "qdeclarativefolderlistmodel.h" diff --git a/src/qtmenu.cpp b/src/qtmenu.cpp deleted file mode 100644 index 1b91f63840b1831eddca9555603579e2aaf6adc3..0000000000000000000000000000000000000000 --- a/src/qtmenu.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#include "qtmenu.h" -#include "qdebug.h" -#include <qguiapplication.h> -#include <QtWidgets/qmenubar.h> - -#include "qtoplevelwindow.h" - -QtMenu::QtMenu(QObject *parent) - : QtMenuBase(parent), - dummy(0), - _selectedIndex(0), - _highlightedIndex(0) -{ - _qmenu = new QMenu(0); - connect(_qmenu, SIGNAL(aboutToHide()), this, SIGNAL(menuClosed())); -} - -QtMenu::~QtMenu() -{ - delete _qmenu; -} - -void QtMenu::setText(const QString &text) -{ - _qmenu->setTitle(text); -} - -QString QtMenu::text() const -{ - return _qmenu->title(); -} - -void QtMenu::setSelectedIndex(int index) -{ - _selectedIndex = index; - QList<QAction *> actionList = _qmenu->actions(); - if (_selectedIndex >= 0 && _selectedIndex < actionList.size()) - _qmenu->setActiveAction(actionList[_selectedIndex]); - emit selectedIndexChanged(); -} - -void QtMenu::setHoveredIndex(int index) -{ - _highlightedIndex = index; - QList<QAction *> actionList = _qmenu->actions(); - if (_highlightedIndex >= 0 && _highlightedIndex < actionList.size()) - _qmenu->setActiveAction(actionList[_highlightedIndex]); - emit hoveredIndexChanged(); -} - -QDeclarativeListProperty<QtMenuBase> QtMenu::menuItems() -{ - return QDeclarativeListProperty<QtMenuBase>(this, 0, &QtMenu::append_qmenuItem); -} - -void QtMenu::showPopup(qreal x, qreal y, int atActionIndex) -{ - if (_qmenu->isVisible()) - return; - - // If atActionIndex is valid, x and y is specified from the - // the position of the corresponding QAction: - QAction *atAction = 0; - if (atActionIndex >= 0 && atActionIndex < _qmenu->actions().size()) - atAction = _qmenu->actions()[atActionIndex]; - - // x,y are in view coordinates, QMenu expects screen coordinates - // ### activeWindow hack - int menuBarHeight = 0; - QWindow *window = QGuiApplication::focusWindow(); -// QWidget *window = QApplication::activeWindow(); - QTopLevelWindow *tw = qobject_cast<QTopLevelWindow*>(window); - if (tw) { - QMenuBar *menuBar = tw->menuBar(); - menuBarHeight = menuBar->height(); - } - - QPoint screenPosition = window->mapToGlobal(QPoint(x, y+menuBarHeight)); - - setHoveredIndex(_selectedIndex); - _qmenu->popup(screenPosition, atAction); -} - -void QtMenu::hidePopup() -{ - _qmenu->close(); -} - -QAction* QtMenu::action() -{ - return _qmenu->menuAction(); -} - -Q_INVOKABLE void QtMenu::clearMenuItems() -{ - _qmenu->clear(); - foreach (QtMenuBase *item, _qmenuItems) { - delete item; - } - _qmenuItems.clear(); -} - -void QtMenu::addMenuItem(const QString &text) -{ - QtMenuItem *menuItem = new QtMenuItem(this); - menuItem->setText(text); - _qmenuItems.append(menuItem); - _qmenu->addAction(menuItem->action()); - - connect(menuItem->action(), SIGNAL(triggered()), this, SLOT(emitSelected())); - connect(menuItem->action(), SIGNAL(hovered()), this, SLOT(emitHovered())); - - if (_qmenu->actions().size() == 1) - // Inform QML that the selected action (0) now has changed contents: - emit selectedIndexChanged(); -} - -void QtMenu::emitSelected() -{ - QAction *act = qobject_cast<QAction *>(sender()); - if (!act) - return; - _selectedIndex = _qmenu->actions().indexOf(act); - emit selectedIndexChanged(); -} - -void QtMenu::emitHovered() -{ - QAction *act = qobject_cast<QAction *>(sender()); - if (!act) - return; - _highlightedIndex = _qmenu->actions().indexOf(act); - emit hoveredIndexChanged(); -} - -QString QtMenu::itemTextAt(int index) const -{ - QList<QAction *> actionList = _qmenu->actions(); - if (index >= 0 && index < actionList.size()) - return actionList[index]->text(); - else - return ""; -} - -void QtMenu::append_qmenuItem(QDeclarativeListProperty<QtMenuBase> *list, QtMenuBase *menuItem) -{ - QtMenu *menu = qobject_cast<QtMenu *>(list->object); - if (menu) { - menuItem->setParent(menu); - menu->_qmenuItems.append(menuItem); - menu->qmenu()->addAction(menuItem->action()); - } -} - - diff --git a/src/qtmenu.h b/src/qtmenu.h deleted file mode 100644 index 6e4f8211061f650f60630fb7afce49a9284b2ffd..0000000000000000000000000000000000000000 --- a/src/qtmenu.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QTMLMENU_H -#define QTMLMENU_H - -#include <QtWidgets/qmenu.h> -#include <QtDeclarative/qdeclarative.h> -#include <QtDeclarative/QQuickItem> -#include <QtDeclarative/QDeclarativeListProperty> -#include "qtmenuitem.h" -#include <QtDeclarative/QDeclarativeListProperty> -#include "qtmenuitem.h" - -class QtMenu : public QtMenuBase -{ - Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText) - Q_PROPERTY(int selectedIndex READ selectedIndex WRITE setSelectedIndex NOTIFY selectedIndexChanged) - Q_PROPERTY(int hoveredIndex READ hoveredIndex WRITE setHoveredIndex NOTIFY hoveredIndexChanged) - Q_PROPERTY(QDeclarativeListProperty<QtMenuBase> menuItems READ menuItems) - Q_CLASSINFO("DefaultProperty", "menuItems") -public: - QtMenu(QObject *parent = 0); - virtual ~QtMenu(); - - void setText(const QString &text); - QString text() const; - - int selectedIndex() const { return _selectedIndex; } - void setSelectedIndex(int index); - int hoveredIndex() const { return _highlightedIndex; } - void setHoveredIndex(int index); - - QDeclarativeListProperty<QtMenuBase> menuItems(); - QMenu* qmenu() { return _qmenu; } - - QAction* action(); - - Q_INVOKABLE int minimumWidth() const { return _qmenu->minimumWidth(); } - Q_INVOKABLE void setMinimumWidth(int w) { _qmenu->setMinimumWidth(w); } - Q_INVOKABLE void showPopup(qreal x, qreal y, int atActionIndex = -1); - Q_INVOKABLE void hidePopup(); - Q_INVOKABLE void clearMenuItems(); - Q_INVOKABLE void addMenuItem(const QString &text); - Q_INVOKABLE QString itemTextAt(int index) const; - -Q_SIGNALS: - void menuClosed(); - void selectedIndexChanged(); - void hoveredIndexChanged(); - -private Q_SLOTS: - void emitSelected(); - void emitHovered(); - -private: - static void append_qmenuItem(QDeclarativeListProperty<QtMenuBase> *list, QtMenuBase *menuItem); - -private: - QWidget *dummy; - QMenu *_qmenu; - QList<QtMenuBase *> _qmenuItems; - int _selectedIndex; - int _highlightedIndex; -}; - -QML_DECLARE_TYPE(QtMenu) - -#endif // QTMLMENU_H diff --git a/src/qtmenubar.cpp b/src/qtmenubar.cpp deleted file mode 100644 index 921ec530f498f5a2d43214698638799930534a07..0000000000000000000000000000000000000000 --- a/src/qtmenubar.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtmenubar.h" -#include "qwindowitem.h" - -#include <QtWidgets/QMenu> -#include <QtWidgets/QMenuBar> - -QtMenuBar::QtMenuBar(QQuickItem *parent) - : QQuickItem(parent)/*, _menuBar(new QMenuBar)*/ -{ - connect(this, SIGNAL(parentChanged()), this, SLOT(updateParent())); - setFlag(QQuickItem::ItemHasContents, false); -} - -QtMenuBar::~QtMenuBar() -{ -} - -QDeclarativeListProperty<QtMenu> QtMenuBar::menus() -{ - return QDeclarativeListProperty<QtMenu>(this, 0, &QtMenuBar::append_menu); -} - -void QtMenuBar::updateParent() -{ - if (QWindowItem* window = qobject_cast<QWindowItem*>(parent())) - _menuBar = window->window()->menuBar(); - - //THIS IS WRONG... WE NEED TO DO THAT DIFFERENT! - _menuBar->clear(); - - foreach (QtMenu *menu, m_menus) { - _menuBar->addMenu(menu->qmenu()); - } - //THIS IS WRONG... WE NEED TO DO THAT DIFFERENT! - -} - -void QtMenuBar::append_menu(QDeclarativeListProperty<QtMenu> *list, QtMenu *menu) -{ - QtMenuBar *menuBar = qobject_cast<QtMenuBar *>(list->object); - if (menuBar) { - menu->setParent(menuBar); - menuBar->m_menus.append(menu); - if (menuBar->_menuBar) - menuBar->_menuBar->addMenu(menu->qmenu()); - } -} diff --git a/src/qtmenubar.h b/src/qtmenubar.h deleted file mode 100644 index 66a3908bd50a672200bd53e3e575956e582cd69c..0000000000000000000000000000000000000000 --- a/src/qtmenubar.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTMENUBAR_H -#define QTMENUBAR_H - -#include <QQuickItem> -#include <QtGui> -#include <QtWidgets/QMenu> -#include <QtWidgets/QMenuBar> - -#include "qtmenu.h" - -class QtMenuBar: public QQuickItem -{ - Q_OBJECT - - Q_PROPERTY(QDeclarativeListProperty<QtMenu> menus READ menus) - Q_CLASSINFO("DefaultProperty", "menus") -public: - QtMenuBar(QQuickItem *parent = 0); - ~QtMenuBar(); - - QDeclarativeListProperty<QtMenu> menus(); - -protected Q_SLOTS: - void updateParent(); - -private: - static void append_menu(QDeclarativeListProperty<QtMenu> *list, QtMenu *menu); - -private: - QList<QtMenu *> m_menus; - QMenuBar *_menuBar; -}; - -#endif //QTMENUBAR_H diff --git a/src/qtmenuitem.cpp b/src/qtmenuitem.cpp deleted file mode 100644 index 34be067e55912e97349b14c0a62ca2012f745610..0000000000000000000000000000000000000000 --- a/src/qtmenuitem.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtmenuitem.h" - -void QtMenuBase::setIconSource(const QUrl &icon) -{ - _iconSource = icon; - if (_iconName.isEmpty()) - action()->setIcon(QIcon(icon.toLocalFile())); - else - action()->setIcon(QIcon::fromTheme(_iconName, QIcon(_iconSource.toLocalFile()))); - - emit iconSourceChanged(); -} - -QUrl QtMenuBase::iconSource() const -{ - return _iconSource; -} - -void QtMenuBase::setIconName(const QString &icon) -{ - _iconName = icon; - action()->setIcon(QIcon::fromTheme(_iconName, QIcon(_iconSource.toLocalFile()))); - - emit iconNameChanged(); -} - -QString QtMenuBase::iconName() const -{ - return _iconName; -} - -QtMenuSeparator::QtMenuSeparator(QObject *parent) - : QtMenuBase(parent), _action(new QAction(this)) -{ - _action->setSeparator(true); -} - -QtMenuSeparator::~QtMenuSeparator() -{ -} - -QAction * QtMenuSeparator::action() -{ - return _action; -} - -QtMenuItem::QtMenuItem(QObject *parent) - : QtMenuBase(parent), _action(new QAction(this)) -{ - connect(_action, SIGNAL(triggered()), this, SIGNAL(triggered())); - connect(_action, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); -} - -QtMenuItem::~QtMenuItem() -{ -} - -void QtMenuItem::setText(const QString &text) -{ - _action->setText(text); - emit textChanged(); -} - -void QtMenuItem::setShortcut(const QString &shortcut) -{ - _action->setShortcut(QKeySequence(shortcut)); - emit shortcutChanged(); -} - -void QtMenuItem::setCheckable(bool checkable) -{ - _action->setCheckable(checkable); -} - -void QtMenuItem::setChecked(bool checked) -{ - _action->setChecked(checked); -} - -QString QtMenuItem::text() const -{ - return _action->text(); -} - -QString QtMenuItem::shortcut() const -{ - return _action->shortcut().toString(); -} - -bool QtMenuItem::checkable() const -{ - return _action->isCheckable(); -} - -bool QtMenuItem::checked() const -{ - return _action->isChecked(); -} - -QAction * QtMenuItem::action() -{ - return _action; -} diff --git a/src/qtmenuitem.h b/src/qtmenuitem.h deleted file mode 100644 index f5860a031aade294b124c8730802b1600b9d30d9..0000000000000000000000000000000000000000 --- a/src/qtmenuitem.h +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTMENUITEM_H -#define QTMENUITEM_H - -#include <QtCore/QObject> -#include <QtWidgets/QAction> -#include <QtCore/QUrl> - -class QtMenuBase: public QObject { - Q_OBJECT - Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged) - Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged) - -public: - QtMenuBase(QObject *parent = 0) : QObject(parent) {} - virtual QAction* action() = 0; - - void setIconSource(const QUrl &icon); - QUrl iconSource() const; - - void setIconName(const QString &icon); - QString iconName() const; - -Q_SIGNALS: - void iconSourceChanged(); - void iconNameChanged(); - -private: - QUrl _iconSource; - QString _iconName; -}; - -class QtMenuSeparator : public QtMenuBase -{ - Q_OBJECT -public: - QtMenuSeparator(QObject *parent = 0); - ~QtMenuSeparator(); - QAction* action(); - -private: - QAction *_action; -}; - -class QtMenuItem: public QtMenuBase -{ - Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged); - Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged) - Q_PROPERTY(bool checkable READ checkable WRITE setCheckable) - Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY toggled) - -public: - QtMenuItem(QObject *parent = 0); - ~QtMenuItem(); - - void setText(const QString &text); - void setShortcut(const QString &shortcut); - void setCheckable(bool checkable); - void setChecked(bool checked); - - QString text() const; - QString shortcut() const; - bool checkable() const; - bool checked() const; - - QAction* action(); - -Q_SIGNALS: - void triggered(); - void textChanged(); - void shortcutChanged(); - void toggled(bool); - -private: - QAction *_action; -}; - -#endif //QTMENUITEM_H diff --git a/src/qtoplevelwindow.cpp b/src/qtoplevelwindow.cpp deleted file mode 100644 index d029e03acde5b9bdddee48e8d2cd3488c292badb..0000000000000000000000000000000000000000 --- a/src/qtoplevelwindow.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include "qtoplevelwindow.h" - -#include <QtWidgets/QDesktopWidget> - -QTopLevelWindow::QTopLevelWindow() - : QMainWindow(), _view(new QQuickView), _positionIsDefined(false) { - setVisible(false); - //setCentralWidget(_view); - setAttribute(Qt::WA_DeleteOnClose); -} - -QTopLevelWindow::~QTopLevelWindow() -{ - //we need this to break the parental loop of QWindowItem and QTopLevelWindow - //_view->scene()->setParent(0); -} - -void QTopLevelWindow::registerChildWindow(QTopLevelWindow* child) -{ - _childWindows.insert(child); - child->setParent(this); -} - -void QTopLevelWindow::hideChildWindows() -{ - foreach(QTopLevelWindow* child, _childWindows) { - child->hide(); - } -} - -void QTopLevelWindow::initPosition() -{ - if (!_positionIsDefined) - center(); - foreach(QTopLevelWindow* child, _childWindows) { - child->initPosition(); - } -} - -void QTopLevelWindow::center() -{ - QPoint parentCenter; - if (parentWidget()) - parentCenter = parentWidget()->geometry().center(); - else - parentCenter = QDesktopWidget().screenGeometry().center(); - QRect thisGeometry = geometry(); - thisGeometry.moveCenter(parentCenter); - setGeometry(thisGeometry); -} - -void QTopLevelWindow::move(int x, int y) -{ - qDebug("a %d, %d", x, y); - move(QPoint(x,y)); -} - -void QTopLevelWindow::move(const QPoint &point) -{ - _positionIsDefined = true; - QMainWindow::move(point); -} - -void QTopLevelWindow::setWindowFlags(Qt::WindowFlags type) -{ - QWidget::setWindowFlags(type | Qt::Window); -} - -bool QTopLevelWindow::event(QEvent *event) { - switch (event->type()) { - case QEvent::WindowStateChange: - emit windowStateChanged(); - break; - case QEvent::Show: - emit visibilityChanged(); - break; - case QEvent::Hide: - hideChildWindows(); - emit visibilityChanged(); - break; - case QEvent::ParentChange: - setAttribute(Qt::WA_DeleteOnClose, !parent()); - break; - case QEvent::Resize: { - const QResizeEvent *resize = static_cast<const QResizeEvent *>(event); - emit sizeChanged(resize->size()); - break; - } - default: break; - } - return QMainWindow::event(event); -} diff --git a/src/qtoplevelwindow.h b/src/qtoplevelwindow.h deleted file mode 100644 index 143b576a337e00bda46b08f69ad8e6c1004c1ef9..0000000000000000000000000000000000000000 --- a/src/qtoplevelwindow.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QTOPLEVELWINDOW_H -#define QTOPLEVELWINDOW_H - -#include <QtDeclarative/QQuickView> -#include <QtWidgets/QMainWindow> -#include <QWindowStateChangeEvent> -#include <QDebug> - -class QTopLevelWindow : public QMainWindow { - Q_OBJECT -public: - QTopLevelWindow(); - ~QTopLevelWindow(); - - //QGraphicsScene *scene() { return _view->scene(); } - QQuickView *view() { return _view; } - - - void registerChildWindow(QTopLevelWindow* child); - void hideChildWindows(); - void initPosition(); - void setWindowFlags(Qt::WindowFlags type); - - void center(); - void move(int x, int y); - void move(const QPoint &); - -protected: - virtual bool event(QEvent *event); - -Q_SIGNALS: - void visibilityChanged(); - void windowStateChanged(); - void sizeChanged(QSize newSize); - -private: - QQuickView *_view; - QSet<QTopLevelWindow*> _childWindows; - bool _positionIsDefined; - -}; - -#endif // QTOPLEVELWINDOW_H diff --git a/src/qtsplitterbase.h b/src/qtsplitterbase.h index 726f2f0430f59abaa20165f63fd5f84c88f4e637..c5507e2f1006d576d2284af2ad202e7b6871bbe3 100644 --- a/src/qtsplitterbase.h +++ b/src/qtsplitterbase.h @@ -2,6 +2,7 @@ #define QTSPLITTERBASE_H #include <QtDeclarative> +#include <QtQuick> class QtSplitterAttached : public QObject diff --git a/src/qwheelarea.h b/src/qwheelarea.h index 275e6abf6214bfa45e2318c5d582e5d602eb1546..f88832f6066517bb8e13400b78aa5c5969564220 100644 --- a/src/qwheelarea.h +++ b/src/qwheelarea.h @@ -29,7 +29,7 @@ #include <QtGui/qevent.h> #include <QtWidgets/qgraphicssceneevent.h> -#include <QtDeclarative/qquickitem.h> +#include <QtQuick/qquickitem.h> class QWheelArea : public QQuickItem diff --git a/src/qwindowitem.cpp b/src/qwindowitem.cpp deleted file mode 100644 index ae38b00e195a1c1f5275e748f3f931ae5cf88278..0000000000000000000000000000000000000000 --- a/src/qwindowitem.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTgall -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qwindowitem.h" -#include "qtoplevelwindow.h" - -#include <QTimer> - -QWindowItem::QWindowItem(QTopLevelWindow* tlw) - : _window(tlw ? tlw : new QTopLevelWindow), _positionIsDefined(false), _delayedVisible(false), _x(0), _y(0) -{ - connect(_window, SIGNAL(visibilityChanged()), this, SIGNAL(visibleChanged())); - connect(_window, SIGNAL(windowStateChanged()), this, SIGNAL(windowStateChanged())); - connect(_window, SIGNAL(sizeChanged(QSize)), this, SLOT(updateSize(QSize))); - - connect(qApp, SIGNAL(aboutToQuit()), _window, SLOT(close())); - view()->setResizeMode(QQuickView::SizeRootObjectToView); - _window->installEventFilter(this); -} - -QWindowItem::~QWindowItem() -{ -} - -bool QWindowItem::eventFilter(QObject *, QEvent *ev) -{ - switch(ev->type()) { - case QEvent::Resize: - emit sizeChanged(); - emit widthChanged(); - emit heightChanged(); - break; - - case QEvent::Move: - emit xChanged(); - emit yChanged(); - break; - - default: - break; - } - return false; -} - -void QWindowItem::registerChildWindow(QWindowItem *child) { - _window->registerChildWindow(child->window()); -} - -void QWindowItem::updateParentWindow() { - QQuickItem *p = parentItem(); - while (p) { - if (QWindowItem *w = qobject_cast<QWindowItem*>(p)) { - w->registerChildWindow(this); - return; - } - p = p->parentItem(); - } -} - -void QWindowItem::componentComplete() -{ - updateParentWindow(); -// _window->scene()->addItem(this); -// if (!_window->parentWidget()) -// _window->initPosition(); - - QQuickItem::componentComplete(); - - if (_delayedVisible) { - setVisible(true); - } -} - -void QWindowItem::updateSize(QSize newSize) -{ - QQuickItem::setSize(newSize); - emit sizeChanged(); -} - -void QWindowItem::center() -{ - _window->center(); -} - -void QWindowItem::setX(int x) -{ - _x = x; - _window->move(x, _y); -} -void QWindowItem::setY(int y) -{ - _y = y; - _window->move(_x, y); -} - -void QWindowItem::moveWindow(int x,int y, int lx, int ly) -{ - QPoint p = _window->mapToGlobal(QPoint(x,y)); - p.setX(p.x() - lx); - p.setY(p.y() - ly); - _window->move(p); -} - -void QWindowItem::setHeight(int height) -{ - int menuBarHeight = _window->menuBar()->sizeHint().height(); - if (menuBarHeight) menuBarHeight++; - _window->resize(width(), height+menuBarHeight); - QQuickItem::setHeight(_window->height()); -} - -void QWindowItem::setMinimumHeight(int height) -{ - int menuBarHeight = _window->menuBar()->sizeHint().height(); - if (menuBarHeight) menuBarHeight++; - _window->setMinimumHeight(height+menuBarHeight); -} - -void QWindowItem::setMaximumHeight(int height) -{ - int menuBarHeight = _window->menuBar()->sizeHint().height(); - if (menuBarHeight) menuBarHeight++; - _window->setMaximumHeight(height+menuBarHeight); -} - -void QWindowItem::setWidth(int width) -{ - _window->resize(width, height()); - QQuickItem::setWidth(_window->width()); -} - -void QWindowItem::setTitle(QString title) -{ - _window->setWindowTitle(title); - emit titleChanged(); -} - -void QWindowItem::setVisible(bool visible) -{ - _window->setWindowFlags(_window->windowFlags() | Qt::Window); - if (visible) { - if (isComponentComplete()) { - // avoid flickering when showing the widget, - // by passing the event loop at least once - QTimer::singleShot(1, _window, SLOT(show())); - } else { - _delayedVisible = true; - } - } else { - _window->hide(); - } -} - -void QWindowItem::setWindowDecoration(bool s) -{ - bool visible = _window->isVisible(); - - - _window->setWindowFlags(s ? _window->windowFlags() & ~Qt::FramelessWindowHint - : _window->windowFlags() | Qt::FramelessWindowHint); - if (visible) - _window->show(); - emit windowDecorationChanged(); -} - -void QWindowItem::setModal(bool modal) -{ - bool visible = _window->isVisible(); - _window->hide(); - _window->setWindowModality(modal ? Qt::WindowModal : Qt::NonModal); - - if (modal) //this is a workaround for a bug in Qt? or in Unity? - _window->setWindowFlags(_window->windowFlags() | Qt::WindowStaysOnTopHint); - else - _window->setWindowFlags(_window->windowFlags() & ~Qt::WindowStaysOnTopHint ); - - if (visible) - _window->show(); - emit modalityChanged(); -} - -void QWindowItem::setClose(bool close) -{ - if (close) - _window->close(); -} - - diff --git a/src/qwindowitem.h b/src/qwindowitem.h deleted file mode 100644 index 81e439b9bbca0c0ae9d50c3ddc2dfec4dd54fed1..0000000000000000000000000000000000000000 --- a/src/qwindowitem.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Components project on Qt Labs. -** -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions contained -** in the Technology Preview License Agreement accompanying this package. -** -** 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -****************************************************************************/ - -#ifndef QWindowItem_H -#define QWindowItem_H - -#include "qtoplevelwindow.h" - -#include <QtWidgets/QApplication> -#include <QQuickItem> -#include <QQuickView> -#include <QtWidgets/QMenuBar> - - -class QWindowItem : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged) - Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged) - Q_PROPERTY(int height READ height WRITE setHeight NOTIFY sizeChanged) - Q_PROPERTY(int width READ width WRITE setWidth NOTIFY sizeChanged) - Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged) - Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged) - Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged) - Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) - Q_PROPERTY(bool windowDecoration READ windowDecoration WRITE setWindowDecoration NOTIFY windowDecorationChanged) - Q_PROPERTY(bool modal READ modal WRITE setModal NOTIFY modalityChanged) - Q_PROPERTY(bool close READ close WRITE setClose) - Q_PROPERTY(Qt::WindowState windowState READ windowState WRITE setWindowState NOTIFY windowStateChanged) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) - -public: - QWindowItem(QTopLevelWindow* QTopLevelWindow = 0); - ~QWindowItem(); - - QTopLevelWindow *window() { return _window; } - QQuickView *view() { return _window->view(); } - int x() { return _window->x(); } - int y() { return _window->y(); } - int height() { return _window->height(); } - int minimumHeight() { return _window->minimumHeight(); } - int maximumHeight() { return _window->maximumHeight(); } - int width() { return _window->width(); } - int minimumWidth() { return _window->minimumWidth(); } - int maximumWidth() { return _window->maximumWidth(); } - bool isVisible() { return _window->isVisible(); } - bool windowDecoration() { return !(_window->windowFlags() & Qt::FramelessWindowHint); } - Qt::WindowState windowState() { return static_cast<Qt::WindowState>(static_cast<int>(_window->windowState()) & ~Qt::WindowActive); } - QString title() const { return _window->windowTitle(); } - bool modal() { return _window->isModal(); } - bool close() { return false; } //we always return false here - - void setX(int x); - void setY(int y); - void setHeight(int height); - void setMinimumHeight(int height); - void setMaximumHeight(int height); - void setWidth(int width); - void setMinimumWidth(int width) { _window->setMinimumWidth(width); } - void setMaximumWidth(int width) { _window->setMaximumWidth(width); } - void setVisible(bool visible); - void setWindowDecoration(bool s); - void setWindowState(Qt::WindowState state) { _window->setWindowState(state); } - void setTitle(QString title); - void setModal(bool modal); - void setClose(bool close); - -protected: - bool eventFilter(QObject *, QEvent *ev); - void updateParentWindow(); - void registerChildWindow(QWindowItem* child); - void componentComplete(); - -protected Q_SLOTS: - void updateSize(QSize newSize); - void center(); - void moveWindow(int x, int y, int lx, int ly); - -Q_SIGNALS: - void sizeChanged(); - void xChanged(); - void yChanged(); - void visibleChanged(); - void windowDecorationChanged(); - void windowStateChanged(); - void minimumHeightChanged(); - void minimumWidthChanged(); - void maximumHeightChanged(); - void maximumWidthChanged(); - void titleChanged(); - void modalityChanged(); - -private: - QTopLevelWindow *_window; - bool _complete; - bool _positionIsDefined; - bool _delayedVisible; - int _x; - int _y; -}; - -#endif // QWindowItem_H diff --git a/src/src.pro b/src/src.pro index 6e82d68bc441f1917a0327359c2044f35b92fe2c..e95a64d7b13e83ba16e235bcdbd3527004d7426b 100644 --- a/src/src.pro +++ b/src/src.pro @@ -9,33 +9,23 @@ DESTDIR = ../components/plugin OBJECTS_DIR = obj MOC_DIR = moc -HEADERS += qtmenu.h \ - qtmenubar.h \ - qrangemodel_p.h \ +HEADERS += qrangemodel_p.h \ qrangemodel.h \ qstyleplugin.h \ qdeclarativefolderlistmodel.h \ qstyleitem.h \ qwheelarea.h \ - qtmenuitem.h \ - qwindowitem.h \ qdesktopitem.h \ - qtoplevelwindow.h \ qcursorarea.h \ qtooltiparea.h \ qtsplitterbase.h -SOURCES += qtmenu.cpp \ - qtmenubar.cpp \ - qrangemodel.cpp \ +SOURCES += qrangemodel.cpp \ qstyleplugin.cpp \ qdeclarativefolderlistmodel.cpp \ qstyleitem.cpp \ qwheelarea.cpp \ - qtmenuitem.cpp \ - qwindowitem.cpp \ qdesktopitem.cpp \ - qtoplevelwindow.cpp \ qcursorarea.cpp \ qtooltiparea.cpp \ qtsplitterbase.cpp