Skip to content

Commit

Permalink
Initial restructure to add menu for classic theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Iktwo committed Sep 28, 2016
1 parent 5c62de6 commit fabd9d3
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ Item {

verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight

font {
pointSize: 22
}
//transform: Rotation { origin.x: 0; origin.y: textElement.height / 2; axis { x: 0; y: 1; z: 0 } angle: mouseArea.pressed ? 0 : 45 }

transform: Rotation { origin.x: 0; origin.y: textElement.height / 2; axis { x: 0; y: 1; z: 0 } angle: mouseArea.pressed ? -10 : 0 }

scale: mouseArea.pressed ? 0.98 : 1
color: root.enabled ? "black" : "#8d8d8d"
}
Expand All @@ -41,7 +44,12 @@ Item {

onClicked: {
root.clicked()
root.parent.close()

try {
root.parent.close()
} catch (e) {
console.log("MenuItem is meant to be used inside a PressAndHoldMenu")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ Item {
property int expandedHeight: 300
property int menuXPosition: width / 2
property int menuYPosition: height / 2
property int screenHeight

default property alias content: container.children

function open(yPosition, xPosition) {
signal closed
signal canceled

function open(xPosition, yPosition) {
/// TODO: add some y offset so it's not oppened under the finger
if (yPosition === undefined) {
yPosition = screenHeight / 2
}

if (xPosition === undefined) {
xPosition = 0
}

if (xPosition < width * 0.15)
menuXPosition = width * 0.15
Expand All @@ -32,6 +44,11 @@ Item {
background.state = "closed"
}

function cancel() {
background.state = "closed"
root.canceled()
}

anchors.fill: parent

Rectangle {
Expand All @@ -45,7 +62,7 @@ Item {

enabled: background.state != "closed"

onClicked: root.close()
onClicked: root.cancel()
}

Rectangle {
Expand Down
2 changes: 2 additions & 0 deletions src/qml/components/qmldir
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MenuItem 1.0 MenuItem.qml
PressAndHoldMenu 1.0 PressAndHoldMenu.qml
2 changes: 1 addition & 1 deletion src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ApplicationWindow {
id: loaderMainTheme

anchors.fill: parent
source: "themes/tiles/ThemeMain.qml"
source: "themes/classic/ThemeMain.qml"
}

Loader {
Expand Down
7 changes: 5 additions & 2 deletions src/qml/themes/classic/ApplicationGrid.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ScrollView {

property alias model: gridView.model

signal pressAndHold(var model)
signal pressAndHold(var model, int x, int y)

anchors.fill: parent

Expand All @@ -35,6 +35,9 @@ ScrollView {
incrementControl: Item { }
}

flickableItem.focus: true
flickableItem.interactive: true

GridView {
id: gridView

Expand Down Expand Up @@ -73,7 +76,7 @@ ScrollView {
text: model.name

onClicked: QL.PackageManager.launchApplication(model.packageName)
onPressAndHold: root.pressAndHold(model)
onPressAndHold: root.pressAndHold(model, x, y)
}

onHeightChanged: {
Expand Down
25 changes: 25 additions & 0 deletions src/qml/themes/classic/ApplicationGridMenu.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import QtQuick 2.2
import com.iktwo.qutelauncher 1.0 as QL
import components 1.0 as C

C.PressAndHoldMenu {
property string packageName
property string name

expandedHeight: menuItem.height * 2

C.MenuItem {
id: menuItem
text: qsTr("Info")
onClicked: QL.PackageManager.openApplicationInfo(packageName)
}

C.MenuItem {
/// TODO: consume the click even if not enabled
/// TODO: verify this
// enabled: QL.PackageManager.packages.indexOf(packageName) === -1
text: qsTr("Add to grid")

onClicked: QL.PackageManager.addApplicationToGrid(name, packageName)
}
}
8 changes: 6 additions & 2 deletions src/qml/themes/classic/ApplicationTile.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Item {
property var _originalParent
property var _newParent

signal pressAndHold(var model)
signal pressAndHold(var model, int x, int y)
signal clicked

Drag.active: mouseArea.drag.active
Expand Down Expand Up @@ -76,7 +76,11 @@ Item {
drag.target: root.dragTarget

onClicked: root.clicked()
onPressAndHold: root.pressAndHold(model)

onPressAndHold: {
var mappedItem = mapToItem(loaderMainTheme, mouse.x, mouse.y)
root.pressAndHold(model, mappedItem.x, mappedItem.y)
}

onReleased: root._newParent = (root.Drag.target !== null ? root.Drag.target : root._originalParent)

Expand Down
14 changes: 12 additions & 2 deletions src/qml/themes/classic/ThemeMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ Item {
/// TODO: implement this
// applicationTile.source = "image://icon/" + model.packageName
// applicationTile.text = model.name

explandableItem.close()
applicationGridMenu.packageName = model.packageName
applicationGridMenu.name = model.name
applicationGridMenu.open(x, y)
}
}
}
Expand Down Expand Up @@ -97,4 +98,13 @@ Item {
onNewIntentReceived: explandableItem.close()
onMinimized: explandableItem.close()
}


ApplicationGridMenu {
id: applicationGridMenu

screenHeight: root.height

onClosed: explandableItem.close()
}
}
2 changes: 1 addition & 1 deletion src/qml/themes/tiles/ApplicationList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Item {
var mappedItem = mapToItem(root, mouse.x, mouse.y)
menu.packageName = model.packageName
menu.name = model.name
menu.open(mappedItem.y, mouse.x)
menu.open(mouse.x, mappedItem.y)
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/qml/themes/tiles/ApplicationMenu.qml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import QtQuick 2.2
import com.iktwo.qutelauncher 1.0 as QL
import components 1.0 as C

PressAndHoldMenu {
C.PressAndHoldMenu {
property string packageName
property string name

expandedHeight: menuItem.height * 2

MenuItem {
C.MenuItem {
id: menuItem
text: qsTr("Info")
onClicked: QL.PackageManager.openApplicationInfo(packageName)
}

MenuItem {
C.MenuItem {
/// TODO: consume the click even if not enabled
/// TODO: verify this
// enabled: QL.PackageManager.packages.indexOf(packageName) === -1
Expand Down
6 changes: 4 additions & 2 deletions src/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
<file>qml/themes/tiles/ApplicationList.qml</file>
<file>qml/themes/tiles/ApplicationMenu.qml</file>
<file>qml/themes/tiles/ColorPicker.qml</file>
<file>qml/themes/tiles/PressAndHoldMenu.qml</file>
<file>qml/themes/tiles/SectionNavigator.qml</file>
<file>qml/themes/tiles/MenuItem.qml</file>
<file>qml/themes/tiles/ApplicationSection.qml</file>
<file>qml/themes/tiles/Configuration.qml</file>
<file>qml/themes/tiles/qmldir</file>
<file>qml/components/PressAndHoldMenu.qml</file>
<file>qml/components/qmldir</file>
<file>qml/themes/classic/ApplicationGridMenu.qml</file>
<file>qml/components/MenuItem.qml</file>
</qresource>
<qresource prefix="/images">
<file alias="test">resources/images/test.png</file>
Expand Down
2 changes: 1 addition & 1 deletion src/src/packagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void PackageManager::retrievePackages()
++i;
}

qDebug() << "mApplications:" << mApplications;
// qDebug() << "mApplications:" << mApplications;

endResetModel();
emit sectionsChanged();
Expand Down

0 comments on commit fabd9d3

Please sign in to comment.