From 6970ffc9109e8b3b139bd22b4d87e892ae895244 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 17 Dec 2023 22:28:02 +0100 Subject: [PATCH 1/4] [Updater] Fix overload signal for updateAvailable() --- src/core/updatechecker.cpp | 4 ++-- src/core/updatechecker.h | 4 ++-- src/dialogs/updatedialog.cpp | 4 ++-- src/dialogs/updatedialog.h | 2 +- src/mainwindow.cpp | 6 +++--- src/mainwindow.h | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/updatechecker.cpp b/src/core/updatechecker.cpp index 1e8ed946..10cd319d 100644 --- a/src/core/updatechecker.cpp +++ b/src/core/updatechecker.cpp @@ -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); } /****************************************************************************** diff --git a/src/core/updatechecker.h b/src/core/updatechecker.h index 4ce7115f..2f0df3aa 100644 --- a/src/core/updatechecker.h +++ b/src/core/updatechecker.h @@ -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); diff --git a/src/dialogs/updatedialog.cpp b/src/dialogs/updatedialog.cpp index 232e688f..4fb33c0a 100644 --- a/src/dialogs/updatedialog.cpp +++ b/src/dialogs/updatedialog.cpp @@ -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))); @@ -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); diff --git a/src/dialogs/updatedialog.h b/src/dialogs/updatedialog.h index 39974f97..dddb31f2 100644 --- a/src/dialogs/updatedialog.h +++ b/src/dialogs/updatedialog.h @@ -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); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b1cd2ba1..ac5866c5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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); } @@ -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(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index b120a09b..77cec73b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -125,7 +125,7 @@ public slots: void showPreferences(); // Help - void onUpdateAvailable(); + void onUpdateAvailableForConsole(); void checkForUpdates(); void showTutorial(); void about(); From d83324472524614ff762807f58290080b36dfc8a Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 17 Dec 2023 22:41:07 +0100 Subject: [PATCH 2/4] [Core] Replace QMap with QHash in theme --- src/core/theme.cpp | 24 ++++++++++++------------ src/core/theme.h | 6 +++--- src/dialogs/homedialog.cpp | 4 ++-- src/dialogs/preferencedialog.cpp | 12 ++++++------ src/mainwindow.cpp | 4 ++-- src/widgets/streamformatpicker.cpp | 4 ++-- src/widgets/texteditorwidget.cpp | 4 ++-- test/manual-test/demo/mainwindow.cpp | 4 ++-- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/core/theme.cpp b/src/core/theme.cpp index 1fc8060f..e53f4ad6 100644 --- a/src/core/theme.cpp +++ b/src/core/theme.cpp @@ -231,38 +231,38 @@ void Theme::applyTheme(const QMap &map) /*! * QtDesigner doesn't icon themes correctly, this is a workaround */ -void Theme::setIcons(const QWidget *widget, const QMap &map) +void Theme::setIcons(const QWidget *widget, const QHash &hash) { - QMapIterator it(map); + QHashIterator 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 &map) +void Theme::setIcons(const QWidget *widget, const QHash &hash) { - QMapIterator it(map); + QHashIterator 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 &map, int extent) +void Theme::setIcons(const QWidget *widget, const QHash &hash, int extent) { - QMapIterator it(map); + QHashIterator 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); } diff --git a/src/core/theme.h b/src/core/theme.h index 40ed975e..facd8748 100644 --- a/src/core/theme.h +++ b/src/core/theme.h @@ -50,9 +50,9 @@ class Theme static void applyTheme(const QMap &map); /* Utils */ - static void setIcons(const QWidget *widget, const QMap &map); - static void setIcons(const QWidget *widget, const QMap &map); - static void setIcons(const QWidget *widget, const QMap &map, int extent = 48); + static void setIcons(const QWidget *widget, const QHash &hash); + static void setIcons(const QWidget *widget, const QHash &hash); + static void setIcons(const QWidget *widget, const QHash &hash, int extent = 48); }; #endif // WIDGETS_THEME_H diff --git a/src/dialogs/homedialog.cpp b/src/dialogs/homedialog.cpp index f0baf173..433404ec 100644 --- a/src/dialogs/homedialog.cpp +++ b/src/dialogs/homedialog.cpp @@ -76,12 +76,12 @@ void HomeDialog::acceptUrls() void HomeDialog::propagateIcons() { - const QMap map = { + const QHash 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); } diff --git a/src/dialogs/preferencedialog.cpp b/src/dialogs/preferencedialog.cpp index 10083c76..0f5c6faf 100644 --- a/src/dialogs/preferencedialog.cpp +++ b/src/dialogs/preferencedialog.cpp @@ -279,13 +279,13 @@ void PreferenceDialog::restylizeUi() ui->tabWidget->setTabIcon(6, QIcon::fromTheme("preference-advanced")); // Restylize icons - const QMap map = { - {ui->streamHelp, "help"}, - {ui->concurrentFragmentHelp, "help"}, - {ui->httpUserAgentHelp, "help"}, - {ui->httpReferringPageHelp, "help"} + const QHash hash = { + {ui->streamHelp, "help"}, + {ui->concurrentFragmentHelp, "help"}, + {ui->httpUserAgentHelp, "help"}, + {ui->httpReferringPageHelp, "help"} }; - Theme::setIcons(this, map); + Theme::setIcons(this, hash); } /****************************************************************************** diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ac5866c5..6123b2b2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -438,7 +438,7 @@ void MainWindow::propagateToolTips() void MainWindow::propagateIcons() { - const QMap map = { + const QHash hash = { //! [0] File {ui->actionHome , "home"}, @@ -516,7 +516,7 @@ void MainWindow::propagateIcons() // {ui->actionAboutYTDLP , ""} //! [5] }; - Theme::setIcons(this, map); + Theme::setIcons(this, hash); } /****************************************************************************** diff --git a/src/widgets/streamformatpicker.cpp b/src/widgets/streamformatpicker.cpp index 46c8e8a6..4969b117 100644 --- a/src/widgets/streamformatpicker.cpp +++ b/src/widgets/streamformatpicker.cpp @@ -206,13 +206,13 @@ void StreamFormatPicker::onButtonBarClicked() ******************************************************************************/ void StreamFormatPicker::propagateIcons() { - const QMap map = { + const QHash 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); } /****************************************************************************** diff --git a/src/widgets/texteditorwidget.cpp b/src/widgets/texteditorwidget.cpp index 9c2f531b..01079d9b 100644 --- a/src/widgets/texteditorwidget.cpp +++ b/src/widgets/texteditorwidget.cpp @@ -110,7 +110,7 @@ void TextEditorWidget::onBlockModeToggled(bool checked) ******************************************************************************/ void TextEditorWidget::propagateIcons() { - const QMap map = { + const QHash hash = { {ui->editblockmode, "edit-block-mode"}, {ui->editcopy , "edit-copy"}, {ui->editcut , "edit-cut"}, @@ -118,5 +118,5 @@ void TextEditorWidget::propagateIcons() {ui->editredo , "edit-redo"}, {ui->editundo , "edit-undo"} }; - Theme::setIcons(this, map); + Theme::setIcons(this, hash); } diff --git a/test/manual-test/demo/mainwindow.cpp b/test/manual-test/demo/mainwindow.cpp index 6a1bceb8..0f04fe68 100644 --- a/test/manual-test/demo/mainwindow.cpp +++ b/test/manual-test/demo/mainwindow.cpp @@ -166,7 +166,7 @@ void MainWindow::createContextMenu() void MainWindow::propagateIcons() { - const QMap map = { + const QHash hash = { //! [0] File // {ui->actionHome , "home"}, @@ -245,7 +245,7 @@ void MainWindow::propagateIcons() // {ui->actionAboutYoutubeDL , ""} //! [5] }; - Theme::setIcons(this, map); + Theme::setIcons(this, hash); } /****************************************************************************** From 9cc02af413baaef05bdc8a1aa2cc24785783a4a7 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 17 Dec 2023 22:45:30 +0100 Subject: [PATCH 3/4] [Torrent] Replace QMap with QHash in torrent --- src/core/torrentcontext_p.cpp | 2 +- src/core/torrentcontext_p.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/torrentcontext_p.cpp b/src/core/torrentcontext_p.cpp index cf23f8a5..14f588f1 100644 --- a/src/core/torrentcontext_p.cpp +++ b/src/core/torrentcontext_p.cpp @@ -506,7 +506,7 @@ void TorrentContextPrivate::downloadTorrentFile(Torrent *torrent) void TorrentContextPrivate::abortNetworkReply(Torrent *torrent) { - QMapIterator it(m_currentDownloads); + QHashIterator it(m_currentDownloads); while (it.hasNext()) { it.next(); auto currentReply = it.key(); diff --git a/src/core/torrentcontext_p.h b/src/core/torrentcontext_p.h index b0abfa23..3aecf9ff 100644 --- a/src/core/torrentcontext_p.h +++ b/src/core/torrentcontext_p.h @@ -117,8 +117,9 @@ public slots: private slots: void onNetworkReplyFinished(); + private: - QMap m_currentDownloads; + QHash m_currentDownloads; void downloadMagnetLink(Torrent *torrent); void downloadTorrentFile(Torrent *torrent); void abortNetworkReply(Torrent *torrent); From 67c9c2eae909c7eecec28c792091bc0c557772df Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sat, 30 Dec 2023 11:12:30 +0100 Subject: [PATCH 4/4] [Torrent] Fix missing bencode namespace --- src/core/torrentcontext_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/torrentcontext_p.cpp b/src/core/torrentcontext_p.cpp index 14f588f1..9405920a 100644 --- a/src/core/torrentcontext_p.cpp +++ b/src/core/torrentcontext_p.cpp @@ -612,7 +612,7 @@ void TorrentContextPrivate::writeTorrentFileFromMagnet( lt::create_torrent ct(*ti); auto te = ct.generate(); std::vector buffer; - bencode(std::back_inserter(buffer), te); + lt::bencode(std::back_inserter(buffer), te); // Write QByteArray data(&buffer[0], static_cast(buffer.size()));