Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c48fe5f38 | |||
| 61ef94b474 | |||
| aba5e21271 | |||
| 76a63b29c2 | |||
| 37840dfdb1 | |||
| 9ff378d5e0 | |||
| 317b7097f6 | |||
| 64658a7778 | |||
| 447f33bf94 | |||
| 6200504627 |
@ -1,10 +1,12 @@
|
|||||||
#include "audio_support.h"
|
#include "audio_support.h"
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
#include <QSound>
|
#include <QSound>
|
||||||
|
|
||||||
extern void play_audio(const app_settings::selected_audio& item)
|
extern void play_audio(const app_settings::selected_audio& item)
|
||||||
{
|
{
|
||||||
// Play audio
|
// Play audio
|
||||||
|
|
||||||
if (item.name != Audio_Empty && item.name != Audio_Custom)
|
if (item.name != Audio_Empty && item.name != Audio_Custom)
|
||||||
{
|
{
|
||||||
// Find bundled audio
|
// Find bundled audio
|
||||||
@ -16,4 +18,7 @@ extern void play_audio(const app_settings::selected_audio& item)
|
|||||||
if (item.name == Audio_Custom && !item.path.isEmpty())
|
if (item.name == Audio_Custom && !item.path.isEmpty())
|
||||||
QSound::play(item.path);
|
QSound::play(item.path);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
extern void play_audio(const app_settings::selected_audio& item)
|
||||||
|
{}
|
||||||
|
#endif
|
||||||
|
|||||||
@ -64,6 +64,17 @@ static fs::path autostart_path()
|
|||||||
|
|
||||||
void autostart::enable(const std::string& path_to_me)
|
void autostart::enable(const std::string& path_to_me)
|
||||||
{
|
{
|
||||||
|
// Ensure autostart directory exists at all
|
||||||
|
if (!fs::exists(autostart_dir()))
|
||||||
|
{
|
||||||
|
std::error_code ec;
|
||||||
|
if (!fs::create_directory(autostart_dir(), ec))
|
||||||
|
{
|
||||||
|
qDebug() << "Failed to create autostart directory. Error: " << QString::fromStdString(ec.message());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Put .desktop file to ~/.config/autostart
|
// Put .desktop file to ~/.config/autostart
|
||||||
std::ofstream ofs(autostart_path());
|
std::ofstream ofs(autostart_path());
|
||||||
if (ofs.is_open())
|
if (ofs.is_open())
|
||||||
|
|||||||
@ -4,10 +4,10 @@
|
|||||||
// 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 11
|
#define QBREAK_VERSION_SUFFIX 17
|
||||||
|
|
||||||
// How often UI is updated - interval in seconds
|
// How often UI is updated - interval in seconds
|
||||||
#define INTERVAL_UPDATE_UI (60)
|
#define INTERVAL_UPDATE_UI (10)
|
||||||
|
|
||||||
// How often progress bar is updated - interval in milliseconds
|
// How often progress bar is updated - interval in milliseconds
|
||||||
#define INTERVAL_UPDATE_PROGRESS (1000)
|
#define INTERVAL_UPDATE_PROGRESS (1000)
|
||||||
|
|||||||
@ -6,9 +6,9 @@
|
|||||||
#if defined(TARGET_LINUX)
|
#if defined(TARGET_LINUX)
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDBusConnection>
|
#include <QtDBus/QDBusConnection>
|
||||||
#include <QDBusReply>
|
#include <QtDBus/QDBusReply>
|
||||||
#include <QDBusInterface>
|
#include <QtDBus/QDBusInterface>
|
||||||
|
|
||||||
// Thanks to https://stackoverflow.com/questions/222606/detecting-keyboard-mouse-activity-in-linux
|
// Thanks to https://stackoverflow.com/questions/222606/detecting-keyboard-mouse-activity-in-linux
|
||||||
|
|
||||||
@ -210,6 +210,7 @@ int get_idle_time_kde_wayland()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool Warning_X11InWayland = false;
|
||||||
int get_idle_time_dynamically()
|
int get_idle_time_dynamically()
|
||||||
{
|
{
|
||||||
const char* wl_display = std::getenv("WAYLAND_DISPLAY");
|
const char* wl_display = std::getenv("WAYLAND_DISPLAY");
|
||||||
@ -235,8 +236,14 @@ int get_idle_time_dynamically()
|
|||||||
#else
|
#else
|
||||||
// Restrict to X11
|
// Restrict to X11
|
||||||
if (wl_display)
|
if (wl_display)
|
||||||
|
{
|
||||||
|
// One time error message
|
||||||
|
if (!Warning_X11InWayland) {
|
||||||
|
qDebug() << "Wayland is found, but app built for X11 only. Idle tracking is not supported.";
|
||||||
|
Warning_X11InWayland = true;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
return get_idle_time_x11();
|
return get_idle_time_x11();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
54
app/main.cpp
54
app/main.cpp
@ -6,13 +6,63 @@
|
|||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
#if defined(TARGET_LINUX)
|
||||||
|
# include <syslog.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Handler for Qt log messages that sends output to syslog as well as standard error.
|
||||||
|
void SyslogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
|
{
|
||||||
|
Q_UNUSED(context)
|
||||||
|
std::string timePrefix = QDateTime::currentDateTime().toString().toStdString();
|
||||||
|
|
||||||
|
QByteArray localMsg = msg.toLocal8Bit();
|
||||||
|
switch (type) {
|
||||||
|
case QtDebugMsg:
|
||||||
|
fprintf(stderr, "debug: %s %s\n", timePrefix.c_str(), localMsg.constData());
|
||||||
|
#if defined(TARGET_LINUX)
|
||||||
|
syslog(LOG_DEBUG, "debug: %s", localMsg.constData());
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case QtInfoMsg:
|
||||||
|
fprintf(stderr, "info: %s %s\n", timePrefix.c_str(), localMsg.constData());
|
||||||
|
#if defined(TARGET_LINUX)
|
||||||
|
syslog(LOG_INFO, "info: %s", localMsg.constData());
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case QtWarningMsg:
|
||||||
|
fprintf(stderr, "warning: %s %s\n", timePrefix.c_str(), localMsg.constData());
|
||||||
|
#if defined(TARGET_LINUX)
|
||||||
|
syslog(LOG_WARNING, "warning: %s", localMsg.constData());
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
fprintf(stderr, "critical: %s %s\n", timePrefix.c_str(), localMsg.constData());
|
||||||
|
#if defined(TARGET_LINUX)
|
||||||
|
syslog(LOG_CRIT, "critical: %s", localMsg.constData());
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case QtFatalMsg:
|
||||||
|
fprintf(stderr, "fatal: %s %s\n", timePrefix.c_str(), localMsg.constData());
|
||||||
|
#if defined(TARGET_LINUX)
|
||||||
|
syslog(LOG_ALERT, "fatal: %s", localMsg.constData());
|
||||||
|
#endif
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
RunGuard guard("adjfaifaif");
|
RunGuard guard("QBreak app - runguard");
|
||||||
if ( !guard.tryToRun() )
|
if ( !guard.tryToRun() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
// Needed to enable logging to syslog or journald.
|
||||||
|
qInstallMessageHandler(SyslogMessageHandler);
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
QCoreApplication::setOrganizationName("voipobjects.com");
|
QCoreApplication::setOrganizationName("voipobjects.com");
|
||||||
@ -29,7 +79,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
// Put itself into app menu
|
// Put itself into app menu
|
||||||
auto exe_path = QCoreApplication::applicationFilePath();//QFileInfo(QCoreApplication::arguments().front()).absoluteFilePath();
|
auto exe_path = QCoreApplication::applicationFilePath();
|
||||||
const char* appimage = std::getenv("APPIMAGE");
|
const char* appimage = std::getenv("APPIMAGE");
|
||||||
if (appimage != nullptr)
|
if (appimage != nullptr)
|
||||||
exe_path = appimage;
|
exe_path = appimage;
|
||||||
|
|||||||
@ -12,25 +12,46 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QSvgGenerator>
|
#include <QSvgGenerator>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QSound>
|
|
||||||
#include <QCommandLineOption>
|
#include <QCommandLineOption>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
# include <QDesktopWidget>
|
||||||
|
# include <QSound>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
static void dispatchToMainThread(std::function<void()> callback, std::chrono::milliseconds delay = std::chrono::milliseconds(0))
|
||||||
|
{
|
||||||
|
// any thread
|
||||||
|
QTimer* timer = new QTimer();
|
||||||
|
timer->moveToThread(qApp->thread());
|
||||||
|
timer->setSingleShot(true);
|
||||||
|
timer->setInterval(delay);
|
||||||
|
QObject::connect(timer, &QTimer::timeout, [=]()
|
||||||
|
{
|
||||||
|
// main thread
|
||||||
|
callback();
|
||||||
|
timer->deleteLater();
|
||||||
|
});
|
||||||
|
QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, 0));
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
init();
|
|
||||||
|
// Defer init call for 100 ms - attempt to resolve the problem with non working setTooltip()
|
||||||
|
dispatchToMainThread([this](){init();}, std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -122,27 +143,17 @@ void MainWindow::init()
|
|||||||
shiftTo(AppState::Counting);
|
shiftTo(AppState::Counting);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString get_time()
|
|
||||||
{
|
|
||||||
return QDateTime::currentDateTime().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString get_log_prefix()
|
|
||||||
{
|
|
||||||
return get_time();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int str_to_seconds(const QString& s)
|
static int str_to_seconds(const QString& s)
|
||||||
{
|
{
|
||||||
if (s.isEmpty())
|
if (s.isEmpty())
|
||||||
throw std::runtime_error("Bad parameter value.");
|
throw std::runtime_error("Bad parameter value.");
|
||||||
|
|
||||||
if (s.back() == 'h')
|
if (s.back() == 'h')
|
||||||
return s.leftRef(s.size()-1).toInt() * 3600;
|
return s.left(s.size()-1).toInt() * 3600;
|
||||||
if (s.back() == 'm')
|
if (s.back() == 'm')
|
||||||
return s.leftRef(s.size()-1).toInt() * 60;
|
return s.left(s.size()-1).toInt() * 60;
|
||||||
if (s.back() == 's')
|
if (s.back() == 's')
|
||||||
return s.leftRef(s.size()-1).toInt();
|
return s.left(s.size()-1).toInt();
|
||||||
|
|
||||||
if (s.back().isDigit())
|
if (s.back().isDigit())
|
||||||
return s.toInt();
|
return s.toInt();
|
||||||
@ -225,10 +236,11 @@ void MainWindow::showMe()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else
|
// else
|
||||||
// qDebug() << get_log_prefix() << "Screen not found!";
|
// qDebug() << "Screen not found!";
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
showMaximized();
|
showFullScreen();
|
||||||
|
//showMaximized();
|
||||||
#else
|
#else
|
||||||
showFullScreen();
|
showFullScreen();
|
||||||
#endif
|
#endif
|
||||||
@ -274,10 +286,11 @@ void MainWindow::createTrayIcon()
|
|||||||
|
|
||||||
mTrayIcon->setContextMenu(menu);
|
mTrayIcon->setContextMenu(menu);
|
||||||
mTrayIcon->setIcon(getTrayIcon());
|
mTrayIcon->setIcon(getTrayIcon());
|
||||||
mTrayIcon->setToolTip(AppName);
|
// mTrayIcon->setToolTip(AppName);
|
||||||
mTrayIcon->show();
|
|
||||||
connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||||
this, SLOT(onTrayIconActivated(QSystemTrayIcon::ActivationReason)));
|
this, SLOT(onTrayIconActivated(QSystemTrayIcon::ActivationReason)));
|
||||||
|
|
||||||
|
mTrayIcon->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int msec2min(int msec)
|
static int msec2min(int msec)
|
||||||
@ -302,13 +315,12 @@ QString state2str(AppState state)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::shiftTo(AppState newState)
|
void MainWindow::shiftTo(AppState newState)
|
||||||
{
|
{
|
||||||
if (newState == mState)
|
if (newState == mState)
|
||||||
return;
|
return;
|
||||||
#if defined(DEBUG)
|
qDebug() << state2str(mState) << " -> " << state2str(newState);
|
||||||
qDebug() << get_log_prefix() << state2str(mState) << " -> " << state2str(newState);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (newState)
|
switch (newState)
|
||||||
{
|
{
|
||||||
@ -336,10 +348,17 @@ 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()
|
||||||
|
{
|
||||||
|
qDebug() << "UI timer fired.";
|
||||||
|
|
||||||
int idle_milliseconds = 0;
|
int idle_milliseconds = 0;
|
||||||
switch (mState) {
|
switch (mState) {
|
||||||
case AppState::None:
|
case AppState::None:
|
||||||
@ -350,7 +369,7 @@ void MainWindow::onUpdateUI() {
|
|||||||
// Detected idle, don't count this time as working
|
// Detected idle, don't count this time as working
|
||||||
// But check - maybe idle is over
|
// But check - maybe idle is over
|
||||||
idle_milliseconds = get_idle_time_dynamically();
|
idle_milliseconds = get_idle_time_dynamically();
|
||||||
qDebug() << get_log_prefix() << "Idle found: " << idle_milliseconds / 1000 << "s";
|
qDebug() << "Idle found: " << idle_milliseconds / 1000 << "s";
|
||||||
|
|
||||||
if (idle_milliseconds < mAppConfig.idle_timeout * 1000)
|
if (idle_milliseconds < mAppConfig.idle_timeout * 1000)
|
||||||
{
|
{
|
||||||
@ -371,6 +390,8 @@ void MainWindow::onUpdateUI() {
|
|||||||
if (!mIdleStart && mAppConfig.idle_timeout)
|
if (!mIdleStart && mAppConfig.idle_timeout)
|
||||||
{
|
{
|
||||||
idle_milliseconds = get_idle_time_dynamically();
|
idle_milliseconds = get_idle_time_dynamically();
|
||||||
|
qDebug() << "Idle found: " << idle_milliseconds / 1000 << "s";
|
||||||
|
|
||||||
if (idle_milliseconds >= mAppConfig.idle_timeout * 1000)
|
if (idle_milliseconds >= mAppConfig.idle_timeout * 1000)
|
||||||
{
|
{
|
||||||
shiftTo(AppState::Idle);
|
shiftTo(AppState::Idle);
|
||||||
@ -389,6 +410,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;
|
||||||
}
|
}
|
||||||
@ -408,7 +431,7 @@ void MainWindow::onLongBreakStart()
|
|||||||
{
|
{
|
||||||
mBreakStartTimer->stop();
|
mBreakStartTimer->stop();
|
||||||
mBreakNotifyTimer->stop();
|
mBreakNotifyTimer->stop();
|
||||||
qDebug() << get_log_prefix() << "Stop main and notify timers.";
|
qDebug() << "Stop main and notify timers.";
|
||||||
|
|
||||||
// Reset idle counter
|
// Reset idle counter
|
||||||
mIdleStart.reset();
|
mIdleStart.reset();
|
||||||
@ -445,16 +468,16 @@ void MainWindow::onLongBreakEnd()
|
|||||||
if (!mBreakStartTimer->isActive())
|
if (!mBreakStartTimer->isActive())
|
||||||
{
|
{
|
||||||
mBreakStartTimer->start(std::chrono::seconds(mAppConfig.longbreak_interval));
|
mBreakStartTimer->start(std::chrono::seconds(mAppConfig.longbreak_interval));
|
||||||
qDebug() << get_log_prefix() << "Start main timer for " << mAppConfig.longbreak_interval << " seconds.";
|
qDebug() << "Start main timer for " << mAppConfig.longbreak_interval << " seconds.";
|
||||||
}
|
}
|
||||||
if (!mBreakNotifyTimer->isActive())
|
if (!mBreakNotifyTimer->isActive())
|
||||||
{
|
{
|
||||||
mBreakNotifyTimer->start(std::chrono::seconds(mAppConfig.longbreak_interval - 30));
|
mBreakNotifyTimer->start(std::chrono::seconds(mAppConfig.longbreak_interval - 30));
|
||||||
qDebug() << get_log_prefix() << "Start notify timer for " << mAppConfig.longbreak_interval - 30 << " seconds.";
|
qDebug() << "Start notify timer for " << mAppConfig.longbreak_interval - 30 << " seconds.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play selected audio. When break is postponed - audio is not played
|
// Play selected audio. When break is postponed - audio is not played
|
||||||
if (!mPostponeCount)
|
if (0 == mPostponeCount)
|
||||||
play_audio(mAppConfig.play_audio);
|
play_audio(mAppConfig.play_audio);
|
||||||
|
|
||||||
// Run script
|
// Run script
|
||||||
@ -462,7 +485,7 @@ void MainWindow::onLongBreakEnd()
|
|||||||
{
|
{
|
||||||
int retcode = system(mAppConfig.script_on_break_finish.toStdString().c_str());
|
int retcode = system(mAppConfig.script_on_break_finish.toStdString().c_str());
|
||||||
if (retcode != 0)
|
if (retcode != 0)
|
||||||
qDebug() << get_log_prefix() << "User script exited with error code " << retcode;
|
qDebug() << "User script exited with error code " << retcode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,7 +554,7 @@ void MainWindow::onIdleStart()
|
|||||||
// Stop main & notify timers
|
// Stop main & notify timers
|
||||||
mBreakStartTimer->stop();
|
mBreakStartTimer->stop();
|
||||||
mBreakNotifyTimer->stop();
|
mBreakNotifyTimer->stop();
|
||||||
qDebug() << get_log_prefix() << "Stop main and notify timers. Remaining time is " << mRemainingWorkInterval.value() << "s";
|
qDebug() << "Stop main and notify timers. Remaining time is " << mRemainingWorkInterval.value() << "s";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onIdleEnd()
|
void MainWindow::onIdleEnd()
|
||||||
@ -544,13 +567,13 @@ void MainWindow::onIdleEnd()
|
|||||||
// Update timer(s) duration
|
// Update timer(s) duration
|
||||||
if (mRemainingWorkInterval)
|
if (mRemainingWorkInterval)
|
||||||
{
|
{
|
||||||
qDebug() << get_log_prefix() << "Reset main timer to " << *mRemainingWorkInterval << "s";
|
qDebug() << "Reset main timer to " << *mRemainingWorkInterval << "s";
|
||||||
mBreakStartTimer->setInterval(std::chrono::seconds(*mRemainingWorkInterval));
|
mBreakStartTimer->setInterval(std::chrono::seconds(*mRemainingWorkInterval));
|
||||||
|
|
||||||
if (mRemainingWorkInterval > INTERVAL_NOTIFICATION)
|
if (mRemainingWorkInterval > INTERVAL_NOTIFICATION)
|
||||||
{
|
{
|
||||||
mBreakNotifyTimer->setInterval(std::chrono::seconds(*mRemainingWorkInterval - INTERVAL_NOTIFICATION));
|
mBreakNotifyTimer->setInterval(std::chrono::seconds(*mRemainingWorkInterval - INTERVAL_NOTIFICATION));
|
||||||
qDebug() << get_log_prefix() << "Reset notify timer to " << *mRemainingWorkInterval - INTERVAL_NOTIFICATION << "s";
|
qDebug() << "Reset notify timer to " << *mRemainingWorkInterval - INTERVAL_NOTIFICATION << "s";
|
||||||
}
|
}
|
||||||
mRemainingWorkInterval.reset();
|
mRemainingWorkInterval.reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,12 +53,12 @@ private:
|
|||||||
std::optional<int> mRemainingWorkInterval;
|
std::optional<int> mRemainingWorkInterval;
|
||||||
|
|
||||||
app_settings::config mAppConfig;
|
app_settings::config mAppConfig;
|
||||||
int mPostponeCount;
|
int mPostponeCount = 0;
|
||||||
|
|
||||||
// Time when idle was started
|
// Time when idle was started
|
||||||
std::optional<std::chrono::steady_clock::time_point> mIdleStart;
|
std::optional<std::chrono::steady_clock::time_point> mIdleStart;
|
||||||
|
|
||||||
int mLastIdleMilliseconds;
|
int mLastIdleMilliseconds = 0;
|
||||||
|
|
||||||
AppState mState = AppState::None;
|
AppState mState = AppState::None;
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
QT += core gui svg multimedia
|
QT += core gui svg multimedia widgets dbus
|
||||||
|
|
||||||
CONFIG += debug_and_release
|
CONFIG += debug_and_release console
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets dbus
|
|
||||||
|
|
||||||
CONFIG += c++17 lrelease embed_translations
|
CONFIG += c++17 lrelease embed_translations
|
||||||
|
|
||||||
@ -55,9 +54,8 @@ unix:LIBS += -L/usr/X11R6/lib/ \
|
|||||||
-lX11 -lXext -lXss -ldl
|
-lX11 -lXext -lXss -ldl
|
||||||
|
|
||||||
Debug: DEFINES += DEBUG
|
Debug: DEFINES += DEBUG
|
||||||
|
Release: DEFINES += QT_NO_DEBUG_OUTPUT
|
||||||
|
|
||||||
# When using wayland:
|
# When using wayland:
|
||||||
# unix:LIBS += -L/usr/local/lib \
|
# unix:LIBS += -L/usr/local/lib \
|
||||||
# -lwayland-client-unstable++ -lwayland-client-extra++ -lwayland-client++
|
# -lwayland-client-unstable++ -lwayland-client-extra++ -lwayland-client++
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,8 +27,8 @@ const QString Primary_Monitor = "[Primary]";
|
|||||||
|
|
||||||
// Default behavior is not play any audio on break end.
|
// Default behavior is not play any audio on break end.
|
||||||
const QString Audio_Empty = "None";
|
const QString Audio_Empty = "None";
|
||||||
const QString Audio_Default_1 = "Default 1";
|
const QString Audio_Retro = "Retro";
|
||||||
const QString Audio_Default_2 = "Default 2";
|
const QString Audio_Gagarin = "Gagarin";
|
||||||
const QString Audio_Custom = "Custom...";
|
const QString Audio_Custom = "Custom...";
|
||||||
|
|
||||||
struct audio_item
|
struct audio_item
|
||||||
@ -38,8 +38,8 @@ struct audio_item
|
|||||||
};
|
};
|
||||||
|
|
||||||
const std::map<QString, QString> AudioMap {
|
const std::map<QString, QString> AudioMap {
|
||||||
{Audio_Default_1, ":/assets/sound/alarm-retro.wav"},
|
{Audio_Retro, ":/assets/sound/alarm-retro.wav"},
|
||||||
{Audio_Default_2, ":/assets/sound/alarm-poehali.wav"},
|
{Audio_Gagarin, ":/assets/sound/alarm-poehali.wav"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ public:
|
|||||||
selected_audio play_audio;
|
selected_audio play_audio;
|
||||||
QString script_on_break_finish;
|
QString script_on_break_finish;
|
||||||
|
|
||||||
// Zero means "idle is not tracked"
|
// Zero means "idle is not tracked". Value in seconds.
|
||||||
int idle_timeout = Default_Idle_Timeout;
|
int idle_timeout = Default_Idle_Timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ void SettingsDialog::init()
|
|||||||
ui->mPreferredMonitorCombobox->setCurrentIndex(found_idx);
|
ui->mPreferredMonitorCombobox->setCurrentIndex(found_idx);
|
||||||
|
|
||||||
// Fill audio combo box
|
// Fill audio combo box
|
||||||
auto audios = {Audio_Empty, Audio_Default_1, Audio_Default_2, Audio_Custom};
|
auto audios = {Audio_Empty, Audio_Retro, Audio_Gagarin, Audio_Custom};
|
||||||
ui->mAudioComboBox->addItems(audios);
|
ui->mAudioComboBox->addItems(audios);
|
||||||
mCustomAudioIdx = audios.size() - 1;
|
mCustomAudioIdx = audios.size() - 1;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ void SettingsDialog::init()
|
|||||||
connect(ui->mAudioComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onAudioIndexChanged(int)));
|
connect(ui->mAudioComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onAudioIndexChanged(int)));
|
||||||
|
|
||||||
// Idle timeout
|
// Idle timeout
|
||||||
ui->mIdleTimeoutSpinbox->setValue(c.idle_timeout);
|
ui->mIdleTimeoutSpinbox->setValue(c.idle_timeout / 60);
|
||||||
|
|
||||||
mSkipAudioChangeEvent = false;
|
mSkipAudioChangeEvent = false;
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ void SettingsDialog::accept()
|
|||||||
if (c.play_audio.name == Audio_Custom)
|
if (c.play_audio.name == Audio_Custom)
|
||||||
c.play_audio.path = mCustomAudioPath;
|
c.play_audio.path = mCustomAudioPath;
|
||||||
|
|
||||||
c.idle_timeout = ui->mIdleTimeoutSpinbox->value();
|
c.idle_timeout = ui->mIdleTimeoutSpinbox->value() * 60;
|
||||||
app_settings::save(c);
|
app_settings::save(c);
|
||||||
|
|
||||||
emit accepted();
|
emit accepted();
|
||||||
|
|||||||
@ -131,7 +131,7 @@
|
|||||||
<item row="9" column="0">
|
<item row="9" column="0">
|
||||||
<widget class="QLabel" name="label_8">
|
<widget class="QLabel" name="label_8">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Command to run when break finish</string>
|
<string>Shell command to run when break finish</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
# I use this script on two different hosts so there are logic to find proper Qt installation
|
# I use this script on two different hosts so there are logic to find proper Qt installation
|
||||||
|
|
||||||
export QT_HOME=/home/$USER/qt5.15/5.15.2/gcc_64
|
export QT_HOME=/home/$USER/tools/qt/5.15.2/gcc_64
|
||||||
if [ ! -d "$QT_HOME" ] ; then
|
if [ ! -d "$QT_HOME" ] ; then
|
||||||
export QT_HOME=/home/$USER/qt5.15/5.15.2/gcc_64
|
export QT_HOME=/home/$USER/tools/qt/5.15.2/gcc_64
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build .appimage
|
# Build .appimage
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
# I use this script on two different hosts so there are logic to find proper Qt installation
|
# I use this script on two different hosts so there are logic to find proper Qt installation
|
||||||
|
|
||||||
export QT_HOME=/home/$USER/qt5.15/5.15.2/gcc_64
|
export QT_HOME=/home/$USER/tools/qt/5.15.2/gcc_64
|
||||||
if [ ! -d "$QT_HOME" ] ; then
|
if [ ! -d "$QT_HOME" ] ; then
|
||||||
export QT_HOME=/home/$USER/qt5.15/5.15.2/gcc_64
|
export QT_HOME=/home/$USER/qt/5.15.2/gcc_64
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build .appimage
|
# Build .appimage
|
||||||
|
|||||||
12
scripts/build_linux_qt6.sh
Executable file
12
scripts/build_linux_qt6.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# I use this script on two different hosts so there are logic to find proper Qt installation
|
||||||
|
|
||||||
|
export QT_HOME=/home/$USER/tools/qt/6.8.0/gcc_64
|
||||||
|
if [ ! -d "$QT_HOME" ] ; then
|
||||||
|
export QT_HOME=/home/$USER/tools/qt/6.8.0/gcc_64
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build .appimage
|
||||||
|
/usr/bin/python3 build_qbreak.py release
|
||||||
|
|
||||||
12
scripts/build_linux_qt6_debug.sh
Executable file
12
scripts/build_linux_qt6_debug.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# I use this script on two different hosts so there are logic to find proper Qt installation
|
||||||
|
|
||||||
|
export QT_HOME=/home/$USER/tools/qt/6.8.0/gcc_64
|
||||||
|
if [ ! -d "$QT_HOME" ] ; then
|
||||||
|
export QT_HOME=/home/$USER/tools/qt/6.8.0/gcc_64
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build .appimage
|
||||||
|
/usr/bin/python3 build_qbreak.py debug
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ if platform.system() == 'Linux':
|
|||||||
'-qmake=' + os.environ['QT_HOME'] + '/bin/qmake',
|
'-qmake=' + os.environ['QT_HOME'] + '/bin/qmake',
|
||||||
'-unsupported-allow-new-glibc',
|
'-unsupported-allow-new-glibc',
|
||||||
#'-no-translations',
|
#'-no-translations',
|
||||||
'-extra-plugins=iconengines,platformthemes/libqgtk3.so'
|
'-extra-plugins=iconengines,platformthemes/libqgtk3.so,platforms/libqxcb.so'
|
||||||
]
|
]
|
||||||
|
|
||||||
desktop_path = 'appimage_dir/usr/share/applications/qbreak.desktop'
|
desktop_path = 'appimage_dir/usr/share/applications/qbreak.desktop'
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user