Browse Source

Allow X to close

tags/v5.0.0
ArsenArsen 5 years ago
parent
commit
bd2be65e03
  1. 13
      mainwindow.cpp
  2. 2
      mainwindow.hpp
  3. 85
      mainwindow.ui

13
mainwindow.cpp

@ -3,6 +3,7 @@
#include "screenshotutil.hpp"
#include "ui_mainwindow.h"
#include <QAction>
#include <QApplication>
#include <QCheckBox>
#include <QCloseEvent>
#include <QCoreApplication>
@ -84,6 +85,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
addHotkeyItem("Area image", "area", new std::function<void()>([] { 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);
}

2
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();

85
mainwindow.ui

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>512</width>
<height>337</height>
<height>368</height>
</rect>
</property>
<property name="windowTitle">
@ -25,7 +25,14 @@
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="7" column="0" colspan="2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Uploader selection:</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>&lt;a href=&quot;https://github.com/ArsenArsen/KShare&quot;&gt;Source code available free for everyone. Forever.&lt;/a&gt;
@ -34,53 +41,34 @@
</property>
</widget>
</item>
<item row="1" column="1" rowspan="5">
<widget class="QListWidget" name="hotkeys"/>
</item>
<item row="5" column="0">
<widget class="QDoubleSpinBox" name="delay">
<property name="toolTip">
<string>In seconds</string>
</property>
<property name="whatsThis">
<string>A delay before taking a screenshot, in seconds</string>
</property>
<property name="suffix">
<string>s</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>File name scheme:</string>
<string>Delay before taking a screenshot</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<item row="0" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Uploader selection:</string>
<string>Hotkeys</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<item row="6" column="0">
<widget class="QCheckBox" name="quickMode">
<property name="text">
<string>Delay before taking a screenshot</string>
<string>Quick mode (mouse release screenshots)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_5">
<item row="6" column="1">
<widget class="QPushButton" name="settingsButton">
<property name="text">
<string>Hotkeys</string>
<string>Open settings directory</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QListWidget" name="uploaderList"/>
</item>
<item row="3" column="0">
<widget class="QLineEdit" name="nameScheme">
<property name="toolTip">
@ -91,17 +79,36 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="quickMode">
<item row="5" column="0">
<widget class="QDoubleSpinBox" name="delay">
<property name="toolTip">
<string>In seconds</string>
</property>
<property name="whatsThis">
<string>A delay before taking a screenshot, in seconds</string>
</property>
<property name="suffix">
<string>s</string>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="5">
<widget class="QListWidget" name="hotkeys"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Quick mode (mouse release screenshots)</string>
<string>File name scheme:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="settingsButton">
<item row="1" column="0">
<widget class="QListWidget" name="uploaderList"/>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="hideToTray">
<property name="text">
<string>Open settings directory</string>
<string>Pressing &lt;X&gt; hides to tray</string>
</property>
</widget>
</item>

Loading…
Cancel
Save