Merge the kpart stuff from branches/work/partitionmanager/kpartstuff and
disable it in the build by default. svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=902274
This commit is contained in:
parent
0d9d8bea7e
commit
80bee5cfc4
|
@ -15,27 +15,65 @@
|
|||
# Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
FILE(GLOB partitionmanager_SRCS
|
||||
############################################
|
||||
|
||||
FILE(GLOB partitionmanagerprivate_SRCS
|
||||
core/*.cpp
|
||||
gui/*.cpp
|
||||
util/*.cpp
|
||||
ops/*.cpp
|
||||
jobs/*.cpp
|
||||
fs/*.cpp
|
||||
main.cpp
|
||||
gui/*.cpp
|
||||
)
|
||||
|
||||
FILE(GLOB partitionmanager_UIFILES gui/*.ui)
|
||||
FILE(GLOB partitionmanagerprivate_UIFILES gui/*.ui)
|
||||
|
||||
KDE4_ADD_UI_FILES(partitionmanager_SRCS ${partitionmanager_UIFILES})
|
||||
KDE4_ADD_UI_FILES(partitionmanagerprivate_SRCS ${partitionmanagerprivate_UIFILES})
|
||||
|
||||
KDE4_ADD_KCFG_FILES(partitionmanager_SRCS config.kcfgc)
|
||||
KDE4_ADD_KCFG_FILES(partitionmanagerprivate_SRCS config.kcfgc)
|
||||
|
||||
KDE4_ADD_LIBRARY(partitionmanagerprivate SHARED ${partitionmanagerprivate_SRCS})
|
||||
|
||||
TARGET_LINK_LIBRARIES(partitionmanagerprivate ${KDE4_KDECORE_LIBS} ${KDE4_KFILE_LIBS} ${LIBPARTED_LIBS} ${UUID_LIBRARIES} ${BLKID_LIBRARIES})
|
||||
|
||||
INSTALL(TARGETS partitionmanagerprivate DESTINATION ${LIB_INSTALL_DIR})
|
||||
|
||||
############################################
|
||||
|
||||
FILE(GLOB partitionmanager_SRCS main.cpp)
|
||||
|
||||
KDE4_ADD_EXECUTABLE(partitionmanager ${partitionmanager_SRCS})
|
||||
|
||||
TARGET_LINK_LIBRARIES(partitionmanager ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${LIBPARTED_LIBS} ${UUID_LIBRARIES} ${BLKID_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(partitionmanager partitionmanagerprivate)
|
||||
|
||||
INSTALL(TARGETS partitionmanager ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
INSTALL(TARGETS partitionmanager DESTINATION ${BIN_INSTALL_DIR})
|
||||
INSTALL(FILES gui/partitionmanagerui.rc DESTINATION ${DATA_INSTALL_DIR}/partitionmanager)
|
||||
INSTALL(FILES partitionmanager.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
|
||||
|
||||
############################################
|
||||
|
||||
OPTION(PARTMAN_KPART "Build a kpart for KDE Partition Manager" OFF)
|
||||
|
||||
IF(PARTMAN_KPART)
|
||||
FILE(GLOB partitionmanagerpart_SRCS kpart/partitionmanagerpart.cpp)
|
||||
|
||||
KDE4_ADD_PLUGIN(partitionmanagerpart ${partitionmanagerpart_SRCS})
|
||||
|
||||
TARGET_LINK_LIBRARIES(partitionmanagerpart
|
||||
${KDE4_KPARTS_LIBS}
|
||||
${KDE4_KDECORE_LIBS}
|
||||
partitionmanagerprivate
|
||||
)
|
||||
|
||||
INSTALL(TARGETS partitionmanagerpart DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
INSTALL(FILES kpart/partitionmanagerpart.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
INSTALL(FILES kpart/partitionmanagerpart.rc DESTINATION ${DATA_INSTALL_DIR}/partitionmanagerpart)
|
||||
|
||||
OPTION(PARTMAN_KPART_TEST "Build a kpart test application for KDE Partition Manager" OFF)
|
||||
|
||||
IF(PARTMAN_KPART_TEST)
|
||||
ADD_SUBDIRECTORY(kpart/test)
|
||||
ENDIF(PARTMAN_KPART_TEST)
|
||||
|
||||
ENDIF(PARTMAN_KPART)
|
||||
|
||||
|
|
|
@ -89,8 +89,9 @@ class PartitionTreeWidgetItem : public QTreeWidgetItem
|
|||
|
||||
/** Creates a new MainWindow instance.
|
||||
@param parent the parent widget
|
||||
@param coll an action collection if used as a KPart
|
||||
*/
|
||||
MainWindow::MainWindow(QWidget* parent) :
|
||||
MainWindow::MainWindow(QWidget* parent, KActionCollection* coll) :
|
||||
KXmlGuiWindow(parent),
|
||||
Ui::MainWindowBase(),
|
||||
m_LibParted(),
|
||||
|
@ -99,7 +100,8 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||
m_StatusText(new QLabel(this)),
|
||||
m_InfoPane(new InfoPane(this)),
|
||||
m_ClipboardPartition(NULL),
|
||||
m_ProgressDialog(new ProgressDialog(this, operationRunner()))
|
||||
m_ProgressDialog(new ProgressDialog(this, operationRunner())),
|
||||
m_ActionCollection(coll)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
|
@ -110,7 +112,12 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||
setupStatusBar();
|
||||
setupConnections();
|
||||
|
||||
setupGUI();
|
||||
// If we were called with an action collection we're supposed to be a KPart, so don't
|
||||
// create the GUI in that case.
|
||||
if (coll != NULL)
|
||||
setupGUI(ToolBar | Keys | StatusBar | Save);
|
||||
else
|
||||
setupGUI(ToolBar | Keys | StatusBar | Save | Create);
|
||||
|
||||
loadConfig();
|
||||
|
||||
|
@ -158,6 +165,11 @@ void MainWindow::changeEvent(QEvent* event)
|
|||
KXmlGuiWindow::changeEvent(event);
|
||||
}
|
||||
|
||||
KActionCollection* MainWindow::actionCollection() const
|
||||
{
|
||||
return m_ActionCollection != NULL ? m_ActionCollection : KXmlGuiWindow::actionCollection();
|
||||
}
|
||||
|
||||
void MainWindow::setupActions()
|
||||
{
|
||||
// File actions
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#define MAINWINDOW__H
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
#include "ui_mainwindowbase.h"
|
||||
|
||||
#include "core/libparted.h"
|
||||
|
@ -39,17 +41,18 @@ class QCloseEvent;
|
|||
class QEvent;
|
||||
class Device;
|
||||
class ProgressDialog;
|
||||
class KActionCollection;
|
||||
|
||||
/** @brief The application's main window.
|
||||
|
||||
@author vl@fidra.de
|
||||
*/
|
||||
class MainWindow : public KXmlGuiWindow, public Ui::MainWindowBase
|
||||
class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, public Ui::MainWindowBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget* parent = NULL);
|
||||
MainWindow(QWidget* parent = NULL, KActionCollection* coll = NULL);
|
||||
|
||||
signals:
|
||||
void devicesChanged();
|
||||
|
@ -74,6 +77,8 @@ class MainWindow : public KXmlGuiWindow, public Ui::MainWindowBase
|
|||
Device* selectedDevice();
|
||||
Partition* selectedPartition();
|
||||
|
||||
KActionCollection* actionCollection() const;
|
||||
|
||||
InfoPane& infoPane() { Q_ASSERT(m_InfoPane); return *m_InfoPane; }
|
||||
|
||||
PartTableWidget& partTableWidget() { Q_ASSERT(m_PartTableWidget); return *m_PartTableWidget; }
|
||||
|
@ -163,6 +168,7 @@ class MainWindow : public KXmlGuiWindow, public Ui::MainWindowBase
|
|||
InfoPane* m_InfoPane;
|
||||
Partition* m_ClipboardPartition;
|
||||
ProgressDialog* m_ProgressDialog;
|
||||
KActionCollection* m_ActionCollection;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kpart/partitionmanagerpart.h"
|
||||
|
||||
#include "gui/mainwindow.h"
|
||||
|
||||
#include "util/helpers.h"
|
||||
|
||||
#include <kpluginfactory.h>
|
||||
|
||||
K_PLUGIN_FACTORY(PartitionManagerPartFactory, registerPlugin<PartitionManagerPart>("PartitionManagerPart");)
|
||||
K_EXPORT_PLUGIN(PartitionManagerPartFactory("partitionmanagerpart", "partitionmanager"))
|
||||
|
||||
PartitionManagerPart::PartitionManagerPart(QWidget*, QObject* parent, const QVariantList&) :
|
||||
KParts::ReadOnlyPart(parent),
|
||||
m_MainWindow(NULL)
|
||||
{
|
||||
setComponentData(PartitionManagerPartFactory::componentData(), false);
|
||||
|
||||
// workaround for https://bugs.launchpad.net/kdesudo/+bug/272427
|
||||
unblockSigChild();
|
||||
|
||||
registerMetaTypes();
|
||||
|
||||
setMainWindow(new MainWindow(NULL, actionCollection()));
|
||||
setWidget(&mainWindow());
|
||||
|
||||
setXMLFile("partitionmanagerpart.rc");
|
||||
}
|
||||
|
||||
KAboutData* PartitionManagerPart::createAboutData()
|
||||
{
|
||||
return createPartitionManagerAboutData();
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
[Desktop Entry]
|
||||
Type=Service
|
||||
Name=KDE Partition Manager
|
||||
Icon=
|
||||
|
||||
X-KDE-ServiceTypes=KParts/ReadOnlyPart
|
||||
X-KDE-Library=partitionmanagerpart
|
|
@ -0,0 +1,49 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if !defined(PARTITIONMANAGERPART__H)
|
||||
|
||||
#define PARTITIONMANAGERPART__H
|
||||
|
||||
#include <kparts/part.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
class KAboutData;
|
||||
class MainWindow;
|
||||
|
||||
class PartitionManagerPart : public KParts::ReadOnlyPart
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PartitionManagerPart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
|
||||
|
||||
public:
|
||||
static KAboutData* createAboutData();
|
||||
MainWindow& mainWindow() { Q_ASSERT(m_MainWindow != NULL); return *m_MainWindow; }
|
||||
|
||||
protected:
|
||||
virtual bool openFile() { return false; }
|
||||
void setMainWindow(MainWindow* m) { m_MainWindow = m; }
|
||||
|
||||
private:
|
||||
MainWindow* m_MainWindow;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||
|
||||
<kpartgui name="partitionmanagerpart" version="6">
|
||||
<ToolBar name="editToolBar">
|
||||
<text context="@title:menu turn on and off edit toolbar">Edit Toolbar</text>
|
||||
<Action name="applyAllOperations"/>
|
||||
<Action name="undoOperation"/>
|
||||
<Action name="clearAllOperations"/>
|
||||
</ToolBar>
|
||||
|
||||
<ToolBar name="partitionToolBar">
|
||||
<text context="@title:menu">Partition Toolbar</text>
|
||||
<Action name="newPartition"/>
|
||||
<Action name="resizePartition"/>
|
||||
<Action name="copyPartition"/>
|
||||
<Action name="pastePartition"/>
|
||||
<Action name="deletePartition"/>
|
||||
<Action name="checkPartition"/>
|
||||
<Action name="propertiesPartition"/>
|
||||
</ToolBar>
|
||||
|
||||
<ToolBar name="deviceToolBar">
|
||||
<text context="@title:menu">Device Toolbar</text>
|
||||
<Action name="createNewPartitionTable"/>
|
||||
</ToolBar>
|
||||
|
||||
<MenuBar>
|
||||
<Menu name="edit">
|
||||
<text context="@title:menu">Edit</text>
|
||||
<Action name="undoOperation"/>
|
||||
<Action name="clearAllOperations"/>
|
||||
<Action name="applyAllOperations"/>
|
||||
</Menu>
|
||||
<Menu name="view">
|
||||
<text context="@title:menu">View</text>
|
||||
<Action name="toggleDockDevices"/>
|
||||
<Action name="toggleDockOperations"/>
|
||||
<Action name="toggleDockInformation"/>
|
||||
<Action name="toggleDockLog"/>
|
||||
<separator name="separator_7"/>
|
||||
<Action name="fileSystemSupport"/>
|
||||
<Action name="refreshDevices"/>
|
||||
</Menu>
|
||||
<Menu name="device">
|
||||
<text context="@title:menu">Device</text>
|
||||
<Action name="createNewPartitionTable"/>
|
||||
</Menu>
|
||||
<Menu name="partition">
|
||||
<text context="@title:menu">Partition</text>
|
||||
<Action name="newPartition"/>
|
||||
<Action name="resizePartition"/>
|
||||
<Action name="deletePartition"/>
|
||||
<separator name="separator_6"/>
|
||||
<Action name="copyPartition"/>
|
||||
<Action name="pastePartition"/>
|
||||
<separator name="separator_3"/>
|
||||
<Action name="mountPartition"/>
|
||||
<separator name="separator_4"/>
|
||||
<Action name="checkPartition"/>
|
||||
<separator name="separator_5"/>
|
||||
<Action name="backupPartition"/>
|
||||
<Action name="restorePartition"/>
|
||||
<separator name="separator_8"/>
|
||||
<Action name="propertiesPartition"/>
|
||||
</Menu>
|
||||
</MenuBar>
|
||||
|
||||
<StatusBar/>
|
||||
|
||||
</kpartgui>
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# Copyright (C) 2008 by Volker Lanz <vl@fidra.de>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the
|
||||
# Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
FIND_PACKAGE(KDE4 REQUIRED)
|
||||
|
||||
INCLUDE_DIRECTORIES(${KDE4_INCLUDES} .)
|
||||
|
||||
SET(kparttest_SRCS
|
||||
main.cpp
|
||||
kparttest.cpp
|
||||
)
|
||||
|
||||
KDE4_ADD_EXECUTABLE(kparttest ${kparttest_SRCS})
|
||||
|
||||
TARGET_LINK_LIBRARIES(kparttest ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS})
|
||||
|
||||
INSTALL(TARGETS kparttest DESTINATION ${BIN_INSTALL_DIR})
|
||||
INSTALL(FILES kparttestui.rc DESTINATION ${DATA_INSTALL_DIR}/kparttest)
|
|
@ -0,0 +1,57 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kparttest.h"
|
||||
|
||||
#include <kaction.h>
|
||||
#include <kactioncollection.h>
|
||||
#include <kpluginfactory.h>
|
||||
#include <kpluginloader.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kstandardaction.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
KPartTest::KPartTest() :
|
||||
KParts::MainWindow(),
|
||||
m_Part(NULL)
|
||||
{
|
||||
setupActions();
|
||||
|
||||
KPluginFactory* factory = KPluginLoader("partitionmanagerpart").factory();
|
||||
m_Part = factory ? factory->create<KParts::ReadOnlyPart>("PartitionManagerPart", this) : NULL;
|
||||
|
||||
if (m_Part == NULL)
|
||||
{
|
||||
KMessageBox::error(this, "Could not load Partition Manager's KPart");
|
||||
qApp->quit();
|
||||
return;
|
||||
}
|
||||
|
||||
setCentralWidget(m_Part->widget());
|
||||
|
||||
setupGUI(ToolBar | Keys | StatusBar | Save);
|
||||
createGUI(m_Part);
|
||||
}
|
||||
|
||||
void KPartTest::setupActions()
|
||||
{
|
||||
KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection());
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#if !defined(KPARTTEST__H)
|
||||
|
||||
#define KPARTTEST__H
|
||||
|
||||
#include <kparts/mainwindow.h>
|
||||
|
||||
class KPartTest : public KParts::MainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KPartTest();
|
||||
|
||||
private:
|
||||
void setupActions();
|
||||
|
||||
private:
|
||||
KParts::ReadOnlyPart* m_Part;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||
|
||||
<kpartgui name="kparttest" version="3">
|
||||
<MenuBar>
|
||||
<Menu name="file">
|
||||
<Merge/>
|
||||
<Separator/>
|
||||
</Menu>
|
||||
|
||||
<Merge/>
|
||||
|
||||
<Menu name="settings"/>
|
||||
<Menu name="help"/>
|
||||
</MenuBar>
|
||||
</kpartgui>
|
|
@ -0,0 +1,45 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kparttest.h"
|
||||
|
||||
#include <KApplication>
|
||||
#include <KAboutData>
|
||||
#include <KCmdLineArgs>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
KAboutData aboutData(
|
||||
"kparttest",
|
||||
NULL,
|
||||
ki18n("KDE Partition Manager KPart"), "0.1",
|
||||
ki18n("A test application for KDE Partition Manager's KPart."),
|
||||
KAboutData::License_GPL,
|
||||
ki18n("Copyright (c) 2008 Volker Lanz")
|
||||
);
|
||||
|
||||
KCmdLineArgs::init(argc, argv, &aboutData);
|
||||
|
||||
KApplication app;
|
||||
|
||||
KPartTest* widget = new KPartTest();
|
||||
widget->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
56
src/main.cpp
56
src/main.cpp
|
@ -19,64 +19,14 @@
|
|||
|
||||
#include "gui/mainwindow.h"
|
||||
|
||||
#include "util/helpers.h"
|
||||
|
||||
#include <kapplication.h>
|
||||
#include <kcmdlineargs.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
|
||||
#include "ops/operation.h"
|
||||
#include "util/globallog.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
static void registerMetaTypes()
|
||||
{
|
||||
qRegisterMetaType<Operation*>("Operation*");
|
||||
qRegisterMetaType<log::Level>("log::Level");
|
||||
}
|
||||
|
||||
static bool checkPermissions()
|
||||
{
|
||||
if (geteuid() != 0)
|
||||
return KMessageBox::warningContinueCancel(NULL, i18nc("@info",
|
||||
"<para><warning>You do not have administrative privileges.</warning></para>"
|
||||
"<para>It is possible to run <application>%1</application> without these privileges. "
|
||||
"You will, however, <emphasis>not</emphasis> be allowed to apply operations.</para>"
|
||||
"<para>Do you want to continue running <application>%1</application>?</para>",
|
||||
KGlobal::mainComponent().aboutData()->programName()),
|
||||
i18nc("@title:window", "No Administrative Privileges"),
|
||||
KGuiItem(i18nc("@action:button", "Run Without Administrative Privileges")),
|
||||
KStandardGuiItem::cancel(),
|
||||
"runWithoutRootPrivileges") == KMessageBox::Continue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void unblockSigChild()
|
||||
{
|
||||
sigset_t sset;
|
||||
sigemptyset(&sset);
|
||||
sigaddset(&sset, SIGCHLD);
|
||||
sigprocmask(SIG_UNBLOCK, &sset, NULL);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
KAboutData about(
|
||||
"partitionmanager",
|
||||
0,
|
||||
ki18nc("@title", "<application>KDE Partition Manager</application>"),
|
||||
VERSION,
|
||||
ki18nc("@title", "Manage your disks, partitions and file systems"),
|
||||
KAboutData::License_GPL,
|
||||
ki18nc("@info:credit", "(c) 2008 Volker Lanz")
|
||||
);
|
||||
about.addAuthor(ki18nc("@info:credit", "Volker Lanz"), KLocalizedString(), "vl@fidra.de");
|
||||
about.setHomepage("http://www.partitionmanager.org");
|
||||
|
||||
KCmdLineArgs::init(argc, argv, &about);
|
||||
KCmdLineArgs::init(argc, argv, createPartitionManagerAboutData());
|
||||
|
||||
// workaround for https://bugs.launchpad.net/kdesudo/+bug/272427
|
||||
unblockSigChild();
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "util/helpers.h"
|
||||
#include "util/globallog.h"
|
||||
|
||||
#include "ops/operation.h"
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kglobal.h>
|
||||
#include <kcomponentdata.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
void registerMetaTypes()
|
||||
{
|
||||
qRegisterMetaType<Operation*>("Operation*");
|
||||
qRegisterMetaType<log::Level>("log::Level");
|
||||
}
|
||||
|
||||
void unblockSigChild()
|
||||
{
|
||||
sigset_t sset;
|
||||
sigemptyset(&sset);
|
||||
sigaddset(&sset, SIGCHLD);
|
||||
sigprocmask(SIG_UNBLOCK, &sset, NULL);
|
||||
}
|
||||
|
||||
bool checkPermissions()
|
||||
{
|
||||
if (geteuid() != 0)
|
||||
return KMessageBox::warningContinueCancel(NULL, i18nc("@info",
|
||||
"<para><warning>You do not have administrative privileges.</warning></para>"
|
||||
"<para>It is possible to run <application>%1</application> without these privileges. "
|
||||
"You will, however, <emphasis>not</emphasis> be allowed to apply operations.</para>"
|
||||
"<para>Do you want to continue running <application>%1</application>?</para>",
|
||||
KGlobal::mainComponent().aboutData()->programName()),
|
||||
i18nc("@title:window", "No administrative privileges"),
|
||||
KGuiItem(i18nc("@action:button", "Run without administrative privileges")),
|
||||
KStandardGuiItem::cancel(),
|
||||
"runWithoutRootPrivileges") == KMessageBox::Continue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
KAboutData* createPartitionManagerAboutData()
|
||||
{
|
||||
KAboutData* about = new KAboutData(
|
||||
"partitionmanager",
|
||||
NULL,
|
||||
ki18nc("@title", "<application>KDE Partition Manager</application>"),
|
||||
VERSION,
|
||||
ki18nc("@title", "Manage your disks, partitions and file systems"),
|
||||
KAboutData::License_GPL,
|
||||
ki18nc("@info:credit", "(c) 2008 Volker Lanz")
|
||||
);
|
||||
|
||||
about->addAuthor(ki18nc("@info:credit", "Volker Lanz"), KLocalizedString(), "vl@fidra.de");
|
||||
about->setHomepage("http://www.partitionmanager.org");
|
||||
|
||||
return about;
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if !defined(HELPERS__H)
|
||||
|
||||
#define HELPERS__H
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
class KAboutData;
|
||||
|
||||
LIBPARTITIONMANAGERPRIVATE_EXPORT void registerMetaTypes();
|
||||
LIBPARTITIONMANAGERPRIVATE_EXPORT void unblockSigChild();
|
||||
LIBPARTITIONMANAGERPRIVATE_EXPORT bool checkPermissions();
|
||||
|
||||
LIBPARTITIONMANAGERPRIVATE_EXPORT KAboutData* createPartitionManagerAboutData();
|
||||
|
||||
#endif
|
|
@ -0,0 +1,58 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if !defined(LIBPARTITIONMANAGEREXPORT__H)
|
||||
#define LIBPARTITIONMANAGEREXPORT__H
|
||||
|
||||
#include <kdemacros.h>
|
||||
|
||||
#if !defined(LIBPARTITIONMANAGERPRIVATE_EXPORT)
|
||||
# define LIBPARTITIONMANAGERPRIVATE_EXPORT KDE_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#if !defined(LIBPARTITIONMANAGEREXPORT__H)
|
||||
#define LIBPARTITIONMANAGEREXPORT__H
|
||||
|
||||
#include <kdemacros.h>
|
||||
|
||||
#if !defined(LIBPARTITIONMANAGERPRIVATE_EXPORT)
|
||||
# define LIBPARTITIONMANAGERPRIVATE_EXPORT KDE_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue