implemented tray icon
This commit is contained in:
parent
1fcf6c3722
commit
5a9d2f7099
7 changed files with 70 additions and 42 deletions
5
assets.qrc
Normal file
5
assets.qrc
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/">
|
||||
<file>assets/notificationAreaIcon.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
BIN
assets/notificationAreaIcon.png
Normal file
BIN
assets/notificationAreaIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 156 KiB |
|
|
@ -1,12 +1,16 @@
|
|||
QMAKE_CXXFLAGS += --target=x86_64-w64-mingw32 -g -gcodeview
|
||||
#QMAKE_LINK += clang++
|
||||
QMAKE_LFLAGS += --target=x86_64-w64-mingw32 -g -gcodeview -Wl,-pdb= -v
|
||||
QMAKE_LFLAGS += --target=x86_64-w64-mingw32 -g -Wl,-pdb= -v
|
||||
|
||||
DEFINES += DEBUG
|
||||
CONFIG += debug console
|
||||
|
||||
QT += widgets
|
||||
INCLUDEPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||
DESTPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||
VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||
SOURCES += qtestmain.cpp qtclasses.cpp backlasses.cpp contclasses.cpp
|
||||
HEADERS += qtclasses.h backlasses.h contclasses.h global.h debug.h backfuncs.h
|
||||
RESOURCES = assets.qrc
|
||||
|
||||
#DESTDIR += "build"
|
||||
|
|
|
|||
|
|
@ -7,12 +7,11 @@
|
|||
|
||||
#include "debug.h"
|
||||
|
||||
//#define ENDPOINT_MASTER_VOLUME -1
|
||||
/* #define ENDPOINT_LEFT_CHANNEL_VOLUME 0 */
|
||||
/* #define ENDPOINT_RIGHT_CHANNEL_VOLUME 1 */
|
||||
|
||||
//TODO: Use tr();? QTranslator
|
||||
#define STRING_MUTE "Mute"
|
||||
#define STRING_UNMUTE "Unmute"
|
||||
#define STRING_QUIT "Quit"
|
||||
#define STRING_TITLE "Mixer Fachero"
|
||||
//INIT BACK
|
||||
|
||||
class OverseerHandler;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
* ...
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,13 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
#include <QApplication>
|
||||
#include <QCloseEvent>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
//#include <QMessageBox>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include <QGridLayout>
|
||||
|
|
@ -79,7 +86,7 @@ public:
|
|||
public slots:
|
||||
void updateMainVolume(int newValue);
|
||||
void updateMute(int checked);
|
||||
|
||||
|
||||
private:
|
||||
QTimer* timer = nullptr;
|
||||
uint64_t idx;
|
||||
|
|
@ -99,6 +106,11 @@ public:
|
|||
MainWindow(QWidget *parent = nullptr);
|
||||
void reloadEndpointWidgets();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
//TODO: destroy/empty existing EndpointWidgets
|
||||
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
||||
|
|
@ -107,8 +119,10 @@ private:
|
|||
std::vector<EndpointWidget*> ews;
|
||||
QWidget *widget;
|
||||
QGridLayout *layout;
|
||||
//QLabel *pintas;
|
||||
|
||||
QSystemTrayIcon *trayIcon;
|
||||
QMenu *trayIconMenu;
|
||||
QAction *trayIconMenuQuit;
|
||||
//public slots:
|
||||
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ int main (int argc, char* argv[]) {
|
|||
QScopedPointer<QApplication> app(createApplication(argc, argv));
|
||||
MainWindow window = MainWindow();
|
||||
//window.setEndpointHandlers(ephs);
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
app->setStyle("windowsvista");
|
||||
window.show();
|
||||
return app->exec();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue