Skip to content

Commit

Permalink
Merge pull request #7566 from evsh/themes-cbc
Browse files Browse the repository at this point in the history
Themes part 1
  • Loading branch information
zeule committed Oct 11, 2017
2 parents e075012 + db35bb5 commit 7a652c0
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 109 deletions.
58 changes: 0 additions & 58 deletions src/base/bittorrent/torrenthandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,64 +131,6 @@ AddTorrentData::AddTorrentData(const AddTorrentParams &params)
savePath = Session::instance()->defaultSavePath();
}

// TorrentState

TorrentState::TorrentState(int value)
: m_value(value)
{
}

QString TorrentState::toString() const
{
switch (m_value) {
case Error:
return QLatin1String("error");
case MissingFiles:
return QLatin1String("missingFiles");
case Uploading:
return QLatin1String("uploading");
case PausedUploading:
return QLatin1String("pausedUP");
case QueuedUploading:
return QLatin1String("queuedUP");
case StalledUploading:
return QLatin1String("stalledUP");
case CheckingUploading:
return QLatin1String("checkingUP");
case ForcedUploading:
return QLatin1String("forcedUP");
case Allocating:
return QLatin1String("allocating");
case Downloading:
return QLatin1String("downloading");
case DownloadingMetadata:
return QLatin1String("metaDL");
case PausedDownloading:
return QLatin1String("pausedDL");
case QueuedDownloading:
return QLatin1String("queuedDL");
case StalledDownloading:
return QLatin1String("stalledDL");
case CheckingDownloading:
return QLatin1String("checkingDL");
case ForcedDownloading:
return QLatin1String("forcedDL");
#if LIBTORRENT_VERSION_NUM < 10100
case QueuedForChecking:
return QLatin1String("queuedForChecking");
#endif
case CheckingResumeData:
return QLatin1String("checkingResumeData");
default:
return QLatin1String("unknown");
}
}

TorrentState::operator int() const
{
return m_value;
}

// TorrentHandle

const qreal TorrentHandle::USE_GLOBAL_RATIO = -2.;
Expand Down
55 changes: 22 additions & 33 deletions src/base/bittorrent/torrenthandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,48 +120,35 @@ namespace BitTorrent
quint32 numPeers = 0;
};

class TorrentState
enum class TorrentState
{
public:
enum
{
Unknown = -1,

ForcedDownloading,
Downloading,
DownloadingMetadata,
Allocating,
StalledDownloading,

ForcedUploading,
Uploading,
StalledUploading,
Unknown = -1,

QueuedDownloading,
QueuedUploading,
ForcedDownloading,
Downloading,
DownloadingMetadata,
Allocating,
StalledDownloading,

CheckingUploading,
CheckingDownloading,
ForcedUploading,
Uploading,
StalledUploading,

#if LIBTORRENT_VERSION_NUM < 10100
QueuedForChecking,
QueuedForChecking,
#endif
CheckingResumeData,
CheckingResumeData,
QueuedDownloading,
QueuedUploading,

PausedDownloading,
PausedUploading,
CheckingUploading,
CheckingDownloading,

MissingFiles,
Error
};
PausedDownloading,
PausedUploading,

TorrentState(int value);

operator int() const;
QString toString() const;

private:
int m_value;
MissingFiles,
Error
};

class TorrentHandle : public QObject
Expand Down Expand Up @@ -474,4 +461,6 @@ namespace BitTorrent
};
}

Q_DECLARE_METATYPE(BitTorrent::TorrentState)

#endif // BITTORRENT_TORRENTHANDLE_H
2 changes: 1 addition & 1 deletion src/base/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

Preferences *Preferences::m_instance = 0;

Preferences::Preferences() {}
Preferences::Preferences() = default;

Preferences *Preferences::instance()
{
Expand Down
5 changes: 1 addition & 4 deletions src/base/torrentfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ typedef QSet<QString> QStringSet;

namespace BitTorrent
{

class TorrentHandle;
class TorrentState;

class TorrentHandle;
}

class TorrentFilter
Expand Down
3 changes: 1 addition & 2 deletions src/gui/guiiconprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GuiIconProvider::GuiIconProvider(QObject *parent)
connect(Preferences::instance(), SIGNAL(changed()), SLOT(configure()));
}

GuiIconProvider::~GuiIconProvider() {}
GuiIconProvider::~GuiIconProvider() = default;

void GuiIconProvider::initInstance()
{
Expand Down Expand Up @@ -138,7 +138,6 @@ QString GuiIconProvider::getIconPath(const QString &iconId)
return IconProvider::getIconPath(iconId);
}


void GuiIconProvider::configure()
{
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
Expand Down
2 changes: 1 addition & 1 deletion src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ void MainWindow::createKeyboardShortcuts()
m_ui->actionDocumentation->setShortcut(QKeySequence::HelpContents);
m_ui->actionOptions->setShortcut(Qt::ALT + Qt::Key_O);
m_ui->actionStart->setShortcut(Qt::CTRL + Qt::Key_S);
m_ui->actionStartAll->setShortcut(Qt::CTRL + Qt::SHIFT +Qt::Key_S);
m_ui->actionStartAll->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_S);
m_ui->actionPause->setShortcut(Qt::CTRL + Qt::Key_P);
m_ui->actionPauseAll->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_P);
m_ui->actionBottomPriority->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Minus);
Expand Down
3 changes: 1 addition & 2 deletions src/gui/optionsdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
connect(m_ui->comboRatioLimitAct, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::toggleComboRatioLimitAct);
connect(m_ui->spinMaxSeedingMinutes, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, &ThisType::enableApplyButton);
connect(m_ui->spinMaxSeedingMinutes, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
// Proxy tab
connect(m_ui->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
connect(m_ui->textProxyIP, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
Expand Down
6 changes: 3 additions & 3 deletions src/gui/optionsdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ private slots:
void on_buttonBox_accepted();
void closeEvent(QCloseEvent *e);
void on_buttonBox_rejected();
void applySettings(QAbstractButton* button);
void applySettings(QAbstractButton *button);
void enableApplyButton();
void toggleComboRatioLimitAct();
void changePage(QListWidgetItem*, QListWidgetItem*);
void changePage(QListWidgetItem *, QListWidgetItem *);
void loadWindowState();
void loadSplitterState();
void saveWindowState() const;
Expand Down Expand Up @@ -132,7 +132,7 @@ private slots:
bool addTorrentsInPause() const;
QString getTorrentExportDir() const;
QString getFinishedTorrentExportDir() const;
QString askForExportDir(const QString& currentExportPath);
QString askForExportDir(const QString &currentExportPath);
int getActionOnDblClOnTorrentDl() const;
int getActionOnDblClOnTorrentFn() const;
// Connection options
Expand Down
6 changes: 3 additions & 3 deletions src/gui/transferlistdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
bool isHideState = true;
if (Preferences::instance()->getHideZeroComboValues() == 1) { // paused torrents only
QModelIndex stateIndex = index.sibling(index.row(), TorrentModel::TR_STATUS);
if (stateIndex.data().toInt() != BitTorrent::TorrentState::PausedDownloading)
if (stateIndex.data().value<BitTorrent::TorrentState>() != BitTorrent::TorrentState::PausedDownloading)
isHideState = false;
}
const bool hideValues = Preferences::instance()->getHideZeroValues() & isHideState;
Expand Down Expand Up @@ -98,7 +98,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
break;
}
case TorrentModel::TR_STATUS: {
const int state = index.data().toInt();
const auto state = index.data().value<BitTorrent::TorrentState>();
QString display = getStatusString(state);
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
break;
Expand Down Expand Up @@ -223,7 +223,7 @@ QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem & option, const
return size;
}

QString TransferListDelegate::getStatusString(const int state) const
QString TransferListDelegate::getStatusString(const BitTorrent::TorrentState state) const
{
QString str;

Expand Down
6 changes: 5 additions & 1 deletion src/gui/transferlistdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class QStyleOptionViewItem;
class QModelIndex;
QT_END_NAMESPACE

namespace BitTorrent
{
enum class TorrentState;
}
// Defines for download list list columns

class TransferListDelegate: public QItemDelegate
Expand All @@ -52,7 +56,7 @@ class TransferListDelegate: public QItemDelegate
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;

private:
QString getStatusString(const int state) const;
QString getStatusString(const BitTorrent::TorrentState state) const;
};

#endif // TRANSFERLISTDELEGATE_H
50 changes: 49 additions & 1 deletion src/webui/btjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <QElapsedTimer>
#include <QVariant>

#include <libtorrent/version.hpp>

#include "base/bittorrent/cachestatus.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/sessionstatus.h"
Expand Down Expand Up @@ -227,6 +229,52 @@ static const char KEY_LOG_PEER_REASON[] = "reason";

namespace
{
QString torrentStateToString(const BitTorrent::TorrentState state)
{
switch (state) {
case BitTorrent::TorrentState::Error:
return QLatin1String("error");
case BitTorrent::TorrentState::MissingFiles:
return QLatin1String("missingFiles");
case BitTorrent::TorrentState::Uploading:
return QLatin1String("uploading");
case BitTorrent::TorrentState::PausedUploading:
return QLatin1String("pausedUP");
case BitTorrent::TorrentState::QueuedUploading:
return QLatin1String("queuedUP");
case BitTorrent::TorrentState::StalledUploading:
return QLatin1String("stalledUP");
case BitTorrent::TorrentState::CheckingUploading:
return QLatin1String("checkingUP");
case BitTorrent::TorrentState::ForcedUploading:
return QLatin1String("forcedUP");
case BitTorrent::TorrentState::Allocating:
return QLatin1String("allocating");
case BitTorrent::TorrentState::Downloading:
return QLatin1String("downloading");
case BitTorrent::TorrentState::DownloadingMetadata:
return QLatin1String("metaDL");
case BitTorrent::TorrentState::PausedDownloading:
return QLatin1String("pausedDL");
case BitTorrent::TorrentState::QueuedDownloading:
return QLatin1String("queuedDL");
case BitTorrent::TorrentState::StalledDownloading:
return QLatin1String("stalledDL");
case BitTorrent::TorrentState::CheckingDownloading:
return QLatin1String("checkingDL");
case BitTorrent::TorrentState::ForcedDownloading:
return QLatin1String("forcedDL");
#if LIBTORRENT_VERSION_NUM < 10100
case BitTorrent::TorrentState::QueuedForChecking:
return QLatin1String("queuedForChecking");
#endif
case BitTorrent::TorrentState::CheckingResumeData:
return QLatin1String("checkingResumeData");
default:
return QLatin1String("unknown");
}
}

class QTorrentCompare
{
public:
Expand Down Expand Up @@ -315,7 +363,7 @@ namespace
ret[KEY_TORRENT_NUM_INCOMPLETE] = torrent->totalLeechersCount();
const qreal ratio = torrent->realRatio();
ret[KEY_TORRENT_RATIO] = (ratio > BitTorrent::TorrentHandle::MAX_RATIO) ? -1 : ratio;
ret[KEY_TORRENT_STATE] = torrent->state().toString();
ret[KEY_TORRENT_STATE] = torrentStateToString(torrent->state());
ret[KEY_TORRENT_ETA] = torrent->eta();
ret[KEY_TORRENT_SEQUENTIAL_DOWNLOAD] = torrent->isSequentialDownload();
if (torrent->hasMetadata())
Expand Down

0 comments on commit 7a652c0

Please sign in to comment.