mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 16:53:08 -07:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
c27aa7723e
commit
e0935fe14f
2 changed files with 1289 additions and 1209 deletions
|
@ -57,8 +57,10 @@
|
|||
#endif
|
||||
|
||||
// Constructor
|
||||
options_imp::options_imp(QWidget *parent):
|
||||
QDialog(parent), m_refreshingIpFilter(false) {
|
||||
options_imp::options_imp(QWidget *parent)
|
||||
: QDialog(parent),
|
||||
m_refreshingIpFilter(false)
|
||||
{
|
||||
qDebug("-> Constructing Options");
|
||||
setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -94,17 +96,16 @@ options_imp::options_imp(QWidget *parent):
|
|||
scanFoldersView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
scanFoldersView->setModel(ScanFoldersModel::instance());
|
||||
connect(ScanFoldersModel::instance(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(enableApplyButton()));
|
||||
connect(scanFoldersView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleScanFolderViewSelectionChanged()));
|
||||
connect(ScanFoldersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(enableApplyButton()));
|
||||
connect(scanFoldersView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(handleScanFolderViewSelectionChanged()));
|
||||
|
||||
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(applySettings(QAbstractButton*)));
|
||||
// Languages supported
|
||||
initializeLanguageCombo();
|
||||
|
||||
// Load week days (scheduler)
|
||||
for (uint i=1; i<=7; ++i) {
|
||||
for (uint i = 1; i <= 7; ++i)
|
||||
schedule_days->addItem(QDate::longDayName(i, QDate::StandaloneFormat));
|
||||
}
|
||||
|
||||
// Load options
|
||||
loadOptions();
|
||||
|
@ -126,7 +127,7 @@ options_imp::options_imp(QWidget *parent):
|
|||
#endif
|
||||
|
||||
// Connect signals / slots
|
||||
connect(comboProxyType, SIGNAL(currentIndexChanged(int)),this, SLOT(enableProxy(int)));
|
||||
connect(comboProxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(enableProxy(int)));
|
||||
connect(checkRandomPort, SIGNAL(toggled(bool)), spinPort, SLOT(setDisabled(bool)));
|
||||
|
||||
// Apply button is activated when a value is changed
|
||||
|
@ -291,13 +292,14 @@ void options_imp::initializeLanguageCombo()
|
|||
localeStr.chop(3); // Remove ".qm"
|
||||
QLocale locale(localeStr);
|
||||
QString language_name = languageToLocalizedString(locale);
|
||||
comboI18n->addItem(/*QIcon(":/icons/flags/"+country+".png"), */language_name, localeStr);
|
||||
comboI18n->addItem(/*QIcon(":/icons/flags/"+country+".png"), */ language_name, localeStr);
|
||||
qDebug() << "Supported locale:" << localeStr;
|
||||
}
|
||||
}
|
||||
|
||||
// Main destructor
|
||||
options_imp::~options_imp() {
|
||||
options_imp::~options_imp()
|
||||
{
|
||||
qDebug("-> destructing Options");
|
||||
foreach (const QString &path, addedScanDirs)
|
||||
ScanFoldersModel::instance()->removePath(path);
|
||||
|
@ -305,13 +307,15 @@ options_imp::~options_imp() {
|
|||
delete advancedSettings;
|
||||
}
|
||||
|
||||
void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous) {
|
||||
void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||||
{
|
||||
if (!current)
|
||||
current = previous;
|
||||
tabOption->setCurrentIndex(tabSelection->row(current));
|
||||
}
|
||||
|
||||
void options_imp::loadWindowState() {
|
||||
void options_imp::loadWindowState()
|
||||
{
|
||||
const Preferences* const pref = Preferences::instance();
|
||||
resize(pref->getPrefSize(sizeFittingScreen()));
|
||||
QPoint p = pref->getPrefPos();
|
||||
|
@ -325,14 +329,16 @@ void options_imp::loadWindowState() {
|
|||
if (sizes_str.size() == 2) {
|
||||
sizes << sizes_str.first().toInt();
|
||||
sizes << sizes_str.last().toInt();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sizes << 116;
|
||||
sizes << hsplitter->width()-116;
|
||||
sizes << hsplitter->width() - 116;
|
||||
}
|
||||
hsplitter->setSizes(sizes);
|
||||
}
|
||||
|
||||
void options_imp::saveWindowState() const {
|
||||
void options_imp::saveWindowState() const
|
||||
{
|
||||
Preferences* const pref = Preferences::instance();
|
||||
pref->setPrefSize(size());
|
||||
pref->setPrefPos(pos());
|
||||
|
@ -343,7 +349,8 @@ void options_imp::saveWindowState() const {
|
|||
pref->setPrefHSplitterSizes(sizes_str);
|
||||
}
|
||||
|
||||
QSize options_imp::sizeFittingScreen() const {
|
||||
QSize options_imp::sizeFittingScreen() const
|
||||
{
|
||||
int scrn = 0;
|
||||
QWidget *w = this->topLevelWidget();
|
||||
|
||||
|
@ -355,25 +362,24 @@ QSize options_imp::sizeFittingScreen() const {
|
|||
scrn = QApplication::desktop()->screenNumber(this);
|
||||
|
||||
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)
|
||||
return QSize(desk.width(), desk.height());
|
||||
}
|
||||
return size();
|
||||
}
|
||||
|
||||
void options_imp::saveOptions() {
|
||||
void options_imp::saveOptions()
|
||||
{
|
||||
applyButton->setEnabled(false);
|
||||
Preferences* const pref = Preferences::instance();
|
||||
// Load the translation
|
||||
QString locale = getLocale();
|
||||
if (pref->getLocale() != locale) {
|
||||
QTranslator *translator = new QTranslator;
|
||||
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
|
||||
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale))
|
||||
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
||||
}else{
|
||||
else
|
||||
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
|
||||
}
|
||||
qApp->installTranslator(translator);
|
||||
}
|
||||
|
||||
|
@ -482,13 +488,11 @@ void options_imp::saveOptions() {
|
|||
// End Queueing system preferences
|
||||
// Web UI
|
||||
pref->setWebUiEnabled(isWebUiEnabled());
|
||||
if (isWebUiEnabled())
|
||||
{
|
||||
if (isWebUiEnabled()) {
|
||||
pref->setWebUiPort(webUiPort());
|
||||
pref->setUPnPForWebUIPort(checkWebUIUPnP->isChecked());
|
||||
pref->setWebUiHttpsEnabled(checkWebUiHttps->isChecked());
|
||||
if (checkWebUiHttps->isChecked())
|
||||
{
|
||||
if (checkWebUiHttps->isChecked()) {
|
||||
pref->setWebUiHttpsCertificate(m_sslCert);
|
||||
pref->setWebUiHttpsKey(m_sslKey);
|
||||
}
|
||||
|
@ -512,31 +516,32 @@ void options_imp::saveOptions() {
|
|||
pref->apply();
|
||||
}
|
||||
|
||||
bool options_imp::isFilteringEnabled() const {
|
||||
bool options_imp::isFilteringEnabled() const
|
||||
{
|
||||
return checkIPFilter->isChecked();
|
||||
}
|
||||
|
||||
int options_imp::getProxyType() const {
|
||||
switch(comboProxyType->currentIndex()) {
|
||||
int options_imp::getProxyType() const
|
||||
{
|
||||
switch (comboProxyType->currentIndex()) {
|
||||
case 1:
|
||||
return Proxy::SOCKS4;
|
||||
break;
|
||||
case 2:
|
||||
if (isProxyAuthEnabled()) {
|
||||
if (isProxyAuthEnabled())
|
||||
return Proxy::SOCKS5_PW;
|
||||
}
|
||||
return Proxy::SOCKS5;
|
||||
case 3:
|
||||
if (isProxyAuthEnabled()) {
|
||||
if (isProxyAuthEnabled())
|
||||
return Proxy::HTTP_PW;
|
||||
}
|
||||
return Proxy::HTTP;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void options_imp::loadOptions() {
|
||||
void options_imp::loadOptions()
|
||||
{
|
||||
int intValue;
|
||||
qreal floatValue;
|
||||
QString strValue;
|
||||
|
@ -573,11 +578,10 @@ void options_imp::loadOptions() {
|
|||
checkStartPaused->setChecked(pref->addTorrentsInPause());
|
||||
|
||||
textSavePath->setText(Utils::Fs::toNativePath(pref->getSavePath()));
|
||||
if (pref->isTempPathEnabled()) {
|
||||
if (pref->isTempPathEnabled())
|
||||
checkTempFolder->setChecked(true);
|
||||
} else {
|
||||
else
|
||||
checkTempFolder->setChecked(false);
|
||||
}
|
||||
textTempPath->setText(Utils::Fs::toNativePath(pref->getTempPath()));
|
||||
checkAppendLabel->setChecked(pref->appendTorrentLabel());
|
||||
checkAppendqB->setChecked(pref->useIncompleteFilesExtension());
|
||||
|
@ -587,7 +591,8 @@ void options_imp::loadOptions() {
|
|||
if (strValue.isEmpty()) {
|
||||
// Disable
|
||||
checkExportDir->setChecked(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Enable
|
||||
checkExportDir->setChecked(true);
|
||||
textExportDir->setText(strValue);
|
||||
|
@ -597,7 +602,8 @@ void options_imp::loadOptions() {
|
|||
if (strValue.isEmpty()) {
|
||||
// Disable
|
||||
checkExportDirFin->setChecked(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Enable
|
||||
checkExportDirFin->setChecked(true);
|
||||
textExportDirFin->setText(strValue);
|
||||
|
@ -635,7 +641,8 @@ void options_imp::loadOptions() {
|
|||
checkMaxConnecs->setChecked(true);
|
||||
spinMaxConnec->setEnabled(true);
|
||||
spinMaxConnec->setValue(intValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// disable
|
||||
checkMaxConnecs->setChecked(false);
|
||||
spinMaxConnec->setEnabled(false);
|
||||
|
@ -646,7 +653,8 @@ void options_imp::loadOptions() {
|
|||
checkMaxConnecsPerTorrent->setChecked(true);
|
||||
spinMaxConnecPerTorrent->setEnabled(true);
|
||||
spinMaxConnecPerTorrent->setValue(intValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// disable
|
||||
checkMaxConnecsPerTorrent->setChecked(false);
|
||||
spinMaxConnecPerTorrent->setEnabled(false);
|
||||
|
@ -657,7 +665,8 @@ void options_imp::loadOptions() {
|
|||
checkMaxUploads->setChecked(true);
|
||||
spinMaxUploads->setEnabled(true);
|
||||
spinMaxUploads->setValue(intValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// disable
|
||||
checkMaxUploads->setChecked(false);
|
||||
spinMaxUploads->setEnabled(false);
|
||||
|
@ -668,14 +677,15 @@ void options_imp::loadOptions() {
|
|||
checkMaxUploadsPerTorrent->setChecked(true);
|
||||
spinMaxUploadsPerTorrent->setEnabled(true);
|
||||
spinMaxUploadsPerTorrent->setValue(intValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// disable
|
||||
checkMaxUploadsPerTorrent->setChecked(false);
|
||||
spinMaxUploadsPerTorrent->setEnabled(false);
|
||||
}
|
||||
|
||||
intValue = pref->getProxyType();
|
||||
switch(intValue) {
|
||||
switch (intValue) {
|
||||
case Proxy::SOCKS4:
|
||||
comboProxyType->setCurrentIndex(1);
|
||||
break;
|
||||
|
@ -712,7 +722,8 @@ void options_imp::loadOptions() {
|
|||
checkDownloadLimit->setChecked(true);
|
||||
spinDownloadLimit->setEnabled(true);
|
||||
spinDownloadLimit->setValue(intValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Disabled
|
||||
checkDownloadLimit->setChecked(false);
|
||||
spinDownloadLimit->setEnabled(false);
|
||||
|
@ -723,7 +734,8 @@ void options_imp::loadOptions() {
|
|||
checkUploadLimit->setChecked(true);
|
||||
spinUploadLimit->setEnabled(true);
|
||||
spinUploadLimit->setValue(intValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Disabled
|
||||
checkUploadLimit->setChecked(false);
|
||||
spinUploadLimit->setEnabled(false);
|
||||
|
@ -735,7 +747,8 @@ void options_imp::loadOptions() {
|
|||
checkDownloadLimitAlt->setChecked(true);
|
||||
spinDownloadLimitAlt->setEnabled(true);
|
||||
spinDownloadLimitAlt->setValue(intValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Disabled
|
||||
checkDownloadLimitAlt->setChecked(false);
|
||||
spinDownloadLimitAlt->setEnabled(false);
|
||||
|
@ -746,7 +759,8 @@ void options_imp::loadOptions() {
|
|||
checkUploadLimitAlt->setChecked(true);
|
||||
spinUploadLimitAlt->setEnabled(true);
|
||||
spinUploadLimitAlt->setValue(intValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Disabled
|
||||
checkUploadLimitAlt->setChecked(false);
|
||||
spinUploadLimitAlt->setEnabled(false);
|
||||
|
@ -783,7 +797,8 @@ void options_imp::loadOptions() {
|
|||
spinMaxRatio->setEnabled(true);
|
||||
comboRatioLimitAct->setEnabled(true);
|
||||
spinMaxRatio->setValue(floatValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Disable
|
||||
checkMaxRatio->setChecked(false);
|
||||
spinMaxRatio->setEnabled(false);
|
||||
|
@ -813,102 +828,115 @@ void options_imp::loadOptions() {
|
|||
|
||||
// return min & max ports
|
||||
// [min, max]
|
||||
int options_imp::getPort() const {
|
||||
int options_imp::getPort() const
|
||||
{
|
||||
return spinPort->value();
|
||||
}
|
||||
|
||||
void options_imp::on_randomButton_clicked() {
|
||||
void options_imp::on_randomButton_clicked()
|
||||
{
|
||||
// Range [1024: 65535]
|
||||
spinPort->setValue(rand() % 64512 + 1024);
|
||||
}
|
||||
|
||||
int options_imp::getEncryptionSetting() const {
|
||||
int options_imp::getEncryptionSetting() const
|
||||
{
|
||||
return comboEncryption->currentIndex();
|
||||
}
|
||||
|
||||
int options_imp::getMaxActiveDownloads() const {
|
||||
int options_imp::getMaxActiveDownloads() const
|
||||
{
|
||||
return spinMaxActiveDownloads->value();
|
||||
}
|
||||
|
||||
int options_imp::getMaxActiveUploads() const {
|
||||
int options_imp::getMaxActiveUploads() const
|
||||
{
|
||||
return spinMaxActiveUploads->value();
|
||||
}
|
||||
|
||||
int options_imp::getMaxActiveTorrents() const {
|
||||
int options_imp::getMaxActiveTorrents() const
|
||||
{
|
||||
return spinMaxActiveTorrents->value();
|
||||
}
|
||||
|
||||
bool options_imp::minimizeToTray() const {
|
||||
bool options_imp::minimizeToTray() const
|
||||
{
|
||||
if (!checkShowSystray->isChecked()) return false;
|
||||
return checkMinimizeToSysTray->isChecked();
|
||||
}
|
||||
|
||||
bool options_imp::closeToTray() const {
|
||||
bool options_imp::closeToTray() const
|
||||
{
|
||||
if (!checkShowSystray->isChecked()) return false;
|
||||
return checkCloseToSystray->isChecked();
|
||||
}
|
||||
|
||||
bool options_imp::isQueueingSystemEnabled() const {
|
||||
bool options_imp::isQueueingSystemEnabled() const
|
||||
{
|
||||
return checkEnableQueueing->isChecked();
|
||||
}
|
||||
|
||||
bool options_imp::isDHTEnabled() const {
|
||||
bool options_imp::isDHTEnabled() const
|
||||
{
|
||||
return checkDHT->isChecked();
|
||||
}
|
||||
|
||||
bool options_imp::isLSDEnabled() const {
|
||||
bool options_imp::isLSDEnabled() const
|
||||
{
|
||||
return checkLSD->isChecked();
|
||||
}
|
||||
|
||||
bool options_imp::isUPnPEnabled() const {
|
||||
bool options_imp::isUPnPEnabled() const
|
||||
{
|
||||
return checkUPnP->isChecked();
|
||||
}
|
||||
|
||||
// Return Download & Upload limits in kbps
|
||||
// [download,upload]
|
||||
QPair<int,int> options_imp::getGlobalBandwidthLimits() const {
|
||||
QPair<int, int> options_imp::getGlobalBandwidthLimits() const
|
||||
{
|
||||
int DL = -1, UP = -1;
|
||||
if (checkDownloadLimit->isChecked()) {
|
||||
if (checkDownloadLimit->isChecked())
|
||||
DL = spinDownloadLimit->value();
|
||||
}
|
||||
if (checkUploadLimit->isChecked()) {
|
||||
if (checkUploadLimit->isChecked())
|
||||
UP = spinUploadLimit->value();
|
||||
}
|
||||
return qMakePair(DL, UP);
|
||||
}
|
||||
|
||||
// Return alternate Download & Upload limits in kbps
|
||||
// [download,upload]
|
||||
QPair<int,int> options_imp::getAltGlobalBandwidthLimits() const {
|
||||
QPair<int, int> options_imp::getAltGlobalBandwidthLimits() const
|
||||
{
|
||||
int DL = -1, UP = -1;
|
||||
if (checkDownloadLimitAlt->isChecked()) {
|
||||
if (checkDownloadLimitAlt->isChecked())
|
||||
DL = spinDownloadLimitAlt->value();
|
||||
}
|
||||
if (checkUploadLimitAlt->isChecked()) {
|
||||
if (checkUploadLimitAlt->isChecked())
|
||||
UP = spinUploadLimitAlt->value();
|
||||
}
|
||||
return qMakePair(DL, UP);
|
||||
}
|
||||
|
||||
bool options_imp::startMinimized() const {
|
||||
bool options_imp::startMinimized() const
|
||||
{
|
||||
return checkStartMinimized->isChecked();
|
||||
}
|
||||
|
||||
bool options_imp::systrayIntegration() const {
|
||||
bool options_imp::systrayIntegration() const
|
||||
{
|
||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) return false;
|
||||
return checkShowSystray->isChecked();
|
||||
}
|
||||
|
||||
// Return Share ratio
|
||||
qreal options_imp::getMaxRatio() const {
|
||||
if (checkMaxRatio->isChecked()) {
|
||||
qreal options_imp::getMaxRatio() const
|
||||
{
|
||||
if (checkMaxRatio->isChecked())
|
||||
return spinMaxRatio->value();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Return Save Path
|
||||
QString options_imp::getSavePath() const {
|
||||
QString options_imp::getSavePath() const
|
||||
{
|
||||
if (textSavePath->text().trimmed().isEmpty()) {
|
||||
QString save_path = Preferences::instance()->getSavePath();
|
||||
textSavePath->setText(Utils::Fs::toNativePath(save_path));
|
||||
|
@ -916,48 +944,51 @@ QString options_imp::getSavePath() const {
|
|||
return Utils::Fs::expandPathAbs(textSavePath->text());
|
||||
}
|
||||
|
||||
QString options_imp::getTempPath() const {
|
||||
QString options_imp::getTempPath() const
|
||||
{
|
||||
return Utils::Fs::expandPathAbs(textTempPath->text());
|
||||
}
|
||||
|
||||
bool options_imp::isTempPathEnabled() const {
|
||||
bool options_imp::isTempPathEnabled() const
|
||||
{
|
||||
return checkTempFolder->isChecked();
|
||||
}
|
||||
|
||||
// Return max connections number
|
||||
int options_imp::getMaxConnecs() const {
|
||||
if (!checkMaxConnecs->isChecked()) {
|
||||
int options_imp::getMaxConnecs() const
|
||||
{
|
||||
if (!checkMaxConnecs->isChecked())
|
||||
return -1;
|
||||
}else{
|
||||
else
|
||||
return spinMaxConnec->value();
|
||||
}
|
||||
}
|
||||
|
||||
int options_imp::getMaxConnecsPerTorrent() const {
|
||||
if (!checkMaxConnecsPerTorrent->isChecked()) {
|
||||
int options_imp::getMaxConnecsPerTorrent() const
|
||||
{
|
||||
if (!checkMaxConnecsPerTorrent->isChecked())
|
||||
return -1;
|
||||
}else{
|
||||
else
|
||||
return spinMaxConnecPerTorrent->value();
|
||||
}
|
||||
}
|
||||
|
||||
int options_imp::getMaxUploads() const {
|
||||
if (!checkMaxUploads->isChecked()) {
|
||||
int options_imp::getMaxUploads() const
|
||||
{
|
||||
if (!checkMaxUploads->isChecked())
|
||||
return -1;
|
||||
}else{
|
||||
else
|
||||
return spinMaxUploads->value();
|
||||
}
|
||||
}
|
||||
|
||||
int options_imp::getMaxUploadsPerTorrent() const {
|
||||
if (!checkMaxUploadsPerTorrent->isChecked()) {
|
||||
int options_imp::getMaxUploadsPerTorrent() const
|
||||
{
|
||||
if (!checkMaxUploadsPerTorrent->isChecked())
|
||||
return -1;
|
||||
}else{
|
||||
else
|
||||
return spinMaxUploadsPerTorrent->value();
|
||||
}
|
||||
}
|
||||
|
||||
void options_imp::on_buttonBox_accepted() {
|
||||
void options_imp::on_buttonBox_accepted()
|
||||
{
|
||||
if (applyButton->isEnabled()) {
|
||||
if (!schedTimesOk()) {
|
||||
tabSelection->setCurrentRow(TAB_SPEED);
|
||||
|
@ -972,7 +1003,8 @@ void options_imp::on_buttonBox_accepted() {
|
|||
accept();
|
||||
}
|
||||
|
||||
void options_imp::applySettings(QAbstractButton* button) {
|
||||
void options_imp::applySettings(QAbstractButton* button)
|
||||
{
|
||||
if (button == applyButton) {
|
||||
if (!schedTimesOk()) {
|
||||
tabSelection->setCurrentRow(TAB_SPEED);
|
||||
|
@ -983,25 +1015,30 @@ void options_imp::applySettings(QAbstractButton* button) {
|
|||
}
|
||||
}
|
||||
|
||||
void options_imp::closeEvent(QCloseEvent *e) {
|
||||
void options_imp::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
e->accept();
|
||||
}
|
||||
|
||||
void options_imp::on_buttonBox_rejected() {
|
||||
void options_imp::on_buttonBox_rejected()
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
reject();
|
||||
}
|
||||
|
||||
bool options_imp::useAdditionDialog() const {
|
||||
bool options_imp::useAdditionDialog() const
|
||||
{
|
||||
return checkAdditionDialog->isChecked();
|
||||
}
|
||||
|
||||
void options_imp::enableApplyButton() {
|
||||
void options_imp::enableApplyButton()
|
||||
{
|
||||
applyButton->setEnabled(true);
|
||||
}
|
||||
|
||||
void options_imp::enableProxy(int index) {
|
||||
void options_imp::enableProxy(int index)
|
||||
{
|
||||
if (index) {
|
||||
//enable
|
||||
lblProxyIP->setEnabled(true);
|
||||
|
@ -1013,11 +1050,13 @@ void options_imp::enableProxy(int index) {
|
|||
isProxyOnlyForTorrents->setEnabled(true);
|
||||
if (index > 1) {
|
||||
checkProxyAuth->setEnabled(true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
checkProxyAuth->setEnabled(false);
|
||||
checkProxyAuth->setChecked(false);
|
||||
}
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
//disable
|
||||
lblProxyIP->setEnabled(false);
|
||||
textProxyIP->setEnabled(false);
|
||||
|
@ -1031,68 +1070,81 @@ void options_imp::enableProxy(int index) {
|
|||
}
|
||||
}
|
||||
|
||||
bool options_imp::isSlashScreenDisabled() const {
|
||||
bool options_imp::isSlashScreenDisabled() const
|
||||
{
|
||||
return !checkShowSplash->isChecked();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool options_imp::WinStartup() const {
|
||||
bool options_imp::WinStartup() const
|
||||
{
|
||||
return checkStartup->isChecked();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool options_imp::preventFromSuspend() const {
|
||||
bool options_imp::preventFromSuspend() const
|
||||
{
|
||||
return checkPreventFromSuspend->isChecked();
|
||||
}
|
||||
|
||||
bool options_imp::preAllocateAllFiles() const {
|
||||
bool options_imp::preAllocateAllFiles() const
|
||||
{
|
||||
return checkPreallocateAll->isChecked();
|
||||
}
|
||||
|
||||
bool options_imp::addTorrentsInPause() const {
|
||||
bool options_imp::addTorrentsInPause() const
|
||||
{
|
||||
return checkStartPaused->isChecked();
|
||||
}
|
||||
|
||||
// Proxy settings
|
||||
bool options_imp::isProxyEnabled() const {
|
||||
bool options_imp::isProxyEnabled() const
|
||||
{
|
||||
return comboProxyType->currentIndex();
|
||||
}
|
||||
|
||||
bool options_imp::isProxyAuthEnabled() const {
|
||||
bool options_imp::isProxyAuthEnabled() const
|
||||
{
|
||||
return checkProxyAuth->isChecked();
|
||||
}
|
||||
|
||||
QString options_imp::getProxyIp() const {
|
||||
QString options_imp::getProxyIp() const
|
||||
{
|
||||
return textProxyIP->text().trimmed();
|
||||
}
|
||||
|
||||
unsigned short options_imp::getProxyPort() const {
|
||||
unsigned short options_imp::getProxyPort() const
|
||||
{
|
||||
return spinProxyPort->value();
|
||||
}
|
||||
|
||||
QString options_imp::getProxyUsername() const {
|
||||
QString options_imp::getProxyUsername() const
|
||||
{
|
||||
QString username = textProxyUsername->text();
|
||||
username = username.trimmed();
|
||||
return username;
|
||||
}
|
||||
|
||||
QString options_imp::getProxyPassword() const {
|
||||
QString options_imp::getProxyPassword() const
|
||||
{
|
||||
QString password = textProxyPassword->text();
|
||||
password = password.trimmed();
|
||||
return password;
|
||||
}
|
||||
|
||||
// Locale Settings
|
||||
QString options_imp::getLocale() const {
|
||||
QString options_imp::getLocale() const
|
||||
{
|
||||
return comboI18n->itemData(comboI18n->currentIndex(), Qt::UserRole).toString();
|
||||
}
|
||||
|
||||
void options_imp::setLocale(const QString &localeStr) {
|
||||
void options_imp::setLocale(const QString &localeStr)
|
||||
{
|
||||
QLocale locale(localeStr);
|
||||
QString name = locale.name();
|
||||
// Attempt to find exact match
|
||||
int index = comboI18n->findData(name, Qt::UserRole);
|
||||
if (index < 0 ) {
|
||||
if (index < 0) {
|
||||
//Attempt to find a language match without a country
|
||||
int pos = name.indexOf('_');
|
||||
if (pos > -1) {
|
||||
|
@ -1108,33 +1160,38 @@ void options_imp::setLocale(const QString &localeStr) {
|
|||
comboI18n->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
QString options_imp::getTorrentExportDir() const {
|
||||
QString options_imp::getTorrentExportDir() const
|
||||
{
|
||||
if (checkExportDir->isChecked())
|
||||
return Utils::Fs::expandPathAbs(textExportDir->text());
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString options_imp::getFinishedTorrentExportDir() const {
|
||||
QString options_imp::getFinishedTorrentExportDir() const
|
||||
{
|
||||
if (checkExportDirFin->isChecked())
|
||||
return Utils::Fs::expandPathAbs(textExportDirFin->text());
|
||||
return QString();
|
||||
}
|
||||
|
||||
// Return action on double-click on a downloading torrent set in options
|
||||
int options_imp::getActionOnDblClOnTorrentDl() const {
|
||||
int options_imp::getActionOnDblClOnTorrentDl() const
|
||||
{
|
||||
if (actionTorrentDlOnDblClBox->currentIndex() < 1)
|
||||
return 0;
|
||||
return actionTorrentDlOnDblClBox->currentIndex();
|
||||
}
|
||||
|
||||
// Return action on double-click on a finished torrent set in options
|
||||
int options_imp::getActionOnDblClOnTorrentFn() const {
|
||||
int options_imp::getActionOnDblClOnTorrentFn() const
|
||||
{
|
||||
if (actionTorrentFnOnDblClBox->currentIndex() < 1)
|
||||
return 0;
|
||||
return actionTorrentFnOnDblClBox->currentIndex();
|
||||
}
|
||||
|
||||
void options_imp::on_addScanFolderButton_clicked() {
|
||||
void options_imp::on_addScanFolderButton_clicked()
|
||||
{
|
||||
Preferences* const pref = Preferences::instance();
|
||||
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"),
|
||||
Utils::Fs::toNativePath(Utils::Fs::folderName(pref->getScanDirsLastPath())));
|
||||
|
@ -1158,13 +1215,13 @@ void options_imp::on_addScanFolderButton_clicked() {
|
|||
enableApplyButton();
|
||||
}
|
||||
|
||||
if (!error.isEmpty()) {
|
||||
if (!error.isEmpty())
|
||||
QMessageBox::warning(this, tr("Failure"), tr("Failed to add Scan Folder '%1': %2").arg(dir).arg(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void options_imp::on_removeScanFolderButton_clicked() {
|
||||
void options_imp::on_removeScanFolderButton_clicked()
|
||||
{
|
||||
const QModelIndexList selected
|
||||
= scanFoldersView->selectionModel()->selectedIndexes();
|
||||
if (selected.isEmpty())
|
||||
|
@ -1173,7 +1230,8 @@ void options_imp::on_removeScanFolderButton_clicked() {
|
|||
ScanFoldersModel::instance()->removePath(selected.first().row());
|
||||
}
|
||||
|
||||
void options_imp::handleScanFolderViewSelectionChanged() {
|
||||
void options_imp::handleScanFolderViewSelectionChanged()
|
||||
{
|
||||
removeScanFolderButton->setEnabled(!scanFoldersView->selectionModel()->selectedIndexes().isEmpty());
|
||||
}
|
||||
|
||||
|
@ -1181,68 +1239,70 @@ QString options_imp::askForExportDir(const QString& currentExportPath)
|
|||
{
|
||||
QDir currentExportDir(Utils::Fs::expandPathAbs(currentExportPath));
|
||||
QString dir;
|
||||
if (!currentExportPath.isEmpty() && currentExportDir.exists()) {
|
||||
if (!currentExportPath.isEmpty() && currentExportDir.exists())
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), currentExportDir.absolutePath());
|
||||
} else {
|
||||
else
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), QDir::homePath());
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
void options_imp::on_browseExportDirButton_clicked() {
|
||||
void options_imp::on_browseExportDirButton_clicked()
|
||||
{
|
||||
const QString newExportDir = askForExportDir(textExportDir->text());
|
||||
if (!newExportDir.isNull())
|
||||
textExportDir->setText(Utils::Fs::toNativePath(newExportDir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseExportDirFinButton_clicked() {
|
||||
void options_imp::on_browseExportDirFinButton_clicked()
|
||||
{
|
||||
const QString newExportDir = askForExportDir(textExportDirFin->text());
|
||||
if (!newExportDir.isNull())
|
||||
textExportDirFin->setText(Utils::Fs::toNativePath(newExportDir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseFilterButton_clicked() {
|
||||
void options_imp::on_browseFilterButton_clicked()
|
||||
{
|
||||
const QString filter_path = Utils::Fs::expandPathAbs(textFilterPath->text());
|
||||
QDir filterDir(filter_path);
|
||||
QString ipfilter;
|
||||
if (!filter_path.isEmpty() && filterDir.exists()) {
|
||||
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an IP filter file"), filterDir.absolutePath(), tr("Filters")+QString(" (*.dat *.p2p *.p2b)"));
|
||||
} else {
|
||||
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an IP filter file"), QDir::homePath(), tr("Filters")+QString(" (*.dat *.p2p *.p2b)"));
|
||||
}
|
||||
if (!filter_path.isEmpty() && filterDir.exists())
|
||||
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an IP filter file"), filterDir.absolutePath(), tr("Filters") + QString(" (*.dat *.p2p *.p2b)"));
|
||||
else
|
||||
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an IP filter file"), QDir::homePath(), tr("Filters") + QString(" (*.dat *.p2p *.p2b)"));
|
||||
if (!ipfilter.isNull())
|
||||
textFilterPath->setText(Utils::Fs::toNativePath(ipfilter));
|
||||
}
|
||||
|
||||
// Display dialog to choose save dir
|
||||
void options_imp::on_browseSaveDirButton_clicked() {
|
||||
void options_imp::on_browseSaveDirButton_clicked()
|
||||
{
|
||||
const QString save_path = Utils::Fs::expandPathAbs(textSavePath->text());
|
||||
QDir saveDir(save_path);
|
||||
QString dir;
|
||||
if (!save_path.isEmpty() && saveDir.exists()) {
|
||||
if (!save_path.isEmpty() && saveDir.exists())
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), saveDir.absolutePath());
|
||||
} else {
|
||||
else
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||
}
|
||||
if (!dir.isNull())
|
||||
textSavePath->setText(Utils::Fs::toNativePath(dir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseTempDirButton_clicked() {
|
||||
void options_imp::on_browseTempDirButton_clicked()
|
||||
{
|
||||
const QString temp_path = Utils::Fs::expandPathAbs(textTempPath->text());
|
||||
QDir tempDir(temp_path);
|
||||
QString dir;
|
||||
if (!temp_path.isEmpty() && tempDir.exists()) {
|
||||
if (!temp_path.isEmpty() && tempDir.exists())
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), tempDir.absolutePath());
|
||||
} else {
|
||||
else
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||
}
|
||||
if (!dir.isNull())
|
||||
textTempPath->setText(Utils::Fs::toNativePath(dir));
|
||||
}
|
||||
|
||||
// Return Filter object to apply to BT session
|
||||
QString options_imp::getFilter() const {
|
||||
QString options_imp::getFilter() const
|
||||
{
|
||||
return Utils::Fs::fromNativePath(textFilterPath->text());
|
||||
}
|
||||
|
||||
|
@ -1273,8 +1333,9 @@ void options_imp::showConnectionTab()
|
|||
tabSelection->setCurrentRow(TAB_CONNECTION);
|
||||
}
|
||||
|
||||
void options_imp::on_btnWebUiCrt_clicked() {
|
||||
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Certificate")+QString(" (*.crt *.pem)"));
|
||||
void options_imp::on_btnWebUiCrt_clicked()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Certificate") + QString(" (*.crt *.pem)"));
|
||||
if (filename.isNull())
|
||||
return;
|
||||
QFile file(filename);
|
||||
|
@ -1284,8 +1345,9 @@ void options_imp::on_btnWebUiCrt_clicked() {
|
|||
}
|
||||
}
|
||||
|
||||
void options_imp::on_btnWebUiKey_clicked() {
|
||||
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Key")+QString(" (*.key *.pem)"));
|
||||
void options_imp::on_btnWebUiKey_clicked()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("SSL Key") + QString(" (*.key *.pem)"));
|
||||
if (filename.isNull())
|
||||
return;
|
||||
QFile file(filename);
|
||||
|
@ -1295,11 +1357,13 @@ void options_imp::on_btnWebUiKey_clicked() {
|
|||
}
|
||||
}
|
||||
|
||||
void options_imp::on_registerDNSBtn_clicked() {
|
||||
void options_imp::on_registerDNSBtn_clicked()
|
||||
{
|
||||
QDesktopServices::openUrl(Net::DNSUpdater::getRegistrationUrl(comboDNSService->currentIndex()));
|
||||
}
|
||||
|
||||
void options_imp::on_IpFilterRefreshBtn_clicked() {
|
||||
void options_imp::on_IpFilterRefreshBtn_clicked()
|
||||
{
|
||||
if (m_refreshingIpFilter) return;
|
||||
m_refreshingIpFilter = true;
|
||||
// Updating program preferences
|
||||
|
@ -1315,18 +1379,17 @@ void options_imp::on_IpFilterRefreshBtn_clicked() {
|
|||
void options_imp::handleIPFilterParsed(bool error, int ruleCount)
|
||||
{
|
||||
setCursor(QCursor(Qt::ArrowCursor));
|
||||
if (error) {
|
||||
if (error)
|
||||
QMessageBox::warning(this, tr("Parsing error"), tr("Failed to parse the provided IP filter"));
|
||||
} else {
|
||||
else
|
||||
QMessageBox::information(this, tr("Successfully refreshed"), tr("Successfully parsed the provided IP filter: %1 rules were applied.", "%1 is a number").arg(ruleCount));
|
||||
}
|
||||
m_refreshingIpFilter = false;
|
||||
disconnect(BitTorrent::Session::instance(), SIGNAL(ipFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int)));
|
||||
}
|
||||
|
||||
QString options_imp::languageToLocalizedString(const QLocale &locale)
|
||||
{
|
||||
switch(locale.language()) {
|
||||
switch (locale.language()) {
|
||||
case QLocale::English: {
|
||||
if (locale.country() == QLocale::Australia)
|
||||
return QString::fromUtf8(C_LOCALE_ENGLISH_AUSTRALIA);
|
||||
|
@ -1375,7 +1438,7 @@ QString options_imp::languageToLocalizedString(const QLocale &locale)
|
|||
case QLocale::Basque: return QString::fromUtf8(C_LOCALE_BASQUE);
|
||||
case QLocale::Vietnamese: return QString::fromUtf8(C_LOCALE_VIETNAMESE);
|
||||
case QLocale::Chinese: {
|
||||
switch(locale.country()) {
|
||||
switch (locale.country()) {
|
||||
case QLocale::China:
|
||||
return QString::fromUtf8(C_LOCALE_CHINESE_SIMPLIFIED);
|
||||
case QLocale::HongKong:
|
||||
|
@ -1401,7 +1464,8 @@ void options_imp::setSslKey(const QByteArray &key, bool interactive)
|
|||
if (!key.isEmpty() && !QSslKey(key, QSsl::Rsa).isNull()) {
|
||||
lblSslKeyStatus->setPixmap(QPixmap(":/icons/oxygen/security-high.png").scaledToHeight(20, Qt::SmoothTransformation));
|
||||
m_sslKey = key;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lblSslKeyStatus->setPixmap(QPixmap(":/icons/oxygen/security-low.png").scaledToHeight(20, Qt::SmoothTransformation));
|
||||
m_sslKey.clear();
|
||||
if (interactive)
|
||||
|
@ -1416,7 +1480,8 @@ void options_imp::setSslCertificate(const QByteArray &cert, bool interactive)
|
|||
if (!cert.isEmpty() && !QSslCertificate(cert).isNull()) {
|
||||
lblSslCertStatus->setPixmap(QPixmap(":/icons/oxygen/security-high.png").scaledToHeight(20, Qt::SmoothTransformation));
|
||||
m_sslCert = cert;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lblSslCertStatus->setPixmap(QPixmap(":/icons/oxygen/security-low.png").scaledToHeight(20, Qt::SmoothTransformation));
|
||||
m_sslCert.clear();
|
||||
if (interactive)
|
||||
|
@ -1425,7 +1490,8 @@ void options_imp::setSslCertificate(const QByteArray &cert, bool interactive)
|
|||
#endif
|
||||
}
|
||||
|
||||
bool options_imp::schedTimesOk() {
|
||||
bool options_imp::schedTimesOk()
|
||||
{
|
||||
QString msg;
|
||||
|
||||
if (schedule_from->time() == schedule_to->time())
|
||||
|
|
|
@ -34,7 +34,12 @@
|
|||
#include "ui_options.h"
|
||||
|
||||
// actions on double-click on torrents
|
||||
enum DoubleClickAction {TOGGLE_PAUSE, OPEN_DEST, NO_ACTION};
|
||||
enum DoubleClickAction
|
||||
{
|
||||
TOGGLE_PAUSE,
|
||||
OPEN_DEST,
|
||||
NO_ACTION
|
||||
};
|
||||
|
||||
class AdvancedSettings;
|
||||
|
||||
|
@ -42,14 +47,24 @@ QT_BEGIN_NAMESPACE
|
|||
class QCloseEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class options_imp : public QDialog, private Ui_Preferences {
|
||||
class options_imp: public QDialog, private Ui_Preferences
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
enum Tabs {TAB_UI, TAB_DOWNLOADS, TAB_CONNECTION, TAB_SPEED, TAB_BITTORRENT, TAB_WEBUI, TAB_ADVANCED};
|
||||
enum Tabs
|
||||
{
|
||||
TAB_UI,
|
||||
TAB_DOWNLOADS,
|
||||
TAB_CONNECTION,
|
||||
TAB_SPEED,
|
||||
TAB_BITTORRENT,
|
||||
TAB_WEBUI,
|
||||
TAB_ADVANCED
|
||||
};
|
||||
|
||||
public:
|
||||
// Constructor / Destructor
|
||||
options_imp(QWidget *parent=0);
|
||||
options_imp(QWidget *parent = 0);
|
||||
~options_imp();
|
||||
|
||||
public slots:
|
||||
|
@ -117,8 +132,8 @@ private:
|
|||
// Connection options
|
||||
int getPort() const;
|
||||
bool isUPnPEnabled() const;
|
||||
QPair<int,int> getGlobalBandwidthLimits() const;
|
||||
QPair<int,int> getAltGlobalBandwidthLimits() const;
|
||||
QPair<int, int> getGlobalBandwidthLimits() const;
|
||||
QPair<int, int> getAltGlobalBandwidthLimits() const;
|
||||
// Bittorrent options
|
||||
int getMaxConnecs() const;
|
||||
int getMaxConnecsPerTorrent() const;
|
||||
|
@ -163,7 +178,6 @@ private:
|
|||
QList<QString> addedScanDirs;
|
||||
// SSL Cert / key
|
||||
QByteArray m_sslCert, m_sslKey;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue