diff --git a/Changelog b/Changelog index c62ab4b0d..dd094cc99 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ - FEATURE: Simplify program preferences - COSMETIC: Same deletion confirmation dialog in the GUI and Web UI - COSMETIC: Simplified the top toolbar + - COSMETIC: Display execution log as a tab instead of a modal window * Sun Dec 5 2010 - Christophe Dumez - v2.5.0 - FEATURE: qBittorrent can now act as a tracker diff --git a/src/console_imp.h b/src/console_imp.h deleted file mode 100644 index 6f1dcbc8d..000000000 --- a/src/console_imp.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * In addition, as a special exception, the copyright holders give permission to - * link this program with the OpenSSL project's "OpenSSL" library (or with - * modified versions of it that use the same license as the "OpenSSL" library), - * and distribute the linked executables. You must obey the GNU General Public - * License in all respects for all of the code used other than "OpenSSL". If you - * modify file(s), you may extend this exception to your version of the file(s), - * but you are not obligated to do so. If you do not wish to do so, delete this - * exception statement from your version. - * - * Contact : chris@qbittorrent.org - */ - -#ifndef CONSOLE_H -#define CONSOLE_H - -#include "qbtsession.h" -#include "ui_console.h" -#include "misc.h" - -class consoleDlg : public QDialog, private Ui_ConsoleDlg{ - Q_OBJECT - - public: - consoleDlg(QWidget *parent) : QDialog(parent) { - setupUi(this); - setAttribute(Qt::WA_DeleteOnClose); - setModal(true); - tabConsole->setTabIcon(0, misc::getIcon("view-calendar-journal")); - tabConsole->setTabIcon(1, misc::getIcon("view-filter")); - textConsole->setHtml(QBtSession::instance()->getConsoleMessages().join("
")); - textBannedPeers->setHtml(QBtSession::instance()->getPeerBanMessages().join("
")); - show(); - } - - ~consoleDlg() {} - -}; - -#endif diff --git a/src/executionlog.cpp b/src/executionlog.cpp new file mode 100644 index 000000000..8430133a6 --- /dev/null +++ b/src/executionlog.cpp @@ -0,0 +1,32 @@ +#include "executionlog.h" +#include "ui_executionlog.h" +#include "qbtsession.h" +#include "misc.h" + +ExecutionLog::ExecutionLog(QWidget *parent) : + QWidget(parent), + ui(new Ui::ExecutionLog) +{ + ui->setupUi(this); + ui->tabConsole->setTabIcon(0, misc::getIcon("view-calendar-journal")); + ui->tabConsole->setTabIcon(1, misc::getIcon("view-filter")); + ui->textConsole->setHtml(QBtSession::instance()->getConsoleMessages().join("
")); + connect(QBtSession::instance(), SIGNAL(newConsoleMessage(QString)), SLOT(addLogMessage(QString))); + ui->textBannedPeers->setHtml(QBtSession::instance()->getPeerBanMessages().join("
")); + connect(QBtSession::instance(), SIGNAL(newBanMessage(QString)), SLOT(addBanMessage(QString))); +} + +ExecutionLog::~ExecutionLog() +{ + delete ui; +} + +void ExecutionLog::addLogMessage(const QString &msg) +{ + ui->textConsole->setHtml(msg+ui->textConsole->toHtml()); +} + +void ExecutionLog::addBanMessage(const QString &msg) +{ + ui->textBannedPeers->setHtml(msg+ui->textBannedPeers->toHtml()); +} diff --git a/src/executionlog.h b/src/executionlog.h new file mode 100644 index 000000000..5ceb56725 --- /dev/null +++ b/src/executionlog.h @@ -0,0 +1,26 @@ +#ifndef EXECUTIONLOG_H +#define EXECUTIONLOG_H + +#include + +namespace Ui { + class ExecutionLog; +} + +class ExecutionLog : public QWidget +{ + Q_OBJECT + +public: + explicit ExecutionLog(QWidget *parent = 0); + ~ExecutionLog(); + +public slots: + void addLogMessage(const QString &msg); + void addBanMessage(const QString &msg); + +private: + Ui::ExecutionLog *ui; +}; + +#endif // EXECUTIONLOG_H diff --git a/src/console.ui b/src/executionlog.ui similarity index 73% rename from src/console.ui rename to src/executionlog.ui index a473c11a2..326b13098 100644 --- a/src/console.ui +++ b/src/executionlog.ui @@ -1,21 +1,24 @@ - ConsoleDlg - + ExecutionLog + 0 0 - 512 - 497 + 400 + 300 - qBittorrent log viewer + Form - + + + QTabWidget::East + 0 @@ -33,7 +36,7 @@ Blocked IPs - + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8a86b0722..10db2b462 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -58,7 +58,6 @@ #include "options_imp.h" #include "speedlimitdlg.h" #include "preferences.h" -#include "console_imp.h" #include "trackerlist.h" #include "peerlistwidget.h" #include "torrentpersistentdata.h" @@ -70,6 +69,7 @@ #include "torrentimportdlg.h" #include "rsssettings.h" #include "torrentmodel.h" +#include "executionlog.h" #ifdef Q_WS_MAC #include "qmacapplication.h" void qt_mac_set_dock_menu(QMenu *menu); @@ -124,7 +124,6 @@ MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindo actionStart->setIcon(misc::getIcon("media-playback-start")); actionStart_All->setIcon(misc::getIcon("media-playback-start")); action_Import_Torrent->setIcon(misc::getIcon("document-import")); - actionShow_console->setIcon(misc::getIcon("view-calendar-journal")); QMenu *startAllMenu = new QMenu(this); startAllMenu->addAction(actionStart_All); @@ -220,8 +219,10 @@ MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindo actionSpeed_in_title_bar->setChecked(pref.speedInTitleBar()); actionRSS_Reader->setChecked(RssSettings().isRSSEnabled()); actionSearch_engine->setChecked(pref.isSearchEnabled()); + actionExecution_Logs->setChecked(pref.isExecutionLogEnabled()); displaySearchTab(actionSearch_engine->isChecked()); displayRSSTab(actionRSS_Reader->isChecked()); + on_actionExecution_Logs_triggered(actionExecution_Logs->isChecked()); actionShutdown_when_downloads_complete->setChecked(pref.shutdownWhenDownloadsComplete()); actionShutdown_qBittorrent_when_downloads_complete->setChecked(pref.shutdownqBTWhenDownloadsComplete()); @@ -304,8 +305,8 @@ MainWindow::~MainWindow() { delete guiUpdater; if(createTorrentDlg) delete createTorrentDlg; - if(console) - delete console; + if(m_executionLog) + delete m_executionLog; if(aboutDlg) delete aboutDlg; if(options) @@ -567,14 +568,6 @@ void MainWindow::on_actionSet_global_upload_limit_triggered() { } } -void MainWindow::on_actionShow_console_triggered() { - if(!console) { - console = new consoleDlg(this); - } else { - console->setFocus(); - } -} - void MainWindow::on_actionSet_global_download_limit_triggered() { qDebug("actionSet_global_download_limit_triggered"); bool ok; @@ -1265,3 +1258,17 @@ void MainWindow::showConnectionSettings() on_actionOptions_triggered(); options->showConnectionTab(); } + +void MainWindow::on_actionExecution_Logs_triggered(bool checked) +{ + if(checked) { + Q_ASSERT(!m_executionLog); + m_executionLog = new ExecutionLog(tabs); + int index_tab = tabs->addTab(m_executionLog, tr("Execution Log")); + tabs->setTabIcon(index_tab, misc::getIcon("view-calendar-journal")); + } else { + Q_ASSERT(m_executionLog); + delete m_executionLog; + } + Preferences().setExecutionLogEnabled(checked); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 3d7327077..d9ae8b941 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -59,6 +59,7 @@ class downloadFromURL; class HidableTabWidget; class LineEdit; class QFileSystemWatcher; +class ExecutionLog; class MainWindow : public QMainWindow, private Ui::MainWindow{ Q_OBJECT @@ -91,7 +92,6 @@ protected slots: void on_actionCreate_torrent_triggered(); void on_actionWebsite_triggered() const; void on_actionBugReport_triggered() const; - void on_actionShow_console_triggered(); void balloonClicked(); void writeSettings(); void readSettings(); @@ -179,6 +179,8 @@ private: QPointer searchEngine; // RSS QPointer rssWidget; + // Execution Log + QPointer m_executionLog; private slots: void on_actionSearch_engine_triggered(); @@ -189,6 +191,7 @@ private slots: void on_actionShutdown_qBittorrent_when_downloads_complete_triggered(); void on_action_Import_Torrent_triggered(); void on_actionDonate_money_triggered(); + void on_actionExecution_Logs_triggered(bool checked); }; #endif diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 7e72f8a58..490b73cf0 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -59,7 +59,6 @@ &Tools - @@ -85,6 +84,7 @@ + @@ -238,14 +238,6 @@ false - - - &Log viewer... - - - Log viewer - - true @@ -351,6 +343,17 @@ P&ause All + + + true + + + Execution &Log + + + Execution Log + + diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index b760aeaa8..fa277de9f 100644 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -600,6 +600,16 @@ public: setValue(QString::fromUtf8("Preferences/Search/SearchEnabled"), enabled); } + // Execution Log + + bool isExecutionLogEnabled() const { + return value(QString::fromUtf8("Preferences/ExecutionLog/enabled"), false).toBool(); + } + + void setExecutionLogEnabled(bool b) { + setValue(QString::fromUtf8("Preferences/ExecutionLog/enabled"), b); + } + // Queueing system bool isQueueingSystemEnabled() const { return value("Preferences/Queueing/QueueingEnabled", false).toBool(); diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 67514bb9a..f2288cd95 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -1482,27 +1482,32 @@ void QBtSession::saveFastResumeData() { #ifdef DISABLE_GUI void QBtSession::addConsoleMessage(QString msg, QString) { + emit newConsoleMessage(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss") + " - " + msg); #else void QBtSession::addConsoleMessage(QString msg, QColor color) { if(consoleMessages.size() > 100) { - consoleMessages.removeFirst(); + consoleMessages.removeLast(); } #if defined(Q_WS_WIN) || defined(Q_OS_OS2) msg = msg.replace("/", "\\"); #endif - consoleMessages.append(QString::fromUtf8("")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8(" - ") + msg + QString::fromUtf8("")); + msg = ""+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + " - " + msg + ""; + consoleMessages.prepend(msg); + emit newConsoleMessage(msg); #endif - emit newConsoleMessage(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss") + " - " + msg); } void QBtSession::addPeerBanMessage(QString ip, bool from_ipfilter) { if(peerBanMessages.size() > 100) { - peerBanMessages.removeFirst(); + peerBanMessages.removeLast(); } + QString msg; if(from_ipfilter) - peerBanMessages.append(QString::fromUtf8("")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8(" - ")+tr("%1 was blocked due to your IP filter", "x.y.z.w was blocked").arg(ip)); + msg = "" + QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + " - " + tr("%1 was blocked due to your IP filter", "x.y.z.w was blocked").arg(ip); else - peerBanMessages.append(QString::fromUtf8("")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8(" - ")+tr("%1 was banned due to corrupt pieces", "x.y.z.w was banned").arg(ip)); + msg = "" + QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + " - " + tr("%1 was banned due to corrupt pieces", "x.y.z.w was banned").arg(ip); + peerBanMessages.prepend(msg); + emit newBanMessage(msg); } bool QBtSession::isFilePreviewPossible(QString hash) const{ diff --git a/src/qtlibtorrent/qbtsession.h b/src/qtlibtorrent/qbtsession.h index 2eba9f626..a0b96e954 100644 --- a/src/qtlibtorrent/qbtsession.h +++ b/src/qtlibtorrent/qbtsession.h @@ -197,7 +197,8 @@ signals: void torrentFinishedChecking(const QTorrentHandle& h); void metadataReceived(const QTorrentHandle &h); void savePathChanged(const QTorrentHandle &h); - void newConsoleMessage(QString msg); + void newConsoleMessage(const QString &msg); + void newBanMessage(const QString &msg); void alternativeSpeedsModeChanged(bool alternative); void recursiveTorrentDownloadPossible(const QTorrentHandle &h); diff --git a/src/src.pro b/src/src.pro index ddf5c9d50..558e55de8 100644 --- a/src/src.pro +++ b/src/src.pro @@ -121,7 +121,6 @@ nox { deletionconfirmationdlg.h \ statusbar.h \ reverseresolution.h \ - console_imp.h \ ico.h \ speedlimitdlg.h \ about_imp.h \ @@ -132,14 +131,16 @@ nox { trackerlogin.h \ hidabletabwidget.h \ sessionapplication.h \ - torrentimportdlg.h + torrentimportdlg.h \ + executionlog.h SOURCES += mainwindow.cpp \ ico.cpp \ transferlistwidget.cpp \ torrentadditiondlg.cpp \ sessionapplication.cpp \ - torrentimportdlg.cpp + torrentimportdlg.cpp \ + executionlog.cpp win32 { HEADERS += programupdater.h @@ -161,9 +162,9 @@ nox { downloadfromurldlg.ui \ torrentadditiondlg.ui \ bandwidth_limit.ui \ - console.ui \ confirmdeletiondlg.ui \ - torrentimportdlg.ui + torrentimportdlg.ui \ + executionlog.ui } DESTDIR = .