- version 0.1.8 - new state machine + fix problems with desktop file.
This commit is contained in:
parent
f1ca3ed0ed
commit
fff67bbedb
@ -13,6 +13,9 @@ AboutDlg::AboutDlg(QWidget *parent) :
|
|||||||
.arg(QBREAK_VERSION_MAJOR)
|
.arg(QBREAK_VERSION_MAJOR)
|
||||||
.arg(QBREAK_VERSION_MINOR)
|
.arg(QBREAK_VERSION_MINOR)
|
||||||
.arg(QBREAK_VERSION_SUFFIX);
|
.arg(QBREAK_VERSION_SUFFIX);
|
||||||
|
#if defined(DEBUG)
|
||||||
|
version_text += ". Debug build.";
|
||||||
|
#endif
|
||||||
ui->mAppVersionLabel->setText(version_text);
|
ui->mAppVersionLabel->setText(version_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -98,8 +98,21 @@ static fs::path appmenu_install_dir()
|
|||||||
|
|
||||||
void appmenu::install(const std::string& path_to_me)
|
void appmenu::install(const std::string& path_to_me)
|
||||||
{
|
{
|
||||||
|
auto path_to_desktop = appmenu_install_dir() / QBREAK_DESKTOP_NAME;
|
||||||
|
|
||||||
|
// Check if app is installed already.
|
||||||
|
// The code below checks for path to app; as this app is distributed as .AppImage with version numbers - every new version will trigger desktop file rewriting
|
||||||
|
std::ifstream ifs(path_to_desktop);
|
||||||
|
std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
||||||
|
if (content.find(path_to_me) != std::string::npos)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Remove old one
|
||||||
|
std::string uninstall_cmd = "/usr/bin/xdg-desktop-menu uninstall --novendor " + path_to_desktop.string();
|
||||||
|
system(uninstall_cmd.c_str());
|
||||||
|
|
||||||
// Put .desktop file to ~/.config/autostart
|
// Put .desktop file to ~/.config/autostart
|
||||||
std::ofstream ofs(appmenu_install_dir() / QBREAK_DESKTOP_NAME);
|
std::ofstream ofs(path_to_desktop);
|
||||||
if (ofs.is_open())
|
if (ofs.is_open())
|
||||||
{
|
{
|
||||||
ofs << fixup_desktop_file(read_desktop_file(), path_to_me);
|
ofs << fixup_desktop_file(read_desktop_file(), path_to_me);
|
||||||
@ -125,6 +138,9 @@ void appmenu::install(const std::string& path_to_me)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string install_cmd = "/usr/bin/xdg-desktop-menu install --novendor " + path_to_desktop.string();
|
||||||
|
system(install_cmd.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void appmenu::uninstall()
|
void appmenu::uninstall()
|
||||||
|
|||||||
@ -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 6
|
#define QBREAK_VERSION_SUFFIX 8
|
||||||
|
|
||||||
// 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 (60)
|
||||||
|
|||||||
@ -39,7 +39,12 @@ int main(int argc, char *argv[])
|
|||||||
parser.process(app);
|
parser.process(app);
|
||||||
|
|
||||||
// Put itself into app menu
|
// Put itself into app menu
|
||||||
appmenu::install(QFileInfo(argv[0]).absoluteFilePath().toStdString());
|
auto exe_path = QFileInfo(QCoreApplication::arguments().front()).absoluteFilePath();
|
||||||
|
const char* appimage = std::getenv("APPIMAGE");
|
||||||
|
if (appimage != nullptr)
|
||||||
|
exe_path = appimage;
|
||||||
|
|
||||||
|
appmenu::install(exe_path.toStdString());
|
||||||
|
|
||||||
// Main window is full screen window, so start with tray icon only
|
// Main window is full screen window, so start with tray icon only
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
|||||||
@ -11,6 +11,15 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
|
|
||||||
|
// Possible app states
|
||||||
|
enum class AppState
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Counting,
|
||||||
|
Idle,
|
||||||
|
Break
|
||||||
|
};
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@ -31,25 +40,28 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QTimer* mTimer;
|
QTimer* mMainTimer;
|
||||||
QTimer* mNotifyTimer;
|
QTimer* mNotifyTimer;
|
||||||
QTimer* mShowNotifyTimer;
|
|
||||||
QTimer* mUpdateUITimer;
|
QTimer* mUpdateUITimer;
|
||||||
QTimer* mProgressTimer;
|
QTimer* mProgressTimer;
|
||||||
QSystemTrayIcon* mTrayIcon;
|
QSystemTrayIcon* mTrayIcon;
|
||||||
SettingsDialog* mSettingsDialog;
|
SettingsDialog* mSettingsDialog;
|
||||||
|
|
||||||
std::chrono::steady_clock::time_point mBreakStartTime;
|
std::chrono::steady_clock::time_point mBreakStartTime;
|
||||||
|
|
||||||
|
// How much seconds remains for main break
|
||||||
|
int mWorkInterval = -1;
|
||||||
|
|
||||||
app_settings::config mAppConfig;
|
app_settings::config mAppConfig;
|
||||||
int mPostponeCount;
|
int mPostponeCount;
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
// Time remaining in main timer
|
|
||||||
int mIdleRemaining;
|
|
||||||
|
|
||||||
int mLastIdleMilliseconds;
|
int mLastIdleMilliseconds;
|
||||||
|
|
||||||
|
AppState mState = AppState::None;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void loadConfig();
|
void loadConfig();
|
||||||
void applyConfig();
|
void applyConfig();
|
||||||
@ -63,6 +75,9 @@ private:
|
|||||||
QIcon getAppIcon();
|
QIcon getAppIcon();
|
||||||
QIcon getTrayIcon();
|
QIcon getTrayIcon();
|
||||||
|
|
||||||
|
// Function to switch state
|
||||||
|
void shiftTo(AppState state);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onUpdateUI();
|
void onUpdateUI();
|
||||||
void onLongBreakNotify();
|
void onLongBreakNotify();
|
||||||
|
|||||||
@ -52,6 +52,8 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
|||||||
unix:LIBS += -L/usr/X11R6/lib/ \
|
unix:LIBS += -L/usr/X11R6/lib/ \
|
||||||
-lX11 -lXext -lXss -ldl
|
-lX11 -lXext -lXss -ldl
|
||||||
|
|
||||||
|
debug: DEFINES += DEBUG
|
||||||
|
|
||||||
# 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/qt/5.12.10/gcc_64
|
export QT_HOME=/home/$USER/qt5.15/5.15.2/gcc_64
|
||||||
if [ ! -d "$QT_HOME" ] ; then
|
if [ ! -d "$QT_HOME" ] ; then
|
||||||
export QT_HOME=/home/$USER/qt5/5.12.12/gcc_64
|
export QT_HOME=/home/$USER/qt5.15/5.15.2/gcc_64
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build .appimage
|
# Build .appimage
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user