diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2013-09-20 15:20:27 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-26 09:49:22 +0200 |
commit | 0794c6e552c2df6c7531f7657f276e3c7f90976d (patch) | |
tree | c126c36e876d8b4933dc2081416c036b46da56a2 /src | |
parent | 48e14ce3ed6a269cec26c0b18df00617271936d9 (diff) |
Sync the jump lists QML API
The C++ API was changed - update the QML API accordingly.
Change-Id: I89d0939c4ffc27580e7db53a479db4ff70ee0fef
Reviewed-by: Ivan Vizir <define-true-false@yandex.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/winextras/plugin.cpp | 2 | ||||
-rw-r--r-- | src/imports/winextras/qquickjumplist.cpp | 213 | ||||
-rw-r--r-- | src/imports/winextras/qquickjumplist_p.h | 100 | ||||
-rw-r--r-- | src/imports/winextras/qquickjumplistcategory.cpp | 156 | ||||
-rw-r--r-- | src/imports/winextras/qquickjumplistcategory_p.h | 96 | ||||
-rw-r--r-- | src/imports/winextras/qquickjumplistitem.cpp | 88 | ||||
-rw-r--r-- | src/imports/winextras/qquickjumplistitem_p.h | 78 | ||||
-rw-r--r-- | src/imports/winextras/winextras.pro | 4 |
8 files changed, 537 insertions, 200 deletions
diff --git a/src/imports/winextras/plugin.cpp b/src/imports/winextras/plugin.cpp index 6424477..db74e4f 100644 --- a/src/imports/winextras/plugin.cpp +++ b/src/imports/winextras/plugin.cpp @@ -43,6 +43,8 @@ #include "qquickdwmfeatures_p.h" #include "qquicktaskbarbutton_p.h" #include "qquickjumplist_p.h" +#include "qquickjumplistitem_p.h" +#include "qquickjumplistcategory_p.h" #include "qquickthumbnailtoolbar_p.h" #include "qquickthumbnailtoolbutton_p.h" diff --git a/src/imports/winextras/qquickjumplist.cpp b/src/imports/winextras/qquickjumplist.cpp index b49be6d..aa853ae 100644 --- a/src/imports/winextras/qquickjumplist.cpp +++ b/src/imports/winextras/qquickjumplist.cpp @@ -41,7 +41,8 @@ ****************************************************************************/ #include "qquickjumplist_p.h" -#include <QIcon> +#include "qquickjumplistcategory_p.h" +#include <QWinJumpList> QT_BEGIN_NAMESPACE @@ -65,195 +66,139 @@ QT_BEGIN_NAMESPACE \internal */ -QQuickJumpList::QQuickJumpList(QQuickItem *parent) : - QQuickItem(parent), frequentCategoryShown(false), recentCategoryShown(false) +QQuickJumpList::QQuickJumpList(QObject *parent) : + QObject(parent), m_recent(0), m_frequent(0), m_tasks(0) { } -/*! - \qmlproperty object JumpList::tasks - - Application tasks. - */ -QQmlListProperty<QQuickJumpListItem> QQuickJumpList::tasks() +QQuickJumpList::~QQuickJumpList() { - return QQmlListProperty<QQuickJumpListItem>(this, this, &QQuickJumpList::appendTaskItem, 0, 0, 0); } /*! - \qmlproperty object JumpList::destinations + \qmlproperty JumpListCategory JumpList::recent + \readonly - Categories of custom destinations. + The recent items category. */ -QQmlListProperty<QQuickJumpListCategory> QQuickJumpList::destinations() +QQuickJumpListCategory *QQuickJumpList::recent() const { - return QQmlListProperty<QQuickJumpListCategory>(this, this, &QQuickJumpList::appendGroup, 0, 0, 0); + if (!m_recent) { + QQuickJumpList *that = const_cast<QQuickJumpList *>(this); + that->m_recent = new QQuickJumpListCategory(that); + connect(m_recent, SIGNAL(visibilityChanged()), that, SLOT(rebuild())); + m_recent->setVisible(false); + } + return m_recent; } /*! - \qmlproperty bool JumpList::showFrequentCategory + \qmlproperty JumpListCategory JumpList::frequent + \readonly - Contains true if the \e Frequent category is shown; otherwise false. + The frequent items category. */ -bool QQuickJumpList::showFrequentCategory() const -{ - return frequentCategoryShown; -} - -void QQuickJumpList::setShowFrequentCategory(bool show) +QQuickJumpListCategory *QQuickJumpList::frequent() const { - frequentCategoryShown = show; + if (!m_frequent) { + QQuickJumpList *that = const_cast<QQuickJumpList *>(this); + that->m_frequent = new QQuickJumpListCategory(that); + connect(m_frequent, SIGNAL(visibilityChanged()), that, SLOT(rebuild())); + m_frequent->setVisible(false); + } + return m_frequent; } /*! - \qmlproperty bool JumpList::showRecentCategory + \qmlproperty JumpListCategory JumpList::tasks - Contains true if the \e Recent category is shown; otherwise false. + The tasks category. */ -bool QQuickJumpList::showRecentCategory() const -{ - return recentCategoryShown; -} - -void QQuickJumpList::setShowRecentCategory(bool show) -{ - recentCategoryShown = show; -} - -void QQuickJumpList::componentComplete() +QQuickJumpListCategory *QQuickJumpList::tasks() const { - QQuickItem::componentComplete(); - QWinJumpList jumplist; - jumplist.frequent()->setVisible(frequentCategoryShown); - jumplist.recent()->setVisible(recentCategoryShown); - if (!taskList.isEmpty()) { - Q_FOREACH (QQuickJumpListItem *item, taskList) - jumplist.tasks()->addItem(item->toJumpListItem()); - taskList.clear(); - } - if (!categoryList.isEmpty()) { - Q_FOREACH (QQuickJumpListCategory *category, categoryList) { - QList<QWinJumpListItem *> items = category->toItemList(); - jumplist.addCategory(category->title(), items); - } + if (!m_tasks) { + QQuickJumpList *that = const_cast<QQuickJumpList *>(this); + that->m_tasks = new QQuickJumpListCategory(that); + connect(m_tasks, SIGNAL(visibilityChanged()), that, SLOT(rebuild())); } + return m_tasks; } -void QQuickJumpList::appendTaskItem(QQmlListProperty<QQuickJumpListItem> *property, QQuickJumpListItem *value) +void QQuickJumpList::setTasks(QQuickJumpListCategory *tasks) { - static_cast<QQuickJumpList *>(property->data)->taskList.append(value); -} - -void QQuickJumpList::appendGroup(QQmlListProperty<QQuickJumpListCategory> *property, QQuickJumpListCategory *value) -{ - static_cast<QQuickJumpList *>(property->data)->categoryList.append(value); + if (m_tasks != tasks) { + if (m_tasks) + disconnect(m_tasks, SIGNAL(visibilityChanged()), this, SLOT(rebuild())); + delete m_tasks; + m_tasks = tasks; + if (m_tasks) + connect(m_tasks, SIGNAL(visibilityChanged()), this, SLOT(rebuild())); + emit tasksChanged(); + } } - -/*! - \qmltype JumpCategory - \instantiates QQuickJumpListCategory - \inqmlmodule QtWinExtras - - \brief Represents a category of custom destinations. - - \since QtWinExtras 1.0 - - The JumpCategory type represents a category that consists of several - Jump List destinations and has a title. - */ - /*! - \class QQuickJumpListCategory + \qmlproperty list<QtObject> JumpList::data \internal */ - -QQuickJumpListCategory::QQuickJumpListCategory(QObject *parent) : - QObject(parent) -{ -} - -QQuickJumpListCategory::~QQuickJumpListCategory() -{ -} - -/*! - \qmlproperty object JumpCategory::destinations - - The destinations in this category. - */ -QQmlListProperty<QQuickJumpListItem> QQuickJumpListCategory::destinations() +QQmlListProperty<QObject> QQuickJumpList::data() { - return QQmlListProperty<QQuickJumpListItem>(this, this, &QQuickJumpListCategory::addItem, 0, 0, 0); -} - -void QQuickJumpListCategory::setTitle(const QString &title) -{ - m_groupTitle = title; + return QQmlListProperty<QObject>(this, this, &QQuickJumpList::data_append, 0, 0, 0); } /*! - \qmlproperty string JumpCategory::title + \qmlproperty list<JumpListCategory> JumpList::categories - The title of the category. + A list of custom categories. */ -QString QQuickJumpListCategory::title() const +QQmlListProperty<QQuickJumpListCategory> QQuickJumpList::categories() { - return m_groupTitle; + return QQmlListProperty<QQuickJumpListCategory>(this, this, &QQuickJumpList::categories_count, &QQuickJumpList::categories_at); } -QList<QWinJumpListItem *> QQuickJumpListCategory::toItemList() const +void QQuickJumpList::classBegin() { - QList<QWinJumpListItem *> destinations; - foreach (QQuickJumpListItem *item, m_destinations) - destinations.append(item->toJumpListItem()); - return destinations; } -void QQuickJumpListCategory::addItem(QQmlListProperty<QQuickJumpListItem> *property, QQuickJumpListItem *value) -{ - static_cast<QQuickJumpListCategory *>(property->data)->m_destinations.append(value); -} - - -QQuickJumpListItem::QQuickJumpListItem(QObject *p) : - QObject(p) +void QQuickJumpList::componentComplete() { + rebuild(); } -QQuickJumpListItem::~QQuickJumpListItem() +void QQuickJumpList::rebuild() { + QWinJumpList jumpList; + jumpList.recent()->setVisible(m_recent && m_recent->isVisible()); + jumpList.frequent()->setVisible(m_frequent && m_frequent->isVisible()); + if (m_tasks && m_tasks->isVisible()) { + jumpList.tasks()->setVisible(true); + foreach (QWinJumpListItem *item, m_tasks->toItemList()) + jumpList.tasks()->addItem(item); + } + foreach (QQuickJumpListCategory *category, m_categories) { + if (category->isVisible()) + jumpList.addCategory(category->title(), category->toItemList())->setVisible(true); + } } -void QQuickJumpListItem::setType(int type) +void QQuickJumpList::data_append(QQmlListProperty<QObject> *property, QObject *object) { - m_type = type; + if (QQuickJumpListCategory *category = qobject_cast<QQuickJumpListCategory *>(object)) { + QQuickJumpList *jumpList = static_cast<QQuickJumpList *>(property->object); + connect(category, SIGNAL(visibilityChanged()), jumpList, SLOT(rebuild())); + jumpList->m_categories.append(category); + emit jumpList->categoriesChanged(); + } } -int QQuickJumpListItem::type() const +int QQuickJumpList::categories_count(QQmlListProperty<QQuickJumpListCategory> *property) { - return m_type; + return static_cast<QQuickJumpList *>(property->object)->m_categories.count(); } -QWinJumpListItem *QQuickJumpListItem::toJumpListItem() const +QQuickJumpListCategory *QQuickJumpList::categories_at(QQmlListProperty<QQuickJumpListCategory> *property, int index) { - QWinJumpListItem *item = new QWinJumpListItem(QWinJumpListItem::Separator); - switch (m_type) { - case ItemTypeDestination : - item->setType(QWinJumpListItem::Destination); - item->setFilePath(property("filePath").toString()); - break; - case ItemTypeLink : - item->setType(QWinJumpListItem::Link); - item->setFilePath(property("executablePath").toString()); - item->setArguments(QStringList(property("arguments").toStringList())); - item->setDescription(property("description").toString()); - item->setTitle(property("title").toString()); - item->setIcon(QIcon(property("iconPath").toString())); - break; - } - - return item; + return static_cast<QQuickJumpList *>(property->object)->m_categories.value(index); } QT_END_NAMESPACE diff --git a/src/imports/winextras/qquickjumplist_p.h b/src/imports/winextras/qquickjumplist_p.h index 0bb33a1..aae6c5a 100644 --- a/src/imports/winextras/qquickjumplist_p.h +++ b/src/imports/winextras/qquickjumplist_p.h @@ -43,89 +43,57 @@ #ifndef QQUICKJUMPLIST_P_H #define QQUICKJUMPLIST_P_H -#include <QQuickItem> +#include <QObject> +#include <QQmlParserStatus> #include <QQmlListProperty> -#include <QIcon> -#include <QWinJumpList> -#include <QWinJumpListItem> -#include <QWinJumpListCategory> QT_BEGIN_NAMESPACE -class QQuickJumpListItem : public QObject -{ - Q_OBJECT - Q_PROPERTY(int __jumpListItemType READ type WRITE setType) - -public: - enum JumpListItemType { - ItemTypeLink = 1, - ItemTypeDestination = 2, - ItemTypeSeparator = 3 - }; +class QQuickJumpListCategory; - Q_ENUMS(JumpListItemType) - - explicit QQuickJumpListItem(QObject *p = 0); - ~QQuickJumpListItem(); - void setType(int type); - int type() const; - QWinJumpListItem *toJumpListItem() const; - -private: - int m_type; // 1 - link, 2 - destination -}; - -class QQuickJumpListCategory : public QObject +class QQuickJumpList : public QObject, public QQmlParserStatus { Q_OBJECT - Q_PROPERTY(QQmlListProperty<QQuickJumpListItem> destinations READ destinations) - Q_PROPERTY(QString title READ title WRITE setTitle) - Q_CLASSINFO("DefaultProperty", "destinations") + Q_PROPERTY(QQuickJumpListCategory *recent READ recent CONSTANT) + Q_PROPERTY(QQuickJumpListCategory *frequent READ frequent CONSTANT) + Q_PROPERTY(QQuickJumpListCategory *tasks READ tasks WRITE setTasks NOTIFY tasksChanged) + Q_PROPERTY(QQmlListProperty<QQuickJumpListCategory> categories READ categories NOTIFY categoriesChanged) + Q_PROPERTY(QQmlListProperty<QObject> data READ data) + Q_CLASSINFO("DefaultProperty", "data") + Q_INTERFACES(QQmlParserStatus) public: - explicit QQuickJumpListCategory(QObject *parent = 0); - ~QQuickJumpListCategory(); - QQmlListProperty<QQuickJumpListItem> destinations(); - void setTitle(const QString &title); - QString title() const; + explicit QQuickJumpList(QObject *parent = 0); + ~QQuickJumpList(); - QList<QWinJumpListItem *> toItemList() const; + QQuickJumpListCategory *recent() const; + QQuickJumpListCategory *frequent() const; - static void addItem(QQmlListProperty<QQuickJumpListItem> *property, QQuickJumpListItem *value); + QQuickJumpListCategory *tasks() const; + void setTasks(QQuickJumpListCategory *tasks); -private: - QString m_groupTitle; - QList<QQuickJumpListItem *> m_destinations; -}; + QQmlListProperty<QObject> data(); + QQmlListProperty<QQuickJumpListCategory> categories(); -class QQuickJumpList : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty<QQuickJumpListItem> tasks READ tasks) - Q_PROPERTY(QQmlListProperty<QQuickJumpListCategory> destinations READ destinations) - Q_PROPERTY(bool showFrequentCategory READ showFrequentCategory WRITE setShowFrequentCategory) - Q_PROPERTY(bool showRecentCategory READ showRecentCategory WRITE setShowRecentCategory) - -public: - explicit QQuickJumpList(QQuickItem *parent = 0); - QQmlListProperty<QQuickJumpListItem> tasks(); - QQmlListProperty<QQuickJumpListCategory> destinations(); - bool showFrequentCategory() const; - void setShowFrequentCategory(bool); - bool showRecentCategory() const; - void setShowRecentCategory(bool); + void classBegin(); + void componentComplete(); - virtual void componentComplete(); +Q_SIGNALS: + void tasksChanged(); + void categoriesChanged(); - static void appendTaskItem(QQmlListProperty<QQuickJumpListItem> *property, QQuickJumpListItem *value); - static void appendGroup(QQmlListProperty<QQuickJumpListCategory> *property, QQuickJumpListCategory *value); +private Q_SLOTS: + void rebuild(); private: - QList<QQuickJumpListItem *> taskList; - QList<QQuickJumpListCategory *> categoryList; - bool frequentCategoryShown; - bool recentCategoryShown; + static void data_append(QQmlListProperty<QObject> *property, QObject *object); + static int categories_count(QQmlListProperty<QQuickJumpListCategory> *property); + static QQuickJumpListCategory *categories_at(QQmlListProperty<QQuickJumpListCategory> *property, int index); + + QQuickJumpListCategory *m_recent; + QQuickJumpListCategory *m_frequent; + QQuickJumpListCategory *m_tasks; + QList<QQuickJumpListCategory *> m_categories; }; QT_END_NAMESPACE diff --git a/src/imports/winextras/qquickjumplistcategory.cpp b/src/imports/winextras/qquickjumplistcategory.cpp new file mode 100644 index 0000000..4a3e214 --- /dev/null +++ b/src/imports/winextras/qquickjumplistcategory.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** + ** + ** Copyright (C) 2013 Ivan Vizir <define-true-false@yandex.com> + ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + ** Contact: http://www.qt-project.org/legal + ** + ** This file is part of the QtWinExtras 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 "qquickjumplistcategory_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype JumpListCategory + \instantiates QQuickJumpListCategory + \inqmlmodule QtWinExtras + + \brief Represents a jump list category. + + \since QtWinExtras 1.0 + + The JumpListCategory type represents a category that consists of several + Jump List destinations and has a title. + */ + +/*! + \class QQuickJumpListCategory + \internal + */ + +QQuickJumpListCategory::QQuickJumpListCategory(QObject *parent) : + QObject(parent), m_visible(true) +{ +} + +QQuickJumpListCategory::~QQuickJumpListCategory() +{ +} + +/*! + \qmlproperty list<QtObject> JumpListCategory::data + \internal + */ +QQmlListProperty<QObject> QQuickJumpListCategory::data() +{ + return QQmlListProperty<QObject>(this, this, &QQuickJumpListCategory::data_append, 0, 0, 0); +} + +/*! + \qmlproperty list<JumpListItem> JumpListCategory::items + + A list of items. + */ +QQmlListProperty<QQuickJumpListItem> QQuickJumpListCategory::items() +{ + return QQmlListProperty<QQuickJumpListItem>(this, this, &QQuickJumpListCategory::items_count, &QQuickJumpListCategory::items_at); +} + +/*! + \qmlproperty string JumpListCategory::title + + The title of the category. + */ +QString QQuickJumpListCategory::title() const +{ + return m_title; +} + +void QQuickJumpListCategory::setTitle(const QString &title) +{ + if (m_title != title) { + m_title = title; + emit titleChanged(); + } +} + +/*! + \qmlproperty bool JumpListCategory::visible + + The visibility of the category. + */ +bool QQuickJumpListCategory::isVisible() const +{ + return m_visible; +} + +void QQuickJumpListCategory::setVisible(bool visible) +{ + if (m_visible != visible) { + m_visible = visible; + emit visibilityChanged(); + } +} + +QList<QWinJumpListItem *> QQuickJumpListCategory::toItemList() const +{ + QList<QWinJumpListItem *> items; + foreach (QQuickJumpListItem *item, m_items) + items.append(item->toJumpListItem()); + return items; +} + +void QQuickJumpListCategory::data_append(QQmlListProperty<QObject> *property, QObject *object) +{ + if (QQuickJumpListItem *item = qobject_cast<QQuickJumpListItem *>(object)) { + QQuickJumpListCategory *category = static_cast<QQuickJumpListCategory *>(property->object); + category->m_items.append(item); + emit category->itemsChanged(); + } +} + +int QQuickJumpListCategory::items_count(QQmlListProperty<QQuickJumpListItem> *property) +{ + return static_cast<QQuickJumpListCategory *>(property->object)->m_items.count(); +} + +QQuickJumpListItem *QQuickJumpListCategory::items_at(QQmlListProperty<QQuickJumpListItem> *property, int index) +{ + return static_cast<QQuickJumpListCategory *>(property->object)->m_items.value(index); +} + +QT_END_NAMESPACE diff --git a/src/imports/winextras/qquickjumplistcategory_p.h b/src/imports/winextras/qquickjumplistcategory_p.h new file mode 100644 index 0000000..b16ab4c --- /dev/null +++ b/src/imports/winextras/qquickjumplistcategory_p.h @@ -0,0 +1,96 @@ +/**************************************************************************** + ** + ** Copyright (C) 2013 Ivan Vizir <define-true-false@yandex.com> + ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + ** Contact: http://www.qt-project.org/legal + ** + ** This file is part of the QtWinExtras 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 QQUICKJUMPLISTCATEGORY_P_H +#define QQUICKJUMPLISTCATEGORY_P_H + +#include "qquickjumplistitem_p.h" + +#include <QObject> +#include <QQmlListProperty> +#include <QWinJumpListCategory> +#include <QWinJumpListItem> + +QT_BEGIN_NAMESPACE + +class QQuickJumpListCategory : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<QObject> data READ data) + Q_PROPERTY(QQmlListProperty<QQuickJumpListItem> items READ items) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibilityChanged) + Q_CLASSINFO("DefaultProperty", "data") + +public: + explicit QQuickJumpListCategory(QObject *parent = 0); + ~QQuickJumpListCategory(); + + QString title() const; + void setTitle(const QString &title); + + bool isVisible() const; + void setVisible(bool visible); + + QQmlListProperty<QObject> data(); + QQmlListProperty<QQuickJumpListItem> items(); + + QList<QWinJumpListItem *> toItemList() const; + +Q_SIGNALS: + void itemsChanged(); + void titleChanged(); + void visibilityChanged(); + +private: + static void data_append(QQmlListProperty<QObject> *property, QObject *object); + static int items_count(QQmlListProperty<QQuickJumpListItem> *property); + static QQuickJumpListItem *items_at(QQmlListProperty<QQuickJumpListItem> *property, int index); + + bool m_visible; + QString m_title; + QList<QQuickJumpListItem *> m_items; +}; + +QT_END_NAMESPACE + +#endif // QQUICKJUMPLISTCATEGORY_P_H diff --git a/src/imports/winextras/qquickjumplistitem.cpp b/src/imports/winextras/qquickjumplistitem.cpp new file mode 100644 index 0000000..75bd485 --- /dev/null +++ b/src/imports/winextras/qquickjumplistitem.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** + ** + ** Copyright (C) 2013 Ivan Vizir <define-true-false@yandex.com> + ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + ** Contact: http://www.qt-project.org/legal + ** + ** This file is part of the QtWinExtras 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 "qquickjumplistitem_p.h" +#include <QVariant> + +QT_BEGIN_NAMESPACE + +QQuickJumpListItem::QQuickJumpListItem(QObject *parent) : + QObject(parent) +{ +} + +QQuickJumpListItem::~QQuickJumpListItem() +{ +} + +int QQuickJumpListItem::type() const +{ + return m_type; +} + +void QQuickJumpListItem::setType(int type) +{ + m_type = type; +} + +QWinJumpListItem *QQuickJumpListItem::toJumpListItem() const +{ + QWinJumpListItem *item = new QWinJumpListItem(QWinJumpListItem::Separator); + switch (m_type) { + case ItemTypeDestination: + item->setType(QWinJumpListItem::Destination); + item->setFilePath(property("filePath").toString()); + break; + case ItemTypeLink: + item->setType(QWinJumpListItem::Link); + item->setFilePath(property("executablePath").toString()); + item->setArguments(QStringList(property("arguments").toStringList())); + item->setDescription(property("description").toString()); + item->setTitle(property("title").toString()); + item->setIcon(QIcon(property("iconPath").toString())); + break; + } + + return item; +} + +QT_END_NAMESPACE diff --git a/src/imports/winextras/qquickjumplistitem_p.h b/src/imports/winextras/qquickjumplistitem_p.h new file mode 100644 index 0000000..74a0c75 --- /dev/null +++ b/src/imports/winextras/qquickjumplistitem_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** + ** + ** Copyright (C) 2013 Ivan Vizir <define-true-false@yandex.com> + ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + ** Contact: http://www.qt-project.org/legal + ** + ** This file is part of the QtWinExtras 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 QQUICKJUMPLISTITEM_P_H +#define QQUICKJUMPLISTITEM_P_H + +#include <QObject> +#include <QWinJumpListItem> + +QT_BEGIN_NAMESPACE + +class QQuickJumpListItem : public QObject +{ + Q_OBJECT + Q_PROPERTY(int __jumpListItemType READ type WRITE setType) + Q_ENUMS(JumpListItemType) + +public: + enum JumpListItemType { + ItemTypeLink = 1, + ItemTypeDestination = 2, + ItemTypeSeparator = 3 + }; + + explicit QQuickJumpListItem(QObject *p = 0); + ~QQuickJumpListItem(); + + int type() const; + void setType(int type); + + QWinJumpListItem *toJumpListItem() const; + +private: + int m_type; // 1 - link, 2 - destination +}; + +QT_END_NAMESPACE + +#endif // QQUICKJUMPLISTITEM_P_H diff --git a/src/imports/winextras/winextras.pro b/src/imports/winextras/winextras.pro index 2083241..0f574f4 100644 --- a/src/imports/winextras/winextras.pro +++ b/src/imports/winextras/winextras.pro @@ -15,6 +15,8 @@ HEADERS += \ qquickdwmfeatures_p_p.h \ qquicktaskbarbutton_p.h \ qquickjumplist_p.h \ + qquickjumplistitem_p.h \ + qquickjumplistcategory_p.h \ qquickthumbnailtoolbar_p.h \ qquickthumbnailtoolbutton_p.h \ qquickiconloader_p.h @@ -24,6 +26,8 @@ SOURCES += \ qquickdwmfeatures.cpp \ qquicktaskbarbutton.cpp \ qquickjumplist.cpp \ + qquickjumplistitem.cpp \ + qquickjumplistcategory.cpp \ qquickthumbnailtoolbar.cpp \ qquickthumbnailtoolbutton.cpp \ qquickiconloader.cpp |