2015-02-07 00:32:25 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* Copyright (C) 2008, 2010 by Volker Lanz <vl@fidra.de> *
|
2016-03-02 18:33:40 +00:00
|
|
|
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
2015-02-07 00:32:25 +00:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
|
|
*************************************************************************/
|
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>
|
|
|
|
|
2015-04-09 21:26:40 +01:00
|
|
|
#include <KIconLoader>
|
2014-05-13 23:53:37 +01:00
|
|
|
#include <KLocalizedString>
|
2014-05-17 03:06:58 +01:00
|
|
|
#include <KConfigGroup>
|
|
|
|
#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()
|
|
|
|
{
|
2015-07-13 15:17:41 +01:00
|
|
|
QIcon yes = QIcon::fromTheme(QStringLiteral("dialog-ok")).pixmap(IconSize(KIconLoader::Toolbar));
|
|
|
|
QIcon no = QIcon::fromTheme(QStringLiteral("dialog-error")).pixmap(IconSize(KIconLoader::Toolbar));
|
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
|
|
|
|
2015-07-13 15:17:41 +01:00
|
|
|
foreach(const FileSystem * fs, FileSystemFactory::map()) {
|
2016-05-17 15:30:57 +01:00
|
|
|
if (fs->type() == FileSystem::Unknown || fs->type() == FileSystem::Extended || fs->type() == FileSystem::Luks)
|
2015-07-13 15:17:41 +01:00
|
|
|
continue;
|
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
|
|
|
}
|