Mike Tzou
5 years ago
committed by
GitHub
18 changed files with 535 additions and 290 deletions
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent. |
||||
* Copyright (C) 2015 The qBittorrent project |
||||
* |
||||
* 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. |
||||
* |
||||
*/ |
||||
|
||||
#include "stacktracedialog.h" |
||||
|
||||
#include <QString> |
||||
|
||||
#include "base/utils/misc.h" |
||||
#include "ui_stacktracedialog.h" |
||||
|
||||
StacktraceDialog::StacktraceDialog(QWidget *parent) |
||||
: QDialog(parent) |
||||
, m_ui(new Ui::StacktraceDialog) |
||||
{ |
||||
m_ui->setupUi(this); |
||||
} |
||||
|
||||
StacktraceDialog::~StacktraceDialog() |
||||
{ |
||||
delete m_ui; |
||||
} |
||||
|
||||
void StacktraceDialog::setStacktraceString(const QString &sigName, const QString &trace) |
||||
{ |
||||
// try to call Qt function as less as possible
|
||||
const QString htmlStr = QString( |
||||
"<p align=center><b><font size=7 color=red>" |
||||
"qBittorrent has crashed" |
||||
"</font></b></p>" |
||||
"<font size=4><p>" |
||||
"Please file a bug report at " |
||||
"<a href=\"http://bugs.qbittorrent.org\">http://bugs.qbittorrent.org</a> " |
||||
"and provide the following information:" |
||||
"</p></font>" |
||||
"<br/><hr><br/>" |
||||
"<p align=center><font size=4>" |
||||
"qBittorrent version: " QBT_VERSION " (%1-bit)<br/>" |
||||
"Libtorrent version: %2<br/>" |
||||
"Qt version: " QT_VERSION_STR "<br/>" |
||||
"Boost version: %3<br/>" |
||||
"OpenSSL version: %4<br/>" |
||||
"zlib version: %5<br/>" |
||||
"OS version: %6<br/><br/>" |
||||
"Caught signal: %7" |
||||
"</font></p>" |
||||
"<pre><code>%8</code></pre>" |
||||
"<br/><hr><br/><br/>") |
||||
.arg(QString::number(QT_POINTER_SIZE * 8) |
||||
, Utils::Misc::libtorrentVersionString() |
||||
, Utils::Misc::boostVersionString() |
||||
, Utils::Misc::opensslVersionString() |
||||
, Utils::Misc::zlibVersionString() |
||||
, Utils::Misc::osName() |
||||
, sigName |
||||
, trace); |
||||
|
||||
m_ui->errorText->setHtml(htmlStr); |
||||
} |
@ -0,0 +1,105 @@
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent. |
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org> |
||||
* |
||||
* 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. |
||||
*/ |
||||
|
||||
#include "aboutdialog.h" |
||||
|
||||
#include <QFile> |
||||
|
||||
#include "base/unicodestrings.h" |
||||
#include "base/utils/misc.h" |
||||
#include "ui_aboutdialog.h" |
||||
#include "utils.h" |
||||
|
||||
AboutDialog::AboutDialog(QWidget *parent) |
||||
: QDialog(parent) |
||||
, m_ui(new Ui::AboutDialog) |
||||
{ |
||||
m_ui->setupUi(this); |
||||
setAttribute(Qt::WA_DeleteOnClose); |
||||
|
||||
// Title
|
||||
m_ui->labelName->setText(QString("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8)); |
||||
|
||||
m_ui->logo->setPixmap(Utils::Gui::scaledPixmapSvg(":/icons/skin/qbittorrent-tray.svg", this, 32)); |
||||
|
||||
// About
|
||||
QString aboutText = QString( |
||||
"<p style=\"white-space: pre-wrap;\">" |
||||
"%1\n\n" |
||||
"%2\n\n" |
||||
"<table>" |
||||
"<tr><td>%3</td><td><a href=\"https://www.qbittorrent.org\">https://www.qbittorrent.org</a></td></tr>" |
||||
"<tr><td>%4</td><td><a href=\"http://forum.qbittorrent.org\">http://forum.qbittorrent.org</a></td></tr>" |
||||
"<tr><td>%5</td><td><a href=\"http://bugs.qbittorrent.org\">http://bugs.qbittorrent.org</a></td></tr>" |
||||
"</table>" |
||||
"</p>") |
||||
.arg(tr("An advanced BitTorrent client programmed in C++, based on Qt toolkit and libtorrent-rasterbar.") |
||||
, tr("Copyright %1 2006-2019 The qBittorrent project").arg(QString::fromUtf8(C_COPYRIGHT)) |
||||
, tr("Home Page:") |
||||
, tr("Forum:") |
||||
, tr("Bug Tracker:")); |
||||
m_ui->labelAbout->setText(aboutText); |
||||
|
||||
m_ui->labelMascot->setPixmap(Utils::Gui::scaledPixmap(":/icons/skin/mascot.png", this)); |
||||
|
||||
// Thanks
|
||||
QFile thanksfile(":/thanks.html"); |
||||
if (thanksfile.open(QIODevice::ReadOnly | QIODevice::Text)) { |
||||
m_ui->textBrowserThanks->setHtml(QString::fromUtf8(thanksfile.readAll().constData())); |
||||
thanksfile.close(); |
||||
} |
||||
|
||||
// Translation
|
||||
QFile translatorsfile(":/translators.html"); |
||||
if (translatorsfile.open(QIODevice::ReadOnly | QIODevice::Text)) { |
||||
m_ui->textBrowserTranslation->setHtml(QString::fromUtf8(translatorsfile.readAll().constData())); |
||||
translatorsfile.close(); |
||||
} |
||||
|
||||
// License
|
||||
QFile licensefile(":/gpl.html"); |
||||
if (licensefile.open(QIODevice::ReadOnly | QIODevice::Text)) { |
||||
m_ui->textBrowserLicense->setHtml(QString::fromUtf8(licensefile.readAll().constData())); |
||||
licensefile.close(); |
||||
} |
||||
|
||||
// Libraries
|
||||
m_ui->labelQtVer->setText(QT_VERSION_STR); |
||||
m_ui->labelLibtVer->setText(Utils::Misc::libtorrentVersionString()); |
||||
m_ui->labelBoostVer->setText(Utils::Misc::boostVersionString()); |
||||
m_ui->labelOpensslVer->setText(Utils::Misc::opensslVersionString()); |
||||
m_ui->labelZlibVer->setText(Utils::Misc::zlibVersionString()); |
||||
|
||||
Utils::Gui::resize(this); |
||||
show(); |
||||
} |
||||
|
||||
AboutDialog::~AboutDialog() |
||||
{ |
||||
delete m_ui; |
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent. |
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org> |
||||
* |
||||
* 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. |
||||
*/ |
||||
|
||||
#include "hidabletabwidget.h" |
||||
|
||||
#include <QTabBar> |
||||
|
||||
#ifdef Q_OS_MAC |
||||
#include <QPaintEvent> |
||||
#include <QStyle> |
||||
#endif |
||||
|
||||
HidableTabWidget::HidableTabWidget(QWidget *parent) |
||||
: QTabWidget(parent) |
||||
{ |
||||
} |
||||
|
||||
void HidableTabWidget::tabInserted(const int index) |
||||
{ |
||||
QTabWidget::tabInserted(index); |
||||
tabBar()->setVisible(count() != 1); |
||||
} |
||||
|
||||
void HidableTabWidget::tabRemoved(const int index) |
||||
{ |
||||
//QTabWidget::tabInserted(index);
|
||||
QTabWidget::tabRemoved(index); |
||||
tabBar()->setVisible(count() != 1); |
||||
} |
||||
|
||||
#ifdef Q_OS_MAC |
||||
void HidableTabWidget::paintEvent(QPaintEvent *event) |
||||
{ |
||||
// Hide the pane for macintosh style
|
||||
if (!style()->inherits("QMacStyle")) |
||||
QTabWidget::paintEvent(event); |
||||
} |
||||
#endif |
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent. |
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org> |
||||
* |
||||
* 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. |
||||
*/ |
||||
|
||||
#include "previewlistdelegate.h" |
||||
|
||||
#include <QApplication> |
||||
#include <QModelIndex> |
||||
#include <QPainter> |
||||
#include <QStyleOptionProgressBar> |
||||
#include <QStyleOptionViewItem> |
||||
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
||||
#include <QProxyStyle> |
||||
#endif |
||||
|
||||
#include "base/utils/misc.h" |
||||
#include "base/utils/string.h" |
||||
#include "previewselectdialog.h" |
||||
|
||||
PreviewListDelegate::PreviewListDelegate(QObject *parent) |
||||
: QItemDelegate(parent) |
||||
{ |
||||
} |
||||
|
||||
void PreviewListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const |
||||
{ |
||||
painter->save(); |
||||
QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option); |
||||
|
||||
switch (index.column()) { |
||||
case PreviewSelectDialog::SIZE: |
||||
QItemDelegate::drawBackground(painter, opt, index); |
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong())); |
||||
break; |
||||
case PreviewSelectDialog::PROGRESS: { |
||||
QStyleOptionProgressBar newopt; |
||||
qreal progress = index.data().toDouble() * 100.; |
||||
newopt.rect = opt.rect; |
||||
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + '%'); |
||||
newopt.progress = static_cast<int>(progress); |
||||
newopt.maximum = 100; |
||||
newopt.minimum = 0; |
||||
newopt.state |= QStyle::State_Enabled; |
||||
newopt.textVisible = true; |
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
||||
// XXX: To avoid having the progress text on the right of the bar
|
||||
QProxyStyle st("fusion"); |
||||
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0); |
||||
#else |
||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); |
||||
#endif |
||||
} |
||||
break; |
||||
default: |
||||
QItemDelegate::paint(painter, option, index); |
||||
} |
||||
|
||||
painter->restore(); |
||||
} |
||||
|
||||
QWidget *PreviewListDelegate::createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const |
||||
{ |
||||
// No editor here
|
||||
return nullptr; |
||||
} |
@ -0,0 +1,91 @@
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent. |
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org> |
||||
* |
||||
* 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. |
||||
*/ |
||||
|
||||
#include "peerlistdelegate.h" |
||||
|
||||
#include <QPainter> |
||||
|
||||
#include "base/preferences.h" |
||||
#include "base/utils/misc.h" |
||||
#include "base/utils/string.h" |
||||
|
||||
PeerListDelegate::PeerListDelegate(QObject *parent) |
||||
: QItemDelegate(parent) |
||||
{ |
||||
} |
||||
|
||||
void PeerListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const |
||||
{ |
||||
painter->save(); |
||||
|
||||
const bool hideValues = Preferences::instance()->getHideZeroValues(); |
||||
QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option); |
||||
QItemDelegate::drawBackground(painter, opt, index); |
||||
|
||||
switch (index.column()) { |
||||
case PORT: |
||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; |
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, index.data().toString()); |
||||
break; |
||||
case TOT_DOWN: |
||||
case TOT_UP: { |
||||
qlonglong size = index.data().toLongLong(); |
||||
if (hideValues && (size <= 0)) |
||||
break; |
||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; |
||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size)); |
||||
} |
||||
break; |
||||
case DOWN_SPEED: |
||||
case UP_SPEED: { |
||||
qreal speed = index.data().toDouble(); |
||||
if (speed <= 0.0) |
||||
break; |
||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; |
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true)); |
||||
} |
||||
break; |
||||
case PROGRESS: |
||||
case RELEVANCE: { |
||||
qreal progress = index.data().toDouble(); |
||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; |
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress * 100.0, 1) + '%'); |
||||
} |
||||
break; |
||||
default: |
||||
QItemDelegate::paint(painter, option, index); |
||||
} |
||||
|
||||
painter->restore(); |
||||
} |
||||
|
||||
QWidget *PeerListDelegate::createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const |
||||
{ |
||||
// No editor here
|
||||
return nullptr; |
||||
} |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent. |
||||
* Copyright (C) 2013 Nick Tiskov <daymansmail@gmail.com> |
||||
* |
||||
* 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. |
||||
*/ |
||||
|
||||
#include "peerlistsortmodel.h" |
||||
|
||||
#include "base/utils/string.h" |
||||
#include "peerlistdelegate.h" |
||||
|
||||
PeerListSortModel::PeerListSortModel(QObject *parent) |
||||
: QSortFilterProxyModel(parent) |
||||
{ |
||||
} |
||||
|
||||
bool PeerListSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) const |
||||
{ |
||||
switch (sortColumn()) { |
||||
case PeerListDelegate::IP: |
||||
case PeerListDelegate::CLIENT: { |
||||
const QString strL = left.data().toString(); |
||||
const QString strR = right.data().toString(); |
||||
const int result = Utils::String::naturalCompare(strL, strR, Qt::CaseInsensitive); |
||||
return (result < 0); |
||||
} |
||||
break; |
||||
default: |
||||
return QSortFilterProxyModel::lessThan(left, right); |
||||
}; |
||||
} |
Loading…
Reference in new issue