Skip to content

Instantly share code, notes, and snippets.

@walokra
Created January 18, 2014 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walokra/8490494 to your computer and use it in GitHub Desktop.
Save walokra/8490494 to your computer and use it in GitHub Desktop.
Showing notification message to user in SailfishOS app.
Rectangle {
id: infoBanner;
y: Theme.paddingSmall;
z: 1;
width: parent.width;
height: infoLabel.height + 2 * Theme.paddingMedium;
color: Theme.highlightBackgroundColor;
opacity: 0;
Label {
id: infoLabel;
text : ''
font.pixelSize: Theme.fontSizeExtraSmall;
width: parent.width - 2 * Theme.paddingSmall
anchors.top: parent.top;
anchors.topMargin: Theme.paddingMedium;
y: Theme.paddingSmall;
horizontalAlignment: Text.AlignHCenter;
wrapMode: Text.WrapAnywhere;
MouseArea {
anchors.fill: parent;
onClicked: {
infoBanner.opacity = 0.0;
}
}
}
function showText(text) {
infoLabel.text = text;
opacity = 0.9;
console.log("infoBanner: " + text);
closeTimer.restart();
}
function showError(text) {
infoLabel.text = text;
opacity = 0.9;
console.log("infoBanner: " + text);
}
function showHttpError(errorCode, errorMessage) {
switch (errorCode) {
case 0:
showError(qsTr("Server or connection error"));
break;
default:
showError(qsTr("Error: %1").arg(errorMessage + " (" + errorCode + ")"));
}
}
Behavior on opacity { FadeAnimation {} }
Timer {
id: closeTimer;
interval: 3000;
onTriggered: infoBanner.opacity = 0.0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment