Add option to hide window on launch

This commit is contained in:
Steven Stallion 2017-10-23 12:02:33 -05:00
parent c76ef49265
commit 9814125fcf
No known key found for this signature in database
GPG Key ID: FE9050CED4B08B43
4 changed files with 28 additions and 1 deletions

1
.gitignore vendored
View File

@ -17,5 +17,6 @@ qrc_*.cpp
moc_*.cpp
moc_*.h
yubioath-desktop.app/
yubioath-desktop
pymodules
.vagrant/

View File

@ -94,6 +94,11 @@ int main(int argc, char *argv[])
// Set icon in the window, doesn't effect desktop icons.
qmlWindow->setIcon(QIcon(path_prefix + "/images/windowicon.png"));
// Show root window unless explicitly hidden in settings.
auto hideOnLaunch = qmlWindow->property("hideOnLaunch");
if (!hideOnLaunch.toBool()) {
qmlWindow->show();
}
QAction *showAction = new QAction(QObject::tr("&Show credentials"), qmlWindow);
// The call to hide doesn't make much sense but makes it work on macOS when hidden from the dock.

View File

@ -15,6 +15,7 @@ DefaultDialog {
property alias slot1digits: slot1digits.currentIndex
property alias slot2digits: slot2digits.currentIndex
property alias closeToTray: closeToTray.checked
property alias hideOnLaunch: hideOnLaunch.checked
ColumnLayout {
anchors.fill: parent
@ -97,6 +98,23 @@ DefaultDialog {
CheckBox {
id: closeToTray
checked: settings.closeToTray
onCheckedChanged: {
if (!checked) {
hideOnLaunch.checked = false
}
}
KeyNavigation.tab: saveSettingsBtn
Keys.onEscapePressed: close()
}
Label {
text: qsTr("Hide on launch")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.fillWidth: false
}
CheckBox {
id: hideOnLaunch
enabled: closeToTray.checked
checked: settings.hideOnLaunch
KeyNavigation.tab: saveSettingsBtn
Keys.onEscapePressed: close()
}

View File

@ -12,7 +12,6 @@ ApplicationWindow {
height: 400
minimumHeight: 400
minimumWidth: 300
visible: true
title: getTitle()
property var device: yk
property var credentials: device.credentials
@ -31,6 +30,8 @@ ApplicationWindow {
// See http://doc.qt.io/qt-5/qwindow.html#Visibility-enum
property bool shouldRefresh: visibility != 3 && visibility != 0
property bool hideOnLaunch: settings.hideOnLaunch
signal copy
signal generate(bool copyAfterGenerate)
signal deleteCredential
@ -88,6 +89,7 @@ ApplicationWindow {
property var slot2digits
property string savedPasswords
property bool closeToTray
property bool hideOnLaunch
// Keep track of window and desktop dimensions.
property alias width: appWindow.width
@ -598,6 +600,7 @@ ApplicationWindow {
settings.slot1digits = settingsDialog.slot1digits
settings.slot2digits = settingsDialog.slot2digits
settings.closeToTray = settingsDialog.closeToTray
settings.hideOnLaunch = settingsDialog.hideOnLaunch
}
function trySetPassword() {