Merge branch 'kauth'

This commit is contained in:
Andrius Štikonas 2018-07-25 09:38:54 +00:00
commit e2b31f81fb
35 changed files with 556 additions and 569 deletions

View File

@ -1,4 +1,5 @@
# Copyright (C) 2008 by Volker Lanz <vl@fidra.de> # Copyright (C) 2008 by Volker Lanz <vl@fidra.de>
# Copyright (C) 2014-2018 by Andrius Štikonas <andrius@stikonas.eu>
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as # modify it under the terms of the GNU General Public License as
@ -15,19 +16,21 @@
project(partitionmanager) project(partitionmanager)
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) 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_USE_RELATIVE_PATHS OFF)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) 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(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(KF5_MIN_VERSION "5.31")
set(KPMCORE_MIN_VERSION "3.3.0")
# Check KPMcore dependency when bumping # Check KPMcore dependency when bumping
set(VERSION_MAJOR "3") set(VERSION_MAJOR "3")
set(VERSION_MINOR "3") set(VERSION_MINOR "50")
set(VERSION_RELEASE "1") set(VERSION_RELEASE "0")
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE}) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE})
add_definitions(-D'VERSION="${VERSION}"') #" add_definitions(-D'VERSION="${VERSION}"') #"
@ -57,6 +60,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED
ConfigWidgets ConfigWidgets
CoreAddons CoreAddons
Crash Crash
DBusAddons
I18n I18n
IconThemes IconThemes
JobWidgets JobWidgets

View File

@ -44,6 +44,7 @@ target_link_libraries(partitionmanager ${BLKID_LIBRARIES}
KF5::ConfigWidgets KF5::ConfigWidgets
KF5::CoreAddons KF5::CoreAddons
KF5::Crash KF5::Crash
KF5::DBusAddons
KF5::I18n KF5::I18n
KF5::IconThemes KF5::IconThemes
KF5::JobWidgets KF5::JobWidgets

View File

@ -84,8 +84,8 @@ void ConfigureOptionsDialog::updateSettings()
bool changed = false; bool changed = false;
if (generalPageWidget().defaultFileSystem() != Config::defaultFileSystem()) { if (generalPageWidget().defaultFileSystem() != static_cast<FileSystem::Type>(Config::defaultFileSystem())) {
Config::setDefaultFileSystem(generalPageWidget().defaultFileSystem()); Config::setDefaultFileSystem(static_cast<int>(generalPageWidget().defaultFileSystem()));
changed = true; changed = true;
} }
@ -109,7 +109,7 @@ bool ConfigureOptionsDialog::hasChanged()
bool result = KConfigDialog::hasChanged(); bool result = KConfigDialog::hasChanged();
KConfigSkeletonItem* kcItem = Config::self()->findItem(QStringLiteral("defaultFileSystem")); KConfigSkeletonItem* kcItem = Config::self()->findItem(QStringLiteral("defaultFileSystem"));
result = result || !kcItem->isEqual(generalPageWidget().defaultFileSystem()); result = result || !kcItem->isEqual(static_cast<int>(generalPageWidget().defaultFileSystem()));
result = result || (generalPageWidget().kcfg_shredSource->checkedId() != Config::shredSource()); result = result || (generalPageWidget().kcfg_shredSource->checkedId() != Config::shredSource());
if (advancedPageWidget().isVisible()) { if (advancedPageWidget().isVisible()) {

View File

@ -6,39 +6,11 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>367</width> <width>449</width>
<height>420</height> <height>420</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Permissions</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_allowApplyOperationsAsNonRoot">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Allow applying operations without administrator privileges</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_5"> <widget class="QGroupBox" name="groupBox_5">
<property name="sizePolicy"> <property name="sizePolicy">

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>481</width> <width>484</width>
<height>457</height> <height>457</height>
</rect> </rect>
</property> </property>
@ -22,7 +22,7 @@
<property name="title"> <property name="title">
<string>File Systems</string> <string>File Systems</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="textLabel"> <widget class="QLabel" name="textLabel">
<property name="text"> <property name="text">
@ -37,7 +37,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode2"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeExt2"/>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
@ -66,7 +66,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="4"> <item row="0" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode3"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeExt3"/>
</item> </item>
<item row="0" column="5"> <item row="0" column="5">
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
@ -94,8 +94,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="7"> <item row="0" column="8">
<widget class="KColorButton" name="kcfg_fileSystemColorCode4"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeExt4"/>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="textLabel_21"> <widget class="QLabel" name="textLabel_21">
@ -111,7 +111,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode17"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeBtrfs"/>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<spacer name="horizontalSpacer_15"> <spacer name="horizontalSpacer_15">
@ -140,7 +140,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="4"> <item row="1" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode8"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeNtfs"/>
</item> </item>
<item row="1" column="5"> <item row="1" column="5">
<spacer name="horizontalSpacer_3"> <spacer name="horizontalSpacer_3">
@ -156,6 +156,19 @@
</spacer> </spacer>
</item> </item>
<item row="1" column="6"> <item row="1" column="6">
<widget class="QLabel" name="textLabel_18">
<property name="text">
<string>Linux RAID:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="textLabel_4"> <widget class="QLabel" name="textLabel_4">
<property name="text"> <property name="text">
<string>Linux Swap:</string> <string>Linux Swap:</string>
@ -168,24 +181,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode5"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="textLabel_32">
<property name="text">
<string>FAT12:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode29"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeLinuxSwap"/>
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<spacer name="horizontalSpacer_21"> <spacer name="horizontalSpacer_21">
@ -201,9 +198,9 @@
</spacer> </spacer>
</item> </item>
<item row="2" column="3"> <item row="2" column="3">
<widget class="QLabel" name="textLabel_6"> <widget class="QLabel" name="textLabel_32">
<property name="text"> <property name="text">
<string>FAT16:</string> <string>FAT12:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -214,7 +211,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="4"> <item row="2" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode6"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeFat12"/>
</item> </item>
<item row="2" column="5"> <item row="2" column="5">
<spacer name="horizontalSpacer_17"> <spacer name="horizontalSpacer_17">
@ -230,9 +227,9 @@
</spacer> </spacer>
</item> </item>
<item row="2" column="6"> <item row="2" column="6">
<widget class="QLabel" name="textLabel_5"> <widget class="QLabel" name="textLabel_6">
<property name="text"> <property name="text">
<string>FAT32:</string> <string>FAT16:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -242,10 +239,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode7"/>
</item>
<item row="2" column="8"> <item row="2" column="8">
<widget class="KColorButton" name="kcfg_fileSystemColorCodeFat16"/>
</item>
<item row="2" column="9">
<spacer name="horizontalSpacer_16"> <spacer name="horizontalSpacer_16">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -258,10 +255,10 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="6" column="0"> <item row="3" column="0">
<widget class="QLabel" name="textLabel_25"> <widget class="QLabel" name="textLabel_5">
<property name="text"> <property name="text">
<string>ZFS:</string> <string>FAT32:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -271,10 +268,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCodeFat32"/>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>28</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="3"> <item row="3" column="3">
<widget class="QLabel" name="textLabel_7"> <widget class="QLabel" name="textLabel_10">
<property name="text"> <property name="text">
<string>ReiserFS:</string> <string>HPFS:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -285,7 +298,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="4"> <item row="3" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode9"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeHpfs"/>
</item> </item>
<item row="3" column="5"> <item row="3" column="5">
<spacer name="horizontalSpacer_5"> <spacer name="horizontalSpacer_5">
@ -301,6 +314,22 @@
</spacer> </spacer>
</item> </item>
<item row="3" column="6"> <item row="3" column="6">
<widget class="QLabel" name="textLabel_7">
<property name="text">
<string>ReiserFS:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="8">
<widget class="KColorButton" name="kcfg_fileSystemColorCodeReiserFS"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="textLabel_8"> <widget class="QLabel" name="textLabel_8">
<property name="text"> <property name="text">
<string>Reiser4:</string> <string>Reiser4:</string>
@ -313,53 +342,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode10"/>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>28</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="textLabel_10">
<property name="text">
<string>HPFS:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode18"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="textLabel_11">
<property name="text">
<string>JFS:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode12"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeReiser4"/>
</item> </item>
<item row="4" column="2"> <item row="4" column="2">
<spacer name="horizontalSpacer_8"> <spacer name="horizontalSpacer_8">
@ -375,9 +359,9 @@
</spacer> </spacer>
</item> </item>
<item row="4" column="3"> <item row="4" column="3">
<widget class="QLabel" name="textLabel_12"> <widget class="QLabel" name="textLabel_11">
<property name="text"> <property name="text">
<string>HFS:</string> <string>JFS:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -388,7 +372,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="4"> <item row="4" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode13"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeJfs"/>
</item> </item>
<item row="4" column="5"> <item row="4" column="5">
<spacer name="horizontalSpacer_7"> <spacer name="horizontalSpacer_7">
@ -404,6 +388,22 @@
</spacer> </spacer>
</item> </item>
<item row="4" column="6"> <item row="4" column="6">
<widget class="QLabel" name="textLabel_12">
<property name="text">
<string>HFS:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="8">
<widget class="KColorButton" name="kcfg_fileSystemColorCodeHfs"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="textLabel_14"> <widget class="QLabel" name="textLabel_14">
<property name="text"> <property name="text">
<string>HFS+:</string> <string>HFS+:</string>
@ -416,24 +416,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode14"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="textLabel_15">
<property name="text">
<string>UFS:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="1"> <item row="5" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode15"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeHfsPlus"/>
</item> </item>
<item row="5" column="2"> <item row="5" column="2">
<spacer name="horizontalSpacer_10"> <spacer name="horizontalSpacer_10">
@ -449,9 +433,9 @@
</spacer> </spacer>
</item> </item>
<item row="5" column="3"> <item row="5" column="3">
<widget class="QLabel" name="textLabel_22"> <widget class="QLabel" name="textLabel_15">
<property name="text"> <property name="text">
<string>XFS:</string> <string>UFS:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -462,7 +446,7 @@
</widget> </widget>
</item> </item>
<item row="5" column="4"> <item row="5" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode11"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeUfs"/>
</item> </item>
<item row="5" column="5"> <item row="5" column="5">
<spacer name="horizontalSpacer_9"> <spacer name="horizontalSpacer_9">
@ -478,6 +462,22 @@
</spacer> </spacer>
</item> </item>
<item row="5" column="6"> <item row="5" column="6">
<widget class="QLabel" name="textLabel_22">
<property name="text">
<string>XFS:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="8">
<widget class="KColorButton" name="kcfg_fileSystemColorCodeXfs"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="textLabel_24"> <widget class="QLabel" name="textLabel_24">
<property name="text"> <property name="text">
<string>OCFS2:</string> <string>OCFS2:</string>
@ -490,37 +490,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode20"/>
</item>
<item row="6" column="1"> <item row="6" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode21"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeOcfs2"/>
</item>
<item row="6" column="3">
<widget class="QLabel" name="textLabel_26">
<property name="text">
<string>exFAT:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode22"/>
</item>
<item row="6" column="6">
<widget class="QLabel" name="textLabel_27">
<property name="text">
<string>NILFS2:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode23"/>
</item> </item>
<item row="6" column="2"> <item row="6" column="2">
<spacer name="horizontalSpacer_13"> <spacer name="horizontalSpacer_13">
@ -535,6 +506,22 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="6" column="3">
<widget class="QLabel" name="textLabel_25">
<property name="text">
<string>ZFS:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCodeZfs"/>
</item>
<item row="6" column="5"> <item row="6" column="5">
<spacer name="horizontalSpacer_14"> <spacer name="horizontalSpacer_14">
<property name="orientation"> <property name="orientation">
@ -548,21 +535,31 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="7" column="0"> <item row="6" column="6">
<widget class="QLabel" name="textLabel_28"> <widget class="QLabel" name="textLabel_26">
<property name="text"> <property name="text">
<string>LVM2 PV:</string> <string>exFAT:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="wordWrap"> </widget>
<bool>false</bool> </item>
<item row="6" column="8">
<widget class="KColorButton" name="kcfg_fileSystemColorCodeExfat"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="textLabel_27">
<property name="text">
<string>NILFS2:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="7" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode24"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeNilfs2"/>
</item> </item>
<item row="7" column="2"> <item row="7" column="2">
<spacer name="horizontalSpacer_22"> <spacer name="horizontalSpacer_22">
@ -578,9 +575,9 @@
</spacer> </spacer>
</item> </item>
<item row="7" column="3"> <item row="7" column="3">
<widget class="QLabel" name="textLabel_29"> <widget class="QLabel" name="textLabel_28">
<property name="text"> <property name="text">
<string>F2FS:</string> <string>LVM2 PV:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -591,7 +588,7 @@
</widget> </widget>
</item> </item>
<item row="7" column="4"> <item row="7" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode25"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeLvm2_PV"/>
</item> </item>
<item row="7" column="5"> <item row="7" column="5">
<spacer name="horizontalSpacer_18"> <spacer name="horizontalSpacer_18">
@ -607,6 +604,22 @@
</spacer> </spacer>
</item> </item>
<item row="7" column="6"> <item row="7" column="6">
<widget class="QLabel" name="textLabel_29">
<property name="text">
<string>F2FS:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="8">
<widget class="KColorButton" name="kcfg_fileSystemColorCodeF2fs"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="textLabel_30"> <widget class="QLabel" name="textLabel_30">
<property name="text"> <property name="text">
<string>UDF:</string> <string>UDF:</string>
@ -619,24 +632,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode26"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="textLabel_31">
<property name="text">
<string>ISO 9660:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="1"> <item row="8" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode27"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeUdf"/>
</item> </item>
<item row="8" column="2"> <item row="8" column="2">
<spacer name="horizontalSpacer_19"> <spacer name="horizontalSpacer_19">
@ -652,9 +649,9 @@
</spacer> </spacer>
</item> </item>
<item row="8" column="3"> <item row="8" column="3">
<widget class="QLabel" name="textLabel_20"> <widget class="QLabel" name="textLabel_31">
<property name="text"> <property name="text">
<string>LUKS:</string> <string>ISO 9660:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -665,7 +662,7 @@
</widget> </widget>
</item> </item>
<item row="8" column="4"> <item row="8" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode19"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeIso9660"/>
</item> </item>
<item row="8" column="5"> <item row="8" column="5">
<spacer name="horizontalSpacer_20"> <spacer name="horizontalSpacer_20">
@ -681,6 +678,22 @@
</spacer> </spacer>
</item> </item>
<item row="8" column="6"> <item row="8" column="6">
<widget class="QLabel" name="textLabel_20">
<property name="text">
<string>LUKS:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="8">
<widget class="KColorButton" name="kcfg_fileSystemColorCodeLuks"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="textLabel_33"> <widget class="QLabel" name="textLabel_33">
<property name="text"> <property name="text">
<string>LUKS2:</string> <string>LUKS2:</string>
@ -693,10 +706,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="7"> <item row="9" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode28"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeLuks2"/>
</item> </item>
<item row="10" column="0" colspan="8"> <item row="10" column="0" colspan="9">
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -717,7 +730,7 @@
</widget> </widget>
</item> </item>
<item row="11" column="1"> <item row="11" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode1"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeExtended"/>
</item> </item>
<item row="11" column="2"> <item row="11" column="2">
<spacer name="horizontalSpacer_12"> <spacer name="horizontalSpacer_12">
@ -746,7 +759,7 @@
</widget> </widget>
</item> </item>
<item row="11" column="4"> <item row="11" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode16"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeUnformatted"/>
</item> </item>
<item row="11" column="5"> <item row="11" column="5">
<spacer name="horizontalSpacer_11"> <spacer name="horizontalSpacer_11">
@ -774,8 +787,11 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="7"> <item row="11" column="8">
<widget class="KColorButton" name="kcfg_fileSystemColorCode0"/> <widget class="KColorButton" name="kcfg_fileSystemColorCodeUnknown"/>
</item>
<item row="1" column="8">
<widget class="KColorButton" name="kcfg_fileSystemColorCodeLinuxRaidMember"/>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -48,7 +48,7 @@ void GeneralPageWidget::setupDialog()
{ {
QStringList fsNames; QStringList fsNames;
for (const auto &fs : FileSystemFactory::map()) 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()); fsNames.append(fs->name());
std::sort(fsNames.begin(), fsNames.end(), caseInsensitiveLessThan); std::sort(fsNames.begin(), fsNames.end(), caseInsensitiveLessThan);

View File

@ -143,6 +143,7 @@ void ApplyProgressDialog::show()
dialogWidget().treeTasks().clear(); dialogWidget().treeTasks().clear();
okButton->setVisible(false); okButton->setVisible(false);
okButton->setEnabled(false);
cancelButton->setVisible(true); cancelButton->setVisible(true);
cancelButton->setEnabled(true); cancelButton->setEnabled(true);
@ -244,6 +245,7 @@ void ApplyProgressDialog::allOpsDone(const QString& msg)
dialogWidget().progressTotal().setValue(operationRunner().numJobs()); dialogWidget().progressTotal().setValue(operationRunner().numJobs());
cancelButton->setVisible(false); cancelButton->setVisible(false);
okButton->setVisible(true); okButton->setVisible(true);
okButton->setEnabled(true);
detailsWidget().buttonSave().setEnabled(true); detailsWidget().buttonSave().setEnabled(true);
detailsWidget().buttonBrowser().setEnabled(true); detailsWidget().buttonBrowser().setEnabled(true);
timer().stop(); timer().stop();
@ -364,7 +366,7 @@ void ApplyProgressDialog::addTaskOutput(int num, const Operation& op)
item->setFont(0, f); item->setFont(0, f);
item->setFont(1, f); item->setFont(1, f);
item->setData(0, Qt::UserRole, reinterpret_cast<const qulonglong>(&op)); item->setData(0, Qt::UserRole, reinterpret_cast<qulonglong>(&op));
dialogWidget().treeTasks().addTopLevelItem(item); dialogWidget().treeTasks().addTopLevelItem(item);
dialogWidget().treeTasks().scrollToBottom(); dialogWidget().treeTasks().scrollToBottom();
setCurrentOpItem(item); setCurrentOpItem(item);

View File

@ -19,10 +19,14 @@
#include "gui/createvolumegroupdialog.h" #include "gui/createvolumegroupdialog.h"
#include "gui/volumegroupwidget.h" #include "gui/volumegroupwidget.h"
#include <core/device.h>
#include <core/lvmdevice.h> #include <core/lvmdevice.h>
#include <core/partitiontable.h>
#include <fs/lvm2_pv.h> #include <fs/lvm2_pv.h>
#include <ops/deleteoperation.h>
#include <util/capacity.h> #include <util/capacity.h>
#include <util/helpers.h> #include <util/helpers.h>
@ -32,10 +36,11 @@
#include <KLocalizedString> #include <KLocalizedString>
#include <KSharedConfig> #include <KSharedConfig>
CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QVector<const Partition*>& partList, qint32& peSize, QList<Device*> devices) CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QVector<const Partition*>& partList, qint32& peSize, QList<Device*> devices, QList<Operation*> pendingOps)
: VolumeGroupDialog(parent, vgName, partList) : VolumeGroupDialog(parent, vgName, partList)
, m_PESize(peSize) , m_PESize(peSize)
, m_Devices(devices) , m_Devices(devices)
, m_PendingOps(pendingOps)
{ {
setWindowTitle(xi18nc("@title:window", "Create new Volume Group")); setWindowTitle(xi18nc("@title:window", "Create new Volume Group"));
@ -52,9 +57,49 @@ CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgNam
void CreateVolumeGroupDialog::setupDialog() 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
for (const auto &o : qAsConst(m_PendingOps)) {
if (dynamic_cast<DeleteOperation *>(o) && o->targets(*p.partition())) {
toBeDeleted = true;
break;
}
}
if (toBeDeleted)
continue;
if (!p.isLuks() && p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition())) if (!p.isLuks() && p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition()))
dialogWidget().listPV().addPartition(*p.partition(), false); dialogWidget().listPV().addPartition(*p.partition(), false);
}
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<const FS::luks *>(&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() void CreateVolumeGroupDialog::setupConnections()
@ -76,6 +121,14 @@ void CreateVolumeGroupDialog::accept()
QDialog::accept(); QDialog::accept();
} }
void CreateVolumeGroupDialog::updateOkButtonStatus()
{
VolumeGroupDialog::updateOkButtonStatus();
if (okButton->isEnabled())
okButton->setEnabled(!dialogWidget().listPV().checkedItems().empty());
}
void CreateVolumeGroupDialog::onVGNameChanged(const QString& vgName) void CreateVolumeGroupDialog::onVGNameChanged(const QString& vgName)
{ {
for (const auto &d : m_Devices) { for (const auto &d : m_Devices) {

View File

@ -15,8 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.* * along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/ *************************************************************************/
#if !defined(CREATEVOLUMEGROUPDIALOG_H) #ifndef CREATEVOLUMEGROUPDIALOG_H
#define CREATEVOLUMEGROUPDIALOG_H #define CREATEVOLUMEGROUPDIALOG_H
#include <core/device.h> #include <core/device.h>
@ -25,13 +24,14 @@
#include "gui/volumegroupdialog.h" #include "gui/volumegroupdialog.h"
class Device; class Device;
class Operation;
class CreateVolumeGroupDialog : public VolumeGroupDialog class CreateVolumeGroupDialog : public VolumeGroupDialog
{ {
Q_DISABLE_COPY(CreateVolumeGroupDialog) Q_DISABLE_COPY(CreateVolumeGroupDialog)
public: public:
CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QVector<const Partition*>& pvList, qint32& peSize, QList<Device*> devices); CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QVector<const Partition*>& pvList, qint32& peSize, QList<Device*> devices, QList<Operation*> pendingOps = QList<Operation *>());
protected: protected:
void accept() override; void accept() override;
@ -39,6 +39,7 @@ protected:
void setupConnections() override; void setupConnections() override;
protected: protected:
virtual void updateOkButtonStatus() override;
void onVGNameChanged(const QString& vgname); void onVGNameChanged(const QString& vgname);
void onSpinPESizeChanged(int newsize); void onSpinPESizeChanged(int newsize);
@ -50,6 +51,7 @@ protected:
private: private:
const QList<Device*> m_Devices; // List of all devices found on the system const QList<Device*> m_Devices; // List of all devices found on the system
const QList<Operation*> m_PendingOps; // List of pending operations in KPM
}; };
#endif #endif

View File

@ -106,15 +106,10 @@ void DevicePropsDialog::setupDialog()
dialogWidget().capacity().setText(Capacity::formatByteSize(device().capacity())); dialogWidget().capacity().setText(Capacity::formatByteSize(device().capacity()));
dialogWidget().totalSectors().setText(QLocale().toString(device().totalLogical())); 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<const DiskDevice&>(device()); const DiskDevice& disk = dynamic_cast<const DiskDevice&>(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().primariesMax().setText(maxPrimaries);
dialogWidget().logicalSectorSize().setText(Capacity::formatByteSize(disk.logicalSectorSize())); dialogWidget().logicalSectorSize().setText(Capacity::formatByteSize(disk.logicalSectorSize()));
dialogWidget().physicalSectorSize().setText(Capacity::formatByteSize(disk.physicalSectorSize())); dialogWidget().physicalSectorSize().setText(Capacity::formatByteSize(disk.physicalSectorSize()));
@ -132,8 +127,10 @@ void DevicePropsDialog::setupDialog()
dialogWidget().buttonSmartMore().setVisible(false); dialogWidget().buttonSmartMore().setVisible(false);
} }
} else { } else {
if (device().type() == Device::LVM_Device) if (device().type() == Device::Type::LVM_Device)
dialogWidget().type().setText(xi18nc("@label device", "LVM Volume Group")); 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 else
dialogWidget().type().setText(xi18nc("@label device", "Volume Manager Device")); dialogWidget().type().setText(xi18nc("@label device", "Volume Manager Device"));
//TODO: add Volume Manger Device info //TODO: add Volume Manger Device info

View File

@ -37,18 +37,10 @@ public:
return *m_PartTableWidget; return *m_PartTableWidget;
} }
QLabel& chs() {
Q_ASSERT(m_LabelCHS);
return *m_LabelCHS;
}
QLabel& capacity() { QLabel& capacity() {
Q_ASSERT(m_LabelCapacity); Q_ASSERT(m_LabelCapacity);
return *m_LabelCapacity; return *m_LabelCapacity;
} }
QLabel& cylinderSize() {
Q_ASSERT(m_LabelCylinderSize);
return *m_LabelCylinderSize;
}
QLabel& primariesMax() { QLabel& primariesMax() {
Q_ASSERT(m_LabelPrimariesMax); Q_ASSERT(m_LabelPrimariesMax);
return *m_LabelPrimariesMax; return *m_LabelPrimariesMax;

View File

@ -81,7 +81,7 @@
<item> <item>
<widget class="QRadioButton" name="m_RadioSectorBased"> <widget class="QRadioButton" name="m_RadioSectorBased">
<property name="text"> <property name="text">
<string>Sector based al&amp;ignment</string> <string>Sector based align&amp;ment</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -149,35 +149,6 @@
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="8" column="0">
<widget class="QLabel" name="m_LabelTextCHS">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cylinders/Heads/Sectors:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="m_LabelCHS">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>5</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="m_LabelTextLogicalSectorSize"> <widget class="QLabel" name="m_LabelTextLogicalSectorSize">
<property name="text"> <property name="text">
<string>Logical sector size:</string> <string>Logical sector size:</string>
@ -187,14 +158,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="8" column="1">
<widget class="QLabel" name="m_LabelLogicalSectorSize"> <widget class="QLabel" name="m_LabelLogicalSectorSize">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="0"> <item row="9" column="0">
<widget class="QLabel" name="m_LabelTextPhysicalSectorSize"> <widget class="QLabel" name="m_LabelTextPhysicalSectorSize">
<property name="text"> <property name="text">
<string>Physical sector size:</string> <string>Physical sector size:</string>
@ -204,38 +175,28 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="1"> <item row="9" column="1">
<widget class="QLabel" name="m_LabelPhysicalSectorSize"> <widget class="QLabel" name="m_LabelPhysicalSectorSize">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="0"> <item row="10" column="0" colspan="2">
<widget class="QLabel" name="m_LabelTextCylinderSize">
<property name="text">
<string>Cylinder size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLabel" name="m_LabelCylinderSize">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<widget class="Line" name="line_3"> <widget class="Line" name="line_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="13" column="0"> <item row="12" column="0" colspan="2">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="m_LabelTextPrimariesMax"> <widget class="QLabel" name="m_LabelTextPrimariesMax">
<property name="text"> <property name="text">
<string>Primaries/Max:</string> <string>Primaries/Max:</string>
@ -245,21 +206,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="13" column="1"> <item row="11" column="1">
<widget class="QLabel" name="m_LabelPrimariesMax"> <widget class="QLabel" name="m_LabelPrimariesMax">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="14" column="0" colspan="2"> <item row="13" column="0">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="m_LabelTextSmartStatus"> <widget class="QLabel" name="m_LabelTextSmartStatus">
<property name="text"> <property name="text">
<string>SMART status:</string> <string>SMART status:</string>
@ -269,7 +223,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="15" column="1"> <item row="13" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="m_LabelSmartStatusIcon"> <widget class="QLabel" name="m_LabelSmartStatusIcon">
@ -306,7 +260,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="16" column="0" colspan="2"> <item row="14" column="0" colspan="2">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>

View File

@ -49,10 +49,10 @@ EditMountPointDialog::EditMountPointDialog(QWidget* parent, Partition& p) :
this ); this );
mainLayout->addWidget(dbb); mainLayout->addWidget(dbb);
connect(dbb, &QDialogButtonBox::accepted, connect(dbb, &QDialogButtonBox::accepted,
this, [=] () {accept_(Edit);} ); this, [=] () {accept_(MountPointAction::Edit);} );
connect(dbb, &QDialogButtonBox::rejected, connect(dbb, &QDialogButtonBox::rejected,
this, &EditMountPointDialog::reject); 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 */ /** Destroys an EditMountOptionsDialog instance */
@ -72,12 +72,12 @@ void EditMountPointDialog::accept_(MountPointAction action)
KStandardGuiItem::cancel(), KStandardGuiItem::cancel(),
QStringLiteral("reallyWriteMountPoints")) == KMessageBox::Cancel) QStringLiteral("reallyWriteMountPoints")) == KMessageBox::Cancel)
return; return;
if(action == Remove) if(action == MountPointAction::Remove)
widget().removeMountPoint(); widget().removeMountPoint();
else if (action == Edit) else if (action == MountPointAction::Edit)
widget().acceptChanges(); widget().acceptChanges();
if (writeMountpoints(widget().fstabEntries())) { if (writeMountpoints(widget().fstabEntries())) {
if (action == Edit) if (action == MountPointAction::Edit)
partition().setMountPoint(widget().editPath().currentText()); partition().setMountPoint(widget().editPath().currentText());
} }
else else

View File

@ -28,7 +28,7 @@ class Partition;
class QWidget; class QWidget;
class QString; class QString;
enum MountPointAction enum class MountPointAction
{ {
Remove, Remove,
Edit Edit

View File

@ -42,7 +42,7 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
setupUi(this); setupUi(this);
m_deviceNode = partition().deviceNode(); 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<const FS::luks*>(&partition().fileSystem()); const FS::luks* luksFs = dynamic_cast<const FS::luks*>(&partition().fileSystem());
m_deviceNode = luksFs->mapperName(); m_deviceNode = luksFs->mapperName();
} }
@ -54,9 +54,9 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
for (auto &e : m_fstabEntries) { for (auto &e : m_fstabEntries) {
QString canonicalEntryPath = QFileInfo(e.deviceNode()).canonicalFilePath(); QString canonicalEntryPath = QFileInfo(e.deviceNode()).canonicalFilePath();
QString canonicalDevicePath = QFileInfo(m_deviceNode).canonicalFilePath(); QString canonicalDevicePath = QFileInfo(m_deviceNode).canonicalFilePath();
if (canonicalEntryPath == canonicalDevicePath) { // FIXME fix multiple mountpoints if (canonicalEntryPath == canonicalDevicePath) {
entryFound = true; entryFound = true;
entry.append(&e); entry.push_back(&e);
mountPointList = possibleMountPoints(e.deviceNode()); mountPointList = possibleMountPoints(e.deviceNode());
} }
} }
@ -65,19 +65,19 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio
FileSystem::Type type = partition().fileSystem().type(); FileSystem::Type type = partition().fileSystem().type();
QString fsName; QString fsName;
switch (type) { switch (type) {
case FileSystem::LinuxSwap: case FileSystem::Type::LinuxSwap:
fsName = QStringLiteral("swap"); fsName = QStringLiteral("swap");
break; break;
case FileSystem::Fat16: case FileSystem::Type::Fat16:
case FileSystem::Fat32: case FileSystem::Type::Fat32:
fsName = QStringLiteral("vfat"); fsName = QStringLiteral("vfat");
break; break;
default: default:
fsName = partition().fileSystem().name(); fsName = partition().fileSystem().name();
} }
m_fstabEntries.append(FstabEntry(m_deviceNode, QString(), fsName, QString())); m_fstabEntries.push_back(FstabEntry(m_deviceNode, QString(), fsName, QString()));
entry.append(&m_fstabEntries.last()); entry.push_back(&m_fstabEntries.back());
} }
currentEntry = entry[0]; currentEntry = entry[0];
editPath().addItems(mountPointList); editPath().addItems(mountPointList);
@ -127,7 +127,7 @@ void EditMountPointDialogWidget::setupOptions(const QStringList& options)
m_Options = optTmpList.join(QLatin1Char(',')); m_Options = optTmpList.join(QLatin1Char(','));
} }
void EditMountPointDialogWidget::setupRadio(const FstabEntryType entryType) void EditMountPointDialogWidget::setupRadio(const FstabEntry::Type entryType)
{ {
if (partition().fileSystem().uuid().isEmpty()) { if (partition().fileSystem().uuid().isEmpty()) {
radioUUID().setEnabled(false); radioUUID().setEnabled(false);
@ -141,26 +141,26 @@ void EditMountPointDialogWidget::setupRadio(const FstabEntryType entryType)
radioDeviceNode().setChecked(true); radioDeviceNode().setChecked(true);
} }
switch (entryType) { switch (entryType) {
case FstabEntryType::uuid: case FstabEntry::Type::uuid:
radioUUID().setChecked(true); radioUUID().setChecked(true);
break; break;
case FstabEntryType::label: case FstabEntry::Type::label:
radioLabel().setChecked(true); radioLabel().setChecked(true);
break; break;
case FstabEntryType::partuuid: case FstabEntry::Type::partuuid:
radioUUID().setChecked(true); radioUUID().setChecked(true);
break; break;
case FstabEntryType::partlabel: case FstabEntry::Type::partlabel:
radioLabel().setChecked(true); radioLabel().setChecked(true);
break; break;
case FstabEntryType::deviceNode: case FstabEntry::Type::deviceNode:
radioDeviceNode().setChecked(true); radioDeviceNode().setChecked(true);
break; break;
case FstabEntryType::comment: case FstabEntry::Type::comment:
break; break;
} }
} }
@ -174,24 +174,24 @@ void EditMountPointDialogWidget::buttonSelectClicked(bool)
void EditMountPointDialogWidget::removeMountPoint() void EditMountPointDialogWidget::removeMountPoint()
{ {
int i=0; for (auto it = fstabEntries().begin(); it != fstabEntries().end(); ) {
for (const auto &e : fstabEntries()) { if (editPath().count() <= 1 && (
if(editPath().count()<=1 && ((e.fsSpec().contains(partition().deviceNode()) && !partition().deviceNode().isEmpty() ) || (e.fsSpec().contains(partition().fileSystem().uuid()) && !partition().fileSystem().uuid().isEmpty()) || (it->fsSpec().contains(partition().deviceNode()) && !partition().deviceNode().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() ))) (it->fsSpec().contains(partition().fileSystem().uuid()) && !partition().fileSystem().uuid().isEmpty() ) ||
{ (it->fsSpec().contains(partition().fileSystem().label()) && !partition().fileSystem().label().isEmpty()) ||
fstabEntries().removeAt(i); (it->fsSpec().contains(partition().label()) && !partition().label().isEmpty() ) ||
(it->fsSpec().contains(partition().uuid()) && !partition().uuid().isEmpty() )))
{
fstabEntries().erase(it);
partition().setMountPoint(QString()); partition().setMountPoint(QString());
i--; }
} else if (editPath().count() > 1 && ((&*it == currentEntry)))
else if(editPath().count()>1 && ((&e == currentEntry))) {
{ fstabEntries().erase(it);
fstabEntries().removeAt(i);
editPath().removeItem(editPath().currentIndex()); editPath().removeItem(editPath().currentIndex());
partition().setMountPoint(editPath().itemText(editPath().currentIndex())); partition().setMountPoint(editPath().itemText(editPath().currentIndex()));
i--;
break; break;
} }
i++;
} }
} }

View File

@ -84,7 +84,7 @@ protected:
private: private:
void setupOptions(const QStringList& options); void setupOptions(const QStringList& options);
void setupRadio(const FstabEntryType entryType); void setupRadio(const FstabEntry::Type entryType);
std::map<QString, QCheckBox*>& boxOptions() { std::map<QString, QCheckBox*>& boxOptions() {
return m_BoxOptions; return m_BoxOptions;
} }
@ -102,7 +102,7 @@ private:
private: private:
FstabEntryList m_fstabEntries; FstabEntryList m_fstabEntries;
QList<FstabEntry *> entry; QList<FstabEntry *> entry; // All fstab entries for this partition
FstabEntry *currentEntry; FstabEntry *currentEntry;
Partition& m_Partition; Partition& m_Partition;
QString m_Options; QString m_Options;

View File

@ -72,8 +72,8 @@ void FileSystemSupportDialog::setupDialog()
dialogWidget().tree().clear(); dialogWidget().tree().clear();
for (const auto &fs : FileSystemFactory::map()) { for (const auto &fs : FileSystemFactory::map()) {
if (fs->type() == FileSystem::Unknown || fs->type() == FileSystem::Extended || if (fs->type() == FileSystem::Type::Unknown || fs->type() == FileSystem::Type::Extended ||
fs->type() == FileSystem::Luks || fs->type() == FileSystem::Luks2) { fs->type() == FileSystem::Type::Luks || fs->type() == FileSystem::Type::Luks2) {
continue; continue;
} }

View File

@ -22,6 +22,7 @@
#include <core/diskdevice.h> #include <core/diskdevice.h>
#include <core/lvmdevice.h> #include <core/lvmdevice.h>
#include <core/partition.h> #include <core/partition.h>
#include <core/softwareraid.h>
#include <fs/filesystem.h> #include <fs/filesystem.h>
#include <fs/luks.h> #include <fs/luks.h>
@ -114,7 +115,7 @@ void InfoPane::showPartition(Qt::DockWidgetArea area, const Partition& p)
int x = 0; int x = 0;
int y = createHeader(p.deviceNode(), cols(area)); 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<const FS::luks*>(&p.fileSystem()); const FS::luks* luksFs = static_cast<const FS::luks*>(&p.fileSystem());
QString deviceNode = p.partitionPath(); QString deviceNode = p.partitionPath();
createLabels(i18nc("@label partition", "File system:"), p.fileSystem().name(), cols(area), x, y); createLabels(i18nc("@label partition", "File system:"), p.fileSystem().name(), cols(area), x, y);
@ -127,7 +128,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", "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", "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); 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; FS::lvm2_pv *lvm2PVFs;
innerFS(&p, lvm2PVFs); innerFS(&p, lvm2PVFs);
QString deviceNode = p.partitionPath(); QString deviceNode = p.partitionPath();
@ -176,8 +177,8 @@ void InfoPane::showDevice(Qt::DockWidgetArea area, const Device& d)
maxPrimaries = QStringLiteral("%1/%2").arg(d.partitionTable()->numPrimaries()).arg(d.partitionTable()->maxPrimaries()); 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<const DiskDevice&>(d); const DiskDevice& disk = static_cast<const DiskDevice&>(d);
createLabels(i18nc("@label device", "Type:"), type, cols(area), x, y); createLabels(i18nc("@label device", "Type:"), type, cols(area), x, y);
createLabels(i18nc("@label device", "Capacity:"), Capacity::formatByteSize(disk.capacity()), cols(area), x, y); createLabels(i18nc("@label device", "Capacity:"), Capacity::formatByteSize(disk.capacity()), cols(area), x, y);
@ -185,14 +186,22 @@ 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", "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", "Physical sector size:"), Capacity::formatByteSize(disk.physicalSectorSize()), cols(area), x, y);
createLabels(i18nc("@label device", "Primaries/Max:"), maxPrimaries, 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<const LvmDevice&>(d); const LvmDevice& lvm = static_cast<const LvmDevice&>(d);
createLabels(i18nc("@label device", "Volume Type:"), QStringLiteral("LVM"), cols(area), x, y); 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", "Capacity:"), Capacity::formatByteSize(lvm.capacity()), cols(area), x, y);
createLabels(i18nc("@label device", "PE Size:"), Capacity::formatByteSize(lvm.peSize()), cols(area), x, y); createLabels(i18nc("@label device", "PE Size:"), Capacity::formatByteSize(lvm.peSize()), cols(area), x, y);
createLabels(i18nc("@label device", "Total PE:"),QString::number(lvm.totalPE()), cols(area), x, y); 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", "Allocated PE:"), QString::number(lvm.allocatedPE()), cols(area), x, y);
createLabels(i18nc("@label device", "Free PE:"), QString::number(lvm.freePE()), 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 = static_cast<const SoftwareRAID&>(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:"), 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);
} }
} }

View File

@ -55,6 +55,7 @@
#include <fs/filesystemfactory.h> #include <fs/filesystemfactory.h>
#include <fs/luks.h> #include <fs/luks.h>
#include <util/externalcommand.h>
#include <util/helpers.h> #include <util/helpers.h>
#include <util/guihelpers.h> #include <util/guihelpers.h>
#include <util/report.h> #include <util/report.h>
@ -86,11 +87,7 @@
#include <KIO/CopyJob> #include <KIO/CopyJob>
#include <KIO/Job> #include <KIO/Job>
#include <KJobWidgets> #include <KJobWidgets>
#include "config.h"
#include <config.h>
#include <unistd.h>
#include <typeinfo>
/** Creates a new MainWindow instance. /** Creates a new MainWindow instance.
@param parent the parent widget @param parent the parent widget
@ -134,12 +131,15 @@ void MainWindow::init()
listDevices().setActionCollection(actionCollection()); listDevices().setActionCollection(actionCollection());
listOperations().setActionCollection(actionCollection()); listOperations().setActionCollection(actionCollection());
pmWidget().init(&operationStack());
setupGUI(); setupGUI();
loadConfig(); loadConfig();
show();
ExternalCommand::setParentWidget(this);
pmWidget().init(&operationStack());
scanDevices(); scanDevices();
} }
@ -165,6 +165,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
saveConfig(); saveConfig();
KXmlGuiWindow::closeEvent(event); KXmlGuiWindow::closeEvent(event);
ExternalCommand::stopHelper();
} }
void MainWindow::changeEvent(QEvent* event) void MainWindow::changeEvent(QEvent* event)
@ -483,7 +484,8 @@ void MainWindow::enableActions()
actionCollection()->action(QStringLiteral("createNewPartitionTable")) actionCollection()->action(QStringLiteral("createNewPartitionTable"))
->setEnabled(CreatePartitionTableOperation::canCreate(pmWidget().selectedDevice())); ->setEnabled(CreatePartitionTableOperation::canCreate(pmWidget().selectedDevice()));
actionCollection()->action(QStringLiteral("createNewPartitionTable")) actionCollection()->action(QStringLiteral("createNewPartitionTable"))
->setVisible(pmWidget().selectedDevice() && pmWidget().selectedDevice()->type() == Device::Disk_Device); ->setVisible(pmWidget().selectedDevice() && (pmWidget().selectedDevice()->type() == Device::Type::Disk_Device ||
pmWidget().selectedDevice()->type() == Device::Type::SoftwareRAID_Device));
actionCollection()->action(QStringLiteral("exportPartitionTable")) actionCollection()->action(QStringLiteral("exportPartitionTable"))
->setEnabled(pmWidget().selectedDevice() && ->setEnabled(pmWidget().selectedDevice() &&
pmWidget().selectedDevice()->partitionTable() && pmWidget().selectedDevice()->partitionTable() &&
@ -491,10 +493,10 @@ void MainWindow::enableActions()
actionCollection()->action(QStringLiteral("importPartitionTable")) actionCollection()->action(QStringLiteral("importPartitionTable"))
->setEnabled(CreatePartitionTableOperation::canCreate(pmWidget().selectedDevice())); ->setEnabled(CreatePartitionTableOperation::canCreate(pmWidget().selectedDevice()));
actionCollection()->action(QStringLiteral("smartStatusDevice")) 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()); pmWidget().selectedDevice()->smartStatus().isValid());
actionCollection()->action(QStringLiteral("smartStatusDevice")) 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")) actionCollection()->action(QStringLiteral("propertiesDevice"))
->setEnabled(pmWidget().selectedDevice() != nullptr); ->setEnabled(pmWidget().selectedDevice() != nullptr);
@ -503,8 +505,7 @@ void MainWindow::enableActions()
actionCollection()->action(QStringLiteral("clearAllOperations")) actionCollection()->action(QStringLiteral("clearAllOperations"))
->setEnabled(operationStack().size() > 0); ->setEnabled(operationStack().size() > 0);
actionCollection()->action(QStringLiteral("applyAllOperations")) actionCollection()->action(QStringLiteral("applyAllOperations"))
->setEnabled(operationStack().size() > 0 && (geteuid() == 0 || ->setEnabled(operationStack().size() > 0);
Config::allowApplyOperationsAsNonRoot()));
const bool readOnly = pmWidget().selectedDevice() == nullptr || const bool readOnly = pmWidget().selectedDevice() == nullptr ||
pmWidget().selectedDevice()->partitionTable() == nullptr || pmWidget().selectedDevice()->partitionTable() == nullptr ||
@ -513,7 +514,7 @@ void MainWindow::enableActions()
actionCollection()->action(QStringLiteral("createVolumeGroup")) actionCollection()->action(QStringLiteral("createVolumeGroup"))
->setEnabled(CreateVolumeGroupOperation::canCreate()); ->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; bool removable = false;
if (lvmDevice) if (lvmDevice)
@ -707,7 +708,7 @@ void MainWindow::on_m_PartitionManagerWidget_selectedPartitionChanged(const Part
void MainWindow::scanDevices() 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()->id(),
CoreBackendManager::self()->backend()->version()); CoreBackendManager::self()->backend()->version());
@ -1062,11 +1063,11 @@ void MainWindow::onImportPartitionTable()
if (fs->supportSetLabel() != FileSystem::cmdSupportNone && !volumeLabel.isEmpty()) if (fs->supportSetLabel() != FileSystem::cmdSupportNone && !volumeLabel.isEmpty())
fs->setLabel(volumeLabel); 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)); operationStack().push(new NewOperation(device, p));
} else } 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)) if (ptable->type() == PartitionTable::msdos && ptable->isSectorBased(device))
@ -1110,7 +1111,7 @@ void MainWindow::onCreateNewVolumeGroup()
QVector<const Partition*> pvList; QVector<const Partition*> pvList;
qint32 peSize = 4; qint32 peSize = 4;
// *NOTE*: vgName & pvList will be modified and validated by the dialog // *NOTE*: vgName & pvList will be modified and validated by the dialog
QPointer<CreateVolumeGroupDialog> dlg = new CreateVolumeGroupDialog(this, vgName, pvList, peSize, operationStack().previewDevices()); QPointer<CreateVolumeGroupDialog> dlg = new CreateVolumeGroupDialog(this, vgName, pvList, peSize, operationStack().previewDevices(), operationStack().operations());
if (dlg->exec() == QDialog::Accepted) if (dlg->exec() == QDialog::Accepted)
operationStack().push(new CreateVolumeGroupOperation(vgName, pvList, peSize)); operationStack().push(new CreateVolumeGroupOperation(vgName, pvList, peSize));
@ -1119,13 +1120,13 @@ void MainWindow::onCreateNewVolumeGroup()
void MainWindow::onResizeVolumeGroup() void MainWindow::onResizeVolumeGroup()
{ {
if (pmWidget().selectedDevice()->type() == Device::LVM_Device) { if (pmWidget().selectedDevice()->type() == Device::Type::LVM_Device) {
LvmDevice* d = dynamic_cast<LvmDevice*>(pmWidget().selectedDevice()); LvmDevice* d = dynamic_cast<LvmDevice*>(pmWidget().selectedDevice());
QVector<const Partition*> pvList; QVector<const Partition*> pvList;
// *NOTE*: pvList will be modified and validated by the dialog // *NOTE*: pvList will be modified and validated by the dialog
QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, d, pvList); QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, d, pvList, operationStack().previewDevices(), operationStack().operations());
if (dlg->exec() == QDialog::Accepted) if (dlg->exec() == QDialog::Accepted)
operationStack().push(new ResizeVolumeGroupOperation(*d, pvList)); operationStack().push(new ResizeVolumeGroupOperation(*d, pvList));
@ -1136,7 +1137,7 @@ void MainWindow::onResizeVolumeGroup()
void MainWindow::onRemoveVolumeGroup() void MainWindow::onRemoveVolumeGroup()
{ {
Device* tmpDev = pmWidget().selectedDevice(); Device* tmpDev = pmWidget().selectedDevice();
if (tmpDev->type() == Device::LVM_Device) { if (tmpDev->type() == Device::Type::LVM_Device) {
operationStack().push(new RemoveVolumeGroupOperation(*(dynamic_cast<LvmDevice*>(tmpDev)))); operationStack().push(new RemoveVolumeGroupOperation(*(dynamic_cast<LvmDevice*>(tmpDev))));
} }
} }
@ -1144,7 +1145,7 @@ void MainWindow::onRemoveVolumeGroup()
void MainWindow::onDeactivateVolumeGroup() void MainWindow::onDeactivateVolumeGroup()
{ {
Device* tmpDev = pmWidget().selectedDevice(); Device* tmpDev = pmWidget().selectedDevice();
if (tmpDev->type() == Device::LVM_Device) { if (tmpDev->type() == Device::Type::LVM_Device) {
DeactivateVolumeGroupOperation* deactivate = new DeactivateVolumeGroupOperation( *(dynamic_cast<LvmDevice*>(tmpDev)) ); DeactivateVolumeGroupOperation* deactivate = new DeactivateVolumeGroupOperation( *(dynamic_cast<LvmDevice*>(tmpDev)) );
Report* tmpReport = new Report(nullptr); Report* tmpReport = new Report(nullptr);
if (deactivate->execute(*tmpReport)) { if (deactivate->execute(*tmpReport)) {

View File

@ -73,9 +73,9 @@ void NewDialog::setupDialog()
QStringList fsNames; QStringList fsNames;
for (const auto &fs : FileSystemFactory::map()) { for (const auto &fs : FileSystemFactory::map()) {
if (fs->supportCreate() != FileSystem::cmdSupportNone && if (fs->supportCreate() != FileSystem::cmdSupportNone &&
fs->type() != FileSystem::Extended && fs->type() != FileSystem::Type::Extended &&
fs->type() != FileSystem::Luks && fs->type() != FileSystem::Type::Luks &&
fs->type() != FileSystem::Luks2) fs->type() != FileSystem::Type::Luks2)
fsNames.append(fs->name()); fsNames.append(fs->name());
} }
@ -102,7 +102,7 @@ void NewDialog::setupDialog()
dialogWidget().checkBoxEncrypt().hide(); dialogWidget().checkBoxEncrypt().hide();
dialogWidget().editPassphrase().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"))); dialogWidget().comboFileSystem().removeItem(dialogWidget().comboFileSystem().findText(QStringLiteral("lvm2 pv")));
} }
@ -137,14 +137,14 @@ void NewDialog::setupConnections()
bool NewDialog::canMove() const bool NewDialog::canMove() const
{ {
return (device().type() == Device::LVM_Device) ? false : true; return (device().type() == Device::Type::LVM_Device) ? false : true;
} }
void NewDialog::accept() void NewDialog::accept()
{ {
if (partition().roles().has(PartitionRole::Extended)) { if (partition().roles().has(PartitionRole::Extended)) {
partition().deleteFileSystem(); partition().deleteFileSystem();
partition().setFileSystem(FileSystemFactory::create(FileSystem::Extended, partition().setFileSystem(FileSystemFactory::create(FileSystem::Type::Extended,
partition().firstSector(), partition().firstSector(),
partition().lastSector(), partition().lastSector(),
partition().sectorSize())); partition().sectorSize()));
@ -153,7 +153,7 @@ void NewDialog::accept()
FileSystem::Type innerFsType = partition().fileSystem().type(); FileSystem::Type innerFsType = partition().fileSystem().type();
partition().deleteFileSystem(); partition().deleteFileSystem();
FS::luks* luksFs = dynamic_cast< FS::luks* >( FS::luks* luksFs = dynamic_cast< FS::luks* >(
FileSystemFactory::create(FileSystem::Luks, FileSystemFactory::create(FileSystem::Type::Luks,
partition().firstSector(), partition().firstSector(),
partition().lastSector(), partition().lastSector(),
partition().sectorSize())); 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 // Also make sure to set a primary's or logical's file system once the user goes back from
// extended to any of those. // extended to any of those.
if (r == PartitionRole::Extended) if (r == PartitionRole::Extended)
updateFileSystem(FileSystem::Extended); updateFileSystem(FileSystem::Type::Extended);
else else
updateFileSystem(FileSystem::typeForName(dialogWidget().comboFileSystem().currentText())); updateFileSystem(FileSystem::typeForName(dialogWidget().comboFileSystem().currentText()));
@ -269,7 +269,7 @@ void NewDialog::updateHideAndShow()
dialogWidget().label().setReadOnly(false); dialogWidget().label().setReadOnly(false);
dialogWidget().noSetLabel().setVisible(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(); dialogWidget().checkBoxEncrypt().show();
if (dialogWidget().checkBoxEncrypt().isChecked()) if (dialogWidget().checkBoxEncrypt().isChecked())

View File

@ -208,7 +208,7 @@ static QTreeWidgetItem* createTreeWidgetItem(const Partition& p)
int i = 0; int i = 0;
item->setText(i++, p.deviceNode()); 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())); item->setText(i, xi18nc("@item:intable Encrypted file systems, e.g. btrfs[Encrypted]", "%1 [Encrypted]", p.fileSystem().name()));
else else
item->setText(i, p.fileSystem().name()); item->setText(i, p.fileSystem().name());
@ -569,11 +569,11 @@ void PartitionManagerWidget::onDeletePartition(bool shred)
} }
if (shred && Config::shredSource() == Config::EnumShredSource::random) 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) 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 else
operationStack().push(new DeleteOperation(*selectedDevice(), selectedPartition(), DeleteOperation::NoShred)); operationStack().push(new DeleteOperation(*selectedDevice(), selectedPartition(), DeleteOperation::ShredAction::NoShred));
} }
void PartitionManagerWidget::onShredPartition() void PartitionManagerWidget::onShredPartition()
@ -605,7 +605,7 @@ void PartitionManagerWidget::onResizePartition()
qint64 freeBefore = selectedDevice()->partitionTable()->freeSectorsBefore(p); qint64 freeBefore = selectedDevice()->partitionTable()->freeSectorsBefore(p);
qint64 freeAfter = selectedDevice()->partitionTable()->freeSectorsAfter(p); qint64 freeAfter = selectedDevice()->partitionTable()->freeSectorsAfter(p);
if (selectedDevice()->type() == Device::LVM_Device) { if (selectedDevice()->type() == Device::Type::LVM_Device) {
freeBefore = 0; freeBefore = 0;
freeAfter = selectedDevice()->partitionTable()->freeSectors(); freeAfter = selectedDevice()->partitionTable()->freeSectors();
} }
@ -614,7 +614,7 @@ void PartitionManagerWidget::onResizePartition()
if (dlg->exec() == QDialog::Accepted) { if (dlg->exec() == QDialog::Accepted) {
if (dlg->resizedFirstSector() == p.firstSector() && dlg->resizedLastSector() == p.lastSector()) if (dlg->resizedFirstSector() == p.firstSector() && dlg->resizedLastSector() == p.lastSector())
Log(Log::information) << xi18nc("@info:status", "Partition <filename>%1</filename> has the same position and size after resize/move. Ignoring operation.", p.deviceNode()); Log(Log::Level::information) << xi18nc("@info:status", "Partition <filename>%1</filename> has the same position and size after resize/move. Ignoring operation.", p.deviceNode());
else else
operationStack().push(new ResizeOperation(*selectedDevice(), p, dlg->resizedFirstSector(), dlg->resizedLastSector())); operationStack().push(new ResizeOperation(*selectedDevice(), p, dlg->resizedFirstSector(), dlg->resizedLastSector()));
} }

View File

@ -51,7 +51,7 @@ PartPropsDialog::PartPropsDialog(QWidget* parent, Device& d, Partition& p) :
m_Partition(p), m_Partition(p),
m_WarnFileSystemChange(false), m_WarnFileSystemChange(false),
m_DialogWidget(new PartPropsWidget(this)), 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) m_ForceRecreate(false)
{ {
mainLayout = new QVBoxLayout(this); mainLayout = new QVBoxLayout(this);
@ -152,7 +152,7 @@ void PartPropsDialog::setupDialog()
dialogWidget().label().setText(newLabel().isEmpty() ? partition().fileSystem().label() : newLabel()); dialogWidget().label().setText(newLabel().isEmpty() ? partition().fileSystem().label() : newLabel());
dialogWidget().capacity().setText(Capacity::formatByteSize(partition().capacity())); 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 qint64 availPercent = (partition().fileSystem().length() - partition().fileSystem().sectorsUsed()) * 100 / partition().fileSystem().length();
const QString availString = QStringLiteral("%1% - %2") const QString availString = QStringLiteral("%1% - %2")
@ -220,7 +220,7 @@ void PartPropsDialog::updateHideAndShow()
// when do we show the uuid? // when do we show the uuid?
const bool showUuid = 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 !(fs == nullptr || fs->supportGetUUID() == FileSystem::cmdSupportNone); // not if the FS doesn't support it
dialogWidget().showUuid(showUuid); dialogWidget().showUuid(showUuid);
@ -229,10 +229,10 @@ void PartPropsDialog::updateHideAndShow()
// when do we show available and used capacity? // when do we show available and used capacity?
const bool showAvailableAndUsed = 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::Extended) && // neither for extended
!partition().roles().has(PartitionRole::Unallocated) && // or for unallocated !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().showAvailable(showAvailableAndUsed);
dialogWidget().showUsed(showAvailableAndUsed); dialogWidget().showUsed(showAvailableAndUsed);
@ -242,22 +242,22 @@ void PartPropsDialog::updateHideAndShow()
!partition().roles().has(PartitionRole::Extended) && // not for extended, they have no file system !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 !partition().roles().has(PartitionRole::Unallocated) && // and not for unallocated: no choice there
// do now show file system comboBox for open luks volumes. // 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); dialogWidget().showFileSystem(showFileSystem);
// when do we show the recreate file system check box? // when do we show the recreate file system check box?
const bool showCheckRecreate = const bool showCheckRecreate =
showFileSystem && // only if we also show the file system showFileSystem && // only if we also show the file system
partition().fileSystem().supportCreate() != FileSystem::cmdSupportNone && // and support creating this 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().state() != Partition::State::New && // or new partitions
!partition().roles().has(PartitionRole::Luks); // or encrypted filesystems !partition().roles().has(PartitionRole::Luks); // or encrypted filesystems
dialogWidget().showCheckRecreate(showCheckRecreate); dialogWidget().showCheckRecreate(showCheckRecreate);
// when do we show the list of partition flags? // when do we show the list of partition flags?
const bool showListFlags = 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 !partition().roles().has(PartitionRole::Unallocated); // and not for unallocated space
dialogWidget().showListFlags(showListFlags); dialogWidget().showListFlags(showListFlags);
@ -297,7 +297,7 @@ void PartPropsDialog::setupFileSystemComboBox()
for(const auto &fs : FileSystemFactory::map()) for(const auto &fs : FileSystemFactory::map())
{ {
// If the partition isn't encrypted, skip the luks FS // 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; continue;
if (partition().fileSystem().type() == fs->type() || (fs->supportCreate() != FileSystem::cmdSupportNone && if (partition().fileSystem().type() == fs->type() || (fs->supportCreate() != FileSystem::cmdSupportNone &&
partition().capacity() >= fs->minCapacity() && partition().capacity() <= fs->maxCapacity())) { partition().capacity() >= fs->minCapacity() && partition().capacity() <= fs->maxCapacity())) {
@ -307,16 +307,16 @@ void PartPropsDialog::setupFileSystemComboBox()
selected = name; selected = name;
// If the partition isn't extended, skip the extended FS // 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; continue;
// The user cannot change the filesystem back to "unformatted" once a filesystem has been created. // 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 // .. but if the file system is unknown to us, show the unformatted option as the currently selected one
if (partition().fileSystem().type() == FileSystem::Unknown) { if (partition().fileSystem().type() == FileSystem::Type::Unknown) {
name = FileSystem::nameForType(FileSystem::Unformatted); name = FileSystem::nameForType(FileSystem::Type::Unformatted);
selected = name; selected = name;
} else if (partition().fileSystem().type() != FileSystem::Unformatted && partition().state() != Partition::StateNew) } else if (partition().fileSystem().type() != FileSystem::Type::Unformatted && partition().state() != Partition::State::New)
continue; continue;
} }
@ -346,7 +346,7 @@ void PartPropsDialog::updatePartitionFileSystem()
void PartPropsDialog::onFilesystemChanged(int) 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", "<para><warning>You are about to lose all data on partition <filename>%1</filename>.</warning></para>" xi18nc("@info", "<para><warning>You are about to lose all data on partition <filename>%1</filename>.</warning></para>"
"<para>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 <filename>%1</filename> will unrecoverably be lost.</para>", partition().deviceNode()), "<para>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 <filename>%1</filename> will unrecoverably be lost.</para>", partition().deviceNode()),
xi18nc("@title:window", "Really Recreate <filename>%1</filename> with File System %2?", partition().deviceNode(), dialogWidget().fileSystem().currentText()), xi18nc("@title:window", "Really Recreate <filename>%1</filename> with File System %2?", partition().deviceNode(), dialogWidget().fileSystem().currentText()),

View File

@ -91,7 +91,7 @@ void ResizeDialog::accept()
if (partition().roles().has(PartitionRole::Luks)) { if (partition().roles().has(PartitionRole::Luks)) {
FS::luks2* luksFs = dynamic_cast<FS::luks2*>(&partition().fileSystem()); FS::luks2* luksFs = dynamic_cast<FS::luks2*>(&partition().fileSystem());
if (luksFs) { if (luksFs) {
if (luksFs->keyLocation() == FS::luks::keyring) { if (luksFs->keyLocation() == FS::luks::KeyLocation::keyring) {
bool validPassphrase = false; bool validPassphrase = false;
QString errorMessage; QString errorMessage;
QString passphrase; QString passphrase;
@ -130,7 +130,7 @@ void ResizeDialog::reject()
void ResizeDialog::setupDialog() void ResizeDialog::setupDialog()
{ {
SizeDialogBase::setupDialog(); SizeDialogBase::setupDialog();
if (device().type() == Device::LVM_Device) { if (device().type() == Device::Type::LVM_Device) {
dialogWidget().hideBeforeAndAfter(); dialogWidget().hideBeforeAndAfter();
detailsWidget().checkAlign().setChecked(false); detailsWidget().checkAlign().setChecked(false);
detailsWidget().checkAlign().setEnabled(false); detailsWidget().checkAlign().setEnabled(false);
@ -162,5 +162,5 @@ bool ResizeDialog::canShrink() const
bool ResizeDialog::canMove() 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());
} }

View File

@ -24,6 +24,8 @@
#include <core/partitiontable.h> #include <core/partitiontable.h>
#include <fs/lvm2_pv.h> #include <fs/lvm2_pv.h>
#include <ops/deleteoperation.h>
#include <util/capacity.h> #include <util/capacity.h>
#include <util/helpers.h> #include <util/helpers.h>
@ -35,9 +37,11 @@
@param parent pointer to the parent widget @param parent pointer to the parent widget
@param d the Device to show properties for @param d the Device to show properties for
*/ */
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QVector<const Partition*>& partList) ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QVector<const Partition*>& partList, QList<Device*> devices, QList<Operation*> pendingOps)
: VolumeGroupDialog(parent, d->name(), partList) : VolumeGroupDialog(parent, d->name(), partList)
, m_Devices(devices)
, m_Device(d) , m_Device(d)
, m_PendingOps(pendingOps)
{ {
setWindowTitle(xi18nc("@title:window", "Resize Volume Group")); setWindowTitle(xi18nc("@title:window", "Resize Volume Group"));
@ -51,7 +55,20 @@ ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerD
void ResizeVolumeGroupDialog::setupDialog() void ResizeVolumeGroupDialog::setupDialog()
{ {
if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) { if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) {
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
for (const auto &o : qAsConst(m_PendingOps)) {
if (dynamic_cast<DeleteOperation *>(o) && o->targets(*p.partition())) {
toBeDeleted = true;
break;
}
}
if (toBeDeleted)
continue;
if (p.isLuks()) if (p.isLuks())
continue; continue;
if (p.vgName() == device()->name()) if (p.vgName() == device()->name())
@ -59,6 +76,32 @@ void ResizeVolumeGroupDialog::setupDialog()
else if (p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition())) // TODO: Remove LVM PVs in current VG else if (p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition())) // TODO: Remove LVM PVs in current VG
dialogWidget().listPV().addPartition(*p.partition(), false); dialogWidget().listPV().addPartition(*p.partition(), false);
} }
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<const FS::luks *>(&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);
} }
//update used size and LV infos //update used size and LV infos

View File

@ -15,8 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.* * along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/ *************************************************************************/
#if !defined(RESIZEVOLUMEGROUPDIALOG_H) #ifndef RESIZEVOLUMEGROUPDIALOG_H
#define RESIZEVOLUMEGROUPDIALOG_H #define RESIZEVOLUMEGROUPDIALOG_H
#include <fs/lvm2_pv.h> #include <fs/lvm2_pv.h>
@ -24,6 +23,7 @@
#include "gui/volumegroupdialog.h" #include "gui/volumegroupdialog.h"
class Device; class Device;
class Operation;
class VolumeManagerDevice; class VolumeManagerDevice;
class ResizeVolumeGroupDialog : public VolumeGroupDialog class ResizeVolumeGroupDialog : public VolumeGroupDialog
@ -31,7 +31,7 @@ class ResizeVolumeGroupDialog : public VolumeGroupDialog
Q_DISABLE_COPY(ResizeVolumeGroupDialog) Q_DISABLE_COPY(ResizeVolumeGroupDialog)
public: public:
ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QVector<const Partition*>& partList); ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QVector<const Partition*>& partList, QList<Device*> devices, QList<Operation*> pendingOps = QList<Operation *>());
protected: protected:
void accept() override; void accept() override;
@ -43,7 +43,9 @@ protected:
} }
private: private:
const QList<Device*> m_Devices; // List of all devices found on the system
VolumeManagerDevice* m_Device; VolumeManagerDevice* m_Device;
const QList<Operation*> m_PendingOps; // List of pending operations in KPM
}; };
#endif #endif

View File

@ -18,6 +18,8 @@
#include "gui/scanprogressdialog.h" #include "gui/scanprogressdialog.h"
#include <QCloseEvent>
#include <KLocalizedString> #include <KLocalizedString>
ScanProgressDialog::ScanProgressDialog(QWidget* parent) : ScanProgressDialog::ScanProgressDialog(QWidget* parent) :
@ -26,9 +28,15 @@ ScanProgressDialog::ScanProgressDialog(QWidget* parent) :
setWindowTitle(xi18nc("@title:window", "Scanning devices...")); setWindowTitle(xi18nc("@title:window", "Scanning devices..."));
setMinimumWidth(280); setMinimumWidth(280);
setMinimumDuration(150); setMinimumDuration(150);
setValue(0);
setAttribute(Qt::WA_ShowModal, true); setAttribute(Qt::WA_ShowModal, true);
} }
void ScanProgressDialog::closeEvent(QCloseEvent* e)
{
e->ignore();
}
void ScanProgressDialog::setDeviceName(const QString& d) void ScanProgressDialog::setDeviceName(const QString& d)
{ {
if (d.isEmpty()) if (d.isEmpty())
@ -39,7 +47,7 @@ void ScanProgressDialog::setDeviceName(const QString& d)
void ScanProgressDialog::showEvent(QShowEvent* e) void ScanProgressDialog::showEvent(QShowEvent* e)
{ {
setCancelButton(0); setCancelButton(nullptr);
QProgressDialog::showEvent(e); QProgressDialog::showEvent(e);
} }

View File

@ -15,14 +15,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.* * along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/ *************************************************************************/
#if !defined(SCANPROGRESSDIALOG_H) #ifndef SCANPROGRESSDIALOG_H
#define SCANPROGRESSDIALOG_H #define SCANPROGRESSDIALOG_H
#include <QProgressDialog> #include <QProgressDialog>
class QShowEvent;
class ScanProgressDialog : public QProgressDialog class ScanProgressDialog : public QProgressDialog
{ {
public: public:
@ -34,6 +31,7 @@ public:
void setDeviceName(const QString& d); void setDeviceName(const QString& d);
protected: protected:
void closeEvent(QCloseEvent* e) override;
void showEvent(QShowEvent* e) override; void showEvent(QShowEvent* e) override;
}; };

View File

@ -105,11 +105,11 @@ void SizeDialogBase::setupDialog()
dialogWidget().partResizerWidget().init(device(), partition(), minimumFirstSector(), maximumLastSector(), true, canMove()); dialogWidget().partResizerWidget().init(device(), partition(), minimumFirstSector(), maximumLastSector(), true, canMove());
dialogWidget().partResizerWidget().setAlign(Config::alignDefault()); dialogWidget().partResizerWidget().setAlign(Config::alignDefault());
if (device().type() == Device::Disk_Device) { if (device().type() == Device::Type::Disk_Device) {
dialogWidget().lvName().hide(); dialogWidget().lvName().hide();
dialogWidget().textLVName().hide(); dialogWidget().textLVName().hide();
} }
if (device().type() == Device::LVM_Device) { if (device().type() == Device::Type::LVM_Device) {
dialogWidget().hideBeforeAndAfter(); dialogWidget().hideBeforeAndAfter();
detailsWidget().checkAlign().setChecked(false); detailsWidget().checkAlign().setChecked(false);
detailsWidget().checkAlign().setEnabled(false); detailsWidget().checkAlign().setEnabled(false);
@ -380,7 +380,7 @@ void SizeDialogBase::onLVNameChanged(const QString& newName)
partition().setPartitionPath(device().deviceNode() + QStringLiteral("/") + newName.trimmed()); partition().setPartitionPath(device().deviceNode() + QStringLiteral("/") + newName.trimmed());
if ((dialogWidget().lvName().isVisible() && if ((dialogWidget().lvName().isVisible() &&
dialogWidget().lvName().text().isEmpty()) || dialogWidget().lvName().text().isEmpty()) ||
(device().type() == Device::LVM_Device && (device().type() == Device::Type::LVM_Device &&
dynamic_cast<LvmDevice&>(device()).partitionNodes().contains(partition().partitionPath())) ) { dynamic_cast<LvmDevice&>(device()).partitionNodes().contains(partition().partitionPath())) ) {
m_IsValidLVName = false; m_IsValidLVName = false;
} else { } else {
@ -467,6 +467,6 @@ static double sectorsToDialogUnit(const Device& d, qint64 v)
static qint64 dialogUnitToSectors(const Device& d, double 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();
} }

View File

@ -121,8 +121,8 @@ void SmartDialog::setupDialog()
QStringList() QStringList()
<< QLocale().toString(a.id()) << QLocale().toString(a.id())
<< QStringLiteral("<b>%1</b><br/>%2").arg(a.name()).arg(st + a.desc() + QStringLiteral("</span>")) << QStringLiteral("<b>%1</b><br/>%2").arg(a.name()).arg(st + a.desc() + QStringLiteral("</span>"))
<< (a.failureType() == SmartAttribute::PreFailure ? xi18nc("@item:intable", "Pre-Failure") : xi18nc("@item:intable", "Old-Age")) << (a.failureType() == SmartAttribute::FailureType::PreFailure ? xi18nc("@item:intable", "Pre-Failure") : xi18nc("@item:intable", "Old-Age"))
<< (a.updateType() == SmartAttribute::Online ? xi18nc("@item:intable", "Online") : xi18nc("@item:intable", "Offline")) << (a.updateType() == SmartAttribute::UpdateType::Online ? xi18nc("@item:intable", "Online") : xi18nc("@item:intable", "Offline"))
<< QLocale().toString(a.worst()) << QLocale().toString(a.worst())
<< QLocale().toString(a.current()) << QLocale().toString(a.current())
<< QLocale().toString(a.threshold()) << QLocale().toString(a.threshold())
@ -187,8 +187,8 @@ QString SmartDialog::toHtml() const
s << "<td>" << QLocale().toString(a.id()) << "</td>\n" s << "<td>" << QLocale().toString(a.id()) << "</td>\n"
<< "<td>" << QStringLiteral("<b>%1</b><br/>%2").arg(a.name()).arg(st + a.desc() + QStringLiteral("</span>")) << "</td>\n" << "<td>" << QStringLiteral("<b>%1</b><br/>%2").arg(a.name()).arg(st + a.desc() + QStringLiteral("</span>")) << "</td>\n"
<< "<td>" << (a.failureType() == SmartAttribute::PreFailure ? xi18nc("@item:intable", "Pre-Failure") : xi18nc("@item:intable", "Old-Age")) << "</td>\n" << "<td>" << (a.failureType() == SmartAttribute::FailureType::PreFailure ? xi18nc("@item:intable", "Pre-Failure") : xi18nc("@item:intable", "Old-Age")) << "</td>\n"
<< "<td>" << (a.updateType() == SmartAttribute::Online ? xi18nc("@item:intable", "Online") : xi18nc("@item:intable", "Offline")) << "</td>\n" << "<td>" << (a.updateType() == SmartAttribute::UpdateType::Online ? xi18nc("@item:intable", "Online") : xi18nc("@item:intable", "Offline")) << "</td>\n"
<< "<td>" << QLocale().toString(a.worst()) << "</td>\n" << "<td>" << QLocale().toString(a.worst()) << "</td>\n"
<< "<td>" << QLocale().toString(a.current()) << "</td>\n" << "<td>" << QLocale().toString(a.current()) << "</td>\n"
<< "<td>" << QLocale().toString(a.threshold()) << "</td>\n" << "<td>" << QLocale().toString(a.threshold()) << "</td>\n"

View File

@ -150,10 +150,10 @@ void TreeLog::onNewLogMessage(Log::Level logLevel, const QString& s)
qDebug() << s; qDebug() << s;
if (logLevel >= Config::minLogLevel()) { if (static_cast<int>(logLevel) >= Config::minLogLevel()) {
QTreeWidgetItem* item = new QTreeWidgetItem(); QTreeWidgetItem* item = new QTreeWidgetItem();
item->setIcon(0, QIcon::fromTheme(icons[logLevel]).pixmap(IconSize(KIconLoader::Small))); item->setIcon(0, QIcon::fromTheme(icons[static_cast<int>(logLevel)]).pixmap(IconSize(KIconLoader::Small)));
item->setText(1, QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd hh:mm:ss"))); item->setText(1, QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd hh:mm:ss")));
item->setText(2, s); item->setText(2, s);

View File

@ -127,7 +127,7 @@ void VolumeGroupDialog::updateSectorInfos()
{ {
qint32 totalSectors = 0; qint32 totalSectors = 0;
// we can't use LvmDevice mothod here because pv that is not in any VG will return 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) { if (m_ExtentSize > 0) {
totalSectors = m_TotalSize / m_ExtentSize; totalSectors = m_TotalSize / m_ExtentSize;
} }
@ -139,7 +139,7 @@ void VolumeGroupDialog::updateSizeInfos()
const QVector<const Partition *> checkedPartitions = dialogWidget().listPV().checkedItems(); const QVector<const Partition *> checkedPartitions = dialogWidget().listPV().checkedItems();
m_TotalSize = 0; m_TotalSize = 0;
for (const auto &p : checkedPartitions) 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)); dialogWidget().totalSize().setText(Capacity::formatByteSize(m_TotalSize));

View File

@ -1,5 +1,6 @@
/************************************************************************* /*************************************************************************
* Copyright (C) 2008,2011 by Volker Lanz <vl@fidra.de> * * Copyright (C) 2008,2011 by Volker Lanz <vl@fidra.de> *
* Copyright (C) 2014-2018 by Andrius Štikonas <andrius@stikonas.eu> *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as * * modify it under the terms of the GNU General Public License as *
@ -28,7 +29,7 @@
#include <KAboutData> #include <KAboutData>
#include <KCrash> #include <KCrash>
#include <Kdelibs4ConfigMigrator> #include <KDBusService>
#include <KMessageBox> #include <KMessageBox>
#include <KLocalizedString> #include <KLocalizedString>
@ -38,11 +39,6 @@ int Q_DECL_IMPORT main(int argc, char* argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
Kdelibs4ConfigMigrator migrate(QLatin1Literal("partitionmanager"));
migrate.setConfigFiles({ QLatin1Literal("partitionmanagerrc") });
migrate.setUiFiles({ QStringLiteral("partitionmanagerui.rc") });
migrate.migrate();
KLocalizedString::setApplicationDomain("partitionmanager"); KLocalizedString::setApplicationDomain("partitionmanager");
KAboutData aboutData ( KAboutData aboutData (
QStringLiteral("partitionmanager"), QStringLiteral("partitionmanager"),
@ -50,7 +46,7 @@ int Q_DECL_IMPORT main(int argc, char* argv[])
QStringLiteral(VERSION), QStringLiteral(VERSION),
xi18nc("@title", "Manage your disks, partitions and file systems"), xi18nc("@title", "Manage your disks, partitions and file systems"),
KAboutLicense::GPL_V3, 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.setOrganizationDomain(QByteArray("kde.org"));
aboutData.setProductName(QByteArray("partitionmanager")); aboutData.setProductName(QByteArray("partitionmanager"));
@ -68,15 +64,14 @@ int Q_DECL_IMPORT main(int argc, char* argv[])
QCommandLineParser parser; QCommandLineParser parser;
aboutData.setupCommandLine(&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...]")); // FIXME parser.addPositionalArgument(QStringLiteral("device"), xi18nc("@info:shell", "Device(s) to manage"), QStringLiteral("[device...]"));
parser.process(app); parser.process(app);
aboutData.processCommandLine(&parser); aboutData.processCommandLine(&parser);
KDBusService service(KDBusService::Unique);
registerMetaTypes(); registerMetaTypes();
if (!checkPermissions())
return 0;
Config::instance(QStringLiteral("partitionmanagerrc")); Config::instance(QStringLiteral("partitionmanagerrc"));
@ -84,7 +79,7 @@ int Q_DECL_IMPORT main(int argc, char* argv[])
return 0; return 0;
MainWindow* mainWindow = new MainWindow(); MainWindow* mainWindow = new MainWindow();
mainWindow->show(); Q_UNUSED(mainWindow)
return app.exec(); return app.exec();
} }

View File

@ -54,44 +54,75 @@
<label context="@label">Align partitions per default</label> <label context="@label">Align partitions per default</label>
<default>true</default> <default>true</default>
</entry> </entry>
<entry name="allowApplyOperationsAsNonRoot" type="Bool"> <entry key="fileSystemColorCode$(FileSystem)" type="Color">
<label context="@label">Allow applying operations without administrator privileges</label>
<default>false</default>
</entry>
<entry key="fileSystemColorCode$(colorNumber)" type="Color">
<label context="@label">File system colors</label> <label context="@label">File system colors</label>
<parameter name="colorNumber" type="UInt" max="29"/> <parameter name="FileSystem" type="Enum">
<!-- numbers correspond to the enum in kpmcore/fs/filesystem.h --> <!-- values correspond to the enum in kpmcore/fs/filesystem.h -->
<default param="0">220,205,175</default> <!-- unknown --> <values>
<default param="1">187,249,207</default> <!-- extended --> <value>Unknown</value>
<default param="2">102,121,150</default> <!-- ext2 --> <value>Extended</value>
<default param="3">122,145,180</default> <!-- ext3 --> <value>Ext2</value>
<default param="4">143,170,210</default> <!-- ext4 --> <value>Ext3</value>
<default param="5">155,155,130</default> <!-- swap --> <value>Ext4</value>
<default param="6">204,179,215</default> <!-- fat16 --> <value>LinuxSwap</value>
<default param="7">229,201,240</default> <!-- fat32 --> <value>Fat16</value>
<default param="8">244,214,255</default> <!-- ntfs --> <value>Fat32</value>
<default param="9">216,220,135</default> <!-- reiser--> <value>Ntfs</value>
<default param="10">251,255,157</default> <!-- reiser4 --> <value>ReiserFS</value>
<default param="11">200,255,254</default> <!-- xfs --> <value>Reiser4</value>
<default param="12">137,200,198</default> <!-- jfs --> <value>Xfs</value>
<default param="13">210,136,142</default> <!-- hfs --> <value>Jfs</value>
<default param="14">240,165,171</default> <!-- hfs+ --> <value>Hfs</value>
<default param="15">151,220,134</default> <!-- ufs --> <value>HfsPlus</value>
<default param="16">220,205,175</default> <!-- unformatted --> <value>Ufs</value>
<default param="17">173,205,255</default> <!-- btrfs --> <value>Unformatted</value>
<default param="18">176,155,185</default> <!-- hpfs --> <value>Btrfs</value>
<default param="19">170,30,77</default> <!-- luks --> <value>Hpfs</value>
<default param="20">96,140,85</default> <!-- ocfs2 --> <value>Luks</value>
<default param="21">33,137,108</default> <!-- zfs --> <value>Ocfs2</value>
<default param="22">250,230,255</default> <!-- exfat --> <value>Zfs</value>
<default param="23">242,155,104</default> <!-- nilfs2 --> <value>Exfat</value>
<default param="24">160,210,180</default> <!-- lvm2 pv --> <value>Nilfs2</value>
<default param="25">255,170,0</default> <!-- f2fs --> <value>Lvm2_PV</value>
<default param="26">170,120,255</default> <!-- udf --> <value>F2fs</value>
<default param="27">177,82,69</default> <!-- iso9660 --> <value>Udf</value>
<default param="28">223,39,104</default> <!-- luks2 --> <value>Iso9660</value>
<default param="29">204,179,255</default> <!-- fat12 --> <value>Luks2</value>
<value>Fat12</value>
<value>LinuxRaidMember</value>
</values>
</parameter>
<default param="Unknown">220,205,175</default>
<default param="Extended">187,249,207</default>
<default param="Ext2">102,121,150</default>
<default param="Ext3">122,145,180</default>
<default param="Ext4">143,170,210</default>
<default param="LinuxSwap">155,155,130</default>
<default param="Fat16">204,179,215</default>
<default param="Fat32">229,201,240</default>
<default param="Ntfs">244,214,255</default>
<default param="ReiserFS">216,220,135</default>
<default param="Reiser4">251,255,157</default>
<default param="Xfs">200,255,254</default>
<default param="Jfs">137,200,198</default>
<default param="Hfs">210,136,142</default>
<default param="HfsPlus">240,165,171</default>
<default param="Ufs">151,220,134</default>
<default param="Unformatted">220,205,175</default>
<default param="Btrfs">173,205,255</default>
<default param="Hpfs">176,155,185</default>
<default param="Luks">170,30,77</default>
<default param="Ocfs2">96,140,85</default>
<default param="Zfs">33,137,108</default>
<default param="Exfat">250,230,255</default>
<default param="Nilfs2">242,155,104</default>
<default param="Lvm2_PV">160,210,180</default>
<default param="F2fs">255,170,0</default>
<default param="Udf">170,120,255</default>
<default param="Iso9660">177,82,69</default>
<default param="Luks2">223,39,104</default>
<default param="Fat12">204,179,255</default>
<default param="LinuxRaidMember">255,100,100</default>
</entry> </entry>
<entry key="showMenuBar" type="Bool"> <entry key="showMenuBar" type="Bool">
<label context="@label">Show the application's menu bar</label> <label context="@label">Show the application's menu bar</label>
@ -101,7 +132,7 @@
<label context="@label">Backend plugin</label> <label context="@label">Backend plugin</label>
</entry> </entry>
<entry key="defaultFileSystem" type="Int"> <entry key="defaultFileSystem" type="Int">
<default>FileSystem::Ext4</default> <default>static_cast&lt;int&gt;(FileSystem::Type::Ext4)</default>
</entry> </entry>
<entry key="preferredUnit" type="Int"> <entry key="preferredUnit" type="Int">
<label context="@label">Preferred unit:</label> <label context="@label">Preferred unit:</label>

View File

@ -45,90 +45,13 @@ QIcon createFileSystemColor(FileSystem::Type type, quint32 size)
QPixmap pixmap(size, size); QPixmap pixmap(size, size);
QPainter painter(&pixmap); QPainter painter(&pixmap);
painter.setPen(QColor(0, 0, 0)); painter.setPen(QColor(0, 0, 0));
painter.setBrush(Config::fileSystemColorCode(type)); painter.setBrush(Config::fileSystemColorCode(static_cast<int>(type)));
painter.drawRect(QRect(0, 0, pixmap.width() - 1, pixmap.height() - 1)); painter.drawRect(QRect(0, 0, pixmap.width() - 1, pixmap.height() - 1));
painter.end(); painter.end();
return QIcon(pixmap); 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",
"<para><warning>You do not have administrative privileges.</warning></para>"
"<para>It is possible to run <application>%1</application> without these privileges. "
"You will, however, <emphasis>not</emphasis> be allowed to apply operations.</para>"
"<para>Do you want to continue running <application>%1</application>?</para>"
"<para><note>If administrator login is disabled and your password is "
"not accepted, then check <command>kdesu</command> "
"<link url='https://wiki.archlinux.org/index.php/sudo#kdesu'>configuration</link>.</note></para>",
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() bool loadBackend()
{ {
if (CoreBackendManager::self()->load(Config::backend()) == false) { if (CoreBackendManager::self()->load(Config::backend()) == false) {
@ -153,21 +76,6 @@ bool loadBackend()
return true; 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() Capacity::Unit preferredUnit()
{ {
return static_cast<Capacity::Unit>(Config::preferredUnit()); return static_cast<Capacity::Unit>(Config::preferredUnit());
@ -208,12 +116,13 @@ FileSystem::Type defaultFileSystem()
return static_cast<FileSystem::Type>(Config::defaultFileSystem()); return static_cast<FileSystem::Type>(Config::defaultFileSystem());
} }
std::array< QColor, FileSystem::__lastType > fileSystemColorCodesFromSettings() std::vector<QColor> fileSystemColorCodesFromSettings()
{ {
std::array< QColor, FileSystem::__lastType > cc; std::vector<QColor> cc;
for (int i = 0; i < FileSystem::__lastType; ++i) cc.resize(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; return cc;
} }

View File

@ -16,19 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.* * along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/ *************************************************************************/
#if !defined(GUIHELPERS_H) #ifndef GUIHELPERS_H
#define GUIHELPERS_H #define GUIHELPERS_H
#include <fs/filesystem.h> #include <fs/filesystem.h>
#include <util/capacity.h> #include <util/capacity.h>
#include <vector>
class QIcon; class QIcon;
class QPoint; class QPoint;
class QString; class QString;
class QTreeWidget; class QTreeWidget;
bool checkPermissions();
bool loadBackend(); bool loadBackend();
QIcon createFileSystemColor(FileSystem::Type type, quint32 size); QIcon createFileSystemColor(FileSystem::Type type, quint32 size);
Capacity::Unit preferredUnit(); Capacity::Unit preferredUnit();
@ -36,9 +36,7 @@ void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree);
namespace GuiHelpers namespace GuiHelpers
{ {
FileSystem::Type defaultFileSystem(); FileSystem::Type defaultFileSystem();
std::array< QColor, FileSystem::__lastType > fileSystemColorCodesFromSettings(); std::vector<QColor> fileSystemColorCodesFromSettings();
} }
QString suCommand();
#endif #endif