Display execution log as a tab instead of a modal window

This commit is contained in:
Christophe Dumez 2010-12-20 18:07:36 +00:00
parent c3b7aeadd7
commit 897d0be08e
12 changed files with 133 additions and 98 deletions

View file

@ -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 <chris@qbittorrent.org> - v2.5.0
- FEATURE: qBittorrent can now act as a tracker

View file

@ -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 Normal file
View file

@ -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 Normal file
View file

@ -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

View file

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

View file

@ -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);
}

View file

@ -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> searchEngine;
// RSS
QPointer<RSSImp> rssWidget;
// Execution Log
QPointer<ExecutionLog> 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

View file

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

View file

@ -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();

View file

@ -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("<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
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("<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
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{

View file

@ -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);

View file

@ -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 = .