Make the kcm work.
Don't use a hardcoded filename for the configuration; pass a name for the configuration file to PartitionManagerWidget::init() instead, so the kcm and the standalone app can each have an rc file of their own. svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=957525
This commit is contained in:
parent
0ae47a0723
commit
0ff681dd8d
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
|
||||
<kcfg>
|
||||
<kcfgfile name="partitionmanagerrc"/>
|
||||
<kcfgfile arg="true"/>
|
||||
|
||||
<group name="KDE Partition Manager">
|
||||
<entry name="treePartitionColumnWidths" type="IntList">
|
||||
|
|
|
@ -102,7 +102,7 @@ void MainWindow::init()
|
|||
|
||||
listDevices().init(actionCollection(), &pmWidget());
|
||||
listOperations().init(actionCollection(), &pmWidget());
|
||||
pmWidget().init(actionCollection());
|
||||
pmWidget().init(actionCollection(), "partitionmanagerrc");
|
||||
|
||||
// If we were called with an action collection we're supposed to be a KPart, so don't
|
||||
// create the GUI in that case.
|
||||
|
|
|
@ -112,8 +112,10 @@ PartitionManagerWidget::~PartitionManagerWidget()
|
|||
saveConfig();
|
||||
}
|
||||
|
||||
void PartitionManagerWidget::init(KActionCollection* coll)
|
||||
void PartitionManagerWidget::init(KActionCollection* coll, const QString& config_name)
|
||||
{
|
||||
Config::instance(config_name);
|
||||
|
||||
Q_ASSERT(coll);
|
||||
m_ActionCollection = coll;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT PartitionManagerWidget : public QWidget,
|
|||
void setSelectedDevice(Device* d);
|
||||
|
||||
public:
|
||||
void init(KActionCollection* coll);
|
||||
void init(KActionCollection* coll, const QString& config_name);
|
||||
KActionCollection* actionCollection() const { return m_ActionCollection; }
|
||||
|
||||
void clear();
|
||||
|
|
|
@ -24,17 +24,21 @@
|
|||
|
||||
#include "util/helpers.h"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <kgenericfactory.h>
|
||||
#include <klocale.h>
|
||||
#include <kactioncollection.h>
|
||||
#include <ktoolbar.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
K_PLUGIN_FACTORY(
|
||||
PartitionManagerKCMFactory,
|
||||
registerPlugin<PartitionManagerKCM>();
|
||||
)
|
||||
K_EXPORT_PLUGIN(
|
||||
PartitionManagerKCMFactory("partitionmanagerkcm")
|
||||
PartitionManagerKCMFactory("kcm_partitionmanager")
|
||||
)
|
||||
|
||||
PartitionManagerKCM::PartitionManagerKCM(QWidget* parent, const QVariantList&) :
|
||||
|
@ -56,29 +60,22 @@ PartitionManagerKCM::PartitionManagerKCM(QWidget* parent, const QVariantList&) :
|
|||
|
||||
listDevices().init(actionCollection(), &pmWidget());
|
||||
listOperations().init(actionCollection(), &pmWidget());
|
||||
pmWidget().init(actionCollection());
|
||||
pmWidget().init(actionCollection(), "kcm_partitionmanagerrc");
|
||||
|
||||
const char* actionNames[] =
|
||||
{
|
||||
"applyAllOperations",
|
||||
"undoOperation",
|
||||
"clearAllOperations",
|
||||
"",
|
||||
// "refreshDevices",
|
||||
"createNewPartitionTable",
|
||||
"",
|
||||
"newPartition",
|
||||
"resizePartition",
|
||||
"deletePartition",
|
||||
"copyPartition",
|
||||
"pastePartition",
|
||||
// "mountPartition",
|
||||
"checkPartition",
|
||||
"propertiesPartition",
|
||||
"backupPartition",
|
||||
"restorePartition",
|
||||
// "",
|
||||
// "fileSystemSupport"
|
||||
"",
|
||||
"createNewPartitionTable",
|
||||
"refreshDevices"
|
||||
};
|
||||
|
||||
for(size_t i = 0; i < sizeof(actionNames) / sizeof(actionNames[0]); i++)
|
||||
|
@ -88,7 +85,12 @@ PartitionManagerKCM::PartitionManagerKCM(QWidget* parent, const QVariantList&) :
|
|||
toolBar()->addSeparator();
|
||||
|
||||
toolBar()->setIconSize(QSize(22, 22));
|
||||
toolBar()->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||
toolBar()->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
|
||||
splitterHorizontal().setStretchFactor(0, 1);
|
||||
splitterHorizontal().setStretchFactor(1, 4);
|
||||
splitterVertical().setStretchFactor(0, 1);
|
||||
splitterVertical().setStretchFactor(1, 3);
|
||||
}
|
||||
|
||||
void PartitionManagerKCM::onNewLogMessage(log::Level, const QString& s)
|
||||
|
@ -98,19 +100,29 @@ void PartitionManagerKCM::onNewLogMessage(log::Level, const QString& s)
|
|||
|
||||
void PartitionManagerKCM::load()
|
||||
{
|
||||
if (pmWidget().numPendingOperations() > 0)
|
||||
actionCollection()->action("clearAllOperations")->trigger();
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(onStatusChanged()));
|
||||
}
|
||||
|
||||
void PartitionManagerKCM::save()
|
||||
{
|
||||
if (pmWidget().numPendingOperations() > 0)
|
||||
actionCollection()->action("applyAllOperations")->trigger();
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(onStatusChanged()));
|
||||
}
|
||||
|
||||
void PartitionManagerKCM::setupConnections()
|
||||
{
|
||||
connect(&pmWidget(), SIGNAL(devicesChanged()), &listDevices(), SLOT(updateDevices()));
|
||||
connect(&pmWidget(), SIGNAL(operationsChanged()), &listOperations(), SLOT(updateOperations()));
|
||||
connect(&listDevices(), SIGNAL(selectionChanged(Device*)), &pmWidget(), SLOT(setSelectedDevice(Device*)));
|
||||
connect(&pmWidget(), SIGNAL(statusChanged()), SLOT(onStatusChanged()));
|
||||
}
|
||||
|
||||
void PartitionManagerKCM::on_m_ListDevices_selectionChanged(Device* d)
|
||||
void PartitionManagerKCM::onStatusChanged()
|
||||
{
|
||||
pmWidget().setSelectedDevice(d);
|
||||
emit changed(pmWidget().numPendingOperations() > 0);
|
||||
}
|
||||
|
|
|
@ -58,13 +58,16 @@ class PartitionManagerKCM : public KCModule, public Ui::PartitionManagerKCMBase
|
|||
ListOperations& listOperations() { Q_ASSERT(m_ListOperations); return *m_ListOperations; }
|
||||
const ListOperations& listOperations() const { Q_ASSERT(m_ListOperations); return *m_ListOperations; }
|
||||
|
||||
QSplitter& splitterHorizontal() { Q_ASSERT(m_SplitterHorizontal); return *m_SplitterHorizontal; }
|
||||
QSplitter& splitterVertical() { Q_ASSERT(m_SplitterVertical); return *m_SplitterVertical; }
|
||||
|
||||
KActionCollection* actionCollection() { return m_ActionCollection; }
|
||||
|
||||
KToolBar* toolBar() { return m_ToolBar; }
|
||||
|
||||
protected slots:
|
||||
void on_m_ListDevices_selectionChanged(Device* d);
|
||||
void onNewLogMessage(log::Level logLevel, const QString& s);
|
||||
void onStatusChanged();
|
||||
|
||||
private:
|
||||
KActionCollection* m_ActionCollection;
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter_2" >
|
||||
<widget class="QSplitter" name="m_SplitterHorizontal" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QSplitter" name="splitter" >
|
||||
<widget class="QSplitter" name="m_SplitterVertical" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
|
@ -32,27 +32,13 @@
|
|||
</widget>
|
||||
<widget class="ListOperations" native="1" name="m_ListOperations" />
|
||||
</widget>
|
||||
<widget class="QWidget" name="" >
|
||||
<widget class="QWidget" name="layoutWidget" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<widget class="KToolBar" native="1" name="m_ToolBar" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KToolBar" native="1" name="m_ToolBar" />
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PartitionManagerWidget" native="1" name="m_PartitionManagerWidget" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="PartitionManagerWidget" native="1" name="m_PartitionManagerWidget" />
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in New Issue