2011-06-19 22:57:34 +04:00
|
|
|
/*
|
2018-06-06 16:48:17 +03:00
|
|
|
* Bittorrent Client using Qt and libtorrent.
|
2011-06-19 22:57:34 +04:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2018-06-14 12:54:23 +03:00
|
|
|
#include "executionlogwidget.h"
|
2018-06-06 16:48:17 +03:00
|
|
|
|
|
|
|
#include <QDateTime>
|
2020-04-15 19:48:00 +03:00
|
|
|
#include <QMenu>
|
2015-01-06 02:25:56 +03:00
|
|
|
#include <QPalette>
|
2018-06-06 16:48:17 +03:00
|
|
|
|
2022-03-12 17:00:58 +03:00
|
|
|
#include "base/global.h"
|
2020-04-15 19:48:00 +03:00
|
|
|
#include "log/logfiltermodel.h"
|
|
|
|
#include "log/loglistview.h"
|
|
|
|
#include "log/logmodel.h"
|
2018-06-14 12:54:23 +03:00
|
|
|
#include "ui_executionlogwidget.h"
|
2019-07-16 07:01:33 +03:00
|
|
|
#include "uithememanager.h"
|
2010-12-20 21:07:36 +03:00
|
|
|
|
2020-04-15 19:48:00 +03:00
|
|
|
ExecutionLogWidget::ExecutionLogWidget(const Log::MsgTypes types, QWidget *parent)
|
2015-01-06 02:48:24 +03:00
|
|
|
: QWidget(parent)
|
2018-06-14 12:54:23 +03:00
|
|
|
, m_ui(new Ui::ExecutionLogWidget)
|
2020-04-15 19:48:00 +03:00
|
|
|
, m_messageFilterModel(new LogFilterModel(types, this))
|
2010-12-20 21:07:36 +03:00
|
|
|
{
|
2018-06-06 16:48:17 +03:00
|
|
|
m_ui->setupUi(this);
|
2011-09-24 16:39:27 +04:00
|
|
|
|
2020-04-15 19:48:00 +03:00
|
|
|
LogMessageModel *messageModel = new LogMessageModel(this);
|
|
|
|
m_messageFilterModel->setSourceModel(messageModel);
|
|
|
|
LogListView *messageView = new LogListView(this);
|
|
|
|
messageView->setModel(m_messageFilterModel);
|
|
|
|
messageView->setContextMenuPolicy(Qt::CustomContextMenu);
|
2022-01-21 12:31:31 +03:00
|
|
|
connect(messageView, &LogListView::customContextMenuRequested, this, [this, messageView, messageModel]()
|
2020-04-15 19:48:00 +03:00
|
|
|
{
|
2022-01-21 12:31:31 +03:00
|
|
|
displayContextMenu(messageView, messageModel);
|
2020-04-15 19:48:00 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
LogPeerModel *peerModel = new LogPeerModel(this);
|
|
|
|
LogListView *peerView = new LogListView(this);
|
|
|
|
peerView->setModel(peerModel);
|
|
|
|
peerView->setContextMenuPolicy(Qt::CustomContextMenu);
|
2022-01-21 12:31:31 +03:00
|
|
|
connect(peerView, &LogListView::customContextMenuRequested, this, [this, peerView, peerModel]()
|
2020-04-15 19:48:00 +03:00
|
|
|
{
|
2022-01-21 12:31:31 +03:00
|
|
|
displayContextMenu(peerView, peerModel);
|
2020-04-15 19:48:00 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
m_ui->tabGeneral->layout()->addWidget(messageView);
|
|
|
|
m_ui->tabBan->layout()->addWidget(peerView);
|
|
|
|
|
2019-09-05 15:11:33 +03:00
|
|
|
#ifndef Q_OS_MACOS
|
2022-12-25 16:25:56 +03:00
|
|
|
m_ui->tabConsole->setTabIcon(0, UIThemeManager::instance()->getIcon(u"help-contents"_qs, u"view-calendar-journal"_qs));
|
|
|
|
m_ui->tabConsole->setTabIcon(1, UIThemeManager::instance()->getIcon(u"ip-blocked"_qs, u"view-filter"_qs));
|
2017-06-12 22:47:28 +03:00
|
|
|
#endif
|
2010-12-20 21:07:36 +03:00
|
|
|
}
|
|
|
|
|
2018-06-14 12:54:23 +03:00
|
|
|
ExecutionLogWidget::~ExecutionLogWidget()
|
2010-12-20 21:07:36 +03:00
|
|
|
{
|
2018-06-06 16:48:17 +03:00
|
|
|
delete m_ui;
|
2010-12-20 21:07:36 +03:00
|
|
|
}
|
|
|
|
|
2020-04-15 19:48:00 +03:00
|
|
|
void ExecutionLogWidget::setMessageTypes(const Log::MsgTypes types)
|
2016-01-24 22:38:45 +03:00
|
|
|
{
|
2020-04-15 19:48:00 +03:00
|
|
|
m_messageFilterModel->setMessageTypes(types);
|
2016-01-24 22:38:45 +03:00
|
|
|
}
|
|
|
|
|
2022-01-21 12:31:31 +03:00
|
|
|
void ExecutionLogWidget::displayContextMenu(const LogListView *view, const BaseLogModel *model) const
|
2010-12-20 21:07:36 +03:00
|
|
|
{
|
2020-04-15 19:48:00 +03:00
|
|
|
QMenu *menu = new QMenu;
|
|
|
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
2015-01-06 02:25:56 +03:00
|
|
|
|
2020-04-15 19:48:00 +03:00
|
|
|
// only show copy action if any of the row is selected
|
2020-11-16 10:02:11 +03:00
|
|
|
if (view->currentIndex().isValid())
|
|
|
|
{
|
2022-03-12 17:00:58 +03:00
|
|
|
menu->addAction(UIThemeManager::instance()->getIcon(u"edit-copy"_qs), tr("Copy")
|
2021-01-17 09:56:56 +03:00
|
|
|
, view, &LogListView::copySelection);
|
2020-04-15 19:48:00 +03:00
|
|
|
}
|
2010-12-20 21:07:36 +03:00
|
|
|
|
2022-03-12 17:00:58 +03:00
|
|
|
menu->addAction(UIThemeManager::instance()->getIcon(u"edit-clear"_qs), tr("Clear")
|
2021-01-17 09:56:56 +03:00
|
|
|
, model, &BaseLogModel::reset);
|
2015-01-06 02:25:56 +03:00
|
|
|
|
2022-01-21 12:31:31 +03:00
|
|
|
menu->popup(QCursor::pos());
|
2010-12-20 21:07:36 +03:00
|
|
|
}
|