Add consts arguments
This commit is contained in:
parent
ccc210e989
commit
328600b777
@ -10,30 +10,26 @@ CircularProgressBar::CircularProgressBar(QWidget *parent)
|
||||
setFixedSize(220, 220);
|
||||
}
|
||||
|
||||
void CircularProgressBar::setValue(int value)
|
||||
{
|
||||
int clampedValue = qBound(0, value, m_maximum);
|
||||
if (clampedValue != m_value) {
|
||||
void CircularProgressBar::setValue(const int value) {
|
||||
if (const int clampedValue = qBound(0, value, m_maximum); clampedValue != m_value) {
|
||||
m_value = clampedValue;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void CircularProgressBar::setMaximum(int maximum)
|
||||
{
|
||||
void CircularProgressBar::setMaximum(int maximum){
|
||||
m_maximum = maximum;
|
||||
update();
|
||||
}
|
||||
|
||||
void CircularProgressBar::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
void CircularProgressBar::paintEvent(QPaintEvent *event){
|
||||
Q_UNUSED(event)
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
int side = qMin(width(), height());
|
||||
QRect rect((width() - side) / 2 + 20, (height() - side) / 2 + 20,
|
||||
const int side = qMin(width(), height());
|
||||
const QRect rect((width() - side) / 2 + 20, (height() - side) / 2 + 20,
|
||||
side - 40, side - 40);
|
||||
|
||||
// Background circle
|
||||
@ -48,19 +44,17 @@ void CircularProgressBar::paintEvent(QPaintEvent *event)
|
||||
progressPen.setCapStyle(Qt::RoundCap);
|
||||
painter.setPen(progressPen);
|
||||
|
||||
int angle = (360 * m_value) / m_maximum;
|
||||
const int angle = (360 * m_value) / m_maximum;
|
||||
painter.drawArc(rect, 90 * 16, -angle * 16);
|
||||
}
|
||||
}
|
||||
|
||||
void CircularProgressBar::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
void CircularProgressBar::resizeEvent(QResizeEvent *event){
|
||||
QWidget::resizeEvent(event);
|
||||
updateChildPositions();
|
||||
}
|
||||
|
||||
void CircularProgressBar::updateChildPositions()
|
||||
{
|
||||
void CircularProgressBar::updateChildPositions() const {
|
||||
const auto children = findChildren<QWidget*>(QString(), Qt::FindDirectChildrenOnly);
|
||||
for (QWidget *child : children) {
|
||||
child->resize(width(), 40);
|
||||
|
||||
@ -3,8 +3,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class CircularProgressBar : public QWidget
|
||||
{
|
||||
class CircularProgressBar final : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -12,8 +11,8 @@ public:
|
||||
|
||||
void setValue(int value);
|
||||
void setMaximum(int maximum);
|
||||
int value() const { return m_value; }
|
||||
int maximum() const { return m_maximum; }
|
||||
[[nodiscard]] int value() const { return m_value; }
|
||||
[[nodiscard]] int maximum() const { return m_maximum; }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
@ -23,7 +22,7 @@ private:
|
||||
int m_value;
|
||||
int m_maximum;
|
||||
|
||||
void updateChildPositions();
|
||||
void updateChildPositions() const;
|
||||
};
|
||||
|
||||
#endif // CIRCULARPROGRESSBAR_H
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include <QWidget>
|
||||
|
||||
KeyboardShortcuts::KeyboardShortcuts(QWidget *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
setupShortcuts(parent);
|
||||
KeyboardShortcuts::KeyboardShortcuts(QWidget *parent) : QObject(parent) {
|
||||
setupShortcuts(parent);
|
||||
}
|
||||
KeyboardShortcuts::~KeyboardShortcuts() = default;
|
||||
|
||||
void KeyboardShortcuts::setupShortcuts(QWidget *parent)
|
||||
{
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#ifndef KEYBOARDSHORTCUTS_H
|
||||
#define KEYBOARDSHORTCUTS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QShortcut>
|
||||
|
||||
class KeyboardShortcuts : public QObject
|
||||
@ -10,7 +9,7 @@ class KeyboardShortcuts : public QObject
|
||||
|
||||
public:
|
||||
explicit KeyboardShortcuts(QWidget *parent = nullptr);
|
||||
~KeyboardShortcuts() = default;
|
||||
~KeyboardShortcuts() override;
|
||||
|
||||
signals:
|
||||
void startPauseRequested();
|
||||
@ -22,11 +21,11 @@ signals:
|
||||
private:
|
||||
void setupShortcuts(QWidget *parent);
|
||||
|
||||
QShortcut *m_startShortcut;
|
||||
QShortcut *m_pauseShortcut;
|
||||
QShortcut *m_resetShortcut;
|
||||
QShortcut *m_settingsShortcut;
|
||||
QShortcut *m_skipShortcut;
|
||||
QShortcut *m_startShortcut{};
|
||||
QShortcut *m_pauseShortcut{};
|
||||
QShortcut *m_resetShortcut{};
|
||||
QShortcut *m_settingsShortcut{};
|
||||
QShortcut *m_skipShortcut{};
|
||||
};
|
||||
|
||||
#endif // KEYBOARDSHORTCUTS_H
|
||||
|
||||
@ -4,12 +4,9 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
NotificationManager::NotificationManager(QWidget *parent)
|
||||
: QObject(parent)
|
||||
, m_parent(parent)
|
||||
, m_trayManager(nullptr)
|
||||
, m_notificationsEnabled(true)
|
||||
{
|
||||
}
|
||||
: QObject(parent), m_parent(parent), m_trayManager(nullptr),
|
||||
m_notificationsEnabled(true) {}
|
||||
NotificationManager::~NotificationManager() {}
|
||||
|
||||
void NotificationManager::setSystemTrayManager(SystemTrayManager *trayManager)
|
||||
{
|
||||
@ -21,8 +18,7 @@ void NotificationManager::setNotificationsEnabled(bool enabled)
|
||||
m_notificationsEnabled = enabled;
|
||||
}
|
||||
|
||||
void NotificationManager::showNotification(const QString &message)
|
||||
{
|
||||
void NotificationManager::showNotification(const QString &message) const {
|
||||
if (!m_notificationsEnabled) return;
|
||||
|
||||
if (m_trayManager && m_trayManager->isVisible()) {
|
||||
|
||||
@ -13,11 +13,11 @@ class NotificationManager : public QObject
|
||||
|
||||
public:
|
||||
explicit NotificationManager(QWidget *parent = nullptr);
|
||||
~NotificationManager() = default;
|
||||
~NotificationManager() override;
|
||||
|
||||
void setSystemTrayManager(SystemTrayManager *trayManager);
|
||||
void setNotificationsEnabled(bool enabled);
|
||||
void showNotification(const QString &message);
|
||||
void showNotification(const QString &message) const;
|
||||
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
|
||||
@ -8,10 +8,8 @@
|
||||
#include "TimerState.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCloseEvent>
|
||||
#include <QDateTime>
|
||||
#include <QFont>
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QSettings>
|
||||
#include <QVBoxLayout>
|
||||
@ -104,8 +102,8 @@ void PomodoroTimer::createButtons()
|
||||
m_statsButton = new QPushButton("Statistics", m_mainFrame);
|
||||
|
||||
// Set button sizes
|
||||
const QSize mainButtonSize(MAIN_BUTTON_WIDTH, MAIN_BUTTON_HEIGHT);
|
||||
const QSize smallButtonSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
|
||||
constexpr QSize mainButtonSize(MAIN_BUTTON_WIDTH, MAIN_BUTTON_HEIGHT);
|
||||
constexpr QSize smallButtonSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
|
||||
|
||||
m_startButton->setFixedSize(mainButtonSize);
|
||||
m_pauseButton->setFixedSize(mainButtonSize);
|
||||
@ -165,8 +163,7 @@ void PomodoroTimer::createLayouts()
|
||||
setLayout(frameLayout);
|
||||
}
|
||||
|
||||
void PomodoroTimer::applyStyles()
|
||||
{
|
||||
void PomodoroTimer::applyStyles() const {
|
||||
QFont timeFont = m_timeLabel->font();
|
||||
timeFont.setPointSize(TIME_FONT_SIZE);
|
||||
timeFont.setBold(true);
|
||||
@ -325,13 +322,14 @@ void PomodoroTimer::updateTimerState(TimerState newState)
|
||||
m_currentState = newState;
|
||||
}
|
||||
|
||||
QString PomodoroTimer::formatTime(int seconds) const
|
||||
{
|
||||
const int minutes = seconds / 60;
|
||||
const int secs = seconds % 60;
|
||||
return QString("%1:%2").arg(minutes, 2, 10, QChar('0'))
|
||||
.arg(secs, 2, 10, QChar('0'));
|
||||
QString PomodoroTimer::formatTime(int seconds) {
|
||||
const int minutes = seconds / 60;
|
||||
const int secs = seconds % 60;
|
||||
return QString("%1:%2")
|
||||
.arg(minutes, 2, 10, QChar('0'))
|
||||
.arg(secs, 2, 10, QChar('0'));
|
||||
}
|
||||
void PomodoroTimer::needsDisplayUpdate() {}
|
||||
|
||||
void PomodoroTimer::updateDisplay()
|
||||
{
|
||||
@ -350,16 +348,14 @@ void PomodoroTimer::updateDisplay()
|
||||
currentSession, SESSIONS_BEFORE_LONG_BREAK);
|
||||
}
|
||||
|
||||
void PomodoroTimer::updateSessionCounter()
|
||||
{
|
||||
void PomodoroTimer::updateSessionCounter() const {
|
||||
const int currentSession = (m_completedSessions % SESSIONS_BEFORE_LONG_BREAK) + 1;
|
||||
m_sessionLabel->setText(QString("Session %1 of %2")
|
||||
.arg(currentSession)
|
||||
.arg(SESSIONS_BEFORE_LONG_BREAK));
|
||||
}
|
||||
|
||||
void PomodoroTimer::updateButtonStates()
|
||||
{
|
||||
void PomodoroTimer::updateButtonStates() const {
|
||||
m_startButton->setEnabled(!m_isRunning);
|
||||
m_pauseButton->setEnabled(m_isRunning);
|
||||
|
||||
@ -377,21 +373,22 @@ void PomodoroTimer::updateButtonStates()
|
||||
}
|
||||
}
|
||||
|
||||
void PomodoroTimer::updateWindowTitle()
|
||||
{
|
||||
const QString timeRemaining = formatTime(m_currentTime);
|
||||
const QString emoji = TimerStateHelper::getStateEmoji(m_currentState);
|
||||
void PomodoroTimer::updateWindowTitle() {
|
||||
const QString timeRemaining = formatTime(m_currentTime);
|
||||
const QString emoji = TimerStateHelper::getStateEmoji(m_currentState);
|
||||
|
||||
QString title;
|
||||
if (m_isRunning) {
|
||||
const QString stateText = (m_currentState == TimerState::Work) ? "Focus" : "Break";
|
||||
title = QString("%1 %2: %3").arg(emoji, stateText, timeRemaining);
|
||||
} else {
|
||||
title = "🍅 Pomodoro Timer";
|
||||
}
|
||||
QString title;
|
||||
if (m_isRunning) {
|
||||
const QString stateText =
|
||||
(m_currentState == TimerState::Work) ? "Focus" : "Break";
|
||||
title = QString("%1 %2: %3").arg(emoji, stateText, timeRemaining);
|
||||
} else {
|
||||
title = "🍅 Pomodoro Timer";
|
||||
}
|
||||
|
||||
setWindowTitle(title);
|
||||
setWindowTitle(title);
|
||||
}
|
||||
void PomodoroTimer::updateTrayTooltip() {}
|
||||
|
||||
void PomodoroTimer::onShowSettings()
|
||||
{
|
||||
@ -459,8 +456,7 @@ void PomodoroTimer::loadSettings()
|
||||
m_totalBreakTime = settings.value("totalBreakTime", 0).toInt();
|
||||
}
|
||||
|
||||
void PomodoroTimer::saveSettings()
|
||||
{
|
||||
void PomodoroTimer::saveSettings() const {
|
||||
QSettings settings;
|
||||
settings.setValue("workDuration", m_workDuration);
|
||||
settings.setValue("shortBreakDuration", m_shortBreakDuration);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#ifndef POMODOROTIMER_H
|
||||
#define POMODOROTIMER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
@ -61,11 +60,11 @@ private:
|
||||
void createLabels();
|
||||
void createButtons();
|
||||
void createLayouts();
|
||||
void applyStyles();
|
||||
void applyStyles() const;
|
||||
|
||||
// Settings management
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
void saveSettings() const;
|
||||
|
||||
// Timer state management
|
||||
void resetTimerState();
|
||||
@ -73,14 +72,14 @@ private:
|
||||
|
||||
// Display update methods - optimized to avoid unnecessary updates
|
||||
void updateDisplay();
|
||||
void updateSessionCounter();
|
||||
void updateButtonStates();
|
||||
void updateSessionCounter() const;
|
||||
void updateButtonStates() const;
|
||||
void updateWindowTitle();
|
||||
void updateTrayTooltip();
|
||||
static void updateTrayTooltip();
|
||||
|
||||
// Utility methods
|
||||
QString formatTime(int seconds) const;
|
||||
bool needsDisplayUpdate() const;
|
||||
static QString formatTime(int seconds);
|
||||
static void needsDisplayUpdate();
|
||||
|
||||
// UI elements - use raw pointers for Qt objects with parent ownership
|
||||
QTimer *m_timer;
|
||||
|
||||
@ -82,16 +82,15 @@ bool SettingsDialog::minimizeToTray() const { return m_minimizeToTrayCheck->isCh
|
||||
bool SettingsDialog::showNotifications() const { return m_showNotificationsCheck->isChecked(); }
|
||||
|
||||
// Setters
|
||||
void SettingsDialog::setWorkDuration(int minutes) { m_workDurationSpin->setValue(minutes); }
|
||||
void SettingsDialog::setShortBreakDuration(int minutes) { m_shortBreakSpin->setValue(minutes); }
|
||||
void SettingsDialog::setLongBreakDuration(int minutes) { m_longBreakSpin->setValue(minutes); }
|
||||
void SettingsDialog::setAutoStartBreaks(bool enabled) { m_autoStartBreaksCheck->setChecked(enabled); }
|
||||
void SettingsDialog::setAutoStartWork(bool enabled) { m_autoStartWorkCheck->setChecked(enabled); }
|
||||
void SettingsDialog::setMinimizeToTray(bool enabled) { m_minimizeToTrayCheck->setChecked(enabled); }
|
||||
void SettingsDialog::setShowNotifications(bool enabled) { m_showNotificationsCheck->setChecked(enabled); }
|
||||
void SettingsDialog::setWorkDuration(int minutes) const { m_workDurationSpin->setValue(minutes); }
|
||||
void SettingsDialog::setShortBreakDuration(int minutes) const { m_shortBreakSpin->setValue(minutes); }
|
||||
void SettingsDialog::setLongBreakDuration(int minutes) const { m_longBreakSpin->setValue(minutes); }
|
||||
void SettingsDialog::setAutoStartBreaks(bool enabled) const { m_autoStartBreaksCheck->setChecked(enabled); }
|
||||
void SettingsDialog::setAutoStartWork(bool enabled) const { m_autoStartWorkCheck->setChecked(enabled); }
|
||||
void SettingsDialog::setMinimizeToTray(bool enabled) const { m_minimizeToTrayCheck->setChecked(enabled); }
|
||||
void SettingsDialog::setShowNotifications(bool enabled) const { m_showNotificationsCheck->setChecked(enabled); }
|
||||
|
||||
void SettingsDialog::resetToDefaults()
|
||||
{
|
||||
void SettingsDialog::resetToDefaults() const {
|
||||
setWorkDuration(25);
|
||||
setShortBreakDuration(5);
|
||||
setLongBreakDuration(15);
|
||||
|
||||
@ -26,19 +26,19 @@ public:
|
||||
bool showNotifications() const;
|
||||
|
||||
// Setters
|
||||
void setWorkDuration(int minutes);
|
||||
void setShortBreakDuration(int minutes);
|
||||
void setLongBreakDuration(int minutes);
|
||||
void setAutoStartBreaks(bool enabled);
|
||||
void setAutoStartWork(bool enabled);
|
||||
void setMinimizeToTray(bool enabled);
|
||||
void setShowNotifications(bool enabled);
|
||||
void setWorkDuration(int minutes) const;
|
||||
void setShortBreakDuration(int minutes) const;
|
||||
void setLongBreakDuration(int minutes) const;
|
||||
void setAutoStartBreaks(bool enabled) const;
|
||||
void setAutoStartWork(bool enabled) const;
|
||||
void setMinimizeToTray(bool enabled) const;
|
||||
void setShowNotifications(bool enabled) const;
|
||||
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
private slots:
|
||||
void resetToDefaults();
|
||||
void resetToDefaults() const;
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
|
||||
@ -1,18 +1,15 @@
|
||||
#include "StatisticsDialog.h"
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QScrollArea>
|
||||
#include <QPainter>
|
||||
#include <QSettings>
|
||||
#include <QDate>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
#include <QApplication>
|
||||
|
||||
#include "TimerState.h"
|
||||
@ -52,7 +49,7 @@ void StatisticsChart::paintEvent(QPaintEvent *event)
|
||||
}
|
||||
|
||||
constexpr int LABEL_SKIP_INTERVAL = 3;
|
||||
const int margin = 40;
|
||||
constexpr int margin = 40;
|
||||
const int chartWidth = width() - 2 * margin;
|
||||
const int chartHeight = height() - 2 * margin;
|
||||
|
||||
@ -305,8 +302,8 @@ void StatisticsDialog::setStatistics(int totalSessions, int totalWorkTime, int t
|
||||
.arg(m_totalWorkTime / 3600).arg((m_totalWorkTime % 3600) / 60)
|
||||
.arg(m_totalBreakTime / 3600).arg((m_totalBreakTime % 3600) / 60)
|
||||
.arg(m_totalSessions > 0 ? m_totalWorkTime / (m_totalSessions * 60) : 0)
|
||||
.arg(m_totalBreakTime > 0 ? QString::number(double(m_totalWorkTime) / m_totalBreakTime, 'f', 2) : "N/A")
|
||||
.arg(m_totalSessions > 0 ? QString::number(double(m_totalSessions) / 7, 'f', 1) : "0")
|
||||
.arg(m_totalBreakTime > 0 ? QString::number(static_cast<double>(m_totalWorkTime) / m_totalBreakTime, 'f', 2) : "N/A")
|
||||
.arg(m_totalSessions > 0 ? QString::number(static_cast<double>(m_totalSessions) / 7, 'f', 1) : "0")
|
||||
.arg(m_dailyWorkTime.value(QDate::currentDate(), 0))
|
||||
.arg(m_dailyWorkTime.value(QDate::currentDate().addDays(-1), 0))
|
||||
.arg(m_dailyWorkTime.value(QDate::currentDate(), 0)) // This week calculation can be improved
|
||||
@ -323,28 +320,27 @@ void StatisticsDialog::loadDailyStatistics()
|
||||
QDate today = QDate::currentDate();
|
||||
for (int i = 0; i < 30; ++i) {
|
||||
QDate date = today.addDays(-i);
|
||||
QSettings settings;
|
||||
QVariantMap dailyStats = settings.value("dailyStats").toMap();
|
||||
QSettings settings1;
|
||||
auto dailyStats = settings1.value("dailyStats").toMap();
|
||||
|
||||
for (auto it = dailyStats.begin(); it != dailyStats.end(); ++it) {
|
||||
QDate date = QDate::fromString(it.key(), "yyyy-MM-dd");
|
||||
if (date.isValid()) {
|
||||
QDate date1 = QDate::fromString(it.key(), "yyyy-MM-dd");
|
||||
if (date1.isValid()) {
|
||||
QVariantMap dayData = it.value().toMap();
|
||||
m_dailyWorkTime[date] = dayData["workTime"].toInt();
|
||||
m_dailySessions[date] = dayData["sessions"].toInt();
|
||||
m_dailyWorkTime[date1] = dayData["workTime"].toInt();
|
||||
m_dailySessions[date1] = dayData["sessions"].toInt();
|
||||
}
|
||||
}
|
||||
|
||||
QString sessionKey = QString("dailyStats/sessions_%1").arg(date.toString("yyyy-MM-dd"));
|
||||
int sessions = settings.value(sessionKey, 0).toInt();
|
||||
int sessions = settings1.value(sessionKey, 0).toInt();
|
||||
if (sessions > 0) {
|
||||
m_dailySessions[date] = sessions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StatisticsDialog::updateOverview()
|
||||
{
|
||||
void StatisticsDialog::updateOverview() const {
|
||||
m_totalSessionsLabel->setText(QString::number(m_totalSessions));
|
||||
|
||||
// Правильное форматирование времени
|
||||
@ -380,8 +376,7 @@ void StatisticsDialog::updateOverview()
|
||||
m_monthLabel->setText(TimerStateHelper::formatDuration(monthTotal * 60));
|
||||
}
|
||||
|
||||
void StatisticsDialog::updateChart()
|
||||
{
|
||||
void StatisticsDialog::updateChart() const {
|
||||
QMap<QDate, int> chartData;
|
||||
QDate today = QDate::currentDate();
|
||||
|
||||
|
||||
@ -43,8 +43,8 @@ private:
|
||||
void setupChartTab();
|
||||
void setupDetailsTab();
|
||||
void loadDailyStatistics();
|
||||
void updateOverview();
|
||||
void updateChart();
|
||||
void updateOverview() const;
|
||||
void updateChart() const;
|
||||
|
||||
// UI elements
|
||||
QTabWidget *m_tabWidget;
|
||||
|
||||
@ -3,23 +3,23 @@
|
||||
#include <QAction>
|
||||
|
||||
SystemTrayManager::SystemTrayManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_trayIcon(nullptr)
|
||||
, m_trayMenu(nullptr)
|
||||
{
|
||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||
qWarning("System tray is not available on this system.");
|
||||
return;
|
||||
}
|
||||
: QObject(parent), m_trayIcon(nullptr), m_trayMenu(nullptr) {
|
||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||
qWarning("System tray is not available on this system.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_trayIcon = new QSystemTrayIcon(this);
|
||||
m_trayIcon->setIcon(qApp->windowIcon());
|
||||
m_trayIcon = new QSystemTrayIcon(this);
|
||||
m_trayIcon->setIcon(qApp->windowIcon());
|
||||
|
||||
setupTrayMenu();
|
||||
setupTrayMenu();
|
||||
|
||||
connect(m_trayIcon, QOverload<QSystemTrayIcon::ActivationReason>::of(&QSystemTrayIcon::activated),
|
||||
this, &SystemTrayManager::onTrayIconActivated);
|
||||
connect(m_trayIcon,
|
||||
QOverload<QSystemTrayIcon::ActivationReason>::of(
|
||||
&QSystemTrayIcon::activated),
|
||||
this, &SystemTrayManager::onTrayIconActivated);
|
||||
}
|
||||
SystemTrayManager::~SystemTrayManager() {}
|
||||
|
||||
void SystemTrayManager::setupTrayMenu()
|
||||
{
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#ifndef SYSTEMTRAYMANAGER_H
|
||||
#define SYSTEMTRAYMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
#include "TimerState.h"
|
||||
@ -12,7 +11,7 @@ class SystemTrayManager : public QObject
|
||||
|
||||
public:
|
||||
explicit SystemTrayManager(QObject *parent = nullptr);
|
||||
~SystemTrayManager() = default;
|
||||
~SystemTrayManager() override;
|
||||
|
||||
void show();
|
||||
void hide();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user