Merge branch 'master' into kauth

This commit is contained in:
Andrius Štikonas 2018-03-31 20:29:15 +01:00
commit b38db099e0
6 changed files with 286 additions and 271 deletions

View File

@ -144,6 +144,8 @@ void ApplyProgressDialog::show()
dialogWidget().treeTasks().clear();
okButton->setVisible(false);
cancelButton->setVisible(true);
cancelButton->setEnabled(true);
timer().start(1000);
time().start();
@ -194,24 +196,21 @@ void ApplyProgressDialog::onCancelButton()
if (operationRunner().isCancelling())
return;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
cancelButton->setEnabled(false);
setStatus(xi18nc("@info:progress", "Waiting for operation to finish..."));
repaint();
dialogWidget().repaint();
// suspend the runner, so it doesn't happily carry on while the user decides
// if he really wants to cancel
operationRunner().suspendMutex().lock();
cancelButton->setEnabled(true);
QApplication::restoreOverrideCursor();
if (KMessageBox::questionYesNo(this, xi18nc("@info", "Do you really want to cancel?"), xi18nc("@title:window", "Cancel Running Operations"), KGuiItem(xi18nc("@action:button", "Yes, Cancel Operations"), QStringLiteral("dialog-ok")), KStandardGuiItem::no()) == KMessageBox::Yes)
// in the meantime while we were showing the messagebox, the runner might have finished.
if (operationRunner().isRunning())
if (operationRunner().isRunning()) {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
cancelButton->setEnabled(false);
setStatus(xi18nc("@info:progress", "Waiting for operation to finish..."));
repaint();
dialogWidget().repaint();
QApplication::restoreOverrideCursor();
operationRunner().cancel();
}
operationRunner().suspendMutex().unlock();
}

View File

@ -78,7 +78,7 @@ void EditMountPointDialog::accept_(MountPointAction action)
widget().acceptChanges();
if (writeMountpoints(widget().fstabEntries())) {
if (action == Edit)
partition().setMountPoint(widget().editPath().text());
partition().setMountPoint(widget().editPath().currentText());
}
else
KMessageBox::sorry(this,

View File

@ -50,12 +50,14 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
labelType().setText(partition().fileSystem().name());
bool entryFound = false;
editPath().setEditable(true);
for (auto &e : m_fstabEntries) {
QString canonicalEntryPath = QFileInfo(e.deviceNode()).canonicalFilePath();
QString canonicalDevicePath = QFileInfo(m_deviceNode).canonicalFilePath();
if (canonicalEntryPath == canonicalDevicePath) { // FIXME fix multiple mountpoints
entryFound = true;
entry = &e;
entry.append(&e);
mountPointList = possibleMountPoints(e.deviceNode());
}
}
@ -75,15 +77,70 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
}
m_fstabEntries.append(FstabEntry(m_deviceNode, QString(), fsName, QString()));
entry = &m_fstabEntries.last();
entry.append(&m_fstabEntries.last());
}
currentEntry = entry[0];
editPath().addItems(mountPointList);
spinDumpFreq().setValue(currentEntry->dumpFreq());
spinPassNumber().setValue(currentEntry->passNumber());
boxOptions()[QStringLiteral("ro")] = m_CheckReadOnly;
boxOptions()[QStringLiteral("users")] = m_CheckUsers;
boxOptions()[QStringLiteral("noauto")] = m_CheckNoAuto;
boxOptions()[QStringLiteral("noatime")] = m_CheckNoAtime;
boxOptions()[QStringLiteral("nodiratime")] = m_CheckNoDirAtime;
boxOptions()[QStringLiteral("sync")] = m_CheckSync;
boxOptions()[QStringLiteral("noexec")] = m_CheckNoExec;
boxOptions()[QStringLiteral("relatime")] = m_CheckRelAtime;
setupRadio(currentEntry->entryType());
setupOptions(currentEntry->options());
connect(m_ButtonMore, &QPushButton::clicked, this, &EditMountPointDialogWidget::buttonMoreClicked);
connect(m_ButtonSelect, &QPushButton::clicked, this, &EditMountPointDialogWidget::buttonSelectClicked);
connect(m_EditPath, QOverload<int>::of(&QComboBox::currentIndexChanged),
[=](int index){ currentEntry = entry[index];
spinDumpFreq().setValue(currentEntry->dumpFreq());
spinPassNumber().setValue(currentEntry->passNumber());
setupRadio(currentEntry->entryType());
for (iterator_BoxOptions = boxOptions().begin(); iterator_BoxOptions != boxOptions().end(); ++iterator_BoxOptions){
boxOptions()[iterator_BoxOptions->first]->setChecked(false);
}
setupOptions(currentEntry->options());
});
}
EditMountPointDialogWidget::~EditMountPointDialogWidget()
{
}
void EditMountPointDialogWidget::setupOptions(const QStringList& options)
{
QStringList optTmpList;
for (const auto &o : options) {
if (boxOptions().find(o) != boxOptions().end())
boxOptions()[o]->setChecked(true);
else
optTmpList.append(o);
}
editPath().setText(entry->mountPoint());
m_Options = optTmpList.join(QLatin1Char(','));
}
spinDumpFreq().setValue(entry->dumpFreq());
spinPassNumber().setValue(entry->passNumber());
void EditMountPointDialogWidget::setupRadio(const FstabEntryType entryType)
{
if (partition().fileSystem().uuid().isEmpty()) {
radioUUID().setEnabled(false);
if (radioUUID().isChecked())
radioDeviceNode().setChecked(true);
}
switch (entry->entryType()) {
if (partition().fileSystem().label().isEmpty()) {
radioLabel().setEnabled(false);
if (radioLabel().isChecked())
radioDeviceNode().setChecked(true);
}
switch (entryType) {
case FstabEntryType::uuid:
radioUUID().setChecked(true);
break;
@ -106,69 +163,33 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
case FstabEntryType::comment:
break;
}
boxOptions()[QStringLiteral("ro")] = m_CheckReadOnly;
boxOptions()[QStringLiteral("users")] = m_CheckUsers;
boxOptions()[QStringLiteral("noauto")] = m_CheckNoAuto;
boxOptions()[QStringLiteral("noatime")] = m_CheckNoAtime;
boxOptions()[QStringLiteral("nodiratime")] = m_CheckNoDirAtime;
boxOptions()[QStringLiteral("sync")] = m_CheckSync;
boxOptions()[QStringLiteral("noexec")] = m_CheckNoExec;
boxOptions()[QStringLiteral("relatime")] = m_CheckRelAtime;
setupOptions(entry->options());
if (partition().fileSystem().uuid().isEmpty()) {
radioUUID().setEnabled(false);
if (radioUUID().isChecked())
radioDeviceNode().setChecked(true);
}
if (partition().fileSystem().label().isEmpty()) {
radioLabel().setEnabled(false);
if (radioLabel().isChecked())
radioDeviceNode().setChecked(true);
}
connect(m_ButtonMore, &QPushButton::clicked, this, &EditMountPointDialogWidget::buttonMoreClicked);
connect(m_ButtonSelect, &QPushButton::clicked, this, &EditMountPointDialogWidget::buttonSelectClicked);
}
EditMountPointDialogWidget::~EditMountPointDialogWidget()
{
}
void EditMountPointDialogWidget::setupOptions(const QStringList& options)
{
QStringList optTmpList;
for (const auto &o : options) {
if (boxOptions().find(o) != boxOptions().end())
boxOptions()[o]->setChecked(true);
else
optTmpList.append(o);
}
m_Options = optTmpList.join(QLatin1Char(','));
}
void EditMountPointDialogWidget::buttonSelectClicked(bool)
{
const QString s = QFileDialog::getExistingDirectory(this, editPath().text());
const QString s = QFileDialog::getExistingDirectory(this, editPath().currentText());
if (!s.isEmpty())
editPath().setText(s);
editPath().setCurrentText(s);
}
void EditMountPointDialogWidget::removeMountPoint()
{
int i=0;
for (const auto &e : fstabEntries()) {
if(e.fsSpec().contains(partition().deviceNode()) || e.fsSpec().contains(partition().fileSystem().uuid()) ||
e.fsSpec().contains(partition().fileSystem().label()) || e.fsSpec().contains(partition().label()) || e.fsSpec().contains(partition().uuid()) )
{
if(editPath().count()<=1 && ((e.fsSpec().contains(partition().deviceNode()) && !partition().deviceNode().isEmpty() ) || (e.fsSpec().contains(partition().fileSystem().uuid()) && !partition().fileSystem().uuid().isEmpty()) ||
(e.fsSpec().contains(partition().fileSystem().label()) && !partition().fileSystem().label().isEmpty()) || (e.fsSpec().contains(partition().label()) && !partition().label().isEmpty() ) || (e.fsSpec().contains(partition().uuid()) && !partition().uuid().isEmpty() )))
{
fstabEntries().removeAt(i);
partition().setMountPoint(QString());
i--;
}
else if(editPath().count()>1 && ((&e == currentEntry)))
{
fstabEntries().removeAt(i);
editPath().removeItem(editPath().currentIndex());
partition().setMountPoint(editPath().itemText(editPath().currentIndex()));
i--;
break;
}
i++;
}
@ -199,15 +220,15 @@ QStringList EditMountPointDialogWidget::options() const
void EditMountPointDialogWidget::acceptChanges()
{
entry->setDumpFreq(spinDumpFreq().value());
entry->setPassNumber(spinPassNumber().value());
entry->setMountPoint(editPath().text());
entry->setOptions(options());
currentEntry->setDumpFreq(spinDumpFreq().value());
currentEntry->setPassNumber(spinPassNumber().value());
currentEntry->setMountPoint(editPath().currentText());
currentEntry->setOptions(options());
if (radioUUID().isChecked() && !partition().fileSystem().uuid().isEmpty())
entry->setFsSpec(QStringLiteral("UUID=") + partition().fileSystem().uuid());
currentEntry->setFsSpec(QStringLiteral("UUID=") + partition().fileSystem().uuid());
else if (radioLabel().isChecked() && !partition().fileSystem().label().isEmpty())
entry->setFsSpec(QStringLiteral("LABEL=") + partition().fileSystem().label());
currentEntry->setFsSpec(QStringLiteral("LABEL=") + partition().fileSystem().label());
else
entry->setFsSpec(m_deviceNode);
currentEntry->setFsSpec(m_deviceNode);
}

View File

@ -32,7 +32,7 @@ class Partition;
class QFile;
class QSpinBox;
class QCheckBox;
class QLineEdit;
class QComboBox;
class QPushButton;
class QStringList;
@ -48,7 +48,7 @@ public:
QLabel& labelName() {
return *m_LabelNameValue;
}
QLineEdit& editPath() {
QComboBox& editPath() {
return *m_EditPath;
}
QSpinBox& spinDumpFreq() {
@ -84,6 +84,7 @@ protected:
private:
void setupOptions(const QStringList& options);
void setupRadio(const FstabEntryType entryType);
std::map<QString, QCheckBox*>& boxOptions() {
return m_BoxOptions;
}
@ -101,12 +102,14 @@ private:
private:
FstabEntryList m_fstabEntries;
FstabEntry *entry;
QList<FstabEntry *> entry;
FstabEntry *currentEntry;
Partition& m_Partition;
QString m_Options;
QString m_deviceNode;
QStringList mountPointList;
std::map<QString, QCheckBox*> m_BoxOptions;
std::map<QString, QCheckBox*>::iterator iterator_BoxOptions;
};
#endif

View File

@ -6,51 +6,46 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<width>613</width>
<height>374</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="1" colspan="3">
<widget class="QLineEdit" name="m_EditPath">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="4" column="2">
<widget class="QRadioButton" name="m_RadioUUID">
<property name="text">
<string>UU&amp;ID</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="m_LabelPath">
<item row="12" column="1">
<widget class="QSpinBox" name="m_SpinDumpFreq"/>
</item>
<item row="7" column="3" colspan="4">
<widget class="QCheckBox" name="m_CheckUsers">
<property name="text">
<string>Path:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_EditPath</cstring>
<string>Users can mount and unmount</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="m_LabelType">
<item row="10" column="3" colspan="4">
<widget class="QCheckBox" name="m_CheckRelAtime">
<property name="text">
<string>Type:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<string>Update access times relative to modification</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="m_LabelOptions">
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="m_LabelTypeValue">
<property name="text">
<string>Options:</string>
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</widget>
</item>
<item row="2" column="0" colspan="7">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -61,52 +56,23 @@
</property>
</widget>
</item>
<item row="7" column="3" colspan="4">
<widget class="QCheckBox" name="m_CheckUsers">
<item row="12" column="3">
<widget class="QLabel" name="m_LabelPassNumber">
<property name="text">
<string>Users can mount and unmount</string>
<string>Pass &amp;Number:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_SpinPassNumber</cstring>
</property>
</widget>
</item>
<item row="8" column="1" colspan="2">
<widget class="QCheckBox" name="m_CheckNoAuto">
<item row="11" column="6">
<widget class="QPushButton" name="m_ButtonMore">
<property name="text">
<string>No automatic mount</string>
</property>
</widget>
</item>
<item row="8" column="3" colspan="3">
<widget class="QCheckBox" name="m_CheckNoAtime">
<property name="text">
<string>No update of file access times</string>
</property>
</widget>
</item>
<item row="9" column="1" colspan="2">
<widget class="QCheckBox" name="m_CheckSync">
<property name="text">
<string>Synchronous access</string>
</property>
</widget>
</item>
<item row="9" column="3" colspan="4">
<widget class="QCheckBox" name="m_CheckNoDirAtime">
<property name="text">
<string>No update of directory access times</string>
</property>
</widget>
</item>
<item row="10" column="1" colspan="2">
<widget class="QCheckBox" name="m_CheckNoExec">
<property name="text">
<string>No binary execution</string>
</property>
</widget>
</item>
<item row="10" column="3" colspan="4">
<widget class="QCheckBox" name="m_CheckRelAtime">
<property name="text">
<string>Update access times relative to modification</string>
<string>More...</string>
</property>
</widget>
</item>
@ -123,85 +89,23 @@
</property>
</spacer>
</item>
<item row="11" column="6">
<widget class="QPushButton" name="m_ButtonMore">
<item row="4" column="1">
<widget class="QRadioButton" name="m_RadioDeviceNode">
<property name="text">
<string>More...</string>
<string>De&amp;vice Node</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="m_LabelDumpFreq">
<item row="7" column="0">
<widget class="QLabel" name="m_LabelOptions">
<property name="text">
<string>Dump &amp;Frequency:</string>
<string>Options:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_SpinDumpFreq</cstring>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QSpinBox" name="m_SpinDumpFreq"/>
</item>
<item row="12" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>70</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
<item row="12" column="3">
<widget class="QLabel" name="m_LabelPassNumber">
<property name="text">
<string>Pass &amp;Number:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_SpinPassNumber</cstring>
</property>
</widget>
</item>
<item row="12" column="4">
<widget class="QSpinBox" name="m_SpinPassNumber"/>
</item>
<item row="0" column="0" colspan="7">
<widget class="QLabel" name="m_LabelNameValue">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="m_LabelTypeValue">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0" colspan="7">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
</widget>
</item>
@ -221,6 +125,89 @@
</property>
</spacer>
</item>
<item row="4" column="3">
<widget class="QRadioButton" name="m_RadioLabel">
<property name="text">
<string>&amp;Label</string>
</property>
</widget>
</item>
<item row="10" column="1" colspan="2">
<widget class="QCheckBox" name="m_CheckNoExec">
<property name="text">
<string>No binary execution</string>
</property>
</widget>
</item>
<item row="12" column="4">
<widget class="QSpinBox" name="m_SpinPassNumber"/>
</item>
<item row="12" column="5" colspan="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>135</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="1" colspan="2">
<widget class="QCheckBox" name="m_CheckNoAuto">
<property name="text">
<string>No automatic mount</string>
</property>
</widget>
</item>
<item row="5" column="6">
<widget class="QPushButton" name="m_ButtonRemove">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QPushButton" name="m_ButtonSelect">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
<item row="9" column="3" colspan="4">
<widget class="QCheckBox" name="m_CheckNoDirAtime">
<property name="text">
<string>No update of directory access times</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="m_LabelDumpFreq">
<property name="text">
<string>Dump &amp;Frequency:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_SpinDumpFreq</cstring>
</property>
</widget>
</item>
<item row="3" column="0" colspan="7">
<spacer name="verticalSpacer_2">
<property name="orientation">
@ -237,6 +224,42 @@
</property>
</spacer>
</item>
<item row="6" column="0">
<widget class="QLabel" name="m_LabelType">
<property name="text">
<string>Type:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="m_LabelPath">
<property name="text">
<string>Path:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0" colspan="7">
<widget class="QLabel" name="m_LabelNameValue">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="13" column="0" colspan="7">
<spacer name="verticalSpacer_3">
<property name="orientation">
@ -253,29 +276,32 @@
</property>
</spacer>
</item>
<item row="4" column="1">
<widget class="QRadioButton" name="m_RadioDeviceNode">
<item row="8" column="3" colspan="3">
<widget class="QCheckBox" name="m_CheckNoAtime">
<property name="text">
<string>De&amp;vice Node</string>
</property>
<property name="checked">
<bool>true</bool>
<string>No update of file access times</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QRadioButton" name="m_RadioUUID">
<item row="9" column="1" colspan="2">
<widget class="QCheckBox" name="m_CheckSync">
<property name="text">
<string>UU&amp;ID</string>
<string>Synchronous access</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QRadioButton" name="m_RadioLabel">
<property name="text">
<string>&amp;Label</string>
<item row="12" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>70</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
@ -287,44 +313,8 @@
</property>
</widget>
</item>
<item row="12" column="5" colspan="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>135</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="4">
<widget class="QPushButton" name="m_ButtonSelect">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
<item row="5" column="6">
<widget class="QPushButton" name="m_ButtonRemove">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
<item row="5" column="1" colspan="3">
<widget class="QComboBox" name="m_EditPath"/>
</item>
</layout>
</widget>

View File

@ -31,6 +31,7 @@
#include <QFontDatabase>
#include <QPushButton>
#include <QTemporaryFile>
#include <QTextDocumentFragment>
#include <QTextStream>
#include <QTreeWidgetItem>
#include <QtGlobal>
@ -130,6 +131,7 @@ void SmartDialog::setupDialog()
<< a.value()
);
item->setSizeHint(0, QSize(0, 64));
item->setToolTip(1, QTextDocumentFragment::fromHtml(a.desc()).toPlainText());
dialogWidget().treeSmartAttributes().addTopLevelItem(item);
}
} else