2020-09-16 00:35:12 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2010 Volker Lanz <vl@fidra.de>
|
|
|
|
SPDX-FileCopyrightText: 2014-2020 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2008-09-24 20:32:01 +01:00
|
|
|
|
|
|
|
#include "gui/filesystemsupportdialog.h"
|
2010-05-20 17:09:29 +01:00
|
|
|
#include "gui/filesystemsupportdialogwidget.h"
|
2008-09-24 20:32:01 +01:00
|
|
|
|
2016-01-12 00:12:49 +00:00
|
|
|
#include <fs/filesystem.h>
|
|
|
|
#include <fs/filesystemfactory.h>
|
2008-09-24 20:32:01 +01:00
|
|
|
|
2014-05-17 03:06:58 +01:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QDialog>
|
|
|
|
|
2016-08-23 16:40:16 +01:00
|
|
|
#include <KConfigGroup>
|
2014-05-13 23:53:37 +01:00
|
|
|
#include <KLocalizedString>
|
2014-05-17 03:06:58 +01:00
|
|
|
#include <KSharedConfig>
|
2008-09-24 20:32:01 +01:00
|
|
|
|
|
|
|
/** Creates a new FileSystemSupportDialog
|
2015-07-13 15:17:41 +01:00
|
|
|
@param parent the parent object
|
2008-09-24 20:32:01 +01:00
|
|
|
*/
|
|
|
|
FileSystemSupportDialog::FileSystemSupportDialog(QWidget* parent) :
|
2015-07-13 15:17:41 +01:00
|
|
|
QDialog(parent),
|
|
|
|
m_FileSystemSupportDialogWidget(new FileSystemSupportDialogWidget(this))
|
2008-09-24 20:32:01 +01:00
|
|
|
{
|
2015-07-13 15:17:41 +01:00
|
|
|
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
|
|
|
setLayout(mainLayout);
|
|
|
|
mainLayout->addWidget(&dialogWidget());
|
2016-07-18 02:21:14 +01:00
|
|
|
setWindowTitle(xi18nc("@title:window", "File System Support"));
|
2015-07-13 15:17:41 +01:00
|
|
|
dialogButtonBox = new QDialogButtonBox(this);
|
|
|
|
dialogButtonBox -> setStandardButtons(QDialogButtonBox::Ok);
|
|
|
|
mainLayout->addWidget(dialogButtonBox);
|
|
|
|
|
|
|
|
setupDialog();
|
|
|
|
setupConnections();
|
|
|
|
|
|
|
|
KConfigGroup kcg(KSharedConfig::openConfig(), "fileSystemSupportDialog");
|
|
|
|
restoreGeometry(kcg.readEntry<QByteArray>("Geometry", QByteArray()));
|
2008-09-24 20:32:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Destroys a FileSystemSupportDialog */
|
|
|
|
FileSystemSupportDialog::~FileSystemSupportDialog()
|
|
|
|
{
|
2015-07-13 15:17:41 +01:00
|
|
|
KConfigGroup kcg(KSharedConfig::openConfig(), "fileSystemSupportDialog");
|
|
|
|
kcg.writeEntry("Geometry", saveGeometry());
|
2008-09-24 20:32:01 +01:00
|
|
|
}
|
|
|
|
|
2010-01-18 13:46:45 +00:00
|
|
|
QSize FileSystemSupportDialog::sizeHint() const
|
|
|
|
{
|
2015-07-13 15:17:41 +01:00
|
|
|
return QSize(690, 490);
|
2010-01-18 13:46:45 +00:00
|
|
|
}
|
|
|
|
|
2008-09-24 20:32:01 +01:00
|
|
|
void FileSystemSupportDialog::setupDialog()
|
|
|
|
{
|
2020-09-29 17:54:53 +01:00
|
|
|
QIcon yes = QIcon::fromTheme(QStringLiteral("dialog-ok"));
|
|
|
|
QIcon no = QIcon::fromTheme(QStringLiteral("dialog-error"));
|
2008-09-24 20:32:01 +01:00
|
|
|
|
2015-07-13 15:17:41 +01:00
|
|
|
dialogWidget().tree().clear();
|
2008-09-24 20:32:01 +01:00
|
|
|
|
2016-08-09 14:57:33 +01:00
|
|
|
for (const auto &fs : FileSystemFactory::map()) {
|
2018-04-07 19:54:55 +01:00
|
|
|
if (fs->type() == FileSystem::Type::Unknown || fs->type() == FileSystem::Type::Extended ||
|
|
|
|
fs->type() == FileSystem::Type::Luks || fs->type() == FileSystem::Type::Luks2) {
|
2015-07-13 15:17:41 +01:00
|
|
|
continue;
|
2017-12-28 00:53:45 +00:00
|
|
|
}
|
2008-09-24 20:32:01 +01:00
|
|
|
|
2015-07-13 15:17:41 +01:00
|
|
|
QTreeWidgetItem* item = new QTreeWidgetItem();
|
2008-09-24 20:32:01 +01:00
|
|
|
|
2015-07-13 15:17:41 +01:00
|
|
|
int i = 0;
|
|
|
|
item->setText(i++, fs->name());
|
|
|
|
item->setIcon(i++, fs->supportCreate() ? yes : no);
|
|
|
|
item->setIcon(i++, fs->supportGrow() ? yes : no);
|
|
|
|
item->setIcon(i++, fs->supportShrink() ? yes : no);
|
|
|
|
item->setIcon(i++, fs->supportMove() ? yes : no);
|
|
|
|
item->setIcon(i++, fs->supportCopy() ? yes : no);
|
|
|
|
item->setIcon(i++, fs->supportCheck() ? yes : no);
|
|
|
|
item->setIcon(i++, fs->supportGetLabel() ? yes : no);
|
|
|
|
item->setIcon(i++, fs->supportSetLabel() ? yes : no);
|
|
|
|
item->setIcon(i++, fs->supportGetUsed() ? yes : no);
|
|
|
|
item->setIcon(i++, fs->supportBackup() ? yes : no);
|
2008-09-24 20:32:01 +01:00
|
|
|
|
2015-07-13 15:17:41 +01:00
|
|
|
// there is no FileSystem::supportRestore(), because we currently can't tell
|
|
|
|
// if a file is an image of a supported or unsupported (or even invalid) filesystem
|
|
|
|
item->setIcon(i++, yes);
|
2008-09-24 20:32:01 +01:00
|
|
|
|
2015-07-13 15:17:41 +01:00
|
|
|
item->setText(i++, fs->supportToolName().name.isEmpty() ? QStringLiteral("---") : fs->supportToolName().name);
|
2010-05-20 16:25:55 +01:00
|
|
|
|
2015-07-13 15:17:41 +01:00
|
|
|
dialogWidget().tree().addTopLevelItem(item);
|
|
|
|
}
|
2008-09-24 20:32:01 +01:00
|
|
|
|
2015-07-13 15:17:41 +01:00
|
|
|
for (int i = 0; i < dialogWidget().tree().columnCount(); i++)
|
|
|
|
dialogWidget().tree().resizeColumnToContents(i);
|
2008-09-24 20:32:01 +01:00
|
|
|
|
2015-07-13 15:17:41 +01:00
|
|
|
dialogWidget().tree().sortItems(0, Qt::AscendingOrder);
|
2008-09-24 20:32:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FileSystemSupportDialog::setupConnections()
|
|
|
|
{
|
2016-05-18 22:23:59 +01:00
|
|
|
connect(dialogButtonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &FileSystemSupportDialog::close);
|
2016-05-22 20:03:49 +01:00
|
|
|
connect(&dialogWidget().buttonRescan(), &QPushButton::clicked, this, &FileSystemSupportDialog::onButtonRescanClicked);
|
2008-09-24 20:32:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FileSystemSupportDialog::onButtonRescanClicked()
|
|
|
|
{
|
2015-07-13 15:17:41 +01:00
|
|
|
FileSystemFactory::init();
|
|
|
|
setupDialog();
|
2008-09-24 20:32:01 +01:00
|
|
|
}
|