Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c48fe5f38 | |||
| 61ef94b474 | |||
| aba5e21271 | |||
| 76a63b29c2 | |||
| 37840dfdb1 | |||
| 9ff378d5e0 | |||
| 317b7097f6 | |||
| 64658a7778 |
@ -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 13
|
#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 (15)
|
#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
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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()
|
||||||
@ -128,11 +149,11 @@ static int str_to_seconds(const QString& s)
|
|||||||
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();
|
||||||
@ -218,7 +239,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
|
||||||
@ -264,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)
|
||||||
@ -292,6 +315,7 @@ QString state2str(AppState state)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::shiftTo(AppState newState)
|
void MainWindow::shiftTo(AppState newState)
|
||||||
{
|
{
|
||||||
if (newState == mState)
|
if (newState == mState)
|
||||||
@ -324,7 +348,11 @@ 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 +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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
@ -60,5 +59,3 @@ 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++
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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