|
|
|
@@ -33,6 +33,7 @@
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "column-resizer.h"
|
|
|
|
#include "freespace-label.h"
|
|
|
|
#include "freespace-label.h"
|
|
|
|
#include "formatter.h"
|
|
|
|
#include "formatter.h"
|
|
|
|
#include "hig.h"
|
|
|
|
#include "hig.h"
|
|
|
|
@@ -48,154 +49,177 @@
|
|
|
|
namespace
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const char * PREF_KEY ("pref-key");
|
|
|
|
const char * PREF_KEY ("pref-key");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
|
|
|
w->setTime (QTime ().addSecs (myPrefs.getInt(prefKey) * 60));
|
|
|
|
|
|
|
|
else if (auto w = qobject_cast<QLineEdit*> (widget))
|
|
|
|
|
|
|
|
w->setText (myPrefs.getString (prefKey));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
PrefsDialog::linkWidgetToPref (QWidget * widget, int prefKey)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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 ()));
|
|
|
|
|
|
|
|
else if (widget->inherits ("QAbstractSpinBox"))
|
|
|
|
|
|
|
|
connect (widget, SIGNAL (editingFinished ()), SLOT (spinBoxEditingFinished ()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
PrefsDialog::checkBoxToggled (bool checked)
|
|
|
|
PrefsDialog::checkBoxToggled (bool checked)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const int key (sender ()->property (PREF_KEY).toInt ());
|
|
|
|
if (auto c = qobject_cast<QCheckBox*> (sender ()))
|
|
|
|
setPref (key, checked);
|
|
|
|
setPref (getPrefKey (c), checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QCheckBox *
|
|
|
|
|
|
|
|
PrefsDialog::checkBoxNew (const QString& text, int key)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QCheckBox * box = new QCheckBox (text);
|
|
|
|
|
|
|
|
box->setChecked (myPrefs.getBool (key));
|
|
|
|
|
|
|
|
box->setProperty (PREF_KEY, key);
|
|
|
|
|
|
|
|
connect (box, SIGNAL(toggled(bool)), this, SLOT(checkBoxToggled(bool)));
|
|
|
|
|
|
|
|
myWidgets.insert (key, box);
|
|
|
|
|
|
|
|
return box;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
PrefsDialog::enableBuddyWhenChecked (QCheckBox * box, QWidget * buddy)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
connect (box, SIGNAL(toggled(bool)), buddy, SLOT(setEnabled(bool)));
|
|
|
|
|
|
|
|
buddy->setEnabled (box->isChecked ());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
PrefsDialog::spinBoxEditingFinished ()
|
|
|
|
PrefsDialog::spinBoxEditingFinished ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const QObject * spin = sender();
|
|
|
|
const QObject * spin = sender();
|
|
|
|
const int key = spin->property (PREF_KEY).toInt ();
|
|
|
|
const int key = getPrefKey (spin);
|
|
|
|
const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*> (spin);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (d)
|
|
|
|
if (auto e = qobject_cast<const QDoubleSpinBox*> (spin))
|
|
|
|
setPref (key, d->value ());
|
|
|
|
setPref (key, e->value ());
|
|
|
|
else
|
|
|
|
else if (auto e = qobject_cast<const QSpinBox*> (spin))
|
|
|
|
setPref (key, qobject_cast<const QSpinBox*>(spin)->value ());
|
|
|
|
setPref (key, e->value ());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QSpinBox *
|
|
|
|
|
|
|
|
PrefsDialog::spinBoxNew (int key, int low, int high, int step)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QSpinBox * spin = new QSpinBox ();
|
|
|
|
|
|
|
|
spin->setRange (low, high);
|
|
|
|
|
|
|
|
spin->setSingleStep (step);
|
|
|
|
|
|
|
|
spin->setValue (myPrefs.getInt (key));
|
|
|
|
|
|
|
|
spin->setProperty (PREF_KEY, key);
|
|
|
|
|
|
|
|
connect (spin, SIGNAL(editingFinished()), this, SLOT(spinBoxEditingFinished()));
|
|
|
|
|
|
|
|
myWidgets.insert (key, spin);
|
|
|
|
|
|
|
|
return spin;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDoubleSpinBox *
|
|
|
|
|
|
|
|
PrefsDialog::doubleSpinBoxNew (int key, double low, double high, double step, int decimals)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QDoubleSpinBox * spin = new QDoubleSpinBox ();
|
|
|
|
|
|
|
|
spin->setRange (low, high);
|
|
|
|
|
|
|
|
spin->setSingleStep (step);
|
|
|
|
|
|
|
|
spin->setDecimals (decimals);
|
|
|
|
|
|
|
|
spin->setValue (myPrefs.getDouble (key));
|
|
|
|
|
|
|
|
spin->setProperty (PREF_KEY, key);
|
|
|
|
|
|
|
|
connect (spin, SIGNAL(editingFinished()), this, SLOT(spinBoxEditingFinished()));
|
|
|
|
|
|
|
|
myWidgets.insert (key, spin);
|
|
|
|
|
|
|
|
return spin;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
PrefsDialog::timeEditingFinished ()
|
|
|
|
PrefsDialog::timeEditingFinished ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto e = qobject_cast<QTimeEdit*>(sender());
|
|
|
|
if (auto e = qobject_cast<const QTimeEdit*> (sender ()))
|
|
|
|
if (e != nullptr)
|
|
|
|
setPref(getPrefKey (e), QTime ().secsTo (e->time()) / 60);
|
|
|
|
{
|
|
|
|
|
|
|
|
const int key {e->property(PREF_KEY).toInt()};
|
|
|
|
|
|
|
|
const QTime t {e->time()};
|
|
|
|
|
|
|
|
const int minutes_after_midnight {t.hour()*60 + t.minute()};
|
|
|
|
|
|
|
|
setPref(key, minutes_after_midnight);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QTimeEdit*
|
|
|
|
|
|
|
|
PrefsDialog::timeEditNew (int key)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const int minutes {myPrefs.getInt(key)};
|
|
|
|
|
|
|
|
auto e = new QTimeEdit{};
|
|
|
|
|
|
|
|
e->setDisplayFormat(QString::fromUtf8("hh:mm"));
|
|
|
|
|
|
|
|
e->setProperty(PREF_KEY, key);
|
|
|
|
|
|
|
|
e->setTime(QTime{minutes/60, minutes%60});
|
|
|
|
|
|
|
|
myWidgets.insert(key, e);
|
|
|
|
|
|
|
|
connect(e, SIGNAL(editingFinished()), this, SLOT(timeEditingFinished()));
|
|
|
|
|
|
|
|
return e;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
PrefsDialog::lineEditingFinished ()
|
|
|
|
PrefsDialog::lineEditingFinished ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QLineEdit * e = qobject_cast<QLineEdit*>(sender());
|
|
|
|
if (auto e = qobject_cast<const QLineEdit*> (sender ()))
|
|
|
|
if (e && e->isModified ())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const int key (e->property (PREF_KEY).toInt ());
|
|
|
|
if (e->isModified ())
|
|
|
|
const QString text (e->text());
|
|
|
|
setPref (getPrefKey (e), e->text());
|
|
|
|
setPref (key, text);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QLineEdit*
|
|
|
|
|
|
|
|
PrefsDialog::lineEditNew (int key, int echoMode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QLineEdit * e = new QLineEdit (myPrefs.getString (key));
|
|
|
|
|
|
|
|
e->setProperty (PREF_KEY, key);
|
|
|
|
|
|
|
|
e->setEchoMode (QLineEdit::EchoMode (echoMode));
|
|
|
|
|
|
|
|
myWidgets.insert (key, e);
|
|
|
|
|
|
|
|
connect (e, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()));
|
|
|
|
|
|
|
|
return e;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
void
|
|
|
|
PrefsDialog::createRemoteTab (Session& session)
|
|
|
|
PrefsDialog::initRemoteTab ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HIG * hig = new HIG (this);
|
|
|
|
linkWidgetToPref (ui.enableRpcCheck, Prefs::RPC_ENABLED);
|
|
|
|
hig->addSectionTitle (tr ("Remote Control"));
|
|
|
|
linkWidgetToPref (ui.rpcPortSpin, Prefs::RPC_PORT);
|
|
|
|
QWidget * w;
|
|
|
|
linkWidgetToPref (ui.requireRpcAuthCheck, Prefs::RPC_AUTH_REQUIRED);
|
|
|
|
QHBoxLayout * h = new QHBoxLayout ();
|
|
|
|
linkWidgetToPref (ui.rpcUsernameEdit, Prefs::RPC_USERNAME);
|
|
|
|
QPushButton * b = new QPushButton (tr ("&Open web client"));
|
|
|
|
linkWidgetToPref (ui.rpcPasswordEdit, Prefs::RPC_PASSWORD);
|
|
|
|
connect (b, SIGNAL(clicked()), &session, SLOT(launchWebInterface()));
|
|
|
|
linkWidgetToPref (ui.enableRpcWhitelistCheck, Prefs::RPC_WHITELIST_ENABLED);
|
|
|
|
h->addWidget (b, 0, Qt::AlignRight);
|
|
|
|
linkWidgetToPref (ui.rpcWhitelistEdit, Prefs::RPC_WHITELIST);
|
|
|
|
QWidget * l = checkBoxNew (tr ("Allow &remote access"), Prefs::RPC_ENABLED);
|
|
|
|
|
|
|
|
myUnsupportedWhenRemote << l;
|
|
|
|
myWebWidgets <<
|
|
|
|
hig->addRow (l, h, 0);
|
|
|
|
ui.rpcPortLabel <<
|
|
|
|
l = hig->addRow (tr ("HTTP &port:"), w = spinBoxNew (Prefs::RPC_PORT, 0, 65535, 1));
|
|
|
|
ui.rpcPortSpin <<
|
|
|
|
myWebWidgets << l << w;
|
|
|
|
ui.requireRpcAuthCheck <<
|
|
|
|
hig->addWideControl (w = checkBoxNew (tr ("Use &authentication"), Prefs::RPC_AUTH_REQUIRED));
|
|
|
|
ui.enableRpcWhitelistCheck;
|
|
|
|
myWebWidgets << w;
|
|
|
|
myWebAuthWidgets <<
|
|
|
|
l = hig->addRow (tr ("&Username:"), w = lineEditNew (Prefs::RPC_USERNAME));
|
|
|
|
ui.rpcUsernameLabel <<
|
|
|
|
myWebAuthWidgets << l << w;
|
|
|
|
ui.rpcUsernameEdit <<
|
|
|
|
l = hig->addRow (tr ("Pass&word:"), w = lineEditNew (Prefs::RPC_PASSWORD, QLineEdit::Password));
|
|
|
|
ui.rpcPasswordLabel <<
|
|
|
|
myWebAuthWidgets << l << w;
|
|
|
|
ui.rpcPasswordEdit;
|
|
|
|
hig->addWideControl (w = checkBoxNew (tr ("Only allow these IP a&ddresses:"), Prefs::RPC_WHITELIST_ENABLED));
|
|
|
|
myWebWhitelistWidgets <<
|
|
|
|
myWebWidgets << w;
|
|
|
|
ui.rpcWhitelistLabel <<
|
|
|
|
l = hig->addRow (tr ("Addresses:"), w = lineEditNew (Prefs::RPC_WHITELIST));
|
|
|
|
ui.rpcWhitelistEdit;
|
|
|
|
myWebWhitelistWidgets << l << w;
|
|
|
|
myUnsupportedWhenRemote <<
|
|
|
|
myUnsupportedWhenRemote << myWebWidgets << myWebAuthWidgets << myWebWhitelistWidgets;
|
|
|
|
ui.enableRpcCheck <<
|
|
|
|
hig->finish ();
|
|
|
|
myWebWidgets <<
|
|
|
|
return hig;
|
|
|
|
myWebAuthWidgets <<
|
|
|
|
|
|
|
|
myWebWhitelistWidgets;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect (ui.openWebClientButton, SIGNAL (clicked ()), &mySession, SLOT (launchWebInterface ()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/***
|
|
|
|
@@ -209,113 +233,64 @@ PrefsDialog::altSpeedDaysEdited (int i)
|
|
|
|
setPref (Prefs::ALT_SPEED_LIMIT_TIME_DAY, value);
|
|
|
|
setPref (Prefs::ALT_SPEED_LIMIT_TIME_DAY, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
QWidget *
|
|
|
|
PrefsDialog::initSpeedTab ()
|
|
|
|
PrefsDialog::createSpeedTab ()
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QWidget * l;
|
|
|
|
|
|
|
|
QSpinBox * r;
|
|
|
|
|
|
|
|
HIG * hig = new HIG (this);
|
|
|
|
|
|
|
|
hig->addSectionTitle (tr ("Speed Limits"));
|
|
|
|
|
|
|
|
const QString speed_K_str = Formatter::unitStr (Formatter::SPEED, Formatter::KB);
|
|
|
|
const QString speed_K_str = Formatter::unitStr (Formatter::SPEED, Formatter::KB);
|
|
|
|
|
|
|
|
const QLocale locale;
|
|
|
|
|
|
|
|
|
|
|
|
l = checkBoxNew (tr ("&Upload:"), Prefs::USPEED_ENABLED);
|
|
|
|
ui.uploadSpeedLimitSpin->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
r = spinBoxNew (Prefs::USPEED, 0, INT_MAX, 5);
|
|
|
|
ui.downloadSpeedLimitSpin->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
r->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
ui.altUploadSpeedLimitSpin->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
hig->addRow (l, r);
|
|
|
|
ui.altDownloadSpeedLimitSpin->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
enableBuddyWhenChecked (qobject_cast<QCheckBox*>(l), r);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
l = checkBoxNew (tr ("&Download:"), Prefs::DSPEED_ENABLED);
|
|
|
|
ui.altSpeedLimitDaysCombo->addItem (tr ("Every Day"), QVariant (TR_SCHED_ALL));
|
|
|
|
r = spinBoxNew (Prefs::DSPEED, 0, INT_MAX, 5);
|
|
|
|
ui.altSpeedLimitDaysCombo->addItem (tr ("Weekdays"), QVariant (TR_SCHED_WEEKDAY));
|
|
|
|
r->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
ui.altSpeedLimitDaysCombo->addItem (tr ("Weekends"), QVariant (TR_SCHED_WEEKEND));
|
|
|
|
hig->addRow (l, r);
|
|
|
|
ui.altSpeedLimitDaysCombo->insertSeparator (ui.altSpeedLimitDaysCombo->count ());
|
|
|
|
enableBuddyWhenChecked (qobject_cast<QCheckBox*>(l), r);
|
|
|
|
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)));
|
|
|
|
|
|
|
|
|
|
|
|
hig->addSectionDivider ();
|
|
|
|
linkWidgetToPref (ui.uploadSpeedLimitCheck, Prefs::USPEED_ENABLED);
|
|
|
|
QHBoxLayout * h = new QHBoxLayout;
|
|
|
|
linkWidgetToPref (ui.uploadSpeedLimitSpin, Prefs::USPEED);
|
|
|
|
h->setSpacing (HIG::PAD);
|
|
|
|
linkWidgetToPref (ui.downloadSpeedLimitCheck, Prefs::DSPEED_ENABLED);
|
|
|
|
QLabel * label = new QLabel;
|
|
|
|
linkWidgetToPref (ui.downloadSpeedLimitSpin, Prefs::DSPEED);
|
|
|
|
label->setPixmap (QPixmap (QString::fromUtf8 (":/icons/alt-limit-off.png")));
|
|
|
|
linkWidgetToPref (ui.altUploadSpeedLimitSpin, Prefs::ALT_SPEED_LIMIT_UP);
|
|
|
|
label->setAlignment (Qt::AlignLeft|Qt::AlignVCenter);
|
|
|
|
linkWidgetToPref (ui.altDownloadSpeedLimitSpin, Prefs::ALT_SPEED_LIMIT_DOWN);
|
|
|
|
h->addWidget (label);
|
|
|
|
linkWidgetToPref (ui.altSpeedLimitScheduleCheck, Prefs::ALT_SPEED_LIMIT_TIME_ENABLED);
|
|
|
|
label = new QLabel (tr ("Alternative Speed Limits"));
|
|
|
|
linkWidgetToPref (ui.altSpeedLimitStartTimeEdit, Prefs::ALT_SPEED_LIMIT_TIME_BEGIN);
|
|
|
|
label->setStyleSheet (QString::fromUtf8 ("font: bold"));
|
|
|
|
linkWidgetToPref (ui.altSpeedLimitEndTimeEdit, Prefs::ALT_SPEED_LIMIT_TIME_END);
|
|
|
|
label->setAlignment (Qt::AlignLeft|Qt::AlignVCenter);
|
|
|
|
|
|
|
|
h->addWidget (label);
|
|
|
|
|
|
|
|
hig->addSectionTitle (h);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString s = tr ("<small>Override normal speed limits manually or at scheduled times</small>");
|
|
|
|
mySchedWidgets <<
|
|
|
|
hig->addWideControl (new QLabel (s));
|
|
|
|
ui.altSpeedLimitStartTimeEdit <<
|
|
|
|
|
|
|
|
ui.altSpeedLimitToLabel <<
|
|
|
|
|
|
|
|
ui.altSpeedLimitEndTimeEdit <<
|
|
|
|
|
|
|
|
ui.altSpeedLimitDaysLabel <<
|
|
|
|
|
|
|
|
ui.altSpeedLimitDaysCombo;
|
|
|
|
|
|
|
|
|
|
|
|
s = tr ("U&pload:");
|
|
|
|
ColumnResizer * cr (new ColumnResizer (this));
|
|
|
|
r = spinBoxNew (Prefs::ALT_SPEED_LIMIT_UP, 0, INT_MAX, 5);
|
|
|
|
cr->addLayout (ui.speedLimitsSectionLayout);
|
|
|
|
r->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
cr->addLayout (ui.altSpeedLimitsSectionLayout);
|
|
|
|
hig->addRow (s, r);
|
|
|
|
cr->update ();
|
|
|
|
|
|
|
|
|
|
|
|
s = tr ("Do&wnload:");
|
|
|
|
connect (ui.altSpeedLimitDaysCombo, SIGNAL (activated (int)), SLOT (altSpeedDaysEdited (int)));
|
|
|
|
r = spinBoxNew (Prefs::ALT_SPEED_LIMIT_DOWN, 0, INT_MAX, 5);
|
|
|
|
|
|
|
|
r->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
|
|
|
|
|
|
|
|
hig->addRow (s, r);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QCheckBox * c = checkBoxNew (tr ("&Scheduled times:"), Prefs::ALT_SPEED_LIMIT_TIME_ENABLED);
|
|
|
|
|
|
|
|
h = new QHBoxLayout ();
|
|
|
|
|
|
|
|
h->setSpacing (HIG::PAD);
|
|
|
|
|
|
|
|
QWidget * w = timeEditNew (Prefs::ALT_SPEED_LIMIT_TIME_BEGIN);
|
|
|
|
|
|
|
|
h->addWidget (w, 1);
|
|
|
|
|
|
|
|
mySchedWidgets << w;
|
|
|
|
|
|
|
|
QLabel * nd = new QLabel (tr("&to"));
|
|
|
|
|
|
|
|
h->addWidget (nd);
|
|
|
|
|
|
|
|
mySchedWidgets << nd;
|
|
|
|
|
|
|
|
w = timeEditNew (Prefs::ALT_SPEED_LIMIT_TIME_END);
|
|
|
|
|
|
|
|
nd->setBuddy (w);
|
|
|
|
|
|
|
|
h->addWidget (w, 1);
|
|
|
|
|
|
|
|
mySchedWidgets << w;
|
|
|
|
|
|
|
|
hig->addRow (c, h, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s = tr ("&On days:");
|
|
|
|
|
|
|
|
QComboBox * box = new QComboBox;
|
|
|
|
|
|
|
|
const QIcon noIcon;
|
|
|
|
|
|
|
|
box->addItem (noIcon, tr ("Every Day"), QVariant (TR_SCHED_ALL));
|
|
|
|
|
|
|
|
box->addItem (noIcon, tr ("Weekdays"), QVariant (TR_SCHED_WEEKDAY));
|
|
|
|
|
|
|
|
box->addItem (noIcon, tr ("Weekends"), QVariant (TR_SCHED_WEEKEND));
|
|
|
|
|
|
|
|
box->addItem (noIcon, tr ("Sunday"), QVariant (TR_SCHED_SUN));
|
|
|
|
|
|
|
|
box->addItem (noIcon, tr ("Monday"), QVariant (TR_SCHED_MON));
|
|
|
|
|
|
|
|
box->addItem (noIcon, tr ("Tuesday"), QVariant (TR_SCHED_TUES));
|
|
|
|
|
|
|
|
box->addItem (noIcon, tr ("Wednesday"), QVariant (TR_SCHED_WED));
|
|
|
|
|
|
|
|
box->addItem (noIcon, tr ("Thursday"), QVariant (TR_SCHED_THURS));
|
|
|
|
|
|
|
|
box->addItem (noIcon, tr ("Friday"), QVariant (TR_SCHED_FRI));
|
|
|
|
|
|
|
|
box->addItem (noIcon, tr ("Saturday"), QVariant (TR_SCHED_SAT));
|
|
|
|
|
|
|
|
box->setCurrentIndex (box->findData (myPrefs.getInt (Prefs::ALT_SPEED_LIMIT_TIME_DAY)));
|
|
|
|
|
|
|
|
connect (box, SIGNAL(activated(int)), this, SLOT(altSpeedDaysEdited(int)));
|
|
|
|
|
|
|
|
w = hig->addRow (s, box);
|
|
|
|
|
|
|
|
mySchedWidgets << w << box;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->finish ();
|
|
|
|
|
|
|
|
return hig;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
void
|
|
|
|
PrefsDialog::createDesktopTab ()
|
|
|
|
PrefsDialog::initDesktopTab ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HIG * hig = new HIG (this);
|
|
|
|
linkWidgetToPref (ui.showTrayIconCheck, Prefs::SHOW_TRAY_ICON);
|
|
|
|
hig->addSectionTitle (tr ("Desktop"));
|
|
|
|
linkWidgetToPref (ui.startMinimizedCheck, Prefs::START_MINIMIZED);
|
|
|
|
|
|
|
|
linkWidgetToPref (ui.notifyOnTorrentAddedCheck, Prefs::SHOW_NOTIFICATION_ON_ADD);
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("Show Transmission icon in the ¬ification area"), Prefs::SHOW_TRAY_ICON));
|
|
|
|
linkWidgetToPref (ui.notifyOnTorrentCompletedCheck, Prefs::SHOW_NOTIFICATION_ON_COMPLETE);
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("Start &minimized in notification area"), Prefs::START_MINIMIZED));
|
|
|
|
linkWidgetToPref (ui.playSoundOnTorrentCompletedCheck, Prefs::COMPLETE_SOUND_ENABLED);
|
|
|
|
|
|
|
|
|
|
|
|
hig->addSectionDivider ();
|
|
|
|
|
|
|
|
hig->addSectionTitle (tr ("Notification"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("Show a notification when torrents are a&dded"), Prefs::SHOW_NOTIFICATION_ON_ADD));
|
|
|
|
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("Show a notification when torrents &finish"), Prefs::SHOW_NOTIFICATION_ON_COMPLETE));
|
|
|
|
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("Play a &sound when torrents finish"), Prefs::COMPLETE_SOUND_ENABLED));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->finish ();
|
|
|
|
|
|
|
|
return hig;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/***
|
|
|
|
@@ -325,63 +300,44 @@ PrefsDialog::createDesktopTab ()
|
|
|
|
void
|
|
|
|
void
|
|
|
|
PrefsDialog::onPortTested (bool isOpen)
|
|
|
|
PrefsDialog::onPortTested (bool isOpen)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
myPortButton->setEnabled (true);
|
|
|
|
ui.testPeerPortButton->setEnabled (true);
|
|
|
|
myWidgets[Prefs::PEER_PORT]->setEnabled (true);
|
|
|
|
myWidgets[Prefs::PEER_PORT]->setEnabled (true);
|
|
|
|
myPortLabel->setText (isOpen ? tr ("Port is <b>open</b>")
|
|
|
|
ui.peerPortStatusLabel->setText (isOpen ? tr ("Port is <b>open</b>")
|
|
|
|
: tr ("Port is <b>closed</b>"));
|
|
|
|
: tr ("Port is <b>closed</b>"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
PrefsDialog::onPortTest ()
|
|
|
|
PrefsDialog::onPortTest ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
myPortLabel->setText (tr ("Testing TCP Port..."));
|
|
|
|
ui.peerPortStatusLabel->setText (tr ("Testing TCP Port..."));
|
|
|
|
myPortButton->setEnabled (false);
|
|
|
|
ui.testPeerPortButton->setEnabled (false);
|
|
|
|
myWidgets[Prefs::PEER_PORT]->setEnabled (false);
|
|
|
|
myWidgets[Prefs::PEER_PORT]->setEnabled (false);
|
|
|
|
mySession.portTest ();
|
|
|
|
mySession.portTest ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
void
|
|
|
|
PrefsDialog::createNetworkTab ()
|
|
|
|
PrefsDialog::initNetworkTab ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HIG * hig = new HIG (this);
|
|
|
|
ui.torrentPeerLimitSpin->setRange (1, FD_SETSIZE);
|
|
|
|
hig->addSectionTitle (tr ("Incoming Peers"));
|
|
|
|
ui.globalPeerLimitSpin->setRange (1, FD_SETSIZE);
|
|
|
|
|
|
|
|
|
|
|
|
QSpinBox * s = spinBoxNew (Prefs::PEER_PORT, 1, 65535, 1);
|
|
|
|
linkWidgetToPref (ui.peerPortSpin, Prefs::PEER_PORT);
|
|
|
|
QHBoxLayout * h = new QHBoxLayout ();
|
|
|
|
linkWidgetToPref (ui.randomPeerPortCheck, Prefs::PEER_PORT_RANDOM_ON_START);
|
|
|
|
QPushButton * b = myPortButton = new QPushButton (tr ("Te&st Port"));
|
|
|
|
linkWidgetToPref (ui.enablePortForwardingCheck, Prefs::PORT_FORWARDING);
|
|
|
|
QLabel * l = myPortLabel = new QLabel (tr ("Status unknown"));
|
|
|
|
linkWidgetToPref (ui.torrentPeerLimitSpin, Prefs::PEER_LIMIT_TORRENT);
|
|
|
|
h->addWidget (l);
|
|
|
|
linkWidgetToPref (ui.globalPeerLimitSpin, Prefs::PEER_LIMIT_GLOBAL);
|
|
|
|
h->addSpacing (HIG::PAD_BIG);
|
|
|
|
linkWidgetToPref (ui.enableUtpCheck, Prefs::UTP_ENABLED);
|
|
|
|
h->addWidget (b);
|
|
|
|
linkWidgetToPref (ui.enablePexCheck, Prefs::PEX_ENABLED);
|
|
|
|
h->setStretchFactor (l, 1);
|
|
|
|
linkWidgetToPref (ui.enableDhtCheck, Prefs::DHT_ENABLED);
|
|
|
|
connect (b, SIGNAL(clicked(bool)), this, SLOT(onPortTest()));
|
|
|
|
linkWidgetToPref (ui.enableLpdCheck, Prefs::LPD_ENABLED);
|
|
|
|
connect (&mySession, SIGNAL(portTested(bool)), this, SLOT(onPortTested(bool)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->addRow (tr ("&Port for incoming connections:"), s);
|
|
|
|
ColumnResizer * cr (new ColumnResizer (this));
|
|
|
|
hig->addRow (QString(), h, 0);
|
|
|
|
cr->addLayout (ui.incomingPeersSectionLayout);
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("Pick a &random port every time Transmission is started"), Prefs::PEER_PORT_RANDOM_ON_START));
|
|
|
|
cr->addLayout (ui.peerLimitsSectionLayout);
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("Use UPnP or NAT-PMP port &forwarding from my router"), Prefs::PORT_FORWARDING));
|
|
|
|
cr->update ();
|
|
|
|
|
|
|
|
|
|
|
|
hig->addSectionDivider ();
|
|
|
|
connect (ui.testPeerPortButton, SIGNAL (clicked ()), SLOT (onPortTest ()));
|
|
|
|
hig->addSectionTitle (tr ("Peer Limits"));
|
|
|
|
connect (&mySession, SIGNAL (portTested (bool)), SLOT (onPortTested (bool)));
|
|
|
|
hig->addRow (tr ("Maximum peers per &torrent:"), spinBoxNew (Prefs::PEER_LIMIT_TORRENT, 1, FD_SETSIZE, 5));
|
|
|
|
|
|
|
|
hig->addRow (tr ("Maximum peers &overall:"), spinBoxNew (Prefs::PEER_LIMIT_GLOBAL, 1, FD_SETSIZE, 5));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->addSectionDivider ();
|
|
|
|
|
|
|
|
hig->addSectionTitle (tr ("Options"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget * w;
|
|
|
|
|
|
|
|
hig->addWideControl (w = checkBoxNew (tr ("Enable &uTP for peer connections"), Prefs::UTP_ENABLED));
|
|
|
|
|
|
|
|
w->setToolTip (tr ("uTP is a tool for reducing network congestion."));
|
|
|
|
|
|
|
|
hig->addWideControl (w = checkBoxNew (tr ("Use PE&X to find more peers"), Prefs::PEX_ENABLED));
|
|
|
|
|
|
|
|
w->setToolTip (tr ("PEX is a tool for exchanging peer lists with the peers you're connected to."));
|
|
|
|
|
|
|
|
hig->addWideControl (w = checkBoxNew (tr ("Use &DHT to find more peers"), Prefs::DHT_ENABLED));
|
|
|
|
|
|
|
|
w->setToolTip (tr ("DHT is a tool for finding peers without a tracker."));
|
|
|
|
|
|
|
|
hig->addWideControl (w = checkBoxNew (tr ("Use &Local Peer Discovery to find more peers"), Prefs::LPD_ENABLED));
|
|
|
|
|
|
|
|
w->setToolTip (tr ("LPD is a tool for finding peers on your local network."));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->finish ();
|
|
|
|
|
|
|
|
return hig;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/***
|
|
|
|
@@ -431,49 +387,33 @@ PrefsDialog::encryptionEdited (int i)
|
|
|
|
setPref (Prefs::ENCRYPTION, value);
|
|
|
|
setPref (Prefs::ENCRYPTION, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
void
|
|
|
|
PrefsDialog::createPrivacyTab ()
|
|
|
|
PrefsDialog::initPrivacyTab ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QWidget * w;
|
|
|
|
ui.encryptionModeCombo->addItem (tr ("Allow encryption"), 0);
|
|
|
|
HIG * hig = new HIG (this);
|
|
|
|
ui.encryptionModeCombo->addItem (tr ("Prefer encryption"), 1);
|
|
|
|
|
|
|
|
ui.encryptionModeCombo->addItem (tr ("Require encryption"), 2);
|
|
|
|
|
|
|
|
|
|
|
|
hig->addSectionTitle (tr ("Encryption"));
|
|
|
|
linkWidgetToPref (ui.encryptionModeCombo, Prefs::ENCRYPTION);
|
|
|
|
|
|
|
|
linkWidgetToPref (ui.blocklistCheck, Prefs::BLOCKLIST_ENABLED);
|
|
|
|
|
|
|
|
linkWidgetToPref (ui.blocklistEdit, Prefs::BLOCKLIST_URL);
|
|
|
|
|
|
|
|
linkWidgetToPref (ui.autoUpdateBlocklistCheck, Prefs::BLOCKLIST_UPDATES_ENABLED);
|
|
|
|
|
|
|
|
|
|
|
|
QComboBox * box = new QComboBox ();
|
|
|
|
myBlockWidgets <<
|
|
|
|
box->addItem (tr ("Allow encryption"), 0);
|
|
|
|
ui.blocklistEdit <<
|
|
|
|
box->addItem (tr ("Prefer encryption"), 1);
|
|
|
|
ui.blocklistStatusLabel <<
|
|
|
|
box->addItem (tr ("Require encryption"), 2);
|
|
|
|
ui.updateBlocklistButton <<
|
|
|
|
myWidgets.insert (Prefs::ENCRYPTION, box);
|
|
|
|
ui.autoUpdateBlocklistCheck;
|
|
|
|
connect (box, SIGNAL(activated(int)), this, SLOT(encryptionEdited(int)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->addRow (tr ("&Encryption mode:"), box);
|
|
|
|
ColumnResizer * cr (new ColumnResizer (this));
|
|
|
|
|
|
|
|
cr->addLayout (ui.encryptionSectionLayout);
|
|
|
|
|
|
|
|
cr->addLayout (ui.blocklistSectionLayout);
|
|
|
|
|
|
|
|
cr->update ();
|
|
|
|
|
|
|
|
|
|
|
|
hig->addSectionDivider ();
|
|
|
|
connect (ui.encryptionModeCombo, SIGNAL (activated (int)), SLOT (encryptionEdited (int)));
|
|
|
|
hig->addSectionTitle (tr ("Blocklist"));
|
|
|
|
connect (ui.updateBlocklistButton, SIGNAL (clicked ()), SLOT (onUpdateBlocklistClicked ()));
|
|
|
|
|
|
|
|
|
|
|
|
QWidget * l = checkBoxNew (tr("Enable &blocklist:"), Prefs::BLOCKLIST_ENABLED);
|
|
|
|
|
|
|
|
QWidget * e = lineEditNew (Prefs::BLOCKLIST_URL);
|
|
|
|
|
|
|
|
myBlockWidgets << e;
|
|
|
|
|
|
|
|
hig->addRow (l, e);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
l = myBlocklistLabel = new QLabel ();
|
|
|
|
|
|
|
|
myBlockWidgets << l;
|
|
|
|
|
|
|
|
w = new QPushButton (tr ("&Update"));
|
|
|
|
|
|
|
|
connect (w, SIGNAL(clicked(bool)), this, SLOT(onUpdateBlocklistClicked()));
|
|
|
|
|
|
|
|
myBlockWidgets << w;
|
|
|
|
|
|
|
|
QHBoxLayout * h = new QHBoxLayout ();
|
|
|
|
|
|
|
|
h->addWidget (l);
|
|
|
|
|
|
|
|
h->addStretch (1);
|
|
|
|
|
|
|
|
h->addWidget (w);
|
|
|
|
|
|
|
|
hig->addWideControl (h);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
l = checkBoxNew (tr ("Enable &automatic updates"), Prefs::BLOCKLIST_UPDATES_ENABLED);
|
|
|
|
|
|
|
|
myBlockWidgets << l;
|
|
|
|
|
|
|
|
hig->addWideControl (l);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->finish ();
|
|
|
|
|
|
|
|
updateBlocklistLabel ();
|
|
|
|
updateBlocklistLabel ();
|
|
|
|
return hig;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/***
|
|
|
|
@@ -534,127 +474,76 @@ void
|
|
|
|
PrefsDialog::onIdleLimitChanged ()
|
|
|
|
PrefsDialog::onIdleLimitChanged ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//: Spin box suffix, "Stop seeding if idle for: [ 5 minutes ]" (includes leading space after the number, if needed)
|
|
|
|
//: Spin box suffix, "Stop seeding if idle for: [ 5 minutes ]" (includes leading space after the number, if needed)
|
|
|
|
const QString unitsSuffix = tr (" minute(s)", 0, myIdleLimitSpin->value ());
|
|
|
|
const QString unitsSuffix = tr (" minute(s)", 0, ui.idleLimitSpin->value ());
|
|
|
|
if (myIdleLimitSpin->suffix () != unitsSuffix)
|
|
|
|
if (ui.idleLimitSpin->suffix () != unitsSuffix)
|
|
|
|
myIdleLimitSpin->setSuffix (unitsSuffix);
|
|
|
|
ui.idleLimitSpin->setSuffix (unitsSuffix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
void
|
|
|
|
PrefsDialog::createSeedingTab ()
|
|
|
|
PrefsDialog::initSeedingTab ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize));
|
|
|
|
linkWidgetToPref (ui.ratioLimitCheck, Prefs::RATIO_ENABLED);
|
|
|
|
const QFileIconProvider iconProvider;
|
|
|
|
linkWidgetToPref (ui.ratioLimitSpin, Prefs::RATIO);
|
|
|
|
const QIcon folderIcon = iconProvider.icon (QFileIconProvider::Folder);
|
|
|
|
linkWidgetToPref (ui.idleLimitCheck, Prefs::IDLE_LIMIT_ENABLED);
|
|
|
|
const QPixmap folderPixmap = folderIcon.pixmap (iconSize);
|
|
|
|
linkWidgetToPref (ui.idleLimitSpin, Prefs::IDLE_LIMIT);
|
|
|
|
const QIcon fileIcon = iconProvider.icon (QFileIconProvider::File);
|
|
|
|
|
|
|
|
const QPixmap filePixmap = fileIcon.pixmap (iconSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *l, *r;
|
|
|
|
connect (ui.idleLimitSpin, SIGNAL (valueChanged (int)), SLOT (onIdleLimitChanged ()));
|
|
|
|
HIG * hig = new HIG (this);
|
|
|
|
|
|
|
|
hig->addSectionTitle (tr ("Limits"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
l = checkBoxNew (tr ("Stop seeding at &ratio:"), Prefs::RATIO_ENABLED);
|
|
|
|
|
|
|
|
r = doubleSpinBoxNew (Prefs::RATIO, 0, INT_MAX, 0.5, 2);
|
|
|
|
|
|
|
|
hig->addRow (l, r);
|
|
|
|
|
|
|
|
enableBuddyWhenChecked (qobject_cast<QCheckBox*>(l), r);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
l = checkBoxNew (tr ("Stop seedi&ng if idle for:"), Prefs::IDLE_LIMIT_ENABLED);
|
|
|
|
|
|
|
|
r = myIdleLimitSpin = spinBoxNew (Prefs::IDLE_LIMIT, 1, INT_MAX, 5);
|
|
|
|
|
|
|
|
connect (r, SIGNAL (valueChanged (int)), this, SLOT (onIdleLimitChanged ()));
|
|
|
|
|
|
|
|
hig->addRow (l, r);
|
|
|
|
|
|
|
|
enableBuddyWhenChecked (qobject_cast<QCheckBox*>(l), r);
|
|
|
|
|
|
|
|
onIdleLimitChanged ();
|
|
|
|
onIdleLimitChanged ();
|
|
|
|
|
|
|
|
|
|
|
|
hig->finish ();
|
|
|
|
|
|
|
|
return hig;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
PrefsDialog::onQueueStalledMinutesChanged ()
|
|
|
|
PrefsDialog::onQueueStalledMinutesChanged ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//: Spin box suffix, "Download is inactive if data sharing stopped: [ 5 minutes ago ]" (includes leading space after the number, if needed)
|
|
|
|
//: Spin box suffix, "Download is inactive if data sharing stopped: [ 5 minutes ago ]" (includes leading space after the number, if needed)
|
|
|
|
const QString unitsSuffix = tr (" minute(s) ago", 0, myQueueStalledMinutesSpin->value ());
|
|
|
|
const QString unitsSuffix = tr (" minute(s) ago", 0, ui.queueStalledMinutesSpin->value ());
|
|
|
|
if (myQueueStalledMinutesSpin->suffix () != unitsSuffix)
|
|
|
|
if (ui.queueStalledMinutesSpin->suffix () != unitsSuffix)
|
|
|
|
myQueueStalledMinutesSpin->setSuffix (unitsSuffix);
|
|
|
|
ui.queueStalledMinutesSpin->setSuffix (unitsSuffix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
void
|
|
|
|
PrefsDialog::createDownloadingTab ()
|
|
|
|
PrefsDialog::initDownloadingTab ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize));
|
|
|
|
const QSize iconSize (QSize (1, 1) * style ()->pixelMetric (QStyle::PM_SmallIconSize));
|
|
|
|
const QFileIconProvider iconProvider;
|
|
|
|
const QFileIconProvider iconProvider;
|
|
|
|
const QIcon folderIcon = iconProvider.icon (QFileIconProvider::Folder);
|
|
|
|
const QIcon folderIcon = iconProvider.icon (QFileIconProvider::Folder);
|
|
|
|
const QPixmap folderPixmap = folderIcon.pixmap (iconSize);
|
|
|
|
|
|
|
|
const QIcon fileIcon = iconProvider.icon (QFileIconProvider::File);
|
|
|
|
const QIcon fileIcon = iconProvider.icon (QFileIconProvider::File);
|
|
|
|
const QPixmap filePixmap = fileIcon.pixmap (iconSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget * l;
|
|
|
|
ui.watchDirButton->setIcon (folderIcon);
|
|
|
|
QPushButton * b;
|
|
|
|
ui.watchDirButton->setIconSize (iconSize);
|
|
|
|
HIG * hig = new HIG (this);
|
|
|
|
ui.downloadDirButton->setIcon (folderIcon);
|
|
|
|
hig->addSectionTitle (tr ("Adding"));
|
|
|
|
ui.downloadDirButton->setIconSize (iconSize);
|
|
|
|
|
|
|
|
ui.incompleteDirButton->setIcon (folderIcon);
|
|
|
|
|
|
|
|
ui.incompleteDirButton->setIconSize (iconSize);
|
|
|
|
|
|
|
|
ui.completionScriptButton->setIcon (fileIcon);
|
|
|
|
|
|
|
|
ui.completionScriptButton->setIconSize (iconSize);
|
|
|
|
|
|
|
|
|
|
|
|
l = checkBoxNew (tr ("Automatically add .torrent files &from:"), Prefs::DIR_WATCH_ENABLED);
|
|
|
|
ui.downloadDirFreeSpaceLabel->setSession (mySession);
|
|
|
|
b = myWatchButton = new QPushButton;
|
|
|
|
ui.downloadDirFreeSpaceLabel->setPath (myPrefs.getString (Prefs::DOWNLOAD_DIR));
|
|
|
|
b->setIcon (folderPixmap);
|
|
|
|
|
|
|
|
b->setStyleSheet (QString::fromUtf8 ("text-align: left; padding-left: 5; padding-right: 5"));
|
|
|
|
|
|
|
|
connect (b, SIGNAL(clicked(bool)), this, SLOT(onWatchClicked()));
|
|
|
|
|
|
|
|
hig->addRow (l, b);
|
|
|
|
|
|
|
|
enableBuddyWhenChecked (qobject_cast<QCheckBox*>(l), b);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("Show the Torrent Options &dialog"), Prefs::OPTIONS_PROMPT));
|
|
|
|
linkWidgetToPref (ui.watchDirCheck, Prefs::DIR_WATCH_ENABLED);
|
|
|
|
|
|
|
|
linkWidgetToPref (ui.showTorrentOptionsDialogCheck, Prefs::OPTIONS_PROMPT);
|
|
|
|
|
|
|
|
linkWidgetToPref (ui.startAddedTorrentsCheck, Prefs::START);
|
|
|
|
|
|
|
|
linkWidgetToPref (ui.trashTorrentFileCheck, Prefs::TRASH_ORIGINAL);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
linkWidgetToPref (ui.completionScriptCheck, Prefs::SCRIPT_TORRENT_DONE_ENABLED);
|
|
|
|
|
|
|
|
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("&Start added torrents"), Prefs::START));
|
|
|
|
ColumnResizer * cr (new ColumnResizer (this));
|
|
|
|
|
|
|
|
cr->addLayout (ui.addingSectionLayout);
|
|
|
|
|
|
|
|
cr->addLayout (ui.downloadQueueSectionLayout);
|
|
|
|
|
|
|
|
cr->addLayout (ui.incompleteSectionLayout);
|
|
|
|
|
|
|
|
cr->update ();
|
|
|
|
|
|
|
|
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("Mo&ve the .torrent file to the trash"), Prefs::TRASH_ORIGINAL));
|
|
|
|
connect (ui.watchDirButton, SIGNAL (clicked ()), SLOT (onWatchClicked ()));
|
|
|
|
|
|
|
|
connect (ui.downloadDirButton, SIGNAL (clicked ()), SLOT (onDestinationClicked ()));
|
|
|
|
|
|
|
|
connect (ui.incompleteDirButton, SIGNAL (clicked ()), SLOT (onIncompleteClicked ()));
|
|
|
|
|
|
|
|
connect (ui.completionScriptButton, SIGNAL (clicked ()), SLOT (onScriptClicked ()));
|
|
|
|
|
|
|
|
connect (ui.queueStalledMinutesSpin, SIGNAL (valueChanged (int)), SLOT (onQueueStalledMinutesChanged ()));
|
|
|
|
|
|
|
|
|
|
|
|
b = myDestinationButton = new QPushButton;
|
|
|
|
|
|
|
|
b->setIcon (folderPixmap);
|
|
|
|
|
|
|
|
b->setStyleSheet (QString::fromUtf8 ("text-align: left; padding-left: 5; padding-right: 5"));
|
|
|
|
|
|
|
|
connect (b, SIGNAL(clicked(bool)), this, SLOT(onDestinationClicked()));
|
|
|
|
|
|
|
|
hig->addRow (tr ("Save to &Location:"), b);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QString downloadDir (myPrefs.getString(Prefs::DOWNLOAD_DIR));
|
|
|
|
|
|
|
|
l = myFreespaceLabel = new FreespaceLabel (this);
|
|
|
|
|
|
|
|
myFreespaceLabel->setSession (mySession);
|
|
|
|
|
|
|
|
myFreespaceLabel->setPath (downloadDir);
|
|
|
|
|
|
|
|
QHBoxLayout * h = new QHBoxLayout ();
|
|
|
|
|
|
|
|
h->addStretch (1);
|
|
|
|
|
|
|
|
h->addWidget (l);
|
|
|
|
|
|
|
|
hig->addWideControl (h);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->addSectionDivider ();
|
|
|
|
|
|
|
|
hig->addSectionTitle (tr ("Download Queue"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->addRow (tr ("Ma&ximum active downloads:"), spinBoxNew (Prefs::DOWNLOAD_QUEUE_SIZE, 1, INT_MAX, 1));
|
|
|
|
|
|
|
|
QSpinBox * sb = myQueueStalledMinutesSpin = spinBoxNew (Prefs::QUEUE_STALLED_MINUTES, 1, INT_MAX, 10);
|
|
|
|
|
|
|
|
connect (sb, SIGNAL (valueChanged (int)), this, SLOT (onQueueStalledMinutesChanged ()));
|
|
|
|
|
|
|
|
//: Please keep this phrase as short as possible, it's curently the longest and influences dialog width
|
|
|
|
|
|
|
|
hig->addRow (tr ("Download is i&nactive if data sharing stopped:"), sb);
|
|
|
|
|
|
|
|
onQueueStalledMinutesChanged ();
|
|
|
|
onQueueStalledMinutesChanged ();
|
|
|
|
|
|
|
|
|
|
|
|
hig->addSectionDivider ();
|
|
|
|
|
|
|
|
hig->addSectionTitle (tr ("Incomplete"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->addWideControl (checkBoxNew (tr ("Append \".&part\" to incomplete files' names"), Prefs::RENAME_PARTIAL_FILES));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
l = myIncompleteCheckbox = checkBoxNew (tr ("Keep &incomplete files in:"), Prefs::INCOMPLETE_DIR_ENABLED);
|
|
|
|
|
|
|
|
b = myIncompleteButton = new QPushButton;
|
|
|
|
|
|
|
|
b->setIcon (folderPixmap);
|
|
|
|
|
|
|
|
b->setStyleSheet (QString::fromUtf8 ("text-align: left; padding-left: 5; padding-right: 5"));
|
|
|
|
|
|
|
|
connect (b, SIGNAL(clicked(bool)), this, SLOT(onIncompleteClicked()));
|
|
|
|
|
|
|
|
hig->addRow (myIncompleteCheckbox, b);
|
|
|
|
|
|
|
|
enableBuddyWhenChecked (qobject_cast<QCheckBox*>(l), b);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
l = myTorrentDoneScriptCheckbox = checkBoxNew (tr ("Call scrip&t when torrent is completed:"), Prefs::SCRIPT_TORRENT_DONE_ENABLED);
|
|
|
|
|
|
|
|
b = myTorrentDoneScriptButton = new QPushButton;
|
|
|
|
|
|
|
|
b->setIcon (filePixmap);
|
|
|
|
|
|
|
|
b->setStyleSheet (QString::fromUtf8 ("text-align: left; padding-left: 5; padding-right: 5"));
|
|
|
|
|
|
|
|
connect (b, SIGNAL(clicked(bool)), this, SLOT(onScriptClicked()));
|
|
|
|
|
|
|
|
hig->addRow (myTorrentDoneScriptCheckbox, b);
|
|
|
|
|
|
|
|
enableBuddyWhenChecked (qobject_cast<QCheckBox*>(l), b);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hig->finish ();
|
|
|
|
|
|
|
|
return hig;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/***
|
|
|
|
@@ -665,27 +554,19 @@ PrefsDialog::PrefsDialog (Session& session, Prefs& prefs, QWidget * parent):
|
|
|
|
QDialog (parent),
|
|
|
|
QDialog (parent),
|
|
|
|
myIsServer (session.isServer ()),
|
|
|
|
myIsServer (session.isServer ()),
|
|
|
|
mySession (session),
|
|
|
|
mySession (session),
|
|
|
|
myPrefs (prefs),
|
|
|
|
myPrefs (prefs)
|
|
|
|
myLayout (new QVBoxLayout (this))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setWindowTitle (tr ("Transmission Preferences"));
|
|
|
|
ui.setupUi (this);
|
|
|
|
|
|
|
|
|
|
|
|
QTabWidget * t = new QTabWidget (this);
|
|
|
|
initSpeedTab ();
|
|
|
|
t->addTab (createSpeedTab (), tr ("Speed"));
|
|
|
|
initDownloadingTab ();
|
|
|
|
t->addTab (createDownloadingTab (), tr ("Downloading"));
|
|
|
|
initSeedingTab ();
|
|
|
|
t->addTab (createSeedingTab (), tr ("Seeding"));
|
|
|
|
initPrivacyTab ();
|
|
|
|
t->addTab (createPrivacyTab (), tr ("Privacy"));
|
|
|
|
initNetworkTab ();
|
|
|
|
t->addTab (createNetworkTab (), tr ("Network"));
|
|
|
|
initDesktopTab ();
|
|
|
|
t->addTab (createDesktopTab (), tr ("Desktop"));
|
|
|
|
initRemoteTab ();
|
|
|
|
t->addTab (createRemoteTab(session), tr ("Remote"));
|
|
|
|
|
|
|
|
myLayout->addWidget (t);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDialogButtonBox * buttons = new QDialogButtonBox (QDialogButtonBox::Close, Qt::Horizontal, this);
|
|
|
|
connect (&mySession, SIGNAL (sessionUpdated ()), SLOT (sessionUpdated ()));
|
|
|
|
connect (buttons, SIGNAL(rejected()), this, SLOT(close())); // "close" triggers rejected
|
|
|
|
|
|
|
|
myLayout->addWidget (buttons);
|
|
|
|
|
|
|
|
QWidget::setAttribute (Qt::WA_DeleteOnClose, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect (&mySession, SIGNAL(sessionUpdated()), this, SLOT(sessionUpdated()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<int> keys;
|
|
|
|
QList<int> keys;
|
|
|
|
keys << Prefs::RPC_ENABLED
|
|
|
|
keys << Prefs::RPC_ENABLED
|
|
|
|
@@ -711,6 +592,8 @@ PrefsDialog::PrefsDialog (Session& session, Prefs& prefs, QWidget * parent):
|
|
|
|
w->setEnabled (false);
|
|
|
|
w->setEnabled (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adjustSize ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PrefsDialog::~PrefsDialog ()
|
|
|
|
PrefsDialog::~PrefsDialog ()
|
|
|
|
@@ -738,7 +621,7 @@ void
|
|
|
|
PrefsDialog::updateBlocklistLabel ()
|
|
|
|
PrefsDialog::updateBlocklistLabel ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const int n = mySession.blocklistSize ();
|
|
|
|
const int n = mySession.blocklistSize ();
|
|
|
|
myBlocklistLabel->setText (tr ("<i>Blocklist contains %Ln rule(s)</i>", 0, n));
|
|
|
|
ui.blocklistStatusLabel->setText (tr ("<i>Blocklist contains %Ln rule(s)</i>", 0, n));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
@@ -753,61 +636,59 @@ PrefsDialog::refreshPref (int key)
|
|
|
|
const bool enabled (myPrefs.getBool (Prefs::RPC_ENABLED));
|
|
|
|
const bool enabled (myPrefs.getBool (Prefs::RPC_ENABLED));
|
|
|
|
const bool whitelist (myPrefs.getBool (Prefs::RPC_WHITELIST_ENABLED));
|
|
|
|
const bool whitelist (myPrefs.getBool (Prefs::RPC_WHITELIST_ENABLED));
|
|
|
|
const bool auth (myPrefs.getBool (Prefs::RPC_AUTH_REQUIRED));
|
|
|
|
const bool auth (myPrefs.getBool (Prefs::RPC_AUTH_REQUIRED));
|
|
|
|
foreach (QWidget * w, myWebWhitelistWidgets)w->setEnabled (enabled && whitelist);
|
|
|
|
foreach (QWidget * w, myWebWhitelistWidgets)
|
|
|
|
foreach (QWidget * w, myWebAuthWidgets)w->setEnabled (enabled && auth);
|
|
|
|
w->setEnabled (enabled && whitelist);
|
|
|
|
foreach (QWidget * w, myWebWidgets)w->setEnabled (enabled);
|
|
|
|
foreach (QWidget * w, myWebAuthWidgets)
|
|
|
|
|
|
|
|
w->setEnabled (enabled && auth);
|
|
|
|
|
|
|
|
foreach (QWidget * w, myWebWidgets)
|
|
|
|
|
|
|
|
w->setEnabled (enabled);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case Prefs::ALT_SPEED_LIMIT_TIME_ENABLED:
|
|
|
|
case Prefs::ALT_SPEED_LIMIT_TIME_ENABLED:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const bool enabled = myPrefs.getBool (key);
|
|
|
|
const bool enabled = myPrefs.getBool (key);
|
|
|
|
foreach (QWidget * w, mySchedWidgets)w->setEnabled (enabled);
|
|
|
|
foreach (QWidget * w, mySchedWidgets)
|
|
|
|
|
|
|
|
w->setEnabled (enabled);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case Prefs::BLOCKLIST_ENABLED:
|
|
|
|
case Prefs::BLOCKLIST_ENABLED:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const bool enabled = myPrefs.getBool (key);
|
|
|
|
const bool enabled = myPrefs.getBool (key);
|
|
|
|
foreach (QWidget * w, myBlockWidgets)w->setEnabled (enabled);
|
|
|
|
foreach (QWidget * w, myBlockWidgets)
|
|
|
|
|
|
|
|
w->setEnabled (enabled);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case Prefs::DIR_WATCH:
|
|
|
|
case Prefs::DIR_WATCH:
|
|
|
|
myWatchButton->setText (QFileInfo(myPrefs.getString(Prefs::DIR_WATCH)).fileName());
|
|
|
|
ui.watchDirButton->setText (QFileInfo (myPrefs.getString (Prefs::DIR_WATCH)).fileName ());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case Prefs::SCRIPT_TORRENT_DONE_FILENAME:
|
|
|
|
case Prefs::SCRIPT_TORRENT_DONE_FILENAME:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const QString path (myPrefs.getString (key));
|
|
|
|
const QString path (myPrefs.getString (key));
|
|
|
|
myTorrentDoneScriptButton->setText (QFileInfo(path).fileName());
|
|
|
|
ui.completionScriptButton->setText (QFileInfo (path).fileName ());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case Prefs::PEER_PORT:
|
|
|
|
case Prefs::PEER_PORT:
|
|
|
|
myPortLabel->setText (tr ("Status unknown"));
|
|
|
|
ui.peerPortStatusLabel->setText (tr ("Status unknown"));
|
|
|
|
myPortButton->setEnabled (true);
|
|
|
|
ui.testPeerPortButton->setEnabled (true);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case Prefs::DOWNLOAD_DIR:
|
|
|
|
case Prefs::DOWNLOAD_DIR:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const QString path (myPrefs.getString (key));
|
|
|
|
const QString path (myPrefs.getString (key));
|
|
|
|
myDestinationButton->setText (QFileInfo(path).fileName());
|
|
|
|
ui.downloadDirButton->setText (QFileInfo (path).fileName ());
|
|
|
|
myFreespaceLabel->setPath (path);
|
|
|
|
ui.downloadDirFreeSpaceLabel->setPath (path);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case Prefs::INCOMPLETE_DIR:
|
|
|
|
case Prefs::INCOMPLETE_DIR:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString path (myPrefs.getString (key));
|
|
|
|
QString path (myPrefs.getString (key));
|
|
|
|
myIncompleteButton->setText (QFileInfo(path).fileName());
|
|
|
|
ui.incompleteDirButton->setText (QFileInfo (path).fileName ());
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case Prefs::INCOMPLETE_DIR_ENABLED:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const bool enabled = myPrefs.getBool (key);
|
|
|
|
|
|
|
|
myIncompleteButton->setEnabled (enabled);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -819,34 +700,10 @@ PrefsDialog::refreshPref (int key)
|
|
|
|
if (it != myWidgets.end ())
|
|
|
|
if (it != myWidgets.end ())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QWidget * w (it.value ());
|
|
|
|
QWidget * w (it.value ());
|
|
|
|
QCheckBox * checkBox;
|
|
|
|
|
|
|
|
QSpinBox * spin;
|
|
|
|
|
|
|
|
QDoubleSpinBox * doubleSpin;
|
|
|
|
|
|
|
|
QTimeEdit * timeEdit;
|
|
|
|
|
|
|
|
QLineEdit * lineEdit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((checkBox = qobject_cast<QCheckBox*>(w)))
|
|
|
|
if (!updateWidgetValue (w, key))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
checkBox->setChecked (myPrefs.getBool (key));
|
|
|
|
if (key == Prefs::ENCRYPTION)
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ((spin = qobject_cast<QSpinBox*>(w)))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
spin->setValue (myPrefs.getInt (key));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ((doubleSpin = qobject_cast<QDoubleSpinBox*>(w)))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
doubleSpin->setValue (myPrefs.getDouble (key));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ((timeEdit = qobject_cast<QTimeEdit*>(w)))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const int minutes (myPrefs.getInt (key));
|
|
|
|
|
|
|
|
timeEdit->setTime (QTime().addSecs (minutes * 60));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ((lineEdit = qobject_cast<QLineEdit*>(w)))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lineEdit->setText (myPrefs.getString (key));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (key == Prefs::ENCRYPTION)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QComboBox * comboBox (qobject_cast<QComboBox*> (w));
|
|
|
|
QComboBox * comboBox (qobject_cast<QComboBox*> (w));
|
|
|
|
const int index = comboBox->findData (myPrefs.getInt (key));
|
|
|
|
const int index = comboBox->findData (myPrefs.getInt (key));
|
|
|
|
@@ -854,11 +711,4 @@ PrefsDialog::refreshPref (int key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
|
|
|
PrefsDialog::isAllowed (int key) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Q_UNUSED (key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|