Merge pull request #25 from namecheap/feature/RND-547-flameshot-popup-on-windows-after-start-in-tray

Show notification popup after application start in tray
This commit is contained in:
Yurii Puchkov
2020-08-17 23:12:49 +03:00
committed by GitHub
5 changed files with 42 additions and 2 deletions

View File

@@ -36,6 +36,7 @@ GeneneralConf::GeneneralConf(QWidget *parent) : QWidget(parent) {
initShowDesktopNotification();
initShowTrayIcon();
initAutostart();
initShowStartupLaunchMessage();
initCloseAfterCapture();
initCopyAndCloseAfterUpload();
@@ -78,6 +79,10 @@ void GeneneralConf::autostartChanged(bool checked) {
ConfigHandler().setStartupLaunch(checked);
}
void GeneneralConf::showStartupLaunchMessageChanged(bool checked) {
ConfigHandler().setShowStartupLaunchMessage(checked);
}
void GeneneralConf::closeAfterCaptureChanged(bool checked) {
ConfigHandler().setCloseAfterScreenshot(checked);
}
@@ -201,8 +206,7 @@ void GeneneralConf::initConfingButtons() {
}
void GeneneralConf::initAutostart() {
m_autostart =
new QCheckBox(tr("Launch at startup"), this);
m_autostart = new QCheckBox(tr("Launch at startup"), this);
ConfigHandler config;
bool checked = config.startupLaunchValue();
m_autostart->setChecked(checked);
@@ -213,6 +217,19 @@ void GeneneralConf::initAutostart() {
&GeneneralConf::autostartChanged);
}
void GeneneralConf::initShowStartupLaunchMessage() {
m_showStartupLaunchMessage = new QCheckBox(tr("Show welcome message on launch"), this);
ConfigHandler config;
bool checked = config.showStartupLaunchMessage();
m_showStartupLaunchMessage->setChecked(checked);
m_showStartupLaunchMessage->setToolTip(tr("Launch Flameshot"));
m_layout->addWidget(m_showStartupLaunchMessage);
connect(m_showStartupLaunchMessage, &QCheckBox::clicked, [](bool checked) {
ConfigHandler().setShowStartupLaunchMessage(checked);
});
}
void GeneneralConf::initCloseAfterCapture() {
m_closeAfterCapture = new QCheckBox(tr("Close application after capture"), this);
ConfigHandler config;

View File

@@ -36,6 +36,7 @@ private slots:
void showDesktopNotificationChanged(bool checked);
void showTrayIconChanged(bool checked);
void autostartChanged(bool checked);
void showStartupLaunchMessageChanged(bool checked);
void closeAfterCaptureChanged(bool checked);
void importConfiguration();
void exportFileConfiguration();
@@ -47,6 +48,7 @@ private:
QCheckBox *m_showTray;
QCheckBox *m_helpMessage;
QCheckBox *m_autostart;
QCheckBox *m_showStartupLaunchMessage;
QCheckBox *m_closeAfterCapture;
QCheckBox *m_copyAndCloseAfterUpload;
QPushButton *m_importButton;
@@ -58,6 +60,7 @@ private:
void initShowTrayIcon();
void initConfingButtons();
void initAutostart();
void initShowStartupLaunchMessage();
void initCloseAfterCapture();
void initCopyAndCloseAfterUpload();
};

View File

@@ -226,6 +226,12 @@ void Controller::enableTrayIcon() {
};
connect(m_trayIcon, &QSystemTrayIcon::activated, this, trayIconActivated);
m_trayIcon->show();
if (ConfigHandler().showStartupLaunchMessage()) {
m_trayIcon->showMessage("Flameshot",
QObject::tr("Hello, I'm here! Click icon in the tray to take a screenshot or click with a right button to see more options."),
QSystemTrayIcon::Information,
3000);
}
}
void Controller::disableTrayIcon() {

View File

@@ -321,6 +321,17 @@ void ConfigHandler::setStartupLaunch(const bool start) {
m_settings.setValue(QStringLiteral("startupLaunch"), start);
}
bool ConfigHandler::showStartupLaunchMessage() {
if (!m_settings.contains(QStringLiteral("showStartupLaunchMessage"))) {
m_settings.setValue(QStringLiteral("showStartupLaunchMessage"), true);
}
return m_settings.value(QStringLiteral("showStartupLaunchMessage")).toBool();
}
void ConfigHandler::setShowStartupLaunchMessage(const bool showStartupLaunchMessage){
m_settings.setValue(QStringLiteral("showStartupLaunchMessage"), showStartupLaunchMessage);
}
int ConfigHandler::contrastOpacityValue() {
int opacity = 190;
if (m_settings.contains(QStringLiteral("contrastOpacity"))) {

View File

@@ -67,6 +67,9 @@ public:
bool startupLaunchValue();
void setStartupLaunch(const bool);
bool showStartupLaunchMessage();
void setShowStartupLaunchMessage(const bool);
int contrastOpacityValue();
void setContrastOpacity(const int);