From 4dc8959f67f02741273e67ce8f1f08327c7f4d93 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 30 Nov 2009 21:30:14 +0000 Subject: [PATCH] * More exit tweaking to make shutdown faster * Fixed active upload icon in Web UI * Fixed text alignment in Web UI preferences dialog * Fixes to ratio display in Web UI transfer list and properties panel * Edited Queued/Paused/Checking icons so that they are the same for complete/incomplete torrents (easier to understand) * Color torrents in UI transfer list as in qBittorrent < 2.0 (more easily understandable) * Progress and size are now updated when files are filtered in torrent properties --- Changelog | 2 +- src/GUI.cpp | 20 +++++++++++++------- src/Icons/skin/checkingDL.png | Bin 3411 -> 3352 bytes src/Icons/skin/checkingUP.png | Bin 3424 -> 3352 bytes src/Icons/skin/pausedDL.png | Bin 3020 -> 2970 bytes src/Icons/skin/pausedUP.png | Bin 2947 -> 2970 bytes src/Icons/skin/queuedDL.png | Bin 3371 -> 3014 bytes src/Icons/skin/queuedUP.png | Bin 3330 -> 3014 bytes src/Icons/skin/stalledDL.png | Bin 3182 -> 3188 bytes src/Icons/skin/stalledUP.png | Bin 3181 -> 3237 bytes src/bittorrent.cpp | 26 +++++++++++++++++++++----- src/bittorrent.h | 3 +++ src/eventmanager.cpp | 20 ++++++-------------- src/main.cpp | 4 +++- src/propertieswidget.cpp | 2 +- src/torrentfilesmodel.h | 28 ++++++++++++++++++++-------- src/transferlistwidget.cpp | 25 ++++++++++++++----------- src/transferlistwidget.h | 2 +- src/webui/preferences.html | 14 +++++++------- src/webui/scripts/dynamicTable.js | 6 +++--- 20 files changed, 93 insertions(+), 59 deletions(-) diff --git a/Changelog b/Changelog index 243dfd1c3..296dd2b8b 100644 --- a/Changelog +++ b/Changelog @@ -4,7 +4,7 @@ - FEATURE: Display more information regarding the torrent in its properties - FEATURE: Various optimizations to save CPU and memory - FEATURE: Folder scanning now works with CIFS and NFS mounted folders - - FEATURE: Speed up qBittorrent startup + - FEATURE: Speed up qBittorrent startup and shutdown - FEATURE: Display per-torrent peer list - FEATURE: Make sure torrent files are always sorted by name - FEATURE: Seeds and Peers columns are now sortable diff --git a/src/GUI.cpp b/src/GUI.cpp index a82b77905..47b6d29cf 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -196,17 +196,21 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis GUI::~GUI() { qDebug("GUI destruction"); hide(); + // Async deletion of Bittorrent session as early as possible + // in order to speed up exit + session_proxy sp = BTSession->asyncDeletion(); + // Delete other GUI objects delete status_bar; + delete transferList; + delete guiUpdater; + if(rssWidget) delete rssWidget; delete searchEngine; delete transferListFilters; delete properties; - delete transferList; delete hSplitter; delete vSplitter; - delete guiUpdater; - qDebug("1"); if(systrayCreator) { delete systrayCreator; } @@ -214,19 +218,21 @@ GUI::~GUI() { delete systrayIcon; delete myTrayIconMenu; } - qDebug("2"); localServer->close(); delete localServer; delete tabs; - qDebug("3"); // Keyboard shortcuts delete switchSearchShortcut; delete switchSearchShortcut2; delete switchTransferShortcut; delete switchRSSShortcut; - qDebug("4"); + // Delete BTSession objects delete BTSession; - qDebug("5"); + // May freeze for a few seconds after the next line + // because the Bittorrent session proxy will + // actually be deleted now and destruction + // becomes synchronous + qDebug("Exiting GUI destructor..."); } void GUI::displayRSSTab(bool enable) { diff --git a/src/Icons/skin/checkingDL.png b/src/Icons/skin/checkingDL.png index 3f1c6247b688004cfe8b8f8e6535a5f679877e16..0f40b448639547d3ed5ff1a7b5818ba5d44c1c40 100644 GIT binary patch delta 612 zcmV-q0-OEQ8kicezzTmuNkl1B{V! zKnTCQ-EK!+*8pT$#$Yf2Ac`WQC_)Iqd_MmLe1Ctl-EJ|)u-$)dIXOAu^Yas}H2`Uv zlIJ;H*P)a`2!T@Sn4oQ2>bj;V3Yw96MxxBnY2yp~B z=P1jPudgqzudj)s2(2|)mH}{ebw!${gb;Xsex@u-hQlEMJpf}2ZQD{+6ZyMj5#K#>zd_qi7|%FW%XImcqLpeTO|thG$1Q>2tgDVa{ESZgVY zg2i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a60|De66laV18e*gz`Nliru*$W;ACKTeh zw_v;fRxgyAjU|HQ3R;(H9!af@BK0Sx!nNx zz2D!~08P_8b}G06YCQL@b=$Tlz z41luMmQo7yJd1oV3Y7;GCoDIuXD* a2f!bKwW6dR03i(k0000 z06Lfe02gnPU&TfM008$%L_t(|+N9GlPQx%1#_@kdRjITSQYTor0XJabBpjnN;uxHR zfdvUMa|1+%E=UNWCT;xuYzEiF4(VWcl85g_{^{w-scxQ*J^!c)z}5MRjeq$ly11C0 z@bG#YfY05UukO7Fux{5+AlhQIDFQ_2Jz%t@vzwof*B6ff+`U|mW&kr;q(GAav4*`g z$B6@A+j79R`3^eUi~!BSESdpZWG`lm8uZdEy6pk0f~XnUv^kiqN)I^aQT_cOhrKjA z=Tjh@SgZSac5#^F9jZOxT{<`=uCT00L)25K~y-)rII<0gfI|ApCuz8aK=Hn&GgZHgr3`Q5JCj_v;fRxgyAjU|HQ3R;(H9!af@BK0Sx!nNx zz2D!~08P_8b}G06YCQL@b=$Tlz z41luMmQo7yJd1oV3Y7;GCoDIuXD* a2f!bKwW6dR03i(k0000 z06Lfe02gnPU&TfM006E@L_t(|+N_d63c@fDMPIClfx56O&*MqFPH*8!JdaCJX+nre z7fm27r7*PvVfY#H<}(=;TOxnN9)PQcuaUj1H9SlLybQdBt-UE6xO61pm~a4WQM{$G z+||4WI4%Kl*abauU{?U_rVh3M{EAxrv+C0NM{(#g<5b&r`Mr zrwgzv90V`jMBtDCVFe(RGicx}1vEgH0Ub~a0o{=L0RT04Nk^hZU}yjU002ovPDHLk FV1h@)U_k%? diff --git a/src/Icons/skin/queuedDL.png b/src/Icons/skin/queuedDL.png index 94ed8268d00e88996e8894a15ae422d7e6abd132..963f7125bf223f12a399ccb8b79159846dcf74e7 100644 GIT binary patch delta 330 zcmV-Q0k!_C8paop83+Ub006c6H|nuAUJ45WVoOIv0RM-N%)gN#7k>Z;bV*G`2iXfA z2PX-brRu%_008_+L_t(2&wbIoN&`_8Md2?$1VOGu1VL;f2wG_^K8w%fJJ{KaZy**H ziMFDGkR~Ba7>$_8%)J)lR1!~n7HglwZe1t;PM1^PYnB@xby@fVxrGWHo3=nz8%iZI z(UENp3UY1o cwN>Z%0U8l$JsWd+k^lez07*qoM6N<$f+dxWpa1{> delta 709 zcmV;$0y_Q17poeO865@y001BJ|6u?C010qNS#tmY3ljhU3ljkVnw%K1Azli9AY({U zO#lFTB>(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fdMgRZ;R!KxbRCwB?lS@xi zK@@<$K4^iy5Q^o|R!TyMiEd09g19m+T)B1U%3tByxYR^{f*W11Fe+feQZWW?c$g5V z<#9_fr7dls_d@U7nQ?I|#U*inb~ERkFJI1_<9YhISMwjo4{$H@gr*HCH zqoV-qmr87GFVj5xPGH!;tqFAiwzO#37NUHO6c4z4_YQs02&&zk{(%91(qkExzKl>T zzNIU%hwZlj@VWpK>o7*Jk!5OnhHx~31ad2@T0T<#cu2ziRITi8+~G-w|*PE4AXMd_f(%NNg?`|u8{C2_O|VYd+S zv}52%f$7h)Q^=D@4pXny*)0@!_~8&0?7rg7>kV$+xKDa~5&&a+ll7kqn01;{_m?!{+3+v+rQs=k9 ro>2^8xBx>eLEv&6Yix);0R9XBjVCAqe#MTq00000NkvXXu0mjf*EBwS diff --git a/src/Icons/skin/queuedUP.png b/src/Icons/skin/queuedUP.png index 272cb57093782041d7eef6613a4fc986dd390d9b..8786a62683fcadbf1b89bb229bfa272ecbf28af4 100644 GIT binary patch delta 330 zcmV-Q0k!^u8paop83+Ub006c6H|nuAUJ45WVoOIv0RM-N%)gN#7k>Z;bV*G`2iXfA z2PYF{#}mW=008_+L_t(2&wbIoN&`_8Md2?$1VOGu1VL;f2wG_^K8w%fJJ{KaZy**H ziMFDGkR~Ba7>$_8%)J)lR1!~n7HglwZe1t;PM1^PYnB@xby@fVxrGWHo3=nz8%iZI z(UENp3UY1o cwN>Z%0U8l$JsWd+k^lez07*qoM6N<$f&@T}p8x;= delta 667 zcmV;M0%ZNh7lIm)865@y001BJ|6u?C010qNS#tmY3ljhU3ljkVnw%K1Azli9AY({U zO#lFTB>(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fdMgRZ;ElET{RCwB?lh02R zK@@<$Ws#QBZmcATU<=idT8Nq;u@Y)bym{up&69tHcMl%a#Q(wr2ZJe+7;k9sz^^ED zA+4qSNT9_M=x)pI&Wwj`3BeP8agxa-llQ)S@68)cy+-jLs~v!+olvV^E;HN-U+Yc4 zQ5}x`dx_50={<^KoT`=tAgW9T_3sP>R%t`{fnNQbfz#Z;dgBqr&=j$eC*1Gv2ViG+ zm$lp-?BfrN1m`)+IS&vGopmQoDfW_yiN{WWrOQNdA~|w zA;^%_M8IJo3D>;deSfenN&39$X+?*OFq`)n#NWxoIb002ovPDHLkV1h7R BE;#@I diff --git a/src/Icons/skin/stalledDL.png b/src/Icons/skin/stalledDL.png index ef2438eb8d29a73dd111d2135e6a44af39610746..60fd87bdd2e06c3135308247ea1c5716cefb39b6 100644 GIT binary patch delta 496 zcmVm1QG}d#8h5mV`2VRYqt(gD1OPtrA zajmBnKq@1W@9z;}S9c(UAkT9E@;oP7zNLM4i+KL&e^~w4A^LfT5PJg@Lew3Up_D=v zn%kRqXs!A6;E-hxW^fm0a6Ta4_v!U|X8+m14&Rt#7SjMuH_`c6@ zIK*|`8elLOkYyRu>6F!Kg;K|7x+(!mDK?u8K@hOrZfk%zjv0@~gkfm(6@bA$Qo0MGL(AEk`NVgW$A-L9Q^ mo<|(V#}?u^{^xI8*8Bm1C?G1Dr~lRf0000 z06Lfe02gnPU&TfM00EgvL_t(|+N6_9%Hlv2g+CuDgNg_l_`;1ib|ix9a|uy!=8p?; z=qv^l0#Or5C6z}HB(ba0lcvwC>Yn=Q-a}PmyWJN2huQ$E)e0$Pwb^Ji5Pw3@ZnptY zN}-gZD86@@rpeFG&j%2OA@BFQDheU!cDvQuFbskq&@M^S^xHw2ro?fqwN@HRB}t-r zI-SlJkR%CGN`w%M$75QpRt+#54jBvv-0yd!l$fUZ1;lZTloBZ=Q4}$qP7y+A0HqYJ z>!OsRJfi`kC;}jgBEm3aK7XIn>-DNV$8of-%8axTN;R8Jk|bd^n*reaK2a2rWto~y+7K>^3mml%e@>2#_+EbTK{mZbqoozG_gMx#-!W?2@#?|%T7 i%jKWH@$>lv;MV{qp$n|!7ddMH0000C3qXK}zV1ShJpDxyF zHAbV+E#T(ne}*(oD+VD1?RFc_^O((M7-K5B)_U84)|$;`<3!*0IXXI`*=zz3h9T4G z6s45&L{S8Q2axAEQc4%&`1sge252-IoSd8>gmAt*&$ochW`mTHFbwH-yEGb&oy_%m zonEg;9LGp0UB^KQ$g+$q%Q!tfrPXTD@AoT!$z;M}f3a};IF7e~GD2B@zDHR~sfwqJ z-~d^cIdMLpGairWbUFZ>ot<%cc}Y={C)?j=Luy800000NkvXX1g=70g77&3O8@`> delta 491 zcmV z06Lfe02gnPU&TfM00EduL_t(|+N6^`uc|;0h96X-;1Ub%ZA>I$W$f+!hyD=lEiA2# z(L@`K9cm;jEFZTx*;URtxyj9)isgOh*%@ZA7K=s6e?$XdKA$6{{HMfLtAE96wfX|Q zUN533su(QGqTlaRtJOH4&lE*b(X%XjSCC~HNs<_`Ua#Z(KAlbn0Nb|N?RF@ojHlUb z0#E};(-bMCX(I>%lMEn)U_2gUS(fpoY5E2vNrIFT+qRiZCI}&Z^z1ke)9Dn~b&*n< ziW?db$1!mnvs^Ce^?J-^vwsR;v)ORF-OSl_-8VqDpyTs<=uk>kJh}w~h~wCZm&=9q zdd*-k0N`*qa5|mH^Za*!QtHPPvMl3zy#i2{B}%Ev6!dcqpePFRJSWd{8jS|N?<0hu zC<=kzg&o-i0yWZ=XnG{ zPyy`sd%`d@=L$f#@hNJs5W>t}=Y(PS1vnm$Kgjp{ h{jY!Habort(); delete s; + qDebug("Bittorrent session async deletion OUT"); + return sp; +} + +// Main destructor +Bittorrent::~Bittorrent() { + qDebug("BTSession destructor IN"); + if(!exiting) { + // Do some BT related saving + saveDHTEntry(); + saveSessionState(); + saveFastResumeData(); + // Delete session + session_proxy sp = s->abort(); + delete s; + } // Disable directory scanning disableDirectoryScanning(); // Delete our objects @@ -129,7 +145,7 @@ Bittorrent::~Bittorrent() { delete httpServer; if(timerETA) delete timerETA; - qDebug("Deleting session..."); + qDebug("BTSession destructor OUT"); } void Bittorrent::preAllocateAllFiles(bool b) { diff --git a/src/bittorrent.h b/src/bittorrent.h index b672d9182..e2d8116d1 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -120,6 +120,8 @@ private: // Web UI QPointer httpServer; QStringList url_skippingDlg; + // Fast exit (async) + bool exiting; protected: QString getSavePath(QString hash); @@ -163,6 +165,7 @@ public slots: void downloadFromUrl(QString url); void deleteTorrent(QString hash, bool delete_local_files = false); void startUpTorrents(); + session_proxy asyncDeletion(); /* Needed by Web UI */ void pauseAllTorrents(); void pauseTorrent(QString hash); diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index 84f3b9b89..e58a314cf 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -161,19 +161,11 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const { data["time_elapsed"] = elapsed_txt; data["nb_connections"] = QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")"; // Update ratio info - float ratio; - if(h.total_payload_download() == 0){ - if(h.total_payload_upload() == 0) - ratio = 1.; + double ratio = BTSession->getRealRatio(h.hash()); + if(ratio > 100.) + data["share_ratio"] = QString::fromUtf8("∞"); else - ratio = 10.; // Max ratio - }else{ - ratio = (double)h.total_payload_upload()/(double)h.total_payload_download(); - if(ratio > 10.){ - ratio = 10.; - } - } - data["share_ratio"] = QString(QByteArray::number(ratio, 'f', 1)); + data["share_ratio"] = QString(QByteArray::number(ratio, 'f', 1)); } return data; } @@ -210,7 +202,7 @@ void EventManager::modifiedTorrent(QTorrentHandle h) case torrent_status::finished: case torrent_status::seeding: if(h.upload_payload_rate() > 0) { - event["state"] = QVariant("seeding"); + event["state"] = QVariant("uploading"); } else { event["state"] = QVariant("stalledUP"); } @@ -263,7 +255,7 @@ void EventManager::modifiedTorrent(QTorrentHandle h) event["seed"] = QVariant(h.is_seed()); double ratio = BTSession->getRealRatio(hash); if(ratio > 100.) - QString::fromUtf8("∞"); + event["ratio"] = QString::fromUtf8("∞"); else event["ratio"] = QVariant(QString::number(ratio, 'f', 1)); event["hash"] = QVariant(hash); diff --git a/src/main.cpp b/src/main.cpp index 78d3a9770..248cd1bfc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -211,8 +211,10 @@ int main(int argc, char *argv[]){ } int ret = app->exec(); delete window; - qDebug("app children: %d", app->children().size()); + qDebug("GUI was deleted!"); + qDebug("Deleting app..."); delete app; + qDebug("App was deleted! All good."); return ret; } diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 4680f1cd8..b724bcafb 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -356,8 +356,8 @@ void PropertiesWidget::loadDynamicData() { // Files progress std::vector fp; h.file_progress(fp); - PropListModel->updateFilesProgress(fp); PropListModel->updateFilesPriorities(h.file_priorities()); + PropListModel->updateFilesProgress(fp); } } catch(invalid_handle e) {} } diff --git a/src/torrentfilesmodel.h b/src/torrentfilesmodel.h index 93ca68e27..89bb2ec89 100644 --- a/src/torrentfilesmodel.h +++ b/src/torrentfilesmodel.h @@ -133,13 +133,13 @@ public: Q_ASSERT(type == FOLDER); qulonglong size = 0; foreach(TreeItem* child, childItems) { - size += child->getSize(); + if(child->getPriority() > 0) + size += child->getSize(); } setSize(size); } void setProgress(qulonglong done) { - if(done == total_done) return; total_done = done; qulonglong size = getSize(); Q_ASSERT(total_done <= size); @@ -149,6 +149,7 @@ public: else progress = 1.; Q_ASSERT(progress >= 0. && progress <= 1.); + //qDebug("setProgress(%s): %f", getName().toLocal8Bit().data(), progress); itemData.replace(2, progress); if(parentItem) parentItem->updateProgress(); @@ -169,9 +170,12 @@ public: if(type == ROOT) return; Q_ASSERT(type == FOLDER); total_done = 0; + //qDebug("Folder %s is updating its progress", getName().toLocal8Bit().data()); foreach(TreeItem* child, childItems) { - total_done += child->getTotalDone(); + if(child->getPriority() > 0) + total_done += child->getTotalDone(); } + //qDebug("Folder: total_done: %llu/%llu", total_done, getSize()); Q_ASSERT(total_done <= getSize()); setProgress(total_done); } @@ -180,16 +184,24 @@ public: return itemData.value(3).toInt(); } - void setPriority(int priority) { - if(getPriority() != priority) { - itemData.replace(3, priority); + void setPriority(int new_prio) { + int old_prio = getPriority(); + if(old_prio != new_prio) { + itemData.replace(3, new_prio); // Update parent - if(parentItem) + if(parentItem) { + if(new_prio == 0 || old_prio == 0) { + // Files got filtered or unfiltered + // Update parent size and progress + parentItem->updateSize(); + parentItem->updateProgress(); + } parentItem->updatePriority(); + } } // Update children foreach(TreeItem* child, childItems) { - child->setPriority(priority); + child->setPriority(new_prio); } } diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 760c3962d..f407423d2 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -163,7 +163,7 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) { listModel->setData(listModel->index(row, TR_STATUS), STATE_PAUSED_DL); listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/pausedDL.png"))), Qt::DecorationRole); } - //setRowColor(row, QString::fromUtf8("red")); + setRowColor(row, QString::fromUtf8("red")); }else{ if(h.is_seed()) { listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/stalledUP.png"))), Qt::DecorationRole); @@ -172,7 +172,7 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) { listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/stalledDL.png"))), Qt::DecorationRole); listModel->setData(listModel->index(row, TR_STATUS), STATE_STALLED_DL); } - //setRowColor(row, QString::fromUtf8("grey")); + setRowColor(row, QApplication::palette().color(QPalette::WindowText)); } // Select first torrent to be added if(listModel->rowCount() == 1) @@ -184,12 +184,12 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) { } } -/*void TransferListWidget::setRowColor(int row, QColor color) { +void TransferListWidget::setRowColor(int row, QColor color) { unsigned int nbColumns = listModel->columnCount()-1; for(unsigned int i=0; isetData(listModel->index(row, i), QVariant(color), Qt::ForegroundRole); } -}*/ +} void TransferListWidget::deleteTorrent(int row, bool refresh_list) { listModel->removeRow(row); @@ -216,7 +216,7 @@ void TransferListWidget::pauseTorrent(int row, bool refresh_list) { } listModel->setData(listModel->index(row, TR_SEEDS), QVariant(0.0)); listModel->setData(listModel->index(row, TR_PEERS), QVariant(0.0)); - //setRowColor(row, QString::fromUtf8("red")); + setRowColor(row, QString::fromUtf8("red")); if(refresh_list) refreshList(); } @@ -236,6 +236,7 @@ void TransferListWidget::resumeTorrent(int row, bool refresh_list) { listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(":/Icons/skin/stalledDL.png")), Qt::DecorationRole); listModel->setData(listModel->index(row, TR_STATUS), STATE_STALLED_DL); } + setRowColor(row, QApplication::palette().color(QPalette::WindowText)); if(refresh_list) refreshList(); } @@ -312,7 +313,7 @@ int TransferListWidget::updateTorrent(int row) { listModel->setData(listModel->index(row, TR_UPSPEED), QVariant((double)0.)); listModel->setData(listModel->index(row, TR_SEEDS), QVariant(0.0)); listModel->setData(listModel->index(row, TR_PEERS), QVariant(0.0)); - //setRowColor(row, QString::fromUtf8("grey")); + setRowColor(row, QString::fromUtf8("grey")); return s; } } @@ -340,7 +341,7 @@ int TransferListWidget::updateTorrent(int row) { } listModel->setData(listModel->index(row, TR_PROGRESS), QVariant((double)h.progress())); listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1)); - //setRowColor(row, QString::fromUtf8("grey")); + setRowColor(row, QString::fromUtf8("grey")); break; case torrent_status::downloading: case torrent_status::downloading_metadata: @@ -348,12 +349,12 @@ int TransferListWidget::updateTorrent(int row) { listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png"))), Qt::DecorationRole); listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)BTSession->getETA(hash))); s = STATE_DOWNLOADING; - //setRowColor(row, QString::fromUtf8("green")); + setRowColor(row, QString::fromUtf8("green")); }else{ listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/stalledDL.png"))), Qt::DecorationRole); listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1)); s = STATE_STALLED_DL; - //setRowColor(row, QApplication::palette().color(QPalette::WindowText)); + setRowColor(row, QApplication::palette().color(QPalette::WindowText)); } listModel->setData(listModel->index(row, TR_DLSPEED), QVariant((double)h.download_payload_rate())); listModel->setData(listModel->index(row, TR_PROGRESS), QVariant((double)h.progress())); @@ -363,9 +364,11 @@ int TransferListWidget::updateTorrent(int row) { if(h.upload_payload_rate() > 0) { s = STATE_SEEDING; listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/uploading.png"))), Qt::DecorationRole); + setRowColor(row, "orange"); } else { s = STATE_STALLED_UP; listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/stalledUP.png"))), Qt::DecorationRole); + setRowColor(row, QApplication::palette().color(QPalette::WindowText)); } } // Common to both downloads and uploads @@ -389,11 +392,11 @@ void TransferListWidget::setFinished(QTorrentHandle &h) { if(h.is_paused()) { listModel->setData(listModel->index(row, TR_NAME), QIcon(":/Icons/skin/pausedUP.png"), Qt::DecorationRole); listModel->setData(listModel->index(row, TR_STATUS), STATE_PAUSED_UP); - //setRowColor(row, "red"); + setRowColor(row, "red"); }else{ listModel->setData(listModel->index(row, TR_NAME), QVariant(QIcon(":/Icons/skin/stalledUP.png")), Qt::DecorationRole); listModel->setData(listModel->index(row, TR_STATUS), STATE_STALLED_UP); - //setRowColor(row, "orange"); + setRowColor(row, QApplication::palette().color(QPalette::WindowText)); } listModel->setData(listModel->index(row, TR_ETA), QVariant((qlonglong)-1)); listModel->setData(listModel->index(row, TR_DLSPEED), QVariant((double)0.)); diff --git a/src/transferlistwidget.h b/src/transferlistwidget.h index c876d9b51..d40f685f8 100644 --- a/src/transferlistwidget.h +++ b/src/transferlistwidget.h @@ -84,7 +84,7 @@ protected slots: #endif void toggleSelectedTorrentsSequentialDownload(); void toggleSelectedFirstLastPiecePrio(); - //void setRowColor(int row, QColor color); + void setRowColor(int row, QColor color); public slots: void refreshList(); diff --git a/src/webui/preferences.html b/src/webui/preferences.html index c9acd6749..6140f0e8c 100644 --- a/src/webui/preferences.html +++ b/src/webui/preferences.html @@ -14,10 +14,10 @@
- + - +
_(Upload:)  _(KiB/s)_(Upload:)  _(KiB/s)
_(Download:)  _(KiB/s)_(Download:)  _(KiB/s)
@@ -28,13 +28,13 @@
- + - + - +
_(Global maximum number of connections:)_(Global maximum number of connections:)
_(Maximum number of connections per torrent:)_(Maximum number of connections per torrent:)
_(Maximum number of upload slots per torrent:)_(Maximum number of upload slots per torrent:)
@@ -45,7 +45,7 @@
- +
_(Enable DHT network (decentralized))_(Enable DHT network (decentralized))
@@ -226,4 +226,4 @@ loadPreferences = function() { loadPreferences(); - \ No newline at end of file + diff --git a/src/webui/scripts/dynamicTable.js b/src/webui/scripts/dynamicTable.js index 97c905dd8..747f3ca10 100644 --- a/src/webui/scripts/dynamicTable.js +++ b/src/webui/scripts/dynamicTable.js @@ -194,21 +194,21 @@ var dynamicTable = new Class ({ } break; case 'completed': - if(status == "seeding" || status == "stalledUP" || status == "checkingUP" || status == "pausedUP" || status == "queuedUP") { + if(status == "uploading" || status == "stalledUP" || status == "checkingUP" || status == "pausedUP" || status == "queuedUP") { tr.removeClass("invisible"); } else { tr.addClass("invisible"); } break; case 'active': - if(status == "downloading" || status == "seeding") { + if(status == "downloading" || status == "uploading") { tr.removeClass("invisible"); } else { tr.addClass("invisible"); } break; case 'inactive': - if(status != "downloading" && status != "seeding") { + if(status != "downloading" && status != "uploading") { tr.removeClass("invisible"); } else { tr.addClass("invisible");