mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 18:50:44 +00:00
System Tray Notification Area for user alerts (where supported by your O/S)
This commit is contained in:
parent
44bd913d69
commit
b9fc8c8eba
@ -140,10 +140,30 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
connect(ui->webView, SIGNAL(statusBarMessage(QString)), this, SLOT(updatestatusBarMessage(QString)));
|
||||
|
||||
if (QSystemTrayIcon::isSystemTrayAvailable() && QSystemTrayIcon::supportsMessages()) {
|
||||
systray=new QSystemTrayIcon(QIcon(":/docs/sheep.png"),this);
|
||||
systray->show();
|
||||
systraymenu=new QMenu(this);
|
||||
systray->setContextMenu(systraymenu);
|
||||
QAction *a=systraymenu->addAction("SleepyHead v"+PREF["VersionString"].toString());
|
||||
a->setEnabled(false);
|
||||
systraymenu->addSeparator();
|
||||
systraymenu->addAction("About",this,SLOT(on_action_About_triggered()));
|
||||
systraymenu->addAction("Check for Updates",this,SLOT(on_actionCheck_for_Updates_triggered()));
|
||||
systraymenu->addSeparator();
|
||||
systraymenu->addAction("Exit",this,SLOT(close()));
|
||||
} else {
|
||||
systray=NULL;
|
||||
systraymenu=NULL;
|
||||
}
|
||||
|
||||
}
|
||||
extern MainWindow *mainwin;
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
if (systray) delete systray;
|
||||
if (systraymenu) delete systraymenu;
|
||||
|
||||
//if (!isMaximized()) {
|
||||
QSettings settings("Jedimark", "SleepyHead");
|
||||
settings.setValue("MainWindow/geometry", saveGeometry());
|
||||
@ -166,9 +186,18 @@ MainWindow::~MainWindow()
|
||||
mainwin=NULL;
|
||||
delete ui;
|
||||
}
|
||||
void MainWindow::Notify(QString s)
|
||||
{
|
||||
if (systray) {
|
||||
systray->showMessage("SleepyHead v"+PREF["VersionString"].toString(),s,QSystemTrayIcon::Information,5000);
|
||||
} else {
|
||||
ui->statusbar->showMessage(s,5000);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::Startup()
|
||||
{
|
||||
//Notify("Hi!");
|
||||
qDebug() << PREF["AppName"].toString().toAscii()+" v"+PREF["VersionString"].toString().toAscii() << "built with Qt"<< QT_VERSION_STR << "on" << __DATE__ << __TIME__;
|
||||
qstatus->setText(tr("Loading Data"));
|
||||
qprogress->show();
|
||||
@ -402,6 +431,7 @@ void MainWindow::on_oximetryButton_clicked()
|
||||
|
||||
void MainWindow::CheckForUpdates()
|
||||
{
|
||||
mainwin->Notify("Checking for Updates");
|
||||
on_actionCheck_for_Updates_triggered();
|
||||
}
|
||||
|
||||
@ -411,7 +441,7 @@ void MainWindow::on_actionCheck_for_Updates_triggered()
|
||||
if (PREF["Updates_LastChecked"].toDateTime().secsTo(QDateTime::currentDateTime())<3600) {
|
||||
// Instead of doing this, just use the cached crud
|
||||
if (prefdialog) prefdialog->RefreshLastChecked();
|
||||
ui->statusbar->showMessage("No New Updates - You already checked in the last hour...",4000);
|
||||
mainwin->Notify("No New Updates - You already checked in the last hour...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -435,7 +465,7 @@ void MainWindow::replyFinished(QNetworkReply * reply)
|
||||
QMessageBox::information(this,"Laziness Warning","I'd love to do it for you automatically, but it's not implemented yet.. :)",QMessageBox::Ok);
|
||||
}
|
||||
} else {
|
||||
ui->statusbar->showMessage("Checked for Updates and SleepyHead is already up to date (v"+a+")",4000);
|
||||
mainwin->Notify("Checked for Updates: SleepyHead is already up to date!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include <QGLContext>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
#include "daily.h"
|
||||
#include "overview.h"
|
||||
#include "oximetry.h"
|
||||
@ -42,7 +44,7 @@ public:
|
||||
void Log(QString s);
|
||||
QMenu * CreateMenu(QString title);
|
||||
void CheckForUpdates();
|
||||
|
||||
void Notify(QString s);
|
||||
private slots:
|
||||
void on_action_Import_Data_triggered();
|
||||
|
||||
@ -108,7 +110,8 @@ private:
|
||||
QMutex loglock,strlock;
|
||||
QStringList logbuffer;
|
||||
QTime logtime;
|
||||
|
||||
QSystemTrayIcon *systray;
|
||||
QMenu *systraymenu;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
Loading…
Reference in New Issue
Block a user