mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-30 14:50:12 +03:00
move currentSession code in globalSettings
This commit is contained in:
parent
30fb90ec01
commit
466136cbd1
@ -795,26 +795,6 @@ void DockView::setSession(Dock::SessionType type)
|
||||
emit sessionChanged();
|
||||
}
|
||||
|
||||
Dock::SessionType DockView::runningSession() const
|
||||
{
|
||||
auto *dockCorona = qobject_cast<DockCorona *>(corona());
|
||||
|
||||
if (dockCorona) {
|
||||
return dockCorona->currentSession();
|
||||
}
|
||||
|
||||
return Dock::DefaultSession;
|
||||
}
|
||||
|
||||
void DockView::setRunningSession(Dock::SessionType session)
|
||||
{
|
||||
auto *dockCorona = qobject_cast<DockCorona *>(corona());
|
||||
|
||||
if (dockCorona && dockCorona->currentSession() != session) {
|
||||
dockCorona->switchToSession(session);
|
||||
}
|
||||
}
|
||||
|
||||
float DockView::maxLength() const
|
||||
{
|
||||
return m_maxLength;
|
||||
|
@ -74,7 +74,6 @@ class DockView : public PlasmaQuick::ContainmentView {
|
||||
Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
|
||||
|
||||
Q_PROPERTY(Latte::Dock::SessionType session READ session WRITE setSession NOTIFY sessionChanged)
|
||||
Q_PROPERTY(Latte::Dock::SessionType runningSession READ runningSession WRITE setRunningSession NOTIFY runningSessionChanged)
|
||||
|
||||
public:
|
||||
DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr, bool alwaysVisible = false);
|
||||
@ -124,10 +123,6 @@ public:
|
||||
QRect absGeometry() const;
|
||||
QRect screenGeometry() const;
|
||||
|
||||
|
||||
Latte::Dock::SessionType runningSession() const;
|
||||
void setRunningSession(Latte::Dock::SessionType session);
|
||||
|
||||
Plasma::FrameSvg::EnabledBorders enabledBorders() const;
|
||||
|
||||
QString currentScreen() const;
|
||||
@ -190,7 +185,6 @@ signals:
|
||||
void onPrimaryChanged();
|
||||
void visibilityChanged();
|
||||
void maskAreaChanged();
|
||||
void runningSessionChanged();
|
||||
void screenGeometryChanged();
|
||||
void sessionChanged();
|
||||
void shadowChanged();
|
||||
|
@ -24,7 +24,7 @@ GlobalSettings::GlobalSettings(QObject *parent)
|
||||
m_altSessionAction->setCheckable(true);
|
||||
connect(m_altSessionAction, &QAction::triggered, this, &GlobalSettings::enableAltSession);
|
||||
|
||||
connect(m_corona, &DockCorona::currentSessionChanged, this, &GlobalSettings::currentSessionChanged);
|
||||
connect(m_corona, &DockCorona::currentSessionChanged, this, &GlobalSettings::currentSessionChangedSlot);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,13 +59,14 @@ void GlobalSettings::setExposeAltSession(bool state)
|
||||
emit exposeAltSessionChanged();
|
||||
}
|
||||
|
||||
void GlobalSettings::currentSessionChanged(Dock::SessionType type)
|
||||
void GlobalSettings::currentSessionChangedSlot(Dock::SessionType type)
|
||||
{
|
||||
if (m_corona->currentSession() == Dock::DefaultSession)
|
||||
m_altSessionAction->setChecked(false);
|
||||
else
|
||||
m_altSessionAction->setChecked(true);
|
||||
|
||||
emit currentSessionChanged();
|
||||
}
|
||||
|
||||
QAction *GlobalSettings::altSessionAction() const
|
||||
@ -73,6 +74,12 @@ QAction *GlobalSettings::altSessionAction() const
|
||||
return m_altSessionAction;
|
||||
}
|
||||
|
||||
bool GlobalSettings::autostart() const
|
||||
{
|
||||
QFile autostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop");
|
||||
return autostartFile.exists();
|
||||
}
|
||||
|
||||
void GlobalSettings::setAutostart(bool state)
|
||||
{
|
||||
QFile autostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop");
|
||||
@ -90,12 +97,17 @@ void GlobalSettings::setAutostart(bool state)
|
||||
}
|
||||
}
|
||||
|
||||
bool GlobalSettings::autostart() const
|
||||
Dock::SessionType GlobalSettings::currentSession() const
|
||||
{
|
||||
QFile autostartFile(QDir::homePath() + "/.config/autostart/latte-dock.desktop");
|
||||
return autostartFile.exists();
|
||||
return m_corona->currentSession();
|
||||
}
|
||||
|
||||
void GlobalSettings::setCurrentSession(Dock::SessionType session)
|
||||
{
|
||||
if (currentSession() != session) {
|
||||
m_corona->switchToSession(session);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//!BEGIN configuration functions
|
||||
|
@ -36,6 +36,8 @@ class GlobalSettings : public QObject {
|
||||
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
|
||||
Q_PROPERTY(bool exposeAltSession READ exposeAltSession WRITE setExposeAltSession NOTIFY exposeAltSessionChanged)
|
||||
|
||||
Q_PROPERTY(Latte::Dock::SessionType currentSession READ currentSession WRITE setCurrentSession NOTIFY currentSessionChanged)
|
||||
|
||||
Q_PROPERTY(QAction *altSessionAction READ altSessionAction NOTIFY altSessionActionChanged)
|
||||
|
||||
public:
|
||||
@ -49,16 +51,19 @@ public:
|
||||
|
||||
bool exposeAltSession() const;
|
||||
void setExposeAltSession(bool state);
|
||||
|
||||
QAction *altSessionAction() const;
|
||||
|
||||
Latte::Dock::SessionType currentSession() const;
|
||||
void setCurrentSession(Latte::Dock::SessionType session);
|
||||
|
||||
signals:
|
||||
void altSessionActionChanged();
|
||||
void currentSessionChanged();
|
||||
void autostartChanged();
|
||||
void exposeAltSessionChanged();
|
||||
|
||||
private slots:
|
||||
void currentSessionChanged(Dock::SessionType type);
|
||||
void currentSessionChangedSlot(Dock::SessionType type);
|
||||
void enableAltSession(bool enabled);
|
||||
|
||||
private:
|
||||
|
@ -133,14 +133,14 @@ PlasmaComponents.Page {
|
||||
Layout.rightMargin: units.smallSpacing * 2
|
||||
Layout.fillWidth: true
|
||||
text: i18n("Alternative Session")
|
||||
checked: dock.runningSession === Latte.Dock.AlternativeSession
|
||||
checked: globalSettings.currentSession === Latte.Dock.AlternativeSession
|
||||
checkable: true
|
||||
|
||||
onClicked: {
|
||||
if (dock.runningSession === Latte.Dock.DefaultSession){
|
||||
dock.runningSession = Latte.Dock.AlternativeSession;
|
||||
if (globalSettings.currentSession === Latte.Dock.DefaultSession){
|
||||
globalSettings.currentSession = Latte.Dock.AlternativeSession;
|
||||
} else {
|
||||
dock.runningSession = Latte.Dock.DefaultSession;
|
||||
globalSettings.currentSession = Latte.Dock.DefaultSession;
|
||||
}
|
||||
dockConfig.hideConfigWindow();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user