2016-08-30 20:01:07 +02:00
|
|
|
#ifndef TRAY_WIDGET_H
|
|
|
|
#define TRAY_WIDGET_H
|
2016-08-25 00:45:32 +02:00
|
|
|
|
2021-01-25 19:48:11 +01:00
|
|
|
#include <syncthingwidgets/settings/settings.h>
|
|
|
|
#include <syncthingwidgets/webview/webviewdefs.h>
|
|
|
|
|
|
|
|
#include <syncthingmodel/syncthingdevicemodel.h>
|
|
|
|
#include <syncthingmodel/syncthingdirectorymodel.h>
|
|
|
|
#include <syncthingmodel/syncthingdownloadmodel.h>
|
|
|
|
#include <syncthingmodel/syncthingrecentchangesmodel.h>
|
|
|
|
#include <syncthingmodel/syncthingsortfiltermodel.h>
|
|
|
|
|
|
|
|
#include <syncthingconnector/syncthingconnection.h>
|
|
|
|
#include <syncthingconnector/syncthingnotifier.h>
|
|
|
|
#include <syncthingconnector/syncthingprocess.h>
|
2017-04-23 18:27:31 +02:00
|
|
|
|
2016-08-25 00:45:32 +02:00
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2016-09-03 19:39:43 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QFrame)
|
2016-09-03 20:14:52 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QMenu)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QActionGroup)
|
2019-07-17 19:07:58 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
2020-01-23 20:07:11 +01:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QTreeView)
|
2016-09-03 19:39:43 +02:00
|
|
|
|
2019-06-10 22:48:26 +02:00
|
|
|
namespace CppUtilities {
|
2016-08-25 00:45:32 +02:00
|
|
|
class QtConfigArguments;
|
|
|
|
}
|
2016-08-30 20:01:07 +02:00
|
|
|
|
2019-06-10 22:48:26 +02:00
|
|
|
namespace QtUtilities {
|
2016-08-25 00:45:32 +02:00
|
|
|
class AboutDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
2023-03-27 20:13:49 +02:00
|
|
|
#ifdef SYNCTHINGWIDGETS_NO_WEBVIEW
|
|
|
|
using WebViewDialog = void;
|
|
|
|
#else
|
2016-08-25 00:45:32 +02:00
|
|
|
class WebViewDialog;
|
2023-03-27 20:13:49 +02:00
|
|
|
#endif
|
2016-08-25 00:45:32 +02:00
|
|
|
class SettingsDialog;
|
2022-10-01 20:25:21 +02:00
|
|
|
class Wizard;
|
2016-08-25 00:45:32 +02:00
|
|
|
class TrayMenu;
|
2016-08-30 20:01:07 +02:00
|
|
|
|
2016-08-25 00:45:32 +02:00
|
|
|
namespace Ui {
|
|
|
|
class TrayWidget;
|
|
|
|
}
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
class TrayWidget : public QWidget {
|
2016-08-25 00:45:32 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2024-04-12 02:35:18 +02:00
|
|
|
explicit TrayWidget(TrayMenu *parent = nullptr);
|
2018-10-10 21:26:46 +02:00
|
|
|
~TrayWidget() override;
|
2016-08-25 00:45:32 +02:00
|
|
|
|
|
|
|
Data::SyncthingConnection &connection();
|
2018-05-01 22:27:03 +02:00
|
|
|
const Data::SyncthingConnection &connection() const;
|
2018-01-27 23:27:50 +01:00
|
|
|
Data::SyncthingNotifier ¬ifier();
|
2018-05-01 22:27:03 +02:00
|
|
|
const Data::SyncthingNotifier ¬ifier() const;
|
2016-09-03 20:14:52 +02:00
|
|
|
QMenu *connectionsMenu();
|
2016-09-24 16:19:23 +02:00
|
|
|
static const std::vector<TrayWidget *> &instances();
|
2020-10-19 18:33:10 +02:00
|
|
|
Data::SyncthingConnectionSettings *selectedConnection();
|
2022-08-06 21:08:55 +02:00
|
|
|
SettingsDialog *settingsDialog();
|
2016-08-25 00:45:32 +02:00
|
|
|
|
2020-03-08 13:50:32 +01:00
|
|
|
public Q_SLOTS:
|
2016-08-25 00:45:32 +02:00
|
|
|
void showSettingsDialog();
|
2022-10-02 20:33:07 +02:00
|
|
|
void showLauncherSettings();
|
2022-10-01 20:25:21 +02:00
|
|
|
void showWizard();
|
2016-08-25 00:45:32 +02:00
|
|
|
void showAboutDialog();
|
2023-03-27 20:13:49 +02:00
|
|
|
void showWebUI();
|
2016-08-25 00:45:32 +02:00
|
|
|
void showOwnDeviceId();
|
|
|
|
void showLog();
|
2016-09-08 23:35:15 +02:00
|
|
|
void showNotifications();
|
2019-06-22 17:28:09 +02:00
|
|
|
void showUsingPositioningSettings();
|
2021-10-09 01:14:33 +02:00
|
|
|
void showInternalError(const QString &errorMessage, Data::SyncthingErrorCategory category, int networkError, const QNetworkRequest &request,
|
|
|
|
const QByteArray &response);
|
2019-07-17 19:07:58 +02:00
|
|
|
void showInternalErrorsButton();
|
2021-03-24 14:40:59 +01:00
|
|
|
void showInternalErrorsDialog();
|
2016-12-10 12:03:08 +01:00
|
|
|
void dismissNotifications();
|
2016-10-05 00:01:55 +02:00
|
|
|
void restartSyncthing();
|
2016-09-24 16:19:23 +02:00
|
|
|
void quitTray();
|
2018-05-15 22:01:03 +02:00
|
|
|
void applySettings(const QString &connectionConfig = QString());
|
2022-10-01 22:25:33 +02:00
|
|
|
void applySettingsChangesFromWizard();
|
2023-02-17 19:20:10 +01:00
|
|
|
void saveSettings();
|
2016-08-25 00:45:32 +02:00
|
|
|
|
2022-07-16 19:28:31 +02:00
|
|
|
protected:
|
|
|
|
bool event(QEvent *event) override;
|
|
|
|
|
2020-03-08 13:50:32 +01:00
|
|
|
private Q_SLOTS:
|
2016-09-06 22:55:49 +02:00
|
|
|
void handleStatusChanged(Data::SyncthingStatus status);
|
2017-08-09 01:11:47 +02:00
|
|
|
static void applySettingsOnAllInstances();
|
2016-09-21 21:09:12 +02:00
|
|
|
void openDir(const Data::SyncthingDir &dir);
|
|
|
|
void openItemDir(const Data::SyncthingItemDownloadProgress &item);
|
|
|
|
void scanDir(const Data::SyncthingDir &dir);
|
|
|
|
void pauseResumeDev(const Data::SyncthingDev &dev);
|
2017-02-23 15:49:58 +01:00
|
|
|
void pauseResumeDir(const Data::SyncthingDir &dir);
|
2024-04-01 18:57:18 +02:00
|
|
|
void browseRemoteFiles(const Data::SyncthingDir &dir);
|
2020-01-23 20:07:11 +01:00
|
|
|
void showRecentChangesContextMenu(const QPoint &position);
|
2016-08-29 20:51:30 +02:00
|
|
|
void changeStatus();
|
2016-08-30 20:01:07 +02:00
|
|
|
void updateTraffic();
|
2023-06-08 14:04:16 +02:00
|
|
|
bool updateTrafficText();
|
2019-02-18 00:35:32 +01:00
|
|
|
void updateOverallStatistics();
|
2020-10-19 18:33:10 +02:00
|
|
|
void updateIconAndTooltip();
|
2019-07-12 20:26:56 +02:00
|
|
|
void toggleRunning();
|
|
|
|
Settings::Launcher::LauncherStatus handleLauncherStatusChanged();
|
2019-07-13 13:21:25 +02:00
|
|
|
Settings::Launcher::LauncherStatus applyLauncherSettings(
|
|
|
|
bool reconnectRequired = false, bool skipApplyingToConnection = false, bool skipStartStopButton = false);
|
2016-12-18 16:50:35 +01:00
|
|
|
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
2019-07-12 20:26:56 +02:00
|
|
|
Settings::Systemd::ServiceStatus handleSystemdStatusChanged();
|
|
|
|
Settings::Systemd::ServiceStatus applySystemdSettings(bool reconnectRequired = false);
|
2016-12-18 16:50:35 +01:00
|
|
|
#endif
|
2016-08-25 00:45:32 +02:00
|
|
|
void handleWebViewDeleted();
|
2019-06-10 22:48:26 +02:00
|
|
|
void handleNewNotification(CppUtilities::DateTime when, const QString &msg);
|
2016-09-03 20:14:52 +02:00
|
|
|
void handleConnectionSelected(QAction *connectionAction);
|
2022-10-01 22:25:33 +02:00
|
|
|
void concludeWizard(const QString &errorMessage = QString());
|
2021-03-24 14:40:59 +01:00
|
|
|
void showDialog(QWidget *dlg, bool maximized = false);
|
2022-07-16 19:28:31 +02:00
|
|
|
void setBrightColorsOfModelsAccordingToPalette();
|
2023-06-08 14:04:16 +02:00
|
|
|
void setLabelPixmaps();
|
|
|
|
void setTrafficPixmaps(bool recompute = false);
|
2016-08-25 00:45:32 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
TrayMenu *m_menu;
|
|
|
|
std::unique_ptr<Ui::TrayWidget> m_ui;
|
2019-07-27 15:11:50 +02:00
|
|
|
static SettingsDialog *s_settingsDlg;
|
2022-10-01 20:25:21 +02:00
|
|
|
static Wizard *s_wizard;
|
2019-07-27 15:11:50 +02:00
|
|
|
static QtUtilities::AboutDialog *s_aboutDlg;
|
2016-08-25 00:45:32 +02:00
|
|
|
WebViewDialog *m_webViewDlg;
|
2016-09-03 19:39:43 +02:00
|
|
|
QFrame *m_cornerFrame;
|
2019-07-17 19:07:58 +02:00
|
|
|
QPushButton *m_internalErrorsButton;
|
2016-08-25 00:45:32 +02:00
|
|
|
Data::SyncthingConnection m_connection;
|
2018-01-27 23:27:50 +01:00
|
|
|
Data::SyncthingNotifier m_notifier;
|
2016-08-25 00:45:32 +02:00
|
|
|
Data::SyncthingDirectoryModel m_dirModel;
|
2020-10-20 19:16:53 +02:00
|
|
|
Data::SyncthingSortFilterModel m_sortFilterDirModel;
|
2016-08-25 00:45:32 +02:00
|
|
|
Data::SyncthingDeviceModel m_devModel;
|
2020-10-20 19:16:53 +02:00
|
|
|
Data::SyncthingSortFilterModel m_sortFilterDevModel;
|
2016-09-21 21:09:12 +02:00
|
|
|
Data::SyncthingDownloadModel m_dlModel;
|
2020-01-18 16:37:20 +01:00
|
|
|
Data::SyncthingRecentChangesModel m_recentChangesModel;
|
2016-09-03 20:14:52 +02:00
|
|
|
QMenu *m_connectionsMenu;
|
|
|
|
QActionGroup *m_connectionsActionGroup;
|
2016-09-29 21:19:54 +02:00
|
|
|
Data::SyncthingConnectionSettings *m_selectedConnection;
|
2016-12-26 19:19:10 +01:00
|
|
|
QMenu *m_notificationsMenu;
|
2016-09-08 23:35:15 +02:00
|
|
|
std::vector<Data::SyncthingLogEntry> m_notifications;
|
2019-07-13 13:21:25 +02:00
|
|
|
enum class StartStopButtonTarget { None, Service, Launcher } m_startStopButtonTarget;
|
2022-09-05 21:56:22 +02:00
|
|
|
QStringList m_tabTexts;
|
2023-06-08 14:04:16 +02:00
|
|
|
struct {
|
|
|
|
QPixmap uploadIconActive;
|
|
|
|
QPixmap uploadIconInactive;
|
|
|
|
QPixmap downloadIconActive;
|
|
|
|
QPixmap downloadIconInactive;
|
|
|
|
} m_trafficIcons;
|
2022-09-05 21:56:22 +02:00
|
|
|
bool m_tabTextsShown;
|
2022-10-01 22:25:33 +02:00
|
|
|
bool m_applyingSettingsForWizard;
|
2019-07-27 15:11:50 +02:00
|
|
|
static std::vector<TrayWidget *> s_instances;
|
2016-08-25 00:45:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline Data::SyncthingConnection &TrayWidget::connection()
|
|
|
|
{
|
|
|
|
return m_connection;
|
|
|
|
}
|
|
|
|
|
2018-05-01 22:27:03 +02:00
|
|
|
inline const Data::SyncthingConnection &TrayWidget::connection() const
|
|
|
|
{
|
|
|
|
return m_connection;
|
|
|
|
}
|
|
|
|
|
2018-01-27 23:27:50 +01:00
|
|
|
inline Data::SyncthingNotifier &TrayWidget::notifier()
|
|
|
|
{
|
|
|
|
return m_notifier;
|
|
|
|
}
|
|
|
|
|
2018-05-01 22:27:03 +02:00
|
|
|
inline const Data::SyncthingNotifier &TrayWidget::notifier() const
|
|
|
|
{
|
|
|
|
return m_notifier;
|
|
|
|
}
|
|
|
|
|
2016-09-03 20:14:52 +02:00
|
|
|
inline QMenu *TrayWidget::connectionsMenu()
|
|
|
|
{
|
|
|
|
return m_connectionsMenu;
|
|
|
|
}
|
|
|
|
|
2016-09-24 16:19:23 +02:00
|
|
|
inline const std::vector<TrayWidget *> &TrayWidget::instances()
|
|
|
|
{
|
2019-07-27 15:11:50 +02:00
|
|
|
return s_instances;
|
2016-09-24 16:19:23 +02:00
|
|
|
}
|
2020-10-19 18:33:10 +02:00
|
|
|
|
|
|
|
inline Data::SyncthingConnectionSettings *TrayWidget::selectedConnection()
|
|
|
|
{
|
|
|
|
return m_selectedConnection;
|
|
|
|
}
|
|
|
|
|
2017-09-17 21:48:15 +02:00
|
|
|
} // namespace QtGui
|
2016-08-25 00:45:32 +02:00
|
|
|
|
2016-08-30 20:01:07 +02:00
|
|
|
#endif // TRAY_WIDGET_H
|