diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index 34b5cf877..42651abea 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -556,7 +556,7 @@ int DockCorona::noDocksWithTasks() const int result = 0; foreach (auto view, m_dockViews) { - if (view->tasksPresent() && view->session() == m_session) { + if (view->tasksPresent()) { result++; } } @@ -621,14 +621,13 @@ void DockCorona::syncDockViews() bool onPrimary = cont->config().readEntry("onPrimary", true); Plasma::Types::Location location = static_cast((int)cont->config().readEntry("location", (int)Plasma::Types::BottomEdge)); - Dock::SessionType session = static_cast((int)cont->config().readEntry("session", (int)Dock::DefaultSession)); //! two main situations that a dock must be added when it is not already running //! 1. when a dock is primary, not running and the edge for which is associated is free //! 2. when a dock in explicit, not running and the associated screen currently exists //! e.g. the screen has just been added if (((onPrimary && freeEdges(qGuiApp->primaryScreen()).contains(location)) || (!onPrimary && (m_screenPool->connector(id) == scr->name()))) - && (!m_dockViews.contains(cont)) && session == currentSession()) { + && (!m_dockViews.contains(cont))) { qDebug() << "screen Count signal: view must be added... for:" << scr->name(); addDock(cont); } @@ -689,14 +688,10 @@ void DockCorona::syncDockViews() } } - if (view->session() != currentSession()) { - qDebug() << "deleting view that does not belong in this session..."; - auto viewToDelete = m_dockViews.take(view->containment()); - viewToDelete->deactivateApplets(); - viewToDelete->deleteLater(); - //! which explicit docks can be deleted - } else if (!found && !view->onPrimary() && (m_dockViews.size() > 1) && m_dockViews.contains(view->containment()) - && !(view->tasksPresent() && noDocksWithTasks() == 1)) { + + //! which explicit docks can be deleted + if (!found && !view->onPrimary() && (m_dockViews.size() > 1) && m_dockViews.contains(view->containment()) + && !(view->tasksPresent() && noDocksWithTasks() == 1)) { //do not delete last dock containing tasks if (dockWithTasksWillBeShown || preserveContainmentId != view->containment()->id()) { qDebug() << "screen Count signal: view must be deleted... for:" << view->currentScreen(); @@ -791,50 +786,9 @@ void DockCorona::aboutApplication() aboutDialog->show(); } -Dock::SessionType DockCorona::currentSession() +int DockCorona::noOfDocks() { - return m_session; -} - -void DockCorona::setCurrentSession(Dock::SessionType session) -{ - if (m_session == session) { - return; - } - - m_session = session; - - emit currentSessionChanged(m_session);; -} - -void DockCorona::switchToSession(Dock::SessionType session) -{ - if (currentSession() == session) { - return; - } - - setCurrentSession(session); - - if (noDocksForSession(session) == 0) { - m_waitingSessionDocksCreation = true; - loadDefaultLayout(); - } else { - m_waitingSessionDocksCreation = false; - syncDockViews(); - } -} -int DockCorona::noDocksForSession(Dock::SessionType session) -{ - int count{0}; - - foreach (auto cont, containments()) { - Dock::SessionType ses = static_cast(cont->config().readEntry("session", (int)Dock::DefaultSession)); - - if (session == ses) - count++; - } - - return count; + return m_dockViews.count(); } QList DockCorona::freeEdges(QScreen *screen) const @@ -844,7 +798,7 @@ QList DockCorona::freeEdges(QScreen *screen) const Types::TopEdge, Types::RightEdge}; for (auto *view : m_dockViews) { - if (view && view->currentScreen() == screen->name() && view->session() == m_session) { + if (view && view->currentScreen() == screen->name()) { edges.removeOne(view->location()); } } @@ -861,7 +815,7 @@ QList DockCorona::freeEdges(int screen) const QScreen *scr = m_screenPool->screenForId(screen); for (auto *view : m_dockViews) { - if (view && scr && view->currentScreen() == scr->name() && view->session() == m_session) { + if (view && scr && view->currentScreen() == scr->name()) { edges.removeOne(view->location()); } } @@ -929,14 +883,6 @@ void DockCorona::addDock(Plasma::Containment *containment, int expDockScreen) if (metadata.pluginId() != "org.kde.latte.containment") return; - - int session = containment->config().readEntry("session", (int)Dock::DefaultSession); - - //! when this containment does not belong to this session - if (session != currentSession() && !m_waitingSessionDocksCreation) { - return; - } - for (auto *dock : m_dockViews) { if (dock->containment() == containment) return; @@ -1012,8 +958,6 @@ void DockCorona::addDock(Plasma::Containment *containment, int expDockScreen) dockView->setOnPrimary(true); } - dockView->setSession(currentSession()); - connect(containment, &QObject::destroyed, this, &DockCorona::dockContainmentDestroyed); connect(containment, &Plasma::Applet::destroyedChanged, this, &DockCorona::destroyedChanged); connect(containment, &Plasma::Applet::locationChanged, this, &DockCorona::dockLocationChanged); @@ -1029,14 +973,6 @@ void DockCorona::addDock(Plasma::Containment *containment, int expDockScreen) m_dockViews[containment] = dockView; - if (m_waitingSessionDocksCreation) { - m_waitingSessionDocksCreation = false; - - if (noDocksForSession(currentSession()) == 1) { - syncDockViews(); - } - } - emit docksCountChanged(); } @@ -1172,16 +1108,12 @@ void DockCorona::loadDefaultLayout() defaultContainment->restore(config); QList edges = freeEdges(defaultContainment->screen()); - if ((edges.count() > 0) && !m_waitingSessionDocksCreation) { + if ((edges.count() > 0)) { defaultContainment->setLocation(edges.at(0)); } else { defaultContainment->setLocation(Plasma::Types::BottomEdge); } - if (currentSession() != Dock::DefaultSession) { - config.writeEntry("session", (int)currentSession()); - } - defaultContainment->updateConstraints(Plasma::Types::StartupCompletedConstraint); defaultContainment->save(config); @@ -1353,10 +1285,6 @@ void DockCorona::copyDock(Plasma::Containment *containment) newContainment->config().writeEntry("lastScreen", dockScrId); } - if (currentSession() != Dock::DefaultSession) { - newContainment->config().writeEntry("session", (int)currentSession()); - } - newContainment->updateConstraints(Plasma::Types::StartupCompletedConstraint); newContainment->save(config); @@ -1388,7 +1316,6 @@ bool DockCorona::heuresticForLoadingDockWithTasks() if (plugin == "org.kde.latte.containment") { bool onPrimary = containmentsEntries.group(cId).readEntry("onPrimary", true); int lastScreen = containmentsEntries.group(cId).readEntry("lastScreen", -1); - Dock::SessionType session = static_cast(containmentsEntries.group(cId).readEntry("session", (int)Dock::DefaultSession)); qDebug() << "containment values: " << onPrimary << " - " << lastScreen; @@ -1403,7 +1330,7 @@ bool DockCorona::heuresticForLoadingDockWithTasks() } } - if (containsTasks && session == Dock::DefaultSession) { + if (containsTasks) { m_firstContainmentWithTasks = cId.toInt(); if (onPrimary) { diff --git a/app/dockcorona.h b/app/dockcorona.h index 2ccf298e2..dcc045599 100644 --- a/app/dockcorona.h +++ b/app/dockcorona.h @@ -86,10 +86,6 @@ public: void recreateDock(Plasma::Containment *containment); void copyDock(Plasma::Containment *containment); - Dock::SessionType currentSession(); - void setCurrentSession(Dock::SessionType session); - void switchToSession(Dock::SessionType session); - void aboutApplication(); void closeApplication(); @@ -108,7 +104,6 @@ public slots: signals: void configurationShown(PlasmaQuick::ConfigView *configView); - void currentSessionChanged(Dock::SessionType type); void docksCountChanged(); void dockLocationChanged(); void raiseDocksTemporaryChanged(); @@ -136,12 +131,10 @@ private: bool containmentContainsTasks(Plasma::Containment *cont); bool containmentExists(uint id) const; bool heuresticForLoadingDockWithTasks(); - int noDocksForSession(Dock::SessionType session); + int noOfDocks(); int primaryScreenId() const; bool m_activitiesStarting{true}; - //! used to initialize the docks when changing sessions - bool m_waitingSessionDocksCreation{false}; //! this is used to check if a dock with tasks in it will be loaded on startup bool m_tasksWillBeLoaded{false}; //! this is used to record the first dock having tasks in it. It is used @@ -150,7 +143,6 @@ private: int m_firstContainmentWithTasks{ -1}; QString m_layoutDir; - Dock::SessionType m_session{Dock::DefaultSession}; QHash m_dockViews; QHash m_waitingDockViews; diff --git a/app/dockview.cpp b/app/dockview.cpp index 48e3e5ab1..edd170de6 100644 --- a/app/dockview.cpp +++ b/app/dockview.cpp @@ -189,7 +189,6 @@ void DockView::init() connect(this, &DockView::dockWinBehaviorChanged, this, &DockView::saveConfig); connect(this, &DockView::onPrimaryChanged, this, &DockView::saveConfig); connect(this, &DockView::onPrimaryChanged, this, &DockView::reconsiderScreen); - connect(this, &DockView::sessionChanged, this, &DockView::saveConfig); connect(this, &DockView::locationChanged, this, [&]() { updateFormFactor(); syncGeometry(); @@ -344,7 +343,7 @@ void DockView::reconsiderScreen() //!check if the associated screen is running foreach (auto scr, qGuiApp->screens()) { if (m_screenToFollowId == scr->name() - || (onPrimary() && scr == qGuiApp->primaryScreen()) ) { + || (onPrimary() && scr == qGuiApp->primaryScreen())) { screenExists = true; } } @@ -356,7 +355,7 @@ void DockView::reconsiderScreen() //! even though it has been configured as an explicit if ((m_onPrimary || (tasksPresent() && dockCorona->noDocksWithTasks() == 1 && !screenExists)) && (m_screenToFollowId != qGuiApp->primaryScreen()->name() - || m_screenToFollow != qGuiApp->primaryScreen())) { + || m_screenToFollow != qGuiApp->primaryScreen())) { //change to primary screen only if the specific edge is free qDebug() << "updating the primary screen for dock..."; qDebug() << "available primary screen edges:" << dockCorona->freeEdges(qGuiApp->primaryScreen()); @@ -377,7 +376,7 @@ void DockView::reconsiderScreen() syncGeometry(); } - } else if (!m_onPrimary){ + } else if (!m_onPrimary) { //! 3.an explicit dock must be always on the correct associated screen //! there are cases that window manager misplaces the dock, this function //! ensures that this dock will return at its correct screen @@ -966,21 +965,6 @@ void DockView::setOnPrimary(bool flag) emit onPrimaryChanged(); } -Dock::SessionType DockView::session() const -{ - return m_session; -} - -void DockView::setSession(Dock::SessionType type) -{ - if (m_session == type) { - return; - } - - m_session = type; - emit sessionChanged(); -} - float DockView::maxLength() const { return m_maxLength; @@ -1908,7 +1892,6 @@ void DockView::saveConfig() auto config = this->containment()->config(); config.writeEntry("onPrimary", m_onPrimary); - config.writeEntry("session", (int)m_session); config.writeEntry("dockWindowBehavior", m_dockWinBehavior); emit this->containment()->configNeedsSaving(); } @@ -1920,7 +1903,6 @@ void DockView::restoreConfig() auto config = this->containment()->config(); setOnPrimary(config.readEntry("onPrimary", true)); - setSession((Dock::SessionType)config.readEntry("session", (int)Dock::DefaultSession)); setDockWinBehavior(config.readEntry("dockWindowBehavior", true)); } //!END configuration functions diff --git a/app/dockview.h b/app/dockview.h index 2f63cfbda..afb3860db 100644 --- a/app/dockview.h +++ b/app/dockview.h @@ -85,8 +85,6 @@ class DockView : public PlasmaQuick::ContainmentView { Q_PROPERTY(QRect maskArea READ maskArea WRITE setMaskArea NOTIFY maskAreaChanged) Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged) - Q_PROPERTY(Latte::Dock::SessionType session READ session WRITE setSession NOTIFY sessionChanged) - public: DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr, bool dockWindowBehavior = false); virtual ~DockView(); @@ -155,9 +153,6 @@ public: QRect localGeometry() const; void setLocalGeometry(const QRect &geometry); - Dock::SessionType session() const; - void setSession(Dock::SessionType type); - VisibilityManager *visibility() const; QQmlListProperty screens(); @@ -223,7 +218,6 @@ signals: void visibilityChanged(); void maskAreaChanged(); void screenGeometryChanged(); - void sessionChanged(); void shadowChanged(); void totalDocksCountChanged(); void xChanged(); @@ -269,7 +263,6 @@ private: float m_maxLength{1}; Dock::Alignment m_alignment{Dock::Center}; - Dock::SessionType m_session{Dock::DefaultSession}; QRect m_effectsArea; QRect m_localGeometry; diff --git a/app/globalsettings.cpp b/app/globalsettings.cpp index 6e7948038..7074791ea 100644 --- a/app/globalsettings.cpp +++ b/app/globalsettings.cpp @@ -54,8 +54,6 @@ GlobalSettings::GlobalSettings(QObject *parent) m_altSessionAction->setStatusTip(i18n("Enable/Disable Alternative Session")); m_altSessionAction->setCheckable(true); connect(m_altSessionAction, &QAction::triggered, this, &GlobalSettings::enableAltSession); - connect(m_corona, &DockCorona::currentSessionChanged, this, &GlobalSettings::currentSessionChangedSlot); - connect(m_corona, &DockCorona::currentSessionChanged, this, &GlobalSettings::loadLaunchers); //! create the add widgets action const QIcon addWidIcon = QIcon::fromTheme("add"); @@ -109,11 +107,11 @@ void GlobalSettings::showWidgetsExplorer() void GlobalSettings::enableAltSession(bool enabled) { - if (enabled) { + /*if (enabled) { m_corona->switchToSession(Dock::AlternativeSession); } else { m_corona->switchToSession(Dock::DefaultSession); - } + }*/ } bool GlobalSettings::exposeAltSession() const @@ -132,15 +130,6 @@ void GlobalSettings::setExposeAltSession(bool state) emit exposeAltSessionChanged(); } -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 { @@ -221,18 +210,6 @@ void GlobalSettings::setAutostart(bool state) } } -Dock::SessionType GlobalSettings::currentSession() const -{ - return m_corona->currentSession(); -} - -void GlobalSettings::setCurrentSession(Dock::SessionType session) -{ - if (currentSession() != session) { - m_corona->switchToSession(session); - } -} - //!BEGIN configuration functions void GlobalSettings::load(bool all) { @@ -252,13 +229,13 @@ void GlobalSettings::load(bool all) void GlobalSettings::loadLaunchers() { - if (m_corona->currentSession() == Latte::Dock::AlternativeSession) { + /*if (m_corona->currentSession() == Latte::Dock::AlternativeSession) { m_syncLaunchers = m_configGroup.readEntry("syncLaunchers_alternative", false); m_globalLaunchers = m_configGroup.readEntry("globalLaunchers_alternative", QStringList()); } else { m_syncLaunchers = m_configGroup.readEntry("syncLaunchers_default", false); m_globalLaunchers = m_configGroup.readEntry("globalLaunchers_default", QStringList()); - } + }*/ emit syncLaunchersChanged(); emit globalLaunchersChanged(); @@ -268,14 +245,6 @@ void GlobalSettings::save() { m_configGroup.writeEntry("exposeAltSession", m_exposeAltSession); - if (m_corona->currentSession() == Latte::Dock::AlternativeSession) { - m_configGroup.writeEntry("syncLaunchers_alternative", m_syncLaunchers); - m_configGroup.writeEntry("globalLaunchers_alternative", m_globalLaunchers); - } else { - m_configGroup.writeEntry("syncLaunchers_default", m_syncLaunchers); - m_configGroup.writeEntry("globalLaunchers_default", m_globalLaunchers); - } - m_configGroup.sync(); } @@ -437,7 +406,7 @@ void GlobalSettings::importConfiguration() , m_fileDialog.data(), &QFileDialog::deleteLater); connect(m_fileDialog.data(), &QFileDialog::fileSelected - , this, [&](const QString & file) { + , this, [&](const QString & file) { importLayoutInternal(file); }); @@ -596,7 +565,7 @@ void GlobalSettings::exportConfiguration() , m_fileDialog.data(), &QFileDialog::deleteLater); connect(m_fileDialog.data(), &QFileDialog::fileSelected - , this, [&](const QString & file) { + , this, [&](const QString & file) { auto showNotificationError = []() { auto notification = new KNotification("export-fail", KNotification::CloseOnTimeout); notification->setText(i18nc("import/export config", "Failed to export configuration")); @@ -634,7 +603,7 @@ void GlobalSettings::exportConfiguration() notification->setText(i18nc("import/export config", "Configuration exported successfully")); connect(notification, &KNotification::action1Activated - , this, [file]() { + , this, [file]() { QDesktopServices::openUrl({QFileInfo(file).canonicalPath()}); }); diff --git a/app/globalsettings.h b/app/globalsettings.h index 8723ce8f5..588503e9d 100644 --- a/app/globalsettings.h +++ b/app/globalsettings.h @@ -44,8 +44,6 @@ class GlobalSettings : public QObject { Q_PROPERTY(bool syncLaunchers READ syncLaunchers WRITE setSyncLaunchers NOTIFY syncLaunchersChanged) Q_PROPERTY(QStringList globalLaunchers READ globalLaunchers WRITE setGlobalLaunchers NOTIFY globalLaunchersChanged) - Q_PROPERTY(Latte::Dock::SessionType currentSession READ currentSession WRITE setCurrentSession NOTIFY currentSessionChanged) - Q_PROPERTY(QAction *altSessionAction READ altSessionAction NOTIFY altSessionActionChanged) Q_PROPERTY(QAction *addWidgetsAction READ addWidgetsAction NOTIFY addWidgetsActionChanged) @@ -53,7 +51,7 @@ public: GlobalSettings(QObject *parent = nullptr); ~GlobalSettings() override; - void load(bool all=true); + void load(bool all = true); void reload(); bool autostart() const; @@ -71,9 +69,6 @@ public: QAction *addWidgetsAction() const; - Latte::Dock::SessionType currentSession() const; - void setCurrentSession(Latte::Dock::SessionType session); - static bool importHelper(const QString &fileName); Q_INVOKABLE void importConfiguration(); Q_INVOKABLE void exportConfiguration(); @@ -85,13 +80,12 @@ signals: void altSessionActionChanged(); void autostartChanged(); void clearLayoutSelection(); - void currentSessionChanged(); void exposeAltSessionChanged(); void globalLaunchersChanged(); void syncLaunchersChanged(); private slots: - void currentSessionChangedSlot(Dock::SessionType type); + // void currentSessionChangedSlot(Dock::SessionType type); void enableAltSession(bool enabled); void importLayoutInternal(const QString &file); void loadLaunchers();