mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
Fix execution log lines selection and copying
This commit is contained in:
parent
94a23cf1d4
commit
6606cf60af
@ -5,6 +5,7 @@
|
|||||||
- FEATURE: Add support for anonymous mode (libtorrent >= v0.16)
|
- FEATURE: Add support for anonymous mode (libtorrent >= v0.16)
|
||||||
- FEATURE: Add quick "set as default save path" checkbox to torrent addition dialog (sledgehammer999)
|
- FEATURE: Add quick "set as default save path" checkbox to torrent addition dialog (sledgehammer999)
|
||||||
- BUGFIX: Add tray menu entry for toggling window visibility
|
- BUGFIX: Add tray menu entry for toggling window visibility
|
||||||
|
- BUGFIX: Fix execution log lines selection and copying
|
||||||
- COSMETIC: Display speed at the beginning of the Window title
|
- COSMETIC: Display speed at the beginning of the Window title
|
||||||
- OTHER: Display libraries versions in about dialog (sledgehammer999)
|
- OTHER: Display libraries versions in about dialog (sledgehammer999)
|
||||||
|
|
||||||
|
@ -34,14 +34,21 @@
|
|||||||
#include "ui_executionlog.h"
|
#include "ui_executionlog.h"
|
||||||
#include "qbtsession.h"
|
#include "qbtsession.h"
|
||||||
#include "iconprovider.h"
|
#include "iconprovider.h"
|
||||||
|
#include "loglistwidget.h"
|
||||||
|
|
||||||
ExecutionLog::ExecutionLog(QWidget *parent) :
|
ExecutionLog::ExecutionLog(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::ExecutionLog)
|
ui(new Ui::ExecutionLog),
|
||||||
|
m_logList(new LogListWidget(MAX_LOG_MESSAGES)),
|
||||||
|
m_banList(new LogListWidget(MAX_LOG_MESSAGES))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->tabConsole->setTabIcon(0, IconProvider::instance()->getIcon("view-calendar-journal"));
|
ui->tabConsole->setTabIcon(0, IconProvider::instance()->getIcon("view-calendar-journal"));
|
||||||
ui->tabConsole->setTabIcon(1, IconProvider::instance()->getIcon("view-filter"));
|
ui->tabConsole->setTabIcon(1, IconProvider::instance()->getIcon("view-filter"));
|
||||||
|
ui->tabGeneral->layout()->addWidget(m_logList);
|
||||||
|
ui->tabBan->layout()->addWidget(m_banList);
|
||||||
|
|
||||||
const QStringList log_msgs = QBtSession::instance()->getConsoleMessages();
|
const QStringList log_msgs = QBtSession::instance()->getConsoleMessages();
|
||||||
foreach(const QString& msg, log_msgs)
|
foreach(const QString& msg, log_msgs)
|
||||||
addLogMessage(msg);
|
addLogMessage(msg);
|
||||||
@ -54,29 +61,17 @@ ExecutionLog::ExecutionLog(QWidget *parent) :
|
|||||||
|
|
||||||
ExecutionLog::~ExecutionLog()
|
ExecutionLog::~ExecutionLog()
|
||||||
{
|
{
|
||||||
|
delete m_logList;
|
||||||
|
delete m_banList;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecutionLog::addLogMessage(const QString &msg)
|
void ExecutionLog::addLogMessage(const QString &msg)
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = new QListWidgetItem;
|
m_logList->appendLine(msg);
|
||||||
QLabel *lbl = new QLabel(msg);
|
|
||||||
lbl->setContentsMargins(4, 2, 4, 2);
|
|
||||||
item->setSizeHint(lbl->sizeHint());
|
|
||||||
ui->logList->insertItem(0, item);
|
|
||||||
ui->logList->setItemWidget(item, lbl);
|
|
||||||
if(ui->logList->count() > MAX_LOG_MESSAGES)
|
|
||||||
delete ui->logList->takeItem(ui->logList->count()-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecutionLog::addBanMessage(const QString &msg)
|
void ExecutionLog::addBanMessage(const QString &msg)
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = new QListWidgetItem;
|
m_banList->appendLine(msg);
|
||||||
QLabel *lbl = new QLabel(msg);
|
|
||||||
lbl->setContentsMargins(4, 2, 4, 2);
|
|
||||||
item->setSizeHint(lbl->sizeHint());
|
|
||||||
ui->banList->insertItem(0, item);
|
|
||||||
ui->banList->setItemWidget(item, lbl);
|
|
||||||
if(ui->banList->count() > MAX_LOG_MESSAGES)
|
|
||||||
delete ui->banList->takeItem(ui->banList->count()-1);
|
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ExecutionLog;
|
class ExecutionLog;
|
||||||
}
|
}
|
||||||
|
class LogListWidget;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class ExecutionLog : public QWidget
|
class ExecutionLog : public QWidget
|
||||||
@ -52,7 +53,11 @@ public slots:
|
|||||||
void addBanMessage(const QString &msg);
|
void addBanMessage(const QString &msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ExecutionLog *ui;
|
Ui::ExecutionLog *ui;
|
||||||
|
|
||||||
|
LogListWidget *m_logList;
|
||||||
|
LogListWidget *m_banList;
|
||||||
|
int m_maxLines;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXECUTIONLOG_H
|
#endif // EXECUTIONLOG_H
|
||||||
|
@ -22,33 +22,17 @@
|
|||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tabGeneral">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>General</string>
|
<string>General</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout"/>
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="logList">
|
|
||||||
<property name="alternatingRowColors">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tabBan">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Blocked IPs</string>
|
<string>Blocked IPs</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="_2">
|
<layout class="QVBoxLayout" name="_2"/>
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="banList">
|
|
||||||
<property name="alternatingRowColors">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
89
src/loglistwidget.cpp
Normal file
89
src/loglistwidget.cpp
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Bittorrent Client using Qt4 and libtorrent.
|
||||||
|
* Copyright (C) 2011 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
|
||||||
|
*/
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QRegExp>
|
||||||
|
#include <QAction>
|
||||||
|
#include "loglistwidget.h"
|
||||||
|
#include "iconprovider.h"
|
||||||
|
|
||||||
|
LogListWidget::LogListWidget(int max_lines, QWidget *parent) :
|
||||||
|
QListWidget(parent),
|
||||||
|
m_maxLines(max_lines)
|
||||||
|
{
|
||||||
|
// Allow multiple selections
|
||||||
|
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
// Context menu
|
||||||
|
QAction *copyAct = new QAction(IconProvider::instance()->getIcon("edit-copy"), tr("Copy"), this);
|
||||||
|
connect(copyAct, SIGNAL(triggered()), SLOT(copySelection()));
|
||||||
|
addAction(copyAct);
|
||||||
|
setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogListWidget::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if (event->matches(QKeySequence::Copy)) {
|
||||||
|
copySelection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event->matches(QKeySequence::SelectAll)) {
|
||||||
|
selectAll();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogListWidget::appendLine(const QString &line)
|
||||||
|
{
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(this);
|
||||||
|
// We need to use QLabel here to support rich text
|
||||||
|
QLabel *lbl = new QLabel(line);
|
||||||
|
lbl->setContentsMargins(4, 2, 4, 2);
|
||||||
|
item->setSizeHint(lbl->sizeHint());
|
||||||
|
insertItem(0, item);
|
||||||
|
setItemWidget(item, lbl);
|
||||||
|
const int nbLines = count();
|
||||||
|
// Limit log size
|
||||||
|
if(nbLines > m_maxLines)
|
||||||
|
delete takeItem(nbLines - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogListWidget::copySelection()
|
||||||
|
{
|
||||||
|
static QRegExp html_tag("<[^>]+>");
|
||||||
|
QList<QListWidgetItem*> items = selectedItems();
|
||||||
|
QStringList strings;
|
||||||
|
foreach(QListWidgetItem* it, items)
|
||||||
|
strings << static_cast<QLabel*>(itemWidget(it))->text().replace(html_tag, "");
|
||||||
|
|
||||||
|
QApplication::clipboard()->setText(strings.join("\n"));
|
||||||
|
}
|
60
src/loglistwidget.h
Normal file
60
src/loglistwidget.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Bittorrent Client using Qt4 and libtorrent.
|
||||||
|
* Copyright (C) 2011 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 LOGLISTWIDGET_H
|
||||||
|
#define LOGLISTWIDGET_H
|
||||||
|
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QKeyEvent;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class LogListWidget : public QListWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit LogListWidget(int max_lines = 100, QWidget *parent = 0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void appendLine(const QString &line);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void copySelection();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_maxLines;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOGLISTWIDGET_H
|
11
src/src.pro
11
src/src.pro
@ -102,14 +102,15 @@ HEADERS += misc.h \
|
|||||||
scannedfoldersmodel.h \
|
scannedfoldersmodel.h \
|
||||||
qinisettings.h \
|
qinisettings.h \
|
||||||
smtp.h \
|
smtp.h \
|
||||||
dnsupdater.h
|
dnsupdater.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
downloadthread.cpp \
|
downloadthread.cpp \
|
||||||
scannedfoldersmodel.cpp \
|
scannedfoldersmodel.cpp \
|
||||||
misc.cpp \
|
misc.cpp \
|
||||||
smtp.cpp \
|
smtp.cpp \
|
||||||
dnsupdater.cpp
|
dnsupdater.cpp
|
||||||
|
|
||||||
nox {
|
nox {
|
||||||
HEADERS += headlessloader.h
|
HEADERS += headlessloader.h
|
||||||
@ -135,7 +136,8 @@ nox {
|
|||||||
torrentimportdlg.h \
|
torrentimportdlg.h \
|
||||||
executionlog.h \
|
executionlog.h \
|
||||||
iconprovider.h \
|
iconprovider.h \
|
||||||
updownratiodlg.h
|
updownratiodlg.h \
|
||||||
|
loglistwidget.h
|
||||||
|
|
||||||
SOURCES += mainwindow.cpp \
|
SOURCES += mainwindow.cpp \
|
||||||
ico.cpp \
|
ico.cpp \
|
||||||
@ -146,7 +148,8 @@ nox {
|
|||||||
executionlog.cpp \
|
executionlog.cpp \
|
||||||
previewselect.cpp \
|
previewselect.cpp \
|
||||||
iconprovider.cpp \
|
iconprovider.cpp \
|
||||||
updownratiodlg.cpp
|
updownratiodlg.cpp \
|
||||||
|
loglistwidget.cpp
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
HEADERS += programupdater.h
|
HEADERS += programupdater.h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user