mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Merge pull request #2302 from buinsky/WebUI2
Accept multiple files at once. Closes #2253
This commit is contained in:
commit
6d6e3042c2
38
src/main.cpp
38
src/main.cpp
@ -74,6 +74,20 @@ Q_IMPORT_PLUGIN(qico)
|
||||
#include "misc.h"
|
||||
#include "preferences.h"
|
||||
|
||||
class MessagesCollector : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
void collectMessage(const QString& message)
|
||||
{
|
||||
messages.append(message.split("|", QString::SkipEmptyParts));
|
||||
}
|
||||
public:
|
||||
QStringList messages;
|
||||
};
|
||||
|
||||
#include "main.moc"
|
||||
|
||||
#if defined(Q_OS_WIN) && !defined(QBT_HAS_GETCURRENTPID)
|
||||
#error You seem to have updated QtSingleApplication without porting our custom QtSingleApplication::getRunningPid() function. Please see previous version to understate how it works.
|
||||
#endif
|
||||
@ -113,6 +127,10 @@ int main(int argc, char *argv[])
|
||||
// Create Application
|
||||
Application app("qBittorrent-" + misc::getUserIDString(), argc, argv);
|
||||
|
||||
MessagesCollector* messagesCollector = new MessagesCollector();
|
||||
QObject::connect(&app, SIGNAL(messageReceived(const QString &)),
|
||||
messagesCollector, SLOT(collectMessage(const QString &)));
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
parseCommandLine(showVersion, showUsage, noSplash, torrents);
|
||||
#else
|
||||
@ -131,9 +149,8 @@ int main(int argc, char *argv[])
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
// Set environment variable
|
||||
if (!qputenv("QBITTORRENT", QByteArray(VERSION))) {
|
||||
if (!qputenv("QBITTORRENT", QByteArray(VERSION)))
|
||||
std::cerr << "Couldn't set environment variable...\n";
|
||||
}
|
||||
|
||||
if (!userAgreesWithLegalNotice())
|
||||
return EXIT_SUCCESS;
|
||||
@ -141,6 +158,7 @@ int main(int argc, char *argv[])
|
||||
// Check if qBittorrent is already running for this user
|
||||
if (app.isRunning()) {
|
||||
qDebug("qBittorrent is already running for this user.");
|
||||
misc::msleep(300);
|
||||
#ifdef Q_OS_WIN
|
||||
DWORD pid = (DWORD)app.getRunningPid();
|
||||
if (pid > 0) {
|
||||
@ -181,8 +199,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
MainWindow window(0, torrents);
|
||||
QObject::connect(&app, SIGNAL(messageReceived(const QString&)),
|
||||
&window, SLOT(processParams(const QString&)));
|
||||
QObject::connect(&app, SIGNAL(messageReceived(const QString &)),
|
||||
&window, SLOT(processParams(const QString &)));
|
||||
QObject::disconnect(&app, SIGNAL(messageReceived(const QString &)),
|
||||
messagesCollector, SLOT(collectMessage(const QString &)));
|
||||
window.processParams(messagesCollector->messages);
|
||||
delete messagesCollector;
|
||||
app.setActivationWindow(&window);
|
||||
#ifdef Q_OS_MAC
|
||||
static_cast<QMacApplication*>(&app)->setReadyToProcessEvents();
|
||||
@ -190,8 +212,12 @@ int main(int argc, char *argv[])
|
||||
#else
|
||||
// Load Headless class
|
||||
HeadlessLoader loader(torrents);
|
||||
QObject::connect(&app, SIGNAL(messageReceived(const QString&)),
|
||||
&loader, SLOT(processParams(const QString&)));
|
||||
QObject::connect(&app, SIGNAL(messageReceived(const QString &)),
|
||||
&loader, SLOT(processParams(const QString &)));
|
||||
QObject::disconnect(&app, SIGNAL(messageReceived(const QString &)),
|
||||
messagesCollector, SLOT(collectMessage(const QString &)));
|
||||
loader.processParams(messagesCollector->messages);
|
||||
delete messagesCollector;
|
||||
#endif
|
||||
|
||||
int ret = app.exec();
|
||||
|
2409
src/mainwindow.cpp
2409
src/mainwindow.cpp
File diff suppressed because it is too large
Load Diff
251
src/mainwindow.h
251
src/mainwindow.h
@ -66,152 +66,153 @@ class QTabWidget;
|
||||
class QTimer;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow, private Ui::MainWindow{
|
||||
Q_OBJECT
|
||||
class MainWindow: public QMainWindow, private Ui::MainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Construct / Destruct
|
||||
MainWindow(QWidget *parent=0, const QStringList& torrentCmdLine = QStringList());
|
||||
// Methods
|
||||
QWidget* getCurrentTabWidget() const;
|
||||
TransferListWidget* getTransferList() const { return transferList; }
|
||||
QMenu* getTrayIconMenu();
|
||||
PropertiesWidget *getProperties() const { return properties; }
|
||||
// Construct / Destruct
|
||||
MainWindow(QWidget *parent = 0, const QStringList& torrentCmdLine = QStringList());
|
||||
// Methods
|
||||
QWidget* getCurrentTabWidget() const;
|
||||
TransferListWidget* getTransferList() const { return transferList; }
|
||||
QMenu* getTrayIconMenu();
|
||||
PropertiesWidget *getProperties() const { return properties; }
|
||||
|
||||
public slots:
|
||||
void trackerAuthenticationRequired(const QTorrentHandle& h);
|
||||
void setTabText(int index, QString text) const;
|
||||
void showNotificationBaloon(QString title, QString msg) const;
|
||||
void downloadFromURLList(const QStringList& urls);
|
||||
void updateAltSpeedsBtn(bool alternative);
|
||||
void updateNbTorrents();
|
||||
void shutdownCleanUp();
|
||||
void trackerAuthenticationRequired(const QTorrentHandle& h);
|
||||
void setTabText(int index, QString text) const;
|
||||
void showNotificationBaloon(QString title, QString msg) const;
|
||||
void downloadFromURLList(const QStringList& urls);
|
||||
void updateAltSpeedsBtn(bool alternative);
|
||||
void updateNbTorrents();
|
||||
void shutdownCleanUp();
|
||||
void processParams(const QStringList& params);
|
||||
|
||||
protected slots:
|
||||
// GUI related slots
|
||||
void dropEvent(QDropEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void toggleVisibility(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
||||
void on_actionAbout_triggered();
|
||||
void on_actionStatistics_triggered();
|
||||
void on_actionCreate_torrent_triggered();
|
||||
void on_actionWebsite_triggered() const;
|
||||
void on_actionBugReport_triggered() const;
|
||||
void balloonClicked();
|
||||
void writeSettings();
|
||||
void readSettings();
|
||||
void on_actionExit_triggered();
|
||||
void createTrayIcon();
|
||||
void fullDiskError(const QTorrentHandle& h, QString msg) const;
|
||||
void handleDownloadFromUrlFailure(QString, QString) const;
|
||||
void createSystrayDelayed();
|
||||
void tab_changed(int);
|
||||
void on_actionLock_qBittorrent_triggered();
|
||||
void defineUILockPassword();
|
||||
void clearUILockPassword();
|
||||
bool unlockUI();
|
||||
void notifyOfUpdate(QString);
|
||||
void showConnectionSettings();
|
||||
void minimizeWindow();
|
||||
void updateTrayIconMenu();
|
||||
// Keyboard shortcuts
|
||||
void createKeyboardShortcuts();
|
||||
void displayTransferTab() const;
|
||||
void displaySearchTab() const;
|
||||
void displayRSSTab() const;
|
||||
// Torrent actions
|
||||
void on_actionSet_global_upload_limit_triggered();
|
||||
void on_actionSet_global_download_limit_triggered();
|
||||
void on_actionDocumentation_triggered() const;
|
||||
void on_actionOpen_triggered();
|
||||
void updateGUI();
|
||||
void loadPreferences(bool configure_session=true);
|
||||
void processParams(const QString& params);
|
||||
void processParams(const QStringList& params);
|
||||
void addTorrent(QString path);
|
||||
void addUnauthenticatedTracker(const QPair<QTorrentHandle,QString> &tracker);
|
||||
void processDownloadedFiles(QString path, QString url);
|
||||
void processNewMagnetLink(const QString& link);
|
||||
void finishedTorrent(const QTorrentHandle& h) const;
|
||||
void askRecursiveTorrentDownloadConfirmation(const QTorrentHandle &h);
|
||||
// Options slots
|
||||
void on_actionOptions_triggered();
|
||||
void optionsSaved();
|
||||
// HTTP slots
|
||||
void on_actionDownload_from_URL_triggered();
|
||||
// GUI related slots
|
||||
void dropEvent(QDropEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void toggleVisibility(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
||||
void on_actionAbout_triggered();
|
||||
void on_actionStatistics_triggered();
|
||||
void on_actionCreate_torrent_triggered();
|
||||
void on_actionWebsite_triggered() const;
|
||||
void on_actionBugReport_triggered() const;
|
||||
void balloonClicked();
|
||||
void writeSettings();
|
||||
void readSettings();
|
||||
void on_actionExit_triggered();
|
||||
void createTrayIcon();
|
||||
void fullDiskError(const QTorrentHandle& h, QString msg) const;
|
||||
void handleDownloadFromUrlFailure(QString, QString) const;
|
||||
void createSystrayDelayed();
|
||||
void tab_changed(int);
|
||||
void on_actionLock_qBittorrent_triggered();
|
||||
void defineUILockPassword();
|
||||
void clearUILockPassword();
|
||||
bool unlockUI();
|
||||
void notifyOfUpdate(QString);
|
||||
void showConnectionSettings();
|
||||
void minimizeWindow();
|
||||
void updateTrayIconMenu();
|
||||
// Keyboard shortcuts
|
||||
void createKeyboardShortcuts();
|
||||
void displayTransferTab() const;
|
||||
void displaySearchTab() const;
|
||||
void displayRSSTab() const;
|
||||
// Torrent actions
|
||||
void on_actionSet_global_upload_limit_triggered();
|
||||
void on_actionSet_global_download_limit_triggered();
|
||||
void on_actionDocumentation_triggered() const;
|
||||
void on_actionOpen_triggered();
|
||||
void updateGUI();
|
||||
void loadPreferences(bool configure_session = true);
|
||||
void processParams(const QString& params);
|
||||
void addTorrent(QString path);
|
||||
void addUnauthenticatedTracker(const QPair<QTorrentHandle,QString> &tracker);
|
||||
void processDownloadedFiles(QString path, QString url);
|
||||
void processNewMagnetLink(const QString& link);
|
||||
void finishedTorrent(const QTorrentHandle& h) const;
|
||||
void askRecursiveTorrentDownloadConfirmation(const QTorrentHandle &h);
|
||||
// Options slots
|
||||
void on_actionOptions_triggered();
|
||||
void optionsSaved();
|
||||
// HTTP slots
|
||||
void on_actionDownload_from_URL_triggered();
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||
void handleUpdateCheckFinished(bool update_available, QString new_version, bool invokedByUser);
|
||||
void handleUpdateCheckFinished(bool update_available, QString new_version, bool invokedByUser);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *);
|
||||
void showEvent(QShowEvent *);
|
||||
bool event(QEvent * event);
|
||||
void displayRSSTab(bool enable);
|
||||
void displaySearchTab(bool enable);
|
||||
void closeEvent(QCloseEvent *);
|
||||
void showEvent(QShowEvent *);
|
||||
bool event(QEvent * event);
|
||||
void displayRSSTab(bool enable);
|
||||
void displaySearchTab(bool enable);
|
||||
|
||||
private:
|
||||
QIcon getSystrayIcon() const;
|
||||
QIcon getSystrayIcon() const;
|
||||
#ifdef Q_OS_WIN
|
||||
bool addPythonPathToEnv();
|
||||
void installPython();
|
||||
bool addPythonPathToEnv();
|
||||
void installPython();
|
||||
|
||||
private slots:
|
||||
void pythonDownloadSuccess(QString url, QString file_path);
|
||||
void pythonDownloadFailure(QString url, QString error);
|
||||
void pythonDownloadSuccess(QString url, QString file_path);
|
||||
void pythonDownloadFailure(QString url, QString error);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QFileSystemWatcher *executable_watcher;
|
||||
// Bittorrent
|
||||
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
|
||||
// GUI related
|
||||
bool m_posInitialized;
|
||||
QTimer *guiUpdater;
|
||||
HidableTabWidget *tabs;
|
||||
StatusBar *status_bar;
|
||||
QPointer<options_imp> options;
|
||||
QPointer<consoleDlg> console;
|
||||
QPointer<about> aboutDlg;
|
||||
QPointer<StatsDialog> statsDlg;
|
||||
QPointer<TorrentCreatorDlg> createTorrentDlg;
|
||||
QPointer<downloadFromURL> downloadFromURLDialog;
|
||||
QPointer<QSystemTrayIcon> systrayIcon;
|
||||
QPointer<QTimer> systrayCreator;
|
||||
QPointer<QMenu> myTrayIconMenu;
|
||||
TransferListWidget *transferList;
|
||||
TransferListFiltersWidget *transferListFilters;
|
||||
PropertiesWidget *properties;
|
||||
bool displaySpeedInTitle;
|
||||
bool force_exit;
|
||||
bool ui_locked;
|
||||
bool unlockDlgShowing;
|
||||
LineEdit *search_filter;
|
||||
QAction *searchFilterAct;
|
||||
// Keyboard shortcuts
|
||||
QShortcut *switchSearchShortcut;
|
||||
QShortcut *switchSearchShortcut2;
|
||||
QShortcut *switchTransferShortcut;
|
||||
QShortcut *switchRSSShortcut;
|
||||
// Widgets
|
||||
QAction *prioSeparator;
|
||||
QAction *prioSeparatorMenu;
|
||||
QSplitter *hSplitter;
|
||||
QSplitter *vSplitter;
|
||||
// Search
|
||||
QPointer<SearchEngine> searchEngine;
|
||||
// RSS
|
||||
QPointer<RSSImp> rssWidget;
|
||||
// Execution Log
|
||||
QPointer<ExecutionLog> m_executionLog;
|
||||
// Power Management
|
||||
PowerManagement *m_pwr;
|
||||
QTimer *preventTimer;
|
||||
QFileSystemWatcher *executable_watcher;
|
||||
// Bittorrent
|
||||
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
|
||||
// GUI related
|
||||
bool m_posInitialized;
|
||||
QTimer *guiUpdater;
|
||||
HidableTabWidget *tabs;
|
||||
StatusBar *status_bar;
|
||||
QPointer<options_imp> options;
|
||||
QPointer<consoleDlg> console;
|
||||
QPointer<about> aboutDlg;
|
||||
QPointer<StatsDialog> statsDlg;
|
||||
QPointer<TorrentCreatorDlg> createTorrentDlg;
|
||||
QPointer<downloadFromURL> downloadFromURLDialog;
|
||||
QPointer<QSystemTrayIcon> systrayIcon;
|
||||
QPointer<QTimer> systrayCreator;
|
||||
QPointer<QMenu> myTrayIconMenu;
|
||||
TransferListWidget *transferList;
|
||||
TransferListFiltersWidget *transferListFilters;
|
||||
PropertiesWidget *properties;
|
||||
bool displaySpeedInTitle;
|
||||
bool force_exit;
|
||||
bool ui_locked;
|
||||
bool unlockDlgShowing;
|
||||
LineEdit *search_filter;
|
||||
QAction *searchFilterAct;
|
||||
// Keyboard shortcuts
|
||||
QShortcut *switchSearchShortcut;
|
||||
QShortcut *switchSearchShortcut2;
|
||||
QShortcut *switchTransferShortcut;
|
||||
QShortcut *switchRSSShortcut;
|
||||
// Widgets
|
||||
QAction *prioSeparator;
|
||||
QAction *prioSeparatorMenu;
|
||||
QSplitter *hSplitter;
|
||||
QSplitter *vSplitter;
|
||||
// Search
|
||||
QPointer<SearchEngine> searchEngine;
|
||||
// RSS
|
||||
QPointer<RSSImp> rssWidget;
|
||||
// Execution Log
|
||||
QPointer<ExecutionLog> m_executionLog;
|
||||
// Power Management
|
||||
PowerManagement *m_pwr;
|
||||
QTimer *preventTimer;
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||
QTimer programUpdateTimer;
|
||||
QTimer programUpdateTimer;
|
||||
#endif
|
||||
#ifdef Q_OS_WIN
|
||||
bool has_python;
|
||||
bool has_python;
|
||||
#endif
|
||||
|
||||
private slots:
|
||||
|
Loading…
Reference in New Issue
Block a user