diff --git a/CMakeLists.txt b/CMakeLists.txt index e2877f8..f380e35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,13 +17,12 @@ project(partitionmanager) -cmake_minimum_required(VERSION 2.6.2) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") +cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) set(CMAKE_USE_RELATIVE_PATHS OFF) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) +set(QT_MIN_VERSION "5.3.0") set(VERSION_MAJOR "1") set(VERSION_MINOR "0") set(VERSION_RELEASE "60") @@ -31,26 +30,59 @@ set(VERSION_SUFFIX "") set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE}${VERSION_SUFFIX}) add_definitions(-D'VERSION="${VERSION}"') -set(KDE_MIN_VERSION 4.4) -find_package(KDE4 REQUIRED) +find_package(ECM 0.0.10 REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") +include(ECMInstallIcons) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings) +include(FeatureSummary) +include(GenerateExportHeader) + +find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS + Core + DBus + Widgets + Sql + Test +) + +# Load the frameworks we need +find_package(KF5 CONFIG REQUIRED COMPONENTS + Config + DocTools + FrameworkIntegration + GuiAddons + I18n + IconThemes + Init + JobWidgets + KIO + Service + Parts + TextEditor + WindowSystem + XmlGui + WidgetsAddons +) + +# use sane compile flags +add_definitions( + -fexceptions +) find_package(MSGFMT REQUIRED) find_package(PkgConfig REQUIRED) pkg_check_modules(BLKID REQUIRED blkid) pkg_check_modules(LIBATASMART REQUIRED libatasmart) -add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) -add_definitions(${KDE4_ENABLE_EXCEPTIONS}) - -include(KDE4Defaults) -include(MacroLibrary) - option(ENABLE_UDISKS2 "Use UDisks2 backend." OFF) if (ENABLE_UDISKS2) add_definitions(-DENABLE_UDISKS2) endif (ENABLE_UDISKS2) -include_directories(${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ${UUID_INCLUDE_DIRS} ${BLKID_INCLUDE_DIRS} lib/ src/) +include_directories(${Qt5Core_INCLUDE_DIRS} ${UUID_INCLUDE_DIRS} ${BLKID_INCLUDE_DIRS} lib/ src/) add_subdirectory(lib) add_subdirectory(src) diff --git a/cmake/modules/FindLIBPARTED.cmake b/cmake/modules/FindLIBPARTED.cmake index b47e8fb..97e7d97 100644 --- a/cmake/modules/FindLIBPARTED.cmake +++ b/cmake/modules/FindLIBPARTED.cmake @@ -21,7 +21,8 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -INCLUDE(CheckCSourceCompiles) +include(CheckCSourceCompiles) +include(CheckFunctionExists) if (LIBPARTED_INCLUDE_DIR AND LIBPARTED_LIBRARY) # Already in cache, be silent diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt index 02e3c9e..6ad3aa2 100644 --- a/icons/CMakeLists.txt +++ b/icons/CMakeLists.txt @@ -1 +1,10 @@ -kde4_install_icons(${ICON_INSTALL_DIR}) +# collect the needed icon files +set (PARTITIONMANAGER_ICONS + hi16-apps-partitionmanager.png + hi22-apps-partitionmanager.png + hi32-apps-partitionmanager.png + hi48-apps-partitionmanager.png + hi64-apps-partitionmanager.png + hi128-apps-partitionmanager.png +) +ecm_install_icons(ICONS ${PARTITIONMANAGER_ICONS} DESTINATION ${ICON_INSTALL_DIR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e565dd0..84286a2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,13 +30,26 @@ file(GLOB partitionmanagerprivate_SRCS file(GLOB partitionmanagerprivate_UIFILES config/*.ui gui/*.ui) -kde4_add_ui_files(partitionmanagerprivate_SRCS ${partitionmanagerprivate_UIFILES}) +qt5_wrap_ui(partitionmanagerprivate_SRCS ${partitionmanagerprivate_UIFILES}) -kde4_add_kcfg_files(partitionmanagerprivate_SRCS config.kcfgc) +kconfig_add_kcfg_files(partitionmanagerprivate_SRCS config.kcfgc) +install(FILES config.kcfg DESTINATION ${KCFG_INSTALL_DIR}) -kde4_add_library(partitionmanagerprivate SHARED ${partitionmanagerprivate_SRCS}) -target_link_libraries(partitionmanagerprivate libfatlabel ${KDE4_KDECORE_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${UUID_LIBRARIES} ${BLKID_LIBRARIES} ${LIBATASMART_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS}) +add_library(partitionmanagerprivate SHARED ${partitionmanagerprivate_SRCS}) +generate_export_header(partitionmanagerprivate EXPORT_FILE_NAME libpartitionmanager_export.h) +target_link_libraries( partitionmanagerprivate libfatlabel + ${UUID_LIBRARIES} ${BLKID_LIBRARIES} ${LIBATASMART_LIBRARIES} + KF5::I18n + KF5::IconThemes + KF5::JobWidgets + KF5::KIOCore + KF5::KIOWidgets + KF5::Service + KF5::Solid + KF5::XmlGui + KF5::WidgetsAddons +) install(TARGETS partitionmanagerprivate ${INSTALL_TARGETS_DEFAULT_ARGS}) @@ -44,11 +57,9 @@ install(TARGETS partitionmanagerprivate ${INSTALL_TARGETS_DEFAULT_ARGS}) file(GLOB partitionmanager_SRCS main.cpp) -kde4_add_app_icon(partitionmanager_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../icons/hi*-apps-partitionmanager.png") +add_executable(partitionmanager ${partitionmanager_SRCS}) -kde4_add_executable(partitionmanager ${partitionmanager_SRCS}) - -target_link_libraries(partitionmanager partitionmanagerprivate ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS}) +target_link_libraries(partitionmanager partitionmanagerprivate) install(TARGETS partitionmanager ${INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES gui/partitionmanagerui.rc DESTINATION ${DATA_INSTALL_DIR}/partitionmanager) diff --git a/src/backend/corebackenddevice.h b/src/backend/corebackenddevice.h index bc08df1..3043446 100644 --- a/src/backend/corebackenddevice.h +++ b/src/backend/corebackenddevice.h @@ -24,7 +24,6 @@ #include "util/libpartitionmanagerexport.h" #include -#include class CoreBackendPartition; class CoreBackendPartitionTable; diff --git a/src/backend/corebackendmanager.cpp b/src/backend/corebackendmanager.cpp index e5be0b4..509cfb3 100644 --- a/src/backend/corebackendmanager.cpp +++ b/src/backend/corebackendmanager.cpp @@ -24,12 +24,10 @@ #include #include -#include -#include +#include #include -#include -#include -#include +#include +#include #include @@ -65,8 +63,9 @@ bool CoreBackendManager::load(const QString& name) if (factory != NULL) { m_Backend = factory->create(NULL); - backend()->setAboutData(factory->componentData().aboutData()); - qDebug() << "Loaded backend plugin: " << backend()->about().programName() << ", " << backend()->about().version(); +// FIXME: port KF5 +// backend()->setAboutData(factory->componentData().aboutData()); +// qDebug() << "Loaded backend plugin: " << backend()->about().displayName() << ", " << backend()->about().version(); return true; } diff --git a/src/backend/corebackendmanager.h b/src/backend/corebackendmanager.h index 133b861..f5c9bfe 100644 --- a/src/backend/corebackendmanager.h +++ b/src/backend/corebackendmanager.h @@ -23,7 +23,7 @@ #include "util/libpartitionmanagerexport.h" -#include +#include class QString; class QStringList; diff --git a/src/backend/corebackendpartitiontable.h b/src/backend/corebackendpartitiontable.h index c1cf5c6..1f6df5c 100644 --- a/src/backend/corebackendpartitiontable.h +++ b/src/backend/corebackendpartitiontable.h @@ -20,6 +20,7 @@ #if !defined(COREBACKENDPARTITIONTABLE__H) #define COREBACKENDPARTITIONTABLE__H +#include "libpartitionmanager_export.h" #include "util/libpartitionmanagerexport.h" diff --git a/src/config/configureoptionsdialog.cpp b/src/config/configureoptionsdialog.cpp index 4c7da78..ff68382 100644 --- a/src/config/configureoptionsdialog.cpp +++ b/src/config/configureoptionsdialog.cpp @@ -33,11 +33,9 @@ #include "ui_configurepagefilesystemcolors.h" -#include -#include -#include -#include +#include #include +#include #include @@ -55,31 +53,32 @@ ConfigureOptionsDialog::ConfigureOptionsDialog(QWidget* parent, const OperationS KPageWidgetItem* item = NULL; item = addPage(&generalPageWidget(), i18nc("@title:tab general application settings", "General"), QString(), i18n("General Settings")); - item->setIcon(KIcon(DesktopIcon("partitionmanager"))); + item->setIcon(KIconLoader().loadIcon(QLatin1String("partitionmanager"), KIconLoader::Desktop)); connect(&generalPageWidget().comboDefaultFileSystem(), SIGNAL(activated(int)), SLOT(onComboDefaultFileSystemActivated(int))); item = addPage(&fileSystemColorsPageWidget(), i18nc("@title:tab", "File System Colors"), QString(), i18n("File System Color Settings")); - item->setIcon(KIcon(DesktopIcon("format-fill-color"))); + item->setIcon(KIconLoader().loadIcon(QLatin1String("format-fill-color"), KIconLoader::Desktop)); - if (KCmdLineArgs::parsedArgs()->isSet("advconfig")) + if (QCoreApplication::arguments().contains(QLatin1String("--advconfig"))) { item = addPage(&advancedPageWidget(), i18nc("@title:tab advanced application settings", "Advanced"), QString(), i18n("Advanced Settings")); - item->setIcon(KIcon(DesktopIcon("configure"))); + item->setIcon(KIconLoader().loadIcon(QLatin1String("configure"), KIconLoader::Desktop)); connect(&advancedPageWidget().comboBackend(), SIGNAL(activated(int)), SLOT(onComboBackendActivated(int))); } else advancedPageWidget().setVisible(false); - restoreDialogSize(KConfigGroup(KGlobal::config(), "configureOptionsDialog")); + KConfigGroup kcg(KSharedConfig::openConfig(), "configureOptionsDialogs"); + restoreGeometry(kcg.readEntry("Geometry", QByteArray())); } /** Destroys a ConfigureOptionsDialog instance */ ConfigureOptionsDialog::~ConfigureOptionsDialog() { - KConfigGroup kcg(KGlobal::config(), "configureOptionsDialog"); - saveDialogSize(kcg); + KConfigGroup kcg(KSharedConfig::openConfig(), "configureOptionsDialog"); + kcg.writeEntry("Geometry", saveGeometry()); } void ConfigureOptionsDialog::updateSettings() @@ -150,7 +149,7 @@ void ConfigureOptionsDialog::onComboBackendActivated(int) Q_ASSERT(advancedPageWidget().isVisible()); if (operationStack().size() == 0 || KMessageBox::warningContinueCancel(this, - i18nc("@info", + xi18nc("@info", "Do you really want to change the backend?" "This will also rescan devices and thus clear the list of pending operations."), i18nc("@title:window", "Really Change Backend?"), diff --git a/src/config/configureoptionsdialog.h b/src/config/configureoptionsdialog.h index 5d13f76..5a4a72f 100644 --- a/src/config/configureoptionsdialog.h +++ b/src/config/configureoptionsdialog.h @@ -21,7 +21,7 @@ #define CONFIGUREOPTIONSDIALOG__H -#include +#include class GeneralPageWidget; class FileSystemColorsPageWidget; diff --git a/src/config/configurepagegeneral.ui b/src/config/configurepagegeneral.ui index 11eb720..2e8fbf8 100644 --- a/src/config/configurepagegeneral.ui +++ b/src/config/configurepagegeneral.ui @@ -156,7 +156,7 @@ - + 0 diff --git a/src/core/partition.cpp b/src/core/partition.cpp index 8d55e50..c28ec4e 100644 --- a/src/core/partition.cpp +++ b/src/core/partition.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include /** Creates a new Partition object. @param parent the Partition's parent. May be another Partition (for logicals) or a PartitionTable. Must not be NULL. diff --git a/src/core/partitionalignment.cpp b/src/core/partitionalignment.cpp index ba7f321..4165e15 100644 --- a/src/core/partitionalignment.cpp +++ b/src/core/partitionalignment.cpp @@ -85,10 +85,10 @@ bool PartitionAlignment::isAligned(const Device& d, const Partition& p, bool qui bool PartitionAlignment::isAligned(const Device& d, const Partition& p, qint64 newFirst, qint64 newLast, bool quiet) { if (firstDelta(d, p, newFirst) && !quiet) - Log(Log::warning) << i18nc("@info/plain", "Partition %1 is not properly aligned (first sector: %2, modulo: %3).", p.deviceNode(), newFirst, firstDelta(d, p, newFirst)); + Log(Log::warning) << xi18nc("@info/plain", "Partition %1 is not properly aligned (first sector: %2, modulo: %3).", p.deviceNode(), newFirst, firstDelta(d, p, newFirst)); if (lastDelta(d, p, newLast) && !quiet) - Log(Log::warning) << i18nc("@info/plain", "Partition %1 is not properly aligned (last sector: %2, modulo: %3).", p.deviceNode(), newLast, lastDelta(d, p, newLast)); + Log(Log::warning) << xi18nc("@info/plain", "Partition %1 is not properly aligned (last sector: %2, modulo: %3).", p.deviceNode(), newLast, lastDelta(d, p, newLast)); return firstDelta(d, p, newFirst) == 0 && lastDelta(d, p, newLast) == 0; } diff --git a/src/core/partitiontable.cpp b/src/core/partitiontable.cpp index 72e5a69..12ba334 100644 --- a/src/core/partitiontable.cpp +++ b/src/core/partitiontable.cpp @@ -31,7 +31,6 @@ #include "util/globallog.h" #include -#include #include #include @@ -401,7 +400,7 @@ QString PartitionTable::tableTypeToName(TableType l) if (l == tableTypes[i].type) return tableTypes[i].name; - return i18nc("@item/plain partition table name", "unknown"); + return i18nc("@item partition table name", "unknown"); } qint64 PartitionTable::maxPrimariesForTableType(TableType l) diff --git a/src/core/smartattribute.cpp b/src/core/smartattribute.cpp index ee2c41d..783cde7 100644 --- a/src/core/smartattribute.cpp +++ b/src/core/smartattribute.cpp @@ -22,8 +22,8 @@ #include -#include -#include +#include +#include #include @@ -77,7 +77,7 @@ static QString getPrettyValue(qint64 value, qint64 unit) switch (unit) { case SK_SMART_ATTRIBUTE_UNIT_MSECONDS: - rval = KGlobal::locale()->formatDuration(value); + rval = KFormat().formatDuration(value); break; case SK_SMART_ATTRIBUTE_UNIT_SECTORS: diff --git a/src/core/smartstatus.cpp b/src/core/smartstatus.cpp index 384b0d0..ff2d39f 100644 --- a/src/core/smartstatus.cpp +++ b/src/core/smartstatus.cpp @@ -21,7 +21,6 @@ #include "core/smartattribute.h" #include -#include #include #include diff --git a/src/fs/btrfs.cpp b/src/fs/btrfs.cpp index d0c6fa7..48fbf9c 100644 --- a/src/fs/btrfs.cpp +++ b/src/fs/btrfs.cpp @@ -25,9 +25,9 @@ #include #include +#include #include -#include namespace FS { @@ -134,33 +134,33 @@ namespace FS bool btrfs::resize(Report& report, const QString& deviceNode, qint64 length) const { - KTempDir tempDir; - if (!tempDir.exists()) + QTemporaryDir tempDir; + if (!tempDir.isValid()) { - report.line() << i18nc("@info/plain", "Resizing Btrfs file system on partition %1 failed: Could not create temp dir.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing Btrfs file system on partition %1 failed: Could not create temp dir.", deviceNode); return false; } bool rval = false; - ExternalCommand mountCmd(report, "mount", QStringList() << "-v" << "-t" << "btrfs" << deviceNode << tempDir.name()); + ExternalCommand mountCmd(report, "mount", QStringList() << "-v" << "-t" << "btrfs" << deviceNode << tempDir.path()); if (mountCmd.run(-1) && mountCmd.exitCode() == 0) { - ExternalCommand resizeCmd(report, "btrfs", QStringList() << "filesystem" << "resize" << QString::number(length) << tempDir.name()); - + ExternalCommand resizeCmd(report, "btrfs", QStringList() << "filesystem" << "resize" << QString::number(length) << tempDir.path()); + if (resizeCmd.run(-1) && resizeCmd.exitCode() == 0) rval = true; else - report.line() << i18nc("@info/plain", "Resizing Btrfs file system on partition %1 failed: btrfs file system resize failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing Btrfs file system on partition %1 failed: btrfs file system resize failed.", deviceNode); - ExternalCommand unmountCmd(report, "umount", QStringList() << tempDir.name()); + ExternalCommand unmountCmd(report, "umount", QStringList() << tempDir.path()); if (!unmountCmd.run(-1) && unmountCmd.exitCode() == 0 ) - report.line() << i18nc("@info/plain", "Warning: Resizing Btrfs file system on partition %1: Unmount failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Warning: Resizing Btrfs file system on partition %1: Unmount failed.", deviceNode); } else - report.line() << i18nc("@info/plain", "Resizing Btrfs file system on partition %1 failed: Initial mount failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing Btrfs file system on partition %1 failed: Initial mount failed.", deviceNode); return rval; } diff --git a/src/fs/fat16.cpp b/src/fs/fat16.cpp index 6d1bca4..f80d667 100644 --- a/src/fs/fat16.cpp +++ b/src/fs/fat16.cpp @@ -133,7 +133,7 @@ namespace FS bool fat16::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) { - report.line() << i18nc("@info/plain", "Setting label for partition %1 to %2", deviceNode, newLabel); + report.line() << xi18nc("@info/plain", "Setting label for partition %1 to %2", deviceNode, newLabel); return fatlabel_set_label(deviceNode.toLocal8Bit(), newLabel.toLocal8Bit()) == 0; } diff --git a/src/fs/filesystem.h b/src/fs/filesystem.h index 274ee87..927080c 100644 --- a/src/fs/filesystem.h +++ b/src/fs/filesystem.h @@ -21,8 +21,6 @@ #define FILESYSTEM__H -#include - #include #include #include @@ -50,7 +48,7 @@ class FileSystem explicit SupportTool(const QString& n = QString(), const QUrl& u = QUrl()) : name(n), url(u) {} const QString name; - const KUrl url; + const QUrl url; }; /** Supported FileSystem types */ diff --git a/src/fs/jfs.cpp b/src/fs/jfs.cpp index 0f446ef..4b1b1aa 100644 --- a/src/fs/jfs.cpp +++ b/src/fs/jfs.cpp @@ -25,9 +25,9 @@ #include #include +#include #include -#include #include @@ -156,33 +156,33 @@ namespace FS bool jfs::resize(Report& report, const QString& deviceNode, qint64) const { - KTempDir tempDir; - if (!tempDir.exists()) + QTemporaryDir tempDir; + if (!tempDir.isValid()) { - report.line() << i18nc("@info/plain", "Resizing JFS file system on partition %1 failed: Could not create temp dir.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing JFS file system on partition %1 failed: Could not create temp dir.", deviceNode); return false; } bool rval = false; - ExternalCommand mountCmd(report, "mount", QStringList() << "-v" << "-t" << "jfs" << deviceNode << tempDir.name()); + ExternalCommand mountCmd(report, "mount", QStringList() << "-v" << "-t" << "jfs" << deviceNode << tempDir.path()); if (mountCmd.run(-1)) { - ExternalCommand resizeMountCmd(report, "mount", QStringList() << "-v" << "-t" << "jfs" << "-o" << "remount,resize" << deviceNode << tempDir.name()); + ExternalCommand resizeMountCmd(report, "mount", QStringList() << "-v" << "-t" << "jfs" << "-o" << "remount,resize" << deviceNode << tempDir.path()); if (resizeMountCmd.run(-1)) rval = true; else - report.line() << i18nc("@info/plain", "Resizing JFS file system on partition %1 failed: Remount failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing JFS file system on partition %1 failed: Remount failed.", deviceNode); - ExternalCommand unmountCmd(report, "umount", QStringList() << tempDir.name()); + ExternalCommand unmountCmd(report, "umount", QStringList() << tempDir.path()); if (!unmountCmd.run(-1)) - report.line() << i18nc("@info/plain", "Warning: Resizing JFS file system on partition %1: Unmount failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Warning: Resizing JFS file system on partition %1: Unmount failed.", deviceNode); } else - report.line() << i18nc("@info/plain", "Resizing JFS file system on partition %1 failed: Initial mount failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing JFS file system on partition %1 failed: Initial mount failed.", deviceNode); return rval; } diff --git a/src/fs/luks.cpp b/src/fs/luks.cpp index c065ffe..50f690b 100644 --- a/src/fs/luks.cpp +++ b/src/fs/luks.cpp @@ -139,7 +139,7 @@ namespace FS { QUuid uuid = QUuid::createUuid(); - ExternalCommand cmd(report, "cryptsetup", QStringList() << "luksUUID" << deviceNode << "--uuid" << uuid); + ExternalCommand cmd(report, "cryptsetup", QStringList() << "luksUUID" << deviceNode << "--uuid" << uuid.toString()); return cmd.run(-1) && cmd.exitCode() == 0; } diff --git a/src/fs/nilfs2.cpp b/src/fs/nilfs2.cpp index 4862b44..274ef07 100644 --- a/src/fs/nilfs2.cpp +++ b/src/fs/nilfs2.cpp @@ -24,11 +24,12 @@ #include "util/report.h" #include + #include +#include #include #include -#include namespace FS { @@ -138,33 +139,33 @@ namespace FS bool nilfs2::resize(Report& report, const QString& deviceNode, qint64 length) const { - KTempDir tempDir; - if (!tempDir.exists()) + QTemporaryDir tempDir; + if (!tempDir.isValid()) { - report.line() << i18nc("@info/plain", "Resizing NILFS2 file system on partition %1 failed: Could not create temp dir.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing NILFS2 file system on partition %1 failed: Could not create temp dir.", deviceNode); return false; } bool rval = false; - ExternalCommand mountCmd(report, "mount", QStringList() << "-v" << "-t" << "nilfs2" << deviceNode << tempDir.name()); + ExternalCommand mountCmd(report, "mount", QStringList() << "-v" << "-t" << "nilfs2" << deviceNode << tempDir.path()); if (mountCmd.run(-1) && mountCmd.exitCode() == 0) { ExternalCommand resizeCmd(report, "nilfs-resize", QStringList() << "-v" << "-y" << deviceNode << QString::number(length)); - + if (resizeCmd.run(-1) && resizeCmd.exitCode() == 0) rval = true; else - report.line() << i18nc("@info/plain", "Resizing NILFS2 file system on partition %1 failed: NILFS2 file system resize failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing NILFS2 file system on partition %1 failed: NILFS2 file system resize failed.", deviceNode); - ExternalCommand unmountCmd(report, "umount", QStringList() << tempDir.name()); + ExternalCommand unmountCmd(report, "umount", QStringList() << tempDir.path()); if (!unmountCmd.run(-1) && unmountCmd.exitCode() == 0 ) - report.line() << i18nc("@info/plain", "Warning: Resizing NILFS2 file system on partition %1: Unmount failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Warning: Resizing NILFS2 file system on partition %1: Unmount failed.", deviceNode); } else - report.line() << i18nc("@info/plain", "Resizing NILFS2 file system on partition %1 failed: Initial mount failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing NILFS2 file system on partition %1 failed: Initial mount failed.", deviceNode); return rval; } @@ -178,7 +179,7 @@ namespace FS bool nilfs2::updateUUID(Report& report, const QString& deviceNode) const { QUuid uuid = QUuid::createUuid(); - ExternalCommand cmd(report, "nilfs-tune", QStringList() << "-U" << uuid << deviceNode); + ExternalCommand cmd(report, "nilfs-tune", QStringList() << "-U" << uuid.toString() << deviceNode); return cmd.run(-1) && cmd.exitCode() == 0; } } diff --git a/src/fs/ntfs.cpp b/src/fs/ntfs.cpp index 8457b98..ca258a6 100644 --- a/src/fs/ntfs.cpp +++ b/src/fs/ntfs.cpp @@ -194,7 +194,7 @@ namespace FS bool ntfs::updateBootSector(Report& report, const QString& deviceNode) const { - report.line() << i18nc("@info/plain", "Updating boot sector for NTFS file system on partition %1.", deviceNode); + report.line() << xi18nc("@info/plain", "Updating boot sector for NTFS file system on partition %1.", deviceNode); quint32 n = firstSector(); char* s = reinterpret_cast(&n); @@ -207,23 +207,23 @@ namespace FS QFile device(deviceNode); if (!device.open(QFile::ReadWrite | QFile::Unbuffered)) { - Log() << i18nc("@info/plain", "Could not open partition %1 for writing when trying to update the NTFS boot sector.", deviceNode); + Log() << xi18nc("@info/plain", "Could not open partition %1 for writing when trying to update the NTFS boot sector.", deviceNode); return false; } if (!device.seek(0x1c)) { - Log() << i18nc("@info/plain", "Could not seek to position 0x1c on partition %1 when trying to update the NTFS boot sector.", deviceNode); + Log() << xi18nc("@info/plain", "Could not seek to position 0x1c on partition %1 when trying to update the NTFS boot sector.", deviceNode); return false; } if (device.write(s, 4) != 4) { - Log() << i18nc("@info/plain", "Could not write new start sector to partition %1 when trying to update the NTFS boot sector.", deviceNode); + Log() << xi18nc("@info/plain", "Could not write new start sector to partition %1 when trying to update the NTFS boot sector.", deviceNode); return false; } - Log() << i18nc("@info/plain", "Updated NTFS boot sector for partition %1 successfully.", deviceNode); + Log() << xi18nc("@info/plain", "Updated NTFS boot sector for partition %1 successfully.", deviceNode); return true; } diff --git a/src/fs/xfs.cpp b/src/fs/xfs.cpp index edae343..6301fcb 100644 --- a/src/fs/xfs.cpp +++ b/src/fs/xfs.cpp @@ -26,8 +26,8 @@ #include #include #include +#include -#include #include #include @@ -163,33 +163,33 @@ namespace FS bool xfs::resize(Report& report, const QString& deviceNode, qint64) const { - KTempDir tempDir; - if (!tempDir.exists()) + QTemporaryDir tempDir; + if (!tempDir.isValid()) { - report.line() << i18nc("@info/plain", "Resizing XFS file system on partition %1 failed: Could not create temp dir.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing XFS file system on partition %1 failed: Could not create temp dir.", deviceNode); return false; } bool rval = false; - ExternalCommand mountCmd(report, "mount", QStringList() << "-v" << "-t" << "xfs" << deviceNode << tempDir.name()); + ExternalCommand mountCmd(report, "mount", QStringList() << "-v" << "-t" << "xfs" << deviceNode << tempDir.path()); if (mountCmd.run(-1)) { - ExternalCommand resizeCmd(report, "xfs_growfs", QStringList() << tempDir.name()); + ExternalCommand resizeCmd(report, "xfs_growfs", QStringList() << tempDir.path()); if (resizeCmd.run(-1)) rval = true; else - report.line() << i18nc("@info/plain", "Resizing XFS file system on partition %1 failed: xfs_growfs failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing XFS file system on partition %1 failed: xfs_growfs failed.", deviceNode); - ExternalCommand unmountCmd(report, "umount", QStringList() << tempDir.name()); + ExternalCommand unmountCmd(report, "umount", QStringList() << tempDir.path()); if (!unmountCmd.run(-1)) - report.line() << i18nc("@info/plain", "Warning: Resizing XFS file system on partition %1: Unmount failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Warning: Resizing XFS file system on partition %1: Unmount failed.", deviceNode); } else - report.line() << i18nc("@info/plain", "Resizing XFS file system on partition %1 failed: Initial mount failed.", deviceNode); + report.line() << xi18nc("@info/plain", "Resizing XFS file system on partition %1 failed: Initial mount failed.", deviceNode); return rval; } diff --git a/src/gui/applyprogressdialog.cpp b/src/gui/applyprogressdialog.cpp index 0f495f5..90085df 100644 --- a/src/gui/applyprogressdialog.cpp +++ b/src/gui/applyprogressdialog.cpp @@ -31,26 +31,25 @@ #include "util/report.h" #include "util/htmlreport.h" +#include #include #include #include -#include #include +#include +#include #include +#include #include -#include -#include +#include #include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include const QString ApplyProgressDialog::m_TimeFormat = "hh:mm:ss"; @@ -196,7 +195,7 @@ void ApplyProgressDialog::onCancelButton() if (operationRunner().isCancelling()) return; - KApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); cancelButton->setEnabled(false); setStatus(i18nc("@info:progress", "Waiting for operation to finish...")); @@ -208,7 +207,7 @@ void ApplyProgressDialog::onCancelButton() operationRunner().suspendMutex().lock(); cancelButton->setEnabled(true); - KApplication::restoreOverrideCursor(); + QApplication::restoreOverrideCursor(); if (KMessageBox::questionYesNo(this, i18nc("@info", "Do you really want to cancel?"), i18nc("@title:window", "Cancel Running Operations"), KGuiItem(i18nc("@action:button", "Yes, Cancel Operations"), "dialog-ok"), KStandardGuiItem::no()) == KMessageBox::Yes) // in the meantime while we were showing the messagebox, the runner might have finished. @@ -412,27 +411,28 @@ void ApplyProgressDialog::keyPressEvent(QKeyEvent* e) void ApplyProgressDialog::saveReport() { - const KUrl url = KFileDialog::getSaveUrl(KUrl("kfiledialog://saveReport")); + const QUrl url = QFileDialog::getSaveFileUrl(); if (url.isEmpty()) return; - KTemporaryFile tempFile; + QTemporaryFile tempFile; if (tempFile.open()) { QTextStream s(&tempFile); - + HtmlReport html; - + s << html.header() << report().toHtml() << html.footer(); tempFile.close(); - KIO::CopyJob* job = KIO::move(tempFile.fileName(), url, KIO::HideProgressInfo); - if (!KIO::NetAccess::synchronousRun(job, NULL)) + KIO::CopyJob* job = KIO::move(QUrl::fromLocalFile(tempFile.fileName()), url, KIO::HideProgressInfo); + job->exec(); + if ( job->error() ) job->ui()->showErrorMessage(); } else @@ -441,11 +441,11 @@ void ApplyProgressDialog::saveReport() void ApplyProgressDialog::browserReport() { - KTemporaryFile file; + QTemporaryFile file; // Make sure the temp file is created somewhere another user can read it: KRun::runUrl() will open // the file as the logged in user, not as the user running our application. - file.setFileTemplate("/tmp/" + KGlobal::mainComponent().aboutData()->appName() + "-XXXXXX.html"); + file.setFileTemplate("/tmp/" + QCoreApplication::applicationName() + "-XXXXXX.html"); file.setAutoRemove(false); if (file.open()) @@ -453,7 +453,7 @@ void ApplyProgressDialog::browserReport() QTextStream s(&file); HtmlReport html; - + s << html.header() << report().toHtml() << html.footer(); @@ -465,5 +465,5 @@ void ApplyProgressDialog::browserReport() KMessageBox::sorry(this, i18nc("@info", "The configured external browser could not be run. Please check your settings."), i18nc("@title:window", "Could Not Launch Browser.")); } else - KMessageBox::sorry(this, i18nc("@info", "Could not create temporary file %1 for writing.", file.fileName()), i18nc("@title:window", "Could Not Launch Browser.")); + KMessageBox::sorry(this, xi18nc("@info", "Could not create temporary file %1 for writing.", file.fileName()), i18nc("@title:window", "Could Not Launch Browser.")); } diff --git a/src/gui/createpartitiontabledialog.cpp b/src/gui/createpartitiontabledialog.cpp index dd58c7d..8c1f5e4 100644 --- a/src/gui/createpartitiontabledialog.cpp +++ b/src/gui/createpartitiontabledialog.cpp @@ -23,12 +23,12 @@ #include "core/device.h" #include "core/partitiontable.h" -#include -#include - #include #include +#include +#include + #include CreatePartitionTableDialog::CreatePartitionTableDialog(QWidget* parent, const Device& d) : @@ -39,7 +39,7 @@ CreatePartitionTableDialog::CreatePartitionTableDialog(QWidget* parent, const De QVBoxLayout *mainLayout = new QVBoxLayout(this); setLayout(mainLayout); mainLayout->addWidget(&widget()); - setWindowTitle(i18nc("@title:window", "Create a New Partition Table on %1", device().deviceNode())); + setWindowTitle(xi18nc("@title:window", "Create a New Partition Table on %1", device().deviceNode())); dialogButtonBox = new QDialogButtonBox; createButton = dialogButtonBox->addButton( QDialogButtonBox::Ok ); createButton->setText(i18n("Create &New Partition Table")); @@ -67,7 +67,7 @@ void CreatePartitionTableDialog::onMSDOSToggled(bool on) if (on && device().totalSectors() > 0xffffffff) { if (KMessageBox::warningContinueCancel(this, - i18nc("@info", + xi18nc("@info", "Do you really want to create an MS-Dos partition table on %1?" "This device has more than 2^32 sectors. That is the most the MS-Dos partition table type supports, so you will not be able to use the whole device.", device().deviceNode()), i18nc("@title:window", "Really Create MS-Dos Partition Table Type?"), diff --git a/src/gui/decryptluksdialog.cpp b/src/gui/decryptluksdialog.cpp index f7dcca0..ecdca70 100644 --- a/src/gui/decryptluksdialog.cpp +++ b/src/gui/decryptluksdialog.cpp @@ -38,7 +38,7 @@ DecryptLuksDialog::DecryptLuksDialog(QWidget* parent, const QString& deviceNode) QVBoxLayout *mainLayout = new QVBoxLayout(this); setLayout(mainLayout); mainLayout->addWidget(&widget()); - setWindowTitle(i18nc("@title:window", "Decrypt LUKS partition on %1", this->deviceNode())); + setWindowTitle(xi18nc("@title:window", "Decrypt LUKS partition on %1", this->deviceNode())); QDialogButtonBox* dialogButtonBox = new QDialogButtonBox; QPushButton* decryptButton = new QPushButton; diff --git a/src/gui/devicepropsdialog.cpp b/src/gui/devicepropsdialog.cpp index 9ff8e1a..4dc15fb 100644 --- a/src/gui/devicepropsdialog.cpp +++ b/src/gui/devicepropsdialog.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include @@ -51,7 +51,7 @@ DevicePropsDialog::DevicePropsDialog(QWidget* parent, Device& d) : mainLayout = new QVBoxLayout(this); setLayout(mainLayout); mainLayout->addWidget(&dialogWidget()); - setWindowTitle(i18nc("@title:window", "Device Properties: %1", device().deviceNode())); + setWindowTitle(xi18nc("@title:window", "Device Properties: %1", device().deviceNode())); setupDialog(); setupConnections(); @@ -126,12 +126,12 @@ void DevicePropsDialog::setupDialog() if (device().smartStatus().status()) { dialogWidget().smartStatusText().setText(i18nc("@label SMART disk status", "good")); - dialogWidget().smartStatusIcon().setPixmap(SmallIcon("dialog-ok")); + dialogWidget().smartStatusIcon().setPixmap(KIconLoader().loadIcon(QLatin1String("dialog-ok"), KIconLoader::Small)); } else { dialogWidget().smartStatusText().setText(i18nc("@label SMART disk status", "BAD")); - dialogWidget().smartStatusIcon().setPixmap(SmallIcon("dialog-warning")); + dialogWidget().smartStatusIcon().setPixmap(KIconLoader().loadIcon(QLatin1String("dialog-warning"), KIconLoader::Small)); } } else diff --git a/src/gui/editmountoptionsdialog.cpp b/src/gui/editmountoptionsdialog.cpp index ae670a2..0974396 100644 --- a/src/gui/editmountoptionsdialog.cpp +++ b/src/gui/editmountoptionsdialog.cpp @@ -25,6 +25,7 @@ #include #include +#include EditMountOptionsDialog::EditMountOptionsDialog(QWidget* parent, const QStringList& options) : QDialog(parent), diff --git a/src/gui/editmountpointdialog.cpp b/src/gui/editmountpointdialog.cpp index 07e9b5e..731b863 100644 --- a/src/gui/editmountpointdialog.cpp +++ b/src/gui/editmountpointdialog.cpp @@ -22,7 +22,9 @@ #include "core/partition.h" -#include +#include +#include +#include #include #include #include @@ -35,7 +37,7 @@ EditMountPointDialog::EditMountPointDialog(QWidget* parent, Partition& p) : QVBoxLayout *mainLayout = new QVBoxLayout(this); setLayout(mainLayout); mainLayout->addWidget(&widget()); - setWindowTitle(i18nc("@title:window", "Edit mount point for %1", p.deviceNode())); + setWindowTitle(xi18nc("@title:window", "Edit mount point for %1", p.deviceNode())); KConfigGroup kcg(KSharedConfig::openConfig(), "editMountPointDialog"); restoreGeometry(kcg.readEntry("Geometry", QByteArray())); @@ -51,7 +53,7 @@ EditMountPointDialog::~EditMountPointDialog() void EditMountPointDialog::accept() { if (KMessageBox::warningContinueCancel(this, - i18nc("@info", "Are you sure you want to save the changes you made to the system table file /etc/fstab?" + xi18nc("@info", "Are you sure you want to save the changes you made to the system table file /etc/fstab?" "This will overwrite the existing file on your hard drive now. This can not be undone."), i18nc("@title:window", "Really save changes?"), KGuiItem(i18nc("@action:button", "Save changes"), "arrow-right"), diff --git a/src/gui/editmountpointdialogwidget.cpp b/src/gui/editmountpointdialogwidget.cpp index e1622f6..97a96e5 100644 --- a/src/gui/editmountpointdialogwidget.cpp +++ b/src/gui/editmountpointdialogwidget.cpp @@ -26,14 +26,13 @@ #include "fs/filesystem.h" #include -#include -#include -#include -#include +#include +#include #include #include #include +#include #include #include @@ -145,7 +144,7 @@ void EditMountPointDialogWidget::setupOptions(const QStringList& options) void EditMountPointDialogWidget::on_m_ButtonSelect_clicked(bool) { - const QString s = KFileDialog::getExistingDirectory(KUrl(editPath().text()), this); + const QString s = QFileDialog::getExistingDirectory(this, editPath().text()); if (!s.isEmpty()) editPath().setText(s); } @@ -178,7 +177,7 @@ bool EditMountPointDialogWidget::readMountpoints(const QString& filename) if (fp == NULL) { KMessageBox::sorry(this, - i18nc("@info", "Could not open mount point file %1.", filename), + xi18nc("@info", "Could not open mount point file %1.", filename), i18nc("@title:window", "Error while reading mount points")); return false; } @@ -298,7 +297,7 @@ bool EditMountPointDialogWidget::writeMountpoints(const QString& filename) if (!rval) KMessageBox::sorry(this, - i18nc("@info", "Could not save mount points to file %1.", filename), + xi18nc("@info", "Could not save mount points to file %1.", filename), i18nc("@title:window", "Error While Saving Mount Points")); return rval; diff --git a/src/gui/filesystemsupportdialog.cpp b/src/gui/filesystemsupportdialog.cpp index 352fa88..ac0ae00 100644 --- a/src/gui/filesystemsupportdialog.cpp +++ b/src/gui/filesystemsupportdialog.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -66,8 +67,8 @@ QSize FileSystemSupportDialog::sizeHint() const void FileSystemSupportDialog::setupDialog() { - QPixmap yes(BarIcon("dialog-ok")); - QPixmap no(BarIcon("dialog-error")); + QIcon yes = QIcon(KIconLoader().loadIcon(QLatin1String("dialog-ok"), KIconLoader::Toolbar)); + QIcon no = QIcon(KIconLoader().loadIcon(QLatin1String("dialog-error"), KIconLoader::Toolbar)); dialogWidget().tree().clear(); diff --git a/src/gui/infopane.cpp b/src/gui/infopane.cpp index 09d4928..6530115 100644 --- a/src/gui/infopane.cpp +++ b/src/gui/infopane.cpp @@ -27,13 +27,13 @@ #include "util/capacity.h" +#include +#include +#include #include #include -#include -#include #include -#include #include /** Creates a new InfoPane instance @@ -77,7 +77,7 @@ int InfoPane::createHeader(const QString& title, const int num_cols) void InfoPane::createLabels(const QString& title, const QString& value, const int num_cols, int& x, int& y) { QLabel* labelTitle = new QLabel(title, this); - labelTitle->setFont(KGlobalSettings::smallestReadableFont()); + labelTitle->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); labelTitle->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); QPalette palette = labelTitle->palette(); @@ -90,7 +90,7 @@ void InfoPane::createLabels(const QString& title, const QString& value, const in QLabel* labelValue = new QLabel(value, this); labelValue->setTextInteractionFlags(Qt::TextBrowserInteraction); - labelValue->setFont(KGlobalSettings::smallestReadableFont()); + labelValue->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); gridLayout().addWidget(labelValue, y, x + 1, 1, 1); x += 2; diff --git a/src/gui/listdevices.cpp b/src/gui/listdevices.cpp index 1cf1a28..4775342 100644 --- a/src/gui/listdevices.cpp +++ b/src/gui/listdevices.cpp @@ -24,14 +24,13 @@ #include "util/globallog.h" #include "util/capacity.h" -#include -#include +#include class ListDeviceWidgetItem : public QListWidgetItem { public: ListDeviceWidgetItem(const Device& d) : - QListWidgetItem(DesktopIcon(d.iconName()), d.prettyName()), + QListWidgetItem(QIcon(KIconLoader().loadIcon(d.iconName(), KIconLoader::Desktop)), d.prettyName()), deviceNode(d.deviceNode()) { setToolTip(d.prettyName()); diff --git a/src/gui/listoperations.cpp b/src/gui/listoperations.cpp index 6efe4f3..9716374 100644 --- a/src/gui/listoperations.cpp +++ b/src/gui/listoperations.cpp @@ -24,8 +24,7 @@ #include "util/globallog.h" #include "util/capacity.h" -#include -#include +#include /** Creates a new ListOperations instance. @param parent the parent widget @@ -44,7 +43,7 @@ void ListOperations::updateOperations(const OperationStack::Operations& ops) foreach (const Operation* op, ops) { - QListWidgetItem* item = new QListWidgetItem(SmallIcon(op->iconName()), op->description()); + QListWidgetItem* item = new QListWidgetItem(QIcon(KIconLoader().loadIcon(op->iconName(), KIconLoader::Small)), op->description()); item->setToolTip(op->description()); listOperations().addItem(item); } diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 687a4bb..e8d64f0 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -50,33 +50,29 @@ #include "util/helpers.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include #include -#include -#include -#include #include +#include +#include #include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include @@ -140,10 +136,10 @@ void MainWindow::closeEvent(QCloseEvent* event) if (operationStack().size() > 0) { if (KMessageBox::warningContinueCancel(this, - i18ncp("@info", "Do you really want to quit the application?There is still an operation pending.", - "Do you really want to quit the application?There are still %1 operations pending.", operationStack().size()), + xi18ncp("@info", "Do you really want to quit the application?There is still an operation pending.", + "Do you really want to quit the application?There are still %1 operations pending.", operationStack().size()), i18nc("@title:window", "Discard Pending Operations and Quit?"), - KGuiItem(i18nc("@action:button", "Quit %1", KGlobal::mainComponent().aboutData()->programName()), "arrow-right"), + KGuiItem(xi18nc("@action:button", "Quit %1", QGuiApplication::applicationDisplayName()), "arrow-right"), KStandardGuiItem::cancel(), "reallyQuit") == KMessageBox::Cancel) { event->ignore(); @@ -190,21 +186,21 @@ void MainWindow::setupActions() undoOperation->setToolTip(i18nc("@info:tooltip", "Undo the last operation")); undoOperation->setStatusTip(i18nc("@info:status", "Remove the last operation from the list.")); undoOperation->setShortcut(Qt::CTRL | Qt::Key_Z); - undoOperation->setIcon(BarIcon("edit-undo")); + undoOperation->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("edit-undo"), KIconLoader::Toolbar))); QAction* clearAllOperations = actionCollection()->addAction("clearAllOperations", this, SLOT(onClearAllOperations())); clearAllOperations->setEnabled(false); clearAllOperations->setText(i18nc("@action:inmenu clear the list of operations", "Clear")); clearAllOperations->setToolTip(i18nc("@info:tooltip", "Clear all operations")); clearAllOperations->setStatusTip(i18nc("@info:status", "Empty the list of pending operations.")); - clearAllOperations->setIcon(BarIcon("dialog-cancel")); + clearAllOperations->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("dialog-cancel"), KIconLoader::Toolbar))); QAction* applyAllOperations = actionCollection()->addAction("applyAllOperations", this, SLOT(onApplyAllOperations())); applyAllOperations->setEnabled(false); applyAllOperations->setText(i18nc("@action:inmenu apply all operations", "Apply")); applyAllOperations->setToolTip(i18nc("@info:tooltip", "Apply all operations")); applyAllOperations->setStatusTip(i18nc("@info:status", "Apply the pending operations in the list.")); - applyAllOperations->setIcon(BarIcon("dialog-ok-apply")); + applyAllOperations->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("dialog-ok-apply"), KIconLoader::Toolbar))); // Device actions QAction* refreshDevices = actionCollection()->addAction("refreshDevices", this, SLOT(onRefreshDevices())); @@ -212,7 +208,7 @@ void MainWindow::setupActions() refreshDevices->setToolTip(i18nc("@info:tooltip", "Refresh all devices")); refreshDevices->setStatusTip(i18nc("@info:status", "Renew the devices list.")); refreshDevices->setShortcut(Qt::Key_F5); - refreshDevices->setIcon(BarIcon("view-refresh")); + refreshDevices->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("view-refresh"), KIconLoader::Toolbar))); QAction* createNewPartitionTable = actionCollection()->addAction("createNewPartitionTable", this, SLOT(onCreateNewPartitionTable())); createNewPartitionTable->setEnabled(false); @@ -220,21 +216,21 @@ void MainWindow::setupActions() createNewPartitionTable->setToolTip(i18nc("@info:tooltip", "Create a new partition table")); createNewPartitionTable->setStatusTip(i18nc("@info:status", "Create a new and empty partition table on a device.")); createNewPartitionTable->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_N); - createNewPartitionTable->setIcon(BarIcon("edit-clear")); + createNewPartitionTable->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("edit-clear"), KIconLoader::Toolbar))); QAction* exportPartitionTable = actionCollection()->addAction("exportPartitionTable", this, SLOT(onExportPartitionTable())); exportPartitionTable->setEnabled(false); exportPartitionTable->setText(i18nc("@action:inmenu", "Export Partition Table")); exportPartitionTable->setToolTip(i18nc("@info:tooltip", "Export a partition table")); exportPartitionTable->setStatusTip(i18nc("@info:status", "Export the device's partition table to a text file.")); - exportPartitionTable->setIcon(BarIcon("document-export")); + exportPartitionTable->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("document-export"), KIconLoader::Toolbar))); QAction* importPartitionTable = actionCollection()->addAction("importPartitionTable", this, SLOT(onImportPartitionTable())); importPartitionTable->setEnabled(false); importPartitionTable->setText(i18nc("@action:inmenu", "Import Partition Table")); importPartitionTable->setToolTip(i18nc("@info:tooltip", "Import a partition table")); importPartitionTable->setStatusTip(i18nc("@info:status", "Import a partition table from a text file.")); - importPartitionTable->setIcon(BarIcon("document-import")); + importPartitionTable->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("document-import"), KIconLoader::Toolbar))); QAction* smartStatusDevice = actionCollection()->addAction("smartStatusDevice", this, SLOT(onSmartStatusDevice())); smartStatusDevice->setEnabled(false); @@ -247,7 +243,7 @@ void MainWindow::setupActions() propertiesDevice->setText(i18nc("@action:inmenu", "Properties")); propertiesDevice->setToolTip(i18nc("@info:tooltip", "Show device properties dialog")); propertiesDevice->setStatusTip(i18nc("@info:status", "View and modify device properties")); - propertiesDevice->setIcon(BarIcon("document-properties")); + propertiesDevice->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("document-properties"), KIconLoader::Toolbar))); // Partition actions QAction* newPartition = actionCollection()->addAction("newPartition", &pmWidget(), SLOT(onNewPartition())); @@ -256,7 +252,7 @@ void MainWindow::setupActions() newPartition->setToolTip(i18nc("@info:tooltip", "New partition")); newPartition->setStatusTip(i18nc("@info:status", "Create a new partition.")); newPartition->setShortcut(Qt::CTRL | Qt::Key_N); - newPartition->setIcon(BarIcon("document-new")); + newPartition->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("document-new"), KIconLoader::Toolbar))); QAction* resizePartition = actionCollection()->addAction("resizePartition", &pmWidget(), SLOT(onResizePartition())); resizePartition->setEnabled(false); @@ -264,7 +260,7 @@ void MainWindow::setupActions() resizePartition->setToolTip(i18nc("@info:tooltip", "Resize or move partition")); resizePartition->setStatusTip(i18nc("@info:status", "Shrink, grow or move an existing partition.")); resizePartition->setShortcut(Qt::CTRL | Qt::Key_R); - resizePartition->setIcon(BarIcon("arrow-right-double")); + resizePartition->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("arrow-right-double"), KIconLoader::Toolbar))); QAction* deletePartition = actionCollection()->addAction("deletePartition", &pmWidget(), SLOT(onDeletePartition())); deletePartition->setEnabled(false); @@ -272,7 +268,7 @@ void MainWindow::setupActions() deletePartition->setToolTip(i18nc("@info:tooltip", "Delete partition")); deletePartition->setStatusTip(i18nc("@info:status", "Delete a partition.")); deletePartition->setShortcut(Qt::Key_Delete); - deletePartition->setIcon(BarIcon("edit-delete")); + deletePartition->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("edit-delete"), KIconLoader::Toolbar))); QAction* shredPartition = actionCollection()->addAction("shredPartition", &pmWidget(), SLOT(onShredPartition())); shredPartition->setEnabled(false); @@ -280,7 +276,7 @@ void MainWindow::setupActions() shredPartition->setToolTip(i18nc("@info:tooltip", "Shred partition")); shredPartition->setStatusTip(i18nc("@info:status", "Shred a partition so that its contents cannot be restored.")); shredPartition->setShortcut(Qt::SHIFT | Qt::Key_Delete); - shredPartition->setIcon(BarIcon("edit-delete-shred")); + shredPartition->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("edit-delete-shred"), KIconLoader::Toolbar))); QAction* copyPartition = actionCollection()->addAction("copyPartition", &pmWidget(), SLOT(onCopyPartition())); copyPartition->setEnabled(false); @@ -288,7 +284,7 @@ void MainWindow::setupActions() copyPartition->setToolTip(i18nc("@info:tooltip", "Copy partition")); copyPartition->setStatusTip(i18nc("@info:status", "Copy an existing partition.")); copyPartition->setShortcut(Qt::CTRL | Qt::Key_C); - copyPartition->setIcon(BarIcon("edit-copy")); + copyPartition->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("edit-copy"), KIconLoader::Toolbar))); QAction* pastePartition = actionCollection()->addAction("pastePartition", &pmWidget(), SLOT(onPastePartition())); pastePartition->setEnabled(false); @@ -296,7 +292,7 @@ void MainWindow::setupActions() pastePartition->setToolTip(i18nc("@info:tooltip", "Paste partition")); pastePartition->setStatusTip(i18nc("@info:status", "Paste a copied partition.")); pastePartition->setShortcut(Qt::CTRL | Qt::Key_V); - pastePartition->setIcon(BarIcon("edit-paste")); + pastePartition->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("edit-paste"), KIconLoader::Toolbar))); QAction* editMountPoint = actionCollection()->addAction("editMountPoint", &pmWidget(), SLOT(onEditMountPoint())); editMountPoint->setEnabled(false); @@ -315,28 +311,28 @@ void MainWindow::setupActions() checkPartition->setText(i18nc("@action:inmenu", "Check")); checkPartition->setToolTip(i18nc("@info:tooltip", "Check partition")); checkPartition->setStatusTip(i18nc("@info:status", "Check a filesystem on a partition for errors.")); - checkPartition->setIcon(BarIcon("flag")); + checkPartition->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("flag"), KIconLoader::Toolbar))); QAction* propertiesPartition = actionCollection()->addAction("propertiesPartition", &pmWidget(), SLOT(onPropertiesPartition())); propertiesPartition->setEnabled(false); propertiesPartition->setText(i18nc("@action:inmenu", "Properties")); propertiesPartition->setToolTip(i18nc("@info:tooltip", "Show partition properties dialog")); propertiesPartition->setStatusTip(i18nc("@info:status", "View and modify partition properties (label, partition flags, etc.)")); - propertiesPartition->setIcon(BarIcon("document-properties")); + propertiesPartition->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("document-properties"), KIconLoader::Toolbar))); QAction* backup = actionCollection()->addAction("backupPartition", &pmWidget(), SLOT(onBackupPartition())); backup->setEnabled(false); backup->setText(i18nc("@action:inmenu", "Backup")); backup->setToolTip(i18nc("@info:tooltip", "Backup partition")); backup->setStatusTip(i18nc("@info:status", "Backup a partition to an image file.")); - backup->setIcon(BarIcon("document-export")); + backup->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("document-export"), KIconLoader::Toolbar))); QAction* restore = actionCollection()->addAction("restorePartition", &pmWidget(), SLOT(onRestorePartition())); restore->setEnabled(false); restore->setText(i18nc("@action:inmenu", "Restore")); restore->setToolTip(i18nc("@info:tooltip", "Restore partition")); restore->setStatusTip(i18nc("@info:status", "Restore a partition from an image file.")); - restore->setIcon(BarIcon("document-import")); + restore->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("document-import"), KIconLoader::Toolbar))); // View actions QAction* fileSystemSupport = actionCollection()->addAction("fileSystemSupport", this, SLOT(onFileSystemSupport())); @@ -357,13 +353,13 @@ void MainWindow::setupActions() clearLog->setText(i18nc("@action:inmenu", "Clear Log")); clearLog->setToolTip(i18nc("@info:tooltip", "Clear the log output")); clearLog->setStatusTip(i18nc("@info:status", "Clear the log output panel.")); - clearLog->setIcon(BarIcon("edit-clear-list")); + clearLog->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("edit-clear-list"), KIconLoader::Toolbar))); QAction* saveLog = actionCollection()->addAction("saveLog", &treeLog(), SLOT(onSaveLog())); saveLog->setText(i18nc("@action:inmenu", "Save Log")); saveLog->setToolTip(i18nc("@info:tooltip", "Save the log output")); saveLog->setStatusTip(i18nc("@info:status", "Save the log output to a file.")); - saveLog->setIcon(BarIcon("document-save")); + saveLog->setIcon(QIcon(KIconLoader().loadIcon(QLatin1String("document-save"), KIconLoader::Toolbar))); } void MainWindow::setupConnections() @@ -383,7 +379,6 @@ void MainWindow::loadConfig() { dockLog().setVisible(false); dockInformation().setVisible(false); - toolBar("deviceToolBar")->setVisible(false); } } @@ -473,9 +468,7 @@ void MainWindow::updateWindowTitle() QString title; if (pmWidget().selectedDevice()) - title = pmWidget().selectedDevice()->deviceNode() + " - "; - - title += KGlobal::mainComponent().aboutData()->programName() + ' ' + KGlobal::mainComponent().aboutData()->version(); + title = pmWidget().selectedDevice()->deviceNode(); setWindowTitle(title); } @@ -545,9 +538,10 @@ void MainWindow::on_m_PartitionManagerWidget_selectedPartitionChanged(const Part void MainWindow::scanDevices() { - Log(Log::information) << i18nc("@info/plain", "Using backend plugin: %1 (%2)", - CoreBackendManager::self()->backend()->about().programName(), - CoreBackendManager::self()->backend()->about().version()); +// FIXME: port KF5 +// Log(Log::information) << i18nc("@info/plain", "Using backend plugin: %1 (%2)", +// CoreBackendManager::self()->backend()->about().displayName(), +// CoreBackendManager::self()->backend()->about().version()); Log() << i18nc("@info/plain", "Scanning devices..."); @@ -556,7 +550,7 @@ void MainWindow::scanDevices() pmWidget().clear(); - KApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); scanProgressDialog().setEnabled(true); scanProgressDialog().show(); @@ -582,7 +576,7 @@ void MainWindow::on_m_DeviceScanner_finished() pmWidget().updatePartitions(); Log() << i18nc("@info/plain", "Scan finished."); - KApplication::restoreOverrideCursor(); + QApplication::restoreOverrideCursor(); // try to set the seleted device, either from the saved one or just select the // first device @@ -619,7 +613,7 @@ void MainWindow::onSelectedDeviceMenuTriggered(bool) if (action == NULL || action->parent() != devicesMenu) return; - foreach (QAction* entry, qFindChildren(devicesMenu)) + foreach (QAction* entry, devicesMenu->findChildren()) entry->setChecked(entry == action); listDevices().setSelectedDevice(action->data().toString()); @@ -629,14 +623,14 @@ void MainWindow::on_m_ListDevices_selectionChanged(const QString& device_node) { QMenu* devicesMenu = static_cast(guiFactory()->container("selectedDevice", this)); - foreach (QAction* entry, qFindChildren(devicesMenu)) + foreach (QAction* entry, devicesMenu->findChildren()) entry->setChecked(entry->data().toString() == device_node); } void MainWindow::onRefreshDevices() { if (operationStack().size() == 0 || KMessageBox::warningContinueCancel(this, - i18nc("@info", + xi18nc("@info", "Do you really want to rescan the devices?" "This will also clear the list of pending operations."), i18nc("@title:window", "Really Rescan the Devices?"), @@ -655,7 +649,7 @@ void MainWindow::onApplyAllOperations() opList.append(op->description()); if (KMessageBox::warningContinueCancelList(this, - i18nc("@info", + xi18nc("@info", "Do you really want to apply the pending operations listed below?" "This will permanently modify your disks."), opList, i18nc("@title:window", "Apply Pending Operations?"), @@ -739,15 +733,18 @@ void MainWindow::onImportPartitionTable() { Q_ASSERT(pmWidget().selectedDevice()); - const KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog://importPartitionTable")); + const QUrl url = QFileDialog::getOpenFileUrl(this, "kfiledialog://importPartitionTable"); if (url.isEmpty()) return; QString fileName; - if (!KIO::NetAccess::download(url, fileName, this)) + KIO::FileCopyJob *job = KIO::file_copy(url, fileName); + KJobWidgets::setWindow(job, this); + job->exec(); + if ( job->error() ) { - KMessageBox::error(this, i18nc("@info", "Could not open input file %1 for import: %2", url.fileName(), KIO::NetAccess::lastErrorString()), i18nc("@title:window", "Error Importing Partition Table")); + KMessageBox::error(this, xi18nc("@info", "Could not open input file %1 for import: %2", url.fileName(), job->errorString()), i18nc("@title:window", "Error Importing Partition Table")); return; } @@ -755,7 +752,7 @@ void MainWindow::onImportPartitionTable() if (!file.open(QFile::ReadOnly)) { - KMessageBox::error(this, i18nc("@info", "Could not open temporary file %1 while trying to import from %2.", fileName, url.fileName()), i18nc("@title:window", "Error Importing Partition Table")); + KMessageBox::error(this, xi18nc("@info", "Could not open temporary file %1 while trying to import from %2.", fileName, url.fileName()), i18nc("@title:window", "Error Importing Partition Table")); return; } @@ -781,7 +778,7 @@ void MainWindow::onImportPartitionTable() if (!haveMagic && rxMagic.indexIn(line) == -1) { - KMessageBox::error(this, i18nc("@info", "The import file %1 does not contain a valid partition table.", fileName), i18nc("@title:window", "Error While Importing Partition Table")); + KMessageBox::error(this, xi18nc("@info", "The import file %1 does not contain a valid partition table.", fileName), i18nc("@title:window", "Error While Importing Partition Table")); return; } else @@ -909,16 +906,16 @@ void MainWindow::onExportPartitionTable() Q_ASSERT(pmWidget().selectedDevice()); Q_ASSERT(pmWidget().selectedDevice()->partitionTable()); - const KUrl url = KFileDialog::getSaveUrl(KUrl("kfiledialog://exportPartitionTable")); + const QUrl url = QFileDialog::getSaveFileUrl(); if (url.isEmpty()) return; - KTemporaryFile tempFile; + QTemporaryFile tempFile; if (!tempFile.open()) { - KMessageBox::error(this, i18nc("@info", "Could not create temporary file when trying to save to %1.", url.fileName()), i18nc("@title:window", "Error Exporting Partition Table")); + KMessageBox::error(this, xi18nc("@info", "Could not create temporary file when trying to save to %1.", url.fileName()), i18nc("@title:window", "Error Exporting Partition Table")); return; } @@ -931,7 +928,8 @@ void MainWindow::onExportPartitionTable() tempFile.close(); KIO::CopyJob* job = KIO::move(tempFile.fileName(), url, KIO::HideProgressInfo); - if (!KIO::NetAccess::synchronousRun(job, NULL)) + job->exec(); + if ( job->error() ) job->ui()->showErrorMessage(); } @@ -943,7 +941,7 @@ void MainWindow::onFileSystemSupport() void MainWindow::onSettingsChanged() { - if (CoreBackendManager::self()->backend()->about().appName() != Config::backend()) + if (CoreBackendManager::self()->backend()->about().productName() != Config::backend()) { CoreBackendManager::self()->unload(); // FIXME: if loadBackend() fails to load the configured backend and loads the default @@ -1042,7 +1040,7 @@ static QStringList checkSupportInNode(const PartitionNode* parent) .arg(p->deviceNode()) .arg(p->fileSystem().name()) .arg(p->fileSystem().supportToolName().name) - .arg(p->fileSystem().supportToolName().url.prettyUrl()); + .arg(p->fileSystem().supportToolName().url.toString()); } return rval; @@ -1059,7 +1057,7 @@ void MainWindow::checkFileSystemSupport() if (!supportList.isEmpty()) KMessageBox::information(this, - i18nc("@info", + xi18nc("@info", "No support tools were found for file systems currently present on hard disks in this computer:" "" "" diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index c31e240..2ca0949 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -29,7 +29,7 @@ #include "ui_mainwindowbase.h" -#include +#include class ApplyProgressDialog; class ScanProgressDialog; @@ -37,6 +37,8 @@ class Device; class Partition; class InfoPane; +class KActionCollection; + class QWidget; class QLabel; class QCloseEvent; diff --git a/src/gui/newdialog.cpp b/src/gui/newdialog.cpp index e0d5c29..0359380 100644 --- a/src/gui/newdialog.cpp +++ b/src/gui/newdialog.cpp @@ -30,9 +30,9 @@ #include "util/capacity.h" #include "util/helpers.h" +#include #include -#include #include #include #include @@ -181,7 +181,7 @@ void NewDialog::updateHideAndShow() { dialogWidget().label().setReadOnly(true); dialogWidget().noSetLabel().setVisible(true); - dialogWidget().noSetLabel().setFont(KGlobalSettings::smallestReadableFont()); + dialogWidget().noSetLabel().setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); QPalette palette = dialogWidget().noSetLabel().palette(); QColor f = palette.color(QPalette::Foreground); diff --git a/src/gui/partitionmanagerwidget.cpp b/src/gui/partitionmanagerwidget.cpp index ecb8d52..5783a37 100644 --- a/src/gui/partitionmanagerwidget.cpp +++ b/src/gui/partitionmanagerwidget.cpp @@ -49,17 +49,16 @@ #include "util/report.h" #include "util/helpers.h" -#include -#include -#include -#include -#include - #include +#include #include #include #include +#include +#include +#include + #include class PartitionTreeWidgetItem : public QTreeWidgetItem @@ -216,7 +215,7 @@ static QTreeWidgetItem* createTreeWidgetItem(const Partition& p) item->setText(i, p.mountPoint()); if (p.isMounted()) - item->setIcon(i, SmallIcon("object-locked")); + item->setIcon(i, QIcon(KIconLoader().loadIcon(QLatin1String("object-locked"), KIconLoader::Small))); i++; item->setText(i++, p.fileSystem().label()); @@ -254,7 +253,7 @@ void PartitionManagerWidget::updatePartitions() deviceItem->setFont(0, font); deviceItem->setText(0, selectedDevice()->prettyName()); - deviceItem->setIcon(0, DesktopIcon(selectedDevice()->iconName())); + deviceItem->setIcon(0, QIcon(KIconLoader().loadIcon(selectedDevice()->iconName(), KIconLoader::Desktop))); deviceItem->setSizeHint(0, QSize(0, 32)); treePartitions().addTopLevelItem(deviceItem); @@ -404,12 +403,12 @@ void PartitionManagerWidget::onMountPartition() if (p->canMount()) { if (!p->mount(report)) - KMessageBox::detailedSorry(this, i18nc("@info", "The file system on partition %1 could not be mounted.", p->deviceNode()), QString("
%1
").arg(report.toText()), i18nc("@title:window", "Could Not Mount File System.")); + KMessageBox::detailedSorry(this, xi18nc("@info", "The file system on partition %1 could not be mounted.", p->deviceNode()), QString("
%1
").arg(report.toText()), i18nc("@title:window", "Could Not Mount File System.")); } else if (p->canUnmount()) { if (!p->unmount(report)) - KMessageBox::detailedSorry(this, i18nc("@info", "The file system on partition %1 could not be unmounted.", p->deviceNode()), QString("
%1
").arg(report.toText()), i18nc("@title:window", "Could Not Unmount File System.")); + KMessageBox::detailedSorry(this, xi18nc("@info", "The file system on partition %1 could not be unmounted.", p->deviceNode()), QString("
%1
").arg(report.toText()), i18nc("@title:window", "Could Not Unmount File System.")); } if (p->roles().has(PartitionRole::Logical)) @@ -450,7 +449,7 @@ static bool checkTooManyPartitions(QWidget* parent, const Device& d, const Parti if (p.roles().has(PartitionRole::Unallocated) && d.partitionTable()->numPrimaries() >= d.partitionTable()->maxPrimaries() && !p.roles().has(PartitionRole::Logical)) { - KMessageBox::sorry(parent, i18ncp("@info", + KMessageBox::sorry(parent, xi18ncp("@info", "There is already one primary partition on this device. This is the maximum number its partition table type can handle." "You cannot create, paste or restore a primary partition on it before you delete an existing one.", "There are already %1 primary partitions on this device. This is the maximum number its partition table type can handle." @@ -519,7 +518,7 @@ void PartitionManagerWidget::onDeletePartition(bool shred) if (selectedPartition()->number() > 0 && selectedPartition()->parent()->highestMountedChild() > selectedPartition()->number()) { KMessageBox::sorry(this, - i18nc("@info", + xi18nc("@info", "The partition %1 cannot currently be deleted because one or more partitions with higher logical numbers are still mounted." "Please unmount all partitions with higher logical numbers than %2 first.", selectedPartition()->deviceNode(), selectedPartition()->number()), @@ -582,7 +581,7 @@ void PartitionManagerWidget::onResizePartition() if (dlg->exec() == QDialog::Accepted) { if (dlg->resizedFirstSector() == p.firstSector() && dlg->resizedLastSector() == p.lastSector()) - Log(Log::information) << i18nc("@info/plain", "Partition %1 has the same position and size after resize/move. Ignoring operation.", p.deviceNode()); + Log(Log::information) << xi18nc("@info/plain", "Partition %1 has the same position and size after resize/move. Ignoring operation.", p.deviceNode()); else operationStack().push(new ResizeOperation(*selectedDevice(), p, dlg->resizedFirstSector(), dlg->resizedLastSector())); } @@ -612,7 +611,7 @@ void PartitionManagerWidget::onCopyPartition() } setClipboardPartition(selectedPartition()); - Log() << i18nc("@info/plain", "Partition %1 has been copied to the clipboard.", selectedPartition()->deviceNode()); + Log() << xi18nc("@info/plain", "Partition %1 has been copied to the clipboard.", selectedPartition()->deviceNode()); } void PartitionManagerWidget::onPastePartition() @@ -681,7 +680,7 @@ bool PartitionManagerWidget::showInsertDialog(Partition& insertedPartition, qint return false; } else if (KMessageBox::warningContinueCancel(this, - i18nc("@info", "You are about to lose all data on partition " + xi18nc("@info", "You are about to lose all data on partition " "%1." "Overwriting one partition with another (or with an image file) will " "destroy all data on this target partition." @@ -698,11 +697,11 @@ bool PartitionManagerWidget::showInsertDialog(Partition& insertedPartition, qint if (insertedPartition.length() < sourceLength) { if (overwrite) - KMessageBox::error(this, i18nc("@info", + KMessageBox::error(this, xi18nc("@info", "The selected partition is not large enough to hold the source partition or the backup file." "Pick another target or resize this partition so it is as large as the source."), i18nc("@title:window", "Target Not Large Enough")); else - KMessageBox::sorry(this, i18nc("@info", + KMessageBox::sorry(this, xi18nc("@info", "It is not possible to create the target partition large enough to hold the source." "This may happen if not all partitions on a device are correctly aligned " "or when copying a primary partition into an extended partition."), @@ -738,13 +737,13 @@ void PartitionManagerWidget::onBackupPartition() return; } - QString fileName = KFileDialog::getSaveFileName(KUrl("kfiledialog://backupPartition")); + QString fileName = QFileDialog::getSaveFileName(this, "kfiledialog://backupPartition"); // QString fileName = "/tmp/backuptest.img"; if (fileName.isEmpty()) return; - if (!QFile::exists(fileName) || KMessageBox::warningContinueCancel(this, i18nc("@info", "Do you want to overwrite the existing file %1?", fileName), i18nc("@title:window", "Overwrite Existing File?"), KGuiItem(i18nc("@action:button", "Overwrite File"), "arrow-right"), KStandardGuiItem::cancel()) == KMessageBox::Continue) + if (!QFile::exists(fileName) || KMessageBox::warningContinueCancel(this, xi18nc("@info", "Do you want to overwrite the existing file %1?", fileName), i18nc("@title:window", "Overwrite Existing File?"), KGuiItem(i18nc("@action:button", "Overwrite File"), "arrow-right"), KStandardGuiItem::cancel()) == KMessageBox::Continue) operationStack().push(new BackupOperation(*selectedDevice(), *selectedPartition(), fileName)); } @@ -762,7 +761,7 @@ void PartitionManagerWidget::onRestorePartition() if (checkTooManyPartitions(this, *selectedDevice(), *selectedPartition())) return; - QString fileName = KFileDialog::getOpenFileName(KUrl("kfiledialog://backupPartition")); + QString fileName = QFileDialog::getOpenFileName(this, "kfiledialog://restorePartition"); // QString fileName = "/tmp/backuptest.img"; if (!fileName.isEmpty() && QFile::exists(fileName)) @@ -771,7 +770,7 @@ void PartitionManagerWidget::onRestorePartition() if (restorePartition->length() > selectedPartition()->length()) { - KMessageBox::error(this, i18nc("@info", "The file system in the image file %1 is too large to be restored to the selected partition.", fileName), i18nc("@title:window", "Not Enough Space to Restore File System.")); + KMessageBox::error(this, xi18nc("@info", "The file system in the image file %1 is too large to be restored to the selected partition.", fileName), i18nc("@title:window", "Not Enough Space to Restore File System.")); delete restorePartition; return; } diff --git a/src/gui/partpropsdialog.cpp b/src/gui/partpropsdialog.cpp index 17de835..19ec6c8 100644 --- a/src/gui/partpropsdialog.cpp +++ b/src/gui/partpropsdialog.cpp @@ -29,17 +29,16 @@ #include "util/helpers.h" #include -#include +#include #include +#include #include #include -#include #include -#include #include -#include -#include +#include +#include /** Creates a new PartPropsDialog @param parent pointer to the parent widget @@ -59,7 +58,7 @@ PartPropsDialog::PartPropsDialog(QWidget* parent, Device& d, Partition& p) : setLayout(mainLayout); mainLayout->addWidget(&dialogWidget()); - setWindowTitle(i18nc("@title:window", "Partition properties: %1", partition().deviceNode())); + setWindowTitle(xi18nc("@title:window", "Partition properties: %1", partition().deviceNode())); setupDialog(); setupConnections(); @@ -126,7 +125,7 @@ void PartPropsDialog::setupDialog() if (partition().roles().has(PartitionRole::Extended)) statusText = i18nc("@label partition state", "At least one logical partition is mounted."); else if (!partition().mountPoint().isEmpty()) - statusText = i18nc("@label partition state", "mounted on %1", mp); + statusText = xi18nc("@label partition state", "mounted on %1", mp); else statusText = i18nc("@label partition state", "mounted"); } @@ -200,7 +199,7 @@ void PartPropsDialog::updateHideAndShow() { dialogWidget().label().setReadOnly(true); dialogWidget().noSetLabel().setVisible(true); - dialogWidget().noSetLabel().setFont(KGlobalSettings::smallestReadableFont()); + dialogWidget().noSetLabel().setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); QPalette palette = dialogWidget().noSetLabel().palette(); QColor f = palette.color(QPalette::Foreground); @@ -339,9 +338,9 @@ void PartPropsDialog::updatePartitionFileSystem() void PartPropsDialog::onFilesystemChanged(int) { if (partition().state() == Partition::StateNew || warnFileSystemChange() || KMessageBox::warningContinueCancel(this, - i18nc("@info", "You are about to lose all data on partition %1." + xi18nc("@info", "You are about to lose all data on partition %1." "Changing the file system on a partition already on disk will erase all its contents. If you continue now and apply the resulting operation in the main window, all data on %1 will unrecoverably be lost.", partition().deviceNode()), - i18nc("@title:window", "Really Recreate %1 with File System %2?", partition().deviceNode(), dialogWidget().fileSystem().currentText()), + xi18nc("@title:window", "Really Recreate %1 with File System %2?", partition().deviceNode(), dialogWidget().fileSystem().currentText()), KGuiItem(i18nc("@action:button", "Change the File System"), "arrow-right"), KGuiItem(i18nc("@action:button", "Do Not Change the File System"), "dialog-cancel"), "reallyChangeFileSystem") == KMessageBox::Continue) { @@ -364,9 +363,9 @@ void PartPropsDialog::onFilesystemChanged(int) void PartPropsDialog::onRecreate(int state) { if (state == Qt::Checked && (warnFileSystemChange() || KMessageBox::warningContinueCancel(this, - i18nc("@info", "You are about to lose all data on partition %1." - "Recreating a file system will erase all its contents. If you continue now and apply the resulting operation in the main window, all data on %1 will unrecoverably be lost.", partition().deviceNode()), - i18nc("@title:window", "Really Recreate File System on %1?", partition().deviceNode()), + xi18nc("@info", "You are about to lose all data on partition %1." + "Recreating a file system will erase all its contents. If you continue now and apply the resulting operation in the main window, all data on %1 will unrecoverably be lost.

", partition().deviceNode()), + xi18nc("@title:window", "Really Recreate File System on %1?", partition().deviceNode()), KGuiItem(i18nc("@action:button", "Recreate the File System"), "arrow-right"), KGuiItem(i18nc("@action:button", "Do Not Recreate the File System"), "dialog-cancel"), "reallyRecreateFileSystem") == KMessageBox::Continue)) { diff --git a/src/gui/partwidget.cpp b/src/gui/partwidget.cpp index 25cc823..ea39fe2 100644 --- a/src/gui/partwidget.cpp +++ b/src/gui/partwidget.cpp @@ -28,9 +28,7 @@ #include #include #include -#include - -#include +#include #include @@ -43,19 +41,20 @@ PartWidget::PartWidget(QWidget* parent, const Partition* p) : m_Partition(NULL), m_Active(false) { - setFont(KGlobalSettings::smallestReadableFont()); + setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); // Check if user is running a GTK style; in that case, use plastique as a fallback // style for the PartWidget to work around GTK styles not showing the FS colors // correctly. // Inspired by Aurélien Gâteau's similar workaround in Gwenview (230aebbd) - if (qstrcmp(QApplication::style()->metaObject()->className(), "QGtkStyle") == 0) + //FIXME: port KF5. Is this still necessary? + /*if (qstrcmp(QApplication::style()->metaObject()->className(), "QGtkStyle") == 0) { QStyle* style = new QPlastiqueStyle(); style->setParent(this); setStyle(style); - } - + }*/ + init(p); } diff --git a/src/gui/resizedialog.cpp b/src/gui/resizedialog.cpp index 033b3a7..3aed041 100644 --- a/src/gui/resizedialog.cpp +++ b/src/gui/resizedialog.cpp @@ -47,7 +47,7 @@ ResizeDialog::ResizeDialog(QWidget* parent, Device& d, Partition& p, qint64 minF m_ResizedFirstSector(p.firstSector()), m_ResizedLastSector(p.lastSector()) { - setWindowTitle(i18nc("@title:window", "Resize/move partition: %1", partition().deviceNode())); + setWindowTitle(xi18nc("@title:window", "Resize/move partition: %1", partition().deviceNode())); dialogWidget().hideRole(); dialogWidget().hideFileSystem(); diff --git a/src/gui/scanprogressdialog.cpp b/src/gui/scanprogressdialog.cpp index e060b8e..3286490 100644 --- a/src/gui/scanprogressdialog.cpp +++ b/src/gui/scanprogressdialog.cpp @@ -35,7 +35,7 @@ void ScanProgressDialog::setDeviceName(const QString& d) if (d.isEmpty()) setLabelText(i18nc("@label", "Scanning...")); else - setLabelText(i18nc("@label", "Scanning device: %1", d)); + setLabelText(xi18nc("@label", "Scanning device: %1", d)); } void ScanProgressDialog::showEvent(QShowEvent* e) diff --git a/src/gui/smartdialog.cpp b/src/gui/smartdialog.cpp index 9c14693..dbecb11 100644 --- a/src/gui/smartdialog.cpp +++ b/src/gui/smartdialog.cpp @@ -27,28 +27,24 @@ #include "util/helpers.h" #include "util/htmlreport.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include +#include +#include #include -#include -#include +#include #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include + #include #include @@ -66,7 +62,7 @@ SmartDialog::SmartDialog(QWidget* parent, Device& d) : QVBoxLayout *mainLayout = new QVBoxLayout(this); setLayout(mainLayout); mainLayout->addWidget(&dialogWidget()); - setWindowTitle(i18nc("@title:window", "SMART Properties: %1", device().deviceNode())); + setWindowTitle(xi18nc("@title:window", "SMART Properties: %1", device().deviceNode())); buttonBox = new QDialogButtonBox(this); buttonBox->setStandardButtons(QDialogButtonBox::Save | QDialogButtonBox::Close); @@ -100,7 +96,7 @@ void SmartDialog::setupDialog() else { dialogWidget().statusText().setText(i18nc("@label SMART disk status", "BAD")); - dialogWidget().statusIcon().setPixmap(SmallIcon("dialog-warning")); + dialogWidget().statusIcon().setPixmap(KIconLoader().loadIcon(QLatin1String("dialog-warning"), KIconLoader::Small)); } dialogWidget().modelName().setText(device().smartStatus().modelName()); @@ -112,14 +108,14 @@ void SmartDialog::setupDialog() ? QLocale().toString(device().smartStatus().badSectors()) : i18nc("@label SMART number of bad sectors", "none"); dialogWidget().badSectors().setText(badSectors); - dialogWidget().poweredOn().setText(KGlobal::locale()->formatDuration(device().smartStatus().poweredOn())); + dialogWidget().poweredOn().setText(KFormat().formatDuration(device().smartStatus().poweredOn())); dialogWidget().powerCycles().setText(QLocale().toString(device().smartStatus().powerCycles())); dialogWidget().overallAssessment().setText(SmartStatus::overallAssessmentToString(device().smartStatus().overall())); dialogWidget().selfTests().setText(SmartStatus::selfTestStatusToString(device().smartStatus().selfTestStatus())); dialogWidget().treeSmartAttributes().clear(); - const QFont f = KGlobalSettings::smallestReadableFont(); + const QFont f = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont); const QString size = f.pixelSize() != -1 ? QString("%1px").arg(f.pixelSize()) : QString("%1pt").arg(f.pointSize()); const QString st = QString("").arg(f.family()).arg(size); @@ -175,7 +171,7 @@ QString SmartDialog::toHtml() const << HtmlReport::tableLine(i18n("Firmware revision:"), device().smartStatus().firmware()) << HtmlReport::tableLine(i18n("Temperature:"), SmartStatus::tempToString(device().smartStatus().temp())) << HtmlReport::tableLine(i18n("Bad sectors:"), badSectors) - << HtmlReport::tableLine(i18n("Powered on for:"), KGlobal::locale()->formatDuration(device().smartStatus().poweredOn())) + << HtmlReport::tableLine(i18n("Powered on for:"), KFormat().formatDuration(device().smartStatus().poweredOn())) << HtmlReport::tableLine(i18n("Power cycles:"), QLocale().toString(device().smartStatus().powerCycles())) << HtmlReport::tableLine(i18n("Self tests:"), SmartStatus::selfTestStatusToString(device().smartStatus().selfTestStatus())) << HtmlReport::tableLine(i18n("Overall assessment:"), SmartStatus::overallAssessmentToString(device().smartStatus().overall())); @@ -185,7 +181,7 @@ QString SmartDialog::toHtml() const if (device().smartStatus().isValid()) { - const QFont f = KGlobalSettings::smallestReadableFont(); + const QFont f = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont); const QString size = f.pixelSize() != -1 ? QString("%1px").arg(f.pixelSize()) : QString("%1pt").arg(f.pointSize()); const QString st = QString("").arg(f.family()).arg(size); @@ -222,12 +218,12 @@ QString SmartDialog::toHtml() const void SmartDialog::saveSmartReport() { - const KUrl url = KFileDialog::getSaveUrl(KUrl("kfiledialog://saveSMARTReport")); + const QUrl url = QFileDialog::getSaveFileUrl(); if (url.isEmpty()) return; - KTemporaryFile tempFile; + QTemporaryFile tempFile; if (tempFile.open()) { @@ -241,11 +237,12 @@ void SmartDialog::saveSmartReport() tempFile.close(); - KIO::CopyJob* job = KIO::move(tempFile.fileName(), url, KIO::HideProgressInfo); - if (!KIO::NetAccess::synchronousRun(job, NULL)) + KIO::CopyJob* job = KIO::move(QUrl::fromLocalFile(tempFile.fileName()), url, KIO::HideProgressInfo); + job->exec(); + if ( job->error() ) job->ui()->showErrorMessage(); } else - KMessageBox::sorry(this, i18nc("@info", "Could not create temporary file when trying to save to %1.", url.fileName()), i18nc("@title:window", "Could Not Save SMART Report.")); + KMessageBox::sorry(this, xi18nc("@info", "Could not create temporary file when trying to save to %1.", url.fileName()), i18nc("@title:window", "Could Not Save SMART Report.")); } diff --git a/src/gui/treelog.cpp b/src/gui/treelog.cpp index 7f4f86b..4e40b5b 100644 --- a/src/gui/treelog.cpp +++ b/src/gui/treelog.cpp @@ -24,23 +24,21 @@ #include "util/globallog.h" #include "util/helpers.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include #include #include +#include +#include +#include +#include #include #include -#include -#include + +#include +#include +#include +#include +#include #include @@ -121,15 +119,15 @@ void TreeLog::onClearLog() void TreeLog::onSaveLog() { - const KUrl url = KFileDialog::getSaveUrl(KUrl("kfiledialog://saveLog")); + const QUrl url = QFileDialog::getSaveFileUrl(); if (!url.isEmpty()) { - KTemporaryFile tempFile; + QTemporaryFile tempFile; if (!tempFile.open()) { - KMessageBox::error(this, i18nc("@info", "Could not create temporary output file to save %1.", url.fileName()), i18nc("@title:window", "Error Saving Log File")); + KMessageBox::error(this, xi18nc("@info", "Could not create temporary output file to save %1.", url.fileName()), i18nc("@title:window", "Error Saving Log File")); return; } @@ -144,7 +142,8 @@ void TreeLog::onSaveLog() tempFile.close(); KIO::CopyJob* job = KIO::move(tempFile.fileName(), url, KIO::HideProgressInfo); - if (!KIO::NetAccess::synchronousRun(job, NULL)) + job->exec(); + if ( job->error() ) job->ui()->showErrorMessage(); } } @@ -170,7 +169,7 @@ void TreeLog::onNewLogMessage(Log::Level logLevel, const QString& s) { QTreeWidgetItem* item = new QTreeWidgetItem(); - item->setIcon(0, SmallIcon(icons[logLevel])); + item->setIcon(0, QIcon(KIconLoader().loadIcon(icons[logLevel], KIconLoader::Small))); item->setText(1, QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")); item->setText(2, s); diff --git a/src/jobs/backupfilesystemjob.cpp b/src/jobs/backupfilesystemjob.cpp index ab220b5..49784ec 100644 --- a/src/jobs/backupfilesystemjob.cpp +++ b/src/jobs/backupfilesystemjob.cpp @@ -51,9 +51,9 @@ qint32 BackupFileSystemJob::numSteps() const bool BackupFileSystemJob::run(Report& parent) { bool rval = false; - + Report* report = jobStarted(parent); - + if (sourcePartition().fileSystem().supportBackup() == FileSystem::cmdSupportFileSystem) rval = sourcePartition().fileSystem().backup(*report, sourceDevice(), sourcePartition().deviceNode(), fileName()); else if (sourcePartition().fileSystem().supportBackup() == FileSystem::cmdSupportCore) @@ -62,13 +62,13 @@ bool BackupFileSystemJob::run(Report& parent) CopyTargetFile copyTarget(fileName(), sourceDevice().logicalSectorSize()); if (!copySource.open()) - report->line() << i18nc("@info/plain", "Could not open file system on source partition %1 for backup.", sourcePartition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open file system on source partition %1 for backup.", sourcePartition().deviceNode()); else if (!copyTarget.open()) - report->line() << i18nc("@info/plain", "Could not create backup file %1.", fileName()); + report->line() << xi18nc("@info/plain", "Could not create backup file %1.", fileName()); else rval = copyBlocks(*report, copyTarget, copySource); } - + jobFinished(*report, rval); return rval; @@ -76,5 +76,5 @@ bool BackupFileSystemJob::run(Report& parent) QString BackupFileSystemJob::description() const { - return i18nc("@info/plain", "Back up file system on partition %1 to %2", sourcePartition().deviceNode(), fileName()); + return xi18nc("@info/plain", "Back up file system on partition %1 to %2", sourcePartition().deviceNode(), fileName()); } diff --git a/src/jobs/checkfilesystemjob.cpp b/src/jobs/checkfilesystemjob.cpp index a6d0d7b..f6c3a75 100644 --- a/src/jobs/checkfilesystemjob.cpp +++ b/src/jobs/checkfilesystemjob.cpp @@ -53,5 +53,5 @@ bool CheckFileSystemJob::run(Report& parent) QString CheckFileSystemJob::description() const { - return i18nc("@info/plain", "Check file system on partition %1", partition().deviceNode()); + return xi18nc("@info/plain", "Check file system on partition %1", partition().deviceNode()); } diff --git a/src/jobs/copyfilesystemjob.cpp b/src/jobs/copyfilesystemjob.cpp index 83f862a..c0d0e65 100644 --- a/src/jobs/copyfilesystemjob.cpp +++ b/src/jobs/copyfilesystemjob.cpp @@ -57,7 +57,7 @@ bool CopyFileSystemJob::run(Report& parent) Report* report = jobStarted(parent); if (targetPartition().fileSystem().length() < sourcePartition().fileSystem().length()) - report->line() << i18nc("@info/plain", "Cannot copy file system: File system on target partition %1 is smaller than the file system on source partition %2.", targetPartition().deviceNode(), sourcePartition().deviceNode()); + report->line() << xi18nc("@info/plain", "Cannot copy file system: File system on target partition %1 is smaller than the file system on source partition %2.", targetPartition().deviceNode(), sourcePartition().deviceNode()); else if (sourcePartition().fileSystem().supportCopy() == FileSystem::cmdSupportFileSystem) rval = sourcePartition().fileSystem().copy(*report, targetPartition().deviceNode(), sourcePartition().deviceNode()); else if (sourcePartition().fileSystem().supportCopy() == FileSystem::cmdSupportCore) @@ -66,9 +66,9 @@ bool CopyFileSystemJob::run(Report& parent) CopyTargetDevice copyTarget(targetDevice(), targetPartition().fileSystem().firstSector(), targetPartition().fileSystem().lastSector()); if (!copySource.open()) - report->line() << i18nc("@info/plain", "Could not open file system on source partition %1 for copying.", sourcePartition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open file system on source partition %1 for copying.", sourcePartition().deviceNode()); else if (!copyTarget.open()) - report->line() << i18nc("@info/plain", "Could not open file system on target partition %1 for copying.", targetPartition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open file system on target partition %1 for copying.", targetPartition().deviceNode()); else { rval = copyBlocks(*report, copyTarget, copySource); @@ -101,5 +101,5 @@ bool CopyFileSystemJob::run(Report& parent) QString CopyFileSystemJob::description() const { - return i18nc("@info/plain", "Copy file system on partition %1 to partition %2", sourcePartition().deviceNode(), targetPartition().deviceNode()); + return xi18nc("@info/plain", "Copy file system on partition %1 to partition %2", sourcePartition().deviceNode(), targetPartition().deviceNode()); } diff --git a/src/jobs/createfilesystemjob.cpp b/src/jobs/createfilesystemjob.cpp index e52ffed..2798cca 100644 --- a/src/jobs/createfilesystemjob.cpp +++ b/src/jobs/createfilesystemjob.cpp @@ -67,17 +67,17 @@ bool CreateFileSystemJob::run(Report& parent) backendPartitionTable->commit(); } else - report->line() << i18nc("@info/plain", "Failed to set the system type for the file system on partition %1.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Failed to set the system type for the file system on partition %1.", partition().deviceNode()); delete backendPartitionTable; } else - report->line() << i18nc("@info/plain", "Could not open partition table on device %1 to set the system type for partition %2.", device().deviceNode(), partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open partition table on device %1 to set the system type for partition %2.", device().deviceNode(), partition().deviceNode()); delete backendDevice; } else - report->line() << i18nc("@info/plain", "Could not open device %1 to set the system type for partition %2.", device().deviceNode(), partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open device %1 to set the system type for partition %2.", device().deviceNode(), partition().deviceNode()); } } @@ -88,5 +88,5 @@ bool CreateFileSystemJob::run(Report& parent) QString CreateFileSystemJob::description() const { - return i18nc("@info/plain", "Create file system %1 on partition %2", partition().fileSystem().name(), partition().deviceNode()); + return xi18nc("@info/plain", "Create file system %1 on partition %2", partition().fileSystem().name(), partition().deviceNode()); } diff --git a/src/jobs/createpartitionjob.cpp b/src/jobs/createpartitionjob.cpp index 4b062f0..27cc3ba 100644 --- a/src/jobs/createpartitionjob.cpp +++ b/src/jobs/createpartitionjob.cpp @@ -68,17 +68,17 @@ bool CreatePartitionJob::run(Report& parent) backendPartitionTable->commit(); } else - report->line() << i18nc("@info/plain", "Failed to add partition %1 to device %2.", partition().deviceNode(), device().deviceNode()); + report->line() << xi18nc("@info/plain", "Failed to add partition %1 to device %2.", partition().deviceNode(), device().deviceNode()); delete backendPartitionTable; } else - report->line() << i18nc("@info/plain", "Could not open partition table on device %1 to create new partition %2.", device().deviceNode(), partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open partition table on device %1 to create new partition %2.", device().deviceNode(), partition().deviceNode()); delete backendDevice; } else - report->line() << i18nc("@info/plain", "Could not open device %1 to create new partition %2.", device().deviceNode(), partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open device %1 to create new partition %2.", device().deviceNode(), partition().deviceNode()); jobFinished(*report, rval); @@ -88,7 +88,7 @@ bool CreatePartitionJob::run(Report& parent) QString CreatePartitionJob::description() const { if (partition().number() > 0) - return i18nc("@info/plain", "Create new partition %1", partition().deviceNode()); + return xi18nc("@info/plain", "Create new partition %1", partition().deviceNode()); - return i18nc("@info/plain", "Create new partition on device %1", device().deviceNode()); + return xi18nc("@info/plain", "Create new partition on device %1", device().deviceNode()); } diff --git a/src/jobs/createpartitiontablejob.cpp b/src/jobs/createpartitiontablejob.cpp index bdc8493..3286c25 100644 --- a/src/jobs/createpartitiontablejob.cpp +++ b/src/jobs/createpartitiontablejob.cpp @@ -56,7 +56,7 @@ bool CreatePartitionTableJob::run(Report& parent) delete backendDevice; } else - report->line() << i18nc("@info/plain", "Creating partition table failed: Could not open device %1.", device().deviceNode()); + report->line() << xi18nc("@info/plain", "Creating partition table failed: Could not open device %1.", device().deviceNode()); jobFinished(*report, rval); @@ -65,5 +65,5 @@ bool CreatePartitionTableJob::run(Report& parent) QString CreatePartitionTableJob::description() const { - return i18nc("@info/plain", "Create new partition table on device %1", device().deviceNode()); + return xi18nc("@info/plain", "Create new partition table on device %1", device().deviceNode()); } diff --git a/src/jobs/deletefilesystemjob.cpp b/src/jobs/deletefilesystemjob.cpp index 0e436cc..65ac836 100644 --- a/src/jobs/deletefilesystemjob.cpp +++ b/src/jobs/deletefilesystemjob.cpp @@ -79,7 +79,7 @@ bool DeleteFileSystemJob::run(Report& parent) rval = backendPartitionTable->clobberFileSystem(*report, partition()); if (!rval) - report->line() << i18nc("@info/plain", "Could not delete file system on %1.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not delete file system on %1.", partition().deviceNode()); else backendPartitionTable->commit(); @@ -87,12 +87,12 @@ bool DeleteFileSystemJob::run(Report& parent) } else - report->line() << i18nc("@info/plain", "Could not open partition table on device %1 to delete file system on %2.", device().deviceNode(), partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open partition table on device %1 to delete file system on %2.", device().deviceNode(), partition().deviceNode()); delete backendDevice; } else - report->line() << i18nc("@info/plain", "Could not delete file system signature for partition %1: Failed to open device %2.", partition().deviceNode(), device().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not delete file system signature for partition %1: Failed to open device %2.", partition().deviceNode(), device().deviceNode()); } jobFinished(*report, rval); @@ -102,5 +102,5 @@ bool DeleteFileSystemJob::run(Report& parent) QString DeleteFileSystemJob::description() const { - return i18nc("@info/plain", "Delete file system on %1", partition().deviceNode()); + return xi18nc("@info/plain", "Delete file system on %1", partition().deviceNode()); } diff --git a/src/jobs/deletepartitionjob.cpp b/src/jobs/deletepartitionjob.cpp index 5ea3289..8ecbdc6 100644 --- a/src/jobs/deletepartitionjob.cpp +++ b/src/jobs/deletepartitionjob.cpp @@ -69,7 +69,7 @@ bool DeletePartitionJob::run(Report& parent) rval = backendPartitionTable->deletePartition(*report, partition()); if (!rval) - report->line() << i18nc("@info/plain", "Could not delete partition %1.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not delete partition %1.", partition().deviceNode()); else backendPartitionTable->commit(); @@ -77,12 +77,12 @@ bool DeletePartitionJob::run(Report& parent) } else - report->line() << i18nc("@info/plain", "Could not open partition table on device %1 to delete partition %2.", device().deviceNode(), partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open partition table on device %1 to delete partition %2.", device().deviceNode(), partition().deviceNode()); delete backendDevice; } else - report->line() << i18nc("@info/plain", "Deleting partition failed: Could not open device %1.", device().deviceNode()); + report->line() << xi18nc("@info/plain", "Deleting partition failed: Could not open device %1.", device().deviceNode()); jobFinished(*report, rval); @@ -91,5 +91,5 @@ bool DeletePartitionJob::run(Report& parent) QString DeletePartitionJob::description() const { - return i18nc("@info/plain", "Delete the partition %1", partition().deviceNode()); + return xi18nc("@info/plain", "Delete the partition %1", partition().deviceNode()); } diff --git a/src/jobs/job.cpp b/src/jobs/job.cpp index 04b43aa..db8ca39 100644 --- a/src/jobs/job.cpp +++ b/src/jobs/job.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include Job::Job() : @@ -162,14 +162,14 @@ bool Job::rollbackCopyBlocks(Report& report, CopyTarget& origTarget, CopySource& CopySourceDevice undoSource(ctd.device(), undoSourceFirstSector, undoSourceLastSector); if (!undoSource.open()) { - report.line() << i18nc("@info/plain", "Could not open device %1 to rollback copying.", ctd.device().deviceNode()); + report.line() << xi18nc("@info/plain", "Could not open device %1 to rollback copying.", ctd.device().deviceNode()); return false; } CopyTargetDevice undoTarget(csd.device(), undoTargetFirstSector, undoTargetLastSector); if (!undoTarget.open()) { - report.line() << i18nc("@info/plain", "Could not open device %1 to rollback copying.", csd.device().deviceNode()); + report.line() << xi18nc("@info/plain", "Could not open device %1 to rollback copying.", csd.device().deviceNode()); return false; } @@ -192,7 +192,7 @@ Report* Job::jobStarted(Report& parent) { emit started(); - return parent.newChild(i18nc("@info/plain", "Job: %1", description())); + return parent.newChild(i18nc("@info/plain", "Job: %1", description())); } void Job::jobFinished(Report& report, bool b) @@ -219,7 +219,7 @@ QIcon Job::statusIcon() const if (status() < 0 || static_cast(status()) >= sizeof(icons) / sizeof(icons[0])) return QIcon(); - return SmallIcon(icons[status()]); + return QIcon(KIconLoader().loadIcon(icons[status()], KIconLoader::Small)); } /** @return the Job's current status text */ diff --git a/src/jobs/movefilesystemjob.cpp b/src/jobs/movefilesystemjob.cpp index 21bed91..0182f9f 100644 --- a/src/jobs/movefilesystemjob.cpp +++ b/src/jobs/movefilesystemjob.cpp @@ -60,9 +60,9 @@ bool MoveFileSystemJob::run(Report& parent) CopyTargetDevice moveTarget(device(), newStart(), newStart() + partition().fileSystem().length()); if (!moveSource.open()) - report->line() << i18nc("@info/plain", "Could not open file system on partition %1 for moving.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open file system on partition %1 for moving.", partition().deviceNode()); else if (!moveTarget.open()) - report->line() << i18nc("@info/plain", "Could not create target for moving file system on partition %1.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not create target for moving file system on partition %1.", partition().deviceNode()); else { rval = copyBlocks(*report, moveTarget, moveSource); @@ -74,7 +74,7 @@ bool MoveFileSystemJob::run(Report& parent) partition().fileSystem().setLastSector(newStart() + savedLength); } else if (!rollbackCopyBlocks(*report, moveTarget, moveSource)) - report->line() << i18nc("@info/plain", "Rollback for file system on partition %1 failed.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Rollback for file system on partition %1 failed.", partition().deviceNode()); report->line() << i18nc("@info/plain", "Closing device. This may take a few seconds."); } @@ -90,5 +90,5 @@ bool MoveFileSystemJob::run(Report& parent) QString MoveFileSystemJob::description() const { - return i18nc("@info/plain", "Move the file system on partition %1 to sector %2", partition().deviceNode(), newStart()); + return xi18nc("@info/plain", "Move the file system on partition %1 to sector %2", partition().deviceNode(), newStart()); } diff --git a/src/jobs/resizefilesystemjob.cpp b/src/jobs/resizefilesystemjob.cpp index d04b0b0..f22b57d 100644 --- a/src/jobs/resizefilesystemjob.cpp +++ b/src/jobs/resizefilesystemjob.cpp @@ -73,7 +73,7 @@ bool ResizeFileSystemJob::run(Report& parent) if (partition().fileSystem().length() == newLength()) { - report->line() << i18ncp("@info/plain", "The file system on partition %2 already has the requested length of 1 sector.", "The file system on partition %2 already has the requested length of %1 sectors.", newLength(), partition().deviceNode()); + report->line() << xi18ncp("@info/plain", "The file system on partition %2 already has the requested length of 1 sector.", "The file system on partition %2 already has the requested length of %1 sectors.", newLength(), partition().deviceNode()); rval = true; } else @@ -100,7 +100,7 @@ bool ResizeFileSystemJob::run(Report& parent) } default: - report->line() << i18nc("@info/plain", "The file system on partition %1 cannot be resized because there is no support for it.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "The file system on partition %1 cannot be resized because there is no support for it.", partition().deviceNode()); break; } @@ -138,12 +138,12 @@ bool ResizeFileSystemJob::resizeFileSystemBackend(Report& report) delete backendPartitionTable; } else - report.line() << i18nc("@info/plain", "Could not open partition %1 while trying to resize the file system.", partition().deviceNode()); + report.line() << xi18nc("@info/plain", "Could not open partition %1 while trying to resize the file system.", partition().deviceNode()); delete backendDevice; } else - report.line() << i18nc("@info/plain", "Could not read geometry for partition %1 while trying to resize the file system.", partition().deviceNode()); + report.line() << xi18nc("@info/plain", "Could not read geometry for partition %1 while trying to resize the file system.", partition().deviceNode()); return rval; } @@ -151,7 +151,7 @@ bool ResizeFileSystemJob::resizeFileSystemBackend(Report& report) QString ResizeFileSystemJob::description() const { if (isMaximizing()) - return i18nc("@info/plain", "Maximize file system on %1 to fill the partition", partition().deviceNode()); + return xi18nc("@info/plain", "Maximize file system on %1 to fill the partition", partition().deviceNode()); - return i18ncp("@info/plain", "Resize file system on partition %2 to 1 sector", "Resize file system on partition %2 to %1 sectors", newLength(), partition().deviceNode()); + return xi18ncp("@info/plain", "Resize file system on partition %2 to 1 sector", "Resize file system on partition %2 to %1 sectors", newLength(), partition().deviceNode()); } diff --git a/src/jobs/restorefilesystemjob.cpp b/src/jobs/restorefilesystemjob.cpp index 9151eaa..14baed0 100644 --- a/src/jobs/restorefilesystemjob.cpp +++ b/src/jobs/restorefilesystemjob.cpp @@ -71,9 +71,9 @@ bool RestoreFileSystemJob::run(Report& parent) CopySourceFile copySource(fileName(), copyTarget.sectorSize()); if (!copySource.open()) - report->line() << i18nc("@info/plain", "Could not open backup file %1 to restore from.", fileName()); + report->line() << xi18nc("@info/plain", "Could not open backup file %1 to restore from.", fileName()); else if (!copyTarget.open()) - report->line() << i18nc("@info/plain", "Could not open target partition %1 to restore to.", targetPartition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open target partition %1 to restore to.", targetPartition().deviceNode()); else { rval = copyBlocks(*report, copyTarget, copySource); @@ -112,5 +112,5 @@ bool RestoreFileSystemJob::run(Report& parent) QString RestoreFileSystemJob::description() const { - return i18nc("@info/plain", "Restore the file system from file %1 to partition %2", fileName(), targetPartition().deviceNode()); + return xi18nc("@info/plain", "Restore the file system from file %1 to partition %2", fileName(), targetPartition().deviceNode()); } diff --git a/src/jobs/setfilesystemlabeljob.cpp b/src/jobs/setfilesystemlabeljob.cpp index ca9aa81..7a67d1d 100644 --- a/src/jobs/setfilesystemlabeljob.cpp +++ b/src/jobs/setfilesystemlabeljob.cpp @@ -48,7 +48,7 @@ bool SetFileSystemLabelJob::run(Report& parent) // just ignore the request and say all is well. This helps in operations because // we don't have to check for support to avoid having a failed job. if (partition().fileSystem().supportSetLabel() == FileSystem::cmdSupportNone) - report->line() << i18nc("@info/plain", "File system on partition %1 does not support setting labels. Job ignored.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "File system on partition %1 does not support setting labels. Job ignored.", partition().deviceNode()); else if (partition().fileSystem().supportSetLabel() == FileSystem::cmdSupportFileSystem) { rval = partition().fileSystem().writeLabel(*report, partition().deviceNode(), label()); @@ -64,5 +64,5 @@ bool SetFileSystemLabelJob::run(Report& parent) QString SetFileSystemLabelJob::description() const { - return i18nc("@info/plain", "Set the file system label on partition %1 to \"%2\"", partition().deviceNode(), label()); + return xi18nc("@info/plain", "Set the file system label on partition %1 to \"%2\"", partition().deviceNode(), label()); } diff --git a/src/jobs/setpartflagsjob.cpp b/src/jobs/setpartflagsjob.cpp index 3841ae2..40a680d 100644 --- a/src/jobs/setpartflagsjob.cpp +++ b/src/jobs/setpartflagsjob.cpp @@ -82,7 +82,7 @@ bool SetPartFlagsJob::run(Report& parent) if (!backendPartition->setFlag(*report, f, state)) { - report->line() << i18nc("@info/plain", "There was an error setting flag %1 for partition %2 to state %3.", PartitionTable::flagName(f), partition().deviceNode(), state ? i18nc("@info/plain flag turned on, active", "on") : i18nc("@info/plain flag turned off, inactive", "off")); + report->line() << xi18nc("@info/plain", "There was an error setting flag %1 for partition %2 to state %3.", PartitionTable::flagName(f), partition().deviceNode(), state ? i18nc("@info/plain flag turned on, active", "on") : i18nc("@info/plain flag turned off, inactive", "off")); rval = false; } @@ -91,7 +91,7 @@ bool SetPartFlagsJob::run(Report& parent) delete backendPartition; } else - report->line() << i18nc("@info/plain", "Could not find partition %1 on device %2 to set partition flags.", partition().deviceNode(), device().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not find partition %1 on device %2 to set partition flags.", partition().deviceNode(), device().deviceNode()); if (rval) backendPartitionTable->commit(); @@ -99,12 +99,12 @@ bool SetPartFlagsJob::run(Report& parent) delete backendPartitionTable; } else - report->line() << i18nc("@info/plain", "Could not open partition table on device %1 to set partition flags for partition %2.", device().deviceNode(), partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open partition table on device %1 to set partition flags for partition %2.", device().deviceNode(), partition().deviceNode()); delete backendDevice; } else - report->line() << i18nc("@info/plain", "Could not open device %1 to set partition flags for partition %2.", device().deviceNode(), partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open device %1 to set partition flags for partition %2.", device().deviceNode(), partition().deviceNode()); if (rval) partition().setFlags(flags()); @@ -117,7 +117,7 @@ bool SetPartFlagsJob::run(Report& parent) QString SetPartFlagsJob::description() const { if (PartitionTable::flagNames(flags()).size() == 0) - return QString(i18nc("@info/plain", "Clear flags for partition %1", partition().deviceNode())); + return QString(xi18nc("@info/plain", "Clear flags for partition %1", partition().deviceNode())); - return i18nc("@info/plain", "Set the flags for partition %1 to \"%2\"", partition().deviceNode(), PartitionTable::flagNames(flags()).join(",")); + return xi18nc("@info/plain", "Set the flags for partition %1 to \"%2\"", partition().deviceNode(), PartitionTable::flagNames(flags()).join(",")); } diff --git a/src/jobs/setpartgeometryjob.cpp b/src/jobs/setpartgeometryjob.cpp index 20b5dbf..1a7901b 100644 --- a/src/jobs/setpartgeometryjob.cpp +++ b/src/jobs/setpartgeometryjob.cpp @@ -78,7 +78,7 @@ bool SetPartGeometryJob::run(Report& parent) delete backendDevice; } else - report->line() << i18nc("@info/plain", "Could not open device %1 while trying to resize/move partition %2.", device().deviceNode(), partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open device %1 while trying to resize/move partition %2.", device().deviceNode(), partition().deviceNode()); jobFinished(*report, rval); @@ -87,5 +87,5 @@ bool SetPartGeometryJob::run(Report& parent) QString SetPartGeometryJob::description() const { - return i18nc("@info/plain", "Set geometry of partition %1: Start sector: %2, length: %3", partition().deviceNode(), newStart(), newLength()); + return xi18nc("@info/plain", "Set geometry of partition %1: Start sector: %2, length: %3", partition().deviceNode(), newStart(), newLength()); } diff --git a/src/jobs/shredfilesystemjob.cpp b/src/jobs/shredfilesystemjob.cpp index f142810..0f83d88 100644 --- a/src/jobs/shredfilesystemjob.cpp +++ b/src/jobs/shredfilesystemjob.cpp @@ -71,7 +71,7 @@ bool ShredFileSystemJob::run(Report& parent) if (!copySource.open()) report->line() << i18nc("@info/plain", "Could not open random data source to overwrite file system."); else if (!copyTarget.open()) - report->line() << i18nc("@info/plain", "Could not open target partition %1 to restore to.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Could not open target partition %1 to restore to.", partition().deviceNode()); else { rval = copyBlocks(*report, copyTarget, copySource); @@ -86,5 +86,5 @@ bool ShredFileSystemJob::run(Report& parent) QString ShredFileSystemJob::description() const { - return i18nc("@info/plain", "Shred the file system on %1", partition().deviceNode()); + return xi18nc("@info/plain", "Shred the file system on %1", partition().deviceNode()); } diff --git a/src/main.cpp b/src/main.cpp index 9248497..da99305 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,24 +24,35 @@ #include "util/helpers.h" -#include -#include -#include -#include +#include +#include + +#include +#include #include #include -int main(int argc, char* argv[]) +int Q_DECL_IMPORT main(int argc, char* argv[]) { - KCmdLineArgs::init(argc, argv, createPartitionManagerAboutData()); - KCmdLineOptions options; - options.add("dontsu", ki18nc("@info:shell", "Do not try to gain super user privileges")); - options.add("advconfig", ki18nc("@info:shell", "Show advanced tab in configuration dialog")); - options.add("+[device]", ki18nc("@info:shell", "Device(s) to manage")); - KCmdLineArgs::addCmdLineOptions(options); + QApplication app(argc, argv); + KAboutData *aboutData = createPartitionManagerAboutData(); + KAboutData::setApplicationData(*aboutData); - KApplication app; + app.setApplicationName(aboutData->componentName()); + app.setApplicationDisplayName(aboutData->displayName()); + app.setOrganizationDomain(aboutData->organizationDomain()); + app.setApplicationVersion(aboutData->version()); + + QCommandLineParser parser; + parser.setApplicationDescription( aboutData->shortDescription() ); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addOption( QCommandLineOption( QLatin1Literal("dontsu"), i18nc("@info:shell", "Do not try to gain super user privileges"))); + parser.addOption( QCommandLineOption( QLatin1Literal("advconfig"), i18nc("@info:shell", "Show advanced tab in configuration dialog"))); + parser.addPositionalArgument( QStringLiteral("device"), i18nc("@info:shell", "Device(s) to manage"), QStringLiteral("[device...]") ); + + parser.process(app); registerMetaTypes(); if (!checkPermissions()) diff --git a/src/ops/backupoperation.cpp b/src/ops/backupoperation.cpp index f520f29..a42bb68 100644 --- a/src/ops/backupoperation.cpp +++ b/src/ops/backupoperation.cpp @@ -47,7 +47,7 @@ BackupOperation::BackupOperation(Device& d, Partition& p, const QString& filenam QString BackupOperation::description() const { - return QString(i18nc("@info/plain", "Backup partition %1 (%2, %3) to %4", backupPartition().deviceNode(), Capacity::formatByteSize(backupPartition().capacity()), backupPartition().fileSystem().name(), fileName())); + return QString(xi18nc("@info/plain", "Backup partition %1 (%2, %3) to %4", backupPartition().deviceNode(), Capacity::formatByteSize(backupPartition().capacity()), backupPartition().fileSystem().name(), fileName())); } /** Can the given Partition be backed up? diff --git a/src/ops/checkoperation.cpp b/src/ops/checkoperation.cpp index 2e6c4af..808aa68 100644 --- a/src/ops/checkoperation.cpp +++ b/src/ops/checkoperation.cpp @@ -58,7 +58,7 @@ bool CheckOperation::targets(const Partition& p) const QString CheckOperation::description() const { - return QString(i18nc("@info/plain", "Check and repair partition %1 (%2, %3)", checkedPartition().deviceNode(), Capacity::formatByteSize(checkedPartition().capacity()), checkedPartition().fileSystem().name())); + return QString(xi18nc("@info/plain", "Check and repair partition %1 (%2, %3)", checkedPartition().deviceNode(), Capacity::formatByteSize(checkedPartition().capacity()), checkedPartition().fileSystem().name())); } /** Can a Partition be checked? diff --git a/src/ops/copyoperation.cpp b/src/ops/copyoperation.cpp index f34b9c9..cbeade6 100644 --- a/src/ops/copyoperation.cpp +++ b/src/ops/copyoperation.cpp @@ -162,12 +162,12 @@ bool CopyOperation::execute(Report& parent) // if maximizing doesn't work, just warn the user, don't fail if (!maximizeJob()->run(*report)) { - report->line() << i18nc("@info/plain", "Warning: Maximizing file system on target partition %1 to the size of the partition failed.", copiedPartition().deviceNode()); + report->line() << xi18nc("@info/plain", "Warning: Maximizing file system on target partition %1 to the size of the partition failed.", copiedPartition().deviceNode()); warning = true; } } else - report->line() << i18nc("@info/plain", "Checking target partition %1 after copy failed.", copiedPartition().deviceNode()); + report->line() << xi18nc("@info/plain", "Checking target partition %1 after copy failed.", copiedPartition().deviceNode()); } else { @@ -184,7 +184,7 @@ bool CopyOperation::execute(Report& parent) report->line() << i18nc("@info/plain", "Creating target partition for copying failed."); } else - report->line() << i18nc("@info/plain", "Checking source partition %1 failed.", sourcePartition().deviceNode()); + report->line() << xi18nc("@info/plain", "Checking source partition %1 failed.", sourcePartition().deviceNode()); if (rval) setStatus(warning ? StatusFinishedWarning : StatusFinishedSuccess); @@ -201,7 +201,7 @@ QString CopyOperation::updateDescription() const if (overwrittenPartition()) { if (copiedPartition().length() == overwrittenPartition()->length()) - return QString(i18nc("@info/plain", "Copy partition %1 (%2, %3) to %4 (%5, %6)", + return QString(xi18nc("@info/plain", "Copy partition %1 (%2, %3) to %4 (%5, %6)", sourcePartition().deviceNode(), Capacity::formatByteSize(sourcePartition().capacity()), sourcePartition().fileSystem().name(), @@ -210,7 +210,7 @@ QString CopyOperation::updateDescription() const overwrittenPartition()->fileSystem().name() )); - return QString(i18nc("@info/plain", "Copy partition %1 (%2, %3) to %4 (%5, %6) and grow it to %7", + return QString(xi18nc("@info/plain", "Copy partition %1 (%2, %3) to %4 (%5, %6) and grow it to %7", sourcePartition().deviceNode(), Capacity::formatByteSize(sourcePartition().capacity()), sourcePartition().fileSystem().name(), @@ -222,7 +222,7 @@ QString CopyOperation::updateDescription() const } if (copiedPartition().length() == sourcePartition().length()) - return QString(i18nc("@info/plain", "Copy partition %1 (%2, %3) to unallocated space (starting at %4) on %5", + return QString(xi18nc("@info/plain", "Copy partition %1 (%2, %3) to unallocated space (starting at %4) on %5", sourcePartition().deviceNode(), Capacity::formatByteSize(sourcePartition().capacity()), sourcePartition().fileSystem().name(), @@ -230,7 +230,7 @@ QString CopyOperation::updateDescription() const targetDevice().deviceNode() )); - return QString(i18nc("@info/plain", "Copy partition %1 (%2, %3) to unallocated space (starting at %4) on %5 and grow it to %6", + return QString(xi18nc("@info/plain", "Copy partition %1 (%2, %3) to unallocated space (starting at %4) on %5 and grow it to %6", sourcePartition().deviceNode(), Capacity::formatByteSize(sourcePartition().capacity()), sourcePartition().fileSystem().name(), diff --git a/src/ops/createfilesystemoperation.cpp b/src/ops/createfilesystemoperation.cpp index 2cae070..6a29a64 100644 --- a/src/ops/createfilesystemoperation.cpp +++ b/src/ops/createfilesystemoperation.cpp @@ -93,5 +93,5 @@ bool CreateFileSystemOperation::execute(Report& parent) QString CreateFileSystemOperation::description() const { - return QString(i18nc("@info/plain", "Create filesystem %1 on partition %2", newFileSystem()->name(), partition().deviceNode())); + return QString(xi18nc("@info/plain", "Create filesystem %1 on partition %2", newFileSystem()->name(), partition().deviceNode())); } diff --git a/src/ops/createpartitiontableoperation.cpp b/src/ops/createpartitiontableoperation.cpp index e225a48..dcc5a6d 100644 --- a/src/ops/createpartitiontableoperation.cpp +++ b/src/ops/createpartitiontableoperation.cpp @@ -99,5 +99,5 @@ bool CreatePartitionTableOperation::canCreate(const Device* device) QString CreatePartitionTableOperation::description() const { - return QString(i18nc("@info/plain", "Create a new partition table (type: %1) on %2", partitionTable()->typeName(), targetDevice().deviceNode())); + return QString(xi18nc("@info/plain", "Create a new partition table (type: %1) on %2", partitionTable()->typeName(), targetDevice().deviceNode())); } diff --git a/src/ops/deleteoperation.cpp b/src/ops/deleteoperation.cpp index e3d2c71..7ef4013 100644 --- a/src/ops/deleteoperation.cpp +++ b/src/ops/deleteoperation.cpp @@ -82,9 +82,9 @@ void DeleteOperation::undo() QString DeleteOperation::description() const { if (isSecure()) - return QString(i18nc("@info/plain", "Shred partition %1 (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name())); + return QString(xi18nc("@info/plain", "Shred partition %1 (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name())); else - return QString(i18nc("@info/plain", "Delete partition %1 (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name())); + return QString(xi18nc("@info/plain", "Delete partition %1 (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name())); } void DeleteOperation::checkAdjustLogicalNumbers(Partition& p, bool undo) diff --git a/src/ops/newoperation.cpp b/src/ops/newoperation.cpp index 93ea97d..ce61f8b 100644 --- a/src/ops/newoperation.cpp +++ b/src/ops/newoperation.cpp @@ -109,7 +109,7 @@ void NewOperation::undo() QString NewOperation::description() const { - return QString(i18nc("@info/plain", "Create a new partition (%1, %2) on %3", Capacity::formatByteSize(newPartition().capacity()), newPartition().fileSystem().name(), targetDevice().deviceNode())); + return QString(xi18nc("@info/plain", "Create a new partition (%1, %2) on %3", Capacity::formatByteSize(newPartition().capacity()), newPartition().fileSystem().name(), targetDevice().deviceNode())); } /** Can a Partition be created somewhere? diff --git a/src/ops/operation.cpp b/src/ops/operation.cpp index 10b639f..b745fb4 100644 --- a/src/ops/operation.cpp +++ b/src/ops/operation.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include Operation::Operation() : @@ -115,7 +115,7 @@ QIcon Operation::statusIcon() const if (status() == StatusNone) return QIcon(); - return SmallIcon(icons[status()]); + return QIcon(KIconLoader().loadIcon(icons[status()], KIconLoader::Small)); } void Operation::addJob(Job* job) diff --git a/src/ops/resizeoperation.cpp b/src/ops/resizeoperation.cpp index 76ba4ba..8a0f22e 100644 --- a/src/ops/resizeoperation.cpp +++ b/src/ops/resizeoperation.cpp @@ -162,7 +162,7 @@ bool ResizeOperation::execute(Report& parent) if (moveExtendedJob()) { if (!(rval = moveExtendedJob()->run(*report))) - report->line() << i18nc("@info/plain", "Moving extended partition %1 failed.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Moving extended partition %1 failed.", partition().deviceNode()); } else { @@ -172,14 +172,14 @@ bool ResizeOperation::execute(Report& parent) if (rval) { if (!(rval = checkResizedJob()->run(*report))) - report->line() << i18nc("@info/plain", "Checking partition %1 after resize/move failed.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Checking partition %1 after resize/move failed.", partition().deviceNode()); } else - report->line() << i18nc("@info/plain", "Resizing/moving partition %1 failed.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Resizing/moving partition %1 failed.", partition().deviceNode()); } } else - report->line() << i18nc("@info/plain", "Checking partition %1 before resize/move failed.", partition().deviceNode()); + report->line() << xi18nc("@info/plain", "Checking partition %1 before resize/move failed.", partition().deviceNode()); setStatus(rval ? StatusFinishedSuccess : StatusError); @@ -210,28 +210,28 @@ QString ResizeOperation::description() const switch(resizeAction()) { case MoveLeft: - return i18nc("@info/plain describe resize/move action", "Move partition %1 to the left by %2", partition().deviceNode(), moveDelta); + return xi18nc("@info/plain describe resize/move action", "Move partition %1 to the left by %2", partition().deviceNode(), moveDelta); case MoveRight: - return i18nc("@info/plain describe resize/move action", "Move partition %1 to the right by %2", partition().deviceNode(), moveDelta); + return xi18nc("@info/plain describe resize/move action", "Move partition %1 to the right by %2", partition().deviceNode(), moveDelta); case Grow: - return i18nc("@info/plain describe resize/move action", "Grow partition %1 from %2 to %3", partition().deviceNode(), origCapacity, newCapacity); + return xi18nc("@info/plain describe resize/move action", "Grow partition %1 from %2 to %3", partition().deviceNode(), origCapacity, newCapacity); case Shrink: - return i18nc("@info/plain describe resize/move action", "Shrink partition %1 from %2 to %3", partition().deviceNode(), origCapacity, newCapacity); + return xi18nc("@info/plain describe resize/move action", "Shrink partition %1 from %2 to %3", partition().deviceNode(), origCapacity, newCapacity); case MoveLeftGrow: - return i18nc("@info/plain describe resize/move action", "Move partition %1 to the left by %2 and grow it from %3 to %4", partition().deviceNode(), moveDelta, origCapacity, newCapacity); + return xi18nc("@info/plain describe resize/move action", "Move partition %1 to the left by %2 and grow it from %3 to %4", partition().deviceNode(), moveDelta, origCapacity, newCapacity); case MoveRightGrow: - return i18nc("@info/plain describe resize/move action", "Move partition %1 to the right by %2 and grow it from %3 to %4", partition().deviceNode(), moveDelta, origCapacity, newCapacity); + return xi18nc("@info/plain describe resize/move action", "Move partition %1 to the right by %2 and grow it from %3 to %4", partition().deviceNode(), moveDelta, origCapacity, newCapacity); case MoveLeftShrink: - return i18nc("@info/plain describe resize/move action", "Move partition %1 to the left by %2 and shrink it from %3 to %4", partition().deviceNode(), moveDelta, origCapacity, newCapacity); + return xi18nc("@info/plain describe resize/move action", "Move partition %1 to the left by %2 and shrink it from %3 to %4", partition().deviceNode(), moveDelta, origCapacity, newCapacity); case MoveRightShrink: - return i18nc("@info/plain describe resize/move action", "Move partition %1 to the right by %2 and shrink it from %3 to %4", partition().deviceNode(), moveDelta, origCapacity, newCapacity); + return xi18nc("@info/plain describe resize/move action", "Move partition %1 to the right by %2 and shrink it from %3 to %4", partition().deviceNode(), moveDelta, origCapacity, newCapacity); default: qWarning() << "Could not determine what to do with partition " << partition().deviceNode() << "."; @@ -268,13 +268,13 @@ bool ResizeOperation::shrink(Report& report) { if (shrinkResizeJob() && !shrinkResizeJob()->run(report)) { - report.line() << i18nc("@info/plain", "Resize/move failed: Could not resize file system to shrink partition %1.", partition().deviceNode()); + report.line() << xi18nc("@info/plain", "Resize/move failed: Could not resize file system to shrink partition %1.", partition().deviceNode()); return false; } if (shrinkSetGeomJob() && !shrinkSetGeomJob()->run(report)) { - report.line() << i18nc("@info/plain", "Resize/move failed: Could not shrink partition %1.", partition().deviceNode()); + report.line() << xi18nc("@info/plain", "Resize/move failed: Could not shrink partition %1.", partition().deviceNode()); return false; /** @todo if this fails, no one undoes the shrinking of the file system above, because we @@ -294,17 +294,17 @@ bool ResizeOperation::move(Report& report) const qint64 oldStart = partition().firstSector(); if (moveSetGeomJob() && !moveSetGeomJob()->run(report)) { - report.line() << i18nc("@info/plain", "Moving partition %1 failed.", partition().deviceNode()); + report.line() << xi18nc("@info/plain", "Moving partition %1 failed.", partition().deviceNode()); return false; } if (moveFileSystemJob() && !moveFileSystemJob()->run(report)) { - report.line() << i18nc("@info/plain", "Moving the filesystem for partition %1 failed. Rolling back.", partition().deviceNode()); + report.line() << xi18nc("@info/plain", "Moving the filesystem for partition %1 failed. Rolling back.", partition().deviceNode()); // see above: We now have to move back the partition itself. if (!SetPartGeometryJob(targetDevice(), partition(), oldStart, partition().length()).run(report)) - report.line() << i18nc("@info/plain", "Moving back partition %1 to its original position failed.", partition().deviceNode()); + report.line() << xi18nc("@info/plain", "Moving back partition %1 to its original position failed.", partition().deviceNode()); return false; } @@ -318,16 +318,16 @@ bool ResizeOperation::grow(Report& report) if (growSetGeomJob() && !growSetGeomJob()->run(report)) { - report.line() << i18nc("@info/plain", "Resize/move failed: Could not grow partition %1.", partition().deviceNode()); + report.line() << xi18nc("@info/plain", "Resize/move failed: Could not grow partition %1.", partition().deviceNode()); return false; } if (growResizeJob() && !growResizeJob()->run(report)) { - report.line() << i18nc("@info/plain", "Resize/move failed: Could not resize the file system on partition %1", partition().deviceNode()); + report.line() << xi18nc("@info/plain", "Resize/move failed: Could not resize the file system on partition %1", partition().deviceNode()); if (!SetPartGeometryJob(targetDevice(), partition(), partition().firstSector(), oldLength).run(report)) - report.line() << i18nc("@info/plain", "Could not restore old partition size for partition %1.", partition().deviceNode()); + report.line() << xi18nc("@info/plain", "Could not restore old partition size for partition %1.", partition().deviceNode()); return false; } diff --git a/src/ops/restoreoperation.cpp b/src/ops/restoreoperation.cpp index a6cdc00..7534042 100644 --- a/src/ops/restoreoperation.cpp +++ b/src/ops/restoreoperation.cpp @@ -141,10 +141,10 @@ bool RestoreOperation::execute(Report& parent) // or the image length, whichever is larger. If this fails, don't return an error, just // warn the user. if ((warning = !maximizeJob()->run(*report))) - report->line() << i18nc("@info/plain", "Warning: Maximizing file system on target partition %1 to the size of the partition failed.", restorePartition().deviceNode()); + report->line() << xi18nc("@info/plain", "Warning: Maximizing file system on target partition %1 to the size of the partition failed.", restorePartition().deviceNode()); } else - report->line() << i18nc("@info/plain", "Checking target file system on partition %1 after the restore failed.", restorePartition().deviceNode()); + report->line() << xi18nc("@info/plain", "Checking target file system on partition %1 after the restore failed.", restorePartition().deviceNode()); } else { @@ -170,9 +170,9 @@ bool RestoreOperation::execute(Report& parent) QString RestoreOperation::description() const { if (overwrittenPartition()) - return QString(i18nc("@info/plain", "Restore partition from %1 to %2", fileName(), overwrittenPartition()->deviceNode())); + return QString(xi18nc("@info/plain", "Restore partition from %1 to %2", fileName(), overwrittenPartition()->deviceNode())); - return QString(i18nc("@info/plain", "Restore partition on %1 at %2 from %3", targetDevice().deviceNode(), Capacity::formatByteSize(restorePartition().firstSector() * targetDevice().logicalSectorSize()), fileName())); + return QString(xi18nc("@info/plain", "Restore partition on %1 at %2 from %3", targetDevice().deviceNode(), Capacity::formatByteSize(restorePartition().firstSector() * targetDevice().logicalSectorSize()), fileName())); } void RestoreOperation::setOverwrittenPartition(Partition* p) diff --git a/src/ops/setfilesystemlabeloperation.cpp b/src/ops/setfilesystemlabeloperation.cpp index 014ad16..2cc216d 100644 --- a/src/ops/setfilesystemlabeloperation.cpp +++ b/src/ops/setfilesystemlabeloperation.cpp @@ -67,7 +67,7 @@ void SetFileSystemLabelOperation::undo() QString SetFileSystemLabelOperation::description() const { if (oldLabel().isEmpty()) - return QString(i18nc("@info/plain", "Set label for partition %1 to \"%2\"", labeledPartition().deviceNode(), newLabel())); + return QString(xi18nc("@info/plain", "Set label for partition %1 to \"%2\"", labeledPartition().deviceNode(), newLabel())); - return QString(i18nc("@info/plain", "Set label for partition %1 from \"%2\" to \"%3\"", labeledPartition().deviceNode(), oldLabel(), newLabel())); + return QString(xi18nc("@info/plain", "Set label for partition %1 from \"%2\" to \"%3\"", labeledPartition().deviceNode(), oldLabel(), newLabel())); } diff --git a/src/ops/setpartflagsoperation.cpp b/src/ops/setpartflagsoperation.cpp index 5e6b48b..ece6344 100644 --- a/src/ops/setpartflagsoperation.cpp +++ b/src/ops/setpartflagsoperation.cpp @@ -71,7 +71,7 @@ void SetPartFlagsOperation::undo() QString SetPartFlagsOperation::description() const { if (PartitionTable::flagNames(newFlags()).size() == 0) - return QString(i18nc("@info/plain", "Clear flags for partition %1", flagPartition().deviceNode())); - - return QString(i18nc("@info/plain", "Set flags for partition %1 to \"%2\"", flagPartition().deviceNode(), PartitionTable::flagNames(newFlags()).join(","))); + return QString(xi18nc("@info/plain", "Clear flags for partition %1", flagPartition().deviceNode())); + + return QString(xi18nc("@info/plain", "Set flags for partition %1 to \"%2\"", flagPartition().deviceNode(), PartitionTable::flagNames(newFlags()).join(","))); } diff --git a/src/plugins/dummy/CMakeLists.txt b/src/plugins/dummy/CMakeLists.txt index b58b25b..5fb260d 100644 --- a/src/plugins/dummy/CMakeLists.txt +++ b/src/plugins/dummy/CMakeLists.txt @@ -17,7 +17,7 @@ file (GLOB pmdummybackendplugin_SRCS *.cpp) -kde4_add_plugin(pmdummybackendplugin ${pmdummybackendplugin_SRCS}) +add_library(pmdummybackendplugin SHARED ${pmdummybackendplugin_SRCS}) target_link_libraries(pmdummybackendplugin partitionmanagerprivate ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} ${KDE4_SOLID_LIBS}) diff --git a/src/plugins/dummy/dummybackend.cpp b/src/plugins/dummy/dummybackend.cpp index a4d5970..969bc75 100644 --- a/src/plugins/dummy/dummybackend.cpp +++ b/src/plugins/dummy/dummybackend.cpp @@ -33,31 +33,28 @@ #include #include -#include -#include +#include +#include K_PLUGIN_FACTORY(DummyBackendFactory, registerPlugin(); ) static KAboutData createPluginAboutData() { KAboutData about( - "pmdummybackendplugin", - NULL, - ki18nc("@title", "Dummy Backend Plugin"), - QString(VERSION).toUtf8(), - ki18n("KDE Partition Manager dummy backend."), - KAboutData::License_GPL, - ki18n("Copyright 2010 Volker Lanz")); + QStringLiteral("pmdummybackendplugin"), + i18nc("@title", "Dummy Backend Plugin"), + "1.1.60", + i18n("KDE Partition Manager dummy backend."), + KAboutLicense::GPL, + i18n("Copyright 2010 Volker Lanz"), + QString()); - about.addAuthor(ki18nc("@info:credit", "Volker Lanz"), KLocalizedString(), "vl@fidra.de"); + about.addAuthor(i18nc("@info:credit", "Volker Lanz"), "Maintainer", "vl@fidra.de"); about.setHomepage("http://www.partitionmanager.org"); return about; } -K_EXPORT_PLUGIN(DummyBackendFactory(createPluginAboutData())) - - DummyBackend::DummyBackend(QObject*, const QList&) : CoreBackend() { @@ -120,3 +117,5 @@ bool DummyBackend::closeDevice(CoreBackendDevice* core_device) { return core_device->close(); } + +#include "dummybackend.moc" diff --git a/src/plugins/libparted/CMakeLists.txt b/src/plugins/libparted/CMakeLists.txt index 39b93fb..4c5583c 100644 --- a/src/plugins/libparted/CMakeLists.txt +++ b/src/plugins/libparted/CMakeLists.txt @@ -29,9 +29,9 @@ include_directories(${LIBPARTED_INCLUDE_DIR}) file (GLOB pmlibpartedbackendplugin_SRCS *.cpp) -kde4_add_plugin(pmlibpartedbackendplugin ${pmlibpartedbackendplugin_SRCS}) +add_library(pmlibpartedbackendplugin SHARED ${pmlibpartedbackendplugin_SRCS}) -target_link_libraries(pmlibpartedbackendplugin partitionmanagerprivate ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} ${KDE4_SOLID_LIBS}) +target_link_libraries(pmlibpartedbackendplugin partitionmanagerprivate ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} KF5::KIOCore) install(TARGETS pmlibpartedbackendplugin DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES pmlibpartedbackendplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/src/plugins/libparted/libpartedbackend.cpp b/src/plugins/libparted/libpartedbackend.cpp index 7c507f7..9f0af7e 100644 --- a/src/plugins/libparted/libpartedbackend.cpp +++ b/src/plugins/libparted/libpartedbackend.cpp @@ -44,15 +44,15 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -63,22 +63,20 @@ K_PLUGIN_FACTORY(LibPartedBackendFactory, registerPlugin(); ) static KAboutData createPluginAboutData() { KAboutData about( - "pmlibpartedbackendplugin", - NULL, - ki18nc("@title", "LibParted Backend Plugin"), + QStringLiteral("pmlibpartedbackendplugin"), + i18nc("@title", "LibParted Backend Plugin"), QString("%1, libparted version: %2").arg(VERSION).arg(ped_get_version()).toUtf8(), - ki18n("KDE Partition Manager backend for libparted."), - KAboutData::License_GPL, - ki18n("Copyright 2008,2009,2010 Volker Lanz")); + i18n("KDE Partition Manager backend for libparted."), + KAboutLicense::GPL, + i18n("Copyright 2008,2009,2010 Volker Lanz"), + QString()); - about.addAuthor(ki18nc("@info:credit", "Volker Lanz"), KLocalizedString(), "vl@fidra.de"); + about.addAuthor(i18nc("@info:credit", "Volker Lanz"), "Maintainer", "vl@fidra.de"); about.setHomepage("http://www.partitionmanager.org"); return about; } -K_EXPORT_PLUGIN(LibPartedBackendFactory(createPluginAboutData())) - static struct { PedPartitionFlag pedFlag; @@ -419,7 +417,7 @@ Device* LibPartedBackend::scanDevice(const QString& device_node) if (pedDevice == NULL) { - Log(Log::warning) << i18nc("@info/plain", "Could not access device %1", device_node); + Log(Log::warning) << xi18nc("@info/plain", "Could not access device %1", device_node); return NULL; } @@ -605,3 +603,4 @@ PedPartitionFlag LibPartedBackend::getPedFlag(PartitionTable::Flag flag) return static_cast(-1); } +#include "libpartedbackend.moc" diff --git a/src/plugins/libparted/libpartedbackend.h b/src/plugins/libparted/libpartedbackend.h index 48cd344..2bcf721 100644 --- a/src/plugins/libparted/libpartedbackend.h +++ b/src/plugins/libparted/libpartedbackend.h @@ -24,6 +24,7 @@ #include "backend/corebackend.h" #include "core/partitiontable.h" +#include "util/libpartitionmanagerexport.h" #include "fs/filesystem.h" diff --git a/src/plugins/libparted/libparteddevice.cpp b/src/plugins/libparted/libparteddevice.cpp index ed207a3..bfaafdc 100644 --- a/src/plugins/libparted/libparteddevice.cpp +++ b/src/plugins/libparted/libparteddevice.cpp @@ -96,7 +96,7 @@ bool LibPartedDevice::createPartitionTable(Report& report, const PartitionTable& if (pedDiskType == NULL) { - report.line() << i18nc("@info/plain", "Creating partition table failed: Could not retrieve partition table type \"%1\" for %2.", ptable.typeName(), deviceNode()); + report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not retrieve partition table type \"%1\" for %2.", ptable.typeName(), deviceNode()); return false; } @@ -104,7 +104,7 @@ bool LibPartedDevice::createPartitionTable(Report& report, const PartitionTable& if (dev == NULL) { - report.line() << i18nc("@info/plain", "Creating partition table failed: Could not open backend device %1.", deviceNode()); + report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not open backend device %1.", deviceNode()); return false; } @@ -112,7 +112,7 @@ bool LibPartedDevice::createPartitionTable(Report& report, const PartitionTable& if (disk == NULL) { - report.line() << i18nc("@info/plain", "Creating partition table failed: Could not create a new partition table in the backend for device %1.", deviceNode()); + report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not create a new partition table in the backend for device %1.", deviceNode()); return false; } diff --git a/src/plugins/libparted/libpartedpartitiontable.cpp b/src/plugins/libparted/libpartedpartitiontable.cpp index 87d690b..51c6795 100644 --- a/src/plugins/libparted/libpartedpartitiontable.cpp +++ b/src/plugins/libparted/libpartedpartitiontable.cpp @@ -163,7 +163,7 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition if (pedType == static_cast(0xffffffff)) { - report.line() << i18nc("@info/plain", "Unknown partition role for new partition %1 (roles: %2)", partition.deviceNode(), partition.roles().toString()); + report.line() << xi18nc("@info/plain", "Unknown partition role for new partition %1 (roles: %2)", partition.deviceNode(), partition.roles().toString()); return ""; } @@ -173,7 +173,7 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition if (pedPartition == NULL) { - report.line() << i18nc("@info/plain", "Failed to create new partition %1.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Failed to create new partition %1.", partition.deviceNode()); return ""; } @@ -192,7 +192,7 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition if (ped_disk_add_partition(pedDisk(), pedPartition, pedConstraint)) rval = QString(ped_partition_get_path(pedPartition)); else - report.line() << i18nc("@info/plain", "Failed to add partition %1 to device %2.", partition.deviceNode(), pedDisk()->dev->path); + report.line() << xi18nc("@info/plain", "Failed to add partition %1 to device %2.", partition.deviceNode(), pedDisk()->dev->path); ped_constraint_destroy(pedConstraint); @@ -214,10 +214,10 @@ bool LibPartedPartitionTable::deletePartition(Report& report, const Partition& p rval = ped_disk_delete_partition(pedDisk(), pedPartition); if (!rval) - report.line() << i18nc("@info/plain", "Could not delete partition %1.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not delete partition %1.", partition.deviceNode()); } else - report.line() << i18nc("@info/plain", "Deleting partition failed: Partition to delete (%1) not found on disk.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Deleting partition failed: Partition to delete (%1) not found on disk.", partition.deviceNode()); return rval; } @@ -241,16 +241,16 @@ bool LibPartedPartitionTable::updateGeometry(Report& report, const Partition& pa if (ped_disk_set_partition_geom(pedDisk(), pedPartition, pedConstraint, sector_start, sector_end)) rval = true; else - report.line() << i18nc("@info/plain", "Could not set geometry for partition %1 while trying to resize/move it.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not set geometry for partition %1 while trying to resize/move it.", partition.deviceNode()); } else - report.line() << i18nc("@info/plain", "Could not get constraint for partition %1 while trying to resize/move it.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not get constraint for partition %1 while trying to resize/move it.", partition.deviceNode()); } else - report.line() << i18nc("@info/plain", "Could not get geometry for partition %1 while trying to resize/move it.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not get geometry for partition %1 while trying to resize/move it.", partition.deviceNode()); } else - report.line() << i18nc("@info/plain", "Could not open partition %1 while trying to resize/move it.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not open partition %1 while trying to resize/move it.", partition.deviceNode()); return rval; } @@ -269,7 +269,7 @@ bool LibPartedPartitionTable::clobberFileSystem(Report& report, const Partition& rval = ped_geometry_write(&pedPartition->geom, "0000000", 65536 / pedDevice()->sector_size, 1); if (!rval) - report.line() << i18nc("@info/plain", "Failed to erase filesystem signature on partition %1.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Failed to erase filesystem signature on partition %1.", partition.deviceNode()); ped_device_close(pedDevice()); } @@ -278,7 +278,7 @@ bool LibPartedPartitionTable::clobberFileSystem(Report& report, const Partition& rval = true; } else - report.line() << i18nc("@info/plain", "Could not delete file system on partition %1: Failed to get partition.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not delete file system on partition %1: Failed to get partition.", partition.deviceNode()); return rval; } @@ -306,18 +306,18 @@ bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition& ped_timer_destroy(pedTimer); if (!rval) - report.line() << i18nc("@info/plain", "Could not resize file system on partition %1.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not resize file system on partition %1.", partition.deviceNode()); } else - report.line() << i18nc("@info/plain", "Could not get geometry for resized partition %1 while trying to resize the file system.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not get geometry for resized partition %1 while trying to resize the file system.", partition.deviceNode()); ped_file_system_close(pedFileSystem); } else - report.line() << i18nc("@info/plain", "Could not open partition %1 while trying to resize the file system.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not open partition %1 while trying to resize the file system.", partition.deviceNode()); } else - report.line() << i18nc("@info/plain", "Could not read geometry for partition %1 while trying to resize the file system.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not read geometry for partition %1 while trying to resize the file system.", partition.deviceNode()); #else Q_UNUSED(report); Q_UNUSED(partition); @@ -336,7 +336,7 @@ FileSystem::Type LibPartedPartitionTable::detectFileSystemBySector(Report& repor if (pedPartition) rval = LibPartedBackend::detectFileSystem(pedPartition); else - report.line() << i18nc("@info/plain", "Could not determine file system of partition at sector %1 on device %2.", sector, device.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not determine file system of partition at sector %1 on device %2.", sector, device.deviceNode()); return rval; } @@ -346,10 +346,10 @@ bool LibPartedPartitionTable::setPartitionSystemType(Report& report, const Parti PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? NULL : getPedFileSystemType(partition.fileSystem().type()); PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector()); - + if (pedFsType == NULL || pedPartition == NULL) { - report.line() << i18nc("@info/plain", "Could not update the system type for partition %1.", partition.deviceNode()); + report.line() << xi18nc("@info/plain", "Could not update the system type for partition %1.", partition.deviceNode()); return false; } diff --git a/src/util/capacity.cpp b/src/util/capacity.cpp index e79c2eb..f088da6 100644 --- a/src/util/capacity.cpp +++ b/src/util/capacity.cpp @@ -22,8 +22,8 @@ #include "core/partition.h" #include "core/device.h" -#include -#include +#include +#include #include @@ -149,5 +149,5 @@ QString Capacity::formatByteSize(double size, int precision) { if (size < 0) return invalidString(); - return KGlobal::locale()->formatByteSize(size, precision); + return KFormat().formatByteSize(size, precision); } diff --git a/src/util/helpers.cpp b/src/util/helpers.cpp index 66c445c..6c26a2a 100644 --- a/src/util/helpers.cpp +++ b/src/util/helpers.cpp @@ -24,27 +24,25 @@ #include "ops/operation.h" -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include -#include -#include +#include #include -#include -#include +#include +#include #include +#include +#include +#include #include +#include +#include #include #include -#include #include @@ -59,13 +57,12 @@ void registerMetaTypes() static QString suCommand() { - KStandardDirs d; const char* candidates[] = { "kdesu", "kdesudo", "gksudo", "gksu" }; QString rval; for (quint32 i = 0; i < sizeof(candidates) / sizeof(candidates[0]); i++) { - rval = d.locate("exe", candidates[i]); + rval = QStandardPaths::findExecutable(candidates[i]); if (QFileInfo(rval).isExecutable()) return rval; } @@ -77,11 +74,10 @@ bool checkPermissions() { if (geteuid() != 0) { - KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); // 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() && !args->isSet("dontsu")) + if (!suCommand().isEmpty() && !QCoreApplication::arguments().contains(QLatin1String("--dontsu"))) { QStringList argList; @@ -93,18 +89,18 @@ bool checkPermissions() if (suCmd.indexOf("kdesu") != -1) argList << "-c"; - argList << args->allArguments().join(" ") + " --dontsu"; + argList << QCoreApplication::arguments() << " --dontsu"; if (QProcess::execute(suCmd, argList) == 0) return false; } - return KMessageBox::warningContinueCancel(NULL, i18nc("@info", + return KMessageBox::warningContinueCancel(NULL, xi18nc("@info", "You do not have administrative privileges." "It is possible to run %1 without these privileges. " "You will, however, not be allowed to apply operations." "Do you want to continue running %1?", - KGlobal::mainComponent().aboutData()->programName()), + QGuiApplication::applicationDisplayName()), i18nc("@title:window", "No administrative privileges"), KGuiItem(i18nc("@action:button", "Run without administrative privileges"), "arrow-right"), KStandardGuiItem::cancel(), @@ -117,20 +113,22 @@ bool checkPermissions() KAboutData* createPartitionManagerAboutData() { KAboutData* about = new KAboutData( - "partitionmanager", - NULL, - ki18nc("@title", "KDE Partition Manager"), - VERSION, - ki18nc("@title", "Manage your disks, partitions and file systems"), - KAboutData::License_GPL, - ki18nc("@info:credit", "(c) 2008, 2009, 2010, 2011 Volker Lanz") - ); + QStringLiteral("partitionmanager"), + xi18nc("@title", "KDE Partition Manager"), + QStringLiteral(VERSION), + i18nc("@title", "Manage your disks, partitions and file systems"), + KAboutLicense::GPL, + i18nc("@info:credit", "(c) 2008, 2009, 2010, 2011 Volker Lanz"), + QString()); + about->setOrganizationDomain(QByteArray("kde.org")); + about->setProgramIconName(QStringLiteral("partitionmanager")); + about->setProductName(QByteArray("partitionmanager")); - about->addAuthor(ki18nc("@info:credit", "Volker Lanz"), KLocalizedString(), "vl@fidra.de"); - about->setHomepage("http://www.partitionmanager.org"); + about->addAuthor(i18nc("@info:credit", "Volker Lanz"), QString(), QStringLiteral("vl@fidra.de")); + about->setHomepage(QStringLiteral("http://www.partitionmanager.org")); - about->addCredit(ki18n("Hugo Pereira Da Costa"), ki18nc("@info:credit", "Partition Widget Design"), "hugo@oxygen-icons.org"); - about->addCredit(ki18n("Andrius Štikonas"), ki18nc("@info:credit", "Btrfs support"), "stikonas@gmail.com"); + about->addCredit(i18n("Hugo Pereira Da Costa"), i18nc("@info:credit", "Partition Widget Design"), QStringLiteral("hugo@oxygen-icons.org")); + about->addCredit(i18n("Andrius Štikonas"), i18nc("@info:credit", "Btrfs support"), QStringLiteral("andrius@stikonas.eu")); return about; } @@ -142,7 +140,10 @@ bool caseInsensitiveLessThan(const QString& s1, const QString& s2) bool naturalLessThan(const QString& s1, const QString& s2) { - return KStringHandler::naturalCompare(s1, s2) < 0; + QCollator c; + c.setNumericMode(true); + c.setCaseSensitivity(Qt::CaseSensitive); + return c.compare(s1, s2) < 0; } QIcon createFileSystemColor(FileSystem::Type type, quint32 size) @@ -193,7 +194,7 @@ bool loadBackend() if (CoreBackendManager::self()->load(CoreBackendManager::defaultBackendName())) { KMessageBox::sorry(NULL, - i18nc("@info", "The configured backend plugin \"%1\" could not be loaded." + xi18nc("@info", "The configured backend plugin \"%1\" could not be loaded." "Loading the default backend plugin \"%2\" instead.", Config::backend(), CoreBackendManager::defaultBackendName()), i18nc("@title:window", "Error: Could Not Load Backend Plugin")); @@ -202,7 +203,7 @@ bool loadBackend() else { KMessageBox::error(NULL, - i18nc("@info", "Neither the configured (\"%1\") nor the default (\"%2\") backend " + xi18nc("@info", "Neither the configured (\"%1\") nor the default (\"%2\") backend " "plugin could be loaded.Please check your installation.", Config::backend(), CoreBackendManager::defaultBackendName()), i18nc("@title:window", "Error: Could Not Load Backend Plugin")); @@ -218,7 +219,7 @@ bool checkAccessibleDevices() if (getSolidDeviceList().empty()) { KMessageBox::error(NULL, - i18nc("@info", "No usable devices could be found.Make sure you have sufficient " + xi18nc("@info", "No usable devices could be found.Make sure you have sufficient " "privileges to access block devices on your system."), i18nc("@title:window", "Error: No Usable Devices Found")); return false; @@ -238,26 +239,27 @@ QList getSolidDeviceList() "[ StorageDrive.driveType == 'SdMmc' OR StorageDrive.driveType == 'Xd'] ]"; #endif - KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); - if (args->count() > 0) + QStringList argList; + int argc = argList.size(); + if (argc > 0) { predicate = " [ " + predicate + " AND "; - qint32 brackets = (args->count() + 1) / 2; - brackets = args->count() == 1 ? 0 : brackets; + qint32 brackets = (argc + 1) / 2; + brackets = argc == 1 ? 0 : brackets; for (qint32 i = 0; i < brackets; i++) predicate += "[ "; bool right_bracket = false; - for (qint32 i = 0; i < args->count(); i++, right_bracket =! right_bracket) + for (qint32 i = 0; i < argc; i++, right_bracket =! right_bracket) { - predicate += QString("Block.device == '%1' ").arg(args->arg(i)); + predicate += QString("Block.device == '%1' ").arg(argList[i]); if (right_bracket) predicate += i == 1 ? "] " : "] ] "; - if (i < args->count() - 1) + if (i < argc - 1) predicate += "OR "; - if (right_bracket && i != args->count() - 2 && i != args->count()-1) + if (right_bracket && i != argc - 2 && i != argc - 1) predicate += "[ "; } predicate += right_bracket && brackets > 0 ? "] ]" : "]"; diff --git a/src/util/htmlreport.cpp b/src/util/htmlreport.cpp index ef49aa2..c02836f 100644 --- a/src/util/htmlreport.cpp +++ b/src/util/htmlreport.cpp @@ -22,17 +22,15 @@ #include "backend/corebackend.h" #include "backend/corebackendmanager.h" -#include -#include -#include -#include -#include -#include - +#include +#include #include #include #include +#include +#include + #include #include @@ -42,8 +40,8 @@ QString HtmlReport::tableLine(const QString& label, const QString contents) QTextStream s(&rval); s << "
\n" - << QString("\n").arg(Qt::escape(label)) - << QString("\n").arg(Qt::escape(contents)) + << QString("\n").arg(QString(label).toHtmlEscaped()) + << QString("\n").arg(QString(contents).toHtmlEscaped()) << "\n"; s.flush(); @@ -62,14 +60,14 @@ QString HtmlReport::header() "\n" "\n" " " - << i18n("%1: SMART Status Report", Qt::escape(KGlobal::mainComponent().aboutData()->programName())) + << i18n("%1: SMART Status Report", QGuiApplication::applicationDisplayName().toHtmlEscaped()) << "\n" " \n" "\n\n" "\n"; s << "

" - << i18n("%1: SMART Status Report", Qt::escape(KGlobal::mainComponent().aboutData()->programName())) + << i18n("%1: SMART Status Report", QGuiApplication::applicationDisplayName().toHtmlEscaped()) << "

\n\n"; struct utsname info; @@ -78,9 +76,9 @@ QString HtmlReport::header() s << "
%1%1%1%1
\n" << tableLine(i18n("Date:"), QLocale().toString(QDateTime::currentDateTime(), QLocale::ShortFormat)) - << tableLine(i18n("Program version:"), KGlobal::mainComponent().aboutData()->version()) - << tableLine(i18n("Backend:"), QString("%1 (%2)").arg(CoreBackendManager::self()->backend()->about().programName()).arg(CoreBackendManager::self()->backend()->about().version())) - << tableLine(i18n("KDE version:"), KDE_VERSION_STRING) + << tableLine(i18n("Program version:"), QCoreApplication::applicationVersion()) +// << tableLine(i18n("Backend:"), QString("%1 (%2)").arg(CoreBackendManager::self()->backend()->about().displayName()).arg(CoreBackendManager::self()->backend()->about().version())) +// << tableLine(i18n("KDE version:"), KDE_VERSION_STRING) /* FIXME: port KF5 */ << tableLine(i18n("Machine:"), unameString) << "
\n
\n"; diff --git a/src/util/libpartitionmanagerexport.h b/src/util/libpartitionmanagerexport.h index 6baee6d..95d0e8a 100644 --- a/src/util/libpartitionmanagerexport.h +++ b/src/util/libpartitionmanagerexport.h @@ -16,14 +16,14 @@ * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include "libpartitionmanager_export.h" + #if !defined(LIBPARTITIONMANAGEREXPORT__H) #define LIBPARTITIONMANAGEREXPORT__H -#include - #if !defined(LIBPARTITIONMANAGERPRIVATE_EXPORT) -# define LIBPARTITIONMANAGERPRIVATE_EXPORT KDE_EXPORT + #define LIBPARTITIONMANAGERPRIVATE_EXPORT Q_DECL_EXPORT #endif #endif diff --git a/src/util/report.cpp b/src/util/report.cpp index a322efa..c9e8afd 100644 --- a/src/util/report.cpp +++ b/src/util/report.cpp @@ -25,12 +25,7 @@ #include -#include -#include -#include -#include #include -#include #include #include @@ -80,10 +75,10 @@ QString Report::toHtml() const s += "
\n"; if (!command().isEmpty()) - s += "\n" + Qt::escape(command()) + "\n\n"; + s += "\n" + QString(command()).toHtmlEscaped() + "\n\n"; if (!output().isEmpty()) - s += "
" + Qt::escape(output()) + "
\n\n"; + s += "
" + QString(output()).toHtmlEscaped() + "
\n\n"; if (children().size() == 0) s += "
\n"; @@ -92,7 +87,7 @@ QString Report::toHtml() const s += child->toHtml(); if (!status().isEmpty()) - s += "" + Qt::escape(status()) + "
\n\n"; + s += "" + QString(status()).toHtmlEscaped() + "
\n\n"; if (parent() != NULL) s += "
\n\n";