diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-10-18 15:25:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-18 15:25:56 +0200 |
commit | 98963d4cdf94b173c68bb7c67feb68f6a73d4495 (patch) | |
tree | 53d2bd39bf584874736394db4bca2d99652a52b5 | |
parent | 804ef36b203e7346ba9cf8496ee1aae26d3a5f18 (diff) | |
parent | 71f3c6b461eb296a3d1604e3534c9a4ab3d43397 (diff) | |
download | PrismLauncher-98963d4cdf94b173c68bb7c67feb68f6a73d4495.tar.gz PrismLauncher-98963d4cdf94b173c68bb7c67feb68f6a73d4495.tar.bz2 PrismLauncher-98963d4cdf94b173c68bb7c67feb68f6a73d4495.zip |
Merge pull request #29 from Scrumplex/feat-clear-metadata
-rw-r--r-- | launcher/net/HttpMetaCache.cpp | 12 | ||||
-rw-r--r-- | launcher/net/HttpMetaCache.h | 1 | ||||
-rw-r--r-- | launcher/ui/MainWindow.cpp | 17 | ||||
-rw-r--r-- | launcher/ui/MainWindow.h | 2 |
4 files changed, 32 insertions, 0 deletions
diff --git a/launcher/net/HttpMetaCache.cpp b/launcher/net/HttpMetaCache.cpp index 9606ddb6..42198b71 100644 --- a/launcher/net/HttpMetaCache.cpp +++ b/launcher/net/HttpMetaCache.cpp @@ -162,6 +162,18 @@ auto HttpMetaCache::evictEntry(MetaEntryPtr entry) -> bool return true; } +void HttpMetaCache::evictAll() +{ + for (QString& base : m_entries.keys()) { + EntryMap& map = m_entries[base]; + qDebug() << "Evicting base" << base; + for (MetaEntryPtr entry : map.entry_list) { + if (!evictEntry(entry)) + qWarning() << "Unexpected missing cache entry" << entry->basePath; + } + } +} + auto HttpMetaCache::staleEntry(QString base, QString resource_path) -> MetaEntryPtr { auto foo = new MetaEntry(); diff --git a/launcher/net/HttpMetaCache.h b/launcher/net/HttpMetaCache.h index c0b12318..2a07d65a 100644 --- a/launcher/net/HttpMetaCache.h +++ b/launcher/net/HttpMetaCache.h @@ -113,6 +113,7 @@ class HttpMetaCache : public QObject { // evict selected entry from cache auto evictEntry(MetaEntryPtr entry) -> bool; + void evictAll(); void addBase(QString base, QString base_root); diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 51de1c48..12a3cb2e 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -258,6 +258,7 @@ public: QMenu * helpMenu = nullptr; TranslatedToolButton helpMenuButton; + TranslatedAction actionClearMetadata; TranslatedAction actionReportBug; TranslatedAction actionDISCORD; TranslatedAction actionMATRIX; @@ -347,6 +348,13 @@ public: actionUndoTrashInstance->setShortcut(QKeySequence("Ctrl+Z")); all_actions.append(&actionUndoTrashInstance); + actionClearMetadata = TranslatedAction(MainWindow); + actionClearMetadata->setObjectName(QStringLiteral("actionClearMetadata")); + actionClearMetadata->setIcon(APPLICATION->getThemedIcon("refresh")); + actionClearMetadata.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Clear Metadata Cache")); + actionClearMetadata.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Clear cached metadata")); + all_actions.append(&actionClearMetadata); + if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) { actionReportBug = TranslatedAction(MainWindow); actionReportBug->setObjectName(QStringLiteral("actionReportBug")); @@ -445,6 +453,8 @@ public: helpMenu = new QMenu(MainWindow); helpMenu->setToolTipsVisible(true); + helpMenu->addAction(actionClearMetadata); + if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) { helpMenu->addAction(actionReportBug); } @@ -537,6 +547,8 @@ public: helpMenu = menuBar->addMenu(tr("&Help")); helpMenu->setSeparatorsCollapsible(false); + helpMenu->addAction(actionClearMetadata); + helpMenu->addSeparator(); helpMenu->addAction(actionAbout); helpMenu->addAction(actionOpenWiki); helpMenu->addAction(actionNewsMenuBar); @@ -1967,6 +1979,11 @@ void MainWindow::on_actionReportBug_triggered() DesktopServices::openUrl(QUrl(BuildConfig.BUG_TRACKER_URL)); } +void MainWindow::on_actionClearMetadata_triggered() +{ + APPLICATION->metacache()->evictAll(); +} + void MainWindow::on_actionOpenWiki_triggered() { DesktopServices::openUrl(QUrl(BuildConfig.HELP_URL.arg(""))); diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index 8b41bf94..d01f0448 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -130,6 +130,8 @@ private slots: void on_actionReportBug_triggered(); + void on_actionClearMetadata_triggered(); + void on_actionOpenWiki_triggered(); void on_actionMoreNews_triggered(); |