diff --git a/src/GUI.cpp b/src/GUI.cpp index 4bdff89e2..8e60cbfc6 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -205,9 +205,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis checkConnect->start(5000); // Accept drag 'n drops setAcceptDrops(true); - if(!settings.value(QString::fromUtf8("Preferences/General/StartMinimized"), false).toBool()) { - show(); - } createKeyboardShortcuts(); connecStatusLblIcon = new QLabel(); connecStatusLblIcon->setFrameShape(QFrame::NoFrame); @@ -238,6 +235,9 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis QMainWindow::statusBar()->addPermanentWidget(upSpeedLbl); QMainWindow::statusBar()->addPermanentWidget(statusSep4); QMainWindow::statusBar()->addPermanentWidget(ratioLbl); + if(!settings.value(QString::fromUtf8("Preferences/General/StartMinimized"), false).toBool()) { + show(); + } qDebug("GUI Built"); } @@ -621,6 +621,12 @@ void GUI::on_actionAbout_triggered() { new about(this); } +void GUI::showEvent(QShowEvent *e) { + qDebug("** Show Event **"); + updateLists(true); + e->accept(); +} + // Called when we close the program void GUI::closeEvent(QCloseEvent *e) { @@ -1338,28 +1344,30 @@ void GUI::on_actionTorrent_Properties_triggered() { } } -void GUI::updateLists() { - // update global informations - dlSpeedLbl->setText(tr("DL: %1 KiB/s").arg(QString(QByteArray::number(BTSession->getPayloadDownloadRate()/1024., 'f', 1)))); - upSpeedLbl->setText(tr("UP: %1 KiB/s").arg(QString(QByteArray::number(BTSession->getPayloadUploadRate()/1024., 'f', 1)))); - std::vector torrents = BTSession->getTorrents(); - std::vector::iterator torrentIT; - for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { - QTorrentHandle h = QTorrentHandle(*torrentIT); - if(!h.is_valid()) continue; - if(h.is_seed()) { - // Update in finished list - finishedTorrentTab->updateTorrent(h); - } else { - // Delete from finished list, if it moved back - if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+h.hash()+".finished")) { - if(h.state() != torrent_status::checking_files && h.state() != torrent_status::queued_for_checking) { - finishedTorrentTab->deleteTorrent(h.hash()); - QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+h.hash()+".finished"); +void GUI::updateLists(bool force) { + if(isVisible() || force) { + // update global informations + dlSpeedLbl->setText(tr("DL: %1 KiB/s").arg(QString(QByteArray::number(BTSession->getPayloadDownloadRate()/1024., 'f', 1)))); + upSpeedLbl->setText(tr("UP: %1 KiB/s").arg(QString(QByteArray::number(BTSession->getPayloadUploadRate()/1024., 'f', 1)))); + std::vector torrents = BTSession->getTorrents(); + std::vector::iterator torrentIT; + for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + QTorrentHandle h = QTorrentHandle(*torrentIT); + if(!h.is_valid()) continue; + if(h.is_seed()) { + // Update in finished list + finishedTorrentTab->updateTorrent(h); + } else { + // Delete from finished list, if it moved back + if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+h.hash()+".finished")) { + if(h.state() != torrent_status::checking_files && h.state() != torrent_status::queued_for_checking) { + finishedTorrentTab->deleteTorrent(h.hash()); + QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+h.hash()+".finished"); + } } + // Update in download list + downloadingTorrentTab->updateTorrent(h); } - // Update in download list - downloadingTorrentTab->updateTorrent(h); } } if(displaySpeedInTitle) { diff --git a/src/GUI.h b/src/GUI.h index c2026c241..aed449f7b 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -160,7 +160,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ void finishedTorrent(QTorrentHandle& h) const; void addedTorrent(QTorrentHandle& h) const; void checkedTorrent(QTorrentHandle& h) const; - void updateLists(); + void updateLists(bool force=false); bool initWebUi(QString username, QString password, int port); void pauseTorrent(QString hash); void on_actionIncreasePriority_triggered(); @@ -181,6 +181,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ protected: void closeEvent(QCloseEvent *); + void showEvent(QShowEvent *); bool event(QEvent * event); void displayRSSTab(bool enable);