Rework preferences dialog in Qt client to load from .ui

This commit is contained in:
Mike Gelfand
2015-01-25 15:47:03 +00:00
parent 806f81c05c
commit a18d818882
8 changed files with 1710 additions and 506 deletions

View File

@@ -113,6 +113,7 @@ tr_qt_wrap_ui(${PROJECT_NAME}_UI_SOURCES
make-dialog.ui
make-progress-dialog.ui
options.ui
prefs-dialog.ui
relocate.ui
session-dialog.ui
stats-dialog.ui

View File

@@ -19,6 +19,12 @@
<property name="currentIndex">
<number>0</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
</property>
<property name="usesScrollButtons">
<bool>false</bool>
</property>
<widget class="QWidget" name="infoTab">
<attribute name="title">
<string>Information</string>
@@ -701,12 +707,12 @@
</item>
<item row="0" column="2">
<widget class="QDoubleSpinBox" name="ratioSpin">
<property name="minimum">
<double>0.500000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
</property>
</widget>
</item>
</layout>

View File

@@ -82,7 +82,7 @@ TrMainWindow::getStockIcon (const QString& name, int fallback)
TrMainWindow::TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model, bool minimized):
myLastFullUpdateTime (0),
mySessionDialog (new SessionDialog (session, prefs, this)),
myPrefsDialog (0),
myPrefsDialog (),
myAboutDialog (new AboutDialog (this)),
myStatsDialog (new StatsDialog (session, this)),
myDetailsDialog (0),
@@ -513,23 +513,21 @@ TrMainWindow::hideEvent (QHideEvent * event)
*****
****/
void
TrMainWindow::onPrefsDestroyed ()
{
myPrefsDialog = 0;
}
void
TrMainWindow::openPreferences ()
{
if (myPrefsDialog == 0)
if (myPrefsDialog.isNull ())
{
myPrefsDialog = new PrefsDialog (mySession, myPrefs, this);
connect (myPrefsDialog, SIGNAL (destroyed (QObject*)), this, SLOT (onPrefsDestroyed ()));
}
myPrefsDialog->setAttribute (Qt::WA_DeleteOnClose);
myPrefsDialog->show ();
}
else
{
myPrefsDialog->raise ();
myPrefsDialog->activateWindow ();
}
}
void
TrMainWindow::onDetailsDestroyed ()

View File

@@ -15,6 +15,7 @@
#include <QIcon>
#include <QMainWindow>
#include <QMap>
#include <QPointer>
#include <QPushButton>
#include <QSet>
#include <QSystemTrayIcon>
@@ -57,7 +58,7 @@ class TrMainWindow: public QMainWindow
private:
time_t myLastFullUpdateTime;
QDialog * mySessionDialog;
QDialog * myPrefsDialog;
QPointer<QDialog> myPrefsDialog;
QDialog * myAboutDialog;
QDialog * myStatsDialog;
Details * myDetailsDialog;
@@ -91,7 +92,6 @@ class TrMainWindow: public QMainWindow
QWidgetList myHidden;
private slots:
void onPrefsDestroyed ();
void openPreferences ();
void onDetailsDestroyed ();
void showTotalRatio ();

View File

@@ -33,6 +33,7 @@
#include <QTimer>
#include <QVBoxLayout>
#include "column-resizer.h"
#include "freespace-label.h"
#include "formatter.h"
#include "hig.h"
@@ -48,154 +49,177 @@
namespace
{
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
PrefsDialog::checkBoxToggled (bool checked)
{
const int key (sender ()->property (PREF_KEY).toInt ());
setPref (key, 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 ());
if (auto c = qobject_cast<QCheckBox*> (sender ()))
setPref (getPrefKey (c), checked);
}
void
PrefsDialog::spinBoxEditingFinished ()
{
const QObject * spin = sender();
const int key = spin->property (PREF_KEY).toInt ();
const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*> (spin);
const int key = getPrefKey (spin);
if (d)
setPref (key, d->value ());
else
setPref (key, qobject_cast<const QSpinBox*>(spin)->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;
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 ());
}
void
PrefsDialog::timeEditingFinished ()
{
auto e = qobject_cast<QTimeEdit*>(sender());
if (e != nullptr)
{
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;
if (auto e = qobject_cast<const QTimeEdit*> (sender ()))
setPref(getPrefKey (e), QTime ().secsTo (e->time()) / 60);
}
void
PrefsDialog::lineEditingFinished ()
{
QLineEdit * e = qobject_cast<QLineEdit*>(sender());
if (e && e->isModified ())
if (auto e = qobject_cast<const QLineEdit*> (sender ()))
{
const int key (e->property (PREF_KEY).toInt ());
const QString text (e->text());
setPref (key, text);
if (e->isModified ())
setPref (getPrefKey (e), e->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 *
PrefsDialog::createRemoteTab (Session& session)
void
PrefsDialog::initRemoteTab ()
{
HIG * hig = new HIG (this);
hig->addSectionTitle (tr ("Remote Control"));
QWidget * w;
QHBoxLayout * h = new QHBoxLayout ();
QPushButton * b = new QPushButton (tr ("&Open web client"));
connect (b, SIGNAL(clicked()), &session, SLOT(launchWebInterface()));
h->addWidget (b, 0, Qt::AlignRight);
QWidget * l = checkBoxNew (tr ("Allow &remote access"), Prefs::RPC_ENABLED);
myUnsupportedWhenRemote << l;
hig->addRow (l, h, 0);
l = hig->addRow (tr ("HTTP &port:"), w = spinBoxNew (Prefs::RPC_PORT, 0, 65535, 1));
myWebWidgets << l << w;
hig->addWideControl (w = checkBoxNew (tr ("Use &authentication"), Prefs::RPC_AUTH_REQUIRED));
myWebWidgets << w;
l = hig->addRow (tr ("&Username:"), w = lineEditNew (Prefs::RPC_USERNAME));
myWebAuthWidgets << l << w;
l = hig->addRow (tr ("Pass&word:"), w = lineEditNew (Prefs::RPC_PASSWORD, QLineEdit::Password));
myWebAuthWidgets << l << w;
hig->addWideControl (w = checkBoxNew (tr ("Only allow these IP a&ddresses:"), Prefs::RPC_WHITELIST_ENABLED));
myWebWidgets << w;
l = hig->addRow (tr ("Addresses:"), w = lineEditNew (Prefs::RPC_WHITELIST));
myWebWhitelistWidgets << l << w;
myUnsupportedWhenRemote << myWebWidgets << myWebAuthWidgets << myWebWhitelistWidgets;
hig->finish ();
return hig;
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 ()));
}
/***
@@ -209,113 +233,64 @@ PrefsDialog::altSpeedDaysEdited (int i)
setPref (Prefs::ALT_SPEED_LIMIT_TIME_DAY, value);
}
QWidget *
PrefsDialog::createSpeedTab ()
void
PrefsDialog::initSpeedTab ()
{
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 QLocale locale;
l = checkBoxNew (tr ("&Upload:"), Prefs::USPEED_ENABLED);
r = spinBoxNew (Prefs::USPEED, 0, INT_MAX, 5);
r->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
hig->addRow (l, r);
enableBuddyWhenChecked (qobject_cast<QCheckBox*>(l), r);
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));
l = checkBoxNew (tr ("&Download:"), Prefs::DSPEED_ENABLED);
r = spinBoxNew (Prefs::DSPEED, 0, INT_MAX, 5);
r->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
hig->addRow (l, r);
enableBuddyWhenChecked (qobject_cast<QCheckBox*>(l), r);
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)));
hig->addSectionDivider ();
QHBoxLayout * h = new QHBoxLayout;
h->setSpacing (HIG::PAD);
QLabel * label = new QLabel;
label->setPixmap (QPixmap (QString::fromUtf8 (":/icons/alt-limit-off.png")));
label->setAlignment (Qt::AlignLeft|Qt::AlignVCenter);
h->addWidget (label);
label = new QLabel (tr ("Alternative Speed Limits"));
label->setStyleSheet (QString::fromUtf8 ("font: bold"));
label->setAlignment (Qt::AlignLeft|Qt::AlignVCenter);
h->addWidget (label);
hig->addSectionTitle (h);
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);
QString s = tr ("<small>Override normal speed limits manually or at scheduled times</small>");
hig->addWideControl (new QLabel (s));
mySchedWidgets <<
ui.altSpeedLimitStartTimeEdit <<
ui.altSpeedLimitToLabel <<
ui.altSpeedLimitEndTimeEdit <<
ui.altSpeedLimitDaysLabel <<
ui.altSpeedLimitDaysCombo;
s = tr ("U&pload:");
r = spinBoxNew (Prefs::ALT_SPEED_LIMIT_UP, 0, INT_MAX, 5);
r->setSuffix (QString::fromLatin1 (" %1").arg (speed_K_str));
hig->addRow (s, r);
ColumnResizer * cr (new ColumnResizer (this));
cr->addLayout (ui.speedLimitsSectionLayout);
cr->addLayout (ui.altSpeedLimitsSectionLayout);
cr->update ();
s = tr ("Do&wnload:");
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;
connect (ui.altSpeedLimitDaysCombo, SIGNAL (activated (int)), SLOT (altSpeedDaysEdited (int)));
}
/***
****
***/
QWidget *
PrefsDialog::createDesktopTab ()
void
PrefsDialog::initDesktopTab ()
{
HIG * hig = new HIG (this);
hig->addSectionTitle (tr ("Desktop"));
hig->addWideControl (checkBoxNew (tr ("Show Transmission icon in the &notification area"), Prefs::SHOW_TRAY_ICON));
hig->addWideControl (checkBoxNew (tr ("Start &minimized in notification area"), Prefs::START_MINIMIZED));
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;
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);
}
/***
@@ -325,63 +300,44 @@ PrefsDialog::createDesktopTab ()
void
PrefsDialog::onPortTested (bool isOpen)
{
myPortButton->setEnabled (true);
ui.testPeerPortButton->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>"));
}
void
PrefsDialog::onPortTest ()
{
myPortLabel->setText (tr ("Testing TCP Port..."));
myPortButton->setEnabled (false);
ui.peerPortStatusLabel->setText (tr ("Testing TCP Port..."));
ui.testPeerPortButton->setEnabled (false);
myWidgets[Prefs::PEER_PORT]->setEnabled (false);
mySession.portTest ();
}
QWidget *
PrefsDialog::createNetworkTab ()
void
PrefsDialog::initNetworkTab ()
{
HIG * hig = new HIG (this);
hig->addSectionTitle (tr ("Incoming Peers"));
ui.torrentPeerLimitSpin->setRange (1, FD_SETSIZE);
ui.globalPeerLimitSpin->setRange (1, FD_SETSIZE);
QSpinBox * s = spinBoxNew (Prefs::PEER_PORT, 1, 65535, 1);
QHBoxLayout * h = new QHBoxLayout ();
QPushButton * b = myPortButton = new QPushButton (tr ("Te&st Port"));
QLabel * l = myPortLabel = new QLabel (tr ("Status unknown"));
h->addWidget (l);
h->addSpacing (HIG::PAD_BIG);
h->addWidget (b);
h->setStretchFactor (l, 1);
connect (b, SIGNAL(clicked(bool)), this, SLOT(onPortTest()));
connect (&mySession, SIGNAL(portTested(bool)), this, SLOT(onPortTested(bool)));
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);
hig->addRow (tr ("&Port for incoming connections:"), s);
hig->addRow (QString(), h, 0);
hig->addWideControl (checkBoxNew (tr ("Pick a &random port every time Transmission is started"), Prefs::PEER_PORT_RANDOM_ON_START));
hig->addWideControl (checkBoxNew (tr ("Use UPnP or NAT-PMP port &forwarding from my router"), Prefs::PORT_FORWARDING));
ColumnResizer * cr (new ColumnResizer (this));
cr->addLayout (ui.incomingPeersSectionLayout);
cr->addLayout (ui.peerLimitsSectionLayout);
cr->update ();
hig->addSectionDivider ();
hig->addSectionTitle (tr ("Peer Limits"));
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;
connect (ui.testPeerPortButton, SIGNAL (clicked ()), SLOT (onPortTest ()));
connect (&mySession, SIGNAL (portTested (bool)), SLOT (onPortTested (bool)));
}
/***
@@ -431,49 +387,33 @@ PrefsDialog::encryptionEdited (int i)
setPref (Prefs::ENCRYPTION, value);
}
QWidget *
PrefsDialog::createPrivacyTab ()
void
PrefsDialog::initPrivacyTab ()
{
QWidget * w;
HIG * hig = new HIG (this);
ui.encryptionModeCombo->addItem (tr ("Allow encryption"), 0);
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 ();
box->addItem (tr ("Allow encryption"), 0);
box->addItem (tr ("Prefer encryption"), 1);
box->addItem (tr ("Require encryption"), 2);
myWidgets.insert (Prefs::ENCRYPTION, box);
connect (box, SIGNAL(activated(int)), this, SLOT(encryptionEdited(int)));
myBlockWidgets <<
ui.blocklistEdit <<
ui.blocklistStatusLabel <<
ui.updateBlocklistButton <<
ui.autoUpdateBlocklistCheck;
hig->addRow (tr ("&Encryption mode:"), box);
ColumnResizer * cr (new ColumnResizer (this));
cr->addLayout (ui.encryptionSectionLayout);
cr->addLayout (ui.blocklistSectionLayout);
cr->update ();
hig->addSectionDivider ();
hig->addSectionTitle (tr ("Blocklist"));
connect (ui.encryptionModeCombo, SIGNAL (activated (int)), SLOT (encryptionEdited (int)));
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 ();
return hig;
}
/***
@@ -534,127 +474,76 @@ void
PrefsDialog::onIdleLimitChanged ()
{
//: 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 ());
if (myIdleLimitSpin->suffix () != unitsSuffix)
myIdleLimitSpin->setSuffix (unitsSuffix);
const QString unitsSuffix = tr (" minute(s)", 0, ui.idleLimitSpin->value ());
if (ui.idleLimitSpin->suffix () != unitsSuffix)
ui.idleLimitSpin->setSuffix (unitsSuffix);
}
QWidget *
PrefsDialog::createSeedingTab ()
void
PrefsDialog::initSeedingTab ()
{
const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize));
const QFileIconProvider iconProvider;
const QIcon folderIcon = iconProvider.icon (QFileIconProvider::Folder);
const QPixmap folderPixmap = folderIcon.pixmap (iconSize);
const QIcon fileIcon = iconProvider.icon (QFileIconProvider::File);
const QPixmap filePixmap = fileIcon.pixmap (iconSize);
linkWidgetToPref (ui.ratioLimitCheck, Prefs::RATIO_ENABLED);
linkWidgetToPref (ui.ratioLimitSpin, Prefs::RATIO);
linkWidgetToPref (ui.idleLimitCheck, Prefs::IDLE_LIMIT_ENABLED);
linkWidgetToPref (ui.idleLimitSpin, Prefs::IDLE_LIMIT);
QWidget *l, *r;
HIG * hig = new HIG (this);
hig->addSectionTitle (tr ("Limits"));
connect (ui.idleLimitSpin, SIGNAL (valueChanged (int)), SLOT (onIdleLimitChanged ()));
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 ();
hig->finish ();
return hig;
}
void
PrefsDialog::onQueueStalledMinutesChanged ()
{
//: 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 ());
if (myQueueStalledMinutesSpin->suffix () != unitsSuffix)
myQueueStalledMinutesSpin->setSuffix (unitsSuffix);
const QString unitsSuffix = tr (" minute(s) ago", 0, ui.queueStalledMinutesSpin->value ());
if (ui.queueStalledMinutesSpin->suffix () != unitsSuffix)
ui.queueStalledMinutesSpin->setSuffix (unitsSuffix);
}
QWidget *
PrefsDialog::createDownloadingTab ()
void
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 QIcon folderIcon = iconProvider.icon (QFileIconProvider::Folder);
const QPixmap folderPixmap = folderIcon.pixmap (iconSize);
const QIcon fileIcon = iconProvider.icon (QFileIconProvider::File);
const QPixmap filePixmap = fileIcon.pixmap (iconSize);
QWidget * l;
QPushButton * b;
HIG * hig = new HIG (this);
hig->addSectionTitle (tr ("Adding"));
ui.watchDirButton->setIcon (folderIcon);
ui.watchDirButton->setIconSize (iconSize);
ui.downloadDirButton->setIcon (folderIcon);
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);
b = myWatchButton = 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(onWatchClicked()));
hig->addRow (l, b);
enableBuddyWhenChecked (qobject_cast<QCheckBox*>(l), b);
ui.downloadDirFreeSpaceLabel->setSession (mySession);
ui.downloadDirFreeSpaceLabel->setPath (myPrefs.getString (Prefs::DOWNLOAD_DIR));
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 ();
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),
myIsServer (session.isServer ()),
mySession (session),
myPrefs (prefs),
myLayout (new QVBoxLayout (this))
myPrefs (prefs)
{
setWindowTitle (tr ("Transmission Preferences"));
ui.setupUi (this);
QTabWidget * t = new QTabWidget (this);
t->addTab (createSpeedTab (), tr ("Speed"));
t->addTab (createDownloadingTab (), tr ("Downloading"));
t->addTab (createSeedingTab (), tr ("Seeding"));
t->addTab (createPrivacyTab (), tr ("Privacy"));
t->addTab (createNetworkTab (), tr ("Network"));
t->addTab (createDesktopTab (), tr ("Desktop"));
t->addTab (createRemoteTab(session), tr ("Remote"));
myLayout->addWidget (t);
initSpeedTab ();
initDownloadingTab ();
initSeedingTab ();
initPrivacyTab ();
initNetworkTab ();
initDesktopTab ();
initRemoteTab ();
QDialogButtonBox * buttons = new QDialogButtonBox (QDialogButtonBox::Close, Qt::Horizontal, this);
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()));
connect (&mySession, SIGNAL (sessionUpdated ()), SLOT (sessionUpdated ()));
QList<int> keys;
keys << Prefs::RPC_ENABLED
@@ -711,6 +592,8 @@ PrefsDialog::PrefsDialog (Session& session, Prefs& prefs, QWidget * parent):
w->setEnabled (false);
}
}
adjustSize ();
}
PrefsDialog::~PrefsDialog ()
@@ -738,7 +621,7 @@ void
PrefsDialog::updateBlocklistLabel ()
{
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
@@ -753,61 +636,59 @@ PrefsDialog::refreshPref (int key)
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));
foreach (QWidget * w, myWebWhitelistWidgets)w->setEnabled (enabled && whitelist);
foreach (QWidget * w, myWebAuthWidgets)w->setEnabled (enabled && auth);
foreach (QWidget * w, myWebWidgets)w->setEnabled (enabled);
foreach (QWidget * w, myWebWhitelistWidgets)
w->setEnabled (enabled && whitelist);
foreach (QWidget * w, myWebAuthWidgets)
w->setEnabled (enabled && auth);
foreach (QWidget * w, myWebWidgets)
w->setEnabled (enabled);
break;
}
case Prefs::ALT_SPEED_LIMIT_TIME_ENABLED:
{
const bool enabled = myPrefs.getBool (key);
foreach (QWidget * w, mySchedWidgets)w->setEnabled (enabled);
foreach (QWidget * w, mySchedWidgets)
w->setEnabled (enabled);
break;
}
case Prefs::BLOCKLIST_ENABLED:
{
const bool enabled = myPrefs.getBool (key);
foreach (QWidget * w, myBlockWidgets)w->setEnabled (enabled);
foreach (QWidget * w, myBlockWidgets)
w->setEnabled (enabled);
break;
}
case Prefs::DIR_WATCH:
myWatchButton->setText (QFileInfo(myPrefs.getString(Prefs::DIR_WATCH)).fileName());
ui.watchDirButton->setText (QFileInfo (myPrefs.getString (Prefs::DIR_WATCH)).fileName ());
break;
case Prefs::SCRIPT_TORRENT_DONE_FILENAME:
{
const QString path (myPrefs.getString (key));
myTorrentDoneScriptButton->setText (QFileInfo(path).fileName());
ui.completionScriptButton->setText (QFileInfo (path).fileName ());
break;
}
case Prefs::PEER_PORT:
myPortLabel->setText (tr ("Status unknown"));
myPortButton->setEnabled (true);
ui.peerPortStatusLabel->setText (tr ("Status unknown"));
ui.testPeerPortButton->setEnabled (true);
break;
case Prefs::DOWNLOAD_DIR:
{
const QString path (myPrefs.getString (key));
myDestinationButton->setText (QFileInfo(path).fileName());
myFreespaceLabel->setPath (path);
ui.downloadDirButton->setText (QFileInfo (path).fileName ());
ui.downloadDirFreeSpaceLabel->setPath (path);
break;
}
case Prefs::INCOMPLETE_DIR:
{
QString path (myPrefs.getString (key));
myIncompleteButton->setText (QFileInfo(path).fileName());
break;
}
case Prefs::INCOMPLETE_DIR_ENABLED:
{
const bool enabled = myPrefs.getBool (key);
myIncompleteButton->setEnabled (enabled);
ui.incompleteDirButton->setText (QFileInfo (path).fileName ());
break;
}
@@ -819,34 +700,10 @@ PrefsDialog::refreshPref (int key)
if (it != myWidgets.end ())
{
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));
}
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)
if (key == Prefs::ENCRYPTION)
{
QComboBox * comboBox (qobject_cast<QComboBox*> (w));
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;
}

View File

@@ -11,8 +11,11 @@
#define PREFS_DIALOG_H
#include <QDialog>
#include <QMap>
#include <QSet>
#include "prefs.h"
#include "ui_prefs-dialog.h"
class QAbstractButton;
class QCheckBox;
@@ -62,12 +65,8 @@ class PrefsDialog: public QDialog
void onBlocklistUpdated (int n);
private:
QDoubleSpinBox * doubleSpinBoxNew (int key, double low, double high, double step, int decimals);
QCheckBox * checkBoxNew (const QString& text, int key);
QSpinBox * spinBoxNew (int key, int low, int high, int step);
QTimeEdit * timeEditNew (int key);
QLineEdit * lineEditNew (int key, int mode = 0);
void enableBuddyWhenChecked (QCheckBox *, QWidget *);
bool updateWidgetValue (QWidget * widget, int prefKey);
void linkWidgetToPref (QWidget * widget, int prefKey);
void updateBlocklistLabel ();
public:
@@ -76,14 +75,14 @@ class PrefsDialog: public QDialog
private:
void setPref (int key, const QVariant& v);
bool isAllowed (int key) const;
QWidget * createDownloadingTab ();
QWidget * createSeedingTab ();
QWidget * createSpeedTab ();
QWidget * createPrivacyTab ();
QWidget * createNetworkTab ();
QWidget * createDesktopTab ();
QWidget * createRemoteTab (Session&);
void initDownloadingTab ();
void initSeedingTab ();
void initSpeedTab ();
void initPrivacyTab ();
void initNetworkTab ();
void initDesktopTab ();
void initRemoteTab ();
private:
typedef QMap<int,QWidget*> key2widget_t;
@@ -91,15 +90,6 @@ class PrefsDialog: public QDialog
const bool myIsServer;
Session& mySession;
Prefs& myPrefs;
QVBoxLayout * myLayout;
QLabel * myPortLabel;
QPushButton * myPortButton;
QPushButton * myWatchButton;
QPushButton * myTorrentDoneScriptButton;
QCheckBox * myTorrentDoneScriptCheckbox;
QCheckBox * myIncompleteCheckbox;
QPushButton * myIncompleteButton;
QPushButton * myDestinationButton;
QWidgetList myWebWidgets;
QWidgetList myWebAuthWidgets;
QWidgetList myWebWhitelistWidgets;
@@ -108,14 +98,11 @@ class PrefsDialog: public QDialog
QWidgetList mySchedWidgets;
QWidgetList myBlockWidgets;
QWidgetList myUnsupportedWhenRemote;
FreespaceLabel * myFreespaceLabel;
QSpinBox * myIdleLimitSpin;
QSpinBox * myQueueStalledMinutesSpin;
Ui::PrefsDialog ui;
int myBlocklistHttpTag;
QHttp * myBlocklistHttp;
QMessageBox * myBlocklistDialog;
QLabel * myBlocklistLabel;
};
#endif

1361
qt/prefs-dialog.ui Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -55,6 +55,7 @@ FORMS += about.ui \
make-dialog.ui \
make-progress-dialog.ui \
options.ui \
prefs-dialog.ui \
relocate.ui \
session-dialog.ui \
stats-dialog.ui