correctly save and restore to/from plasma-shellrc
This commit is contained in:
parent
c28b0676ac
commit
a6c82d8a5e
@ -45,6 +45,12 @@ DesktopCorona::DesktopCorona(QObject *parent)
|
|||||||
{
|
{
|
||||||
m_desktopDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(package().filePath("defaults")), "Desktop");
|
m_desktopDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(package().filePath("defaults")), "Desktop");
|
||||||
|
|
||||||
|
m_appConfigSyncTimer = new QTimer(this);
|
||||||
|
m_appConfigSyncTimer->setSingleShot(true);
|
||||||
|
connect(m_appConfigSyncTimer, &QTimer::timeout,
|
||||||
|
this, &DesktopCorona::syncAppConfig);
|
||||||
|
|
||||||
|
|
||||||
connect(m_desktopWidget, SIGNAL(resized(int)),
|
connect(m_desktopWidget, SIGNAL(resized(int)),
|
||||||
this, SLOT(screenResized(int)));
|
this, SLOT(screenResized(int)));
|
||||||
connect(m_desktopWidget, SIGNAL(screenCountChanged(int)),
|
connect(m_desktopWidget, SIGNAL(screenCountChanged(int)),
|
||||||
@ -64,6 +70,20 @@ DesktopCorona::~DesktopCorona()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KSharedConfig::Ptr DesktopCorona::applicationConfig()
|
||||||
|
{
|
||||||
|
return KSharedConfig::openConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesktopCorona::requestApplicationConfigSync()
|
||||||
|
{
|
||||||
|
// constant controlling how long between requesting a configuration sync
|
||||||
|
// and one happening should occur. currently 10 seconds
|
||||||
|
static const int CONFIG_SYNC_TIMEOUT = 10000;
|
||||||
|
|
||||||
|
m_appConfigSyncTimer->start(CONFIG_SYNC_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
void DesktopCorona::loadDefaultLayout()
|
void DesktopCorona::loadDefaultLayout()
|
||||||
{
|
{
|
||||||
WorkspaceScripting::DesktopScriptEngine scriptEngine(this, true);
|
WorkspaceScripting::DesktopScriptEngine scriptEngine(this, true);
|
||||||
@ -155,7 +175,7 @@ void DesktopCorona::checkDesktop(/*Activity *activity,*/ bool signalWhenExists,
|
|||||||
qWarning() << "Invalid screen";
|
qWarning() << "Invalid screen";
|
||||||
}
|
}
|
||||||
c->flushPendingConstraintsEvents();
|
c->flushPendingConstraintsEvents();
|
||||||
requestConfigSync();
|
requestApplicationConfigSync();
|
||||||
|
|
||||||
if (signalWhenExists) {
|
if (signalWhenExists) {
|
||||||
emit containmentAdded(c);
|
emit containmentAdded(c);
|
||||||
@ -292,6 +312,12 @@ void DesktopCorona::showWidgetExplorer()
|
|||||||
m_widgetExplorerView->show();
|
m_widgetExplorerView->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DesktopCorona::syncAppConfig()
|
||||||
|
{
|
||||||
|
qDebug() << "Syncing plasma-shellrc config";
|
||||||
|
applicationConfig()->sync();
|
||||||
|
}
|
||||||
|
|
||||||
void DesktopCorona::printScriptError(const QString &error)
|
void DesktopCorona::printScriptError(const QString &error)
|
||||||
{
|
{
|
||||||
qWarning() << error;
|
qWarning() << error;
|
||||||
@ -302,5 +328,5 @@ void DesktopCorona::printScriptMessage(const QString &message)
|
|||||||
qDebug() << message;
|
qDebug() << message;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "desktopcorona.moc"
|
#include "moc_desktopcorona.cpp"
|
||||||
|
|
||||||
|
@ -45,6 +45,16 @@ public:
|
|||||||
explicit DesktopCorona(QObject * parent = 0);
|
explicit DesktopCorona(QObject * parent = 0);
|
||||||
~DesktopCorona();
|
~DesktopCorona();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to save global configuration that doesn't have anything to do with the scene (e.g. views)
|
||||||
|
*/
|
||||||
|
KSharedConfig::Ptr applicationConfig();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request saving applicationConfig on disk, it's event compressed, not immediate
|
||||||
|
*/
|
||||||
|
void requestApplicationConfigSync();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the default (system wide) layout for this user
|
* Loads the default (system wide) layout for this user
|
||||||
**/
|
**/
|
||||||
@ -88,6 +98,7 @@ protected Q_SLOTS:
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void handleContainmentAdded(Plasma::Containment *c);
|
void handleContainmentAdded(Plasma::Containment *c);
|
||||||
void showWidgetExplorer();
|
void showWidgetExplorer();
|
||||||
|
void syncAppConfig();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDesktopWidget *m_desktopWidget;
|
QDesktopWidget *m_desktopWidget;
|
||||||
@ -95,6 +106,7 @@ private:
|
|||||||
WidgetExplorerView *m_widgetExplorerView;
|
WidgetExplorerView *m_widgetExplorerView;
|
||||||
QHash<Plasma::Containment *, PanelView *> m_panelViews;
|
QHash<Plasma::Containment *, PanelView *> m_panelViews;
|
||||||
KConfigGroup m_desktopDefaultsConfig;
|
KConfigGroup m_desktopDefaultsConfig;
|
||||||
|
QTimer *m_appConfigSyncTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "panelview.h"
|
#include "panelview.h"
|
||||||
|
#include "desktopcorona.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -29,12 +30,13 @@
|
|||||||
#include <Plasma/Containment>
|
#include <Plasma/Containment>
|
||||||
#include <Plasma/Package>
|
#include <Plasma/Package>
|
||||||
|
|
||||||
PanelView::PanelView(Plasma::Corona *corona, QWindow *parent)
|
PanelView::PanelView(DesktopCorona *corona, QWindow *parent)
|
||||||
: View(corona, parent),
|
: View(corona, parent),
|
||||||
m_offset(0),
|
m_offset(0),
|
||||||
m_maxLength(0),
|
m_maxLength(0),
|
||||||
m_minLength(0),
|
m_minLength(0),
|
||||||
m_alignment(Qt::AlignLeft)
|
m_alignment(Qt::AlignLeft),
|
||||||
|
m_corona(corona)
|
||||||
{
|
{
|
||||||
QSurfaceFormat format;
|
QSurfaceFormat format;
|
||||||
format.setAlphaBufferSize(8);
|
format.setAlphaBufferSize(8);
|
||||||
@ -70,7 +72,8 @@ PanelView::~PanelView()
|
|||||||
config().writeEntry("thickness", size().height());
|
config().writeEntry("thickness", size().height());
|
||||||
}
|
}
|
||||||
config().writeEntry("alignment", (int)m_alignment);
|
config().writeEntry("alignment", (int)m_alignment);
|
||||||
containment()->corona()->requestConfigSync();
|
m_corona->requestApplicationConfigSync();
|
||||||
|
m_corona->requestApplicationConfigSync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +82,7 @@ KConfigGroup PanelView::config() const
|
|||||||
if (!containment()) {
|
if (!containment()) {
|
||||||
return KConfigGroup();
|
return KConfigGroup();
|
||||||
}
|
}
|
||||||
KConfigGroup views(KSharedConfig::openConfig(), "PlasmaViews");
|
KConfigGroup views(m_corona->applicationConfig(), "PlasmaViews");
|
||||||
views = KConfigGroup(&views, QString("Panel %1").arg(containment()->id()));
|
views = KConfigGroup(&views, QString("Panel %1").arg(containment()->id()));
|
||||||
|
|
||||||
if (containment()->formFactor() == Plasma::Vertical) {
|
if (containment()->formFactor() == Plasma::Vertical) {
|
||||||
@ -92,12 +95,12 @@ KConfigGroup PanelView::config() const
|
|||||||
|
|
||||||
void PanelView::init()
|
void PanelView::init()
|
||||||
{
|
{
|
||||||
if (!corona()->package().isValid()) {
|
if (!m_corona->package().isValid()) {
|
||||||
qWarning() << "Invalid home screen package";
|
qWarning() << "Invalid home screen package";
|
||||||
}
|
}
|
||||||
|
|
||||||
setResizeMode(View::SizeRootObjectToView);
|
setResizeMode(View::SizeRootObjectToView);
|
||||||
setSource(QUrl::fromLocalFile(corona()->package().filePath("views", "Panel.qml")));
|
setSource(QUrl::fromLocalFile(m_corona->package().filePath("views", "Panel.qml")));
|
||||||
positionPanel();
|
positionPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +134,7 @@ void PanelView::setOffset(int offset)
|
|||||||
config().writeEntry("offset", m_offset);
|
config().writeEntry("offset", m_offset);
|
||||||
positionPanel();
|
positionPanel();
|
||||||
emit offsetChanged();
|
emit offsetChanged();
|
||||||
|
m_corona->requestApplicationConfigSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PanelView::thickness() const
|
int PanelView::thickness() const
|
||||||
@ -145,12 +149,13 @@ void PanelView::setThickness(int value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (formFactor() == Plasma::Vertical) {
|
if (formFactor() == Plasma::Vertical) {
|
||||||
return setWidth(value);
|
setWidth(value);
|
||||||
} else {
|
} else {
|
||||||
return setHeight(value);
|
setHeight(value);
|
||||||
}
|
}
|
||||||
config().writeEntry("thickness", value);
|
config().writeEntry("thickness", value);
|
||||||
emit thicknessChanged();
|
emit thicknessChanged();
|
||||||
|
m_corona->requestApplicationConfigSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PanelView::maximumLength() const
|
int PanelView::maximumLength() const
|
||||||
@ -176,6 +181,7 @@ void PanelView::setMaximumLength(int length)
|
|||||||
config().writeEntry("maxLength", length);
|
config().writeEntry("maxLength", length);
|
||||||
m_maxLength = length;
|
m_maxLength = length;
|
||||||
emit maximumLengthChanged();
|
emit maximumLengthChanged();
|
||||||
|
m_corona->requestApplicationConfigSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PanelView::minimumLength() const
|
int PanelView::minimumLength() const
|
||||||
@ -201,6 +207,7 @@ void PanelView::setMinimumLength(int length)
|
|||||||
config().writeEntry("minLength", length);
|
config().writeEntry("minLength", length);
|
||||||
m_minLength = length;
|
m_minLength = length;
|
||||||
emit minimumLengthChanged();
|
emit minimumLengthChanged();
|
||||||
|
m_corona->requestApplicationConfigSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PanelView::positionPanel()
|
void PanelView::positionPanel()
|
||||||
@ -289,8 +296,8 @@ void PanelView::restore()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_offset = config().readEntry<int>("offset", 0);
|
m_offset = config().readEntry<int>("offset", 0);
|
||||||
m_maxLength = config().readEntry<int>("max", -1);
|
m_maxLength = config().readEntry<int>("maxLength", -1);
|
||||||
m_minLength = config().readEntry<int>("min", -1);
|
m_minLength = config().readEntry<int>("minLength", -1);
|
||||||
m_alignment = (Qt::Alignment)config().readEntry<int>("alignment", Qt::AlignLeft);
|
m_alignment = (Qt::Alignment)config().readEntry<int>("alignment", Qt::AlignLeft);
|
||||||
|
|
||||||
setMinimumSize(QSize(-1, -1));
|
setMinimumSize(QSize(-1, -1));
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "panelconfigview.h"
|
#include "panelconfigview.h"
|
||||||
#include <QtCore/qpointer.h>
|
#include <QtCore/qpointer.h>
|
||||||
|
|
||||||
|
class DesktopCorona;
|
||||||
|
|
||||||
class PanelView : public View
|
class PanelView : public View
|
||||||
{
|
{
|
||||||
@ -35,7 +36,7 @@ class PanelView : public View
|
|||||||
Q_PROPERTY(int minimumLength READ minimumLength WRITE setMinimumLength NOTIFY minimumLengthChanged)
|
Q_PROPERTY(int minimumLength READ minimumLength WRITE setMinimumLength NOTIFY minimumLengthChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PanelView(Plasma::Corona *corona, QWindow *parent = 0);
|
explicit PanelView(DesktopCorona *corona, QWindow *parent = 0);
|
||||||
virtual ~PanelView();
|
virtual ~PanelView();
|
||||||
|
|
||||||
virtual KConfigGroup config() const;
|
virtual KConfigGroup config() const;
|
||||||
@ -75,6 +76,7 @@ private:
|
|||||||
int m_minLength;
|
int m_minLength;
|
||||||
Qt::Alignment m_alignment;
|
Qt::Alignment m_alignment;
|
||||||
QPointer<PanelConfigView> m_panelConfigView;
|
QPointer<PanelConfigView> m_panelConfigView;
|
||||||
|
DesktopCorona *m_corona;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PANELVIEW_H
|
#endif // PANELVIEW_H
|
||||||
|
@ -33,11 +33,31 @@ Rectangle {
|
|||||||
height: 64
|
height: 64
|
||||||
//END properties
|
//END properties
|
||||||
|
|
||||||
|
//BEGIN Connections
|
||||||
|
Connections {
|
||||||
|
target: panel
|
||||||
|
onOffsetChanged: offsetHandle.value = panel.offset
|
||||||
|
onMinimumLengthChanged: minimumLengthHandle.value = panel.minimumLength
|
||||||
|
onMaximumLengthChanged: maximumLengthHandle.value = panel.maximumLength
|
||||||
|
}
|
||||||
|
//END Connections
|
||||||
|
|
||||||
//BEGIN UI components
|
//BEGIN UI components
|
||||||
// Offset
|
// Offset
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: offsetHandle
|
||||||
width: 32
|
width: 32
|
||||||
height: 32
|
height: 32
|
||||||
|
|
||||||
|
property int value
|
||||||
|
onValueChanged: {
|
||||||
|
if (panel.location == 5 || panel.location == 6) {
|
||||||
|
parent.y = panel.offset
|
||||||
|
} else {
|
||||||
|
parent.x = panel.offset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
drag {
|
drag {
|
||||||
target: parent
|
target: parent
|
||||||
@ -63,8 +83,12 @@ Rectangle {
|
|||||||
|
|
||||||
//Minimum length
|
//Minimum length
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: minimumLengthHandle
|
||||||
width: 32
|
width: 32
|
||||||
height: 32
|
height: 32
|
||||||
|
|
||||||
|
property int value
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
drag {
|
drag {
|
||||||
target: parent
|
target: parent
|
||||||
@ -90,8 +114,12 @@ Rectangle {
|
|||||||
|
|
||||||
//Maximum length
|
//Maximum length
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: maximumLengthHandle
|
||||||
width: 32
|
width: 32
|
||||||
height: 32
|
height: 32
|
||||||
|
|
||||||
|
property int value
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
drag {
|
drag {
|
||||||
target: parent
|
target: parent
|
||||||
|
Loading…
Reference in New Issue
Block a user