From 60e86c3ad69d1e5ee1a2044485f005c2da59a0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 19 Mar 2018 02:34:30 +0100 Subject: [PATCH 01/46] Stop ExternalCommandHelper before quiting the application. --- src/gui/mainwindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 6eed849..2ca0e5e 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -165,6 +166,10 @@ void MainWindow::closeEvent(QCloseEvent* event) saveConfig(); KXmlGuiWindow::closeEvent(event); + + QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus()); + if (iface.isValid()) + iface.call(QStringLiteral("exit"), CoreBackendManager::self()->Uuid()); } void MainWindow::changeEvent(QEvent* event) From a1a535cb0330ed1bb1c25e1ad5c8a366caab4a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 19 Mar 2018 02:45:18 +0100 Subject: [PATCH 02/46] Remove checkPermissions code. --- src/main.cpp | 2 - src/util/guihelpers.cpp | 92 ----------------------------------------- src/util/guihelpers.h | 3 -- 3 files changed, 97 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ab2c814..28012c4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,8 +75,6 @@ int Q_DECL_IMPORT main(int argc, char* argv[]) aboutData.processCommandLine(&parser); registerMetaTypes(); - if (!checkPermissions()) - return 0; Config::instance(QStringLiteral("partitionmanagerrc")); diff --git a/src/util/guihelpers.cpp b/src/util/guihelpers.cpp index 5efceca..33aa2ea 100644 --- a/src/util/guihelpers.cpp +++ b/src/util/guihelpers.cpp @@ -52,83 +52,6 @@ QIcon createFileSystemColor(FileSystem::Type type, quint32 size) return QIcon(pixmap); } -bool checkPermissions() -{ - if (geteuid() != 0) { - // only try to gain root privileges if we have a valid (kde|gk)su(do) command and - // we did not try so before: the dontsu-option is there to make sure there are no - // endless loops of calling the same non-working (kde|gk)su(do) binary again and again. - if (!suCommand().isEmpty() && !QCoreApplication::arguments().contains(QLatin1String("--dontsu"))) { - QString argList; - - const QString suCmd = suCommand(); - - // kdesu broke backward compatibility at some point and now only works with "-c"; - // kdesudo accepts either (with or without "-c"), but the gk* helpers only work - // without. kdesu maintainers won't fix their app, so we need to work around that here. - if (suCmd.indexOf(QStringLiteral("kdesu")) != -1) - argList = QStringLiteral("-c "); - - // Workaround for ugly GUI when kdesu uses sudo - QString DBusString = QStringLiteral("DBUS_SESSION_BUS_ADDRESS"); - const QStringList envVars = { QStringLiteral("KDE_FULL_SESSION"), - QStringLiteral("QT_WAYLAND_FORCE_DPI"), - QStringLiteral("QT_QPA_PLATFORM"), - QStringLiteral("XDG_RUNTIME_DIR"), - DBusString }; - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - for (const auto &var : envVars) - if (env.contains(var)) - argList += var + QStringLiteral("=") + env.value(var) + QStringLiteral(" "); - - QString displayString = QStringLiteral("DISPLAY"); - QString homeString = QStringLiteral("HOME"); - if (!env.contains(DBusString) && env.contains(displayString) && env.contains(homeString)) { - QFile file(QStringLiteral("/var/lib/dbus/machine-id")); - if (file.open(QIODevice::ReadOnly)) { - QTextStream in(&file); - QString machineId = in.readLine(); - file.close(); - QString display = env.value(displayString).remove(0,1); - QFile sessionFile(env.value(homeString) + QStringLiteral("/.dbus/session-bus/") + machineId + QStringLiteral("-") + display); - if (sessionFile.open(QIODevice::ReadOnly)) { - QTextStream in2(&sessionFile); - while (!in2.atEnd()) { - QString line = in2.readLine(); - if (line.startsWith(DBusString)) { - argList += line + QStringLiteral(" "); - break; - } - } - } - } - } - - argList += QCoreApplication::arguments().join(QStringLiteral(" ")) + QStringLiteral(" --dontsu"); - - qDebug() << "Executing: " << suCmd << argList; - if (QProcess::execute(suCmd, QStringList(argList)) == 0) - return false; - } - - return KMessageBox::warningContinueCancel(nullptr, xi18nc("@info", - "You do not have administrative privileges." - "It is possible to run %1 without these privileges. " - "You will, however, not be allowed to apply operations." - "Do you want to continue running %1?" - "If administrator login is disabled and your password is " - "not accepted, then check kdesu " - "configuration.", - QGuiApplication::applicationDisplayName()), - xi18nc("@title:window", "No administrative privileges"), - KGuiItem(xi18nc("@action:button", "Run without administrative privileges"), QStringLiteral("arrow-right")), - KStandardGuiItem::cancel(), - QStringLiteral("runWithoutRootPrivileges"), KMessageBox::AllowLink) == KMessageBox::Continue; - } - - return true; -} - bool loadBackend() { if (CoreBackendManager::self()->load(Config::backend()) == false) { @@ -153,21 +76,6 @@ bool loadBackend() return true; } -QString suCommand() -{ - // First look for KF5 version of kdesu in libexec folder - const QString candidates[] = { QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5"/kdesu"), QStringLiteral("kdesu"), QStringLiteral("kdesudo"), QStringLiteral("gksudo"), QStringLiteral("gksu") }; - QString rval; - - for (const auto &candidate : candidates) { - rval = QStandardPaths::findExecutable(candidate); - if (QFileInfo(rval).isExecutable()) - return rval; - } - - return QString(); -} - Capacity::Unit preferredUnit() { return static_cast(Config::preferredUnit()); diff --git a/src/util/guihelpers.h b/src/util/guihelpers.h index 3c857d8..656be77 100644 --- a/src/util/guihelpers.h +++ b/src/util/guihelpers.h @@ -28,7 +28,6 @@ class QPoint; class QString; class QTreeWidget; -bool checkPermissions(); bool loadBackend(); QIcon createFileSystemColor(FileSystem::Type type, quint32 size); Capacity::Unit preferredUnit(); @@ -39,6 +38,4 @@ FileSystem::Type defaultFileSystem(); std::array< QColor, FileSystem::__lastType > fileSystemColorCodesFromSettings(); } -QString suCommand(); - #endif From 62a3b57c2d1095c160e718273aa9ebed6c3bccfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 19 Mar 2018 16:24:49 +0100 Subject: [PATCH 03/46] Remove --dontsu command line option. --- src/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 28012c4..cbf7a3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,7 +68,6 @@ int Q_DECL_IMPORT main(int argc, char* argv[]) QCommandLineParser parser; aboutData.setupCommandLine(&parser); - parser.addOption(QCommandLineOption(QLatin1Literal("dontsu"), xi18nc("@info:shell", "Do not try to gain super user privileges"))); // FIXME parser.addPositionalArgument(QStringLiteral("device"), xi18nc("@info:shell", "Device(s) to manage"), QStringLiteral("[device...]")); parser.process(app); From cc73b6c9cec230e821a61b977edcb65e5b9da399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Wed, 21 Mar 2018 20:51:10 +0100 Subject: [PATCH 04/46] Move external command helper stopping code to kpmcore. --- src/gui/mainwindow.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 2ca0e5e..786d69e 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -63,7 +63,6 @@ #include #include #include -#include #include #include #include @@ -167,9 +166,7 @@ void MainWindow::closeEvent(QCloseEvent* event) KXmlGuiWindow::closeEvent(event); - QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus()); - if (iface.isValid()) - iface.call(QStringLiteral("exit"), CoreBackendManager::self()->Uuid()); + CoreBackendManager::stopExternalCommandHelper(); } void MainWindow::changeEvent(QEvent* event) From cfa53f6d3c58bea7a4fd99c024092508f47a7be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Thu, 22 Mar 2018 17:39:04 +0000 Subject: [PATCH 05/46] Disallow executing KDE Partition Manager as root. Summary: Running GUI applications as root is a huge security risk. Especially the X server is not secured for that. Non-root applications can easily interact with a root running application and thus try to exploit simple bugs in either kate/kwrite itself or in the underlying libraries such as Qt, XLib or xcb. On Wayland the situation can be considered worse as the compositor is running as the normal user and is not protected to handle root windows. It can be rather trivial to attack the root running application from the compositor through interfaces such as scripting. This is not in the aim of the compositors to protect against. This change introduces a check whether the application is started as root before any interaction with X or Wayland happens, that is prior to creating the QApplication. If it is detected that we run as root, we exit and print an information about how to properly edit an application in kwrite/kate as root. The text is deliberatly not translated to keep the threat from running as root as low as possible. See also Differential Revision: https://phabricator.kde.org/D4634 --- src/main.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index cbf7a3e..e79eda8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,10 +32,25 @@ #include #include -#include +#include "config.h" + +#ifndef Q_OS_WIN +#include +#endif +#include int Q_DECL_IMPORT main(int argc, char* argv[]) { +#ifndef Q_OS_WIN + /** + * Check whether we are running as root + **/ + if (getuid() == 0) { + std::cout << "Executing KDE Partition Manager as root is not possible." << std::endl; + return 0; + } +#endif + QApplication app(argc, argv); Kdelibs4ConfigMigrator migrate(QLatin1Literal("partitionmanager")); From d37c0ef9ce2a85ca1e7ea5ae2e33b21668472868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Thu, 22 Mar 2018 20:13:58 +0000 Subject: [PATCH 06/46] Revert "Disallow executing KDE Partition Manager as root." This reverts commit cfa53f6d3c58bea7a4fd99c024092508f47a7be5. --- src/main.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e79eda8..cbf7a3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,25 +32,10 @@ #include #include -#include "config.h" - -#ifndef Q_OS_WIN -#include -#endif -#include +#include int Q_DECL_IMPORT main(int argc, char* argv[]) { -#ifndef Q_OS_WIN - /** - * Check whether we are running as root - **/ - if (getuid() == 0) { - std::cout << "Executing KDE Partition Manager as root is not possible." << std::endl; - return 0; - } -#endif - QApplication app(argc, argv); Kdelibs4ConfigMigrator migrate(QLatin1Literal("partitionmanager")); From c40a729ba73ab82bf75fe6c36b977ae17807b75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sat, 24 Mar 2018 22:24:26 +0000 Subject: [PATCH 07/46] Do not allow the second instance of Partition Manager. BUG: 365882 --- CMakeLists.txt | 1 + src/CMakeLists.txt | 1 + src/main.cpp | 3 +++ 3 files changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f240c37..023cd7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED ConfigWidgets CoreAddons Crash + DBusAddons I18n IconThemes JobWidgets diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 476d269..01a14f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,6 +44,7 @@ target_link_libraries(partitionmanager ${BLKID_LIBRARIES} KF5::ConfigWidgets KF5::CoreAddons KF5::Crash + KF5::DBusAddons KF5::I18n KF5::IconThemes KF5::JobWidgets diff --git a/src/main.cpp b/src/main.cpp index cbf7a3e..81dc244 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -73,6 +74,8 @@ int Q_DECL_IMPORT main(int argc, char* argv[]) parser.process(app); aboutData.processCommandLine(&parser); + KDBusService service(KDBusService::Unique); + registerMetaTypes(); Config::instance(QStringLiteral("partitionmanagerrc")); From 6f8cde5520a8b82f1ca9537358820d969fc5d29f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 1 Apr 2018 18:47:34 +0100 Subject: [PATCH 08/46] Use for loop with iterators when removing mount points. --- src/gui/editmountpointdialogwidget.cpp | 32 +++++++++++++------------- src/gui/editmountpointdialogwidget.h | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gui/editmountpointdialogwidget.cpp b/src/gui/editmountpointdialogwidget.cpp index 8af681f..ee5f739 100644 --- a/src/gui/editmountpointdialogwidget.cpp +++ b/src/gui/editmountpointdialogwidget.cpp @@ -56,7 +56,7 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio QString canonicalDevicePath = QFileInfo(m_deviceNode).canonicalFilePath(); if (canonicalEntryPath == canonicalDevicePath) { // FIXME fix multiple mountpoints entryFound = true; - entry.append(&e); + entry.push_back(&e); mountPointList = possibleMountPoints(e.deviceNode()); } } @@ -76,8 +76,8 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio fsName = partition().fileSystem().name(); } - m_fstabEntries.append(FstabEntry(m_deviceNode, QString(), fsName, QString())); - entry.append(&m_fstabEntries.last()); + m_fstabEntries.push_back(FstabEntry(m_deviceNode, QString(), fsName, QString())); + entry.push_back(&m_fstabEntries.back()); } currentEntry = entry[0]; editPath().addItems(mountPointList); @@ -174,24 +174,24 @@ void EditMountPointDialogWidget::buttonSelectClicked(bool) void EditMountPointDialogWidget::removeMountPoint() { - int i=0; - for (const auto &e : fstabEntries()) { - 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); + for (auto it = fstabEntries().begin(); it != fstabEntries().end(); ) { + if (editPath().count() <= 1 && ( + (it->fsSpec().contains(partition().deviceNode()) && !partition().deviceNode().isEmpty() ) || + (it->fsSpec().contains(partition().fileSystem().uuid()) && !partition().fileSystem().uuid().isEmpty() ) || + (it->fsSpec().contains(partition().fileSystem().label()) && !partition().fileSystem().label().isEmpty()) || + (it->fsSpec().contains(partition().label()) && !partition().label().isEmpty() ) || + (it->fsSpec().contains(partition().uuid()) && !partition().uuid().isEmpty() ))) + { + fstabEntries().erase(it); partition().setMountPoint(QString()); - i--; - } - else if(editPath().count()>1 && ((&e == currentEntry))) - { - fstabEntries().removeAt(i); + } + else if (editPath().count() > 1 && ((&*it == currentEntry))) + { + fstabEntries().erase(it); editPath().removeItem(editPath().currentIndex()); partition().setMountPoint(editPath().itemText(editPath().currentIndex())); - i--; break; } - i++; } } diff --git a/src/gui/editmountpointdialogwidget.h b/src/gui/editmountpointdialogwidget.h index 56705bc..b1d7ad9 100644 --- a/src/gui/editmountpointdialogwidget.h +++ b/src/gui/editmountpointdialogwidget.h @@ -102,7 +102,7 @@ private: private: FstabEntryList m_fstabEntries; - QList entry; + QList entry; // All fstab entries for this partition FstabEntry *currentEntry; Partition& m_Partition; QString m_Options; From f33695eb2f53cb099545b283632d887933080164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 2 Apr 2018 01:25:21 +0100 Subject: [PATCH 09/46] Unnecessary use of a pointer for MainWindow. --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 81dc244..c046f01 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -83,8 +83,8 @@ int Q_DECL_IMPORT main(int argc, char* argv[]) if (!loadBackend()) return 0; - MainWindow* mainWindow = new MainWindow(); - mainWindow->show(); + MainWindow mainWindow; + mainWindow.show(); return app.exec(); } From 73fef8d69c2425d21bafb7dc15c6df8539abecfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 2 Apr 2018 13:01:56 +0100 Subject: [PATCH 10/46] Revert "Unnecessary use of a pointer for MainWindow." This reverts commit f33695eb2f53cb099545b283632d887933080164. --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c046f01..81dc244 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -83,8 +83,8 @@ int Q_DECL_IMPORT main(int argc, char* argv[]) if (!loadBackend()) return 0; - MainWindow mainWindow; - mainWindow.show(); + MainWindow* mainWindow = new MainWindow(); + mainWindow->show(); return app.exec(); } From 3aed3ccd93cfa6c6a9f0ebd0d9fabba9f534f6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 2 Apr 2018 14:01:43 +0100 Subject: [PATCH 11/46] Remove obsolete CHS information. --- src/gui/devicepropsdialog.cpp | 5 -- src/gui/devicepropswidget.h | 8 ---- src/gui/devicepropswidgetbase.ui | 80 +++++++------------------------- 3 files changed, 17 insertions(+), 76 deletions(-) diff --git a/src/gui/devicepropsdialog.cpp b/src/gui/devicepropsdialog.cpp index 175e1d7..f925911 100644 --- a/src/gui/devicepropsdialog.cpp +++ b/src/gui/devicepropsdialog.cpp @@ -109,12 +109,7 @@ void DevicePropsDialog::setupDialog() if (device().type() == Device::Disk_Device) { const DiskDevice& disk = dynamic_cast(device()); - const QString cyls = QLocale().toString((disk.cylinders())); - const QString heads = QLocale().toString((disk.heads())); - const QString sectors = QLocale().toString((disk.sectorsPerTrack())); - dialogWidget().chs().setText(QStringLiteral("%1/%2/%3").arg(cyls).arg(heads).arg(sectors)); - dialogWidget().cylinderSize().setText(i18ncp("@label", "1 Sector", "%1 Sectors", disk.cylinderSize())); dialogWidget().primariesMax().setText(maxPrimaries); dialogWidget().logicalSectorSize().setText(Capacity::formatByteSize(disk.logicalSectorSize())); dialogWidget().physicalSectorSize().setText(Capacity::formatByteSize(disk.physicalSectorSize())); diff --git a/src/gui/devicepropswidget.h b/src/gui/devicepropswidget.h index 9b617ee..5dc8f44 100644 --- a/src/gui/devicepropswidget.h +++ b/src/gui/devicepropswidget.h @@ -37,18 +37,10 @@ public: return *m_PartTableWidget; } - QLabel& chs() { - Q_ASSERT(m_LabelCHS); - return *m_LabelCHS; - } QLabel& capacity() { Q_ASSERT(m_LabelCapacity); return *m_LabelCapacity; } - QLabel& cylinderSize() { - Q_ASSERT(m_LabelCylinderSize); - return *m_LabelCylinderSize; - } QLabel& primariesMax() { Q_ASSERT(m_LabelPrimariesMax); return *m_LabelPrimariesMax; diff --git a/src/gui/devicepropswidgetbase.ui b/src/gui/devicepropswidgetbase.ui index 17b977c..7a6b322 100644 --- a/src/gui/devicepropswidgetbase.ui +++ b/src/gui/devicepropswidgetbase.ui @@ -81,7 +81,7 @@ - Sector based al&ignment + Sector based align&ment @@ -149,35 +149,6 @@ - - - - 2 - 0 - - - - Cylinders/Heads/Sectors: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 5 - 0 - - - - - - - - Logical sector size: @@ -187,14 +158,14 @@ - + - + Physical sector size: @@ -204,38 +175,28 @@ - + - - - - Cylinder size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - + Qt::Horizontal - + + + + Qt::Horizontal + + + + Primaries/Max: @@ -245,21 +206,14 @@ - + - - - - Qt::Horizontal - - - - + SMART status: @@ -269,7 +223,7 @@ - + @@ -306,7 +260,7 @@ - + Qt::Vertical From bf65a186bd9f334f0cc58703abaa971ecf569a17 Mon Sep 17 00:00:00 2001 From: Huzaifa Faruqui Date: Wed, 4 Apr 2018 00:31:14 +0530 Subject: [PATCH 12/46] Removed config option to apply operations as non-root --- src/config/configurepageadvanced.ui | 30 +---------------------------- src/gui/mainwindow.cpp | 9 ++------- src/partitionmanager.kcfg | 4 ---- 3 files changed, 3 insertions(+), 40 deletions(-) diff --git a/src/config/configurepageadvanced.ui b/src/config/configurepageadvanced.ui index dc10749..96b5e5a 100644 --- a/src/config/configurepageadvanced.ui +++ b/src/config/configurepageadvanced.ui @@ -6,39 +6,11 @@ 0 0 - 367 + 449 420 - - - - - 0 - 1 - - - - Permissions - - - - - - - 0 - 0 - - - - Allow applying operations without administrator privileges - - - - - - diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 786d69e..107a6f2 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -86,11 +86,7 @@ #include #include #include - -#include - -#include -#include +#include "config.h" /** Creates a new MainWindow instance. @param parent the parent widget @@ -505,8 +501,7 @@ void MainWindow::enableActions() actionCollection()->action(QStringLiteral("clearAllOperations")) ->setEnabled(operationStack().size() > 0); actionCollection()->action(QStringLiteral("applyAllOperations")) - ->setEnabled(operationStack().size() > 0 && (geteuid() == 0 || - Config::allowApplyOperationsAsNonRoot())); + ->setEnabled(operationStack().size() > 0); const bool readOnly = pmWidget().selectedDevice() == nullptr || pmWidget().selectedDevice()->partitionTable() == nullptr || diff --git a/src/partitionmanager.kcfg b/src/partitionmanager.kcfg index ad89c75..f8b26c7 100644 --- a/src/partitionmanager.kcfg +++ b/src/partitionmanager.kcfg @@ -54,10 +54,6 @@ true - - - false - From 3eae84de134037639e6cfc248d96fcc31b4c9d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Thu, 5 Apr 2018 21:54:55 +0100 Subject: [PATCH 13/46] Adapt to kpmcore API changes std::array->std::vector. --- src/util/guihelpers.cpp | 5 +++-- src/util/guihelpers.h | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util/guihelpers.cpp b/src/util/guihelpers.cpp index 33aa2ea..0f8dbeb 100644 --- a/src/util/guihelpers.cpp +++ b/src/util/guihelpers.cpp @@ -116,9 +116,10 @@ FileSystem::Type defaultFileSystem() return static_cast(Config::defaultFileSystem()); } -std::array< QColor, FileSystem::__lastType > fileSystemColorCodesFromSettings() +std::vector fileSystemColorCodesFromSettings() { - std::array< QColor, FileSystem::__lastType > cc; + std::vector cc; + cc.reserve(FileSystem::__lastType); for (int i = 0; i < FileSystem::__lastType; ++i) { cc[ i ] = Config::fileSystemColorCode( i ); diff --git a/src/util/guihelpers.h b/src/util/guihelpers.h index 656be77..5313045 100644 --- a/src/util/guihelpers.h +++ b/src/util/guihelpers.h @@ -16,13 +16,14 @@ * along with this program. If not, see .* *************************************************************************/ -#if !defined(GUIHELPERS_H) - +#ifndef GUIHELPERS_H #define GUIHELPERS_H #include #include +#include + class QIcon; class QPoint; class QString; @@ -35,7 +36,7 @@ void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree); namespace GuiHelpers { FileSystem::Type defaultFileSystem(); -std::array< QColor, FileSystem::__lastType > fileSystemColorCodesFromSettings(); +std::vector fileSystemColorCodesFromSettings(); } #endif From f42da524fc1971e3f79bdcb33f60e20b7fdfccbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Thu, 5 Apr 2018 22:00:06 +0100 Subject: [PATCH 14/46] enum -> enum class. --- src/gui/editmountpointdialog.cpp | 10 +++++----- src/gui/editmountpointdialog.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/editmountpointdialog.cpp b/src/gui/editmountpointdialog.cpp index 02b4f36..c6d07d2 100644 --- a/src/gui/editmountpointdialog.cpp +++ b/src/gui/editmountpointdialog.cpp @@ -49,10 +49,10 @@ EditMountPointDialog::EditMountPointDialog(QWidget* parent, Partition& p) : this ); mainLayout->addWidget(dbb); connect(dbb, &QDialogButtonBox::accepted, - this, [=] () {accept_(Edit);} ); + this, [=] () {accept_(MountPointAction::Edit);} ); connect(dbb, &QDialogButtonBox::rejected, this, &EditMountPointDialog::reject); - connect(widget().m_ButtonRemove, &QPushButton::clicked, this, [=] () {accept_(Remove);} ); + connect(widget().m_ButtonRemove, &QPushButton::clicked, this, [=] () {accept_(MountPointAction::Remove);} ); } /** Destroys an EditMountOptionsDialog instance */ @@ -72,12 +72,12 @@ void EditMountPointDialog::accept_(MountPointAction action) KStandardGuiItem::cancel(), QStringLiteral("reallyWriteMountPoints")) == KMessageBox::Cancel) return; - if(action == Remove) + if(action == MountPointAction::Remove) widget().removeMountPoint(); - else if (action == Edit) + else if (action == MountPointAction::Edit) widget().acceptChanges(); if (writeMountpoints(widget().fstabEntries())) { - if (action == Edit) + if (action == MountPointAction::Edit) partition().setMountPoint(widget().editPath().currentText()); } else diff --git a/src/gui/editmountpointdialog.h b/src/gui/editmountpointdialog.h index fcdc7cc..e1905ad 100644 --- a/src/gui/editmountpointdialog.h +++ b/src/gui/editmountpointdialog.h @@ -28,7 +28,7 @@ class Partition; class QWidget; class QString; -enum MountPointAction +enum class MountPointAction { Remove, Edit From 3c9d85d8428149c51ec12d6bd561863d6a161c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sat, 7 Apr 2018 19:05:05 +0100 Subject: [PATCH 15/46] Use enums instead of ints when choosing filesystem color in KConfig. --- src/config/configurepagefilesystemcolors.ui | 170 ++++++++++---------- src/partitionmanager.kcfg | 101 ++++++++---- src/util/guihelpers.cpp | 6 +- 3 files changed, 155 insertions(+), 122 deletions(-) diff --git a/src/config/configurepagefilesystemcolors.ui b/src/config/configurepagefilesystemcolors.ui index 5b2f267..c73b4d3 100644 --- a/src/config/configurepagefilesystemcolors.ui +++ b/src/config/configurepagefilesystemcolors.ui @@ -37,7 +37,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -95,7 +95,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -140,7 +140,7 @@ - + @@ -169,7 +169,7 @@ - + @@ -185,7 +185,7 @@ - + @@ -214,7 +214,7 @@ - + @@ -243,7 +243,7 @@ - + @@ -258,10 +258,10 @@ - - + + - ZFS: + HPFS: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -271,6 +271,22 @@ + + + + + + + Qt::Horizontal + + + + 28 + 17 + + + + @@ -285,7 +301,7 @@ - + @@ -314,36 +330,7 @@ - - - - - - Qt::Horizontal - - - - 28 - 17 - - - - - - - - HPFS: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - + @@ -359,7 +346,7 @@ - + @@ -388,7 +375,7 @@ - + @@ -417,7 +404,7 @@ - + @@ -433,7 +420,7 @@ - + @@ -462,7 +449,7 @@ - + @@ -491,36 +478,23 @@ - + + + + + + ZFS: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + - - - - - - exFAT: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - NILFS2: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - + @@ -535,6 +509,19 @@ + + + + exFAT: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + @@ -548,6 +535,19 @@ + + + + NILFS2: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + @@ -562,7 +562,7 @@ - + @@ -591,7 +591,7 @@ - + @@ -620,7 +620,7 @@ - + @@ -636,7 +636,7 @@ - + @@ -665,7 +665,7 @@ - + @@ -694,7 +694,7 @@ - + @@ -717,7 +717,7 @@ - + @@ -746,7 +746,7 @@ - + @@ -775,7 +775,7 @@ - + diff --git a/src/partitionmanager.kcfg b/src/partitionmanager.kcfg index f8b26c7..6513c27 100644 --- a/src/partitionmanager.kcfg +++ b/src/partitionmanager.kcfg @@ -54,40 +54,73 @@ true - + - - - 220,205,175 - 187,249,207 - 102,121,150 - 122,145,180 - 143,170,210 - 155,155,130 - 204,179,215 - 229,201,240 - 244,214,255 - 216,220,135 - 251,255,157 - 200,255,254 - 137,200,198 - 210,136,142 - 240,165,171 - 151,220,134 - 220,205,175 - 173,205,255 - 176,155,185 - 170,30,77 - 96,140,85 - 33,137,108 - 250,230,255 - 242,155,104 - 160,210,180 - 255,170,0 - 170,120,255 - 177,82,69 - 223,39,104 - 204,179,255 + + + + Unknown + Extended + Ext2 + Ext3 + Ext4 + LinuxSwap + Fat16 + Fat32 + Ntfs + ReiserFS + Reiser4 + Xfs + Jfs + Hfs + HfsPlus + Ufs + Unformatted + Btrfs + Hpfs + Luks + Ocfs2 + Zfs + Exfat + Nilfs2 + Lvm2_PV + F2fs + Udf + Iso9660 + Luks2 + Fat12 + + + 220,205,175 + 187,249,207 + 102,121,150 + 122,145,180 + 143,170,210 + 155,155,130 + 204,179,215 + 229,201,240 + 244,214,255 + 216,220,135 + 251,255,157 + 200,255,254 + 137,200,198 + 210,136,142 + 240,165,171 + 151,220,134 + 220,205,175 + 173,205,255 + 176,155,185 + 170,30,77 + 96,140,85 + 33,137,108 + 250,230,255 + 242,155,104 + 160,210,180 + 255,170,0 + 170,120,255 + 177,82,69 + 223,39,104 + 204,179,255 @@ -97,7 +130,7 @@ - FileSystem::Ext4 + FileSystem::Type::Ext4 diff --git a/src/util/guihelpers.cpp b/src/util/guihelpers.cpp index 0f8dbeb..54048b5 100644 --- a/src/util/guihelpers.cpp +++ b/src/util/guihelpers.cpp @@ -119,10 +119,10 @@ FileSystem::Type defaultFileSystem() std::vector fileSystemColorCodesFromSettings() { std::vector cc; - cc.reserve(FileSystem::__lastType); - for (int i = 0; i < FileSystem::__lastType; ++i) + cc.reserve(Config::EnumFileSystem::type::COUNT); + for (int i = 0; i < Config::EnumFileSystem::type::COUNT; ++i) { - cc[ i ] = Config::fileSystemColorCode( i ); + cc[i] = Config::fileSystemColorCode(i); } return cc; } From 2137fa58b86a3bbfb586fa6e2bc1dcfef7e13e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sat, 7 Apr 2018 19:54:55 +0100 Subject: [PATCH 16/46] Explicitely specify the scope of FileSystem::Type enum. --- src/config/configureoptionsdialog.cpp | 6 +++--- src/config/generalpagewidget.cpp | 2 +- src/gui/editmountpointdialogwidget.cpp | 10 +++++----- src/gui/filesystemsupportdialog.cpp | 4 ++-- src/gui/infopane.cpp | 4 ++-- src/gui/newdialog.cpp | 12 ++++++------ src/gui/partitionmanagerwidget.cpp | 2 +- src/gui/partpropsdialog.cpp | 18 +++++++++--------- src/partitionmanager.kcfg | 2 +- src/util/guihelpers.cpp | 2 +- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/config/configureoptionsdialog.cpp b/src/config/configureoptionsdialog.cpp index f1a03e8..ddc4f6b 100644 --- a/src/config/configureoptionsdialog.cpp +++ b/src/config/configureoptionsdialog.cpp @@ -84,8 +84,8 @@ void ConfigureOptionsDialog::updateSettings() bool changed = false; - if (generalPageWidget().defaultFileSystem() != Config::defaultFileSystem()) { - Config::setDefaultFileSystem(generalPageWidget().defaultFileSystem()); + if (generalPageWidget().defaultFileSystem() != static_cast(Config::defaultFileSystem())) { + Config::setDefaultFileSystem(static_cast(generalPageWidget().defaultFileSystem())); changed = true; } @@ -109,7 +109,7 @@ bool ConfigureOptionsDialog::hasChanged() bool result = KConfigDialog::hasChanged(); KConfigSkeletonItem* kcItem = Config::self()->findItem(QStringLiteral("defaultFileSystem")); - result = result || !kcItem->isEqual(generalPageWidget().defaultFileSystem()); + result = result || !kcItem->isEqual(static_cast(generalPageWidget().defaultFileSystem())); result = result || (generalPageWidget().kcfg_shredSource->checkedId() != Config::shredSource()); if (advancedPageWidget().isVisible()) { diff --git a/src/config/generalpagewidget.cpp b/src/config/generalpagewidget.cpp index c4450dd..c596313 100644 --- a/src/config/generalpagewidget.cpp +++ b/src/config/generalpagewidget.cpp @@ -48,7 +48,7 @@ void GeneralPageWidget::setupDialog() { QStringList fsNames; for (const auto &fs : FileSystemFactory::map()) - if (fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Extended && fs->type() != FileSystem::Luks) + if (fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Type::Extended && fs->type() != FileSystem::Type::Luks) fsNames.append(fs->name()); std::sort(fsNames.begin(), fsNames.end(), caseInsensitiveLessThan); diff --git a/src/gui/editmountpointdialogwidget.cpp b/src/gui/editmountpointdialogwidget.cpp index ee5f739..e4099bf 100644 --- a/src/gui/editmountpointdialogwidget.cpp +++ b/src/gui/editmountpointdialogwidget.cpp @@ -42,7 +42,7 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio setupUi(this); m_deviceNode = partition().deviceNode(); - if (partition().roles().has(PartitionRole::Luks) && partition().fileSystem().type() != FileSystem::Luks) { + if (partition().roles().has(PartitionRole::Luks) && partition().fileSystem().type() != FileSystem::Type::Luks) { const FS::luks* luksFs = dynamic_cast(&partition().fileSystem()); m_deviceNode = luksFs->mapperName(); } @@ -54,7 +54,7 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio for (auto &e : m_fstabEntries) { QString canonicalEntryPath = QFileInfo(e.deviceNode()).canonicalFilePath(); QString canonicalDevicePath = QFileInfo(m_deviceNode).canonicalFilePath(); - if (canonicalEntryPath == canonicalDevicePath) { // FIXME fix multiple mountpoints + if (canonicalEntryPath == canonicalDevicePath) { entryFound = true; entry.push_back(&e); mountPointList = possibleMountPoints(e.deviceNode()); @@ -65,11 +65,11 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio FileSystem::Type type = partition().fileSystem().type(); QString fsName; switch (type) { - case FileSystem::LinuxSwap: + case FileSystem::Type::LinuxSwap: fsName = QStringLiteral("swap"); break; - case FileSystem::Fat16: - case FileSystem::Fat32: + case FileSystem::Type::Fat16: + case FileSystem::Type::Fat32: fsName = QStringLiteral("vfat"); break; default: diff --git a/src/gui/filesystemsupportdialog.cpp b/src/gui/filesystemsupportdialog.cpp index 1d61a1e..487b534 100644 --- a/src/gui/filesystemsupportdialog.cpp +++ b/src/gui/filesystemsupportdialog.cpp @@ -72,8 +72,8 @@ void FileSystemSupportDialog::setupDialog() dialogWidget().tree().clear(); for (const auto &fs : FileSystemFactory::map()) { - if (fs->type() == FileSystem::Unknown || fs->type() == FileSystem::Extended || - fs->type() == FileSystem::Luks || fs->type() == FileSystem::Luks2) { + if (fs->type() == FileSystem::Type::Unknown || fs->type() == FileSystem::Type::Extended || + fs->type() == FileSystem::Type::Luks || fs->type() == FileSystem::Type::Luks2) { continue; } diff --git a/src/gui/infopane.cpp b/src/gui/infopane.cpp index f3336e6..dce3c28 100644 --- a/src/gui/infopane.cpp +++ b/src/gui/infopane.cpp @@ -114,7 +114,7 @@ void InfoPane::showPartition(Qt::DockWidgetArea area, const Partition& p) int x = 0; int y = createHeader(p.deviceNode(), cols(area)); - if (p.fileSystem().type() == FileSystem::Luks) { // inactive LUKS partition + if (p.fileSystem().type() == FileSystem::Type::Luks) { // inactive LUKS partition const FS::luks* luksFs = static_cast(&p.fileSystem()); QString deviceNode = p.partitionPath(); createLabels(i18nc("@label partition", "File system:"), p.fileSystem().name(), cols(area), x, y); @@ -127,7 +127,7 @@ void InfoPane::showPartition(Qt::DockWidgetArea area, const Partition& p) createLabels(i18nc("@label partition", "First sector:"), QLocale().toString(p.firstSector()), cols(area), x, y); createLabels(i18nc("@label partition", "Last sector:"), QLocale().toString(p.lastSector()), cols(area), x, y); createLabels(i18nc("@label partition", "Number of sectors:"), QLocale().toString(p.length()), cols(area), x, y); - } else if (p.fileSystem().type() == FileSystem::Lvm2_PV) { + } else if (p.fileSystem().type() == FileSystem::Type::Lvm2_PV) { FS::lvm2_pv *lvm2PVFs; innerFS(&p, lvm2PVFs); QString deviceNode = p.partitionPath(); diff --git a/src/gui/newdialog.cpp b/src/gui/newdialog.cpp index cebba96..4dc5003 100644 --- a/src/gui/newdialog.cpp +++ b/src/gui/newdialog.cpp @@ -73,9 +73,9 @@ void NewDialog::setupDialog() QStringList fsNames; for (const auto &fs : FileSystemFactory::map()) { if (fs->supportCreate() != FileSystem::cmdSupportNone && - fs->type() != FileSystem::Extended && - fs->type() != FileSystem::Luks && - fs->type() != FileSystem::Luks2) + fs->type() != FileSystem::Type::Extended && + fs->type() != FileSystem::Type::Luks && + fs->type() != FileSystem::Type::Luks2) fsNames.append(fs->name()); } @@ -144,7 +144,7 @@ void NewDialog::accept() { if (partition().roles().has(PartitionRole::Extended)) { partition().deleteFileSystem(); - partition().setFileSystem(FileSystemFactory::create(FileSystem::Extended, + partition().setFileSystem(FileSystemFactory::create(FileSystem::Type::Extended, partition().firstSector(), partition().lastSector(), partition().sectorSize())); @@ -153,7 +153,7 @@ void NewDialog::accept() FileSystem::Type innerFsType = partition().fileSystem().type(); partition().deleteFileSystem(); FS::luks* luksFs = dynamic_cast< FS::luks* >( - FileSystemFactory::create(FileSystem::Luks, + FileSystemFactory::create(FileSystem::Type::Luks, partition().firstSector(), partition().lastSector(), partition().sectorSize())); @@ -188,7 +188,7 @@ void NewDialog::onRoleChanged(bool) // Also make sure to set a primary's or logical's file system once the user goes back from // extended to any of those. if (r == PartitionRole::Extended) - updateFileSystem(FileSystem::Extended); + updateFileSystem(FileSystem::Type::Extended); else updateFileSystem(FileSystem::typeForName(dialogWidget().comboFileSystem().currentText())); diff --git a/src/gui/partitionmanagerwidget.cpp b/src/gui/partitionmanagerwidget.cpp index 806fea2..1f5b874 100644 --- a/src/gui/partitionmanagerwidget.cpp +++ b/src/gui/partitionmanagerwidget.cpp @@ -208,7 +208,7 @@ static QTreeWidgetItem* createTreeWidgetItem(const Partition& p) int i = 0; item->setText(i++, p.deviceNode()); - if (p.roles().has(PartitionRole::Luks) && (p.fileSystem().name() != p.fileSystem().nameForType(FileSystem::Luks) && p.fileSystem().name() != p.fileSystem().nameForType(FileSystem::Luks2))) + if (p.roles().has(PartitionRole::Luks) && (p.fileSystem().name() != p.fileSystem().nameForType(FileSystem::Type::Luks) && p.fileSystem().name() != p.fileSystem().nameForType(FileSystem::Type::Luks2))) item->setText(i, xi18nc("@item:intable Encrypted file systems, e.g. btrfs[Encrypted]", "%1 [Encrypted]", p.fileSystem().name())); else item->setText(i, p.fileSystem().name()); diff --git a/src/gui/partpropsdialog.cpp b/src/gui/partpropsdialog.cpp index 8221e4a..f8bb36e 100644 --- a/src/gui/partpropsdialog.cpp +++ b/src/gui/partpropsdialog.cpp @@ -232,7 +232,7 @@ void PartPropsDialog::updateHideAndShow() partition().state() != Partition::StateNew && // not for new partitions !partition().roles().has(PartitionRole::Extended) && // neither for extended !partition().roles().has(PartitionRole::Unallocated) && // or for unallocated - newFileSystemType() != FileSystem::Unformatted; // and not for unformatted file systems + newFileSystemType() != FileSystem::Type::Unformatted; // and not for unformatted file systems dialogWidget().showAvailable(showAvailableAndUsed); dialogWidget().showUsed(showAvailableAndUsed); @@ -242,14 +242,14 @@ void PartPropsDialog::updateHideAndShow() !partition().roles().has(PartitionRole::Extended) && // not for extended, they have no file system !partition().roles().has(PartitionRole::Unallocated) && // and not for unallocated: no choice there // do now show file system comboBox for open luks volumes. - !(partition().roles().has(PartitionRole::Luks) && partition().fileSystem().type() != FileSystem::Luks); + !(partition().roles().has(PartitionRole::Luks) && partition().fileSystem().type() != FileSystem::Type::Luks); dialogWidget().showFileSystem(showFileSystem); // when do we show the recreate file system check box? const bool showCheckRecreate = showFileSystem && // only if we also show the file system partition().fileSystem().supportCreate() != FileSystem::cmdSupportNone && // and support creating this file system - partition().fileSystem().type() != FileSystem::Unknown && // and not for unknown file systems + partition().fileSystem().type() != FileSystem::Type::Unknown && // and not for unknown file systems partition().state() != Partition::StateNew && // or new partitions !partition().roles().has(PartitionRole::Luks); // or encrypted filesystems @@ -297,7 +297,7 @@ void PartPropsDialog::setupFileSystemComboBox() for(const auto &fs : FileSystemFactory::map()) { // If the partition isn't encrypted, skip the luks FS - if (fs->type() == FileSystem::Luks && partition().fileSystem().type() != FileSystem::Luks) + if (fs->type() == FileSystem::Type::Luks && partition().fileSystem().type() != FileSystem::Type::Luks) continue; if (partition().fileSystem().type() == fs->type() || (fs->supportCreate() != FileSystem::cmdSupportNone && partition().capacity() >= fs->minCapacity() && partition().capacity() <= fs->maxCapacity())) { @@ -307,16 +307,16 @@ void PartPropsDialog::setupFileSystemComboBox() selected = name; // If the partition isn't extended, skip the extended FS - if (fs->type() == FileSystem::Extended && !partition().roles().has(PartitionRole::Extended)) + if (fs->type() == FileSystem::Type::Extended && !partition().roles().has(PartitionRole::Extended)) continue; // The user cannot change the filesystem back to "unformatted" once a filesystem has been created. - if (fs->type() == FileSystem::Unformatted) { + if (fs->type() == FileSystem::Type::Unformatted) { // .. but if the file system is unknown to us, show the unformatted option as the currently selected one - if (partition().fileSystem().type() == FileSystem::Unknown) { - name = FileSystem::nameForType(FileSystem::Unformatted); + if (partition().fileSystem().type() == FileSystem::Type::Unknown) { + name = FileSystem::nameForType(FileSystem::Type::Unformatted); selected = name; - } else if (partition().fileSystem().type() != FileSystem::Unformatted && partition().state() != Partition::StateNew) + } else if (partition().fileSystem().type() != FileSystem::Type::Unformatted && partition().state() != Partition::StateNew) continue; } diff --git a/src/partitionmanager.kcfg b/src/partitionmanager.kcfg index 6513c27..7d5992c 100644 --- a/src/partitionmanager.kcfg +++ b/src/partitionmanager.kcfg @@ -130,7 +130,7 @@ - FileSystem::Type::Ext4 + static_cast<int>(FileSystem::Type::Ext4) diff --git a/src/util/guihelpers.cpp b/src/util/guihelpers.cpp index 54048b5..464d85a 100644 --- a/src/util/guihelpers.cpp +++ b/src/util/guihelpers.cpp @@ -45,7 +45,7 @@ QIcon createFileSystemColor(FileSystem::Type type, quint32 size) QPixmap pixmap(size, size); QPainter painter(&pixmap); painter.setPen(QColor(0, 0, 0)); - painter.setBrush(Config::fileSystemColorCode(type)); + painter.setBrush(Config::fileSystemColorCode(static_cast(type))); painter.drawRect(QRect(0, 0, pixmap.width() - 1, pixmap.height() - 1)); painter.end(); From 96693a8455457e9c58ea5a6f16649e9556405fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 9 Apr 2018 02:58:03 +0100 Subject: [PATCH 17/46] Switch Device::Type enum to enum class. --- src/gui/devicepropsdialog.cpp | 4 ++-- src/gui/infopane.cpp | 4 ++-- src/gui/mainwindow.cpp | 14 +++++++------- src/gui/newdialog.cpp | 4 ++-- src/gui/partitionmanagerwidget.cpp | 2 +- src/gui/resizedialog.cpp | 4 ++-- src/gui/sizedialogbase.cpp | 6 +++--- src/partitionmanager.kcfg | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/gui/devicepropsdialog.cpp b/src/gui/devicepropsdialog.cpp index f925911..342bd77 100644 --- a/src/gui/devicepropsdialog.cpp +++ b/src/gui/devicepropsdialog.cpp @@ -106,7 +106,7 @@ void DevicePropsDialog::setupDialog() dialogWidget().capacity().setText(Capacity::formatByteSize(device().capacity())); dialogWidget().totalSectors().setText(QLocale().toString(device().totalLogical())); - if (device().type() == Device::Disk_Device) { + if (device().type() == Device::Type::Disk_Device) { const DiskDevice& disk = dynamic_cast(device()); @@ -127,7 +127,7 @@ void DevicePropsDialog::setupDialog() dialogWidget().buttonSmartMore().setVisible(false); } } else { - if (device().type() == Device::LVM_Device) + if (device().type() == Device::Type::LVM_Device) dialogWidget().type().setText(xi18nc("@label device", "LVM Volume Group")); else dialogWidget().type().setText(xi18nc("@label device", "Volume Manager Device")); diff --git a/src/gui/infopane.cpp b/src/gui/infopane.cpp index dce3c28..b749719 100644 --- a/src/gui/infopane.cpp +++ b/src/gui/infopane.cpp @@ -176,7 +176,7 @@ void InfoPane::showDevice(Qt::DockWidgetArea area, const Device& d) maxPrimaries = QStringLiteral("%1/%2").arg(d.partitionTable()->numPrimaries()).arg(d.partitionTable()->maxPrimaries()); } - if (d.type() == Device::Disk_Device) { + if (d.type() == Device::Type::Disk_Device) { const DiskDevice& disk = dynamic_cast(d); createLabels(i18nc("@label device", "Type:"), type, cols(area), x, y); @@ -185,7 +185,7 @@ void InfoPane::showDevice(Qt::DockWidgetArea area, const Device& d) createLabels(i18nc("@label device", "Logical sector size:"), Capacity::formatByteSize(disk.logicalSectorSize()), cols(area), x, y); createLabels(i18nc("@label device", "Physical sector size:"), Capacity::formatByteSize(disk.physicalSectorSize()), cols(area), x, y); createLabels(i18nc("@label device", "Primaries/Max:"), maxPrimaries, cols(area), x, y); - } else if (d.type() == Device::LVM_Device) { + } else if (d.type() == Device::Type::LVM_Device) { const LvmDevice& lvm = dynamic_cast(d); createLabels(i18nc("@label device", "Volume Type:"), QStringLiteral("LVM"), cols(area), x, y); createLabels(i18nc("@label device", "Capacity:"), Capacity::formatByteSize(lvm.capacity()), cols(area), x, y); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 107a6f2..dbc8aff 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -481,7 +481,7 @@ void MainWindow::enableActions() actionCollection()->action(QStringLiteral("createNewPartitionTable")) ->setEnabled(CreatePartitionTableOperation::canCreate(pmWidget().selectedDevice())); actionCollection()->action(QStringLiteral("createNewPartitionTable")) - ->setVisible(pmWidget().selectedDevice() && pmWidget().selectedDevice()->type() == Device::Disk_Device); + ->setVisible(pmWidget().selectedDevice() && pmWidget().selectedDevice()->type() == Device::Type::Disk_Device); actionCollection()->action(QStringLiteral("exportPartitionTable")) ->setEnabled(pmWidget().selectedDevice() && pmWidget().selectedDevice()->partitionTable() && @@ -489,10 +489,10 @@ void MainWindow::enableActions() actionCollection()->action(QStringLiteral("importPartitionTable")) ->setEnabled(CreatePartitionTableOperation::canCreate(pmWidget().selectedDevice())); actionCollection()->action(QStringLiteral("smartStatusDevice")) - ->setEnabled(pmWidget().selectedDevice() != nullptr && pmWidget().selectedDevice()->type() == Device::Disk_Device && + ->setEnabled(pmWidget().selectedDevice() != nullptr && pmWidget().selectedDevice()->type() == Device::Type::Disk_Device && pmWidget().selectedDevice()->smartStatus().isValid()); actionCollection()->action(QStringLiteral("smartStatusDevice")) - ->setVisible(pmWidget().selectedDevice() != nullptr && pmWidget().selectedDevice()->type() == Device::Disk_Device); + ->setVisible(pmWidget().selectedDevice() != nullptr && pmWidget().selectedDevice()->type() == Device::Type::Disk_Device); actionCollection()->action(QStringLiteral("propertiesDevice")) ->setEnabled(pmWidget().selectedDevice() != nullptr); @@ -510,7 +510,7 @@ void MainWindow::enableActions() actionCollection()->action(QStringLiteral("createVolumeGroup")) ->setEnabled(CreateVolumeGroupOperation::canCreate()); - bool lvmDevice = pmWidget().selectedDevice() && pmWidget().selectedDevice()->type() == Device::LVM_Device; + bool lvmDevice = pmWidget().selectedDevice() && pmWidget().selectedDevice()->type() == Device::Type::LVM_Device; bool removable = false; if (lvmDevice) @@ -1111,7 +1111,7 @@ void MainWindow::onCreateNewVolumeGroup() void MainWindow::onResizeVolumeGroup() { - if (pmWidget().selectedDevice()->type() == Device::LVM_Device) { + if (pmWidget().selectedDevice()->type() == Device::Type::LVM_Device) { LvmDevice* d = dynamic_cast(pmWidget().selectedDevice()); QVector pvList; @@ -1128,7 +1128,7 @@ void MainWindow::onResizeVolumeGroup() void MainWindow::onRemoveVolumeGroup() { Device* tmpDev = pmWidget().selectedDevice(); - if (tmpDev->type() == Device::LVM_Device) { + if (tmpDev->type() == Device::Type::LVM_Device) { operationStack().push(new RemoveVolumeGroupOperation(*(dynamic_cast(tmpDev)))); } } @@ -1136,7 +1136,7 @@ void MainWindow::onRemoveVolumeGroup() void MainWindow::onDeactivateVolumeGroup() { Device* tmpDev = pmWidget().selectedDevice(); - if (tmpDev->type() == Device::LVM_Device) { + if (tmpDev->type() == Device::Type::LVM_Device) { DeactivateVolumeGroupOperation* deactivate = new DeactivateVolumeGroupOperation( *(dynamic_cast(tmpDev)) ); Report* tmpReport = new Report(nullptr); if (deactivate->execute(*tmpReport)) { diff --git a/src/gui/newdialog.cpp b/src/gui/newdialog.cpp index 4dc5003..dda216e 100644 --- a/src/gui/newdialog.cpp +++ b/src/gui/newdialog.cpp @@ -102,7 +102,7 @@ void NewDialog::setupDialog() dialogWidget().checkBoxEncrypt().hide(); dialogWidget().editPassphrase().hide(); - if (device().type() == Device::LVM_Device) { + if (device().type() == Device::Type::LVM_Device) { dialogWidget().comboFileSystem().removeItem(dialogWidget().comboFileSystem().findText(QStringLiteral("lvm2 pv"))); } @@ -137,7 +137,7 @@ void NewDialog::setupConnections() bool NewDialog::canMove() const { - return (device().type() == Device::LVM_Device) ? false : true; + return (device().type() == Device::Type::LVM_Device) ? false : true; } void NewDialog::accept() diff --git a/src/gui/partitionmanagerwidget.cpp b/src/gui/partitionmanagerwidget.cpp index 1f5b874..3c8243d 100644 --- a/src/gui/partitionmanagerwidget.cpp +++ b/src/gui/partitionmanagerwidget.cpp @@ -605,7 +605,7 @@ void PartitionManagerWidget::onResizePartition() qint64 freeBefore = selectedDevice()->partitionTable()->freeSectorsBefore(p); qint64 freeAfter = selectedDevice()->partitionTable()->freeSectorsAfter(p); - if (selectedDevice()->type() == Device::LVM_Device) { + if (selectedDevice()->type() == Device::Type::LVM_Device) { freeBefore = 0; freeAfter = selectedDevice()->partitionTable()->freeSectors(); } diff --git a/src/gui/resizedialog.cpp b/src/gui/resizedialog.cpp index 886e614..6ab5aa8 100644 --- a/src/gui/resizedialog.cpp +++ b/src/gui/resizedialog.cpp @@ -130,7 +130,7 @@ void ResizeDialog::reject() void ResizeDialog::setupDialog() { SizeDialogBase::setupDialog(); - if (device().type() == Device::LVM_Device) { + if (device().type() == Device::Type::LVM_Device) { dialogWidget().hideBeforeAndAfter(); detailsWidget().checkAlign().setChecked(false); detailsWidget().checkAlign().setEnabled(false); @@ -162,5 +162,5 @@ bool ResizeDialog::canShrink() const bool ResizeDialog::canMove() const { - return (device().type() == Device::LVM_Device) ? false : ResizeOperation::canMove(&partition()); + return (device().type() == Device::Type::LVM_Device) ? false : ResizeOperation::canMove(&partition()); } diff --git a/src/gui/sizedialogbase.cpp b/src/gui/sizedialogbase.cpp index 7a2d499..02e89b2 100644 --- a/src/gui/sizedialogbase.cpp +++ b/src/gui/sizedialogbase.cpp @@ -105,11 +105,11 @@ void SizeDialogBase::setupDialog() dialogWidget().partResizerWidget().init(device(), partition(), minimumFirstSector(), maximumLastSector(), true, canMove()); dialogWidget().partResizerWidget().setAlign(Config::alignDefault()); - if (device().type() == Device::Disk_Device) { + if (device().type() == Device::Type::Disk_Device) { dialogWidget().lvName().hide(); dialogWidget().textLVName().hide(); } - if (device().type() == Device::LVM_Device) { + if (device().type() == Device::Type::LVM_Device) { dialogWidget().hideBeforeAndAfter(); detailsWidget().checkAlign().setChecked(false); detailsWidget().checkAlign().setEnabled(false); @@ -380,7 +380,7 @@ void SizeDialogBase::onLVNameChanged(const QString& newName) partition().setPartitionPath(device().deviceNode() + QStringLiteral("/") + newName.trimmed()); if ((dialogWidget().lvName().isVisible() && dialogWidget().lvName().text().isEmpty()) || - (device().type() == Device::LVM_Device && + (device().type() == Device::Type::LVM_Device && dynamic_cast(device()).partitionNodes().contains(partition().partitionPath())) ) { m_IsValidLVName = false; } else { diff --git a/src/partitionmanager.kcfg b/src/partitionmanager.kcfg index 7d5992c..8c858fc 100644 --- a/src/partitionmanager.kcfg +++ b/src/partitionmanager.kcfg @@ -130,7 +130,7 @@ - static_cast<int>(FileSystem::Type::Ext4) + static_cast<int>(FileSystem::Type::Ext4) From e9ac1cf977ff838a35d4b8a2e8315d06828e943f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 9 Apr 2018 15:14:48 +0100 Subject: [PATCH 18/46] Adjust to kpmcore enum changes. --- src/gui/editmountpointdialogwidget.cpp | 14 +++++++------- src/gui/editmountpointdialogwidget.h | 2 +- src/gui/mainwindow.cpp | 6 +++--- src/gui/partitionmanagerwidget.cpp | 8 ++++---- src/gui/partpropsdialog.cpp | 16 ++++++++-------- src/gui/resizedialog.cpp | 2 +- src/gui/sizedialogbase.cpp | 2 +- src/gui/smartdialog.cpp | 8 ++++---- src/gui/treelog.cpp | 4 ++-- src/gui/volumegroupdialog.cpp | 4 ++-- 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/gui/editmountpointdialogwidget.cpp b/src/gui/editmountpointdialogwidget.cpp index e4099bf..768aef4 100644 --- a/src/gui/editmountpointdialogwidget.cpp +++ b/src/gui/editmountpointdialogwidget.cpp @@ -127,7 +127,7 @@ void EditMountPointDialogWidget::setupOptions(const QStringList& options) m_Options = optTmpList.join(QLatin1Char(',')); } -void EditMountPointDialogWidget::setupRadio(const FstabEntryType entryType) +void EditMountPointDialogWidget::setupRadio(const FstabEntry::Type entryType) { if (partition().fileSystem().uuid().isEmpty()) { radioUUID().setEnabled(false); @@ -141,26 +141,26 @@ void EditMountPointDialogWidget::setupRadio(const FstabEntryType entryType) radioDeviceNode().setChecked(true); } switch (entryType) { - case FstabEntryType::uuid: + case FstabEntry::Type::uuid: radioUUID().setChecked(true); break; - case FstabEntryType::label: + case FstabEntry::Type::label: radioLabel().setChecked(true); break; - case FstabEntryType::partuuid: + case FstabEntry::Type::partuuid: radioUUID().setChecked(true); break; - case FstabEntryType::partlabel: + case FstabEntry::Type::partlabel: radioLabel().setChecked(true); break; - case FstabEntryType::deviceNode: + case FstabEntry::Type::deviceNode: radioDeviceNode().setChecked(true); break; - case FstabEntryType::comment: + case FstabEntry::Type::comment: break; } } diff --git a/src/gui/editmountpointdialogwidget.h b/src/gui/editmountpointdialogwidget.h index b1d7ad9..e248b21 100644 --- a/src/gui/editmountpointdialogwidget.h +++ b/src/gui/editmountpointdialogwidget.h @@ -84,7 +84,7 @@ protected: private: void setupOptions(const QStringList& options); - void setupRadio(const FstabEntryType entryType); + void setupRadio(const FstabEntry::Type entryType); std::map& boxOptions() { return m_BoxOptions; } diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index dbc8aff..29eb69b 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -704,7 +704,7 @@ void MainWindow::on_m_PartitionManagerWidget_selectedPartitionChanged(const Part void MainWindow::scanDevices() { - Log(Log::information) << xi18nc("@info:progress", "Using backend plugin: %1 (%2)", + Log(Log::Level::information) << xi18nc("@info:progress", "Using backend plugin: %1 (%2)", CoreBackendManager::self()->backend()->id(), CoreBackendManager::self()->backend()->version()); @@ -1054,11 +1054,11 @@ void MainWindow::onImportPartitionTable() if (fs->supportSetLabel() != FileSystem::cmdSupportNone && !volumeLabel.isEmpty()) fs->setLabel(volumeLabel); - Partition* p = new Partition(parent, device, role, fs, firstSector, lastSector, QString(), PartitionTable::FlagNone, QString(), false, PartitionTable::FlagNone, Partition::StateNew); + Partition* p = new Partition(parent, device, role, fs, firstSector, lastSector, QString(), PartitionTable::FlagNone, QString(), false, PartitionTable::FlagNone, Partition::State::New); operationStack().push(new NewOperation(device, p)); } else - Log(Log::warning) << xi18nc("@info:status", "Could not parse line %1 from import file. Ignoring it.", lineNo); + Log(Log::Level::warning) << xi18nc("@info:status", "Could not parse line %1 from import file. Ignoring it.", lineNo); } if (ptable->type() == PartitionTable::msdos && ptable->isSectorBased(device)) diff --git a/src/gui/partitionmanagerwidget.cpp b/src/gui/partitionmanagerwidget.cpp index 3c8243d..4bdb11d 100644 --- a/src/gui/partitionmanagerwidget.cpp +++ b/src/gui/partitionmanagerwidget.cpp @@ -569,11 +569,11 @@ void PartitionManagerWidget::onDeletePartition(bool shred) } if (shred && Config::shredSource() == Config::EnumShredSource::random) - operationStack().push(new DeleteOperation(*selectedDevice(), selectedPartition(), DeleteOperation::RandomShred)); + operationStack().push(new DeleteOperation(*selectedDevice(), selectedPartition(), DeleteOperation::ShredAction::RandomShred)); else if (shred && Config::shredSource() == Config::EnumShredSource::zeros) - operationStack().push(new DeleteOperation(*selectedDevice(), selectedPartition(), DeleteOperation::ZeroShred)); + operationStack().push(new DeleteOperation(*selectedDevice(), selectedPartition(), DeleteOperation::ShredAction::ZeroShred)); else - operationStack().push(new DeleteOperation(*selectedDevice(), selectedPartition(), DeleteOperation::NoShred)); + operationStack().push(new DeleteOperation(*selectedDevice(), selectedPartition(), DeleteOperation::ShredAction::NoShred)); } void PartitionManagerWidget::onShredPartition() @@ -614,7 +614,7 @@ void PartitionManagerWidget::onResizePartition() if (dlg->exec() == QDialog::Accepted) { if (dlg->resizedFirstSector() == p.firstSector() && dlg->resizedLastSector() == p.lastSector()) - Log(Log::information) << xi18nc("@info:status", "Partition %1 has the same position and size after resize/move. Ignoring operation.", p.deviceNode()); + Log(Log::Level::information) << xi18nc("@info:status", "Partition %1 has the same position and size after resize/move. Ignoring operation.", p.deviceNode()); else operationStack().push(new ResizeOperation(*selectedDevice(), p, dlg->resizedFirstSector(), dlg->resizedLastSector())); } diff --git a/src/gui/partpropsdialog.cpp b/src/gui/partpropsdialog.cpp index f8bb36e..e586fe1 100644 --- a/src/gui/partpropsdialog.cpp +++ b/src/gui/partpropsdialog.cpp @@ -51,7 +51,7 @@ PartPropsDialog::PartPropsDialog(QWidget* parent, Device& d, Partition& p) : m_Partition(p), m_WarnFileSystemChange(false), m_DialogWidget(new PartPropsWidget(this)), - m_ReadOnly(partition().isMounted() || partition().state() == Partition::StateCopy || partition().state() == Partition::StateRestore || d.partitionTable()->isReadOnly()), + m_ReadOnly(partition().isMounted() || partition().state() == Partition::State::Copy || partition().state() == Partition::State::Restore || d.partitionTable()->isReadOnly()), m_ForceRecreate(false) { mainLayout = new QVBoxLayout(this); @@ -152,7 +152,7 @@ void PartPropsDialog::setupDialog() dialogWidget().label().setText(newLabel().isEmpty() ? partition().fileSystem().label() : newLabel()); dialogWidget().capacity().setText(Capacity::formatByteSize(partition().capacity())); - if (Capacity(partition(), Capacity::Available).isValid()) { + if (Capacity(partition(), Capacity::Type::Available).isValid()) { const qint64 availPercent = (partition().fileSystem().length() - partition().fileSystem().sectorsUsed()) * 100 / partition().fileSystem().length(); const QString availString = QStringLiteral("%1% - %2") @@ -220,7 +220,7 @@ void PartPropsDialog::updateHideAndShow() // when do we show the uuid? const bool showUuid = - partition().state() != Partition::StateNew && // not for new partitions + partition().state() != Partition::State::New && // not for new partitions !(fs == nullptr || fs->supportGetUUID() == FileSystem::cmdSupportNone); // not if the FS doesn't support it dialogWidget().showUuid(showUuid); @@ -229,7 +229,7 @@ void PartPropsDialog::updateHideAndShow() // when do we show available and used capacity? const bool showAvailableAndUsed = - partition().state() != Partition::StateNew && // not for new partitions + partition().state() != Partition::State::New && // not for new partitions !partition().roles().has(PartitionRole::Extended) && // neither for extended !partition().roles().has(PartitionRole::Unallocated) && // or for unallocated newFileSystemType() != FileSystem::Type::Unformatted; // and not for unformatted file systems @@ -250,14 +250,14 @@ void PartPropsDialog::updateHideAndShow() showFileSystem && // only if we also show the file system partition().fileSystem().supportCreate() != FileSystem::cmdSupportNone && // and support creating this file system partition().fileSystem().type() != FileSystem::Type::Unknown && // and not for unknown file systems - partition().state() != Partition::StateNew && // or new partitions + partition().state() != Partition::State::New && // or new partitions !partition().roles().has(PartitionRole::Luks); // or encrypted filesystems dialogWidget().showCheckRecreate(showCheckRecreate); // when do we show the list of partition flags? const bool showListFlags = - partition().state() != Partition::StateNew && // not for new partitions + partition().state() != Partition::State::New && // not for new partitions !partition().roles().has(PartitionRole::Unallocated); // and not for unallocated space dialogWidget().showListFlags(showListFlags); @@ -316,7 +316,7 @@ void PartPropsDialog::setupFileSystemComboBox() if (partition().fileSystem().type() == FileSystem::Type::Unknown) { name = FileSystem::nameForType(FileSystem::Type::Unformatted); selected = name; - } else if (partition().fileSystem().type() != FileSystem::Type::Unformatted && partition().state() != Partition::StateNew) + } else if (partition().fileSystem().type() != FileSystem::Type::Unformatted && partition().state() != Partition::State::New) continue; } @@ -346,7 +346,7 @@ void PartPropsDialog::updatePartitionFileSystem() void PartPropsDialog::onFilesystemChanged(int) { - if (partition().state() == Partition::StateNew || warnFileSystemChange() || KMessageBox::warningContinueCancel(this, + if (partition().state() == Partition::State::New || warnFileSystemChange() || KMessageBox::warningContinueCancel(this, xi18nc("@info", "You are about to lose all data on partition %1." "Changing the file system on a partition already on disk will erase all its contents. If you continue now and apply the resulting operation in the main window, all data on %1 will unrecoverably be lost.", partition().deviceNode()), xi18nc("@title:window", "Really Recreate %1 with File System %2?", partition().deviceNode(), dialogWidget().fileSystem().currentText()), diff --git a/src/gui/resizedialog.cpp b/src/gui/resizedialog.cpp index 6ab5aa8..6e45b6e 100644 --- a/src/gui/resizedialog.cpp +++ b/src/gui/resizedialog.cpp @@ -91,7 +91,7 @@ void ResizeDialog::accept() if (partition().roles().has(PartitionRole::Luks)) { FS::luks2* luksFs = dynamic_cast(&partition().fileSystem()); if (luksFs) { - if (luksFs->keyLocation() == FS::luks::keyring) { + if (luksFs->keyLocation() == FS::luks::KeyLocation::keyring) { bool validPassphrase = false; QString errorMessage; QString passphrase; diff --git a/src/gui/sizedialogbase.cpp b/src/gui/sizedialogbase.cpp index 02e89b2..7116756 100644 --- a/src/gui/sizedialogbase.cpp +++ b/src/gui/sizedialogbase.cpp @@ -467,6 +467,6 @@ static double sectorsToDialogUnit(const Device& d, qint64 v) static qint64 dialogUnitToSectors(const Device& d, double v) { - return v * Capacity::unitFactor(Capacity::Byte, preferredUnit()) / d.logicalSize(); + return v * Capacity::unitFactor(Capacity::Unit::Byte, preferredUnit()) / d.logicalSize(); } diff --git a/src/gui/smartdialog.cpp b/src/gui/smartdialog.cpp index cacffbe..78c6c64 100644 --- a/src/gui/smartdialog.cpp +++ b/src/gui/smartdialog.cpp @@ -121,8 +121,8 @@ void SmartDialog::setupDialog() QStringList() << QLocale().toString(a.id()) << QStringLiteral("%1
%2").arg(a.name()).arg(st + a.desc() + QStringLiteral("")) - << (a.failureType() == SmartAttribute::PreFailure ? xi18nc("@item:intable", "Pre-Failure") : xi18nc("@item:intable", "Old-Age")) - << (a.updateType() == SmartAttribute::Online ? xi18nc("@item:intable", "Online") : xi18nc("@item:intable", "Offline")) + << (a.failureType() == SmartAttribute::FailureType::PreFailure ? xi18nc("@item:intable", "Pre-Failure") : xi18nc("@item:intable", "Old-Age")) + << (a.updateType() == SmartAttribute::UpdateType::Online ? xi18nc("@item:intable", "Online") : xi18nc("@item:intable", "Offline")) << QLocale().toString(a.worst()) << QLocale().toString(a.current()) << QLocale().toString(a.threshold()) @@ -187,8 +187,8 @@ QString SmartDialog::toHtml() const s << "" << QLocale().toString(a.id()) << "\n" << "" << QStringLiteral("%1
%2").arg(a.name()).arg(st + a.desc() + QStringLiteral("")) << "\n" - << "" << (a.failureType() == SmartAttribute::PreFailure ? xi18nc("@item:intable", "Pre-Failure") : xi18nc("@item:intable", "Old-Age")) << "\n" - << "" << (a.updateType() == SmartAttribute::Online ? xi18nc("@item:intable", "Online") : xi18nc("@item:intable", "Offline")) << "\n" + << "" << (a.failureType() == SmartAttribute::FailureType::PreFailure ? xi18nc("@item:intable", "Pre-Failure") : xi18nc("@item:intable", "Old-Age")) << "\n" + << "" << (a.updateType() == SmartAttribute::UpdateType::Online ? xi18nc("@item:intable", "Online") : xi18nc("@item:intable", "Offline")) << "\n" << "" << QLocale().toString(a.worst()) << "\n" << "" << QLocale().toString(a.current()) << "\n" << "" << QLocale().toString(a.threshold()) << "\n" diff --git a/src/gui/treelog.cpp b/src/gui/treelog.cpp index d1bb792..9cd0f6d 100644 --- a/src/gui/treelog.cpp +++ b/src/gui/treelog.cpp @@ -150,10 +150,10 @@ void TreeLog::onNewLogMessage(Log::Level logLevel, const QString& s) qDebug() << s; - if (logLevel >= Config::minLogLevel()) { + if (static_cast(logLevel) >= Config::minLogLevel()) { QTreeWidgetItem* item = new QTreeWidgetItem(); - item->setIcon(0, QIcon::fromTheme(icons[logLevel]).pixmap(IconSize(KIconLoader::Small))); + item->setIcon(0, QIcon::fromTheme(icons[static_cast(logLevel)]).pixmap(IconSize(KIconLoader::Small))); item->setText(1, QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd hh:mm:ss"))); item->setText(2, s); diff --git a/src/gui/volumegroupdialog.cpp b/src/gui/volumegroupdialog.cpp index 8434bee..70edf02 100644 --- a/src/gui/volumegroupdialog.cpp +++ b/src/gui/volumegroupdialog.cpp @@ -127,7 +127,7 @@ void VolumeGroupDialog::updateSectorInfos() { qint32 totalSectors = 0; // we can't use LvmDevice mothod here because pv that is not in any VG will return 0 - m_ExtentSize = dialogWidget().spinPESize().value() * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + m_ExtentSize = dialogWidget().spinPESize().value() * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); if (m_ExtentSize > 0) { totalSectors = m_TotalSize / m_ExtentSize; } @@ -139,7 +139,7 @@ void VolumeGroupDialog::updateSizeInfos() const QVector checkedPartitions = dialogWidget().listPV().checkedItems(); m_TotalSize = 0; for (const auto &p : checkedPartitions) - m_TotalSize += p->capacity() - p->capacity() % (dialogWidget().spinPESize().value() * Capacity::unitFactor(Capacity::Byte, Capacity::MiB)); // subtract space which is too small to hold PE + m_TotalSize += p->capacity() - p->capacity() % (dialogWidget().spinPESize().value() * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB)); // subtract space which is too small to hold PE dialogWidget().totalSize().setText(Capacity::formatByteSize(m_TotalSize)); From c0385aca3cbd50a591c2e8a0f85b8cabca81d5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Fri, 13 Apr 2018 14:25:11 +0300 Subject: [PATCH 19/46] CoreBackendManager -> CoreBackendManager::self(). --- src/gui/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 29eb69b..bda4390 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -162,7 +162,7 @@ void MainWindow::closeEvent(QCloseEvent* event) KXmlGuiWindow::closeEvent(event); - CoreBackendManager::stopExternalCommandHelper(); + CoreBackendManager::self()->stopExternalCommandHelper(); } void MainWindow::changeEvent(QEvent* event) From 200bb23b67c6985f983b0ad0ede7f1a965cbb24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Fri, 13 Apr 2018 16:05:13 +0300 Subject: [PATCH 20/46] Disable ok button when it is not visible. Otherwise it was possible to close the window before all cleanup is done and later crash the program. --- src/gui/applyprogressdialog.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/applyprogressdialog.cpp b/src/gui/applyprogressdialog.cpp index d9c1ae1..105b870 100644 --- a/src/gui/applyprogressdialog.cpp +++ b/src/gui/applyprogressdialog.cpp @@ -143,6 +143,7 @@ void ApplyProgressDialog::show() dialogWidget().treeTasks().clear(); okButton->setVisible(false); + okButton->setEnabled(false); cancelButton->setVisible(true); cancelButton->setEnabled(true); @@ -244,6 +245,7 @@ void ApplyProgressDialog::allOpsDone(const QString& msg) dialogWidget().progressTotal().setValue(operationRunner().numJobs()); cancelButton->setVisible(false); okButton->setVisible(true); + okButton->setEnabled(true); detailsWidget().buttonSave().setEnabled(true); detailsWidget().buttonBrowser().setEnabled(true); timer().stop(); From 1344021e1bdbcbf20cfb9f85f6cfa5aa135853e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sat, 14 Apr 2018 23:56:10 +0300 Subject: [PATCH 21/46] Move KAuth helper setup code to ExternalCommand class. --- src/gui/mainwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index bda4390..eb4f1e3 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -55,6 +55,7 @@ #include #include +#include #include #include #include @@ -161,8 +162,7 @@ void MainWindow::closeEvent(QCloseEvent* event) saveConfig(); KXmlGuiWindow::closeEvent(event); - - CoreBackendManager::self()->stopExternalCommandHelper(); + ExternalCommand::stopHelper(); } void MainWindow::changeEvent(QEvent* event) From 93f18ebd9f733c833155b6278fdb47f90b4ac22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 15 Apr 2018 01:03:41 +0300 Subject: [PATCH 22/46] Show MainWindow before KAuth dialog. --- src/gui/mainwindow.cpp | 4 +++- src/gui/scanprogressdialog.cpp | 1 + src/main.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index eb4f1e3..958f513 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -131,12 +131,14 @@ void MainWindow::init() listDevices().setActionCollection(actionCollection()); listOperations().setActionCollection(actionCollection()); - pmWidget().init(&operationStack()); setupGUI(); loadConfig(); + show(); + pmWidget().init(&operationStack()); + scanDevices(); } diff --git a/src/gui/scanprogressdialog.cpp b/src/gui/scanprogressdialog.cpp index 0e7740e..da673f4 100644 --- a/src/gui/scanprogressdialog.cpp +++ b/src/gui/scanprogressdialog.cpp @@ -26,6 +26,7 @@ ScanProgressDialog::ScanProgressDialog(QWidget* parent) : setWindowTitle(xi18nc("@title:window", "Scanning devices...")); setMinimumWidth(280); setMinimumDuration(150); + setValue(0); setAttribute(Qt::WA_ShowModal, true); } diff --git a/src/main.cpp b/src/main.cpp index 81dc244..bbea782 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -84,7 +84,7 @@ int Q_DECL_IMPORT main(int argc, char* argv[]) return 0; MainWindow* mainWindow = new MainWindow(); - mainWindow->show(); + Q_UNUSED(mainWindow); return app.exec(); } From 2846f9adbaaa92ca6a75e5ed078c2ab0e122dcf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 15 Apr 2018 01:35:55 +0300 Subject: [PATCH 23/46] Set KAuth parent widget. --- src/gui/mainwindow.cpp | 1 + src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 958f513..7355162 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -137,6 +137,7 @@ void MainWindow::init() loadConfig(); show(); + ExternalCommand::setParentWidget(this); pmWidget().init(&operationStack()); scanDevices(); diff --git a/src/main.cpp b/src/main.cpp index bbea782..db902a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -84,7 +84,7 @@ int Q_DECL_IMPORT main(int argc, char* argv[]) return 0; MainWindow* mainWindow = new MainWindow(); - Q_UNUSED(mainWindow); + Q_UNUSED(mainWindow) return app.exec(); } From 3054fa1599cf14d3a906e49e40d815ccae7b1ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 16 Apr 2018 22:25:59 +0300 Subject: [PATCH 24/46] Update copyright year. --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index db902a6..0d600b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ /************************************************************************* * Copyright (C) 2008,2011 by Volker Lanz * + * Copyright (C) 2014-2018 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -51,7 +52,7 @@ int Q_DECL_IMPORT main(int argc, char* argv[]) QStringLiteral(VERSION), xi18nc("@title", "Manage your disks, partitions and file systems"), KAboutLicense::GPL_V3, - xi18nc("@info:credit", "© 2008-2013 Volker Lanz\n© 2012-2017 Andrius Štikonas")); + xi18nc("@info:credit", "© 2008-2013 Volker Lanz\n© 2012-2018 Andrius Štikonas")); aboutData.setOrganizationDomain(QByteArray("kde.org")); aboutData.setProductName(QByteArray("partitionmanager")); From 2482eba7dea7e6f5e5bc1e459a2c610908a596b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Thu, 19 Apr 2018 14:29:22 +0300 Subject: [PATCH 25/46] Do not allow closing ScanProgressDialog BUG: 393275 --- src/gui/scanprogressdialog.cpp | 9 ++++++++- src/gui/scanprogressdialog.h | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/scanprogressdialog.cpp b/src/gui/scanprogressdialog.cpp index da673f4..b14049e 100644 --- a/src/gui/scanprogressdialog.cpp +++ b/src/gui/scanprogressdialog.cpp @@ -18,6 +18,8 @@ #include "gui/scanprogressdialog.h" +#include + #include ScanProgressDialog::ScanProgressDialog(QWidget* parent) : @@ -30,6 +32,11 @@ ScanProgressDialog::ScanProgressDialog(QWidget* parent) : setAttribute(Qt::WA_ShowModal, true); } +void ScanProgressDialog::closeEvent(QCloseEvent* e) +{ + e->ignore(); +} + void ScanProgressDialog::setDeviceName(const QString& d) { if (d.isEmpty()) @@ -40,7 +47,7 @@ void ScanProgressDialog::setDeviceName(const QString& d) void ScanProgressDialog::showEvent(QShowEvent* e) { - setCancelButton(0); + setCancelButton(nullptr); QProgressDialog::showEvent(e); } diff --git a/src/gui/scanprogressdialog.h b/src/gui/scanprogressdialog.h index c3bbb93..327828d 100644 --- a/src/gui/scanprogressdialog.h +++ b/src/gui/scanprogressdialog.h @@ -15,8 +15,7 @@ * along with this program. If not, see .* *************************************************************************/ -#if !defined(SCANPROGRESSDIALOG_H) - +#ifndef SCANPROGRESSDIALOG_H #define SCANPROGRESSDIALOG_H #include @@ -34,6 +33,7 @@ public: void setDeviceName(const QString& d); protected: + void closeEvent(QCloseEvent* e) override; void showEvent(QShowEvent* e) override; }; From af9fbe8a4ff273f85a874d3f33195aa5b6a166e0 Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Thu, 3 May 2018 20:50:42 -0300 Subject: [PATCH 26/46] - Allow creating LVM VG with PVs that are going to be created in OperationStack. - Check if there is another CreateVolumeGroupOperation with the LVM PV before listing it in the LVM VG creation widget. - Disallow creating VG with some PV that will be deleted. --- src/gui/createvolumegroupdialog.cpp | 53 +++++++++++++++++++++++++++-- src/gui/createvolumegroupdialog.h | 5 ++- src/gui/mainwindow.cpp | 2 +- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/src/gui/createvolumegroupdialog.cpp b/src/gui/createvolumegroupdialog.cpp index 09dcd12..e4c136b 100644 --- a/src/gui/createvolumegroupdialog.cpp +++ b/src/gui/createvolumegroupdialog.cpp @@ -19,10 +19,15 @@ #include "gui/createvolumegroupdialog.h" #include "gui/volumegroupwidget.h" +#include #include +#include #include +#include +#include + #include #include @@ -32,10 +37,11 @@ #include #include -CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QVector& partList, qint32& peSize, QList devices) +CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QVector& partList, qint32& peSize, QList devices, QList pendingOps) : VolumeGroupDialog(parent, vgName, partList) , m_PESize(peSize) , m_Devices(devices) + , m_PendingOps(pendingOps) { setWindowTitle(xi18nc("@title:window", "Create new Volume Group")); @@ -52,9 +58,44 @@ CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgNam void CreateVolumeGroupDialog::setupDialog() { - for (const auto &p : qAsConst(LVM::pvList)) + for (const auto &p : qAsConst(LVM::pvList)) { + bool toBeDeleted = false; + + // Ignore partitions that are going to be deleted + for (const auto &o : qAsConst(m_PendingOps)) { + if (dynamic_cast(o) && o->targets(*p.partition())) { + toBeDeleted = true; + break; + } + } + + if (toBeDeleted) + continue; + if (!p.isLuks() && p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition())) dialogWidget().listPV().addPartition(*p.partition(), false); + } + + for (const Device *d : qAsConst(m_Devices)) { + for (const Partition *p : qAsConst(d->partitionTable()->children())) { + bool alreadyInPendingVG = false; + + // Looking if there is another VG creation that contains this partition + for (const auto &o : qAsConst(m_PendingOps)) { + if (dynamic_cast(o) && o->targets(*p)) { + alreadyInPendingVG = true; + break; + } + } + + if (alreadyInPendingVG) + continue; + + // Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation) + if (p->state() == Partition::State::New && p->fileSystem().type() == FileSystem::Type::Lvm2_PV) + dialogWidget().listPV().addPartition(*p, false); + } + } } void CreateVolumeGroupDialog::setupConnections() @@ -76,6 +117,14 @@ void CreateVolumeGroupDialog::accept() QDialog::accept(); } +void CreateVolumeGroupDialog::updateOkButtonStatus() +{ + VolumeGroupDialog::updateOkButtonStatus(); + + if (okButton->isEnabled()) + okButton->setEnabled(!dialogWidget().listPV().checkedItems().empty()); +} + void CreateVolumeGroupDialog::onVGNameChanged(const QString& vgName) { for (const auto &d : m_Devices) { diff --git a/src/gui/createvolumegroupdialog.h b/src/gui/createvolumegroupdialog.h index 70d4867..1f40119 100644 --- a/src/gui/createvolumegroupdialog.h +++ b/src/gui/createvolumegroupdialog.h @@ -21,6 +21,7 @@ #include #include +#include #include "gui/volumegroupdialog.h" @@ -31,7 +32,7 @@ class CreateVolumeGroupDialog : public VolumeGroupDialog Q_DISABLE_COPY(CreateVolumeGroupDialog) public: - CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QVector& pvList, qint32& peSize, QList devices); + CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QVector& pvList, qint32& peSize, QList devices, QList pendingOps = QList()); protected: void accept() override; @@ -39,6 +40,7 @@ protected: void setupConnections() override; protected: + virtual void updateOkButtonStatus() override; void onVGNameChanged(const QString& vgname); void onSpinPESizeChanged(int newsize); @@ -50,6 +52,7 @@ protected: private: const QList m_Devices; // List of all devices found on the system + const QList m_PendingOps; // List of pending operations in KPM }; #endif diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 7355162..91500cf 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1105,7 +1105,7 @@ void MainWindow::onCreateNewVolumeGroup() QVector pvList; qint32 peSize = 4; // *NOTE*: vgName & pvList will be modified and validated by the dialog - QPointer dlg = new CreateVolumeGroupDialog(this, vgName, pvList, peSize, operationStack().previewDevices()); + QPointer dlg = new CreateVolumeGroupDialog(this, vgName, pvList, peSize, operationStack().previewDevices(), operationStack().operations()); if (dlg->exec() == QDialog::Accepted) operationStack().push(new CreateVolumeGroupOperation(vgName, pvList, peSize)); From d9b4ec0ce09916f43b0021c2f896407ebf83964e Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Mon, 7 May 2018 19:22:20 -0300 Subject: [PATCH 27/46] Disabling checkBoxEncrypt in Create New Partition dialog when cryptsetup tool is not found. --- src/gui/newdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/newdialog.cpp b/src/gui/newdialog.cpp index dda216e..f1686e3 100644 --- a/src/gui/newdialog.cpp +++ b/src/gui/newdialog.cpp @@ -269,7 +269,7 @@ void NewDialog::updateHideAndShow() dialogWidget().label().setReadOnly(false); dialogWidget().noSetLabel().setVisible(false); } - if (FS::luks::canEncryptType(FileSystem::typeForName(dialogWidget().comboFileSystem().currentText())) && !partition().roles().has(PartitionRole::Extended) ) + if (FileSystemFactory::map()[FileSystem::Type::Luks]->supportCreate() && FS::luks::canEncryptType(FileSystem::typeForName(dialogWidget().comboFileSystem().currentText())) && !partition().roles().has(PartitionRole::Extended)) { dialogWidget().checkBoxEncrypt().show(); if (dialogWidget().checkBoxEncrypt().isChecked()) From 7d5d1f8f8a1d88bb033fbf147baf20d8c851b729 Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Mon, 7 May 2018 20:21:14 -0300 Subject: [PATCH 28/46] Listing newly created encrypted LVM PVs in Create Volume Group dialog. --- src/gui/createvolumegroupdialog.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gui/createvolumegroupdialog.cpp b/src/gui/createvolumegroupdialog.cpp index e4c136b..1021676 100644 --- a/src/gui/createvolumegroupdialog.cpp +++ b/src/gui/createvolumegroupdialog.cpp @@ -92,8 +92,16 @@ void CreateVolumeGroupDialog::setupDialog() continue; // Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation) - if (p->state() == Partition::State::New && p->fileSystem().type() == FileSystem::Type::Lvm2_PV) - dialogWidget().listPV().addPartition(*p, false); + if (p->state() == Partition::State::New) { + if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV) + dialogWidget().listPV().addPartition(*p, false); + else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) { + FileSystem *fs = static_cast(&p->fileSystem())->innerFS(); + + if (fs->type() == FileSystem::Type::Lvm2_PV) + dialogWidget().listPV().addPartition(*p, false); + } + } } } } From 556a5a22ba41643d324452a884cda25bab40b65e Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Mon, 7 May 2018 22:16:58 -0300 Subject: [PATCH 29/46] Don't delete, shrink or move LVM PVs that are being targeted by CreateVolumeGroupOperations. --- src/gui/mainwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 91500cf..7a8eeaa 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -536,17 +536,17 @@ void MainWindow::enableActions() ->setEnabled(!readOnly && NewOperation::canCreateNew(part)); const bool canResize = ResizeOperation::canGrow(part) || - ResizeOperation::canShrink(part) || - ResizeOperation::canMove(part); + ResizeOperation::canShrink(part, m_OperationStack->operations()) || + ResizeOperation::canMove(part, m_OperationStack->operations()); actionCollection()->action(QStringLiteral("resizePartition")) ->setEnabled(!readOnly && canResize); actionCollection()->action(QStringLiteral("copyPartition")) ->setEnabled(CopyOperation::canCopy(part)); actionCollection()->action(QStringLiteral("deletePartition")) - ->setEnabled(!readOnly && DeleteOperation::canDelete(part)); + ->setEnabled(!readOnly && DeleteOperation::canDelete(part, m_OperationStack->operations())); actionCollection()->action(QStringLiteral("shredPartition")) - ->setEnabled(!readOnly && DeleteOperation::canDelete(part)); + ->setEnabled(!readOnly && DeleteOperation::canDelete(part, m_OperationStack->operations())); actionCollection()->action(QStringLiteral("pastePartition")) ->setEnabled(!readOnly && CopyOperation::canPaste(part, pmWidget().clipboardPartition())); actionCollection()->action(QStringLiteral("propertiesPartition")) From dfca46250e5ea5261d66e44223500cf1b94bdcb6 Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Wed, 9 May 2018 04:15:28 -0300 Subject: [PATCH 30/46] - Passing list of pending operations as argument to ResizeOperation::canGrow. - Access LVM::pvList through static list attribute. --- src/gui/createvolumegroupdialog.cpp | 2 +- src/gui/mainwindow.cpp | 2 +- src/gui/resizevolumegroupdialog.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/createvolumegroupdialog.cpp b/src/gui/createvolumegroupdialog.cpp index 1021676..b601d07 100644 --- a/src/gui/createvolumegroupdialog.cpp +++ b/src/gui/createvolumegroupdialog.cpp @@ -58,7 +58,7 @@ CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgNam void CreateVolumeGroupDialog::setupDialog() { - for (const auto &p : qAsConst(LVM::pvList)) { + for (const auto &p : qAsConst(LVM::pvList::list())) { bool toBeDeleted = false; // Ignore partitions that are going to be deleted diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 7a8eeaa..a1a7ac0 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -535,7 +535,7 @@ void MainWindow::enableActions() actionCollection()->action(QStringLiteral("newPartition")) ->setEnabled(!readOnly && NewOperation::canCreateNew(part)); - const bool canResize = ResizeOperation::canGrow(part) || + const bool canResize = ResizeOperation::canGrow(part, m_OperationStack->operations()) || ResizeOperation::canShrink(part, m_OperationStack->operations()) || ResizeOperation::canMove(part, m_OperationStack->operations()); actionCollection()->action(QStringLiteral("resizePartition")) diff --git a/src/gui/resizevolumegroupdialog.cpp b/src/gui/resizevolumegroupdialog.cpp index 7326c13..35ec4ab 100644 --- a/src/gui/resizevolumegroupdialog.cpp +++ b/src/gui/resizevolumegroupdialog.cpp @@ -51,7 +51,7 @@ ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerD void ResizeVolumeGroupDialog::setupDialog() { if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) { - for (const auto &p : qAsConst(LVM::pvList)) { + for (const auto &p : qAsConst(LVM::pvList::list())) { if (p.isLuks()) continue; if (p.vgName() == device()->name()) From 5a849d802b9fb44d75a1dbc776a5c47d95478846 Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Mon, 28 May 2018 16:24:31 -0300 Subject: [PATCH 31/46] Checking if a new partition is targeted by a new VG through LvmDevice::s_DirtyPVs list instead of searching for a CreateVolumeGroupOperation targeting this new partition. --- src/gui/createvolumegroupdialog.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/gui/createvolumegroupdialog.cpp b/src/gui/createvolumegroupdialog.cpp index b601d07..ca635be 100644 --- a/src/gui/createvolumegroupdialog.cpp +++ b/src/gui/createvolumegroupdialog.cpp @@ -78,17 +78,8 @@ void CreateVolumeGroupDialog::setupDialog() for (const Device *d : qAsConst(m_Devices)) { for (const Partition *p : qAsConst(d->partitionTable()->children())) { - bool alreadyInPendingVG = false; - // Looking if there is another VG creation that contains this partition - for (const auto &o : qAsConst(m_PendingOps)) { - if (dynamic_cast(o) && o->targets(*p)) { - alreadyInPendingVG = true; - break; - } - } - - if (alreadyInPendingVG) + if (LvmDevice::s_DirtyPVs.contains(p)) continue; // Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation) From 30815be85c2d567df1f56c3090c8e7123c957aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Fri, 8 Jun 2018 11:20:22 +0100 Subject: [PATCH 32/46] Remove Kdelibs4ConfigMigrator Config is no longer stored in root home folder, so migration cannot be done as we have no access to root folder when running as unprivileged user. --- src/gui/scanprogressdialog.h | 2 -- src/main.cpp | 6 ------ 2 files changed, 8 deletions(-) diff --git a/src/gui/scanprogressdialog.h b/src/gui/scanprogressdialog.h index 327828d..94e3261 100644 --- a/src/gui/scanprogressdialog.h +++ b/src/gui/scanprogressdialog.h @@ -20,8 +20,6 @@ #include -class QShowEvent; - class ScanProgressDialog : public QProgressDialog { public: diff --git a/src/main.cpp b/src/main.cpp index 0d600b7..578cef5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -40,11 +39,6 @@ int Q_DECL_IMPORT main(int argc, char* argv[]) { QApplication app(argc, argv); - Kdelibs4ConfigMigrator migrate(QLatin1Literal("partitionmanager")); - migrate.setConfigFiles({ QLatin1Literal("partitionmanagerrc") }); - migrate.setUiFiles({ QStringLiteral("partitionmanagerui.rc") }); - migrate.migrate(); - KLocalizedString::setApplicationDomain("partitionmanager"); KAboutData aboutData ( QStringLiteral("partitionmanager"), From cc43e8b706c400e3a4c1c84671608ca6771766af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sat, 7 Jul 2018 14:12:25 +0100 Subject: [PATCH 33/46] Fix out of bounds access. BUG: 396099 --- src/util/guihelpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/guihelpers.cpp b/src/util/guihelpers.cpp index 464d85a..49a537a 100644 --- a/src/util/guihelpers.cpp +++ b/src/util/guihelpers.cpp @@ -119,7 +119,7 @@ FileSystem::Type defaultFileSystem() std::vector fileSystemColorCodesFromSettings() { std::vector cc; - cc.reserve(Config::EnumFileSystem::type::COUNT); + cc.resize(Config::EnumFileSystem::type::COUNT); for (int i = 0; i < Config::EnumFileSystem::type::COUNT; ++i) { cc[i] = Config::fileSystemColorCode(i); From e7589702b9a54fff47d89fafd83589cef09ced8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 8 Jul 2018 10:57:16 +0100 Subject: [PATCH 34/46] Fix a compile warning. --- src/gui/applyprogressdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/applyprogressdialog.cpp b/src/gui/applyprogressdialog.cpp index 105b870..4d30dd4 100644 --- a/src/gui/applyprogressdialog.cpp +++ b/src/gui/applyprogressdialog.cpp @@ -366,7 +366,7 @@ void ApplyProgressDialog::addTaskOutput(int num, const Operation& op) item->setFont(0, f); item->setFont(1, f); - item->setData(0, Qt::UserRole, reinterpret_cast(&op)); + item->setData(0, Qt::UserRole, reinterpret_cast(&op)); dialogWidget().treeTasks().addTopLevelItem(item); dialogWidget().treeTasks().scrollToBottom(); setCurrentOpItem(item); From a606306e794a6dc0e879e588b7cd1e7ae06203f9 Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Wed, 11 Jul 2018 12:23:10 -0300 Subject: [PATCH 35/46] Showing SoftwareRAID device properties and allowing to create RAID device partition table. --- src/gui/devicepropsdialog.cpp | 2 ++ src/gui/infopane.cpp | 9 +++++++++ src/gui/mainwindow.cpp | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/devicepropsdialog.cpp b/src/gui/devicepropsdialog.cpp index 342bd77..883d11b 100644 --- a/src/gui/devicepropsdialog.cpp +++ b/src/gui/devicepropsdialog.cpp @@ -129,6 +129,8 @@ void DevicePropsDialog::setupDialog() } else { if (device().type() == Device::Type::LVM_Device) dialogWidget().type().setText(xi18nc("@label device", "LVM Volume Group")); + else if (device().type() == Device::Type::SoftwareRAID_Device) + dialogWidget().type().setText(xi18nc("@label device", "Software RAID Device")); else dialogWidget().type().setText(xi18nc("@label device", "Volume Manager Device")); //TODO: add Volume Manger Device info diff --git a/src/gui/infopane.cpp b/src/gui/infopane.cpp index b749719..dde9e53 100644 --- a/src/gui/infopane.cpp +++ b/src/gui/infopane.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -193,6 +194,14 @@ void InfoPane::showDevice(Qt::DockWidgetArea area, const Device& d) createLabels(i18nc("@label device", "Total PE:"),QString::number(lvm.totalPE()), cols(area), x, y); createLabels(i18nc("@label device", "Allocated PE:"), QString::number(lvm.allocatedPE()), cols(area), x, y); createLabels(i18nc("@label device", "Free PE:"), QString::number(lvm.freePE()), cols(area), x, y); + } else if (d.type() == Device::Type::SoftwareRAID_Device) { + const SoftwareRAID& raid = dynamic_cast(d); + createLabels(i18nc("@label device", "Volume Type:"), QStringLiteral("RAID"), cols(area), x, y); + createLabels(i18nc("@label device", "Capacity:"), Capacity::formatByteSize(raid.capacity()), cols(area), x, y); + createLabels(i18nc("@label device", "RAID Level:"), QString::number(raid.raidLevel()), cols(area), x, y); + createLabels(i18nc("@label device", "Chunk Size:"),Capacity::formatByteSize(raid.chunkSize()), cols(area), x, y); + createLabels(i18nc("@label device", "Total Chunk:"), Capacity::formatByteSize(raid.totalChunk()), cols(area), x, y); + createLabels(i18nc("@label device", "Array Size:"), Capacity::formatByteSize(raid.arraySize()), cols(area), x, y); } } diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index a1a7ac0..1304058 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -484,7 +484,8 @@ void MainWindow::enableActions() actionCollection()->action(QStringLiteral("createNewPartitionTable")) ->setEnabled(CreatePartitionTableOperation::canCreate(pmWidget().selectedDevice())); actionCollection()->action(QStringLiteral("createNewPartitionTable")) - ->setVisible(pmWidget().selectedDevice() && pmWidget().selectedDevice()->type() == Device::Type::Disk_Device); + ->setVisible(pmWidget().selectedDevice() && (pmWidget().selectedDevice()->type() == Device::Type::Disk_Device || + pmWidget().selectedDevice()->type() == Device::Type::SoftwareRAID_Device)); actionCollection()->action(QStringLiteral("exportPartitionTable")) ->setEnabled(pmWidget().selectedDevice() && pmWidget().selectedDevice()->partitionTable() && From 65eb5178f16c2c623da3c3981f8b8ca5904e85b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Thu, 12 Jul 2018 09:58:50 +0000 Subject: [PATCH 36/46] Static cast should be sufficient We manually check device type jsut before cast --- src/gui/infopane.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/infopane.cpp b/src/gui/infopane.cpp index dde9e53..0c82c5f 100644 --- a/src/gui/infopane.cpp +++ b/src/gui/infopane.cpp @@ -178,7 +178,7 @@ void InfoPane::showDevice(Qt::DockWidgetArea area, const Device& d) } if (d.type() == Device::Type::Disk_Device) { - const DiskDevice& disk = dynamic_cast(d); + const DiskDevice& disk = static_cast(d); createLabels(i18nc("@label device", "Type:"), type, cols(area), x, y); createLabels(i18nc("@label device", "Capacity:"), Capacity::formatByteSize(disk.capacity()), cols(area), x, y); @@ -187,7 +187,7 @@ void InfoPane::showDevice(Qt::DockWidgetArea area, const Device& d) createLabels(i18nc("@label device", "Physical sector size:"), Capacity::formatByteSize(disk.physicalSectorSize()), cols(area), x, y); createLabels(i18nc("@label device", "Primaries/Max:"), maxPrimaries, cols(area), x, y); } else if (d.type() == Device::Type::LVM_Device) { - const LvmDevice& lvm = dynamic_cast(d); + const LvmDevice& lvm = static_cast(d); createLabels(i18nc("@label device", "Volume Type:"), QStringLiteral("LVM"), cols(area), x, y); createLabels(i18nc("@label device", "Capacity:"), Capacity::formatByteSize(lvm.capacity()), cols(area), x, y); createLabels(i18nc("@label device", "PE Size:"), Capacity::formatByteSize(lvm.peSize()), cols(area), x, y); @@ -195,7 +195,7 @@ void InfoPane::showDevice(Qt::DockWidgetArea area, const Device& d) createLabels(i18nc("@label device", "Allocated PE:"), QString::number(lvm.allocatedPE()), cols(area), x, y); createLabels(i18nc("@label device", "Free PE:"), QString::number(lvm.freePE()), cols(area), x, y); } else if (d.type() == Device::Type::SoftwareRAID_Device) { - const SoftwareRAID& raid = dynamic_cast(d); + const SoftwareRAID& raid = static_cast(d); createLabels(i18nc("@label device", "Volume Type:"), QStringLiteral("RAID"), cols(area), x, y); createLabels(i18nc("@label device", "Capacity:"), Capacity::formatByteSize(raid.capacity()), cols(area), x, y); createLabels(i18nc("@label device", "RAID Level:"), QString::number(raid.raidLevel()), cols(area), x, y); From 21cfd00159e6ab4ea3fcbb757aa4ccb86adff345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 15 Jul 2018 12:09:58 +0100 Subject: [PATCH 37/46] Bump version number. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 023cd7d..09f2269 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,11 +23,11 @@ set(KDE_INSTALL_USE_QT_SYS_PATHS ON CACHE BOOL "Install mkspecs files, Plugins a set(QT_MIN_VERSION "5.7.0") set(KF5_MIN_VERSION "5.31") -set(KPMCORE_MIN_VERSION "3.3.0") +set(KPMCORE_MIN_VERSION "3.50.0") # Check KPMcore dependency when bumping set(VERSION_MAJOR "3") -set(VERSION_MINOR "3") -set(VERSION_RELEASE "1") +set(VERSION_MINOR "50") +set(VERSION_RELEASE "0") set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE}) add_definitions(-D'VERSION="${VERSION}"') #" From 2e8bbac7bccbe5d7991e116d135be04d6d5cccfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 15 Jul 2018 17:57:30 +0100 Subject: [PATCH 38/46] Require cmake 3.1. Older versions do not support CMAKE_CXX_STANDARD. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09f2269..9d7549d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ project(partitionmanager) -cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) +cmake_minimum_required(VERSION 3.1 FATAL_ERROR) set(CMAKE_USE_RELATIVE_PATHS OFF) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) From b5eaa4aadceae65cca17e06c479d13e8dc04c40e Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Sun, 15 Jul 2018 17:40:01 -0300 Subject: [PATCH 39/46] Adding support for detecting linux_raid_member file system. --- src/config/configurepagefilesystemcolors.ui | 290 +++++++++++--------- src/partitionmanager.kcfg | 2 + 2 files changed, 155 insertions(+), 137 deletions(-) diff --git a/src/config/configurepagefilesystemcolors.ui b/src/config/configurepagefilesystemcolors.ui index c73b4d3..49e3251 100644 --- a/src/config/configurepagefilesystemcolors.ui +++ b/src/config/configurepagefilesystemcolors.ui @@ -6,7 +6,7 @@ 0 0 - 481 + 484 457 @@ -22,7 +22,7 @@ File Systems - + @@ -94,7 +94,7 @@ - + @@ -156,6 +156,19 @@
+ + + Linux RAID: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + Linux Swap: @@ -168,24 +181,8 @@ - - - - - - - FAT12: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - + @@ -201,9 +198,9 @@ - + - FAT16: + FAT12: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -214,7 +211,7 @@ - + @@ -230,9 +227,9 @@ - + - FAT32: + FAT16: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -242,10 +239,10 @@ - - - + + + Qt::Horizontal @@ -259,9 +256,9 @@ - + - HPFS: + FAT32: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -272,7 +269,7 @@ - + @@ -288,9 +285,9 @@ - + - ReiserFS: + HPFS: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -301,7 +298,7 @@ - + @@ -317,6 +314,22 @@ + + + ReiserFS: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + Reiser4: @@ -329,24 +342,8 @@ - - - - - - - JFS: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - + @@ -362,9 +359,9 @@ - + - HFS: + JFS: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -375,7 +372,7 @@ - + @@ -391,6 +388,22 @@ + + + HFS: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + HFS+: @@ -403,24 +416,8 @@ - - - - - - - UFS: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - + @@ -436,9 +433,9 @@ - + - XFS: + UFS: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -449,7 +446,7 @@ - + @@ -465,6 +462,22 @@ + + + XFS: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + OCFS2: @@ -477,24 +490,8 @@ - - - - - - - ZFS: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - + @@ -510,17 +507,20 @@ - + - exFAT: + ZFS: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + false + - + @@ -536,6 +536,19 @@ + + + exFAT: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + NILFS2: @@ -545,24 +558,8 @@ - - - - - - - LVM2 PV: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - + @@ -578,9 +575,9 @@ - + - F2FS: + LVM2 PV: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -591,7 +588,7 @@ - + @@ -607,6 +604,22 @@ + + + F2FS: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + UDF: @@ -619,24 +632,8 @@ - - - - - - - ISO 9660: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - + @@ -652,9 +649,9 @@ - + - LUKS: + ISO 9660: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -665,7 +662,7 @@ - + @@ -681,6 +678,22 @@ + + + LUKS: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + LUKS2: @@ -693,10 +706,10 @@ - + - + Qt::Horizontal @@ -774,9 +787,12 @@ - + + + + diff --git a/src/partitionmanager.kcfg b/src/partitionmanager.kcfg index 8c858fc..7b4eb86 100644 --- a/src/partitionmanager.kcfg +++ b/src/partitionmanager.kcfg @@ -89,6 +89,7 @@ Iso9660 Luks2 Fat12 + LinuxRaidMember 220,205,175 @@ -121,6 +122,7 @@ 177,82,69 223,39,104 204,179,255 + 255,100,100 From aa6f4afeadff6ff9e086569243d5f73445ded71a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 15 Jul 2018 22:33:37 +0100 Subject: [PATCH 40/46] Use the same whitespace as rest of the file. --- src/partitionmanager.kcfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partitionmanager.kcfg b/src/partitionmanager.kcfg index 7b4eb86..1cf4e26 100644 --- a/src/partitionmanager.kcfg +++ b/src/partitionmanager.kcfg @@ -122,7 +122,7 @@ 177,82,69 223,39,104 204,179,255 - 255,100,100 + 255,100,100 From b68db554f65a58222a63745fc54cccd77966c2c1 Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Sun, 15 Jul 2018 19:43:44 -0300 Subject: [PATCH 41/46] Operations should check LvmDevice::s_DirtyPVs instead of check pending CreateVolumeGroupOperations to search for newly LVM PVs. --- src/gui/mainwindow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 1304058..99ea56a 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -536,18 +536,18 @@ void MainWindow::enableActions() actionCollection()->action(QStringLiteral("newPartition")) ->setEnabled(!readOnly && NewOperation::canCreateNew(part)); - const bool canResize = ResizeOperation::canGrow(part, m_OperationStack->operations()) || - ResizeOperation::canShrink(part, m_OperationStack->operations()) || - ResizeOperation::canMove(part, m_OperationStack->operations()); + const bool canResize = ResizeOperation::canGrow(part) || + ResizeOperation::canShrink(part) || + ResizeOperation::canMove(part); actionCollection()->action(QStringLiteral("resizePartition")) ->setEnabled(!readOnly && canResize); actionCollection()->action(QStringLiteral("copyPartition")) ->setEnabled(CopyOperation::canCopy(part)); actionCollection()->action(QStringLiteral("deletePartition")) - ->setEnabled(!readOnly && DeleteOperation::canDelete(part, m_OperationStack->operations())); + ->setEnabled(!readOnly && DeleteOperation::canDelete(part)); actionCollection()->action(QStringLiteral("shredPartition")) - ->setEnabled(!readOnly && DeleteOperation::canDelete(part, m_OperationStack->operations())); + ->setEnabled(!readOnly && DeleteOperation::canDelete(part)); actionCollection()->action(QStringLiteral("pastePartition")) ->setEnabled(!readOnly && CopyOperation::canPaste(part, pmWidget().clipboardPartition())); actionCollection()->action(QStringLiteral("propertiesPartition")) From 773cbf6d3b1c1ab8997bc8f2a597aa99a031e77e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 16 Jul 2018 00:20:00 +0100 Subject: [PATCH 42/46] Newly created / to be removed LVM PVs in Resize VG dialog Port changes from Create VG dialog: Commit: af9fbe8a4ff273f85a874d3f33195aa5b6a166e0 --- src/gui/createvolumegroupdialog.cpp | 1 - src/gui/createvolumegroupdialog.h | 5 ++-- src/gui/mainwindow.cpp | 2 +- src/gui/resizevolumegroupdialog.cpp | 39 ++++++++++++++++++++++++++++- src/gui/resizevolumegroupdialog.h | 8 +++--- 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/gui/createvolumegroupdialog.cpp b/src/gui/createvolumegroupdialog.cpp index ca635be..eab4681 100644 --- a/src/gui/createvolumegroupdialog.cpp +++ b/src/gui/createvolumegroupdialog.cpp @@ -25,7 +25,6 @@ #include -#include #include #include diff --git a/src/gui/createvolumegroupdialog.h b/src/gui/createvolumegroupdialog.h index 1f40119..4dcf2dc 100644 --- a/src/gui/createvolumegroupdialog.h +++ b/src/gui/createvolumegroupdialog.h @@ -15,17 +15,16 @@ * along with this program. If not, see .* *************************************************************************/ -#if !defined(CREATEVOLUMEGROUPDIALOG_H) - +#ifndef CREATEVOLUMEGROUPDIALOG_H #define CREATEVOLUMEGROUPDIALOG_H #include #include -#include #include "gui/volumegroupdialog.h" class Device; +class Operation; class CreateVolumeGroupDialog : public VolumeGroupDialog { diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 99ea56a..fdd0736 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1121,7 +1121,7 @@ void MainWindow::onResizeVolumeGroup() QVector pvList; // *NOTE*: pvList will be modified and validated by the dialog - QPointer dlg = new ResizeVolumeGroupDialog(this, d, pvList); + QPointer dlg = new ResizeVolumeGroupDialog(this, d, pvList, operationStack().previewDevices(), operationStack().operations()); if (dlg->exec() == QDialog::Accepted) operationStack().push(new ResizeVolumeGroupOperation(*d, pvList)); diff --git a/src/gui/resizevolumegroupdialog.cpp b/src/gui/resizevolumegroupdialog.cpp index 35ec4ab..e0f856f 100644 --- a/src/gui/resizevolumegroupdialog.cpp +++ b/src/gui/resizevolumegroupdialog.cpp @@ -24,6 +24,8 @@ #include #include +#include + #include #include @@ -35,9 +37,11 @@ @param parent pointer to the parent widget @param d the Device to show properties for */ -ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QVector& partList) +ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QVector& partList, QList devices, QList pendingOps) : VolumeGroupDialog(parent, d->name(), partList) + , m_Devices(devices) , m_Device(d) + , m_PendingOps(pendingOps) { setWindowTitle(xi18nc("@title:window", "Resize Volume Group")); @@ -52,6 +56,19 @@ void ResizeVolumeGroupDialog::setupDialog() { if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) { for (const auto &p : qAsConst(LVM::pvList::list())) { + bool toBeDeleted = false; + + // Ignore partitions that are going to be deleted + for (const auto &o : qAsConst(m_PendingOps)) { + if (dynamic_cast(o) && o->targets(*p.partition())) { + toBeDeleted = true; + break; + } + } + + if (toBeDeleted) + continue; + if (p.isLuks()) continue; if (p.vgName() == device()->name()) @@ -59,6 +76,26 @@ void ResizeVolumeGroupDialog::setupDialog() else if (p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition())) // TODO: Remove LVM PVs in current VG dialogWidget().listPV().addPartition(*p.partition(), false); } + + for (const Device *d : qAsConst(m_Devices)) { + for (const Partition *p : qAsConst(d->partitionTable()->children())) { + // Looking if there is another VG creation that contains this partition + if (LvmDevice::s_DirtyPVs.contains(p)) + continue; + + // Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation) + if (p->state() == Partition::State::New) { + if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV) + dialogWidget().listPV().addPartition(*p, false); + else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) { + FileSystem *fs = static_cast(&p->fileSystem())->innerFS(); + + if (fs->type() == FileSystem::Type::Lvm2_PV) + dialogWidget().listPV().addPartition(*p, false); + } + } + } + } } //update used size and LV infos diff --git a/src/gui/resizevolumegroupdialog.h b/src/gui/resizevolumegroupdialog.h index 138161a..986ffc8 100644 --- a/src/gui/resizevolumegroupdialog.h +++ b/src/gui/resizevolumegroupdialog.h @@ -15,8 +15,7 @@ * along with this program. If not, see .* *************************************************************************/ -#if !defined(RESIZEVOLUMEGROUPDIALOG_H) - +#ifndef RESIZEVOLUMEGROUPDIALOG_H #define RESIZEVOLUMEGROUPDIALOG_H #include @@ -24,6 +23,7 @@ #include "gui/volumegroupdialog.h" class Device; +class Operation; class VolumeManagerDevice; class ResizeVolumeGroupDialog : public VolumeGroupDialog @@ -31,7 +31,7 @@ class ResizeVolumeGroupDialog : public VolumeGroupDialog Q_DISABLE_COPY(ResizeVolumeGroupDialog) public: - ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QVector& partList); + ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QVector& partList, QList devices, QList pendingOps = QList()); protected: void accept() override; @@ -43,7 +43,9 @@ protected: } private: + const QList m_Devices; // List of all devices found on the system VolumeManagerDevice* m_Device; + const QList m_PendingOps; // List of pending operations in KPM }; #endif From 15f19e818c70dcfa4afb7c7c2b35c3053a199881 Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Mon, 16 Jul 2018 15:51:16 -0300 Subject: [PATCH 43/46] RAID level should not be showed when the device is inactive. (i.e. it's not loaded by mdadm). --- src/gui/infopane.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/infopane.cpp b/src/gui/infopane.cpp index 0c82c5f..71160c3 100644 --- a/src/gui/infopane.cpp +++ b/src/gui/infopane.cpp @@ -198,7 +198,7 @@ void InfoPane::showDevice(Qt::DockWidgetArea area, const Device& d) const SoftwareRAID& raid = static_cast(d); createLabels(i18nc("@label device", "Volume Type:"), QStringLiteral("RAID"), cols(area), x, y); createLabels(i18nc("@label device", "Capacity:"), Capacity::formatByteSize(raid.capacity()), cols(area), x, y); - createLabels(i18nc("@label device", "RAID Level:"), QString::number(raid.raidLevel()), cols(area), x, y); + createLabels(i18nc("@label device", "RAID Level:"), raid.raidLevel() < 0 ? QStringLiteral("---") : QString::number(raid.raidLevel()), cols(area), x, y); createLabels(i18nc("@label device", "Chunk Size:"),Capacity::formatByteSize(raid.chunkSize()), cols(area), x, y); createLabels(i18nc("@label device", "Total Chunk:"), Capacity::formatByteSize(raid.totalChunk()), cols(area), x, y); createLabels(i18nc("@label device", "Array Size:"), Capacity::formatByteSize(raid.arraySize()), cols(area), x, y); From e173a5e3ab55bb3dbc81a3f54cca4d57a6a1aeff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Wed, 18 Jul 2018 21:54:33 +0100 Subject: [PATCH 44/46] Bump minimum Qt version to 5.10. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d7549d..698281c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ set(CMAKE_USE_RELATIVE_PATHS OFF) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) set(KDE_INSTALL_USE_QT_SYS_PATHS ON CACHE BOOL "Install mkspecs files, Plugins and Imports to the Qt 5 install dir" FORCE) -set(QT_MIN_VERSION "5.7.0") +set(QT_MIN_VERSION "5.10.0") set(KF5_MIN_VERSION "5.31") set(KPMCORE_MIN_VERSION "3.50.0") # Check KPMcore dependency when bumping From 9bcde2c7de9df436553f99cd1e3bd3e4fd0e2513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sat, 21 Jul 2018 20:54:20 +0100 Subject: [PATCH 45/46] Specify all dependencies in the same place in CMakeLists.txt. --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 698281c..18aba7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ # Copyright (C) 2008 by Volker Lanz +# Copyright (C) 2014-2018 by Andrius Štikonas # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -17,13 +18,15 @@ project(partitionmanager) cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +# Dependencies +set(QT_MIN_VERSION "5.10.0") +set(KF5_MIN_VERSION "5.31") +set(KPMCORE_MIN_VERSION "3.50.0") + set(CMAKE_USE_RELATIVE_PATHS OFF) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) set(KDE_INSTALL_USE_QT_SYS_PATHS ON CACHE BOOL "Install mkspecs files, Plugins and Imports to the Qt 5 install dir" FORCE) -set(QT_MIN_VERSION "5.10.0") -set(KF5_MIN_VERSION "5.31") -set(KPMCORE_MIN_VERSION "3.50.0") # Check KPMcore dependency when bumping set(VERSION_MAJOR "3") set(VERSION_MINOR "50") From f21b42d10e190db7de5a2dab5dd394b85834e140 Mon Sep 17 00:00:00 2001 From: Caio Carvalho Date: Mon, 23 Jul 2018 13:38:30 -0300 Subject: [PATCH 46/46] Adding PVs that are member of VGs that are going to be deleted soon in CreateVolumeGroupDialog and ResizeVolumeGroupDialog. Avoiding segfault because of devices partition tables in CreateVolumeGroupDialog and ResizeVolumeGroupDialog. --- src/gui/createvolumegroupdialog.cpp | 30 +++++++++++++++---------- src/gui/resizevolumegroupdialog.cpp | 34 +++++++++++++++++------------ 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/gui/createvolumegroupdialog.cpp b/src/gui/createvolumegroupdialog.cpp index eab4681..b4c0ed2 100644 --- a/src/gui/createvolumegroupdialog.cpp +++ b/src/gui/createvolumegroupdialog.cpp @@ -76,24 +76,30 @@ void CreateVolumeGroupDialog::setupDialog() } for (const Device *d : qAsConst(m_Devices)) { - for (const Partition *p : qAsConst(d->partitionTable()->children())) { - // Looking if there is another VG creation that contains this partition - if (LvmDevice::s_DirtyPVs.contains(p)) - continue; + if (d->partitionTable() != nullptr) { + for (const Partition *p : qAsConst(d->partitionTable()->children())) { + // Looking if there is another VG creation that contains this partition + if (LvmDevice::s_DirtyPVs.contains(p)) + continue; - // Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation) - if (p->state() == Partition::State::New) { - if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV) - dialogWidget().listPV().addPartition(*p, false); - else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) { - FileSystem *fs = static_cast(&p->fileSystem())->innerFS(); - - if (fs->type() == FileSystem::Type::Lvm2_PV) + // Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation) + if (p->state() == Partition::State::New) { + if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV) dialogWidget().listPV().addPartition(*p, false); + else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) { + FileSystem *fs = static_cast(&p->fileSystem())->innerFS(); + + if (fs->type() == FileSystem::Type::Lvm2_PV) + dialogWidget().listPV().addPartition(*p, false); + } } } } } + + for (const Partition *p : qAsConst(LvmDevice::s_OrphanPVs)) + if (!LvmDevice::s_DirtyPVs.contains(p)) + dialogWidget().listPV().addPartition(*p, false); } void CreateVolumeGroupDialog::setupConnections() diff --git a/src/gui/resizevolumegroupdialog.cpp b/src/gui/resizevolumegroupdialog.cpp index e0f856f..9acfc28 100644 --- a/src/gui/resizevolumegroupdialog.cpp +++ b/src/gui/resizevolumegroupdialog.cpp @@ -77,25 +77,31 @@ void ResizeVolumeGroupDialog::setupDialog() dialogWidget().listPV().addPartition(*p.partition(), false); } - for (const Device *d : qAsConst(m_Devices)) { - for (const Partition *p : qAsConst(d->partitionTable()->children())) { - // Looking if there is another VG creation that contains this partition - if (LvmDevice::s_DirtyPVs.contains(p)) - continue; + for (const Device *d : qAsConst(m_Devices)) { + if (d->partitionTable() != nullptr) { + for (const Partition *p : qAsConst(d->partitionTable()->children())) { + // Looking if there is another VG creation that contains this partition + if (LvmDevice::s_DirtyPVs.contains(p)) + continue; - // Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation) - if (p->state() == Partition::State::New) { - if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV) - dialogWidget().listPV().addPartition(*p, false); - else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) { - FileSystem *fs = static_cast(&p->fileSystem())->innerFS(); + // Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation) + if (p->state() == Partition::State::New) { + if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV) + dialogWidget().listPV().addPartition(*p, false); + else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) { + FileSystem *fs = static_cast(&p->fileSystem())->innerFS(); - if (fs->type() == FileSystem::Type::Lvm2_PV) - dialogWidget().listPV().addPartition(*p, false); + if (fs->type() == FileSystem::Type::Lvm2_PV) + dialogWidget().listPV().addPartition(*p, false); + } + } } } } - } + + for (const Partition *p : qAsConst(LvmDevice::s_OrphanPVs)) + if (!LvmDevice::s_DirtyPVs.contains(p)) + dialogWidget().listPV().addPartition(*p, false); } //update used size and LV infos