mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 11:49:01 +03:00
- Save / Restore preferences dialog size and position on restart
- Make use of new Preferences in GUI constructor
This commit is contained in:
parent
36748b6729
commit
31180bb00c
3 changed files with 151 additions and 138 deletions
16
src/GUI.cpp
16
src/GUI.cpp
|
@ -79,8 +79,7 @@ using namespace libtorrent;
|
|||
GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), displaySpeedInTitle(false), force_exit(false) {
|
||||
setupUi(this);
|
||||
setWindowTitle(tr("qBittorrent %1", "e.g: qBittorrent v0.x").arg(QString::fromUtf8(VERSION)));
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
systrayIntegration = settings.value(QString::fromUtf8("Preferences/General/SystrayEnabled"), true).toBool();
|
||||
systrayIntegration = Preferences::systrayIntegration();
|
||||
systrayCreator = 0;
|
||||
// Create tray icon
|
||||
if (QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||
|
@ -179,13 +178,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
|
|||
// Add torrent given on command line
|
||||
processParams(torrentCmdLine);
|
||||
// Initialize Web UI
|
||||
httpServer = 0;
|
||||
if(settings.value("Preferences/WebUI/Enabled", false).toBool())
|
||||
{
|
||||
quint16 port = settings.value("Preferences/WebUI/Port", 8080).toUInt();
|
||||
QString username = settings.value("Preferences/WebUI/Username", "").toString();
|
||||
QString password = settings.value("Preferences/WebUI/Password", "").toString();
|
||||
initWebUi(username, password, port);
|
||||
if(Preferences::isWebUiEnabled()) {
|
||||
initWebUi(Preferences::getWebUiUsername(), Preferences::getWebUiPassword(), Preferences::getWebUiPort());
|
||||
}
|
||||
// Use a tcp server to allow only one instance of qBittorrent
|
||||
localServer = new QLocalServer();
|
||||
|
@ -244,8 +238,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
|
|||
readSettings();
|
||||
properties->readSettings();
|
||||
|
||||
if(settings.value(QString::fromUtf8("Preferences/General/StartMinimized"), false).toBool()) {
|
||||
this->setWindowState(Qt::WindowMinimized);
|
||||
if(Preferences::startMinimized()) {
|
||||
setWindowState(Qt::WindowMinimized);
|
||||
}
|
||||
|
||||
scrapeTimer = new QTimer(this);
|
||||
|
|
|
@ -261,7 +261,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
|||
// Tab selection mecanism
|
||||
connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
|
||||
// Adapt size
|
||||
adaptToScreenSize();
|
||||
loadWindowState();
|
||||
show();
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,21 @@ void options_imp::useStyle(){
|
|||
}
|
||||
}
|
||||
|
||||
void options_imp::adaptToScreenSize() {
|
||||
void options_imp::loadWindowState() {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
resize(settings.value(QString::fromUtf8("Preferences/State/size"), sizeFittingScreen()).toSize());
|
||||
QPoint p = settings.value(QString::fromUtf8("Preferences/State/pos"), QPoint()).toPoint();
|
||||
if(!p.isNull())
|
||||
move(p);
|
||||
}
|
||||
|
||||
void options_imp::saveWindowState() const {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
settings.setValue(QString::fromUtf8("Preferences/State/size"), size());
|
||||
settings.setValue(QString::fromUtf8("Preferences/State/pos"), pos());
|
||||
}
|
||||
|
||||
QSize options_imp::sizeFittingScreen() {
|
||||
int scrn = 0;
|
||||
QWidget *w = this->topLevelWidget();
|
||||
|
||||
|
@ -318,8 +332,9 @@ void options_imp::adaptToScreenSize() {
|
|||
QRect desk(QApplication::desktop()->availableGeometry(scrn));
|
||||
if(width() > desk.width() || height() > desk.height()) {
|
||||
if(desk.width() > 0 && desk.height() > 0)
|
||||
resize(desk.width(), desk.height());
|
||||
return QSize(desk.width(), desk.height());
|
||||
}
|
||||
return size();
|
||||
}
|
||||
|
||||
void options_imp::saveOptions(){
|
||||
|
@ -925,6 +940,7 @@ void options_imp::on_buttonBox_accepted(){
|
|||
this->hide();
|
||||
emit status_changed();
|
||||
}
|
||||
saveWindowState();
|
||||
accept();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,135 +46,138 @@ class QCloseEvent;
|
|||
class options_imp : public QDialog, private Ui::Dialog {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QButtonGroup choiceLanguage;
|
||||
QStringList locales;
|
||||
QAbstractButton *applyButton;
|
||||
private:
|
||||
QButtonGroup choiceLanguage;
|
||||
QStringList locales;
|
||||
QAbstractButton *applyButton;
|
||||
|
||||
public:
|
||||
// Contructor / Destructor
|
||||
options_imp(QWidget *parent=0);
|
||||
~options_imp();
|
||||
public:
|
||||
// Contructor / Destructor
|
||||
options_imp(QWidget *parent=0);
|
||||
~options_imp();
|
||||
QSize sizeFittingScreen();
|
||||
|
||||
// Methods
|
||||
void saveOptions();
|
||||
void loadOptions();
|
||||
// General options
|
||||
QString getLocale() const;
|
||||
int getStyle() const;
|
||||
bool confirmOnExit() const;
|
||||
bool speedInTitleBar() const;
|
||||
unsigned int getRefreshInterval() const;
|
||||
bool systrayIntegration() const;
|
||||
bool minimizeToTray() const;
|
||||
bool closeToTray() const;
|
||||
bool startMinimized() const;
|
||||
bool isSlashScreenDisabled() const;
|
||||
bool OSDEnabled() const;
|
||||
bool isToolbarDisplayed() const;
|
||||
// Downloads
|
||||
QString getSavePath() const;
|
||||
bool isTempPathEnabled() const;
|
||||
QString getTempPath() const;
|
||||
bool preAllocateAllFiles() const;
|
||||
bool useAdditionDialog() const;
|
||||
bool addTorrentsInPause() const;
|
||||
bool isDirScanEnabled() const;
|
||||
QString getScanDir() const;
|
||||
int getActionOnDblClOnTorrentDl() const;
|
||||
int getActionOnDblClOnTorrentFn() const;
|
||||
// Connection options
|
||||
int getPort() const;
|
||||
bool isUPnPEnabled() const;
|
||||
bool isNATPMPEnabled() const;
|
||||
QPair<int,int> getGlobalBandwidthLimits() const;
|
||||
// Bittorrent options
|
||||
int getMaxConnecs() const;
|
||||
int getMaxConnecsPerTorrent() const;
|
||||
int getMaxUploadsPerTorrent() const;
|
||||
bool isDHTEnabled() const;
|
||||
bool isDHTPortSameAsBT() const;
|
||||
int getDHTPort() const;
|
||||
bool isLSDEnabled() const;
|
||||
bool isRSSEnabled() const;
|
||||
bool isUtorrentSpoofingEnabled() const;
|
||||
int getEncryptionSetting() const;
|
||||
float getDesiredRatio() const;
|
||||
float getDeleteRatio() const;
|
||||
// Proxy options
|
||||
QString getHTTPProxyIp() const;
|
||||
unsigned short getHTTPProxyPort() const;
|
||||
QString getHTTPProxyUsername() const;
|
||||
QString getHTTPProxyPassword() const;
|
||||
int getHTTPProxyType() const;
|
||||
bool isProxyEnabled() const;
|
||||
bool isHTTPProxyEnabled() const;
|
||||
bool isProxyAuthEnabled() const;
|
||||
bool isHTTPProxyAuthEnabled() const;
|
||||
QString getProxyIp() const;
|
||||
unsigned short getProxyPort() const;
|
||||
QString getProxyUsername() const;
|
||||
QString getProxyPassword() const;
|
||||
int getProxyType() const;
|
||||
bool useProxyForTrackers() const;
|
||||
bool useProxyForPeers() const;
|
||||
bool useProxyForWebseeds() const;
|
||||
bool useProxyForDHT() const;
|
||||
// IP Filter
|
||||
bool isFilteringEnabled() const;
|
||||
QString getFilter() const;
|
||||
// Queueing system
|
||||
bool isQueueingSystemEnabled() const;
|
||||
int getMaxActiveDownloads() const;
|
||||
int getMaxActiveUploads() const;
|
||||
int getMaxActiveTorrents() const;
|
||||
bool isWebUiEnabled() const;
|
||||
quint16 webUiPort() const;
|
||||
QString webUiUsername() const;
|
||||
QString webUiPassword() const;
|
||||
protected:
|
||||
// Methods
|
||||
void saveOptions();
|
||||
void loadOptions();
|
||||
// General options
|
||||
QString getLocale() const;
|
||||
int getStyle() const;
|
||||
bool confirmOnExit() const;
|
||||
bool speedInTitleBar() const;
|
||||
unsigned int getRefreshInterval() const;
|
||||
bool systrayIntegration() const;
|
||||
bool minimizeToTray() const;
|
||||
bool closeToTray() const;
|
||||
bool startMinimized() const;
|
||||
bool isSlashScreenDisabled() const;
|
||||
bool OSDEnabled() const;
|
||||
bool isToolbarDisplayed() const;
|
||||
// Downloads
|
||||
QString getSavePath() const;
|
||||
bool isTempPathEnabled() const;
|
||||
QString getTempPath() const;
|
||||
bool preAllocateAllFiles() const;
|
||||
bool useAdditionDialog() const;
|
||||
bool addTorrentsInPause() const;
|
||||
bool isDirScanEnabled() const;
|
||||
QString getScanDir() const;
|
||||
int getActionOnDblClOnTorrentDl() const;
|
||||
int getActionOnDblClOnTorrentFn() const;
|
||||
// Connection options
|
||||
int getPort() const;
|
||||
bool isUPnPEnabled() const;
|
||||
bool isNATPMPEnabled() const;
|
||||
QPair<int,int> getGlobalBandwidthLimits() const;
|
||||
// Bittorrent options
|
||||
int getMaxConnecs() const;
|
||||
int getMaxConnecsPerTorrent() const;
|
||||
int getMaxUploadsPerTorrent() const;
|
||||
bool isDHTEnabled() const;
|
||||
bool isDHTPortSameAsBT() const;
|
||||
int getDHTPort() const;
|
||||
bool isLSDEnabled() const;
|
||||
bool isRSSEnabled() const;
|
||||
bool isUtorrentSpoofingEnabled() const;
|
||||
int getEncryptionSetting() const;
|
||||
float getDesiredRatio() const;
|
||||
float getDeleteRatio() const;
|
||||
// Proxy options
|
||||
QString getHTTPProxyIp() const;
|
||||
unsigned short getHTTPProxyPort() const;
|
||||
QString getHTTPProxyUsername() const;
|
||||
QString getHTTPProxyPassword() const;
|
||||
int getHTTPProxyType() const;
|
||||
bool isProxyEnabled() const;
|
||||
bool isHTTPProxyEnabled() const;
|
||||
bool isProxyAuthEnabled() const;
|
||||
bool isHTTPProxyAuthEnabled() const;
|
||||
QString getProxyIp() const;
|
||||
unsigned short getProxyPort() const;
|
||||
QString getProxyUsername() const;
|
||||
QString getProxyPassword() const;
|
||||
int getProxyType() const;
|
||||
bool useProxyForTrackers() const;
|
||||
bool useProxyForPeers() const;
|
||||
bool useProxyForWebseeds() const;
|
||||
bool useProxyForDHT() const;
|
||||
// IP Filter
|
||||
bool isFilteringEnabled() const;
|
||||
QString getFilter() const;
|
||||
// Queueing system
|
||||
bool isQueueingSystemEnabled() const;
|
||||
int getMaxActiveDownloads() const;
|
||||
int getMaxActiveUploads() const;
|
||||
int getMaxActiveTorrents() const;
|
||||
bool isWebUiEnabled() const;
|
||||
quint16 webUiPort() const;
|
||||
QString webUiUsername() const;
|
||||
QString webUiPassword() const;
|
||||
|
||||
protected slots:
|
||||
void enableUploadLimit(bool checked);
|
||||
void enableDownloadLimit(bool checked);
|
||||
void enableTempPathInput(bool checked);
|
||||
void enableDirScan(bool checked);
|
||||
void enableProxy(int comboIndex);
|
||||
void enableProxyAuth(bool checked);
|
||||
void enableProxyHTTP(int comboIndex);
|
||||
void enableProxyAuthHTTP(bool checked);
|
||||
void enableMaxConnecsLimit(bool checked);
|
||||
void enableMaxConnecsLimitPerTorrent(bool checked);
|
||||
void enableMaxUploadsLimitPerTorrent(bool checked);
|
||||
void enableShareRatio(bool checked);
|
||||
void enableDeleteRatio(bool checked);
|
||||
void enableFilter(bool checked);
|
||||
void enableRSS(bool checked);
|
||||
void enableDHTPortSettings(bool checked);
|
||||
void enableQueueingSystem(bool checked);
|
||||
void setStyle(int style);
|
||||
void on_buttonBox_accepted();
|
||||
void closeEvent(QCloseEvent *e);
|
||||
void on_buttonBox_rejected();
|
||||
void applySettings(QAbstractButton* button);
|
||||
void on_browseScanDirButton_clicked();
|
||||
void on_browseFilterButton_clicked();
|
||||
void on_browseSaveDirButton_clicked();
|
||||
void enableApplyButton();
|
||||
void enableSystrayOptions();
|
||||
void disableSystrayOptions();
|
||||
void setSystrayOptionsState(bool checked);
|
||||
void enableWebUi(bool checkBoxValue);
|
||||
void changePage(QListWidgetItem*, QListWidgetItem*);
|
||||
void adaptToScreenSize();
|
||||
void on_randomButton_clicked();
|
||||
protected slots:
|
||||
void enableUploadLimit(bool checked);
|
||||
void enableDownloadLimit(bool checked);
|
||||
void enableTempPathInput(bool checked);
|
||||
void enableDirScan(bool checked);
|
||||
void enableProxy(int comboIndex);
|
||||
void enableProxyAuth(bool checked);
|
||||
void enableProxyHTTP(int comboIndex);
|
||||
void enableProxyAuthHTTP(bool checked);
|
||||
void enableMaxConnecsLimit(bool checked);
|
||||
void enableMaxConnecsLimitPerTorrent(bool checked);
|
||||
void enableMaxUploadsLimitPerTorrent(bool checked);
|
||||
void enableShareRatio(bool checked);
|
||||
void enableDeleteRatio(bool checked);
|
||||
void enableFilter(bool checked);
|
||||
void enableRSS(bool checked);
|
||||
void enableDHTPortSettings(bool checked);
|
||||
void enableQueueingSystem(bool checked);
|
||||
void setStyle(int style);
|
||||
void on_buttonBox_accepted();
|
||||
void closeEvent(QCloseEvent *e);
|
||||
void on_buttonBox_rejected();
|
||||
void applySettings(QAbstractButton* button);
|
||||
void on_browseScanDirButton_clicked();
|
||||
void on_browseFilterButton_clicked();
|
||||
void on_browseSaveDirButton_clicked();
|
||||
void enableApplyButton();
|
||||
void enableSystrayOptions();
|
||||
void disableSystrayOptions();
|
||||
void setSystrayOptionsState(bool checked);
|
||||
void enableWebUi(bool checkBoxValue);
|
||||
void changePage(QListWidgetItem*, QListWidgetItem*);
|
||||
void loadWindowState();
|
||||
void saveWindowState() const;
|
||||
void on_randomButton_clicked();
|
||||
|
||||
public slots:
|
||||
void setLocale(QString locale);
|
||||
void useStyle();
|
||||
public slots:
|
||||
void setLocale(QString locale);
|
||||
void useStyle();
|
||||
|
||||
signals:
|
||||
void status_changed() const;
|
||||
void exitWithCancel();
|
||||
signals:
|
||||
void status_changed() const;
|
||||
void exitWithCancel();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue