fix #233,support autostart through tweaks page

pull/1/head
Michail Vourlakos 8 years ago
parent 1e71b9ed4b
commit 1a04ff968d

@ -66,7 +66,11 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV
});
auto *dockCorona = qobject_cast<DockCorona *>(m_dockView->corona());
connections << connect(this, &DockConfigView::aboutApplication, dockCorona, &DockCorona::aboutApplication);
if (dockCorona) {
connections << connect(this, &DockConfigView::aboutApplication, dockCorona, &DockCorona::aboutApplication);
connections << connect(dockCorona, SIGNAL(autostartChanged()), this, SIGNAL(autostartChanged()));
}
}
DockConfigView::~DockConfigView()
@ -252,5 +256,25 @@ void DockConfigView::setSticker(bool blockFocusLost)
m_blockFocusLost = blockFocusLost;
}
bool DockConfigView::autostart() const
{
auto *dockCorona = qobject_cast<DockCorona *>(m_dockView->corona());
if (dockCorona) {
return dockCorona->autostart();
}
return false;
}
void DockConfigView::setAutostart(bool state)
{
auto *dockCorona = qobject_cast<DockCorona *>(m_dockView->corona());
if (dockCorona) {
dockCorona->setAutostart(state);
}
}
}
// kate: indent-mode cstyle; indent-width 4; replace-tabs on;

@ -43,6 +43,7 @@ class DockView;
class DockConfigView : public PlasmaQuick::ConfigView {
Q_OBJECT
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
public:
DockConfigView(Plasma::Containment *containment, DockView *dockView, QWindow *parent = nullptr);
@ -51,11 +52,15 @@ public:
void init() override;
Qt::WindowFlags wFlags() const;
void setAutostart(bool state);
bool autostart() const;
public slots:
Q_INVOKABLE void setSticker(bool blockFocusLost);
Q_INVOKABLE void syncGeometry();
signals:
void autostartChanged();
void showSignal();
protected:

@ -30,6 +30,8 @@
#include <QScreen>
#include <QDebug>
#include <QDesktopWidget>
#include <QDir>
#include <QFile>
#include <QQmlContext>
#include <Plasma>
@ -576,6 +578,30 @@ void DockCorona::aboutApplication()
aboutDialog->show();
}
void DockCorona::setAutostart(bool state)
{
QFile autostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop");
QFile metaFile("/usr/share/applications/latte-dock.desktop");
if (!state && autostartFile.exists()) {
autostartFile.remove();
emit autostartChanged();
} else if (state && metaFile.exists()) {
metaFile.copy(autostartFile.fileName());
//! I havent added the flag "OnlyShowIn=KDE;" into the autostart file
//! because I fall onto a Plasma 5.8 case that this flag
//! didnt let the plasma desktop to start
emit autostartChanged();
}
}
bool DockCorona::autostart() const
{
QFile autostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop");
return autostartFile.exists();
}
QList<Plasma::Types::Location> DockCorona::freeEdges(QScreen *screen) const
{
using Plasma::Types;

@ -65,6 +65,9 @@ public:
void addDock(Plasma::Containment *containment);
void recreateDock(Plasma::Containment *containment);
void setAutostart(bool state);
bool autostart() const;
void aboutApplication();
void closeApplication();
@ -75,6 +78,7 @@ public slots:
void dockContainmentDestroyed(QObject *cont);
signals:
void autostartChanged();
void configurationShown(PlasmaQuick::ConfigView *configView);
void docksCountChanged();
void dockLocationChanged();

@ -49,16 +49,16 @@ PlasmaComponents.Page {
}
PlasmaComponents.CheckBox {
id: showGlow
Layout.leftMargin: units.smallSpacing * 2
text: i18n("Enable autostart during startup")
checked: dockConfig.autostart
onClicked: {
dockConfig.autostart = checked;
}
}
PlasmaComponents.CheckBox {
id: threeColorsWindows
Layout.leftMargin: units.smallSpacing * 2
text: i18n("Show dock on desktop or actitivy change")

Loading…
Cancel
Save