From bd2be65e03e420303a40db31fc2772040b16fbe0 Mon Sep 17 00:00:00 2001 From: ArsenArsen Date: Mon, 15 May 2017 14:42:40 +0200 Subject: [PATCH] Allow X to close --- mainwindow.cpp | 13 +++++-- mainwindow.hpp | 2 ++ mainwindow.ui | 97 +++++++++++++++++++++++++++----------------------- 3 files changed, 65 insertions(+), 47 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index b3f186b..041316e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -3,6 +3,7 @@ #include "screenshotutil.hpp" #include "ui_mainwindow.h" #include +#include #include #include #include @@ -84,6 +85,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi addHotkeyItem("Area image", "area", new std::function([] { screenshotter::area(); })); ui->quickMode->setChecked(settings::settings().value("quickMode", false).toBool()); + ui->hideToTray->setChecked(settings::settings().value("hideOnClose", true).toBool()); } MainWindow::~MainWindow() { @@ -103,8 +105,11 @@ MainWindow *MainWindow::inst() { } void MainWindow::closeEvent(QCloseEvent *event) { - event->ignore(); - QTimer::singleShot(0, this, &MainWindow::hide); + if (settings::settings().value("hideOnClose", true).toBool()) { + event->ignore(); + QTimer::singleShot(0, this, &MainWindow::hide); + } else + QApplication::exit(0); } void MainWindow::quit() { @@ -172,3 +177,7 @@ void MainWindow::on_settingsButton_clicked() { void MainWindow::on_quickMode_clicked(bool checked) { settings::settings().setValue("quickMode", checked); } + +void MainWindow::on_hideToTray_clicked(bool checked) { + settings::settings().setValue("hideOnClose", checked); +} diff --git a/mainwindow.hpp b/mainwindow.hpp index 2395741..cf36673 100644 --- a/mainwindow.hpp +++ b/mainwindow.hpp @@ -34,6 +34,8 @@ class MainWindow : public QMainWindow { void on_quickMode_clicked(bool checked); + void on_hideToTray_clicked(bool checked); + public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); diff --git a/mainwindow.ui b/mainwindow.ui index c1af1bf..205b709 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 512 - 337 + 368 @@ -25,7 +25,14 @@ - + + + + Uploader selection: + + + + <a href="https://github.com/ArsenArsen/KShare">Source code available free for everyone. Forever.</a> @@ -34,36 +41,6 @@ - - - - - - - In seconds - - - A delay before taking a screenshot, in seconds - - - s - - - - - - - File name scheme: - - - - - - - Uploader selection: - - - @@ -78,19 +55,6 @@ - - - - - - - http://doc.qt.io/qt-5/qdatetime.html#toString - - - Screenshot %(yyyy-MM-dd HH:mm:ss)date - - - @@ -105,6 +69,49 @@ + + + + http://doc.qt.io/qt-5/qdatetime.html#toString + + + Screenshot %(yyyy-MM-dd HH:mm:ss)date + + + + + + + In seconds + + + A delay before taking a screenshot, in seconds + + + s + + + + + + + + + + File name scheme: + + + + + + + + + + Pressing <X> hides to tray + + +