mirror of
https://github.com/transmission/transmission
synced 2024-12-25 17:17:31 +00:00
8afbfecadb
* chore: re-enable readability-static-accessed-through-instance test in qt * chore: re-enable clang-diagnostic-nonportable-system-include-path check in qt/ * chore: re-enable clang-diagnostic-undefined-reinterpret-cast test in qt/ * chore: re-enable cert-err58-cpp check in qt/ * chore: re-enable clang-diagnostic-switch-enum check in qt/ * chore: re-enable modernize-return-braced-init-list check in qt/ * chore: re-enable cppcoreguidelines-pro-type-static-cast-downcast check in qt/ * chore: re-enable cppcoreguidelines-pro-type-cstyle-cast check in qt/ * refactor: re-enable cppcoreguidelines-init-variables check in qt/ * chore: re-enable cppcoreguidelines-pro-type-vararg check in qt/ * chore: remove explicit disable of clang-diagnostic-old-style-cast check in qt/ * chore: re-enable bugprone-implicit-widening-of-multiplication-result check in qt/
101 lines
2.9 KiB
C++
101 lines
2.9 KiB
C++
// This file Copyright © 2009-2022 Mnemosyne LLC.
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0), GPLv3 (SPDX: GPL-3.0),
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
// License text can be found in the licenses/ folder.
|
|
|
|
#pragma once
|
|
|
|
#include <ctime>
|
|
#include <memory>
|
|
#include <unordered_set>
|
|
|
|
#include <QApplication>
|
|
#include <QRegularExpression>
|
|
#include <QTimer>
|
|
#include <QTranslator>
|
|
|
|
#include <libtransmission/tr-macros.h>
|
|
|
|
#include "FaviconCache.h"
|
|
#include "Typedefs.h"
|
|
#include "Utils.h" // std::hash<QString>
|
|
|
|
class AddData;
|
|
class Prefs;
|
|
class Session;
|
|
class Torrent;
|
|
class TorrentModel;
|
|
class MainWindow;
|
|
class WatchDir;
|
|
class Torrent;
|
|
|
|
class Application : public QApplication
|
|
{
|
|
Q_OBJECT
|
|
TR_DISABLE_COPY_MOVE(Application)
|
|
|
|
public:
|
|
Application(int& argc, char** argv);
|
|
|
|
void raise() const;
|
|
bool notifyApp(QString const& title, QString const& body, QStringList const& actions = {}) const;
|
|
|
|
QString const& intern(QString const& in)
|
|
{
|
|
return *interned_strings_.insert(in).first;
|
|
}
|
|
|
|
FaviconCache& faviconCache();
|
|
|
|
public slots:
|
|
void addTorrent(AddData const&) const;
|
|
void addTorrent(QString const&) const;
|
|
|
|
private slots:
|
|
void consentGiven(int result) const;
|
|
void onSessionSourceChanged() const;
|
|
void onTorrentsAdded(torrent_ids_t const& torrents) const;
|
|
void onTorrentsCompleted(torrent_ids_t const& torrents) const;
|
|
void onTorrentsEdited(torrent_ids_t const& torrents) const;
|
|
void onTorrentsNeedInfo(torrent_ids_t const& torrents) const;
|
|
void refreshPref(int key) const;
|
|
void refreshTorrents();
|
|
void saveGeometry() const;
|
|
#ifdef QT_DBUS_LIB
|
|
void onNotificationActionInvoked(quint32 notification_id, QString action_key);
|
|
#endif
|
|
|
|
private:
|
|
void maybeUpdateBlocklist() const;
|
|
void loadTranslations();
|
|
QStringList getNames(torrent_ids_t const& ids) const;
|
|
void quitLater() const;
|
|
void notifyTorrentAdded(Torrent const*) const;
|
|
|
|
std::unique_ptr<Prefs> prefs_;
|
|
std::unique_ptr<Session> session_;
|
|
std::unique_ptr<TorrentModel> model_;
|
|
std::unique_ptr<MainWindow> window_;
|
|
std::unique_ptr<WatchDir> watch_dir_;
|
|
QTimer model_timer_;
|
|
QTimer stats_timer_;
|
|
QTimer session_timer_;
|
|
time_t last_full_update_time_ = {};
|
|
QTranslator qt_translator_;
|
|
QTranslator app_translator_;
|
|
FaviconCache favicons_;
|
|
|
|
QString const config_name_ = QStringLiteral("transmission");
|
|
QString const display_name_ = QStringLiteral("transmission-qt");
|
|
|
|
std::unordered_set<QString> interned_strings_;
|
|
|
|
#ifdef QT_DBUS_LIB
|
|
QString const fdo_notifications_service_name_ = QStringLiteral("org.freedesktop.Notifications");
|
|
QString const fdo_notifications_path_ = QStringLiteral("/org/freedesktop/Notifications");
|
|
QString const fdo_notifications_interface_name_ = QStringLiteral("org.freedesktop.Notifications");
|
|
QRegularExpression const start_now_regex_;
|
|
#endif
|
|
};
|
|
|
|
#define trApp dynamic_cast<Application*>(Application::instance())
|