Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add an option to turn of notifications.

Notifications can be turned off by disabling them in the context menu of the
tray icon, or by giving the program option --silent or -s at program startup.
By default, notifications are enabled at startup.
  • Loading branch information...
commit eb5820ffc24635f8e59b39d2dcfea82eedd0b574 1 parent 8633b01
@rohieb rohieb authored
Showing with 22 additions and 2 deletions.
  1. +3 −0  README
  2. +14 −2 main.cpp
  3. +5 −0 main.h
View
3  README
@@ -10,6 +10,9 @@ Compiling:
or, if you are using MS Visual C++:
qmake main.pro && nmake
+By default, a notification is shown when the opening status changes. If you do
+not want that, you can start the program with the --silent or -s option.
+
Windows compatibility has not yet been tested by me, though some users report
that it works too.
View
16 main.cpp
@@ -44,7 +44,7 @@
*/
StratumsphereTrayIcon::StratumsphereTrayIcon() : QObject(0), nam_(0),
trayMenu_(0), trayIcon_(0), status_(UNDEFINED), lastStatus_(UNDEFINED),
- timeoutTimer_(0) {
+ timeoutTimer_(0), toggleNotifyAction_(0) {
nam_ = new QNetworkAccessManager(this);
connect(nam_, SIGNAL(finished(QNetworkReply*)), this,
SLOT(reply(QNetworkReply*)));
@@ -59,6 +59,12 @@ StratumsphereTrayIcon::StratumsphereTrayIcon() : QObject(0), nam_(0),
// set up menu
trayMenu_ = new QMenu;
+
+ toggleNotifyAction_ = new QAction(tr("Show &notifications"), this);
+ toggleNotifyAction_->setCheckable(true);
+ toggleNotifyAction_->setChecked(true);
+ trayMenu_->addAction(toggleNotifyAction_);
+
updateAction_ = new QAction(tr("&Update status"), trayMenu_);
connect(updateAction_, SIGNAL(triggered()), this, SLOT(updateStatus()));
trayMenu_->addAction(updateAction_);
@@ -192,7 +198,7 @@ void StratumsphereTrayIcon::refresh() {
// set balloon message
static bool firstTime = true; // don't show at program start
- if(!firstTime && lastStatus_ != status_ &&
+ if(toggleNotifyAction_->isChecked() && !firstTime && lastStatus_ != status_ &&
status_ != StratumsphereTrayIcon::UNDEFINED) {
#ifdef HAVE_DBUS
@@ -216,6 +222,12 @@ int main(int argc, char * argv[]) {
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
StratumsphereTrayIcon * sti = new StratumsphereTrayIcon;
+ // parse arguments
+ QStringList args = app.arguments();
+ if(args.contains("--silent") || args.contains("-s")) {
+ sti->setNotifications(false);
+ }
+
int ret = app.exec();
delete sti;
View
5 main.h
@@ -62,9 +62,14 @@ class StratumsphereTrayIcon : public QObject {
StratumsphereTrayIcon();
virtual ~StratumsphereTrayIcon();
+ inline void setNotifications(bool b) {
+ toggleNotifyAction_->setChecked(b);
+ }
+
protected:
Status lastStatus_;
QTimer * timeoutTimer_;
+ QAction * toggleNotifyAction_;
public slots:
void updateStatus();
Please sign in to comment.
Something went wrong with that request. Please try again.