diff --git a/client/helper.cpp b/client/helper.cpp index 5284b8d..9a8c213 100644 --- a/client/helper.cpp +++ b/client/helper.cpp @@ -271,7 +271,7 @@ bool activityTracker::ensureSmartTrackingIsPossible() if (!result && QSysInfo::MacintoshVersion <= QSysInfo::MV_10_8) { QMessageBox msgbox(QMessageBox::Question, QT_TR_NOOP("Permission required"), - QT_TR_NOOP("To use smart time tracking Litt needs access to OS X accessibility features.\ + QT_TR_NOOP("To use smart time tracking Noo needs access to OS X accessibility features.\ Please grant access in Security & Privacy preferences, location in System Preferences."), QMessageBox::NoButton, nullptr); msgbox.addButton(QT_TR_NOOP("Open System Preferences"), QMessageBox::AcceptRole); diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 24ff9c5..615f1a7 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -33,6 +33,9 @@ #include "connectdb_widget.h" #include "openorcreatedb_widget.h" #include "qtkeychain/keychain.h" +#if defined(TARGET_LINUX) +# include "platforms/linux/autostart.h" +#endif #include #include @@ -49,24 +52,15 @@ MainWindow::MainWindow(QWidget *parent) : { mSettings = QSharedPointer(new Settings()); + // Dark theme if needed helper::theme::applyCurrent(*mSettings); - mAttachmentsAction = nullptr; - mAttachmentsLabel = nullptr; - - this->setUpdatesEnabled(false); - - mDuplicationSignalLabel = nullptr; - mCurrentIntervalLabel = nullptr; - mTrayIcon = nullptr; - - QCoreApplication::setApplicationName(APPNAME); - + // Restore window size & position from last run + setUpdatesEnabled(false); loadGeometry(); + setUpdatesEnabled(true); - this->setUpdatesEnabled(true); - - // init event + // Other initialization will run in next event loop iteration QApplication::postEvent(this, new ClientEvent()); } @@ -402,6 +396,7 @@ void MainWindow::customEvent(QEvent *ev) } case static_cast(UiInitId): + setupAppMenu(); setupMainUi(); loadGeometry(); break; @@ -445,8 +440,8 @@ void MainWindow::preferences() if (mSettings->data()[KEY_SHOW_TRAY_ICON].toBool() && !mTrayIcon && QSystemTrayIcon::isSystemTrayAvailable()) initTrayIcon(); else - if (!mSettings->data()[KEY_SHOW_TRAY_ICON].toBool() && mTrayIcon) - removeTrayIcon(); + if (!mSettings->data()[KEY_SHOW_TRAY_ICON].toBool() && mTrayIcon) + removeTrayIcon(); updateData(); } @@ -1336,7 +1331,7 @@ void MainWindow::showTimeForTrackingTask() if (mTrayIcon) { - QString tooltip = tr("Litt is tracking ") + mCurrentTask->title() + ".\n" + + QString tooltip = tr("Noo is tracking ") + mCurrentTask->title() + ".\n" + tr("Time spent today for this task is ") + timeString; mTrayIcon->setToolTip(tooltip); @@ -1351,7 +1346,7 @@ void MainWindow::initTrayIcon() mTrayIcon = new QSystemTrayIcon(); connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); updateTrayIcon(Tray_ShowMessage); - + mTrayIcon->setIcon(getAppIcon()); mTrayIcon->setVisible(true); } } @@ -1376,33 +1371,33 @@ void MainWindow::updateTrayIcon(TrayShowMessage flag) bool showSeconds = mSettings->data()[KEY_SHOW_SECONDS].toBool(); int spentSecondsToday = mCurrentTask->timeline()->today(); QString timeString = QString::fromStdString(helper::chrono::secondsToDisplay(spentSecondsToday, showSeconds)); - tooltip = tr("Litt is tracking ") + mCurrentTask->title() + ".\n" + + tooltip = tr("Noo is tracking ") + mCurrentTask->title() + ".\n" + tr("Time spent today for this task is ") + timeString; } else { - tooltip = tr("Litt is not tracking now."); + tooltip = tr("Noo is not tracking now."); } mTrayIcon->setToolTip(tooltip); if (mCurrentTask) { - QIcon icon(TRAY_RUNNING_ICON_NAME); + /*QIcon icon(TRAY_RUNNING_ICON_NAME); #if defined(TARGET_OSX) icon.setIsMask(true); #endif - mTrayIcon->setIcon(icon); + mTrayIcon->setIcon(icon);*/ if (flag == Tray_ShowMessage) mTrayIcon->showMessage(tr("Time tracking started"), mCurrentTask->path()); } else { - QIcon icon(TRAY_DEFAULT_ICON_NAME); + /*QIcon icon(TRAY_DEFAULT_ICON_NAME); #if defined(TARGET_OSX) icon.setIsMask(true); #endif - mTrayIcon->setIcon(icon); + mTrayIcon->setIcon(icon);*/ } } @@ -1613,6 +1608,13 @@ void MainWindow::showMainWindow() #endif } +void MainWindow::setupAppMenu() +{ +#if defined(TARGET_LINUX) + appmenu::install(QCoreApplication::applicationFilePath().toStdString()); +#endif +} + void MainWindow::continueOnIdle() { // Disable idle detection at all - it is not needed in this session anymore diff --git a/client/mainwindow.h b/client/mainwindow.h index 883f642..6aad7d4 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -64,7 +64,7 @@ private: QLabel* mDuplicationSignalLabel = nullptr;; QSystemTrayIcon *mTrayIcon = nullptr; QSharedPointer mSettings; - bool mPasswordFailed; + bool mPasswordFailed = false; PasswordDlg* mPasswordDlg = nullptr; NewPasswordDlg* mNewPasswordDlg = nullptr; QMessageBox* mAlertBox = nullptr; @@ -73,7 +73,7 @@ private: QDateTime mLastTimelineFlush; // Attachments action - QAction* mAttachmentsAction; + QAction* mAttachmentsAction = nullptr; // Attachments label QLabel* mAttachmentsLabel = nullptr; @@ -161,6 +161,8 @@ private: void buildOpenOrCreateView(); void buildMainView(); + void setupAppMenu(); + void onDatabaseAvailable(); signals: void onTimeFormatChanged(); diff --git a/client/noo.pro b/client/noo.pro index 52e10ef..2ce10df 100644 --- a/client/noo.pro +++ b/client/noo.pro @@ -72,6 +72,8 @@ SOURCES += main.cpp \ timereportwizard.cpp \ platforms/hidtracker.cpp \ platforms/hidtrackerimpl.cpp \ + platforms/linux/autostart.cpp \ + platforms/linux/idle_tracking.cpp \ logger.cpp \ timeintervaldlg.cpp \ aboutdlg.cpp \ @@ -84,7 +86,9 @@ SOURCES += main.cpp \ startworkdialog.cpp \ twofish.cpp \ openorcreatedb_widget.cpp \ - connectdb_widget.cpp + connectdb_widget.cpp \ + runguard.cpp \ + HEADERS += mainwindow.h \ storage.h \ @@ -113,6 +117,8 @@ HEADERS += mainwindow.h \ sqlite3ext.h \ platforms/hidtracker.h \ platforms/hidtrackerimpl.h \ + platforms/linux/autostart.h \ + platforms/linux/idle_tracking.h \ logger.h \ timeintervaldlg.h \ aboutdlg.h \ @@ -125,7 +131,8 @@ HEADERS += mainwindow.h \ startworkdialog.h \ twofish.h \ openorcreatedb_widget.h \ - connectdb_widget.h + connectdb_widget.h \ + runguard.h macx { HEADERS += platforms/osx/hidtrackerimpl_osx.h diff --git a/client/openorcreatedb_widget.cpp b/client/openorcreatedb_widget.cpp index 1e077ae..13ff097 100644 --- a/client/openorcreatedb_widget.cpp +++ b/client/openorcreatedb_widget.cpp @@ -45,7 +45,7 @@ void OpenOrCreateDbWidget::handleEnteredPasswords() void OpenOrCreateDbWidget::askForDatabase() { - QString path = QFileDialog::getOpenFileName(this, "Please select existing database", QString(), "*.litt"); + QString path = QFileDialog::getOpenFileName(this, "Please select existing database", QString(), "*.noo"); if (path.size()) { mDbPath = path; diff --git a/client/resources/qdarkstyle/dark/style.qrc b/client/resources/qdarkstyle/dark/style.qrc index ce0d85b..29e2c93 100644 --- a/client/resources/qdarkstyle/dark/style.qrc +++ b/client/resources/qdarkstyle/dark/style.qrc @@ -211,6 +211,6 @@ rc/window_undock_pressed@2x.png - darkstyle.qss + style.qss diff --git a/client/settings.h b/client/settings.h index 14dd6f0..bd0174d 100644 --- a/client/settings.h +++ b/client/settings.h @@ -43,6 +43,7 @@ #define KEY_DARK_THEME "DarkTheme" #define KEY_ASK_BEFORE_DELETE "AskBeforeDelete" + class Settings { public: