Add option to disable notifications in desktop

This commit is contained in:
lupoDharkael
2017-06-14 19:52:29 +02:00
parent 246b5e7651
commit b1c86b9ba8
5 changed files with 40 additions and 8 deletions

View File

@@ -25,4 +25,8 @@
- show Help message
- value: "showHelp"
- type: bool
- description: show Help message in capture mode.
- description: show Help messages in capture mode.
- show Help message
- value: "showDesktopNotification"
- type: bool
- description: show every desktop notification.

View File

@@ -164,7 +164,7 @@ void CaptureWidget::paintEvent(QPaintEvent *) {
QString helpTxt = tr("Select an area with the mouse, or press Esc to exit."
"\nPress Enter to capture the screen."
"\nPress Right Click to choose the tool color.");
"\nPress Right Click to show the color picker.");
// We draw the white contrasting background for the text, using the
//same text and options to get the boundingRect that the text will have.
@@ -394,10 +394,15 @@ void CaptureWidget::keyPressEvent(QKeyEvent *e) {
void CaptureWidget::saveScreenshot() {
hide();
QString path;
if (m_selection.isNull()) {
m_screenshot->graphicalSave(QRect(), this);
path = m_screenshot->graphicalSave(QRect(), this);
} else { // save full screen when no selection
m_screenshot->graphicalSave(getExtendedSelection(), this);
path = m_screenshot->graphicalSave(getExtendedSelection(), this);
}
if (!path.isEmpty()) {
QString saveMessage(tr("Capture saved in "));
Q_EMIT newMessage(saveMessage + path);
}
close();
}

View File

@@ -8,14 +8,19 @@ GeneneralConf::GeneneralConf(QWidget *parent) : QFrame(parent) {
setFrameStyle(QFrame::StyledPanel);
m_layout = new QVBoxLayout(this);
initHelpShow();
initShowHelp();
initShowDesktopNotification();
}
void GeneneralConf::showHelpChanged(bool checked) {
QSettings().setValue("showHelp", checked);
}
void GeneneralConf::initHelpShow() {
void GeneneralConf::showDesktopNotificationChanged(bool checked) {
QSettings().setValue("showDesktopNotification", checked);
}
void GeneneralConf::initShowHelp() {
QCheckBox *c = new QCheckBox(tr("Show help message"), this);
QSettings settings;
bool checked = settings.value("showHelp").toBool();
@@ -26,3 +31,15 @@ void GeneneralConf::initHelpShow() {
connect(c, &QCheckBox::clicked, this, &GeneneralConf::showHelpChanged);
}
void GeneneralConf::initShowDesktopNotification() {
QCheckBox *c = new QCheckBox(tr("Show desktop notifications"), this);
QSettings settings;
bool checked = settings.value("showDesktopNotification").toBool();
c->setChecked(checked);
c->setToolTip(tr("Show desktop notifications"));
m_layout->addWidget(c);
connect(c, &QCheckBox::clicked, this,
&GeneneralConf::showDesktopNotificationChanged);
}

View File

@@ -12,11 +12,13 @@ public:
private slots:
void showHelpChanged(bool checked);
void showDesktopNotificationChanged(bool checked);
private:
QVBoxLayout *m_layout;
void initHelpShow();
void initShowHelp();
void initShowDesktopNotification();
};
#endif // GENENERALCONF_H

View File

@@ -85,6 +85,7 @@ void Controller::initDefaults() {
if (!settings.value("initiated").toBool()) {
settings.setValue("initiated", true);
settings.setValue("showHelp", true);
settings.setValue("showDesktopNotification", true);
settings.setValue("drawColor", QColor(Qt::red));
//settings.setValue("mouseVisible", false);
settings.setValue("uiColor", QColor(116, 0, 150));
@@ -140,5 +141,8 @@ void Controller::openInfoWindow() {
}
void Controller::showMessage(QString msg) {
m_trayIcon->showMessage("Flameshot Info", msg);
bool showMessages = QSettings().value("showDesktopNotification").toBool();
if (showMessages) {
m_trayIcon->showMessage("Flameshot Info", msg);
}
}