implemented tray icon
This commit is contained in:
parent
1fcf6c3722
commit
5a9d2f7099
7 changed files with 70 additions and 42 deletions
|
|
@ -1,21 +1,5 @@
|
|||
#include "qtclasses.h"
|
||||
|
||||
/*
|
||||
* ToggleButton::ToggleButton(QWidget *parent) : QAbstractButton(parent) {
|
||||
* this->setCheckable(true);
|
||||
* }
|
||||
*
|
||||
* ToggleButton::~ToggleButton(){
|
||||
*
|
||||
* }
|
||||
*
|
||||
* void ToggleButton::checkStateSet(){ }
|
||||
*
|
||||
* bool hitButton(const QPoint &pos) {
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
||||
this->idx = idx;
|
||||
this->eph = eph;
|
||||
|
|
@ -173,14 +157,53 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
// setCentralWidget(centralWidget);
|
||||
widget = new QWidget();
|
||||
layout = new QGridLayout();
|
||||
trayIcon = new QSystemTrayIcon();
|
||||
trayIconMenu = new QMenu();
|
||||
trayIconMenuQuit = new QAction(STRING_QUIT);
|
||||
|
||||
widget->setLayout(layout);
|
||||
setCentralWidget(widget);
|
||||
//layout->addWidget(pintas, 0, 0);
|
||||
|
||||
setWindowTitle("slidea resbala nu c");
|
||||
setWindowTitle(STRING_TITLE);
|
||||
|
||||
reloadEndpointWidgets();
|
||||
|
||||
//Tray Icon
|
||||
trayIconMenu->addSeparator();
|
||||
trayIconMenu->addAction(trayIconMenuQuit);
|
||||
connect(trayIconMenuQuit, &QAction::triggered, qApp, &QCoreApplication::quit);
|
||||
trayIcon->setIcon(QIcon(":/assets/notificationAreaIcon.png"));
|
||||
setWindowIcon(QIcon(":/assets/notificationAreaIcon.png"));
|
||||
//TODO: Extend qsystemtrayicon to change mouse click?
|
||||
//show before setting tooltip required; smells like bug to me!
|
||||
trayIcon->show();
|
||||
trayIcon->setToolTip(STRING_TITLE);
|
||||
trayIcon->setContextMenu(trayIconMenu);
|
||||
QString as = trayIcon->toolTip();
|
||||
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated);
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||
if (!event->spontaneous() || !isVisible()) return;
|
||||
|
||||
if (trayIcon->isVisible()) {
|
||||
//todo: would be nice to show this to 1st time users; ini-san will come...
|
||||
//this->trayIcon->showMessage("ini file calling","tratarte como un gilipollas la primera vez", QSystemTrayIcon::Information);
|
||||
|
||||
hide();
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
|
||||
switch (reason) {
|
||||
case QSystemTrayIcon::Trigger:
|
||||
this->showNormal();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::reloadEndpointWidgets() {
|
||||
|
|
@ -209,21 +232,3 @@ void MainWindow::reloadEndpointWidgets() {
|
|||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* void MainWindow::setPlotButton() {
|
||||
* button = new QPushButton("push"),
|
||||
* button->setCheckable(true);
|
||||
* connect(button, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)))
|
||||
* QHBoxLayout *plotsLayout = new QHBoxLayout;
|
||||
* plotsLayout->setSpacing(10);
|
||||
* plotsLayout->addWidget(funPlot);
|
||||
* QHBoxLayout *buttonsLayout = new QHBoxLayout ;
|
||||
* buttonsLayout->addWidget(button);
|
||||
* QVBoxLayout *widgetLayout = new QVBoxLayout;
|
||||
* widgetLayout->addLayout(plotsLayout);
|
||||
* widgetLayout->addLayout(buttonsLayout);
|
||||
* setLayout(widgetLayout);
|
||||
* ...
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue