mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
Cache redirects properly by implementing our own QSettings cache for urls. (#5186)
* Cache redirects properly by implementing our own QSettings cache for urls. * Load and store redirects properly. * Set the maximum network cache size from settings value on PictureLoaderWorker instantiation. * Address comments. * Lint. * Adjust debug statements to be in line with existing ones. * Minor Tweaks * Make redirect cache ttl a user-adjustable setting. * Fix Build * Minor Cleanup * Minor Cleanup * Build Fix --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de> Co-authored-by: ZeldaZach <zahalpern+github@gmail.com>
This commit is contained in:
parent
1bc92623dc
commit
83409c32c4
8 changed files with 178 additions and 16 deletions
|
|
@ -629,11 +629,22 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
|
|||
networkCacheEdit.setValue(SettingsCache::instance().getNetworkCacheSizeInMB());
|
||||
networkCacheEdit.setSuffix(" MB");
|
||||
|
||||
networkRedirectCacheTtlEdit.setMinimum(NETWORK_REDIRECT_CACHE_TTL_MIN);
|
||||
networkRedirectCacheTtlEdit.setMaximum(NETWORK_REDIRECT_CACHE_TTL_MAX);
|
||||
networkRedirectCacheTtlEdit.setSingleStep(1);
|
||||
networkRedirectCacheTtlEdit.setValue(SettingsCache::instance().getRedirectCacheTtl());
|
||||
networkRedirectCacheTtlEdit.setSuffix(" " + tr("Day(s)"));
|
||||
|
||||
auto networkCacheLayout = new QHBoxLayout;
|
||||
networkCacheLayout->addStretch();
|
||||
networkCacheLayout->addWidget(&networkCacheLabel);
|
||||
networkCacheLayout->addWidget(&networkCacheEdit);
|
||||
|
||||
auto networkRedirectCacheLayout = new QHBoxLayout;
|
||||
networkRedirectCacheLayout->addStretch();
|
||||
networkRedirectCacheLayout->addWidget(&networkRedirectCacheTtlLabel);
|
||||
networkRedirectCacheLayout->addWidget(&networkRedirectCacheTtlEdit);
|
||||
|
||||
auto pixmapCacheLayout = new QHBoxLayout;
|
||||
pixmapCacheLayout->addStretch();
|
||||
pixmapCacheLayout->addWidget(&pixmapCacheLabel);
|
||||
|
|
@ -645,8 +656,9 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
|
|||
lpGeneralGrid->addLayout(messageListLayout, 1, 0, 1, 2);
|
||||
lpGeneralGrid->addLayout(networkCacheLayout, 2, 0, 1, 2);
|
||||
lpGeneralGrid->addLayout(pixmapCacheLayout, 3, 0, 1, 2);
|
||||
lpGeneralGrid->addWidget(&urlLinkLabel, 4, 0);
|
||||
lpGeneralGrid->addWidget(&clearDownloadedPicsButton, 4, 1);
|
||||
lpGeneralGrid->addLayout(networkRedirectCacheLayout, 4, 0, 1, 2);
|
||||
lpGeneralGrid->addWidget(&urlLinkLabel, 5, 0);
|
||||
lpGeneralGrid->addWidget(&clearDownloadedPicsButton, 5, 1);
|
||||
|
||||
// Spoiler Layout
|
||||
lpSpoilerGrid->addWidget(&mcDownloadSpoilersCheckBox, 0, 0);
|
||||
|
|
@ -657,13 +669,15 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
|
|||
lpSpoilerGrid->addWidget(updateNowButton, 2, 1);
|
||||
lpSpoilerGrid->addWidget(&infoOnSpoilersLabel, 3, 0, 1, 3, Qt::AlignTop);
|
||||
|
||||
// On a change to the check box, hide/unhide the other fields
|
||||
// On a change to the checkbox, hide/un-hide the other fields
|
||||
connect(&mcDownloadSpoilersCheckBox, SIGNAL(toggled(bool)), &SettingsCache::instance(),
|
||||
SLOT(setDownloadSpoilerStatus(bool)));
|
||||
connect(&mcDownloadSpoilersCheckBox, SIGNAL(toggled(bool)), this, SLOT(setSpoilersEnabled(bool)));
|
||||
connect(&pixmapCacheEdit, SIGNAL(valueChanged(int)), &SettingsCache::instance(), SLOT(setPixmapCacheSize(int)));
|
||||
connect(&networkCacheEdit, SIGNAL(valueChanged(int)), &SettingsCache::instance(),
|
||||
SLOT(setNetworkCacheSizeInMB(int)));
|
||||
connect(&networkRedirectCacheTtlEdit, SIGNAL(valueChanged(int)), &SettingsCache::instance(),
|
||||
SLOT(setNetworkRedirectCacheTtl(int)));
|
||||
|
||||
mpGeneralGroupBox = new QGroupBox;
|
||||
mpGeneralGroupBox->setLayout(lpGeneralGrid);
|
||||
|
|
@ -844,9 +858,11 @@ void DeckEditorSettingsPage::retranslateUi()
|
|||
urlLinkLabel.setText(QString("<a href='%1'>%2</a>").arg(WIKI_CUSTOM_PIC_URL).arg(tr("How to add a custom URL")));
|
||||
clearDownloadedPicsButton.setText(tr("Delete Downloaded Images"));
|
||||
resetDownloadURLs.setText(tr("Reset Download URLs"));
|
||||
networkCacheLabel.setText(tr("Downloaded images directory size:"));
|
||||
networkCacheLabel.setText(tr("Network Cache Size:"));
|
||||
networkCacheEdit.setToolTip(tr("On-disk cache for downloaded pictures"));
|
||||
pixmapCacheLabel.setText(tr("Picture cache size:"));
|
||||
networkRedirectCacheTtlLabel.setText(tr("Redirect Cache TTL:"));
|
||||
networkRedirectCacheTtlEdit.setToolTip(tr("How long cached redirects for urls are valid for."));
|
||||
pixmapCacheLabel.setText(tr("Picture Cache Size:"));
|
||||
pixmapCacheEdit.setToolTip(tr("In-memory cache for pictures not currently on screen"));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue