File indexing completed on 2024-09-15 03:58:32
0001 /* SPDX-FileCopyrightText: 2003-2010 Jesper K. Pedersen <blackie@kde.org> 0002 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 #include "DatabaseBackendPage.h" 0006 0007 #include <MainWindow/DirtyIndicator.h> 0008 #include <kpabase/SettingsData.h> 0009 0010 #include <KLocalizedString> 0011 #include <QCheckBox> 0012 #include <QHBoxLayout> 0013 #include <QLabel> 0014 #include <QSpinBox> 0015 #include <QVBoxLayout> 0016 0017 Settings::DatabaseBackendPage::DatabaseBackendPage(QWidget *parent) 0018 : QWidget(parent) 0019 { 0020 QVBoxLayout *topLayout = new QVBoxLayout(this); 0021 0022 // Compressed index.xml 0023 m_compressedIndexXML = new QCheckBox(i18n("Choose speed over readability for index.xml file"), this); 0024 topLayout->addWidget(m_compressedIndexXML); 0025 connect(m_compressedIndexXML, &QCheckBox::clicked, this, &DatabaseBackendPage::markDirty); 0026 0027 m_compressBackup = new QCheckBox(i18n("Compress backup file"), this); 0028 topLayout->addWidget(m_compressBackup); 0029 0030 // Auto save 0031 QLabel *label = new QLabel(i18n("Auto save every:"), this); 0032 m_autosave = new QSpinBox; 0033 m_autosave->setRange(1, 120); 0034 m_autosave->setSuffix(i18n("min.")); 0035 0036 QHBoxLayout *lay = new QHBoxLayout; 0037 topLayout->addLayout(lay); 0038 lay->addWidget(label); 0039 lay->addWidget(m_autosave); 0040 lay->addStretch(1); 0041 0042 // Backup 0043 lay = new QHBoxLayout; 0044 topLayout->addLayout(lay); 0045 QLabel *backupLabel = new QLabel(i18n("Number of backups to keep:"), this); 0046 lay->addWidget(backupLabel); 0047 0048 m_backupCount = new QSpinBox; 0049 m_backupCount->setRange(-1, 100); 0050 m_backupCount->setSpecialValueText(i18n("Infinite")); 0051 lay->addWidget(m_backupCount); 0052 lay->addStretch(1); 0053 0054 topLayout->addStretch(1); 0055 0056 QString txt; 0057 txt = i18n("<p>KPhotoAlbum is capable of backing up the index.xml file by keeping copies named index.xml~1~ index.xml~2~ etc. " 0058 "and you can use the spinbox to specify the number of backup files to keep. " 0059 "KPhotoAlbum will delete the oldest backup file when it reaches " 0060 "the maximum number of backup files.</p>" 0061 "<p>The index.xml file may grow substantially if you have many images, and in that case it is useful to ask KPhotoAlbum to zip " 0062 "the backup files to preserve disk space.</p>"); 0063 backupLabel->setWhatsThis(txt); 0064 m_backupCount->setWhatsThis(txt); 0065 m_compressBackup->setWhatsThis(txt); 0066 0067 txt = i18n("<p>KPhotoAlbum is using a single index.xml file as its <i>data base</i>. With lots of images it may take " 0068 "a long time to read this file. You may cut down this time to approximately half, by checking this check box. " 0069 "The disadvantage is that the index.xml file is less readable by human eyes.</p>"); 0070 m_compressedIndexXML->setWhatsThis(txt); 0071 } 0072 0073 void Settings::DatabaseBackendPage::loadSettings(Settings::SettingsData *opt) 0074 { 0075 m_compressedIndexXML->setChecked(opt->useCompressedIndexXML()); 0076 m_autosave->setValue(opt->autoSave()); 0077 m_backupCount->setValue(opt->backupCount()); 0078 m_compressBackup->setChecked(opt->compressBackup()); 0079 } 0080 0081 void Settings::DatabaseBackendPage::saveSettings(Settings::SettingsData *opt) 0082 { 0083 opt->setBackupCount(m_backupCount->value()); 0084 opt->setCompressBackup(m_compressBackup->isChecked()); 0085 opt->setUseCompressedIndexXML(m_compressedIndexXML->isChecked()); 0086 opt->setAutoSave(m_autosave->value()); 0087 } 0088 0089 void Settings::DatabaseBackendPage::markDirty() 0090 { 0091 MainWindow::DirtyIndicator::markDirty(); 0092 } 0093 // vi:expandtab:tabstop=4 shiftwidth=4: 0094 0095 #include "moc_DatabaseBackendPage.cpp"