Rework torrent details dialog in Qt client to load from .ui

Make squeeze labels (used for values on Information tab) display tooltip
on hover if their text doesn't fit. Make selective labels (same as in
GTK+ client) text selectable with keyboard in addition to mouse.
Prevent dialog width growth occured before to fit long error texts.
This commit is contained in:
Mike Gelfand
2014-12-14 18:12:21 +00:00
parent 6c02008280
commit 70c6087e94
7 changed files with 1098 additions and 412 deletions

View File

@@ -101,6 +101,7 @@ set(${PROJECT_NAME}_HEADERS
)
tr_qt_wrap_ui(${PROJECT_NAME}_UI_SOURCES
details.ui
mainwin.ui
)

View File

@@ -11,17 +11,11 @@
#include <climits> /* INT_MAX */
#include <ctime>
#include <QCheckBox>
#include <QComboBox>
#include <QDateTime>
#include <QDesktopServices>
#include <QDialogButtonBox>
#include <QDoubleSpinBox>
#include <QEvent>
#include <QFont>
#include <QFontMetrics>
#include <QHBoxLayout>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QHostAddress>
#include <QInputDialog>
@@ -30,18 +24,10 @@
#include <QList>
#include <QMap>
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
#include <QResizeEvent>
#include <QSpinBox>
#include <QStringList>
#include <QStyle>
#include <QTabWidget>
#include <QTextBrowser>
#include <QTreeView>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QVBoxLayout>
#include <libtransmission/transmission.h>
#include <libtransmission/utils.h> // tr_getRatio ()
@@ -58,6 +44,7 @@
#include "tracker-delegate.h"
#include "tracker-model.h"
#include "tracker-model-filter.h"
#include "utils.h"
class Prefs;
class Session;
@@ -83,6 +70,16 @@ namespace
COL_CLIENT,
N_COLUMNS
};
int
measureViewItem (QAbstractItemView * view, const QString& text)
{
QStyleOptionViewItemV4 option;
option.features = QStyleOptionViewItemV2::HasDisplay;
option.text = text;
return view->style ()->sizeFromContents (QStyle::CT_ItemViewItem, &option,
QSize (QWIDGETSIZE_MAX, QWIDGETSIZE_MAX), view).width ();
}
}
/***
@@ -184,28 +181,18 @@ Details::Details (Session & session,
myChangedTorrents (false),
myHavePendingRefresh (false)
{
QVBoxLayout * layout = new QVBoxLayout (this);
ui.setupUi(this);
setWindowTitle (tr ("Torrent Properties"));
initInfoTab ();
initPeersTab ();
initTrackerTab ();
initFilesTab ();
initOptionsTab ();
QTabWidget * t = new QTabWidget (this);
QWidget * w;
t->addTab (w = createInfoTab (), tr ("Information"));
myWidgets << w;
t->addTab (w = createPeersTab (), tr ("Peers"));
myWidgets << w;
t->addTab (w = createTrackerTab (), tr ("Tracker"));
myWidgets << w;
t->addTab (w = createFilesTab (), tr ("Files"));
myWidgets << w;
t->addTab (w = createOptionsTab (), tr ("Options"));
myWidgets << w;
layout->addWidget (t);
adjustSize ();
ui.commentBrowser->setMaximumHeight (QWIDGETSIZE_MAX);
QDialogButtonBox * buttons = new QDialogButtonBox (QDialogButtonBox::Close, Qt::Horizontal, this);
connect (buttons, SIGNAL (rejected ()), this, SLOT (close ()));
layout->addWidget (buttons);
QWidget::setAttribute (Qt::WA_DeleteOnClose, true);
setAttribute (Qt::WA_DeleteOnClose, true);
QList<int> initKeys;
initKeys << Prefs::SHOW_TRACKER_SCRAPES
@@ -244,7 +231,7 @@ Details::setIds (const QSet<int>& ids)
disconnect (tor, SIGNAL (torrentChanged (int)), this, SLOT (onTorrentChanged ()));
}
myFileTreeView->clear ();
ui.filesView->clear ();
myIds = ids;
myTrackerModel->refresh (myModel, myIds);
@@ -256,8 +243,8 @@ Details::setIds (const QSet<int>& ids)
connect (tor, SIGNAL (torrentChanged (int)), this, SLOT (onTorrentChanged ()));
}
foreach (QWidget * w, myWidgets)
w->setEnabled (false);
for (int i = 0; i < ui.tabs->count (); ++i)
ui.tabs->widget (i)->setEnabled (false);
onTimer ();
}
@@ -271,12 +258,12 @@ Details::refreshPref (int key)
{
case Prefs::SHOW_TRACKER_SCRAPES:
{
QItemSelectionModel * selectionModel (myTrackerView->selectionModel ());
QItemSelectionModel * selectionModel (ui.trackersView->selectionModel ());
const QItemSelection selection (selectionModel->selection ());
const QModelIndex currentIndex (selectionModel->currentIndex ());
myTrackerDelegate->setShowMore (myPrefs.getBool (key));
selectionModel->clear ();
myTrackerView->reset ();
ui.trackersView->reset ();
selectionModel->select (selection, QItemSelectionModel::Select);
selectionModel->setCurrentIndex (currentIndex, QItemSelectionModel::NoUpdate);
break;
@@ -429,7 +416,7 @@ Details::refresh ()
else
string = torrents[0]->activityString ();
}
myStateLabel->setText (string);
ui.stateValueLabel->setText (string);
const QString stateString = string;
// myHaveLabel
@@ -487,7 +474,7 @@ Details::refresh ()
.arg (Formatter::sizeToString (haveUnverified));
}
}
myHaveLabel->setText (string);
ui.haveValueLabel->setText (string);
// myAvailabilityLabel
if (torrents.empty ())
@@ -496,7 +483,7 @@ Details::refresh ()
string = none;
else
string = QString ("%1%").arg (Formatter::percentToString ( (100.0 * available) / sizeWhenDone));
myAvailabilityLabel->setText (string);
ui.availabilityValueLabel->setText (string);
// myDownloadedLabel
if (torrents.empty ())
@@ -519,7 +506,7 @@ Details::refresh ()
else
string = dstr;
}
myDownloadedLabel->setText (string);
ui.downloadedValueLabel->setText (string);
// myUploadedLabel
if (torrents.empty ())
@@ -539,7 +526,7 @@ Details::refresh ()
.arg (Formatter::sizeToString (u))
.arg (Formatter::ratioToString (tr_getRatio (u, d)));
}
myUploadedLabel->setText (string);
ui.uploadedValueLabel->setText (string);
const QDateTime qdt_now = QDateTime::currentDateTime ();
@@ -567,7 +554,7 @@ Details::refresh ()
else
string = Formatter::timeToString (baseline.secsTo (qdt_now));
}
myRunTimeLabel->setText (string);
ui.runningTimeValueLabel->setText (string);
// myETALabel
@@ -596,7 +583,7 @@ Details::refresh ()
string = Formatter::timeToString (baseline);
}
}
myETALabel->setText (string);
ui.remainingTimeValueLabel->setText (string);
// myLastActivityLabel
@@ -622,7 +609,7 @@ Details::refresh ()
else
string = tr ("%1 ago").arg (Formatter::timeToString (seconds));
}
myLastActivityLabel->setText (string);
ui.lastActivityValueLabel->setText (string);
if (torrents.empty ())
@@ -643,7 +630,7 @@ Details::refresh ()
}
if (string.isEmpty ())
string = none;
myErrorLabel->setText (string);
ui.errorValueLabel->setText (string);
///
@@ -678,7 +665,7 @@ Details::refresh ()
string = tr ("%1 (%Ln pieces)", "", pieces)
.arg (Formatter::sizeToString (size));
}
mySizeLabel->setText (string);
ui.sizeValueLabel->setText (string);
// myHashLabel
string = none;
@@ -694,7 +681,7 @@ Details::refresh ()
}
}
}
myHashLabel->setText (string);
ui.hashValueLabel->setText (string);
// myPrivacyLabel
string = none;
@@ -712,10 +699,11 @@ Details::refresh ()
}
}
}
myPrivacyLabel->setText (string);
ui.privacyValueLabel->setText (string);
// myCommentBrowser
string = none;
bool isCommentMixed = false;
if (!torrents.empty ())
{
string = torrents[0]->comment ();
@@ -724,15 +712,16 @@ Details::refresh ()
if (string != t->comment ())
{
string = mixed;
isCommentMixed = true;
break;
}
}
}
if (myCommentBrowser->toPlainText() != string)
if (ui.commentBrowser->toPlainText() != string)
{
myCommentBrowser->setText (string);
myCommentBrowser->setMaximumHeight (QWIDGETSIZE_MAX);
ui.commentBrowser->setText (string);
}
ui.commentBrowser->setEnabled (!isCommentMixed && !string.isEmpty ());
// myOriginLabel
string = none;
@@ -758,7 +747,7 @@ Details::refresh ()
else
string = tr ("Created by %1 on %2").arg (creator).arg (date);
}
myOriginLabel->setText (string);
ui.originValueLabel->setText (string);
// myLocationLabel
string = none;
@@ -774,7 +763,7 @@ Details::refresh ()
}
}
}
myLocationLabel->setText (string);
ui.locationValueLabel->setText (string);
///
@@ -794,33 +783,33 @@ Details::refresh ()
uniform = true;
baselineFlag = baseline->honorsSessionLimits ();
foreach (tor, torrents) if (baselineFlag != tor->honorsSessionLimits ()) { uniform = false; break; }
mySessionLimitCheck->setChecked (uniform && baselineFlag);
ui.sessionLimitCheck->setChecked (uniform && baselineFlag);
// mySingleDownCheck
uniform = true;
baselineFlag = baseline->downloadIsLimited ();
foreach (tor, torrents) if (baselineFlag != tor->downloadIsLimited ()) { uniform = false; break; }
mySingleDownCheck->setChecked (uniform && baselineFlag);
ui.singleDownCheck->setChecked (uniform && baselineFlag);
// mySingleUpCheck
uniform = true;
baselineFlag = baseline->uploadIsLimited ();
foreach (tor, torrents) if (baselineFlag != tor->uploadIsLimited ()) { uniform = false; break; }
mySingleUpCheck->setChecked (uniform && baselineFlag);
ui.singleUpCheck->setChecked (uniform && baselineFlag);
// myBandwidthPriorityCombo
uniform = true;
baselineInt = baseline->getBandwidthPriority ();
foreach (tor, torrents) if (baselineInt != tor->getBandwidthPriority ()) { uniform = false; break; }
if (uniform)
i = myBandwidthPriorityCombo->findData (baselineInt);
i = ui.bandwidthPriorityCombo->findData (baselineInt);
else
i = -1;
setIfIdle (myBandwidthPriorityCombo, i);
setIfIdle (ui.bandwidthPriorityCombo, i);
setIfIdle (mySingleDownSpin, int (tor->downloadLimit ().KBps ()));
setIfIdle (mySingleUpSpin, int (tor->uploadLimit ().KBps ()));
setIfIdle (myPeerLimitSpin, tor->peerLimit ());
setIfIdle (ui.singleDownSpin, int (tor->downloadLimit ().KBps ()));
setIfIdle (ui.singleUpSpin, int (tor->uploadLimit ().KBps ()));
setIfIdle (ui.peerLimitSpin, tor->peerLimit ());
}
if (!torrents.empty ())
@@ -832,20 +821,20 @@ Details::refresh ()
int baselineInt = torrents[0]->seedRatioMode ();
foreach (tor, torrents) if (baselineInt != tor->seedRatioMode ()) { uniform = false; break; }
setIfIdle (myRatioCombo, uniform ? myRatioCombo->findData (baselineInt) : -1);
myRatioSpin->setVisible (uniform && (baselineInt == TR_RATIOLIMIT_SINGLE));
setIfIdle (ui.ratioCombo, uniform ? ui.ratioCombo->findData (baselineInt) : -1);
ui.ratioSpin->setVisible (uniform && (baselineInt == TR_RATIOLIMIT_SINGLE));
setIfIdle (myRatioSpin, tor->seedRatioLimit ());
setIfIdle (ui.ratioSpin, tor->seedRatioLimit ());
// idle
uniform = true;
baselineInt = torrents[0]->seedIdleMode ();
foreach (tor, torrents) if (baselineInt != tor->seedIdleMode ()) { uniform = false; break; }
setIfIdle (myIdleCombo, uniform ? myIdleCombo->findData (baselineInt) : -1);
myIdleSpin->setVisible (uniform && (baselineInt == TR_RATIOLIMIT_SINGLE));
setIfIdle (ui.idleCombo, uniform ? ui.idleCombo->findData (baselineInt) : -1);
ui.idleSpin->setVisible (uniform && (baselineInt == TR_RATIOLIMIT_SINGLE));
setIfIdle (myIdleSpin, tor->seedIdleLimit ());
setIfIdle (ui.idleSpin, tor->seedIdleLimit ());
}
///
@@ -926,73 +915,38 @@ Details::refresh ()
}
}
myPeerTree->addTopLevelItems (newItems);
ui.peersView->addTopLevelItems (newItems);
foreach (QString key, myPeers.keys ())
{
if (!peers2.contains (key)) // old peer has disconnected
{
QTreeWidgetItem * item = myPeers.value (key, 0);
myPeerTree->takeTopLevelItem (myPeerTree->indexOfTopLevelItem (item));
ui.peersView->takeTopLevelItem (ui.peersView->indexOfTopLevelItem (item));
delete item;
}
}
myPeers = peers2;
if (!single)
myFileTreeView->clear ();
ui.filesView->clear ();
if (single)
myFileTreeView->update (torrents[0]->files (), myChangedTorrents);
ui.filesView->update (torrents[0]->files (), myChangedTorrents);
myChangedTorrents = false;
myHavePendingRefresh = false;
foreach (QWidget * w, myWidgets)
w->setEnabled (true);
for (int i = 0; i < ui.tabs->count (); ++i)
ui.tabs->widget (i)->setEnabled (true);
}
void
Details::enableWhenChecked (QCheckBox * box, QWidget * w)
{
connect (box, SIGNAL (toggled (bool)), w, SLOT (setEnabled (bool)));
w->setEnabled (box->isChecked ());
}
/***
****
***/
QWidget *
Details::createInfoTab ()
void
Details::initInfoTab ()
{
HIG * hig = new HIG (this);
hig->addSectionTitle (tr ("Activity"));
hig->addRow (tr ("Have:"), myHaveLabel = new SqueezeLabel);
hig->addRow (tr ("Availability:"), myAvailabilityLabel = new SqueezeLabel);
hig->addRow (tr ("Uploaded:"), myUploadedLabel = new SqueezeLabel);
hig->addRow (tr ("Downloaded:"), myDownloadedLabel = new SqueezeLabel);
hig->addRow (tr ("State:"), myStateLabel = new SqueezeLabel);
hig->addRow (tr ("Running time:"), myRunTimeLabel = new SqueezeLabel);
hig->addRow (tr ("Remaining time:"), myETALabel = new SqueezeLabel);
hig->addRow (tr ("Last activity:"), myLastActivityLabel = new SqueezeLabel);
hig->addRow (tr ("Error:"), myErrorLabel = new SqueezeLabel);
hig->addSectionDivider ();
hig->addSectionDivider ();
hig->addSectionTitle (tr ("Details"));
hig->addRow (tr ("Size:"), mySizeLabel = new SqueezeLabel);
hig->addRow (tr ("Location:"), myLocationLabel = new SqueezeLabel);
hig->addRow (tr ("Hash:"), myHashLabel = new SqueezeLabel);
hig->addRow (tr ("Privacy:"), myPrivacyLabel = new SqueezeLabel);
hig->addRow (tr ("Origin:"), myOriginLabel = new SqueezeLabel);
myOriginLabel->setMinimumWidth (325); // stop long origin strings from resizing the widgit
hig->addRow (tr ("Comment:"), myCommentBrowser = new QTextBrowser);
const int h = QFontMetrics (myCommentBrowser->font ()).lineSpacing () * 4;
myCommentBrowser->setFixedHeight (h);
hig->finish ();
return hig;
const int h = QFontMetrics (ui.commentBrowser->font ()).lineSpacing () * 4;
ui.commentBrowser->setFixedHeight (h);
}
/***
@@ -1046,7 +1000,7 @@ Details::onUploadLimitedToggled (bool val)
void
Details::onIdleModeChanged (int index)
{
const int val = myIdleCombo->itemData (index).toInt ();
const int val = ui.idleCombo->itemData (index).toInt ();
mySession.torrentSet (myIds, TR_KEY_seedIdleMode, val);
getNewData ();
}
@@ -1054,7 +1008,7 @@ Details::onIdleModeChanged (int index)
void
Details::onRatioModeChanged (int index)
{
const int val = myRatioCombo->itemData (index).toInt ();
const int val = ui.ratioCombo->itemData (index).toInt ();
mySession.torrentSet (myIds, TR_KEY_seedRatioMode, val);
}
@@ -1063,7 +1017,7 @@ Details::onBandwidthPriorityChanged (int index)
{
if (index != -1)
{
const int priority = myBandwidthPriorityCombo->itemData (index).toInt ();
const int priority = ui.bandwidthPriorityCombo->itemData (index).toInt ();
mySession.torrentSet (myIds, TR_KEY_bandwidthPriority, priority);
getNewData ();
}
@@ -1072,9 +1026,9 @@ Details::onBandwidthPriorityChanged (int index)
void
Details::onTrackerSelectionChanged ()
{
const int selectionCount = myTrackerView->selectionModel ()->selectedRows ().size ();
myEditTrackerButton->setEnabled (selectionCount == 1);
myRemoveTrackerButton->setEnabled (selectionCount > 0);
const int selectionCount = ui.trackersView->selectionModel ()->selectedRows ().size ();
ui.editTrackerButton->setEnabled (selectionCount == 1);
ui.removeTrackerButton->setEnabled (selectionCount > 0);
}
void
@@ -1118,11 +1072,11 @@ Details::onAddTrackerClicked ()
void
Details::onEditTrackerClicked ()
{
QItemSelectionModel * selectionModel = myTrackerView->selectionModel ();
QItemSelectionModel * selectionModel = ui.trackersView->selectionModel ();
QModelIndexList selectedRows = selectionModel->selectedRows ();
assert (selectedRows.size () == 1);
QModelIndex i = selectionModel->currentIndex ();
const TrackerInfo trackerInfo = myTrackerView->model ()->data (i, TrackerModel::TrackerRole).value<TrackerInfo> ();
const TrackerInfo trackerInfo = ui.trackersView->model ()->data (i, TrackerModel::TrackerRole).value<TrackerInfo> ();
bool ok = false;
const QString newval = QInputDialog::getText (this,
@@ -1155,12 +1109,12 @@ void
Details::onRemoveTrackerClicked ()
{
// make a map of torrentIds to announce URLs to remove
QItemSelectionModel * selectionModel = myTrackerView->selectionModel ();
QItemSelectionModel * selectionModel = ui.trackersView->selectionModel ();
QModelIndexList selectedRows = selectionModel->selectedRows ();
QMap<int,int> torrentId_to_trackerIds;
foreach (QModelIndex i, selectedRows)
{
const TrackerInfo inf = myTrackerView->model ()->data (i, TrackerModel::TrackerRole).value<TrackerInfo> ();
const TrackerInfo inf = ui.trackersView->model ()->data (i, TrackerModel::TrackerRole).value<TrackerInfo> ();
torrentId_to_trackerIds.insertMulti (inf.torrentId, inf.st.id);
}
@@ -1176,253 +1130,110 @@ Details::onRemoveTrackerClicked ()
getNewData ();
}
QWidget *
Details::createOptionsTab ()
void
Details::initOptionsTab ()
{
QSpinBox * s;
QCheckBox * c;
QComboBox * m;
QHBoxLayout * h;
QDoubleSpinBox * ds;
const QString speed_K_str = Formatter::unitStr (Formatter::SPEED, Formatter::KB);
HIG * hig = new HIG (this);
hig->addSectionTitle (tr ("Speed"));
ui.singleDownCheck->setText (ui.singleDownCheck->text ().arg(speed_K_str));
ui.singleUpCheck->setText (ui.singleUpCheck->text ().arg(speed_K_str));
c = new QCheckBox (tr ("Honor global &limits"));
mySessionLimitCheck = c;
hig->addWideControl (c);
connect (c, SIGNAL (clicked (bool)), this, SLOT (onHonorsSessionLimitsToggled (bool)));
ui.singleDownSpin->setProperty (PREF_KEY, TR_KEY_downloadLimit);
ui.singleUpSpin->setProperty (PREF_KEY, TR_KEY_uploadLimit);
ui.ratioSpin->setProperty (PREF_KEY, TR_KEY_seedRatioLimit);
ui.idleSpin->setProperty (PREF_KEY, TR_KEY_seedIdleLimit);
ui.peerLimitSpin->setProperty (PREF_KEY, TR_KEY_peer_limit);
c = new QCheckBox (tr ("Limit &download speed (%1):").arg (speed_K_str));
mySingleDownCheck = c;
s = new QSpinBox ();
s->setProperty (PREF_KEY, TR_KEY_downloadLimit);
s->setSingleStep (5);
s->setRange (0, INT_MAX);
mySingleDownSpin = s;
hig->addRow (c, s);
enableWhenChecked (c, s);
connect (c, SIGNAL (clicked (bool)), this, SLOT (onDownloadLimitedToggled (bool)));
connect (s, SIGNAL (editingFinished ()), this, SLOT (onSpinBoxEditingFinished ()));
ui.bandwidthPriorityCombo->addItem (tr ("High"), TR_PRI_HIGH);
ui.bandwidthPriorityCombo->addItem (tr ("Normal"), TR_PRI_NORMAL);
ui.bandwidthPriorityCombo->addItem (tr ("Low"), TR_PRI_LOW);
c = new QCheckBox (tr ("Limit &upload speed (%1):").arg (speed_K_str));
mySingleUpCheck = c;
s = new QSpinBox ();
s->setSingleStep (5);
s->setRange (0, INT_MAX);
s->setProperty (PREF_KEY, TR_KEY_uploadLimit);
mySingleUpSpin = s;
hig->addRow (c, s);
enableWhenChecked (c, s);
connect (c, SIGNAL (clicked (bool)), this, SLOT (onUploadLimitedToggled (bool)));
connect (s, SIGNAL (editingFinished ()), this, SLOT (onSpinBoxEditingFinished ()));
ui.ratioCombo->addItem (tr ("Use Global Settings"), TR_RATIOLIMIT_GLOBAL);
ui.ratioCombo->addItem (tr ("Seed regardless of ratio"), TR_RATIOLIMIT_UNLIMITED);
ui.ratioCombo->addItem (tr ("Stop seeding at ratio:"), TR_RATIOLIMIT_SINGLE);
m = new QComboBox;
m->addItem (tr ("High"), TR_PRI_HIGH);
m->addItem (tr ("Normal"), TR_PRI_NORMAL);
m->addItem (tr ("Low"), TR_PRI_LOW);
connect (m, SIGNAL (currentIndexChanged (int)), this, SLOT (onBandwidthPriorityChanged (int)));
hig->addRow (tr ("Torrent &priority:"), m);
myBandwidthPriorityCombo = m;
ui.idleCombo->addItem (tr ("Use Global Settings"), TR_IDLELIMIT_GLOBAL);
ui.idleCombo->addItem (tr ("Seed regardless of activity"), TR_IDLELIMIT_UNLIMITED);
ui.idleCombo->addItem (tr ("Stop seeding if idle for N minutes:"), TR_IDLELIMIT_SINGLE);
hig->addSectionDivider ();
hig->addSectionTitle (tr ("Seeding Limits"));
h = new QHBoxLayout ();
h->setSpacing (HIG::PAD);
m = new QComboBox;
m->addItem (tr ("Use Global Settings"), TR_RATIOLIMIT_GLOBAL);
m->addItem (tr ("Seed regardless of ratio"), TR_RATIOLIMIT_UNLIMITED);
m->addItem (tr ("Stop seeding at ratio:"), TR_RATIOLIMIT_SINGLE);
connect (m, SIGNAL (currentIndexChanged (int)), this, SLOT (onRatioModeChanged (int)));
h->addWidget (myRatioCombo = m);
ds = new QDoubleSpinBox ();
ds->setRange (0.5, INT_MAX);
ds->setProperty (PREF_KEY, TR_KEY_seedRatioLimit);
connect (ds, SIGNAL (editingFinished ()), this, SLOT (onSpinBoxEditingFinished ()));
h->addWidget (myRatioSpin = ds);
hig->addRow (tr ("&Ratio:"), h, m);
h = new QHBoxLayout ();
h->setSpacing (HIG::PAD);
m = new QComboBox;
m->addItem (tr ("Use Global Settings"), TR_IDLELIMIT_GLOBAL);
m->addItem (tr ("Seed regardless of activity"), TR_IDLELIMIT_UNLIMITED);
m->addItem (tr ("Stop seeding if idle for N minutes:"), TR_IDLELIMIT_SINGLE);
connect (m, SIGNAL (currentIndexChanged (int)), this, SLOT (onIdleModeChanged (int)));
h->addWidget (myIdleCombo = m);
s = new QSpinBox ();
s->setSingleStep (5);
s->setRange (1, 9999);
s->setProperty (PREF_KEY, TR_KEY_seedIdleLimit);
connect (s, SIGNAL (editingFinished ()), this, SLOT (onSpinBoxEditingFinished ()));
h->addWidget (myIdleSpin = s);
hig->addRow (tr ("&Idle:"), h, m);
hig->addSectionDivider ();
hig->addSectionTitle (tr ("Peer Connections"));
s = new QSpinBox ();
s->setSingleStep (5);
s->setRange (1, 300);
s->setProperty (PREF_KEY, TR_KEY_peer_limit);
connect (s, SIGNAL (editingFinished ()), this, SLOT (onSpinBoxEditingFinished ()));
myPeerLimitSpin = s;
hig->addRow (tr ("&Maximum peers:"), s);
hig->finish ();
return hig;
connect (ui.sessionLimitCheck, SIGNAL (clicked (bool)), SLOT (onHonorsSessionLimitsToggled (bool)));
connect (ui.singleDownCheck, SIGNAL (clicked (bool)), SLOT (onDownloadLimitedToggled (bool)));
connect (ui.singleDownSpin, SIGNAL (editingFinished ()), SLOT (onSpinBoxEditingFinished ()));
connect (ui.singleUpCheck, SIGNAL (clicked (bool)), SLOT (onUploadLimitedToggled (bool)));
connect (ui.singleUpSpin, SIGNAL (editingFinished ()), SLOT (onSpinBoxEditingFinished ()));
connect (ui.bandwidthPriorityCombo, SIGNAL (currentIndexChanged (int)), SLOT (onBandwidthPriorityChanged (int)));
connect (ui.ratioCombo, SIGNAL (currentIndexChanged (int)), SLOT (onRatioModeChanged (int)));
connect (ui.ratioSpin, SIGNAL (editingFinished ()), SLOT (onSpinBoxEditingFinished ()));
connect (ui.idleCombo, SIGNAL (currentIndexChanged (int)), SLOT (onIdleModeChanged (int)));
connect (ui.idleSpin, SIGNAL (editingFinished ()), SLOT (onSpinBoxEditingFinished ()));
connect (ui.peerLimitSpin, SIGNAL (editingFinished ()), SLOT (onSpinBoxEditingFinished ()));
}
/***
****
***/
QWidget *
Details::createTrackerTab ()
void
Details::initTrackerTab ()
{
QCheckBox * c;
QPushButton * p;
QWidget * top = new QWidget;
QVBoxLayout * v = new QVBoxLayout (top);
QHBoxLayout * h = new QHBoxLayout ();
QVBoxLayout * v2 = new QVBoxLayout ();
v->setSpacing (HIG::PAD_BIG);
v->setContentsMargins (HIG::PAD_BIG, HIG::PAD_BIG, HIG::PAD_BIG, HIG::PAD_BIG);
h->setSpacing (HIG::PAD);
h->setContentsMargins (HIG::PAD_SMALL, HIG::PAD_SMALL, HIG::PAD_SMALL, HIG::PAD_SMALL);
v2->setSpacing (HIG::PAD);
myTrackerModel = new TrackerModel;
myTrackerFilter = new TrackerModelFilter;
myTrackerModel = new TrackerModel ();
myTrackerFilter = new TrackerModelFilter ();
myTrackerFilter->setSourceModel (myTrackerModel);
myTrackerView = new QTreeView;
myTrackerView->setModel (myTrackerFilter);
myTrackerView->setHeaderHidden (true);
myTrackerView->setSelectionMode (QTreeWidget::ExtendedSelection);
myTrackerView->setRootIsDecorated (false);
myTrackerView->setIndentation (2);
myTrackerView->setItemsExpandable (false);
myTrackerView->setAlternatingRowColors (true);
myTrackerView->setItemDelegate (myTrackerDelegate = new TrackerDelegate ());
connect (myTrackerView->selectionModel (), SIGNAL (selectionChanged (QItemSelection, QItemSelection)), this, SLOT (onTrackerSelectionChanged ()));
h->addWidget (myTrackerView, 1);
myTrackerDelegate = new TrackerDelegate ();
p = new QPushButton ();
p->setIcon (getStockIcon ("list-add", QStyle::SP_DialogOpenButton));
p->setToolTip (tr ("Add Tracker"));
myAddTrackerButton = p;
v2->addWidget (p, 1);
connect (p, SIGNAL (clicked (bool)), this, SLOT (onAddTrackerClicked ()));
ui.trackersView->setModel (myTrackerFilter);
ui.trackersView->setItemDelegate (myTrackerDelegate);
p = new QPushButton ();
p->setIcon (getStockIcon ("document-properties", QStyle::SP_DesktopIcon));
p->setToolTip (tr ("Edit Tracker"));
myAddTrackerButton = p;
p->setEnabled (false);
myEditTrackerButton = p;
v2->addWidget (p, 1);
connect (p, SIGNAL (clicked (bool)), this, SLOT (onEditTrackerClicked ()));
ui.addTrackerButton->setIcon (getStockIcon ("list-add", QStyle::SP_DialogOpenButton));
ui.editTrackerButton->setIcon (getStockIcon ("document-properties", QStyle::SP_DesktopIcon));
ui.removeTrackerButton->setIcon (getStockIcon ("list-remove", QStyle::SP_TrashIcon));
p = new QPushButton ();
p->setIcon (getStockIcon ("list-remove", QStyle::SP_TrashIcon));
p->setToolTip (tr ("Remove Trackers"));
p->setEnabled (false);
myRemoveTrackerButton = p;
v2->addWidget (p, 1);
connect (p, SIGNAL (clicked (bool)), this, SLOT (onRemoveTrackerClicked ()));
ui.showTrackerScrapesCheck->setChecked (myPrefs.getBool (Prefs::SHOW_TRACKER_SCRAPES));
ui.showBackupTrackersCheck->setChecked (myPrefs.getBool (Prefs::SHOW_BACKUP_TRACKERS));
v2->addStretch (1);
connect (ui.trackersView->selectionModel (), SIGNAL (selectionChanged (QItemSelection, QItemSelection)),
SLOT (onTrackerSelectionChanged ()));
connect (ui.addTrackerButton, SIGNAL (clicked ()), SLOT (onAddTrackerClicked ()));
connect (ui.editTrackerButton, SIGNAL (clicked ()), SLOT (onEditTrackerClicked ()));
connect (ui.removeTrackerButton, SIGNAL (clicked ()), SLOT (onRemoveTrackerClicked ()));
connect (ui.showTrackerScrapesCheck, SIGNAL (clicked (bool)), SLOT (onShowTrackerScrapesToggled (bool)));
connect (ui.showBackupTrackersCheck, SIGNAL (clicked (bool)), SLOT (onShowBackupTrackersToggled (bool)));
h->addLayout (v2, 1);
h->setStretch (1, 0);
v->addLayout (h, 1);
c = new QCheckBox (tr ("Show &more details"));
c->setChecked (myPrefs.getBool (Prefs::SHOW_TRACKER_SCRAPES));
myShowTrackerScrapesCheck = c;
v->addWidget (c, 1);
connect (c, SIGNAL (clicked (bool)), this, SLOT (onShowTrackerScrapesToggled (bool)));
c = new QCheckBox (tr ("Show &backup trackers"));
c->setChecked (myPrefs.getBool (Prefs::SHOW_BACKUP_TRACKERS));
myShowBackupTrackersCheck = c;
v->addWidget (c, 1);
connect (c, SIGNAL (clicked (bool)), this, SLOT (onShowBackupTrackersToggled (bool)));
return top;
onTrackerSelectionChanged ();
}
/***
****
***/
QWidget *
Details::createPeersTab ()
void
Details::initPeersTab ()
{
QWidget * top = new QWidget;
QVBoxLayout * v = new QVBoxLayout (top);
v->setSpacing (HIG::PAD_BIG);
v->setContentsMargins (HIG::PAD_BIG, HIG::PAD_BIG, HIG::PAD_BIG, HIG::PAD_BIG);
QStringList headers;
headers << QString () << tr ("Up") << tr ("Down") << tr ("%") << tr ("Status") << tr ("Address") << tr ("Client");
myPeerTree = new QTreeWidget;
myPeerTree->setUniformRowHeights (true);
myPeerTree->setHeaderLabels (headers);
myPeerTree->setColumnWidth (0, 20);
myPeerTree->setSortingEnabled (true);
myPeerTree->sortByColumn (COL_ADDRESS, Qt::AscendingOrder);
myPeerTree->setRootIsDecorated (false);
myPeerTree->setTextElideMode (Qt::ElideRight);
v->addWidget (myPeerTree, 1);
const QFontMetrics m (font ());
QSize size = m.size (0, "1024 MiB/s");
myPeerTree->setColumnWidth (COL_UP, size.width ());
myPeerTree->setColumnWidth (COL_DOWN, size.width ());
size = m.size (0, " 100% ");
myPeerTree->setColumnWidth (COL_PERCENT, size.width ());
size = m.size (0, "ODUK?EXI");
myPeerTree->setColumnWidth (COL_STATUS, size.width ());
size = m.size (0, "888.888.888.888");
myPeerTree->setColumnWidth (COL_ADDRESS, size.width ());
size = m.size (0, "Some BitTorrent Client");
myPeerTree->setColumnWidth (COL_CLIENT, size.width ());
myPeerTree->setAlternatingRowColors (true);
ui.peersView->setHeaderLabels (headers);
ui.peersView->sortByColumn (COL_ADDRESS, Qt::AscendingOrder);
return top;
ui.peersView->setColumnWidth (COL_LOCK, 20);
ui.peersView->setColumnWidth (COL_UP, measureViewItem (ui.peersView, "1024 MiB/s"));
ui.peersView->setColumnWidth (COL_DOWN, measureViewItem (ui.peersView, "1024 MiB/s"));
ui.peersView->setColumnWidth (COL_PERCENT, measureViewItem (ui.peersView, "100%"));
ui.peersView->setColumnWidth (COL_STATUS, measureViewItem (ui.peersView, "ODUK?EXI"));
ui.peersView->setColumnWidth (COL_ADDRESS, measureViewItem (ui.peersView, "888.888.888.888"));
}
/***
****
***/
QWidget *
Details::createFilesTab ()
void
Details::initFilesTab ()
{
myFileTreeView = new FileTreeView ();
connect (myFileTreeView, SIGNAL ( priorityChanged (QSet<int>, int)),
this, SLOT ( onFilePriorityChanged (QSet<int>, int)));
connect (myFileTreeView, SIGNAL ( wantedChanged (QSet<int>, bool)),
this, SLOT ( onFileWantedChanged (QSet<int>, bool)));
connect (myFileTreeView, SIGNAL (pathEdited (QString, QString)),
this, SLOT (onPathEdited (QString, QString)));
connect (myFileTreeView, SIGNAL (openRequested (QString)),
this, SLOT (onOpenRequested (QString)));
return myFileTreeView;
connect (ui.filesView, SIGNAL (priorityChanged (QSet<int>, int)), SLOT (onFilePriorityChanged (QSet<int>, int)));
connect (ui.filesView, SIGNAL (wantedChanged (QSet<int>, bool)), SLOT (onFileWantedChanged (QSet<int>, bool)));
connect (ui.filesView, SIGNAL (pathEdited (QString, QString)), SLOT (onPathEdited (QString, QString)));
connect (ui.filesView, SIGNAL (openRequested (QString)), SLOT (onOpenRequested (QString)));
}
void

View File

@@ -15,20 +15,11 @@
#include <QMap>
#include <QSet>
#include <QTimer>
#include <QWidgetList>
#include "prefs.h"
class FileTreeView;
class QTreeView;
class QComboBox;
class QCheckBox;
class QDoubleSpinBox;
class QLabel;
class QRadioButton;
class QSpinBox;
class QTextBrowser;
class QTreeWidget;
#include "ui_details.h"
class QTreeWidgetItem;
class Session;
class Torrent;
@@ -55,17 +46,16 @@ class Details: public QDialog
virtual QSize sizeHint () const { return QSize (440, 460); }
private:
QWidget * createPeersTab ();
QWidget * createTrackerTab ();
QWidget * createInfoTab ();
QWidget * createFilesTab ();
QWidget * createOptionsTab ();
void initPeersTab ();
void initTrackerTab ();
void initInfoTab ();
void initFilesTab ();
void initOptionsTab ();
private:
QIcon getStockIcon (const QString& freedesktop_name, int fallback);
QString timeToStringRounded (int seconds);
QString trimToDesiredWidth (const QString& str);
void enableWhenChecked (QCheckBox *, QWidget *);
private:
Session& mySession;
@@ -76,63 +66,14 @@ class Details: public QDialog
bool myChangedTorrents;
bool myHavePendingRefresh;
QLabel * myStateLabel;
QLabel * myHaveLabel;
QLabel * myAvailabilityLabel;
QLabel * myDownloadedLabel;
QLabel * myUploadedLabel;
QLabel * myErrorLabel;
QLabel * myRunTimeLabel;
QLabel * myETALabel;
QLabel * myLastActivityLabel;
QCheckBox * mySessionLimitCheck;
QCheckBox * mySingleDownCheck;
QCheckBox * mySingleUpCheck;
QCheckBox * myShowTrackerScrapesCheck;
QCheckBox * myShowBackupTrackersCheck;
QPushButton * myAddTrackerButton;
QPushButton * myEditTrackerButton;
QPushButton * myRemoveTrackerButton;
QSpinBox * mySingleDownSpin;
QSpinBox * mySingleUpSpin;
QComboBox * myRatioCombo;
QDoubleSpinBox * myRatioSpin;
QComboBox * myIdleCombo;
QSpinBox * myIdleSpin;
QSpinBox * myPeerLimitSpin;
QComboBox * myBandwidthPriorityCombo;
QLabel * mySizeLabel;
QLabel * myHashLabel;
QLabel * myPrivacyLabel;
QLabel * myOriginLabel;
QLabel * myLocationLabel;
QTextBrowser * myCommentBrowser;
QLabel * myTrackerLabel;
QLabel * myScrapeTimePrevLabel;
QLabel * myScrapeTimeNextLabel;
QLabel * myScrapeResponseLabel;
QLabel * myAnnounceTimePrevLabel;
QLabel * myAnnounceTimeNextLabel;
QLabel * myAnnounceResponseLabel;
QLabel * myAnnounceManualLabel;
Ui::DetailsDialog ui;
TrackerModel * myTrackerModel;
TrackerModelFilter * myTrackerFilter;
TrackerDelegate * myTrackerDelegate;
QTreeView * myTrackerView;
//QMap<QString,QTreeWidgetItem*> myTrackerTiers;
//QMap<QString,QTreeWidgetItem*> myTrackerItems;
QTreeWidget * myPeerTree;
QMap<QString,QTreeWidgetItem*> myPeers;
QWidgetList myWidgets;
FileTreeView * myFileTreeView;
private slots:
void refreshPref (int key);
void onBandwidthPriorityChanged (int);

936
qt/details.ui Normal file
View File

@@ -0,0 +1,936 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DetailsDialog</class>
<widget class="QDialog" name="DetailsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>505</width>
<height>579</height>
</rect>
</property>
<property name="windowTitle">
<string>Torrent Properties</string>
</property>
<property name="styleSheet">
<string notr="true">[tr-style~=&quot;form-section&quot;]
{
font-weight: bold;
margin-top: 12px;
margin-bottom: 1px;
}
[tr-style~=&quot;form-section&quot;][tr-style~=&quot;first&quot;]
{
margin-top: 0;
}
[tr-style~=&quot;form-label&quot;]
{
margin-left: 18px;
}</string>
</property>
<layout class="QVBoxLayout" name="dialogLayout">
<item>
<widget class="QTabWidget" name="tabs">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="infoTab">
<attribute name="title">
<string>Information</string>
</attribute>
<layout class="QGridLayout" name="infoTabLayout" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1" columnstretch="0,1">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="activitySectionLabel">
<property name="text">
<string>Activity</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-section first</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="haveLabel">
<property name="text">
<string>Have:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SqueezeLabel" name="haveValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="availabilityLabel">
<property name="text">
<string>Availability:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SqueezeLabel" name="availabilityValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="uploadedLabel">
<property name="text">
<string>Uploaded:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="SqueezeLabel" name="uploadedValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="downloadedLabel">
<property name="text">
<string>Downloaded:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="SqueezeLabel" name="downloadedValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="stateLabel">
<property name="text">
<string>State:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="SqueezeLabel" name="stateValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="runningTimeLabel">
<property name="text">
<string>Running time:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="SqueezeLabel" name="runningTimeValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="remainingTimeLabel">
<property name="text">
<string>Remaining time:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="SqueezeLabel" name="remainingTimeValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="lastActivityLabel">
<property name="text">
<string>Last activity:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="SqueezeLabel" name="lastActivityValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="errorLabel">
<property name="text">
<string>Error:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="SqueezeLabel" name="errorValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="QLabel" name="detailsSectionLabel">
<property name="text">
<string>Details</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-section</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="sizeLabel">
<property name="text">
<string>Size:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="SqueezeLabel" name="sizeValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="locationLabel">
<property name="text">
<string>Location:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="SqueezeLabel" name="locationValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="hashLabel">
<property name="text">
<string>Hash:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="SqueezeLabel" name="hashValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="privacyLabel">
<property name="text">
<string>Privacy:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="SqueezeLabel" name="privacyValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="originLabel">
<property name="text">
<string>Origin:</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="SqueezeLabel" name="originValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="commentLabel">
<property name="text">
<string>Comment:</string>
</property>
<property name="buddy">
<cstring>commentBrowser</cstring>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QTextBrowser" name="commentBrowser">
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="peersTab">
<attribute name="title">
<string>Peers</string>
</attribute>
<layout class="QVBoxLayout" name="peersTabLayout">
<item>
<widget class="QTreeWidget" name="peersView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>0</number>
</property>
<attribute name="headerShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="trackersTab">
<attribute name="title">
<string>Tracker</string>
</attribute>
<layout class="QGridLayout" name="trackersTabLayout">
<item row="0" column="0" rowspan="4">
<widget class="QListView" name="trackersView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="addTrackerButton">
<property name="toolTip">
<string>Add Tracker</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="editTrackerButton">
<property name="toolTip">
<string>Edit Tracker</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QToolButton" name="removeTrackerButton">
<property name="toolTip">
<string>Remove Trackers</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="trackerButtonsSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="showTrackerScrapesCheck">
<property name="text">
<string>Show &amp;more details</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="showBackupTrackersCheck">
<property name="text">
<string>Show &amp;backup trackers</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="filesTab">
<attribute name="title">
<string>Files</string>
</attribute>
<layout class="QVBoxLayout" name="filesTabLayout">
<item>
<widget class="FileTreeView" name="filesView"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="optionsTab">
<attribute name="title">
<string>Options</string>
</attribute>
<layout class="QGridLayout" name="optionsTabLayout" columnstretch="0,1">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="speedSectionLabel">
<property name="text">
<string>Speed</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-section first</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="sessionLimitCheck">
<property name="text">
<string>Honor global &amp;limits</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="singleDownCheck">
<property name="text">
<string>Limit &amp;download speed (%1):</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="singleDownSpin">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="singleUpCheck">
<property name="text">
<string>Limit &amp;upload speed (%1):</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="singleUpSpin">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="bandwidthPriorityLabel">
<property name="text">
<string>Torrent &amp;priority:</string>
</property>
<property name="buddy">
<cstring>bandwidthPriorityCombo</cstring>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="bandwidthPriorityCombo"/>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="seedingLimitsSectionLabel">
<property name="text">
<string>Seeding Limits</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-section</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="ratioLabel">
<property name="text">
<string>&amp;Ratio:</string>
</property>
<property name="buddy">
<cstring>ratioCombo</cstring>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="ratioValueLayout">
<item>
<widget class="QComboBox" name="ratioCombo"/>
</item>
<item>
<widget class="QDoubleSpinBox" name="ratioSpin">
<property name="minimum">
<double>0.500000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<widget class="QLabel" name="idleLabel">
<property name="text">
<string>&amp;Idle:</string>
</property>
<property name="buddy">
<cstring>idleCombo</cstring>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="7" column="1">
<layout class="QHBoxLayout" name="idleValueLayout">
<item>
<widget class="QComboBox" name="idleCombo"/>
</item>
<item>
<widget class="QSpinBox" name="idleSpin">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="peerConnectionsSectionLabel">
<property name="text">
<string>Peer Connections</string>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-section</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="peerLimitLabel">
<property name="text">
<string>&amp;Maximum peers:</string>
</property>
<property name="buddy">
<cstring>peerLimitSpin</cstring>
</property>
<property name="tr-style" stdset="0">
<string notr="true">form-label</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QSpinBox" name="peerLimitSpin">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>300</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<spacer name="optionsTabBottomSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="dialogButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SqueezeLabel</class>
<extends>QLabel</extends>
<header>squeezelabel.h</header>
</customwidget>
<customwidget>
<class>FileTreeView</class>
<extends>QTreeView</extends>
<header>file-tree.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabs</tabstop>
<tabstop>errorValueLabel</tabstop>
<tabstop>locationValueLabel</tabstop>
<tabstop>hashValueLabel</tabstop>
<tabstop>originValueLabel</tabstop>
<tabstop>commentBrowser</tabstop>
<tabstop>peersView</tabstop>
<tabstop>trackersView</tabstop>
<tabstop>addTrackerButton</tabstop>
<tabstop>editTrackerButton</tabstop>
<tabstop>removeTrackerButton</tabstop>
<tabstop>showTrackerScrapesCheck</tabstop>
<tabstop>showBackupTrackersCheck</tabstop>
<tabstop>filesView</tabstop>
<tabstop>sessionLimitCheck</tabstop>
<tabstop>singleDownCheck</tabstop>
<tabstop>singleDownSpin</tabstop>
<tabstop>singleUpCheck</tabstop>
<tabstop>singleUpSpin</tabstop>
<tabstop>bandwidthPriorityCombo</tabstop>
<tabstop>ratioCombo</tabstop>
<tabstop>ratioSpin</tabstop>
<tabstop>idleCombo</tabstop>
<tabstop>idleSpin</tabstop>
<tabstop>peerLimitSpin</tabstop>
<tabstop>dialogButtons</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>dialogButtons</sender>
<signal>accepted()</signal>
<receiver>DetailsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>26</x>
<y>563</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>dialogButtons</sender>
<signal>rejected()</signal>
<receiver>DetailsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>26</x>
<y>563</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>singleDownCheck</sender>
<signal>toggled(bool)</signal>
<receiver>singleDownSpin</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>35</x>
<y>99</y>
</hint>
<hint type="destinationlabel">
<x>247</x>
<y>93</y>
</hint>
</hints>
</connection>
<connection>
<sender>singleUpCheck</sender>
<signal>toggled(bool)</signal>
<receiver>singleUpSpin</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>35</x>
<y>131</y>
</hint>
<hint type="destinationlabel">
<x>247</x>
<y>125</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -46,7 +46,8 @@ TRANSLATIONS += translations/transmission_en.ts \
translations/transmission_ru.ts \
translations/transmission_uk.ts
FORMS += mainwin.ui
FORMS += details.ui \
mainwin.ui
RESOURCES += application.qrc
SOURCES += about.cc \
add-data.cc \

View File

@@ -40,40 +40,33 @@
****************************************************************************/
#include <QPainter>
#include <QResizeEvent>
#include <QStyle>
#include <QStyleOption>
#include "squeezelabel.h"
void
SqueezeLabel::init ()
{
setTextInteractionFlags(Qt::TextSelectableByMouse);
}
SqueezeLabel::SqueezeLabel (const QString& text, QWidget * parent):
QLabel (text, parent)
{
init();
}
SqueezeLabel::SqueezeLabel (QWidget * parent):
QLabel (parent)
{
init();
}
void
SqueezeLabel::paintEvent (QPaintEvent * paintEvent)
{
Q_UNUSED (paintEvent);
if (hasFocus () && (textInteractionFlags () & (Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse)))
return QLabel::paintEvent (paintEvent);
QPainter painter (this);
QFontMetrics fm = fontMetrics ();
QStyleOption opt;
opt.initFrom (this);
const QString elidedText = fm.elidedText (text(), Qt::ElideMiddle, width());
const QString fullText = text ();
const QString elidedText = fm.elidedText (fullText, Qt::ElideRight, width());
style()->drawItemText (&painter,
contentsRect(),
alignment(),
@@ -81,4 +74,8 @@ SqueezeLabel::paintEvent (QPaintEvent * paintEvent)
isEnabled(),
elidedText,
foregroundRole());
#ifndef QT_NO_TOOLTIP
setToolTip (fullText != elidedText ? fullText : QString ());
#endif
}

View File

@@ -53,7 +53,6 @@ class SqueezeLabel : public QLabel
SqueezeLabel (const QString& text, QWidget *parent=0);
protected:
void init ();
void paintEvent (QPaintEvent* paintEvent);
};