2009-04-09 18:55:47 +00:00
|
|
|
/*
|
2014-01-19 01:09:44 +00:00
|
|
|
* This file Copyright (C) 2009-2014 Mnemosyne LLC
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
2014-12-21 23:49:39 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
2009-05-31 19:33:48 +00:00
|
|
|
* $Id$
|
2009-04-09 18:55:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cassert>
|
2013-08-24 17:53:45 +00:00
|
|
|
#include <climits> /* INT_MAX */
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QComboBox>
|
2009-10-06 00:27:26 +00:00
|
|
|
#include <QCoreApplication>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QDoubleSpinBox>
|
2009-10-06 00:27:26 +00:00
|
|
|
#include <QFileIconProvider>
|
|
|
|
#include <QFileInfo>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QHBoxLayout>
|
2009-10-06 00:27:26 +00:00
|
|
|
#include <QIcon>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QList>
|
2009-10-06 00:27:26 +00:00
|
|
|
#include <QMessageBox>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QStyle>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QTime>
|
|
|
|
#include <QTimeEdit>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
#include "column-resizer.h"
|
2013-02-09 04:05:03 +00:00
|
|
|
#include "freespace-label.h"
|
2010-07-03 01:10:36 +00:00
|
|
|
#include "formatter.h"
|
2009-04-09 18:55:47 +00:00
|
|
|
#include "hig.h"
|
|
|
|
#include "prefs.h"
|
|
|
|
#include "prefs-dialog.h"
|
|
|
|
#include "session.h"
|
2010-06-04 01:00:27 +00:00
|
|
|
#include "utils.h"
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
const char * PREF_KEY ("pref-key");
|
2015-01-25 15:47:03 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
setPrefKey (QObject * object, int key)
|
|
|
|
{
|
|
|
|
object->setProperty (PREF_KEY, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
getPrefKey (const QObject * object)
|
|
|
|
{
|
|
|
|
return object->property (PREF_KEY).toInt ();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
qtDayToTrDay (int day)
|
|
|
|
{
|
|
|
|
switch (day)
|
|
|
|
{
|
|
|
|
case Qt::Monday:
|
|
|
|
return TR_SCHED_MON;
|
|
|
|
case Qt::Tuesday:
|
|
|
|
return TR_SCHED_TUES;
|
|
|
|
case Qt::Wednesday:
|
|
|
|
return TR_SCHED_WED;
|
|
|
|
case Qt::Thursday:
|
|
|
|
return TR_SCHED_THURS;
|
|
|
|
case Qt::Friday:
|
|
|
|
return TR_SCHED_FRI;
|
|
|
|
case Qt::Saturday:
|
|
|
|
return TR_SCHED_SAT;
|
|
|
|
case Qt::Sunday:
|
|
|
|
return TR_SCHED_SUN;
|
|
|
|
default:
|
|
|
|
assert (0 && "Invalid day of week");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
|
|
|
qtDayName (int day)
|
|
|
|
{
|
|
|
|
switch (day)
|
|
|
|
{
|
|
|
|
case Qt::Monday:
|
|
|
|
return PrefsDialog::tr ("Monday");
|
|
|
|
case Qt::Tuesday:
|
|
|
|
return PrefsDialog::tr ("Tuesday");
|
|
|
|
case Qt::Wednesday:
|
|
|
|
return PrefsDialog::tr ("Wednesday");
|
|
|
|
case Qt::Thursday:
|
|
|
|
return PrefsDialog::tr ("Thursday");
|
|
|
|
case Qt::Friday:
|
|
|
|
return PrefsDialog::tr ("Friday");
|
|
|
|
case Qt::Saturday:
|
|
|
|
return PrefsDialog::tr ("Saturday");
|
|
|
|
case Qt::Sunday:
|
|
|
|
return PrefsDialog::tr ("Sunday");
|
|
|
|
default:
|
|
|
|
assert (0 && "Invalid day of week");
|
|
|
|
return QString ();
|
|
|
|
}
|
|
|
|
}
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
bool
|
|
|
|
PrefsDialog::updateWidgetValue (QWidget * widget, int prefKey)
|
|
|
|
{
|
|
|
|
if (auto w = qobject_cast<QCheckBox*> (widget))
|
|
|
|
w->setChecked (myPrefs.getBool (prefKey));
|
|
|
|
else if (auto w = qobject_cast<QSpinBox*> (widget))
|
|
|
|
w->setValue (myPrefs.getInt (prefKey));
|
|
|
|
else if (auto w = qobject_cast<QDoubleSpinBox*> (widget))
|
|
|
|
w->setValue (myPrefs.getDouble (prefKey));
|
|
|
|
else if (auto w = qobject_cast<QTimeEdit*> (widget))
|
2015-02-06 20:08:36 +00:00
|
|
|
w->setTime (QTime (0, 0).addSecs (myPrefs.getInt(prefKey) * 60));
|
2015-01-25 15:47:03 +00:00
|
|
|
else if (auto w = qobject_cast<QLineEdit*> (widget))
|
|
|
|
w->setText (myPrefs.getString (prefKey));
|
2015-01-25 19:55:05 +00:00
|
|
|
else if (auto w = qobject_cast<TrPathButton*> (widget))
|
|
|
|
w->setPath (myPrefs.getString (prefKey));
|
2015-01-25 15:47:03 +00:00
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::linkWidgetToPref (QWidget * widget, int prefKey)
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
setPrefKey (widget, prefKey);
|
|
|
|
updateWidgetValue (widget, prefKey);
|
|
|
|
myWidgets.insert (prefKey, widget);
|
|
|
|
|
|
|
|
if (widget->inherits ("QCheckBox"))
|
|
|
|
connect (widget, SIGNAL (toggled (bool)), SLOT (checkBoxToggled (bool)));
|
|
|
|
else if (widget->inherits ("QTimeEdit"))
|
|
|
|
connect (widget, SIGNAL (editingFinished ()), SLOT (timeEditingFinished ()));
|
|
|
|
else if (widget->inherits ("QLineEdit"))
|
|
|
|
connect (widget, SIGNAL (editingFinished ()), SLOT (lineEditingFinished ()));
|
2015-01-25 19:55:05 +00:00
|
|
|
else if (widget->inherits ("TrPathButton"))
|
|
|
|
connect (widget, SIGNAL (pathChanged (QString)), SLOT (pathChanged (QString)));
|
2015-01-25 15:47:03 +00:00
|
|
|
else if (widget->inherits ("QAbstractSpinBox"))
|
|
|
|
connect (widget, SIGNAL (editingFinished ()), SLOT (spinBoxEditingFinished ()));
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-25 15:47:03 +00:00
|
|
|
PrefsDialog::checkBoxToggled (bool checked)
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
if (auto c = qobject_cast<QCheckBox*> (sender ()))
|
|
|
|
setPref (getPrefKey (c), checked);
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::spinBoxEditingFinished ()
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
const QObject * spin = sender();
|
2015-01-25 15:47:03 +00:00
|
|
|
const int key = getPrefKey (spin);
|
2013-09-14 22:45:04 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
if (auto e = qobject_cast<const QDoubleSpinBox*> (spin))
|
|
|
|
setPref (key, e->value ());
|
|
|
|
else if (auto e = qobject_cast<const QSpinBox*> (spin))
|
|
|
|
setPref (key, e->value ());
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-25 15:47:03 +00:00
|
|
|
PrefsDialog::timeEditingFinished ()
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
if (auto e = qobject_cast<const QTimeEdit*> (sender ()))
|
2015-02-06 20:08:36 +00:00
|
|
|
setPref(getPrefKey (e), QTime (0, 0).secsTo (e->time()) / 60);
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::lineEditingFinished ()
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
if (auto e = qobject_cast<const QLineEdit*> (sender ()))
|
2010-12-04 00:19:52 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
if (e->isModified ())
|
|
|
|
setPref (getPrefKey (e), e->text());
|
2010-12-04 00:19:52 +00:00
|
|
|
}
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
2013-09-14 22:45:04 +00:00
|
|
|
|
2015-01-25 19:55:05 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::pathChanged (const QString& path)
|
|
|
|
{
|
|
|
|
if (auto b = qobject_cast<const TrPathButton*> (sender ()))
|
|
|
|
setPref(getPrefKey (b), path);
|
|
|
|
}
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::initRemoteTab ()
|
|
|
|
{
|
|
|
|
linkWidgetToPref (ui.enableRpcCheck, Prefs::RPC_ENABLED);
|
|
|
|
linkWidgetToPref (ui.rpcPortSpin, Prefs::RPC_PORT);
|
|
|
|
linkWidgetToPref (ui.requireRpcAuthCheck, Prefs::RPC_AUTH_REQUIRED);
|
|
|
|
linkWidgetToPref (ui.rpcUsernameEdit, Prefs::RPC_USERNAME);
|
|
|
|
linkWidgetToPref (ui.rpcPasswordEdit, Prefs::RPC_PASSWORD);
|
|
|
|
linkWidgetToPref (ui.enableRpcWhitelistCheck, Prefs::RPC_WHITELIST_ENABLED);
|
|
|
|
linkWidgetToPref (ui.rpcWhitelistEdit, Prefs::RPC_WHITELIST);
|
|
|
|
|
|
|
|
myWebWidgets <<
|
|
|
|
ui.rpcPortLabel <<
|
|
|
|
ui.rpcPortSpin <<
|
|
|
|
ui.requireRpcAuthCheck <<
|
|
|
|
ui.enableRpcWhitelistCheck;
|
|
|
|
myWebAuthWidgets <<
|
|
|
|
ui.rpcUsernameLabel <<
|
|
|
|
ui.rpcUsernameEdit <<
|
|
|
|
ui.rpcPasswordLabel <<
|
|
|
|
ui.rpcPasswordEdit;
|
|
|
|
myWebWhitelistWidgets <<
|
|
|
|
ui.rpcWhitelistLabel <<
|
|
|
|
ui.rpcWhitelistEdit;
|
|
|
|
myUnsupportedWhenRemote <<
|
|
|
|
ui.enableRpcCheck <<
|
|
|
|
myWebWidgets <<
|
|
|
|
myWebAuthWidgets <<
|
|
|
|
myWebWhitelistWidgets;
|
|
|
|
|
|
|
|
connect (ui.openWebClientButton, SIGNAL (clicked ()), &mySession, SLOT (launchWebInterface ()));
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::altSpeedDaysEdited (int i)
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
const int value = qobject_cast<QComboBox*>(sender())->itemData(i).toInt();
|
|
|
|
setPref (Prefs::ALT_SPEED_LIMIT_TIME_DAY, value);
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::initSpeedTab ()
|
2013-09-14 22:45:04 +00:00
|
|
|
{
|
|
|
|
const QString speed_K_str = Formatter::unitStr (Formatter::SPEED, Formatter::KB);
|
2015-01-25 15:47:03 +00:00
|
|
|
const QLocale locale;
|
|
|
|
|
|
|
|
ui.uploadSpeedLimitSpin->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
ui.downloadSpeedLimitSpin->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
ui.altUploadSpeedLimitSpin->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
ui.altDownloadSpeedLimitSpin->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
|
|
|
|
ui.altSpeedLimitDaysCombo->addItem (tr ("Every Day"), QVariant (TR_SCHED_ALL));
|
|
|
|
ui.altSpeedLimitDaysCombo->addItem (tr ("Weekdays"), QVariant (TR_SCHED_WEEKDAY));
|
|
|
|
ui.altSpeedLimitDaysCombo->addItem (tr ("Weekends"), QVariant (TR_SCHED_WEEKEND));
|
|
|
|
ui.altSpeedLimitDaysCombo->insertSeparator (ui.altSpeedLimitDaysCombo->count ());
|
|
|
|
for (int i = locale.firstDayOfWeek (); i <= Qt::Sunday; ++i)
|
|
|
|
ui.altSpeedLimitDaysCombo->addItem (qtDayName (i), qtDayToTrDay (i));
|
|
|
|
for (int i = Qt::Monday; i < locale.firstDayOfWeek (); ++i)
|
|
|
|
ui.altSpeedLimitDaysCombo->addItem (qtDayName (i), qtDayToTrDay (i));
|
|
|
|
ui.altSpeedLimitDaysCombo->setCurrentIndex (ui.altSpeedLimitDaysCombo->findData (myPrefs.getInt (Prefs::ALT_SPEED_LIMIT_TIME_DAY)));
|
|
|
|
|
|
|
|
linkWidgetToPref (ui.uploadSpeedLimitCheck, Prefs::USPEED_ENABLED);
|
|
|
|
linkWidgetToPref (ui.uploadSpeedLimitSpin, Prefs::USPEED);
|
|
|
|
linkWidgetToPref (ui.downloadSpeedLimitCheck, Prefs::DSPEED_ENABLED);
|
|
|
|
linkWidgetToPref (ui.downloadSpeedLimitSpin, Prefs::DSPEED);
|
|
|
|
linkWidgetToPref (ui.altUploadSpeedLimitSpin, Prefs::ALT_SPEED_LIMIT_UP);
|
|
|
|
linkWidgetToPref (ui.altDownloadSpeedLimitSpin, Prefs::ALT_SPEED_LIMIT_DOWN);
|
|
|
|
linkWidgetToPref (ui.altSpeedLimitScheduleCheck, Prefs::ALT_SPEED_LIMIT_TIME_ENABLED);
|
|
|
|
linkWidgetToPref (ui.altSpeedLimitStartTimeEdit, Prefs::ALT_SPEED_LIMIT_TIME_BEGIN);
|
|
|
|
linkWidgetToPref (ui.altSpeedLimitEndTimeEdit, Prefs::ALT_SPEED_LIMIT_TIME_END);
|
|
|
|
|
|
|
|
mySchedWidgets <<
|
|
|
|
ui.altSpeedLimitStartTimeEdit <<
|
|
|
|
ui.altSpeedLimitToLabel <<
|
|
|
|
ui.altSpeedLimitEndTimeEdit <<
|
|
|
|
ui.altSpeedLimitDaysLabel <<
|
|
|
|
ui.altSpeedLimitDaysCombo;
|
|
|
|
|
|
|
|
ColumnResizer * cr (new ColumnResizer (this));
|
|
|
|
cr->addLayout (ui.speedLimitsSectionLayout);
|
|
|
|
cr->addLayout (ui.altSpeedLimitsSectionLayout);
|
|
|
|
cr->update ();
|
|
|
|
|
|
|
|
connect (ui.altSpeedLimitDaysCombo, SIGNAL (activated (int)), SLOT (altSpeedDaysEdited (int)));
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::initDesktopTab ()
|
2010-08-02 03:07:42 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
linkWidgetToPref (ui.showTrayIconCheck, Prefs::SHOW_TRAY_ICON);
|
|
|
|
linkWidgetToPref (ui.startMinimizedCheck, Prefs::START_MINIMIZED);
|
|
|
|
linkWidgetToPref (ui.notifyOnTorrentAddedCheck, Prefs::SHOW_NOTIFICATION_ON_ADD);
|
|
|
|
linkWidgetToPref (ui.notifyOnTorrentCompletedCheck, Prefs::SHOW_NOTIFICATION_ON_COMPLETE);
|
|
|
|
linkWidgetToPref (ui.playSoundOnTorrentCompletedCheck, Prefs::COMPLETE_SOUND_ENABLED);
|
2010-08-02 03:07:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::onPortTested (bool isOpen)
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.testPeerPortButton->setEnabled (true);
|
2013-09-14 22:45:04 +00:00
|
|
|
myWidgets[Prefs::PEER_PORT]->setEnabled (true);
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.peerPortStatusLabel->setText (isOpen ? tr ("Port is <b>open</b>")
|
|
|
|
: tr ("Port is <b>closed</b>"));
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::onPortTest ()
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.peerPortStatusLabel->setText (tr ("Testing TCP Port..."));
|
|
|
|
ui.testPeerPortButton->setEnabled (false);
|
2013-09-14 22:45:04 +00:00
|
|
|
myWidgets[Prefs::PEER_PORT]->setEnabled (false);
|
|
|
|
mySession.portTest ();
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::initNetworkTab ()
|
2013-09-14 22:45:04 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.torrentPeerLimitSpin->setRange (1, FD_SETSIZE);
|
|
|
|
ui.globalPeerLimitSpin->setRange (1, FD_SETSIZE);
|
2013-09-14 22:45:04 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
linkWidgetToPref (ui.peerPortSpin, Prefs::PEER_PORT);
|
|
|
|
linkWidgetToPref (ui.randomPeerPortCheck, Prefs::PEER_PORT_RANDOM_ON_START);
|
|
|
|
linkWidgetToPref (ui.enablePortForwardingCheck, Prefs::PORT_FORWARDING);
|
|
|
|
linkWidgetToPref (ui.torrentPeerLimitSpin, Prefs::PEER_LIMIT_TORRENT);
|
|
|
|
linkWidgetToPref (ui.globalPeerLimitSpin, Prefs::PEER_LIMIT_GLOBAL);
|
|
|
|
linkWidgetToPref (ui.enableUtpCheck, Prefs::UTP_ENABLED);
|
|
|
|
linkWidgetToPref (ui.enablePexCheck, Prefs::PEX_ENABLED);
|
|
|
|
linkWidgetToPref (ui.enableDhtCheck, Prefs::DHT_ENABLED);
|
|
|
|
linkWidgetToPref (ui.enableLpdCheck, Prefs::LPD_ENABLED);
|
2013-09-14 22:45:04 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
ColumnResizer * cr (new ColumnResizer (this));
|
|
|
|
cr->addLayout (ui.incomingPeersSectionLayout);
|
|
|
|
cr->addLayout (ui.peerLimitsSectionLayout);
|
|
|
|
cr->update ();
|
2013-09-14 22:45:04 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
connect (ui.testPeerPortButton, SIGNAL (clicked ()), SLOT (onPortTest ()));
|
|
|
|
connect (&mySession, SIGNAL (portTested (bool)), SLOT (onPortTested (bool)));
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::onBlocklistDialogDestroyed (QObject * o)
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
Q_UNUSED (o);
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2013-09-14 22:45:04 +00:00
|
|
|
myBlocklistDialog = 0;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::onUpdateBlocklistCancelled ()
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
disconnect (&mySession, SIGNAL(blocklistUpdated(int)), this, SLOT(onBlocklistUpdated(int)));
|
|
|
|
myBlocklistDialog->deleteLater ();
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::onBlocklistUpdated (int n)
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2015-01-18 02:09:44 +00:00
|
|
|
myBlocklistDialog->setText (tr ("<b>Update succeeded!</b><p>Blocklist now has %Ln rule(s).", 0, n));
|
2013-09-14 22:45:04 +00:00
|
|
|
myBlocklistDialog->setTextFormat (Qt::RichText);
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::onUpdateBlocklistClicked ()
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
myBlocklistDialog = new QMessageBox (QMessageBox::Information,
|
|
|
|
QString(),
|
|
|
|
tr ("<b>Update Blocklist</b><p>Getting new blocklist..."),
|
|
|
|
QMessageBox::Close,
|
|
|
|
this);
|
|
|
|
connect (myBlocklistDialog, SIGNAL(rejected()), this, SLOT(onUpdateBlocklistCancelled()));
|
|
|
|
connect (&mySession, SIGNAL(blocklistUpdated(int)), this, SLOT(onBlocklistUpdated(int)));
|
|
|
|
myBlocklistDialog->show ();
|
|
|
|
mySession.updateBlocklist ();
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
2010-01-05 23:47:50 +00:00
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::encryptionEdited (int i)
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
const int value (qobject_cast<QComboBox*>(sender())->itemData(i).toInt ());
|
|
|
|
setPref (Prefs::ENCRYPTION, value);
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::initPrivacyTab ()
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.encryptionModeCombo->addItem (tr ("Allow encryption"), 0);
|
|
|
|
ui.encryptionModeCombo->addItem (tr ("Prefer encryption"), 1);
|
|
|
|
ui.encryptionModeCombo->addItem (tr ("Require encryption"), 2);
|
2013-01-16 21:42:03 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
linkWidgetToPref (ui.encryptionModeCombo, Prefs::ENCRYPTION);
|
|
|
|
linkWidgetToPref (ui.blocklistCheck, Prefs::BLOCKLIST_ENABLED);
|
|
|
|
linkWidgetToPref (ui.blocklistEdit, Prefs::BLOCKLIST_URL);
|
|
|
|
linkWidgetToPref (ui.autoUpdateBlocklistCheck, Prefs::BLOCKLIST_UPDATES_ENABLED);
|
2013-01-16 21:42:03 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
myBlockWidgets <<
|
|
|
|
ui.blocklistEdit <<
|
|
|
|
ui.blocklistStatusLabel <<
|
|
|
|
ui.updateBlocklistButton <<
|
|
|
|
ui.autoUpdateBlocklistCheck;
|
2010-10-31 17:16:12 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
ColumnResizer * cr (new ColumnResizer (this));
|
|
|
|
cr->addLayout (ui.encryptionSectionLayout);
|
|
|
|
cr->addLayout (ui.blocklistSectionLayout);
|
|
|
|
cr->update ();
|
2010-10-31 17:16:12 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
connect (ui.encryptionModeCombo, SIGNAL (activated (int)), SLOT (encryptionEdited (int)));
|
|
|
|
connect (ui.updateBlocklistButton, SIGNAL (clicked ()), SLOT (onUpdateBlocklistClicked ()));
|
2010-10-31 17:16:12 +00:00
|
|
|
|
2013-09-14 22:45:04 +00:00
|
|
|
updateBlocklistLabel ();
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2014-12-22 03:06:09 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::onIdleLimitChanged ()
|
|
|
|
{
|
2015-01-12 06:18:52 +00:00
|
|
|
//: Spin box suffix, "Stop seeding if idle for: [ 5 minutes ]" (includes leading space after the number, if needed)
|
2015-01-25 15:47:03 +00:00
|
|
|
const QString unitsSuffix = tr (" minute(s)", 0, ui.idleLimitSpin->value ());
|
|
|
|
if (ui.idleLimitSpin->suffix () != unitsSuffix)
|
|
|
|
ui.idleLimitSpin->setSuffix (unitsSuffix);
|
2014-12-22 03:06:09 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::initSeedingTab ()
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
linkWidgetToPref (ui.ratioLimitCheck, Prefs::RATIO_ENABLED);
|
|
|
|
linkWidgetToPref (ui.ratioLimitSpin, Prefs::RATIO);
|
|
|
|
linkWidgetToPref (ui.idleLimitCheck, Prefs::IDLE_LIMIT_ENABLED);
|
|
|
|
linkWidgetToPref (ui.idleLimitSpin, Prefs::IDLE_LIMIT);
|
2009-10-20 14:01:15 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
connect (ui.idleLimitSpin, SIGNAL (valueChanged (int)), SLOT (onIdleLimitChanged ()));
|
2011-08-01 22:24:24 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
onIdleLimitChanged ();
|
2011-08-01 22:24:24 +00:00
|
|
|
}
|
|
|
|
|
2015-01-11 21:10:46 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::onQueueStalledMinutesChanged ()
|
|
|
|
{
|
2015-01-12 06:18:52 +00:00
|
|
|
//: Spin box suffix, "Download is inactive if data sharing stopped: [ 5 minutes ago ]" (includes leading space after the number, if needed)
|
2015-01-25 15:47:03 +00:00
|
|
|
const QString unitsSuffix = tr (" minute(s) ago", 0, ui.queueStalledMinutesSpin->value ());
|
|
|
|
if (ui.queueStalledMinutesSpin->suffix () != unitsSuffix)
|
|
|
|
ui.queueStalledMinutesSpin->setSuffix (unitsSuffix);
|
2015-01-11 21:10:46 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
void
|
|
|
|
PrefsDialog::initDownloadingTab ()
|
2013-09-14 22:45:04 +00:00
|
|
|
{
|
2015-01-25 19:55:05 +00:00
|
|
|
if (mySession.isLocal ())
|
|
|
|
{
|
|
|
|
ui.watchDirStack->setCurrentWidget (ui.watchDirButton);
|
|
|
|
ui.downloadDirStack->setCurrentWidget (ui.downloadDirButton);
|
|
|
|
ui.incompleteDirStack->setCurrentWidget (ui.incompleteDirButton);
|
|
|
|
ui.completionScriptStack->setCurrentWidget (ui.completionScriptButton);
|
|
|
|
|
|
|
|
ui.watchDirButton->setMode (TrPathButton::DirectoryMode);
|
|
|
|
ui.downloadDirButton->setMode (TrPathButton::DirectoryMode);
|
|
|
|
ui.incompleteDirButton->setMode (TrPathButton::DirectoryMode);
|
|
|
|
ui.completionScriptButton->setMode (TrPathButton::FileMode);
|
|
|
|
|
|
|
|
ui.watchDirButton->setTitle (tr ("Select Watch Directory"));
|
|
|
|
ui.downloadDirButton->setTitle (tr ("Select Destination"));
|
|
|
|
ui.incompleteDirButton->setTitle (tr ("Select Incomplete Directory"));
|
|
|
|
ui.completionScriptButton->setTitle (tr ("Select \"Torrent Done\" Script"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui.watchDirStack->setCurrentWidget (ui.watchDirEdit);
|
|
|
|
ui.downloadDirStack->setCurrentWidget (ui.downloadDirEdit);
|
|
|
|
ui.incompleteDirStack->setCurrentWidget (ui.incompleteDirEdit);
|
|
|
|
ui.completionScriptStack->setCurrentWidget (ui.completionScriptEdit);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.watchDirStack->setFixedHeight (ui.watchDirStack->currentWidget ()->sizeHint ().height ());
|
|
|
|
ui.downloadDirStack->setFixedHeight (ui.downloadDirStack->currentWidget ()->sizeHint ().height ());
|
|
|
|
ui.incompleteDirStack->setFixedHeight (ui.incompleteDirStack->currentWidget ()->sizeHint ().height ());
|
|
|
|
ui.completionScriptStack->setFixedHeight (ui.completionScriptStack->currentWidget ()->sizeHint ().height ());
|
|
|
|
|
|
|
|
ui.watchDirStack->setMinimumWidth (200);
|
|
|
|
|
|
|
|
ui.downloadDirLabel->setBuddy (ui.downloadDirStack->currentWidget ());
|
2015-01-25 15:47:03 +00:00
|
|
|
|
|
|
|
ui.downloadDirFreeSpaceLabel->setSession (mySession);
|
|
|
|
ui.downloadDirFreeSpaceLabel->setPath (myPrefs.getString (Prefs::DOWNLOAD_DIR));
|
|
|
|
|
|
|
|
linkWidgetToPref (ui.watchDirCheck, Prefs::DIR_WATCH_ENABLED);
|
2015-01-25 19:55:05 +00:00
|
|
|
linkWidgetToPref (ui.watchDirStack->currentWidget (), Prefs::DIR_WATCH);
|
2015-01-25 15:47:03 +00:00
|
|
|
linkWidgetToPref (ui.showTorrentOptionsDialogCheck, Prefs::OPTIONS_PROMPT);
|
|
|
|
linkWidgetToPref (ui.startAddedTorrentsCheck, Prefs::START);
|
|
|
|
linkWidgetToPref (ui.trashTorrentFileCheck, Prefs::TRASH_ORIGINAL);
|
2015-01-25 19:55:05 +00:00
|
|
|
linkWidgetToPref (ui.downloadDirStack->currentWidget (), Prefs::DOWNLOAD_DIR);
|
2015-01-25 15:47:03 +00:00
|
|
|
linkWidgetToPref (ui.downloadQueueSizeSpin, Prefs::DOWNLOAD_QUEUE_SIZE);
|
|
|
|
linkWidgetToPref (ui.queueStalledMinutesSpin, Prefs::QUEUE_STALLED_MINUTES);
|
|
|
|
linkWidgetToPref (ui.renamePartialFilesCheck, Prefs::RENAME_PARTIAL_FILES);
|
|
|
|
linkWidgetToPref (ui.incompleteDirCheck, Prefs::INCOMPLETE_DIR_ENABLED);
|
2015-01-25 19:55:05 +00:00
|
|
|
linkWidgetToPref (ui.incompleteDirStack->currentWidget (), Prefs::INCOMPLETE_DIR);
|
2015-01-25 15:47:03 +00:00
|
|
|
linkWidgetToPref (ui.completionScriptCheck, Prefs::SCRIPT_TORRENT_DONE_ENABLED);
|
2015-01-25 19:55:05 +00:00
|
|
|
linkWidgetToPref (ui.completionScriptStack->currentWidget (), Prefs::SCRIPT_TORRENT_DONE_FILENAME);
|
2015-01-25 15:47:03 +00:00
|
|
|
|
|
|
|
ColumnResizer * cr (new ColumnResizer (this));
|
|
|
|
cr->addLayout (ui.addingSectionLayout);
|
|
|
|
cr->addLayout (ui.downloadQueueSectionLayout);
|
|
|
|
cr->addLayout (ui.incompleteSectionLayout);
|
|
|
|
cr->update ();
|
|
|
|
|
|
|
|
connect (ui.queueStalledMinutesSpin, SIGNAL (valueChanged (int)), SLOT (onQueueStalledMinutesChanged ()));
|
|
|
|
|
|
|
|
onQueueStalledMinutesChanged ();
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::PrefsDialog (Session& session, Prefs& prefs, QWidget * parent):
|
2013-09-14 22:45:04 +00:00
|
|
|
QDialog (parent),
|
|
|
|
myIsServer (session.isServer ()),
|
|
|
|
mySession (session),
|
2015-01-25 15:47:03 +00:00
|
|
|
myPrefs (prefs)
|
2013-09-14 22:45:04 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.setupUi (this);
|
2013-09-14 22:45:04 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
initSpeedTab ();
|
|
|
|
initDownloadingTab ();
|
|
|
|
initSeedingTab ();
|
|
|
|
initPrivacyTab ();
|
|
|
|
initNetworkTab ();
|
|
|
|
initDesktopTab ();
|
|
|
|
initRemoteTab ();
|
2013-09-14 22:45:04 +00:00
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
connect (&mySession, SIGNAL (sessionUpdated ()), SLOT (sessionUpdated ()));
|
2013-09-14 22:45:04 +00:00
|
|
|
|
|
|
|
QList<int> keys;
|
2014-12-12 23:05:10 +00:00
|
|
|
keys << Prefs::RPC_ENABLED
|
|
|
|
<< Prefs::ALT_SPEED_LIMIT_ENABLED
|
|
|
|
<< Prefs::ALT_SPEED_LIMIT_TIME_ENABLED
|
|
|
|
<< Prefs::ENCRYPTION
|
|
|
|
<< Prefs::BLOCKLIST_ENABLED
|
|
|
|
<< Prefs::DIR_WATCH
|
|
|
|
<< Prefs::DOWNLOAD_DIR
|
|
|
|
<< Prefs::INCOMPLETE_DIR
|
|
|
|
<< Prefs::INCOMPLETE_DIR_ENABLED
|
|
|
|
<< Prefs::SCRIPT_TORRENT_DONE_FILENAME;
|
2013-09-14 22:45:04 +00:00
|
|
|
foreach (int key, keys)
|
|
|
|
refreshPref (key);
|
|
|
|
|
|
|
|
// if it's a remote session, disable the preferences
|
|
|
|
// that don't work in remote sessions
|
|
|
|
if (!myIsServer)
|
|
|
|
{
|
|
|
|
foreach (QWidget * w, myUnsupportedWhenRemote)
|
|
|
|
{
|
|
|
|
w->setToolTip (tr ("Not supported by remote sessions"));
|
|
|
|
w->setEnabled (false);
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-25 15:47:03 +00:00
|
|
|
|
|
|
|
adjustSize ();
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::~PrefsDialog ()
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-02 16:30:24 +00:00
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::setPref (int key, const QVariant& v)
|
2010-08-02 16:30:24 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
myPrefs.set (key, v);
|
|
|
|
refreshPref (key);
|
2010-08-02 16:30:24 +00:00
|
|
|
}
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::sessionUpdated ()
|
2009-04-09 22:42:55 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
updateBlocklistLabel ();
|
2009-04-09 22:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::updateBlocklistLabel ()
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
const int n = mySession.blocklistSize ();
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.blocklistStatusLabel->setText (tr ("<i>Blocklist contains %Ln rule(s)</i>", 0, n));
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-12 23:05:10 +00:00
|
|
|
PrefsDialog::refreshPref (int key)
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
switch (key)
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2014-12-12 23:05:10 +00:00
|
|
|
case Prefs::RPC_ENABLED:
|
|
|
|
case Prefs::RPC_WHITELIST_ENABLED:
|
|
|
|
case Prefs::RPC_AUTH_REQUIRED:
|
2013-09-14 22:45:04 +00:00
|
|
|
{
|
|
|
|
const bool enabled (myPrefs.getBool (Prefs::RPC_ENABLED));
|
|
|
|
const bool whitelist (myPrefs.getBool (Prefs::RPC_WHITELIST_ENABLED));
|
|
|
|
const bool auth (myPrefs.getBool (Prefs::RPC_AUTH_REQUIRED));
|
2015-01-25 15:47:03 +00:00
|
|
|
foreach (QWidget * w, myWebWhitelistWidgets)
|
|
|
|
w->setEnabled (enabled && whitelist);
|
|
|
|
foreach (QWidget * w, myWebAuthWidgets)
|
|
|
|
w->setEnabled (enabled && auth);
|
|
|
|
foreach (QWidget * w, myWebWidgets)
|
|
|
|
w->setEnabled (enabled);
|
2013-09-14 22:45:04 +00:00
|
|
|
break;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 23:05:10 +00:00
|
|
|
case Prefs::ALT_SPEED_LIMIT_TIME_ENABLED:
|
2013-09-14 22:45:04 +00:00
|
|
|
{
|
|
|
|
const bool enabled = myPrefs.getBool (key);
|
2015-01-25 15:47:03 +00:00
|
|
|
foreach (QWidget * w, mySchedWidgets)
|
|
|
|
w->setEnabled (enabled);
|
2013-09-14 22:45:04 +00:00
|
|
|
break;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 23:05:10 +00:00
|
|
|
case Prefs::BLOCKLIST_ENABLED:
|
2013-09-14 22:45:04 +00:00
|
|
|
{
|
|
|
|
const bool enabled = myPrefs.getBool (key);
|
2015-01-25 15:47:03 +00:00
|
|
|
foreach (QWidget * w, myBlockWidgets)
|
|
|
|
w->setEnabled (enabled);
|
2013-09-14 22:45:04 +00:00
|
|
|
break;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 23:05:10 +00:00
|
|
|
case Prefs::DIR_WATCH:
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.watchDirButton->setText (QFileInfo (myPrefs.getString (Prefs::DIR_WATCH)).fileName ());
|
2013-09-14 22:45:04 +00:00
|
|
|
break;
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2014-12-12 23:05:10 +00:00
|
|
|
case Prefs::SCRIPT_TORRENT_DONE_FILENAME:
|
2013-09-14 22:45:04 +00:00
|
|
|
{
|
|
|
|
const QString path (myPrefs.getString (key));
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.completionScriptButton->setText (QFileInfo (path).fileName ());
|
2013-09-14 22:45:04 +00:00
|
|
|
break;
|
2011-01-19 20:33:43 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 23:05:10 +00:00
|
|
|
case Prefs::PEER_PORT:
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.peerPortStatusLabel->setText (tr ("Status unknown"));
|
|
|
|
ui.testPeerPortButton->setEnabled (true);
|
2013-09-14 22:45:04 +00:00
|
|
|
break;
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2014-12-12 23:05:10 +00:00
|
|
|
case Prefs::DOWNLOAD_DIR:
|
2013-09-14 22:45:04 +00:00
|
|
|
{
|
|
|
|
const QString path (myPrefs.getString (key));
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.downloadDirButton->setText (QFileInfo (path).fileName ());
|
|
|
|
ui.downloadDirFreeSpaceLabel->setPath (path);
|
2013-09-14 22:45:04 +00:00
|
|
|
break;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 23:05:10 +00:00
|
|
|
case Prefs::INCOMPLETE_DIR:
|
2013-09-14 22:45:04 +00:00
|
|
|
{
|
|
|
|
QString path (myPrefs.getString (key));
|
2015-01-25 15:47:03 +00:00
|
|
|
ui.incompleteDirButton->setText (QFileInfo (path).fileName ());
|
2013-09-14 22:45:04 +00:00
|
|
|
break;
|
2009-10-20 14:01:15 +00:00
|
|
|
}
|
|
|
|
|
2013-09-14 22:45:04 +00:00
|
|
|
default:
|
|
|
|
break;
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
|
2013-09-14 22:45:04 +00:00
|
|
|
key2widget_t::iterator it (myWidgets.find (key));
|
|
|
|
if (it != myWidgets.end ())
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-09-14 22:45:04 +00:00
|
|
|
QWidget * w (it.value ());
|
|
|
|
|
2015-01-25 15:47:03 +00:00
|
|
|
if (!updateWidgetValue (w, key))
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2015-01-25 15:47:03 +00:00
|
|
|
if (key == Prefs::ENCRYPTION)
|
|
|
|
{
|
|
|
|
QComboBox * comboBox (qobject_cast<QComboBox*> (w));
|
|
|
|
const int index = comboBox->findData (myPrefs.getInt (key));
|
|
|
|
comboBox->setCurrentIndex (index);
|
|
|
|
}
|
2009-04-09 18:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|