From acefb965202f0b5f7c841b0b98628d52334ce9b1 Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Sat, 21 Apr 2018 21:25:52 +0200 Subject: Added 'Windows.js' for dialogs/windows --- js/Windows.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 js/Windows.js (limited to 'js') diff --git a/js/Windows.js b/js/Windows.js new file mode 100644 index 00000000..be2f503e --- /dev/null +++ b/js/Windows.js @@ -0,0 +1,34 @@ +var flagsCustomDecorations = (Qt.FramelessWindowHint | Qt.WindowSystemMenuHint | Qt.Window | Qt.WindowMinimizeButtonHint); +var flags = (Qt.WindowSystemMenuHint | Qt.Window | Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint | Qt.WindowTitleHint | Qt.WindowMaximizeButtonHint); + +/** + * Toggles window decorations + * @param {bool} custom - toggle decorations + */ +function setCustomWindowDecorations(custom) { + // save x,y positions, because we need to hide/show the window + var x = appWindow.x + var y = appWindow.y + if (x < 0) x = 0 + if (y < 0) y = 0 + + // Update persistentSettings + persistentSettings.customDecorations = custom; + + titleBar.visible = custom; + daemonConsolePopup.titleBar.visible = custom; + + if (custom) { + appWindow.flags = flagsCustomDecorations; + daemonConsolePopup.flags = flagsCustomDecorations; + } else { + appWindow.flags = flags; + daemonConsolePopup.flags = flags; + } + + // Reset window + appWindow.hide() + appWindow.x = x + appWindow.y = y + appWindow.show() +} -- cgit v1.2.3 From 75ccc7a31b0ab3b969da9a599e8244a8119aa74d Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Sat, 21 Apr 2018 22:22:13 +0200 Subject: Added Utils.js, for miscellaneous Javascript functions --- js/Utils.js | 25 +++++++++++++++++++++++++ qml.qrc | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 js/Utils.js (limited to 'js') diff --git a/js/Utils.js b/js/Utils.js new file mode 100644 index 00000000..7cf582b2 --- /dev/null +++ b/js/Utils.js @@ -0,0 +1,25 @@ +/** + * Formats a date. + * @param {date} date - toggle decorations + * @param {params} params - + */ +function formatDate( date, params ) { + var options = { + weekday: "short", + year: "numeric", + month: "long", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + timeZone: "UTC", + timeZoneName: "short", + }; + + options = [options, params].reduce(function (r, o) { + Object.keys(o).forEach(function (k) { r[k] = o[k]; }); + return r; + }, {}); + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString + return new Date( date ).toLocaleString( 'en-US', options ); +} diff --git a/qml.qrc b/qml.qrc index 42b868e6..4e605d89 100644 --- a/qml.qrc +++ b/qml.qrc @@ -206,5 +206,7 @@ images/warning.png images/checkedBlackIcon.png images/rightArrowInactive.png + js/Windows.js + js/Utils.js -- cgit v1.2.3