Browse Source

Display execution log as a tab instead of a modal window

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
897d0be08e
  1. 1
      Changelog
  2. 57
      src/console_imp.h
  3. 32
      src/executionlog.cpp
  4. 26
      src/executionlog.h
  5. 17
      src/executionlog.ui
  6. 31
      src/mainwindow.cpp
  7. 5
      src/mainwindow.h
  8. 21
      src/mainwindow.ui
  9. 10
      src/preferences/preferences.h
  10. 17
      src/qtlibtorrent/qbtsession.cpp
  11. 3
      src/qtlibtorrent/qbtsession.h
  12. 11
      src/src.pro

1
Changelog

@ -4,6 +4,7 @@
- FEATURE: Simplify program preferences - FEATURE: Simplify program preferences
- COSMETIC: Same deletion confirmation dialog in the GUI and Web UI - COSMETIC: Same deletion confirmation dialog in the GUI and Web UI
- COSMETIC: Simplified the top toolbar - COSMETIC: Simplified the top toolbar
- COSMETIC: Display execution log as a tab instead of a modal window
* Sun Dec 5 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.5.0 * Sun Dec 5 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.5.0
- FEATURE: qBittorrent can now act as a tracker - FEATURE: qBittorrent can now act as a tracker

57
src/console_imp.h

@ -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("<br>"));
textBannedPeers->setHtml(QBtSession::instance()->getPeerBanMessages().join("<br>"));
show();
}
~consoleDlg() {}
};
#endif

32
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("<br>"));
connect(QBtSession::instance(), SIGNAL(newConsoleMessage(QString)), SLOT(addLogMessage(QString)));
ui->textBannedPeers->setHtml(QBtSession::instance()->getPeerBanMessages().join("<br>"));
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());
}

26
src/executionlog.h

@ -0,0 +1,26 @@
#ifndef EXECUTIONLOG_H
#define EXECUTIONLOG_H
#include <QWidget>
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

17
src/console.ui → src/executionlog.ui

@ -1,21 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ConsoleDlg</class> <class>ExecutionLog</class>
<widget class="QDialog" name="ConsoleDlg"> <widget class="QWidget" name="ExecutionLog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>512</width> <width>400</width>
<height>497</height> <height>300</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>qBittorrent log viewer</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QTabWidget" name="tabConsole"> <widget class="QTabWidget" name="tabConsole">
<property name="tabPosition">
<enum>QTabWidget::East</enum>
</property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
@ -33,7 +36,7 @@
<attribute name="title"> <attribute name="title">
<string>Blocked IPs</string> <string>Blocked IPs</string>
</attribute> </attribute>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout" name="_2">
<item> <item>
<widget class="QTextBrowser" name="textBannedPeers"/> <widget class="QTextBrowser" name="textBannedPeers"/>
</item> </item>

31
src/mainwindow.cpp

@ -58,7 +58,6 @@
#include "options_imp.h" #include "options_imp.h"
#include "speedlimitdlg.h" #include "speedlimitdlg.h"
#include "preferences.h" #include "preferences.h"
#include "console_imp.h"
#include "trackerlist.h" #include "trackerlist.h"
#include "peerlistwidget.h" #include "peerlistwidget.h"
#include "torrentpersistentdata.h" #include "torrentpersistentdata.h"
@ -70,6 +69,7 @@
#include "torrentimportdlg.h" #include "torrentimportdlg.h"
#include "rsssettings.h" #include "rsssettings.h"
#include "torrentmodel.h" #include "torrentmodel.h"
#include "executionlog.h"
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
#include "qmacapplication.h" #include "qmacapplication.h"
void qt_mac_set_dock_menu(QMenu *menu); 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->setIcon(misc::getIcon("media-playback-start"));
actionStart_All->setIcon(misc::getIcon("media-playback-start")); actionStart_All->setIcon(misc::getIcon("media-playback-start"));
action_Import_Torrent->setIcon(misc::getIcon("document-import")); action_Import_Torrent->setIcon(misc::getIcon("document-import"));
actionShow_console->setIcon(misc::getIcon("view-calendar-journal"));
QMenu *startAllMenu = new QMenu(this); QMenu *startAllMenu = new QMenu(this);
startAllMenu->addAction(actionStart_All); startAllMenu->addAction(actionStart_All);
@ -220,8 +219,10 @@ MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindo
actionSpeed_in_title_bar->setChecked(pref.speedInTitleBar()); actionSpeed_in_title_bar->setChecked(pref.speedInTitleBar());
actionRSS_Reader->setChecked(RssSettings().isRSSEnabled()); actionRSS_Reader->setChecked(RssSettings().isRSSEnabled());
actionSearch_engine->setChecked(pref.isSearchEnabled()); actionSearch_engine->setChecked(pref.isSearchEnabled());
actionExecution_Logs->setChecked(pref.isExecutionLogEnabled());
displaySearchTab(actionSearch_engine->isChecked()); displaySearchTab(actionSearch_engine->isChecked());
displayRSSTab(actionRSS_Reader->isChecked()); displayRSSTab(actionRSS_Reader->isChecked());
on_actionExecution_Logs_triggered(actionExecution_Logs->isChecked());
actionShutdown_when_downloads_complete->setChecked(pref.shutdownWhenDownloadsComplete()); actionShutdown_when_downloads_complete->setChecked(pref.shutdownWhenDownloadsComplete());
actionShutdown_qBittorrent_when_downloads_complete->setChecked(pref.shutdownqBTWhenDownloadsComplete()); actionShutdown_qBittorrent_when_downloads_complete->setChecked(pref.shutdownqBTWhenDownloadsComplete());
@ -304,8 +305,8 @@ MainWindow::~MainWindow() {
delete guiUpdater; delete guiUpdater;
if(createTorrentDlg) if(createTorrentDlg)
delete createTorrentDlg; delete createTorrentDlg;
if(console) if(m_executionLog)
delete console; delete m_executionLog;
if(aboutDlg) if(aboutDlg)
delete aboutDlg; delete aboutDlg;
if(options) 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() { void MainWindow::on_actionSet_global_download_limit_triggered() {
qDebug("actionSet_global_download_limit_triggered"); qDebug("actionSet_global_download_limit_triggered");
bool ok; bool ok;
@ -1265,3 +1258,17 @@ void MainWindow::showConnectionSettings()
on_actionOptions_triggered(); on_actionOptions_triggered();
options->showConnectionTab(); 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);
}

5
src/mainwindow.h

@ -59,6 +59,7 @@ class downloadFromURL;
class HidableTabWidget; class HidableTabWidget;
class LineEdit; class LineEdit;
class QFileSystemWatcher; class QFileSystemWatcher;
class ExecutionLog;
class MainWindow : public QMainWindow, private Ui::MainWindow{ class MainWindow : public QMainWindow, private Ui::MainWindow{
Q_OBJECT Q_OBJECT
@ -91,7 +92,6 @@ protected slots:
void on_actionCreate_torrent_triggered(); void on_actionCreate_torrent_triggered();
void on_actionWebsite_triggered() const; void on_actionWebsite_triggered() const;
void on_actionBugReport_triggered() const; void on_actionBugReport_triggered() const;
void on_actionShow_console_triggered();
void balloonClicked(); void balloonClicked();
void writeSettings(); void writeSettings();
void readSettings(); void readSettings();
@ -179,6 +179,8 @@ private:
QPointer<SearchEngine> searchEngine; QPointer<SearchEngine> searchEngine;
// RSS // RSS
QPointer<RSSImp> rssWidget; QPointer<RSSImp> rssWidget;
// Execution Log
QPointer<ExecutionLog> m_executionLog;
private slots: private slots:
void on_actionSearch_engine_triggered(); void on_actionSearch_engine_triggered();
@ -189,6 +191,7 @@ private slots:
void on_actionShutdown_qBittorrent_when_downloads_complete_triggered(); void on_actionShutdown_qBittorrent_when_downloads_complete_triggered();
void on_action_Import_Torrent_triggered(); void on_action_Import_Torrent_triggered();
void on_actionDonate_money_triggered(); void on_actionDonate_money_triggered();
void on_actionExecution_Logs_triggered(bool checked);
}; };
#endif #endif

21
src/mainwindow.ui

@ -59,7 +59,6 @@
<property name="title"> <property name="title">
<string>&amp;Tools</string> <string>&amp;Tools</string>
</property> </property>
<addaction name="actionShow_console"/>
<addaction name="actionCreate_torrent"/> <addaction name="actionCreate_torrent"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionOptions"/> <addaction name="actionOptions"/>
@ -85,6 +84,7 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionSearch_engine"/> <addaction name="actionSearch_engine"/>
<addaction name="actionRSS_Reader"/> <addaction name="actionRSS_Reader"/>
<addaction name="actionExecution_Logs"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionLock_qBittorrent"/> <addaction name="actionLock_qBittorrent"/>
</widget> </widget>
@ -238,14 +238,6 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
</action> </action>
<action name="actionShow_console">
<property name="text">
<string>&amp;Log viewer...</string>
</property>
<property name="toolTip">
<string>Log viewer</string>
</property>
</action>
<action name="actionUse_alternative_speed_limits"> <action name="actionUse_alternative_speed_limits">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@ -351,6 +343,17 @@
<string>P&amp;ause All</string> <string>P&amp;ause All</string>
</property> </property>
</action> </action>
<action name="actionExecution_Logs">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Execution &amp;Log</string>
</property>
<property name="toolTip">
<string>Execution Log</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="icons.qrc"/> <include location="icons.qrc"/>

10
src/preferences/preferences.h

@ -600,6 +600,16 @@ public:
setValue(QString::fromUtf8("Preferences/Search/SearchEnabled"), enabled); 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 // Queueing system
bool isQueueingSystemEnabled() const { bool isQueueingSystemEnabled() const {
return value("Preferences/Queueing/QueueingEnabled", false).toBool(); return value("Preferences/Queueing/QueueingEnabled", false).toBool();

17
src/qtlibtorrent/qbtsession.cpp

@ -1482,27 +1482,32 @@ void QBtSession::saveFastResumeData() {
#ifdef DISABLE_GUI #ifdef DISABLE_GUI
void QBtSession::addConsoleMessage(QString msg, QString) { void QBtSession::addConsoleMessage(QString msg, QString) {
emit newConsoleMessage(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss") + " - " + msg);
#else #else
void QBtSession::addConsoleMessage(QString msg, QColor color) { void QBtSession::addConsoleMessage(QString msg, QColor color) {
if(consoleMessages.size() > 100) { if(consoleMessages.size() > 100) {
consoleMessages.removeFirst(); consoleMessages.removeLast();
} }
#if defined(Q_WS_WIN) || defined(Q_OS_OS2) #if defined(Q_WS_WIN) || defined(Q_OS_OS2)
msg = msg.replace("/", "\\"); msg = msg.replace("/", "\\");
#endif #endif
consoleMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - <font color='") + color.name() +QString::fromUtf8("'><i>") + msg + QString::fromUtf8("</i></font>")); msg = "<font color='grey'>"+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + "</font> - <font color='" + color.name() + "'><i>" + msg + "</i></font>";
consoleMessages.prepend(msg);
emit newConsoleMessage(msg);
#endif #endif
emit newConsoleMessage(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss") + " - " + msg);
} }
void QBtSession::addPeerBanMessage(QString ip, bool from_ipfilter) { void QBtSession::addPeerBanMessage(QString ip, bool from_ipfilter) {
if(peerBanMessages.size() > 100) { if(peerBanMessages.size() > 100) {
peerBanMessages.removeFirst(); peerBanMessages.removeLast();
} }
QString msg;
if(from_ipfilter) if(from_ipfilter)
peerBanMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was blocked due to your IP filter</i>", "x.y.z.w was blocked").arg(ip)); msg = "<font color='grey'>" + QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + "</font> - " + tr("<font color='red'>%1</font> <i>was blocked due to your IP filter</i>", "x.y.z.w was blocked").arg(ip);
else else
peerBanMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was banned due to corrupt pieces</i>", "x.y.z.w was banned").arg(ip)); msg = "<font color='grey'>" + QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + "</font> - " + tr("<font color='red'>%1</font> <i>was banned due to corrupt pieces</i>", "x.y.z.w was banned").arg(ip);
peerBanMessages.prepend(msg);
emit newBanMessage(msg);
} }
bool QBtSession::isFilePreviewPossible(QString hash) const{ bool QBtSession::isFilePreviewPossible(QString hash) const{

3
src/qtlibtorrent/qbtsession.h

@ -197,7 +197,8 @@ signals:
void torrentFinishedChecking(const QTorrentHandle& h); void torrentFinishedChecking(const QTorrentHandle& h);
void metadataReceived(const QTorrentHandle &h); void metadataReceived(const QTorrentHandle &h);
void savePathChanged(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 alternativeSpeedsModeChanged(bool alternative);
void recursiveTorrentDownloadPossible(const QTorrentHandle &h); void recursiveTorrentDownloadPossible(const QTorrentHandle &h);

11
src/src.pro

@ -121,7 +121,6 @@ nox {
deletionconfirmationdlg.h \ deletionconfirmationdlg.h \
statusbar.h \ statusbar.h \
reverseresolution.h \ reverseresolution.h \
console_imp.h \
ico.h \ ico.h \
speedlimitdlg.h \ speedlimitdlg.h \
about_imp.h \ about_imp.h \
@ -132,14 +131,16 @@ nox {
trackerlogin.h \ trackerlogin.h \
hidabletabwidget.h \ hidabletabwidget.h \
sessionapplication.h \ sessionapplication.h \
torrentimportdlg.h torrentimportdlg.h \
executionlog.h
SOURCES += mainwindow.cpp \ SOURCES += mainwindow.cpp \
ico.cpp \ ico.cpp \
transferlistwidget.cpp \ transferlistwidget.cpp \
torrentadditiondlg.cpp \ torrentadditiondlg.cpp \
sessionapplication.cpp \ sessionapplication.cpp \
torrentimportdlg.cpp torrentimportdlg.cpp \
executionlog.cpp
win32 { win32 {
HEADERS += programupdater.h HEADERS += programupdater.h
@ -161,9 +162,9 @@ nox {
downloadfromurldlg.ui \ downloadfromurldlg.ui \
torrentadditiondlg.ui \ torrentadditiondlg.ui \
bandwidth_limit.ui \ bandwidth_limit.ui \
console.ui \
confirmdeletiondlg.ui \ confirmdeletiondlg.ui \
torrentimportdlg.ui torrentimportdlg.ui \
executionlog.ui
} }
DESTDIR = . DESTDIR = .

Loading…
Cancel
Save