- fix missing tooltip if app is in autostart + increase version to 0.1.15

This commit is contained in:
Dmytro Bogovych 2023-05-11 15:32:17 +03:00
parent 317b7097f6
commit 9ff378d5e0
2 changed files with 26 additions and 3 deletions

View File

@ -4,7 +4,7 @@
// App version // App version
#define QBREAK_VERSION_MAJOR 0 #define QBREAK_VERSION_MAJOR 0
#define QBREAK_VERSION_MINOR 1 #define QBREAK_VERSION_MINOR 1
#define QBREAK_VERSION_SUFFIX 14 #define QBREAK_VERSION_SUFFIX 15
// How often UI is updated - interval in seconds // How often UI is updated - interval in seconds
#define INTERVAL_UPDATE_UI (15) #define INTERVAL_UPDATE_UI (15)

View File

@ -218,7 +218,8 @@ void MainWindow::showMe()
// qDebug() << "Screen not found!"; // qDebug() << "Screen not found!";
#if defined(DEBUG) #if defined(DEBUG)
showMaximized(); showFullScreen();
//showMaximized();
#else #else
showFullScreen(); showFullScreen();
#endif #endif
@ -292,6 +293,21 @@ QString state2str(AppState state)
return QString(); return QString();
} }
static void dispatchToMainThread(std::function<void()> callback)
{
// any thread
QTimer* timer = new QTimer();
timer->moveToThread(qApp->thread());
timer->setSingleShot(true);
QObject::connect(timer, &QTimer::timeout, [=]()
{
// main thread
callback();
timer->deleteLater();
});
QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, 0));
}
void MainWindow::shiftTo(AppState newState) void MainWindow::shiftTo(AppState newState)
{ {
if (newState == mState) if (newState == mState)
@ -324,7 +340,12 @@ void MainWindow::shiftTo(AppState newState)
} }
mState = newState; mState = newState;
onUpdateUI();
// Run deferred in main UI thread
dispatchToMainThread([this](){
onUpdateUI();
});
} }
void MainWindow::onUpdateUI() void MainWindow::onUpdateUI()
@ -382,6 +403,8 @@ void MainWindow::onUpdateUI()
tr("There are %1 minutes left until the next break.") tr("There are %1 minutes left until the next break.")
.arg(msec2min(remaining_milliseconds))); .arg(msec2min(remaining_milliseconds)));
} }
else
qDebug() << "No tray icon available.";
break; break;
} }