add button to clear web cache and storage - in Tools menu
This commit is contained in:
parent
0891600884
commit
df7e9109b1
@ -638,6 +638,7 @@ void FormMain::setupIcons() {
|
|||||||
m_ui->m_actionTabsPrevious->setIcon(icon_theme_factory->fromTheme(QSL("go-previous")));
|
m_ui->m_actionTabsPrevious->setIcon(icon_theme_factory->fromTheme(QSL("go-previous")));
|
||||||
m_ui->m_actionBrowserScrollUp->setIcon(icon_theme_factory->fromTheme(QSL("arrow-up")));
|
m_ui->m_actionBrowserScrollUp->setIcon(icon_theme_factory->fromTheme(QSL("arrow-up")));
|
||||||
m_ui->m_actionBrowserScrollDown->setIcon(icon_theme_factory->fromTheme(QSL("arrow-down")));
|
m_ui->m_actionBrowserScrollDown->setIcon(icon_theme_factory->fromTheme(QSL("arrow-down")));
|
||||||
|
m_ui->m_actionCleanupWebCache->setIcon(icon_theme_factory->fromTheme(QSL("edit-clear")));
|
||||||
|
|
||||||
// Setup icons on TabWidget too.
|
// Setup icons on TabWidget too.
|
||||||
m_ui->m_tabWidget->setupIcons();
|
m_ui->m_tabWidget->setupIcons();
|
||||||
@ -759,6 +760,12 @@ void FormMain::createConnections() {
|
|||||||
connect(m_ui->m_actionDownloadManager, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::showDownloadManager);
|
connect(m_ui->m_actionDownloadManager, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::showDownloadManager);
|
||||||
connect(m_ui->m_actionCleanupDatabase, &QAction::triggered, this, &FormMain::showDbCleanupAssistant);
|
connect(m_ui->m_actionCleanupDatabase, &QAction::triggered, this, &FormMain::showDbCleanupAssistant);
|
||||||
|
|
||||||
|
#if defined(USE_WEBENGINE)
|
||||||
|
connect(m_ui->m_actionCleanupWebCache, &QAction::triggered, qApp->web(), &WebFactory::cleanupCache);
|
||||||
|
#else
|
||||||
|
m_ui->m_menuTools->removeAction(m_ui->m_actionCleanupWebCache);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Menu "Help" connections.
|
// Menu "Help" connections.
|
||||||
connect(m_ui->m_actionAboutGuard, &QAction::triggered, this, [this]() {
|
connect(m_ui->m_actionAboutGuard, &QAction::triggered, this, [this]() {
|
||||||
FormAbout(this).exec();
|
FormAbout(this).exec();
|
||||||
|
@ -97,6 +97,7 @@
|
|||||||
<addaction name="m_actionSettings"/>
|
<addaction name="m_actionSettings"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="m_actionCleanupDatabase"/>
|
<addaction name="m_actionCleanupDatabase"/>
|
||||||
|
<addaction name="m_actionCleanupWebCache"/>
|
||||||
<addaction name="m_actionDownloadManager"/>
|
<addaction name="m_actionDownloadManager"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="m_menuFeeds">
|
<widget class="QMenu" name="m_menuFeeds">
|
||||||
@ -931,6 +932,11 @@
|
|||||||
<string>Rearrange &feeds alphabetically</string>
|
<string>Rearrange &feeds alphabetically</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="m_actionCleanupWebCache">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cleanup web cac&he</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
@ -1002,10 +1002,10 @@ void FeedsView::onItemExpandRequested(const QList<RootItem*>& items, bool exp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::drawRow(QPainter* painter, const QStyleOptionViewItem& options, const QModelIndex& index) const {
|
void FeedsView::drawRow(QPainter* painter, const QStyleOptionViewItem& options, const QModelIndex& index) const {
|
||||||
// auto opts = options;
|
auto opts = options;
|
||||||
|
|
||||||
// opts.decorationAlignment = Qt::AlignmentFlag::AlignLeft;
|
opts.decorationAlignment = Qt::AlignmentFlag::AlignLeft;
|
||||||
// opts.decorationSize = {options.decorationSize.height(), options.decorationSize.height()};
|
// opts.decorationSize = {options.decorationSize.height(), 70};
|
||||||
|
|
||||||
BaseTreeView::drawRow(painter, options, index);
|
BaseTreeView::drawRow(painter, opts, index);
|
||||||
}
|
}
|
||||||
|
@ -178,3 +178,8 @@ bool IOFactory::copyFile(const QString& source, const QString& destination) {
|
|||||||
|
|
||||||
return QFile::copy(source, destination);
|
return QFile::copy(source, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IOFactory::removeFolder(const QString& path) {
|
||||||
|
QDir dir(path);
|
||||||
|
dir.removeRecursively();
|
||||||
|
}
|
||||||
|
@ -48,6 +48,8 @@ class IOFactory {
|
|||||||
|
|
||||||
// Copies file, overwrites destination.
|
// Copies file, overwrites destination.
|
||||||
static bool copyFile(const QString& source, const QString& destination);
|
static bool copyFile(const QString& source, const QString& destination);
|
||||||
|
|
||||||
|
static void removeFolder(const QString& path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IOFACTORY_H
|
#endif // IOFACTORY_H
|
||||||
|
@ -673,3 +673,26 @@ QString WebFactory::customUserAgent() const {
|
|||||||
void WebFactory::setCustomUserAgent(const QString& user_agent) {
|
void WebFactory::setCustomUserAgent(const QString& user_agent) {
|
||||||
m_customUserAgent = user_agent;
|
m_customUserAgent = user_agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_WEBENGINE)
|
||||||
|
void WebFactory::cleanupCache() {
|
||||||
|
if (MsgBox::show(nullptr,
|
||||||
|
QMessageBox::Icon::Question,
|
||||||
|
tr("Web cache is going to be cleared"),
|
||||||
|
tr("Do you really want to clear web cache?"),
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No) ==
|
||||||
|
QMessageBox::StandardButton::Yes) {
|
||||||
|
m_engineProfile->clearHttpCache();
|
||||||
|
|
||||||
|
// NOTE: Manually clear storage.
|
||||||
|
try {
|
||||||
|
IOFactory::removeFolder(m_engineProfile->persistentStoragePath());
|
||||||
|
}
|
||||||
|
catch (const ApplicationException& ex) {
|
||||||
|
qCriticalNN << LOGSEC_CORE << "Removing of webengine storage failed:" << QUOTE_W_SPACE_DOT(ex.message());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -58,6 +58,11 @@ class WebFactory : public QObject {
|
|||||||
QString customUserAgent() const;
|
QString customUserAgent() const;
|
||||||
void setCustomUserAgent(const QString& user_agent);
|
void setCustomUserAgent(const QString& user_agent);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
#if defined(USE_WEBENGINE)
|
||||||
|
void cleanupCache();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(USE_WEBENGINE)
|
#if defined(USE_WEBENGINE)
|
||||||
private slots:
|
private slots:
|
||||||
void createMenu(QMenu* menu = nullptr);
|
void createMenu(QMenu* menu = nullptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user