Skip to content

Commit

Permalink
Merge branch 'bugfix-libtorrent' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
setvisible committed Dec 30, 2023
2 parents adf66b7 + 67c9c2e commit 00060a9
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 45 deletions.
24 changes: 12 additions & 12 deletions src/core/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,38 +231,38 @@ void Theme::applyTheme(const QMap<QString, QVariant> &map)
/*!
* QtDesigner doesn't icon themes correctly, this is a workaround
*/
void Theme::setIcons(const QWidget *widget, const QMap<QAbstractButton*, QString> &map)
void Theme::setIcons(const QWidget *widget, const QHash<QAbstractButton *, QString> &hash)
{
QMapIterator<QAbstractButton*, QString> it(map);
QHashIterator<QAbstractButton *, QString> it(hash);
while (it.hasNext()) {
it.next();
auto button = it.key();
auto qbutton = it.key();
auto name = it.value();
button->setIcon(QIcon::fromTheme(name));
qbutton->setIcon(QIcon::fromTheme(name));
}
_assertNoMissingIconTheme(widget);
}

void Theme::setIcons(const QWidget *widget, const QMap<QAction*, QString> &map)
void Theme::setIcons(const QWidget *widget, const QHash<QAction *, QString> &hash)
{
QMapIterator<QAction*, QString> it(map);
QHashIterator<QAction*, QString> it(hash);
while (it.hasNext()) {
it.next();
auto action = it.key();
auto qaction = it.key();
auto name = it.value();
action->setIcon(QIcon::fromTheme(name));
qaction->setIcon(QIcon::fromTheme(name));
}
_assertNoMissingIconTheme(widget);
}

void Theme::setIcons(const QWidget *widget, const QMap<QLabel*, QString> &map, int extent)
void Theme::setIcons(const QWidget *widget, const QHash<QLabel *, QString> &hash, int extent)
{
QMapIterator<QLabel*, QString> it(map);
QHashIterator<QLabel *, QString> it(hash);
while (it.hasNext()) {
it.next();
auto label = it.key();
auto qlabel = it.key();
auto name = it.value();
label->setPixmap(QIcon::fromTheme(name).pixmap(extent));
qlabel->setPixmap(QIcon::fromTheme(name).pixmap(extent));
}
_assertNoMissingIconTheme(widget);
}
6 changes: 3 additions & 3 deletions src/core/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class Theme
static void applyTheme(const QMap<QString, QVariant> &map);

/* Utils */
static void setIcons(const QWidget *widget, const QMap<QAbstractButton*, QString> &map);
static void setIcons(const QWidget *widget, const QMap<QAction*, QString> &map);
static void setIcons(const QWidget *widget, const QMap<QLabel*, QString> &map, int extent = 48);
static void setIcons(const QWidget *widget, const QHash<QAbstractButton *, QString> &hash);
static void setIcons(const QWidget *widget, const QHash<QAction *, QString> &hash);
static void setIcons(const QWidget *widget, const QHash<QLabel *, QString> &hash, int extent = 48);
};

#endif // WIDGETS_THEME_H
4 changes: 2 additions & 2 deletions src/core/torrentcontext_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void TorrentContextPrivate::downloadTorrentFile(Torrent *torrent)

void TorrentContextPrivate::abortNetworkReply(Torrent *torrent)
{
QMapIterator<QNetworkReply*, Torrent*> it(m_currentDownloads);
QHashIterator<QNetworkReply *, Torrent *> it(m_currentDownloads);
while (it.hasNext()) {
it.next();
auto currentReply = it.key();
Expand Down Expand Up @@ -612,7 +612,7 @@ void TorrentContextPrivate::writeTorrentFileFromMagnet(
lt::create_torrent ct(*ti);
auto te = ct.generate();
std::vector<char> buffer;
bencode(std::back_inserter(buffer), te);
lt::bencode(std::back_inserter(buffer), te);

// Write
QByteArray data(&buffer[0], static_cast<int>(buffer.size()));
Expand Down
3 changes: 2 additions & 1 deletion src/core/torrentcontext_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ public slots:

private slots:
void onNetworkReplyFinished();

private:
QMap<QNetworkReply*, Torrent*> m_currentDownloads;
QHash<QNetworkReply *, Torrent *> m_currentDownloads;
void downloadMagnetLink(Torrent *torrent);
void downloadTorrentFile(Torrent *torrent);
void abortNetworkReply(Torrent *torrent);
Expand Down
4 changes: 2 additions & 2 deletions src/core/updatechecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ void UpdateChecker::onMetadataFinished()
if (!changelog.empty()) {
// for no-gui check
m_latestUpdateUrl = changelog.front().assetUrl;
emit updateAvailable();
emit updateAvailableForConsole();
}

storeDateTime();
emit updateAvailable(changelog);
emit updateAvailableForGui(changelog);
}

/******************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions src/core/updatechecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class UpdateChecker : public QObject
QString latestUpdateUrl() const; // For Linux

signals:
void updateAvailable(); // for non-GUI
void updateAvailable(UpdateChecker::ChangeLog changelog);
void updateAvailableForConsole(); // for non-GUI
void updateAvailableForGui(UpdateChecker::ChangeLog changelog);
void downloadProgress(qsizetype bytesReceived, qsizetype bytesTotal);
void updateDownloadFinished();
void updateError(QString errorMessage);
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs/homedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ void HomeDialog::acceptUrls()

void HomeDialog::propagateIcons()
{
const QMap<QAbstractButton*, QString> map = {
const QHash<QAbstractButton *, QString> hash = {
{ui->buttonContent, "add-content"},
{ui->buttonBatch , "add-batch"},
{ui->buttonStream , "add-stream"},
{ui->buttonTorrent, "add-torrent"},
{ui->buttonUrls , "add-urls"}
};
Theme::setIcons(this, map);
Theme::setIcons(this, hash);
}
12 changes: 6 additions & 6 deletions src/dialogs/preferencedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@ void PreferenceDialog::restylizeUi()
ui->tabWidget->setTabIcon(6, QIcon::fromTheme("preference-advanced"));

// Restylize icons
const QMap<QLabel*, QString> map = {
{ui->streamHelp, "help"},
{ui->concurrentFragmentHelp, "help"},
{ui->httpUserAgentHelp, "help"},
{ui->httpReferringPageHelp, "help"}
const QHash<QLabel *, QString> hash = {
{ui->streamHelp, "help"},
{ui->concurrentFragmentHelp, "help"},
{ui->httpUserAgentHelp, "help"},
{ui->httpReferringPageHelp, "help"}
};
Theme::setIcons(this, map);
Theme::setIcons(this, hash);
}

/******************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs/updatedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ UpdateDialog::UpdateDialog(UpdateChecker *updateChecker, QWidget *parent)
connect(ui->checkButton, SIGNAL(released()), this, SLOT(check()));
connect(ui->installButton, SIGNAL(released()), this, SLOT(install()));

connect(m_updateChecker, SIGNAL(updateAvailable(UpdateChecker::ChangeLog)), this, SLOT(onUpdateAvailable(UpdateChecker::ChangeLog)));
connect(m_updateChecker, SIGNAL(updateAvailableForGui(UpdateChecker::ChangeLog)), this, SLOT(updateAvailableForGui(UpdateChecker::ChangeLog)));
connect(m_updateChecker, SIGNAL(downloadProgress(qsizetype,qsizetype)), this, SLOT(onDownloadProgress(qsizetype,qsizetype)));
connect(m_updateChecker, SIGNAL(updateDownloadFinished()), this, SLOT(onUpdateDownloadFinished()));
connect(m_updateChecker, SIGNAL(updateError(QString)), this, SLOT(onUpdateError(QString)));
Expand Down Expand Up @@ -120,7 +120,7 @@ void UpdateDialog::install()

/******************************************************************************
******************************************************************************/
void UpdateDialog::onUpdateAvailable(const UpdateChecker::ChangeLog &changelog)
void UpdateDialog::onUpdateAvailableForGui(const UpdateChecker::ChangeLog &changelog)
{
if (!changelog.empty()) {
ui->stackedWidget->setCurrentWidget(ui->pageNewVersionAvailable);
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/updatedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private slots:
void check();
void install();

void onUpdateAvailable(const UpdateChecker::ChangeLog &changelog);
void onUpdateAvailableForGui(const UpdateChecker::ChangeLog &changelog);
void onDownloadProgress(qsizetype bytesReceived, qsizetype bytesTotal);
void onUpdateDownloadFinished();
void onUpdateError(const QString &errorMessage);
Expand Down
10 changes: 5 additions & 5 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ MainWindow::MainWindow(QWidget *parent): QMainWindow(parent)
}

/* Update Checker */
connect(m_updateChecker, SIGNAL(updateAvailable()), this, SLOT(onUpdateAvailable()));
connect(m_updateChecker, SIGNAL(updateAvailableForConsole()), this, SLOT(onUpdateAvailableForConsole()));
m_updateChecker->checkForUpdates(m_settings);
}

Expand Down Expand Up @@ -438,7 +438,7 @@ void MainWindow::propagateToolTips()

void MainWindow::propagateIcons()
{
const QMap<QAction*, QString> map = {
const QHash<QAction*, QString> hash = {

//! [0] File
{ui->actionHome , "home"},
Expand Down Expand Up @@ -516,7 +516,7 @@ void MainWindow::propagateIcons()
// {ui->actionAboutYTDLP , ""}
//! [5]
};
Theme::setIcons(this, map);
Theme::setIcons(this, hash);
}

/******************************************************************************
Expand Down Expand Up @@ -1023,14 +1023,14 @@ void MainWindow::showTutorial()
dialog.exec();
}

void MainWindow::onUpdateAvailable()
void MainWindow::onUpdateAvailableForConsole()
{
checkForUpdates();
}

void MainWindow::checkForUpdates()
{
disconnect(m_updateChecker, SIGNAL(updateAvailable()), this, SLOT(onUpdateAvailable()));
disconnect(m_updateChecker, SIGNAL(updateAvailableForConsole()), this, SLOT(onUpdateAvailableForConsole()));
UpdateDialog dialog(m_updateChecker, this);
dialog.exec();
}
Expand Down
2 changes: 1 addition & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public slots:
void showPreferences();

// Help
void onUpdateAvailable();
void onUpdateAvailableForConsole();
void checkForUpdates();
void showTutorial();
void about();
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/streamformatpicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@ void StreamFormatPicker::onButtonBarClicked()
******************************************************************************/
void StreamFormatPicker::propagateIcons()
{
const QMap<QAbstractButton*, QString> map = {
const QHash<QAbstractButton *, QString> hash = {
{ui->buttonSimple, "add-stream"},
{ui->buttonAudio, "stream-audio"},
{ui->buttonVideo, "stream-video"},
{ui->buttonOther, "stream-subtitle"}
};
Theme::setIcons(this, map);
Theme::setIcons(this, hash);
}

/******************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/texteditorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ void TextEditorWidget::onBlockModeToggled(bool checked)
******************************************************************************/
void TextEditorWidget::propagateIcons()
{
const QMap<QAbstractButton*, QString> map = {
const QHash<QAbstractButton *, QString> hash = {
{ui->editblockmode, "edit-block-mode"},
{ui->editcopy , "edit-copy"},
{ui->editcut , "edit-cut"},
{ui->editpaste , "edit-paste"},
{ui->editredo , "edit-redo"},
{ui->editundo , "edit-undo"}
};
Theme::setIcons(this, map);
Theme::setIcons(this, hash);
}
4 changes: 2 additions & 2 deletions test/manual-test/demo/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void MainWindow::createContextMenu()

void MainWindow::propagateIcons()
{
const QMap<QAction*, QString> map = {
const QHash<QAction*, QString> hash = {

//! [0] File
// {ui->actionHome , "home"},
Expand Down Expand Up @@ -245,7 +245,7 @@ void MainWindow::propagateIcons()
// {ui->actionAboutYoutubeDL , ""}
//! [5]
};
Theme::setIcons(this, map);
Theme::setIcons(this, hash);
}

/******************************************************************************
Expand Down

0 comments on commit 00060a9

Please sign in to comment.