MCPcopy Create free account
hub / github.com/alpha-liu-01/SpeedyNote / createCacheTab

Method createCacheTab

source/ControlPanelDialog.cpp:1843–1946  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1841}
1842
1843void ControlPanelDialog::createCacheTab() {
1844 cacheTab = new QWidget(this);
1845 QVBoxLayout *layout = new QVBoxLayout(cacheTab);
1846
1847 // Add some spacing at the top
1848 layout->addSpacing(20);
1849
1850 // Title
1851 QLabel *titleLabel = new QLabel(tr("Cache Management"), cacheTab);
1852 titleLabel->setAlignment(Qt::AlignCenter);
1853 titleLabel->setStyleSheet("font-size: 18px; font-weight: bold;");
1854 layout->addWidget(titleLabel);
1855
1856 layout->addSpacing(10);
1857
1858 // Description
1859 QLabel *descriptionLabel = new QLabel(
1860 tr("SpeedyNote uses temporary folders to work with notebook files.\n"
1861 "These folders are normally cleaned up when you close a notebook,\n"
1862 "but crashes or force-close can leave orphaned files behind."),
1863 cacheTab
1864 );
1865 descriptionLabel->setAlignment(Qt::AlignCenter);
1866 descriptionLabel->setWordWrap(true);
1867 descriptionLabel->setStyleSheet("font-size: 11px; color: #7f8c8d; padding: 0 20px;");
1868 layout->addWidget(descriptionLabel);
1869
1870 layout->addSpacing(20);
1871
1872 // Show cache size
1873 // Phase P.1: SpnPackageManager removed - cache management will be reimplemented in NotebookLibrary
1874 qint64 cacheSize = 0; // TODO: Implement with NotebookLibrary::getTempDirsTotalSize()
1875 QString cacheSizeText = QString::number(cacheSize / 1024.0 / 1024.0, 'f', 2) + " MB";
1876 QLabel *cacheSizeLabel = new QLabel(tr("Current cache size: %1").arg(cacheSizeText), cacheTab);
1877 cacheSizeLabel->setAlignment(Qt::AlignCenter);
1878 cacheSizeLabel->setStyleSheet("font-size: 16px; font-weight: bold;");
1879 layout->addWidget(cacheSizeLabel);
1880
1881 layout->addSpacing(5);
1882
1883 // Location info
1884 QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
1885 QLabel *locationLabel = new QLabel(tr("Location: %1").arg(tempPath), cacheTab);
1886 locationLabel->setAlignment(Qt::AlignCenter);
1887 locationLabel->setStyleSheet("font-size: 9px; color: #95a5a6; font-style: italic;");
1888 locationLabel->setWordWrap(true);
1889 layout->addWidget(locationLabel);
1890
1891 layout->addSpacing(30);
1892
1893 // Clear cache button
1894 QPushButton *clearCacheButton = new QPushButton(tr("Clear Cache Now"), cacheTab);
1895 clearCacheButton->setFixedSize(180, 40);
1896 clearCacheButton->setStyleSheet("font-size: 13px; font-weight: bold; padding: 8px;");
1897
1898 connect(clearCacheButton, &QPushButton::clicked, [this, cacheSizeLabel]() {
1899 // ✅ DISK CLEANUP: Warn user to close notebooks first
1900 QMessageBox::StandardButton reply = QMessageBox::question(

Callers

nothing calls this directly

Calls 4

connectFunction · 0.85
addWidgetMethod · 0.80
setTextMethod · 0.45
addStretchMethod · 0.45

Tested by

no test coverage detected