normalized behaviour click trayIcon w/ wndow open + lim compose call

This commit is contained in:
Hane 2024-05-08 19:08:43 +02:00
commit 4f3f8b3e56
2 changed files with 23 additions and 8 deletions

View file

@ -679,7 +679,7 @@ void MainWindow::customEvent(QEvent* ev) {
this->addEndpointWidget((CustomWidgetEvent<EndpointHandler*>*)ev);
} else if (ev->type() == (QEvent::Type)CustomQEvent::RecomposeMainWindow) {
ev->setAccepted(true);
this->compose();
if (this->isVisible()) this->compose();
}
QMainWindow::customEvent(ev);
}
@ -863,9 +863,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
//setAttribute(Qt::WA_TranslucentBackground);
//setStyleSheet("background-color: rgba(255,182,193,60%);");
setWindowTitle(STRING_TITLE);
connect(qApp, &QGuiApplication::applicationStateChanged, this, [=](Qt::ApplicationState state){
if(state == Qt::ApplicationState::ApplicationInactive) hide();
});
/*
* Registering needed custom events
*/
@ -880,6 +877,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
/* This spacer provides proper spacing when window vertically > widgets. */
lastRowSpacer = new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
ewsUpdateTimer = new QTimer(this);
recentlyClosedTimer = new QTimer(this);
widget = new QWidget();
widgetLayout = new QGridLayout();
trayIcon = new QSystemTrayIcon();
@ -890,6 +888,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
ewsUpdateTimer->setSingleShot(true);
ewsUpdateTimer->setInterval(ewsUpdateTimerFrequency);
connect(ewsUpdateTimer, &QTimer::timeout, this, &MainWindow::reorderEndpointWidgetCollection);
recentlyClosedTimer->setSingleShot(true);
recentlyClosedTimer->setInterval(recentlyClosedTimerFrequency);
connect(recentlyClosedTimer, &QTimer::timeout, this, [=]() { this->recentlyClosed = false; });
//widget->setMinimumSize(QSize(300,300));
//widget->setLayout(widgetLayout);
/*
@ -936,7 +938,14 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
trayIcon->setToolTip(STRING_TITLE);
trayIcon->setContextMenu(trayIconMenu);
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated);
connect(qApp, &QGuiApplication::applicationStateChanged, this, [=](Qt::ApplicationState state){
if(state == Qt::ApplicationState::ApplicationInactive) {
this->hide();
//This recentlyClosed... kinda campy.
this->recentlyClosed = true;
this->recentlyClosedTimer->start();
}
});
/*
* Set of function callback definitons for EndpointSituationCallback
*/
@ -1034,9 +1043,12 @@ void MainWindow::closeEvent(QCloseEvent *event) {
void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
switch (reason) {
case QSystemTrayIcon::Trigger:
this->compose();
this->showNormal();
this->activateWindow();
if (!this->isVisible() && !recentlyClosed) {
log_to_file("Recently Closed: %d \n", recentlyClosed);
this->compose();
this->showNormal();
this->activateWindow();
}
break;
default:
break;

View file

@ -261,6 +261,9 @@ private:
QTimer *ewsUpdateTimer;
static constexpr uint64_t ewsUpdateTimerFrequency = 500;
double widthRatio = 0.28;
bool recentlyClosed = false;
uint8_t recentlyClosedTimerFrequency = 1000;
QTimer *recentlyClosedTimer;
QScrollArea *scrollArea;
HeaderWidget* hw;