mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-15 01:33:07 -07:00
Enable systray icon on Mac since it is supported by Qt
This commit is contained in:
parent
ccf0002c0f
commit
4013f9fefd
2 changed files with 1055 additions and 1070 deletions
10
src/GUI.cpp
10
src/GUI.cpp
|
@ -922,7 +922,6 @@ void GUI::optionsSaved() {
|
||||||
// Load program preferences
|
// Load program preferences
|
||||||
void GUI::loadPreferences(bool configure_session) {
|
void GUI::loadPreferences(bool configure_session) {
|
||||||
BTSession->addConsoleMessage(tr("Options were saved successfully."));
|
BTSession->addConsoleMessage(tr("Options were saved successfully."));
|
||||||
#ifndef Q_WS_MAC
|
|
||||||
const bool newSystrayIntegration = Preferences::systrayIntegration();
|
const bool newSystrayIntegration = Preferences::systrayIntegration();
|
||||||
actionLock_qBittorrent->setEnabled(newSystrayIntegration);
|
actionLock_qBittorrent->setEnabled(newSystrayIntegration);
|
||||||
if(newSystrayIntegration != (systrayIcon!=0)) {
|
if(newSystrayIntegration != (systrayIcon!=0)) {
|
||||||
|
@ -947,7 +946,6 @@ void GUI::loadPreferences(bool configure_session) {
|
||||||
delete myTrayIconMenu;
|
delete myTrayIconMenu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
// General
|
// General
|
||||||
if(Preferences::isToolbarDisplayed()) {
|
if(Preferences::isToolbarDisplayed()) {
|
||||||
toolBar->setVisible(true);
|
toolBar->setVisible(true);
|
||||||
|
@ -1011,9 +1009,8 @@ void GUI::trackerAuthenticationRequired(QTorrentHandle& h) {
|
||||||
// Check connection status and display right icon
|
// Check connection status and display right icon
|
||||||
void GUI::updateGUI() {
|
void GUI::updateGUI() {
|
||||||
// update global informations
|
// update global informations
|
||||||
#ifndef Q_WS_MAC
|
|
||||||
if(systrayIcon) {
|
if(systrayIcon) {
|
||||||
#if defined(Q_WS_X11)
|
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
|
||||||
QString html = "<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>";
|
QString html = "<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>";
|
||||||
html += tr("qBittorrent");
|
html += tr("qBittorrent");
|
||||||
html += "</div>";
|
html += "</div>";
|
||||||
|
@ -1031,7 +1028,6 @@ void GUI::updateGUI() {
|
||||||
#endif
|
#endif
|
||||||
systrayIcon->setToolTip(html); // tray icon
|
systrayIcon->setToolTip(html); // tray icon
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(displaySpeedInTitle) {
|
if(displaySpeedInTitle) {
|
||||||
setWindowTitle(tr("qBittorrent %1 (Down: %2/s, Up: %3/s)", "%1 is qBittorrent version").arg(QString::fromUtf8(VERSION)).arg(misc::friendlyUnit(BTSession->getSessionStatus().payload_download_rate)).arg(misc::friendlyUnit(BTSession->getSessionStatus().payload_upload_rate)));
|
setWindowTitle(tr("qBittorrent %1 (Down: %2/s, Up: %3/s)", "%1 is qBittorrent version").arg(QString::fromUtf8(VERSION)).arg(misc::friendlyUnit(BTSession->getSessionStatus().payload_download_rate)).arg(misc::friendlyUnit(BTSession->getSessionStatus().payload_upload_rate)));
|
||||||
}
|
}
|
||||||
|
@ -1051,10 +1047,8 @@ void GUI::showNotificationBaloon(QString title, QString msg) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef Q_WS_MAC
|
|
||||||
if(systrayIcon && QSystemTrayIcon::supportsMessages())
|
if(systrayIcon && QSystemTrayIcon::supportsMessages())
|
||||||
systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
|
systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
|
@ -1091,7 +1085,6 @@ void GUI::downloadFromURLList(const QStringList& url_list) {
|
||||||
*****************************************************/
|
*****************************************************/
|
||||||
|
|
||||||
void GUI::createSystrayDelayed() {
|
void GUI::createSystrayDelayed() {
|
||||||
#ifndef Q_WS_MAC
|
|
||||||
static int timeout = 20;
|
static int timeout = 20;
|
||||||
if(QSystemTrayIcon::isSystemTrayAvailable()) {
|
if(QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
// Ok, systray integration is now supported
|
// Ok, systray integration is now supported
|
||||||
|
@ -1112,7 +1105,6 @@ void GUI::createSystrayDelayed() {
|
||||||
Preferences::setSystrayIntegration(false);
|
Preferences::setSystrayIntegration(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::updateAltSpeedsBtn(bool alternative) {
|
void GUI::updateAltSpeedsBtn(bool alternative) {
|
||||||
|
|
|
@ -151,11 +151,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
// Load options
|
// Load options
|
||||||
loadOptions();
|
loadOptions();
|
||||||
// Disable systray integration if it is not supported by the system
|
// Disable systray integration if it is not supported by the system
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
if(1){
|
|
||||||
#else
|
|
||||||
if(!QSystemTrayIcon::isSystemTrayAvailable()){
|
if(!QSystemTrayIcon::isSystemTrayAvailable()){
|
||||||
#endif
|
|
||||||
checkShowSystray->setChecked(false);
|
checkShowSystray->setChecked(false);
|
||||||
checkShowSystray->setEnabled(false);
|
checkShowSystray->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -278,28 +274,28 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
// Adapt size
|
// Adapt size
|
||||||
show();
|
show();
|
||||||
loadWindowState();
|
loadWindowState();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main destructor
|
// Main destructor
|
||||||
options_imp::~options_imp(){
|
options_imp::~options_imp(){
|
||||||
qDebug("-> destructing Options");
|
qDebug("-> destructing Options");
|
||||||
foreach (const QString &path, addedScanDirs)
|
foreach (const QString &path, addedScanDirs)
|
||||||
ScanFoldersModel::instance()->removePath(path);
|
ScanFoldersModel::instance()->removePath(path);
|
||||||
delete scrollArea_advanced->layout();
|
delete scrollArea_advanced->layout();
|
||||||
delete advancedSettings;
|
delete advancedSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous) {
|
void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous) {
|
||||||
if (!current)
|
if (!current)
|
||||||
current = previous;
|
current = previous;
|
||||||
tabOption->setCurrentIndex(tabSelection->row(current));
|
tabOption->setCurrentIndex(tabSelection->row(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::useStyle() {
|
void options_imp::useStyle() {
|
||||||
QApplication::setStyle(QStyleFactory::create(comboStyle->itemText(comboStyle->currentIndex())));
|
QApplication::setStyle(QStyleFactory::create(comboStyle->itemText(comboStyle->currentIndex())));
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::loadWindowState() {
|
void options_imp::loadWindowState() {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
resize(settings.value(QString::fromUtf8("Preferences/State/size"), sizeFittingScreen()).toSize());
|
resize(settings.value(QString::fromUtf8("Preferences/State/size"), sizeFittingScreen()).toSize());
|
||||||
QPoint p = settings.value(QString::fromUtf8("Preferences/State/pos"), QPoint()).toPoint();
|
QPoint p = settings.value(QString::fromUtf8("Preferences/State/pos"), QPoint()).toPoint();
|
||||||
|
@ -317,9 +313,9 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
sizes << hsplitter->width()-130;
|
sizes << hsplitter->width()-130;
|
||||||
}
|
}
|
||||||
hsplitter->setSizes(sizes);
|
hsplitter->setSizes(sizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::saveWindowState() const {
|
void options_imp::saveWindowState() const {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
settings.setValue(QString::fromUtf8("Preferences/State/size"), size());
|
settings.setValue(QString::fromUtf8("Preferences/State/size"), size());
|
||||||
settings.setValue(QString::fromUtf8("Preferences/State/pos"), pos());
|
settings.setValue(QString::fromUtf8("Preferences/State/pos"), pos());
|
||||||
|
@ -328,9 +324,9 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
sizes_str << QString::number(hsplitter->sizes().first());
|
sizes_str << QString::number(hsplitter->sizes().first());
|
||||||
sizes_str << QString::number(hsplitter->sizes().last());
|
sizes_str << QString::number(hsplitter->sizes().last());
|
||||||
settings.setValue(QString::fromUtf8("Preferences/State/hSplitterSizes"), sizes_str);
|
settings.setValue(QString::fromUtf8("Preferences/State/hSplitterSizes"), sizes_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize options_imp::sizeFittingScreen() {
|
QSize options_imp::sizeFittingScreen() {
|
||||||
int scrn = 0;
|
int scrn = 0;
|
||||||
QWidget *w = this->topLevelWidget();
|
QWidget *w = this->topLevelWidget();
|
||||||
|
|
||||||
|
@ -347,9 +343,9 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
return QSize(desk.width(), desk.height());
|
return QSize(desk.width(), desk.height());
|
||||||
}
|
}
|
||||||
return size();
|
return size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::saveOptions(){
|
void options_imp::saveOptions(){
|
||||||
applyButton->setEnabled(false);
|
applyButton->setEnabled(false);
|
||||||
QIniSettings settings("qBittorrent", "qBittorrent");
|
QIniSettings settings("qBittorrent", "qBittorrent");
|
||||||
// Apply style
|
// Apply style
|
||||||
|
@ -511,13 +507,13 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
|
|
||||||
// Save advanced settings
|
// Save advanced settings
|
||||||
advancedSettings->saveAdvancedSettings();
|
advancedSettings->saveAdvancedSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isFilteringEnabled() const{
|
bool options_imp::isFilteringEnabled() const{
|
||||||
return checkIPFilter->isChecked();
|
return checkIPFilter->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getPeerProxyType() const{
|
int options_imp::getPeerProxyType() const{
|
||||||
switch(comboProxyType->currentIndex()) {
|
switch(comboProxyType->currentIndex()) {
|
||||||
case 1:
|
case 1:
|
||||||
return SOCKS4;
|
return SOCKS4;
|
||||||
|
@ -535,9 +531,9 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getHTTPProxyType() const {
|
int options_imp::getHTTPProxyType() const {
|
||||||
switch(comboProxyType_http->currentIndex()) {
|
switch(comboProxyType_http->currentIndex()) {
|
||||||
case 1: {
|
case 1: {
|
||||||
if(isHTTPProxyAuthEnabled()){
|
if(isHTTPProxyAuthEnabled()){
|
||||||
|
@ -554,23 +550,23 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
default:
|
default:
|
||||||
return -1; // Disabled
|
return -1; // Disabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getStyle() const{
|
QString options_imp::getStyle() const{
|
||||||
return comboStyle->itemText(comboStyle->currentIndex());
|
return comboStyle->itemText(comboStyle->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::setStyle(QString style) {
|
void options_imp::setStyle(QString style) {
|
||||||
int index = comboStyle->findText(style, Qt::MatchFixedString);
|
int index = comboStyle->findText(style, Qt::MatchFixedString);
|
||||||
if(index > 0)
|
if(index > 0)
|
||||||
comboStyle->setCurrentIndex(index);
|
comboStyle->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isHTTPProxyAuthEnabled() const{
|
bool options_imp::isHTTPProxyAuthEnabled() const{
|
||||||
return checkProxyAuth_http->isChecked();
|
return checkProxyAuth_http->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::loadOptions(){
|
void options_imp::loadOptions(){
|
||||||
int intValue;
|
int intValue;
|
||||||
float floatValue;
|
float floatValue;
|
||||||
QString strValue;
|
QString strValue;
|
||||||
|
@ -797,68 +793,68 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
// End Web UI
|
// End Web UI
|
||||||
// Random stuff
|
// Random stuff
|
||||||
srand(time(0));
|
srand(time(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// return min & max ports
|
// return min & max ports
|
||||||
// [min, max]
|
// [min, max]
|
||||||
int options_imp::getPort() const{
|
int options_imp::getPort() const{
|
||||||
return spinPort->value();
|
return spinPort->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_randomButton_clicked() {
|
void options_imp::on_randomButton_clicked() {
|
||||||
// Range [1024: 65535]
|
// Range [1024: 65535]
|
||||||
spinPort->setValue(rand() % 64512 + 1024);
|
spinPort->setValue(rand() % 64512 + 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getEncryptionSetting() const{
|
int options_imp::getEncryptionSetting() const{
|
||||||
return comboEncryption->currentIndex();
|
return comboEncryption->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getMaxActiveDownloads() const {
|
int options_imp::getMaxActiveDownloads() const {
|
||||||
return spinMaxActiveDownloads->value();
|
return spinMaxActiveDownloads->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getMaxActiveUploads() const {
|
int options_imp::getMaxActiveUploads() const {
|
||||||
return spinMaxActiveUploads->value();
|
return spinMaxActiveUploads->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getMaxActiveTorrents() const {
|
int options_imp::getMaxActiveTorrents() const {
|
||||||
return spinMaxActiveTorrents->value();
|
return spinMaxActiveTorrents->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::minimizeToTray() const{
|
bool options_imp::minimizeToTray() const{
|
||||||
if(!checkShowSystray->isChecked()) return false;
|
if(!checkShowSystray->isChecked()) return false;
|
||||||
return checkMinimizeToSysTray->isChecked();
|
return checkMinimizeToSysTray->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::closeToTray() const{
|
bool options_imp::closeToTray() const{
|
||||||
if(!checkShowSystray->isChecked()) return false;
|
if(!checkShowSystray->isChecked()) return false;
|
||||||
return checkCloseToSystray->isChecked();
|
return checkCloseToSystray->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isQueueingSystemEnabled() const {
|
bool options_imp::isQueueingSystemEnabled() const {
|
||||||
return checkEnableQueueing->isChecked();
|
return checkEnableQueueing->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isDHTEnabled() const{
|
bool options_imp::isDHTEnabled() const{
|
||||||
return checkDHT->isChecked();
|
return checkDHT->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isLSDEnabled() const{
|
bool options_imp::isLSDEnabled() const{
|
||||||
return checkLSD->isChecked();
|
return checkLSD->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isUPnPEnabled() const{
|
bool options_imp::isUPnPEnabled() const{
|
||||||
return checkUPnP->isChecked();
|
return checkUPnP->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isNATPMPEnabled() const{
|
bool options_imp::isNATPMPEnabled() const{
|
||||||
return checkNATPMP->isChecked();
|
return checkNATPMP->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Download & Upload limits in kbps
|
// Return Download & Upload limits in kbps
|
||||||
// [download,upload]
|
// [download,upload]
|
||||||
QPair<int,int> options_imp::getGlobalBandwidthLimits() const{
|
QPair<int,int> options_imp::getGlobalBandwidthLimits() const{
|
||||||
int DL = -1, UP = -1;
|
int DL = -1, UP = -1;
|
||||||
if(checkDownloadLimit->isChecked()){
|
if(checkDownloadLimit->isChecked()){
|
||||||
DL = spinDownloadLimit->value();
|
DL = spinDownloadLimit->value();
|
||||||
|
@ -867,35 +863,32 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
UP = spinUploadLimit->value();
|
UP = spinUploadLimit->value();
|
||||||
}
|
}
|
||||||
return qMakePair(DL, UP);
|
return qMakePair(DL, UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::startMinimized() const {
|
bool options_imp::startMinimized() const {
|
||||||
if(checkStartMinimized->isChecked()) return true;
|
if(checkStartMinimized->isChecked()) return true;
|
||||||
return checkStartMinimized->isChecked();
|
return checkStartMinimized->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::systrayIntegration() const{
|
bool options_imp::systrayIntegration() const{
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) return false;
|
if (!QSystemTrayIcon::isSystemTrayAvailable()) return false;
|
||||||
return checkShowSystray->isChecked();
|
return checkShowSystray->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getDHTPort() const {
|
int options_imp::getDHTPort() const {
|
||||||
return spinDHTPort->value();
|
return spinDHTPort->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Share ratio
|
// Return Share ratio
|
||||||
float options_imp::getMaxRatio() const{
|
float options_imp::getMaxRatio() const{
|
||||||
if(checkMaxRatio->isChecked()){
|
if(checkMaxRatio->isChecked()){
|
||||||
return spinMaxRatio->value();
|
return spinMaxRatio->value();
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Save Path
|
// Return Save Path
|
||||||
QString options_imp::getSavePath() const{
|
QString options_imp::getSavePath() const{
|
||||||
if(textSavePath->text().trimmed().isEmpty()){
|
if(textSavePath->text().trimmed().isEmpty()){
|
||||||
QString save_path = Preferences::getSavePath();
|
QString save_path = Preferences::getSavePath();
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||||
|
@ -904,42 +897,42 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
textSavePath->setText(save_path);
|
textSavePath->setText(save_path);
|
||||||
}
|
}
|
||||||
return misc::expandPath(textSavePath->text());
|
return misc::expandPath(textSavePath->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getTempPath() const {
|
QString options_imp::getTempPath() const {
|
||||||
return misc::expandPath(textTempPath->text());
|
return misc::expandPath(textTempPath->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isTempPathEnabled() const {
|
bool options_imp::isTempPathEnabled() const {
|
||||||
return checkTempFolder->isChecked();
|
return checkTempFolder->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return max connections number
|
// Return max connections number
|
||||||
int options_imp::getMaxConnecs() const{
|
int options_imp::getMaxConnecs() const{
|
||||||
if(!checkMaxConnecs->isChecked()){
|
if(!checkMaxConnecs->isChecked()){
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
}else{
|
||||||
return spinMaxConnec->value();
|
return spinMaxConnec->value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getMaxConnecsPerTorrent() const{
|
int options_imp::getMaxConnecsPerTorrent() const{
|
||||||
if(!checkMaxConnecsPerTorrent->isChecked()){
|
if(!checkMaxConnecsPerTorrent->isChecked()){
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
}else{
|
||||||
return spinMaxConnecPerTorrent->value();
|
return spinMaxConnecPerTorrent->value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int options_imp::getMaxUploadsPerTorrent() const{
|
int options_imp::getMaxUploadsPerTorrent() const{
|
||||||
if(!checkMaxUploadsPerTorrent->isChecked()){
|
if(!checkMaxUploadsPerTorrent->isChecked()){
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
}else{
|
||||||
return spinMaxUploadsPerTorrent->value();
|
return spinMaxUploadsPerTorrent->value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_buttonBox_accepted(){
|
void options_imp::on_buttonBox_accepted(){
|
||||||
if(applyButton->isEnabled()){
|
if(applyButton->isEnabled()){
|
||||||
saveOptions();
|
saveOptions();
|
||||||
applyButton->setEnabled(false);
|
applyButton->setEnabled(false);
|
||||||
|
@ -948,85 +941,85 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
}
|
}
|
||||||
saveWindowState();
|
saveWindowState();
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::applySettings(QAbstractButton* button) {
|
void options_imp::applySettings(QAbstractButton* button) {
|
||||||
if(button == applyButton){
|
if(button == applyButton){
|
||||||
saveOptions();
|
saveOptions();
|
||||||
emit status_changed();
|
emit status_changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::closeEvent(QCloseEvent *e){
|
void options_imp::closeEvent(QCloseEvent *e){
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
e->accept();
|
e->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_buttonBox_rejected(){
|
void options_imp::on_buttonBox_rejected(){
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableDownloadLimit(bool checked){
|
void options_imp::enableDownloadLimit(bool checked){
|
||||||
if(checked){
|
if(checked){
|
||||||
spinDownloadLimit->setEnabled(true);
|
spinDownloadLimit->setEnabled(true);
|
||||||
}else{
|
}else{
|
||||||
spinDownloadLimit->setEnabled(false);
|
spinDownloadLimit->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::useAdditionDialog() const{
|
bool options_imp::useAdditionDialog() const{
|
||||||
return checkAdditionDialog->isChecked();
|
return checkAdditionDialog->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableMaxConnecsLimit(bool checked){
|
void options_imp::enableMaxConnecsLimit(bool checked){
|
||||||
spinMaxConnec->setEnabled(checked);
|
spinMaxConnec->setEnabled(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableMaxConnecsLimitPerTorrent(bool checked){
|
void options_imp::enableMaxConnecsLimitPerTorrent(bool checked){
|
||||||
spinMaxConnecPerTorrent->setEnabled(checked);
|
spinMaxConnecPerTorrent->setEnabled(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableSystrayOptions() {
|
void options_imp::enableSystrayOptions() {
|
||||||
checkCloseToSystray->setEnabled(true);
|
checkCloseToSystray->setEnabled(true);
|
||||||
checkMinimizeToSysTray->setEnabled(true);
|
checkMinimizeToSysTray->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::disableSystrayOptions() {
|
void options_imp::disableSystrayOptions() {
|
||||||
checkCloseToSystray->setEnabled(false);
|
checkCloseToSystray->setEnabled(false);
|
||||||
checkMinimizeToSysTray->setEnabled(false);
|
checkMinimizeToSysTray->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::setSystrayOptionsState(bool checked) {
|
void options_imp::setSystrayOptionsState(bool checked) {
|
||||||
if(checked) {
|
if(checked) {
|
||||||
enableSystrayOptions();
|
enableSystrayOptions();
|
||||||
} else {
|
} else {
|
||||||
disableSystrayOptions();
|
disableSystrayOptions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableMaxUploadsLimitPerTorrent(bool checked){
|
void options_imp::enableMaxUploadsLimitPerTorrent(bool checked){
|
||||||
if(checked){
|
if(checked){
|
||||||
spinMaxUploadsPerTorrent->setEnabled(true);
|
spinMaxUploadsPerTorrent->setEnabled(true);
|
||||||
}else{
|
}else{
|
||||||
spinMaxUploadsPerTorrent->setEnabled(false);
|
spinMaxUploadsPerTorrent->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableUploadLimit(bool checked){
|
void options_imp::enableUploadLimit(bool checked){
|
||||||
spinUploadLimit->setEnabled(checked);
|
spinUploadLimit->setEnabled(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableApplyButton(){
|
void options_imp::enableApplyButton(){
|
||||||
applyButton->setEnabled(true);
|
applyButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableMaxRatio(bool checked){
|
void options_imp::enableMaxRatio(bool checked){
|
||||||
spinMaxRatio->setEnabled(checked);
|
spinMaxRatio->setEnabled(checked);
|
||||||
comboRatioLimitAct->setEnabled(checked);
|
comboRatioLimitAct->setEnabled(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enablePeerProxy(int index){
|
void options_imp::enablePeerProxy(int index){
|
||||||
if(index){
|
if(index){
|
||||||
//enable
|
//enable
|
||||||
lblProxyIP->setEnabled(true);
|
lblProxyIP->setEnabled(true);
|
||||||
|
@ -1048,9 +1041,9 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
checkProxyAuth->setEnabled(false);
|
checkProxyAuth->setEnabled(false);
|
||||||
checkProxyAuth->setChecked(false);
|
checkProxyAuth->setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableHTTPProxy(int index){
|
void options_imp::enableHTTPProxy(int index){
|
||||||
bool enable = (index > 0);
|
bool enable = (index > 0);
|
||||||
lblProxyIP_http->setEnabled(enable);
|
lblProxyIP_http->setEnabled(enable);
|
||||||
textProxyIP_http->setEnabled(enable);
|
textProxyIP_http->setEnabled(enable);
|
||||||
|
@ -1060,130 +1053,130 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
|
|
||||||
if(!enable)
|
if(!enable)
|
||||||
checkProxyAuth_http->setChecked(false);
|
checkProxyAuth_http->setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enablePeerProxyAuth(bool checked){
|
void options_imp::enablePeerProxyAuth(bool checked){
|
||||||
lblProxyUsername->setEnabled(checked);
|
lblProxyUsername->setEnabled(checked);
|
||||||
lblProxyPassword->setEnabled(checked);
|
lblProxyPassword->setEnabled(checked);
|
||||||
textProxyUsername->setEnabled(checked);
|
textProxyUsername->setEnabled(checked);
|
||||||
textProxyPassword->setEnabled(checked);
|
textProxyPassword->setEnabled(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::enableHTTPProxyAuth(bool checked){
|
void options_imp::enableHTTPProxyAuth(bool checked){
|
||||||
lblProxyUsername_http->setEnabled(checked);
|
lblProxyUsername_http->setEnabled(checked);
|
||||||
lblProxyPassword_http->setEnabled(checked);
|
lblProxyPassword_http->setEnabled(checked);
|
||||||
textProxyUsername_http->setEnabled(checked);
|
textProxyUsername_http->setEnabled(checked);
|
||||||
textProxyPassword_http->setEnabled(checked);
|
textProxyPassword_http->setEnabled(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isSlashScreenDisabled() const {
|
bool options_imp::isSlashScreenDisabled() const {
|
||||||
return !checkShowSplash->isChecked();
|
return !checkShowSplash->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::preAllocateAllFiles() const {
|
bool options_imp::preAllocateAllFiles() const {
|
||||||
return checkPreallocateAll->isChecked();
|
return checkPreallocateAll->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::addTorrentsInPause() const {
|
bool options_imp::addTorrentsInPause() const {
|
||||||
return checkStartPaused->isChecked();
|
return checkStartPaused->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isDHTPortSameAsBT() const {
|
bool options_imp::isDHTPortSameAsBT() const {
|
||||||
return !checkDifferentDHTPort->isChecked();
|
return !checkDifferentDHTPort->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proxy settings
|
// Proxy settings
|
||||||
bool options_imp::isPeerProxyEnabled() const{
|
bool options_imp::isPeerProxyEnabled() const{
|
||||||
return comboProxyType->currentIndex();
|
return comboProxyType->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isHTTPProxyEnabled() const {
|
bool options_imp::isHTTPProxyEnabled() const {
|
||||||
return comboProxyType_http->currentIndex();
|
return comboProxyType_http->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isPeerProxyAuthEnabled() const{
|
bool options_imp::isPeerProxyAuthEnabled() const{
|
||||||
return checkProxyAuth->isChecked();
|
return checkProxyAuth->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getPeerProxyIp() const{
|
QString options_imp::getPeerProxyIp() const{
|
||||||
QString ip = textProxyIP->text();
|
QString ip = textProxyIP->text();
|
||||||
ip = ip.trimmed();
|
ip = ip.trimmed();
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getHTTPProxyIp() const{
|
QString options_imp::getHTTPProxyIp() const{
|
||||||
QString ip = textProxyIP_http->text();
|
QString ip = textProxyIP_http->text();
|
||||||
ip = ip.trimmed();
|
ip = ip.trimmed();
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short options_imp::getPeerProxyPort() const{
|
unsigned short options_imp::getPeerProxyPort() const{
|
||||||
return spinProxyPort->value();
|
return spinProxyPort->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short options_imp::getHTTPProxyPort() const{
|
unsigned short options_imp::getHTTPProxyPort() const{
|
||||||
return spinProxyPort_http->value();
|
return spinProxyPort_http->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getPeerProxyUsername() const{
|
QString options_imp::getPeerProxyUsername() const{
|
||||||
QString username = textProxyUsername->text();
|
QString username = textProxyUsername->text();
|
||||||
username = username.trimmed();
|
username = username.trimmed();
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getHTTPProxyUsername() const{
|
QString options_imp::getHTTPProxyUsername() const{
|
||||||
QString username = textProxyUsername_http->text();
|
QString username = textProxyUsername_http->text();
|
||||||
username = username.trimmed();
|
username = username.trimmed();
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getPeerProxyPassword() const{
|
QString options_imp::getPeerProxyPassword() const{
|
||||||
QString password = textProxyPassword->text();
|
QString password = textProxyPassword->text();
|
||||||
password = password.trimmed();
|
password = password.trimmed();
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getHTTPProxyPassword() const{
|
QString options_imp::getHTTPProxyPassword() const{
|
||||||
QString password = textProxyPassword_http->text();
|
QString password = textProxyPassword_http->text();
|
||||||
password = password.trimmed();
|
password = password.trimmed();
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locale Settings
|
// Locale Settings
|
||||||
QString options_imp::getLocale() const{
|
QString options_imp::getLocale() const{
|
||||||
return locales.at(comboI18n->currentIndex());
|
return locales.at(comboI18n->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::setLocale(QString locale){
|
void options_imp::setLocale(QString locale){
|
||||||
int indexLocales=locales.indexOf(QRegExp(locale));
|
int indexLocales=locales.indexOf(QRegExp(locale));
|
||||||
if(indexLocales != -1){
|
if(indexLocales != -1){
|
||||||
comboI18n->setCurrentIndex(indexLocales);
|
comboI18n->setCurrentIndex(indexLocales);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getExportDir() const {
|
QString options_imp::getExportDir() const {
|
||||||
if(checkExportDir->isChecked()){
|
if(checkExportDir->isChecked()){
|
||||||
return misc::expandPath(textExportDir->text());
|
return misc::expandPath(textExportDir->text());
|
||||||
}else{
|
}else{
|
||||||
return QString::null;
|
return QString::null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return action on double-click on a downloading torrent set in options
|
// 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)
|
if(actionTorrentDlOnDblClBox->currentIndex()<1)
|
||||||
return 0;
|
return 0;
|
||||||
return actionTorrentDlOnDblClBox->currentIndex();
|
return actionTorrentDlOnDblClBox->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return action on double-click on a finished torrent set in options
|
// 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)
|
if(actionTorrentFnOnDblClBox->currentIndex()<1)
|
||||||
return 0;
|
return 0;
|
||||||
return actionTorrentFnOnDblClBox->currentIndex();
|
return actionTorrentFnOnDblClBox->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_addScanFolderButton_clicked() {
|
void options_imp::on_addScanFolderButton_clicked() {
|
||||||
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"));
|
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"));
|
||||||
if (!dir.isEmpty()) {
|
if (!dir.isEmpty()) {
|
||||||
const ScanFoldersModel::PathStatus status = ScanFoldersModel::instance()->addPath(dir, false);
|
const ScanFoldersModel::PathStatus status = ScanFoldersModel::instance()->addPath(dir, false);
|
||||||
|
@ -1207,22 +1200,22 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
QMessageBox::warning(this, tr("Failure"), tr("Failed to add Scan Folder '%1': %2").arg(dir).arg(error));
|
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
|
const QModelIndexList selected
|
||||||
= scanFoldersView->selectionModel()->selectedIndexes();
|
= scanFoldersView->selectionModel()->selectedIndexes();
|
||||||
if (selected.isEmpty())
|
if (selected.isEmpty())
|
||||||
return;
|
return;
|
||||||
Q_ASSERT(selected.count() == ScanFoldersModel::instance()->columnCount());
|
Q_ASSERT(selected.count() == ScanFoldersModel::instance()->columnCount());
|
||||||
ScanFoldersModel::instance()->removePath(selected.first().row());
|
ScanFoldersModel::instance()->removePath(selected.first().row());
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::handleScanFolderViewSelectionChanged() {
|
void options_imp::handleScanFolderViewSelectionChanged() {
|
||||||
removeScanFolderButton->setEnabled(!scanFoldersView->selectionModel()->selectedIndexes().isEmpty());
|
removeScanFolderButton->setEnabled(!scanFoldersView->selectionModel()->selectedIndexes().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseExportDirButton_clicked() {
|
void options_imp::on_browseExportDirButton_clicked() {
|
||||||
QString export_path = misc::expandPath(textExportDir->text());
|
QString export_path = misc::expandPath(textExportDir->text());
|
||||||
QDir exportDir(export_path);
|
QDir exportDir(export_path);
|
||||||
QString dir;
|
QString dir;
|
||||||
|
@ -1237,9 +1230,9 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
#endif
|
#endif
|
||||||
textExportDir->setText(dir);
|
textExportDir->setText(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseFilterButton_clicked() {
|
void options_imp::on_browseFilterButton_clicked() {
|
||||||
QString filter_path = misc::expandPath(textFilterPath->text());
|
QString filter_path = misc::expandPath(textFilterPath->text());
|
||||||
QDir filterDir(filter_path);
|
QDir filterDir(filter_path);
|
||||||
QString ipfilter;
|
QString ipfilter;
|
||||||
|
@ -1254,10 +1247,10 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
#endif
|
#endif
|
||||||
textFilterPath->setText(ipfilter);
|
textFilterPath->setText(ipfilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display dialog to choose save dir
|
// Display dialog to choose save dir
|
||||||
void options_imp::on_browseSaveDirButton_clicked(){
|
void options_imp::on_browseSaveDirButton_clicked(){
|
||||||
QString save_path = misc::expandPath(textSavePath->text());
|
QString save_path = misc::expandPath(textSavePath->text());
|
||||||
QDir saveDir(save_path);
|
QDir saveDir(save_path);
|
||||||
QString dir;
|
QString dir;
|
||||||
|
@ -1272,9 +1265,9 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
#endif
|
#endif
|
||||||
textSavePath->setText(dir);
|
textSavePath->setText(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseTempDirButton_clicked(){
|
void options_imp::on_browseTempDirButton_clicked(){
|
||||||
QString temp_path = misc::expandPath(textTempPath->text());
|
QString temp_path = misc::expandPath(textTempPath->text());
|
||||||
QDir tempDir(temp_path);
|
QDir tempDir(temp_path);
|
||||||
QString dir;
|
QString dir;
|
||||||
|
@ -1289,31 +1282,31 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||||
#endif
|
#endif
|
||||||
textTempPath->setText(dir);
|
textTempPath->setText(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Filter object to apply to BT session
|
// Return Filter object to apply to BT session
|
||||||
QString options_imp::getFilter() const{
|
QString options_imp::getFilter() const{
|
||||||
return textFilterPath->text();
|
return textFilterPath->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Web UI
|
// Web UI
|
||||||
|
|
||||||
bool options_imp::isWebUiEnabled() const
|
bool options_imp::isWebUiEnabled() const
|
||||||
{
|
{
|
||||||
return checkWebUi->isChecked();
|
return checkWebUi->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
quint16 options_imp::webUiPort() const
|
quint16 options_imp::webUiPort() const
|
||||||
{
|
{
|
||||||
return spinWebUiPort->value();
|
return spinWebUiPort->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::webUiUsername() const
|
QString options_imp::webUiUsername() const
|
||||||
{
|
{
|
||||||
return textWebUiUsername->text();
|
return textWebUiUsername->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::webUiPassword() const
|
QString options_imp::webUiPassword() const
|
||||||
{
|
{
|
||||||
return textWebUiPassword->text();
|
return textWebUiPassword->text();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue