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