File indexing completed on 2024-05-05 05:49:28

0001 /*
0002     SPDX-FileCopyrightText: 2010 Volker Lanz <vl@fidra.de>
0003     SPDX-FileCopyrightText: 2014-2020 Andrius Štikonas <andrius@stikonas.eu>
0004 
0005     SPDX-License-Identifier: GPL-3.0-or-later
0006 */
0007 
0008 #include "config/generalpagewidget.h"
0009 
0010 #include <backend/corebackendmanager.h>
0011 #include <fs/filesystemfactory.h>
0012 
0013 #include <util/helpers.h>
0014 #include "util/guihelpers.h"
0015 
0016 #include <utility>
0017 
0018 #include <config.h>
0019 
0020 GeneralPageWidget::GeneralPageWidget(QWidget* parent) :
0021     QWidget(parent)
0022 {
0023     setupUi(this);
0024     setupDialog();
0025 }
0026 
0027 FileSystem::Type GeneralPageWidget::defaultFileSystem() const
0028 {
0029     return FileSystem::typeForName(comboDefaultFileSystem().currentText());
0030 }
0031 
0032 void GeneralPageWidget::setDefaultFileSystem(FileSystem::Type t)
0033 {
0034     const int idx = comboDefaultFileSystem().findText(FileSystem::nameForType(t));
0035     comboDefaultFileSystem().setCurrentIndex(idx != -1 ? idx : 0);
0036 }
0037 
0038 void GeneralPageWidget::setupDialog()
0039 {
0040     QStringList fsNames;
0041     for (const auto &fs : FileSystemFactory::map())
0042         if (fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Type::Extended && fs->type() != FileSystem::Type::Luks)
0043             fsNames.append(fs->name());
0044 
0045     std::sort(fsNames.begin(), fsNames.end(), caseInsensitiveLessThan);
0046 
0047     for (const auto &fsName : std::as_const(fsNames))
0048         comboDefaultFileSystem().addItem(createFileSystemColor(FileSystem::typeForName(fsName), 8), fsName);
0049 
0050     setDefaultFileSystem(GuiHelpers::defaultFileSystem());
0051 
0052     kcfg_shredSource->setId(radioButton, 0);
0053     kcfg_shredSource->setId(radioButton_2, 1);
0054     radioButton->setChecked(Config::shredSource() == Config::EnumShredSource::random);
0055     radioButton_2->setChecked(Config::shredSource() == Config::EnumShredSource::zeros);
0056 }