summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2015-09-30 16:09:50 (GMT)
committerAleix Pol <aleixpol@kde.org>2015-09-30 16:09:50 (GMT)
commit9396cc5f12fcae8264d944492981f81629e3019c (patch)
tree61f0ac68f991948c7b7c76bdc121e413a5063db5
parente74af40d6de0e023ee66c3d66c984a1a5b0f6992 (diff)
Stop using QAction from QML
Use QtQuick Controls Action
-rw-r--r--discover/CMakeLists.txt1
-rw-r--r--discover/DiscoverAction.cpp63
-rw-r--r--discover/DiscoverAction.h49
-rw-r--r--discover/MuonDiscoverMainWindow.cpp2
-rw-r--r--discover/qml/Main.qml2
-rw-r--r--discover/qml/TopLevelPageData.qml5
6 files changed, 3 insertions, 119 deletions
diff --git a/discover/CMakeLists.txt b/discover/CMakeLists.txt
index b836507..4daa17a 100644
--- a/discover/CMakeLists.txt
+++ b/discover/CMakeLists.txt
@@ -7,7 +7,6 @@ set(muon_discover_SRCS
main.cpp
MuonDiscoverMainWindow.cpp
- DiscoverAction.cpp
PaginateModel.cpp
SystemFonts.cpp
)
diff --git a/discover/DiscoverAction.cpp b/discover/DiscoverAction.cpp
deleted file mode 100644
index 2763adf..0000000
--- a/discover/DiscoverAction.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2013 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library/Lesser General Public License
- * version 2, or (at your option) any later version, as published by the
- * Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
- *
- * You should have received a copy of the GNU Library/Lesser General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "DiscoverAction.h"
-#include <KXmlGuiWindow>
-#include <KActionCollection>
-#include <QDebug>
-#include <QIcon>
-
-DiscoverAction::DiscoverAction(QObject* parent)
- : QAction(parent)
-{
- connect(this, &QAction::changed, this, &DiscoverAction::proxyChanged);
-}
-
-void DiscoverAction::setIconName(const QString& name)
-{
- setIcon(QIcon::fromTheme(name));
-}
-
-QString DiscoverAction::iconName() const
-{
- return icon().name();
-}
-
-KXmlGuiWindow* DiscoverAction::mainWindow() const
-{
- return qobject_cast<KXmlGuiWindow*>(QAction::parentWidget());
-}
-
-void DiscoverAction::setMainWindow(KXmlGuiWindow* w)
-{
- w->actionCollection()->addAction(objectName(), this);
- w->actionCollection()->setDefaultShortcuts(this, shortcuts());
-}
-
-void DiscoverAction::setShortcutString(const QString& str)
-{
- setShortcut(str);
- if (mainWindow())
- mainWindow()->actionCollection()->setDefaultShortcut(this, str);
-}
-
-QString DiscoverAction::stringShortcut() const
-{
- return QAction::shortcut().toString();
-}
diff --git a/discover/DiscoverAction.h b/discover/DiscoverAction.h
deleted file mode 100644
index 96779df..0000000
--- a/discover/DiscoverAction.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2013 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library/Lesser General Public License
- * version 2, or (at your option) any later version, as published by the
- * Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
- *
- * You should have received a copy of the GNU Library/Lesser General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef DISCOVERACTION_H
-#define DISCOVERACTION_H
-
-#include <QAction>
-
-class KXmlGuiWindow;
-class DiscoverAction : public QAction
-{
- Q_OBJECT
- Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY proxyChanged)
- Q_PROPERTY(KXmlGuiWindow* mainWindow READ mainWindow WRITE setMainWindow NOTIFY proxyChanged)
- Q_PROPERTY(QAction::Priority priority READ priority WRITE setPriority NOTIFY proxyChanged)
- Q_PROPERTY(QString shortcut READ stringShortcut WRITE setShortcutString NOTIFY proxyChanged)
- public:
- explicit DiscoverAction(QObject* parent = nullptr);
-
- QString iconName() const;
- void setIconName(const QString& name);
-
- KXmlGuiWindow* mainWindow() const;
- void setMainWindow(KXmlGuiWindow* w);
-
- QString stringShortcut() const;
- void setShortcutString(const QString& name);
-
- Q_SIGNALS:
- void proxyChanged();
-};
-
-#endif // DISCOVERACTION_H
diff --git a/discover/MuonDiscoverMainWindow.cpp b/discover/MuonDiscoverMainWindow.cpp
index 41df824..fbfcf58 100644
--- a/discover/MuonDiscoverMainWindow.cpp
+++ b/discover/MuonDiscoverMainWindow.cpp
@@ -18,7 +18,6 @@
*/
#include "MuonDiscoverMainWindow.h"
-#include "DiscoverAction.h"
#include "PaginateModel.h"
#include "SystemFonts.h"
@@ -78,7 +77,6 @@ MuonDiscoverMainWindow::MuonDiscoverMainWindow()
kdeclarative.setupBindings();
qmlRegisterType<PaginateModel>("org.kde.muon.discover", 1, 0, "PaginateModel");
- qmlRegisterType<DiscoverAction>("org.kde.muon.discover", 1, 0, "DiscoverAction");
qmlRegisterSingletonType<SystemFonts>("org.kde.muon.discover", 1, 0, "SystemFonts", ([](QQmlEngine*, QJSEngine*) -> QObject* { return new SystemFonts; }));
qmlRegisterType<KXmlGuiWindow>();
qmlRegisterType<QActionGroup>();
diff --git a/discover/qml/Main.qml b/discover/qml/Main.qml
index b8ce0e3..0f492c3 100644
--- a/discover/qml/Main.qml
+++ b/discover/qml/Main.qml
@@ -90,7 +90,7 @@ Rectangle
stackView.replace(page, {}, window.status!=Component.Ready)
}
- property list<DiscoverAction> awesome: [
+ property list<Action> awesome: [
TopLevelPageData {
iconName: "tools-wizard"
text: i18n("Discover")
diff --git a/discover/qml/TopLevelPageData.qml b/discover/qml/TopLevelPageData.qml
index e0f698c..61b61ea 100644
--- a/discover/qml/TopLevelPageData.qml
+++ b/discover/qml/TopLevelPageData.qml
@@ -18,13 +18,12 @@
*/
import QtQuick 2.1
-import org.kde.muon.discover 1.0
+import QtQuick.Controls 1.2
import "navigation.js" as Navigation
-DiscoverAction {
+Action {
property string overlay
property Component component
- mainWindow: app
checkable: true
checked: window.currentTopLevel==component
enabled: window.navigationEnabled