diff --git a/README.md b/README.md index 320ec8f..3347cdb 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,15 @@ Redmine Time Tracker RedTimer is an easy-to-use platform-independent time tracker which allows the user to track time while working on an issue. +Usage +----- + +Usually, you can start the RedTimer executable from your file manager. After closing, RedTimer will create a +settings file called `RedTimer.ini` in your current working directory. + +If you experience problems with the system tray icon, e.g. on Linux, you can deactivate the system tray icon +by calling `RedTimer --no-tray-icon`. + Installation instructions ------------------------- diff --git a/RedTimer.cpp b/RedTimer.cpp index b416ade..119f7e0 100644 --- a/RedTimer.cpp +++ b/RedTimer.cpp @@ -9,9 +9,10 @@ using namespace qtredmine; using namespace redtimer; using namespace std; -RedTimer::RedTimer( QApplication* parent ) +RedTimer::RedTimer( QApplication* parent, bool trayIcon ) : QObject( parent ), - app_( parent ) + app_( parent ), + showTrayIcon_( trayIcon ) { ENTER(); init(); @@ -152,7 +153,7 @@ RedTimer::initTrayIcon() { ENTER(); - if( QSystemTrayIcon::isSystemTrayAvailable() ) + if( showTrayIcon_ && QSystemTrayIcon::isSystemTrayAvailable() ) { trayIcon_ = new QSystemTrayIcon( win_ ); trayIcon_->setIcon( QIcon(":/icons/clock_red.svg") ); diff --git a/RedTimer.h b/RedTimer.h index 88310a4..2182955 100644 --- a/RedTimer.h +++ b/RedTimer.h @@ -52,8 +52,11 @@ class RedTimer : public QObject /// Main item object QQuickItem* item_; + /// Show the system tray icon + bool showTrayIcon_; + /// System tray icon - QSystemTrayIcon* trayIcon_; + QSystemTrayIcon* trayIcon_ = nullptr; /// Timer for stopping the worked on time QTimer* timer_; @@ -112,8 +115,9 @@ class RedTimer : public QObject * @brief RedTimer constructor * * @param parent Parent QObject + * @param trayIcon Show tray icon */ - explicit RedTimer( QApplication* parent = nullptr ); + explicit RedTimer( QApplication* parent = nullptr, bool trayIcon = true ); /** * @brief Destructor diff --git a/main.cpp b/main.cpp index c2794ed..6ffbf64 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,7 @@ #include "RedTimer.h" #include <QApplication> +#include <QCommandLineParser> #include <memory> @@ -10,10 +11,26 @@ using namespace std; int main(int argc, char* argv[]) { QApplication app( argc, argv ); + QApplication::setApplicationName( "RedTimer" ); + QApplication::setApplicationVersion( "0.0.4" ); + + // Command line options + QCommandLineParser parser; + parser.setApplicationDescription( "Redmine Time Tracker" ); + parser.addHelpOption(); + parser.addVersionOption(); + + // Disable tray icon + QCommandLineOption noTrayOption( QStringList() << "no-tray-icon", + QApplication::translate("main", "Do not provide a tray icon.") ); + parser.addOption( noTrayOption ); + + // Process command line options + parser.process( app ); app.setWindowIcon( QIcon(":/icons/clock_red.svg") ); - new RedTimer( &app ); + new RedTimer( &app, !parser.isSet(noTrayOption) ); return app.exec(); }