diff options
| author | Aleix Pol <aleixpol@kde.org> | 2015-10-20 16:49:56 (GMT) |
|---|---|---|
| committer | Aleix Pol <aleixpol@kde.org> | 2015-10-20 16:49:56 (GMT) |
| commit | c2e77340b6a9777203d1cc806568103479cde2f3 (patch) | |
| tree | 1550d1e4758309a8b90f61e6ae7563ea7b8ba7a6 | |
| parent | dd4367b3dda722b9e50a8d329b1b4e84dfdb771d (diff) | |
Refactor CategoryDisplay
| -rw-r--r-- | discover/qml/CategoryDelegate.qml | 67 | ||||
| -rw-r--r-- | discover/qml/CategoryDisplay.qml | 34 | ||||
| -rw-r--r-- | discover/qml/CategoryPage.qml | 51 | ||||
| -rw-r--r-- | discover/qml/CategoryView.qml | 97 | ||||
| -rw-r--r-- | discover/resources.qrc | 3 |
5 files changed, 102 insertions, 150 deletions
diff --git a/discover/qml/CategoryDelegate.qml b/discover/qml/CategoryDelegate.qml deleted file mode 100644 index 1b31aab..0000000 --- a/discover/qml/CategoryDelegate.qml +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -import QtQuick 2.1 -import QtQuick.Controls 1.1 -import QtQuick.Layouts 1.1 -import org.kde.muon 1.0 -import org.kde.kquickcontrolsaddons 2.0 -import "navigation.js" as Navigation - -MouseArea { - id: categoryItem - property bool horizontal: false - enabled: true - - GridLayout { - id: layout - rows: categoryItem.horizontal ? 1 : 2 - columns: categoryItem.horizontal ? 2 : 1 - - anchors.top: parent.top - width: parent.width - columnSpacing: 10 - rowSpacing: 5 - Item { - Layout.fillWidth: !categoryItem.horizontal - Layout.fillHeight: categoryItem.horizontal - Layout.preferredWidth: categoryItem.horizontal ? nameLabel.paintedHeight*2 : 32 - Layout.preferredHeight: Layout.preferredWidth - - QIconItem { - icon: decoration - width: 32 - height: width - anchors.centerIn: parent - } - } - Label { - id: nameLabel - text: display - Layout.fillWidth: true - horizontalAlignment: !categoryItem.horizontal ? Text.AlignHCenter : Text.AlignLeft - verticalAlignment: Text.AlignVCenter - wrapMode: Text.WordWrap - - renderType: Text.QtRendering - maximumLineCount: 2 - } - } - onClicked: Navigation.openCategory(category) -} diff --git a/discover/qml/CategoryDisplay.qml b/discover/qml/CategoryDisplay.qml index eebafd4..aa679a1 100644 --- a/discover/qml/CategoryDisplay.qml +++ b/discover/qml/CategoryDisplay.qml @@ -26,8 +26,8 @@ import org.kde.kquickcontrolsaddons 2.0 RowLayout { id: page - property alias category: categoryModel.displayedCategory - readonly property bool extended: !app.isCompact && grid.count>5 + property alias category: view.category + readonly property bool extended: !app.isCompact && view.count>5 spacing: 3 @@ -84,36 +84,10 @@ RowLayout Layout.minimumHeight: paintedHeight*1.5 } - GridItem { + CategoryView { + id: view Layout.fillWidth: true Layout.fillHeight: true - hoverEnabled: false - - ScrollView { - anchors { - margins: -3 - fill: parent - } - - GridView { - id: grid - - cellWidth: app.isCompact ? width : width/Math.floor(width/100) - cellHeight: app.isCompact ? 35 : 60 - boundsBehavior: Flickable.StopAtBounds - - model: CategoryModel { - id: categoryModel - displayedCategory: null - } - - delegate: CategoryDelegate { - horizontal: app.isCompact - width: grid.cellWidth - height: grid.cellHeight-2 - } - } - } } } } diff --git a/discover/qml/CategoryPage.qml b/discover/qml/CategoryPage.qml deleted file mode 100644 index 65b9e4f..0000000 --- a/discover/qml/CategoryPage.qml +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -import QtQuick 2.1 -import QtQuick.Controls 1.1 -import QtQuick.Layouts 1.1 -import org.kde.muon 1.0 -import org.kde.kquickcontrolsaddons 2.0 -import "navigation.js" as Navigation - -Item { - id: page - property QtObject category - readonly property alias categories: categoryModel - readonly property var icon: category.icon - readonly property string title: category.name - - function searchFor(text) { - if(text == "") - return; - Navigation.openApplicationList(category.icon, i18n("Search in '%1'...", category.name), category, text) - } - - ApplicationList { - - } - - ColumnLayout { - CategoryDisplay { - category: page.category - height: 128 - } - CategoryDisplay {} - } -} diff --git a/discover/qml/CategoryView.qml b/discover/qml/CategoryView.qml new file mode 100644 index 0000000..f172697 --- /dev/null +++ b/discover/qml/CategoryView.qml @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2012 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. + */ + +import QtQuick 2.1 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 +import org.kde.muon 1.0 +import org.kde.kquickcontrolsaddons 2.0 +import "navigation.js" as Navigation + +GridItem +{ + property alias category: categoryModel.displayedCategory + readonly property alias count: grid.count + hoverEnabled: false + + ScrollView { + anchors { + margins: -3 + fill: parent + } + + GridView { + id: grid + + cellWidth: app.isCompact ? width : width/Math.floor(width/100) + cellHeight: app.isCompact ? 35 : 60 + boundsBehavior: Flickable.StopAtBounds + + model: CategoryModel { + id: categoryModel + displayedCategory: null + } + + delegate: MouseArea { + id: categoryItem + property bool horizontal: app.isCompact + enabled: true + + width: grid.cellWidth + height: grid.cellHeight-2 + + GridLayout { + id: layout + rows: categoryItem.horizontal ? 1 : 2 + columns: categoryItem.horizontal ? 2 : 1 + + anchors.top: parent.top + width: parent.width + columnSpacing: 10 + rowSpacing: 5 + Item { + Layout.fillWidth: !categoryItem.horizontal + Layout.fillHeight: categoryItem.horizontal + Layout.preferredWidth: categoryItem.horizontal ? nameLabel.paintedHeight*2 : 32 + Layout.preferredHeight: Layout.preferredWidth + + QIconItem { + icon: decoration + width: 32 + height: width + anchors.centerIn: parent + } + } + Label { + id: nameLabel + text: display + Layout.fillWidth: true + horizontalAlignment: !categoryItem.horizontal ? Text.AlignHCenter : Text.AlignLeft + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + + renderType: Text.QtRendering + maximumLineCount: 2 + } + } + onClicked: Navigation.openCategory(category) + } + } + } +} diff --git a/discover/resources.qrc b/discover/resources.qrc index a18bddc..41b3803 100644 --- a/discover/resources.qrc +++ b/discover/resources.qrc @@ -2,8 +2,7 @@ <qresource> <file>qml/Main.qml</file> <file>qml/TopLevelPageData.qml</file> - <file>qml/CategoryPage.qml</file> - <file>qml/CategoryDelegate.qml</file> + <file>qml/CategoryView.qml</file> <file>qml/CategoryDisplay.qml</file> <file>qml/ApplicationsTop.qml</file> <file>qml/FeaturedBanner.qml</file> |
