Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorg. to facilitate building on newer SDK #6

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 193 additions & 0 deletions SailfishOS/qml/elements/CalcScreen.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
import QtQuick 2.5
import Sailfish.Silica 1.0
//import QtQuick.Controls 2.13
import "../elements"

Item{
id: calcScreen

property alias contentHeight: listView.contentHeight
property alias model: listView.model

property alias view: listView

property color fontColor: "black"
property color glassItemColor: "lightblue"
property int fontSize: 12
property string fontFamily: "helvetica"

property string dropIconPath: ""
property color dropIconColor: "white"

property Component horizontalScrollDecorator: Item{}
property int horizontalScrollPadding: 10

property Component verticalScrollDecorator: Item{}
property int verticalScrollPadding: 10

property int scrollIndicatorHeight: 3

CustomGlassItem {
id: divider

anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter

objectName: "menuitem"

height: scrollIndicatorHeight
width: parent.width

color: glassItemColor
opacity : (listView.height >= listView.contentHeight) || listView.atYBeginning ? 0.0 : 1.0

Behavior on opacity { NumberAnimation {duration: 500} }

//cache: false
}

ListView {
id: listView

anchors.fill: parent

snapMode: ListView.NoSnap

//ScrollIndicator.vertical: ScrollIndicator { }
Loader{
sourceComponent: verticalScrollDecorator
}

property Item contextMenu

delegate: Item {
id: myListItem
property bool menuOpen: view.contextMenu != null && view.contextMenu.parent === myListItem

width: view.width
height: menuOpen ? view.contextMenu.height + stackFlick.height : stackFlick.height

StackFlick {
id: stackFlick

stack: currentStack

width: view.width

fontColor: calcScreen.fontColor
fontSize: calcScreen.fontSize
fontFamily: calcScreen.fontFamily

dropIcon: calcScreen.dropIconPath
dropIconColor: calcScreen.dropIconColor

elementScrollDecorator: horizontalScrollDecorator

onPressAndHold: {
if (!view.contextMenu)
view.contextMenu = contextMenuComponent.createObject(view);

view.contextMenu.showOptionsForItem(myListItem, stackFlick);
}
}
}


Component {
id: contextMenuComponent

ContextMenu {
id: menu

property Item currentItem
property int toDrop: -1
property int toPick: -1
onClosed: {
if(toDrop != -1){
stackDropUIIndex(toDrop);
toDrop = -1;
}

if(toPick != -1){
stackPickUIIndex(toPick);
toPick = -1;
}
}

function showOptionsForItem(showItem, item){
menu.currentItem = item;
menu.show(showItem);
}

Row {
width: parent ? parent.width : Screen.width
height: calcScreen.fontSize
CustomBackgroundItem {
width: parent.width / 3
height: Theme.itemSizeSmall
Label{
text: "Pick"
anchors.centerIn: parent
}
onClicked: {
if(menu.currentItem){
menu.toPick = menu.currentItem.invertedIndex; // do not drop immediately, wait after menu is closed.
}

menu.hide();
}
}
CustomBackgroundItem {
width: parent.width / 3
height: Theme.itemSizeSmall
Label{
text: "Drop"
anchors.centerIn: parent
}
onClicked: {
if(menu.currentItem){
menu.toDrop = menu.currentItem.invertedIndex; // do not drop immediately, wait after menu is closed.
}

menu.hide();
}
}
CustomBackgroundItem {
width: parent.width / 3
height: Theme.itemSizeSmall
Label{
text: "Copy"
anchors.centerIn: parent
}
onClicked: {
copyToClipboard(menu.currentItem.text);
menu.hide();
popup.notify("Copied to clipboard !");
}
}
}
}
}
}


CustomGlassItem {
id: divider2

anchors.bottom: listView.bottom
anchors.horizontalCenter: parent.horizontalCenter

objectName: "menuitem"

height: scrollIndicatorHeight
width: parent.width

color: calcScreen.glassItemColor
opacity: listView.atYEnd ? 0.0 : 1.0

Behavior on opacity { NumberAnimation {duration: 500} }

//cache: false
}

}
25 changes: 25 additions & 0 deletions SailfishOS/qml/elements/CustomBackgroundItem.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import QtQuick 2.0
import Sailfish.Silica 1.0

MouseArea {
property bool highlighted: false
property color color: "black"
property real highlightedOpacity: 0.3

Rectangle {
anchors.fill: parent

color: parent.color

opacity: highlighted ? highlightedOpacity : 0.0
}

onPressed: {
highlighted = true;
}

onReleased: {
highlighted = false;
}

}
6 changes: 6 additions & 0 deletions SailfishOS/qml/elements/CustomGlassItem.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import QtQuick 2.0
import Sailfish.Silica 1.0

Rectangle {

}
94 changes: 94 additions & 0 deletions SailfishOS/qml/elements/KeyboardButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import QtQuick 2.0
import Sailfish.Silica 1.0

MouseArea {
id: buttonRect

width: buttonWidth
height: buttonHeigth

property string rectColor: "transparent"
property color rectBorderColor: "white"
property int rectBorderWidth: 1
property real rectOpacity: 1

property int fontSize: mainLabel.font.pixelSize
property int secondaryFontSize: fontSize / 2
property color fontColor: "black"
property color fontColorLeftOption: "orange"
property color fontColorRightOption: "lightblue"

property string text;
property variant actions: [{text: ' ', visual:'', engine:'', type:'', enabled: false},
{text: ' ', visual:'', engine:'', type:'', enabled: false},
{text: ' ', visual:'', engine:'', type:'', enabled: false}];

property int mode: 0
property real disabledOpacity: 0.1
enabled: actions[mode].enabled
opacity: enabled ? 1: disabledOpacity

Behavior on opacity { NumberAnimation { duration: 500 } }

Label{
id: orangeLabel

anchors.top: parent.top
anchors.left: parent.left
width: parent.width / 2
height: secondaryFontSize.height

horizontalAlignment: Text.AlignLeft
font.pixelSize: secondaryFontSize - 2

color: buttonRect.fontColorLeftOption
text: actions[1].text
}

Label{
id: blueLabel

anchors.top: parent.top
anchors.right: parent.right
width: parent.width / 2
height: secondaryFontSize.height

horizontalAlignment: Text.AlignRight
font.pixelSize: secondaryFontSize - 2

color: buttonRect.fontColorRightOption
text: actions[2].text
}

Rectangle {
//anchors.fill: parent
id: rect
width: parent.width
height: parent.height - blueLabel.paintedHeight
anchors.bottom: parent.bottom
color: parent.rectColor
border.width: rectBorderWidth
border.color: rectBorderColor
radius: 10
opacity: parent.rectOpacity
}

Label{
id: mainLabel
//anchors.fill: parent
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: rect.verticalCenter
text: actions[0].text

font.pixelSize: fontSize
color: buttonRect.fontColor
}

/*
onClicked: {
if(settings.vibration()){
vibration.start();
}
}
*/
}
7 changes: 7 additions & 0 deletions SailfishOS/qml/elements/Memory.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import QtQuick 2.0

ListModel {
id: memory

property var stack
}
Loading