Setting RAID configuration file path through GUI.
This commit is contained in:
parent
863e7cafaa
commit
7b1ca5fe72
|
@ -1,6 +1,7 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* Copyright (C) 2018 by Caio Carvalho <caiojcarvalho@gmail.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -22,16 +23,23 @@
|
|||
#include <util/helpers.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <KPluginMetaData>
|
||||
|
||||
#include <config.h>
|
||||
#include <kpmcore/core/softwareraid.h>
|
||||
|
||||
AdvancedPageWidget::AdvancedPageWidget(QWidget* parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
setupDialog();
|
||||
|
||||
raidConfigFilePath->clear();
|
||||
raidConfigFilePath->insert(SoftwareRAID::raidConfigurationFilePath());
|
||||
|
||||
connect(selectRaidFileButton, &QPushButton::clicked, this, &AdvancedPageWidget::searchForRaidConfigFile);
|
||||
}
|
||||
|
||||
QString AdvancedPageWidget::backend() const
|
||||
|
@ -60,3 +68,28 @@ void AdvancedPageWidget::setupDialog()
|
|||
|
||||
setBackend(Config::backend());
|
||||
}
|
||||
|
||||
QString AdvancedPageWidget::raidConfigurationFile() const
|
||||
{
|
||||
return raidConfigFilePath->text();
|
||||
}
|
||||
|
||||
void AdvancedPageWidget::searchForRaidConfigFile()
|
||||
{
|
||||
QPointer<QFileDialog> dialog = new QFileDialog(this, QStringLiteral("Select Software RAID configuration file"),
|
||||
QStringLiteral("/"));
|
||||
|
||||
dialog->setFileMode(QFileDialog::FileMode::ExistingFile);
|
||||
dialog->setNameFilter(QStringLiteral("Configuration files (*.conf)"));
|
||||
|
||||
auto updateConfig = [this](const QString& file){
|
||||
if (!file.isEmpty()) {
|
||||
raidConfigFilePath->clear();
|
||||
raidConfigFilePath->insert(file);
|
||||
}
|
||||
};
|
||||
|
||||
connect(dialog, &QFileDialog::fileSelected, updateConfig);
|
||||
|
||||
dialog->exec();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* Copyright (C) 2018 by Caio Carvalho <caiojcarvalho@gmail.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -45,6 +46,11 @@ public:
|
|||
QString backend() const;
|
||||
void setBackend(const QString& name);
|
||||
|
||||
QString raidConfigurationFile() const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void searchForRaidConfigFile();
|
||||
|
||||
private:
|
||||
void setupDialog();
|
||||
};
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <QIcon>
|
||||
|
||||
#include <config.h>
|
||||
#include <kpmcore/core/softwareraid.h>
|
||||
|
||||
ConfigureOptionsDialog::ConfigureOptionsDialog(QWidget* parent, const OperationStack& ostack, const QString& name) :
|
||||
KConfigDialog(parent, name, Config::self()),
|
||||
|
@ -100,6 +101,9 @@ void ConfigureOptionsDialog::updateSettings()
|
|||
changed = true;
|
||||
}
|
||||
|
||||
if (advancedPageWidget().raidConfigurationFile() != SoftwareRAID::raidConfigurationFilePath())
|
||||
SoftwareRAID::setRaidConfigurationFilePath(advancedPageWidget().raidConfigurationFile());
|
||||
|
||||
if (changed)
|
||||
emit KConfigDialog::settingsChanged(i18n("General Settings"));
|
||||
}
|
||||
|
|
|
@ -6,12 +6,18 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>449</width>
|
||||
<width>511</width>
|
||||
<height>420</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>420</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -26,7 +32,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Active backend:</string>
|
||||
<string>Acti&ve backend:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_ComboBackend</cstring>
|
||||
|
@ -39,7 +45,47 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Software RAID configuration</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Configuration file:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>raidConfigFilePath</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="raidConfigFilePath">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="selectRaidFileButton">
|
||||
<property name="text">
|
||||
<string>Select File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -50,11 +96,11 @@
|
|||
<property name="title">
|
||||
<string>Units</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Preferred unit:</string>
|
||||
<string>Preferred &unit:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_ComboBackend</cstring>
|
||||
|
|
Loading…
Reference in New Issue