support to send the viewType through dbus

pull/4/head
Michail Vourlakos 6 years ago
parent 9eb5e25a2c
commit a375902442

@ -962,9 +962,11 @@ void Corona::showSettingsWindow(int page)
QStringList Corona::contextMenuData()
{
QStringList data;
Types::ViewType viewType{Types::DockView};
data << QString::number((int)m_layoutManager->memoryUsage());
data << m_layoutManager->currentLayoutName();
data << QString::number((int)viewType);
foreach (auto layoutName, m_layoutManager->menuLayouts()) {
if (m_layoutManager->activeLayout(layoutName)) {

@ -816,6 +816,17 @@ QHash<const Plasma::Containment *, Latte::View *> *Layout::latteViews()
return &m_latteViews;
}
Types::ViewType Layout::latteViewType(int containmentId) const
{
foreach (auto view, m_latteViews) {
if (view->containment() && view->containment()->id() == containmentId) {
return view->type();
}
}
return Types::DockView;
}
Latte::View *Layout::highestPriorityView()
{
QList<Latte::View *> views = sortedLatteViews();

@ -21,6 +21,9 @@
#ifndef LAYOUT_H
#define LAYOUT_H
// local
#include "../../liblatte2/types.h"
// Qt
#include <QObject>
#include <QPointer>
@ -143,6 +146,8 @@ public:
QList<Latte::View *> sortedLatteViews();
QList<Latte::View *> viewsWithPlasmaShortcuts();
Types::ViewType latteViewType(int containmentId) const;
Latte::View *highestPriorityView();
//! Bind this latteView and its relevant containments(including systrays)

@ -39,6 +39,8 @@
#include <Plasma/Corona>
#include <Plasma/ServiceJob>
const int LAYOUTSPOS = 3;
Menu::Menu(QObject *parent, const QVariantList &args)
: Plasma::ContainmentActions(parent, args)
{
@ -107,22 +109,30 @@ QList<QAction *> Menu::contextualActions()
actions << m_addWidgetsAction;
actions << m_configureAction;
m_layoutsData.clear();
m_data.clear();
QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus());
if (iface.isValid()) {
iface.call("contextMenuData", containment()->id());
QDBusReply<QStringList> replyData = iface.call("contextMenuData");
m_layoutsData = replyData.value();
m_data = replyData.value();
}
if (m_layoutsData.size() > 3) {
if (m_data.size() > LAYOUTSPOS + 1) {
m_layoutsAction->setEnabled(true);
m_layoutsAction->setVisible(true);
} else {
m_layoutsAction->setVisible(false);
}
Latte::Types::ViewType viewType{Latte::Types::DockView};
if (m_data.size() >= LAYOUTSPOS + 1) {
viewType = static_cast<Latte::Types::ViewType>((m_data[2]).toInt());
}
return actions;
}
@ -143,15 +153,15 @@ void Menu::populateLayouts()
{
m_switchLayoutsMenu->clear();
if (m_layoutsData.size() > 3) {
if (m_data.size() > LAYOUTSPOS + 1) {
//when there are more than 1 layouts present
Latte::Types::LayoutsMemoryUsage memoryUsage = static_cast<Latte::Types::LayoutsMemoryUsage>((m_layoutsData[0]).toInt());
QString currentName = m_layoutsData[1];
Latte::Types::LayoutsMemoryUsage memoryUsage = static_cast<Latte::Types::LayoutsMemoryUsage>((m_data[0]).toInt());
QString currentName = m_data[1];
for (int i = 2; i < m_layoutsData.size(); ++i) {
bool isActive = m_layoutsData[i].startsWith("0") ? false : true;
for (int i = LAYOUTSPOS; i < m_data.size(); ++i) {
bool isActive = m_data[i].startsWith("0") ? false : true;
QString layout = m_layoutsData[i].right(m_layoutsData[i].length() - 2);
QString layout = m_data[i].right(m_data[i].length() - 2);
QString currentText = (memoryUsage == Latte::Types::MultipleLayouts && layout == currentName) ?
(" " + i18nc("current layout", "(Current)")) : "";

@ -48,7 +48,7 @@ private Q_SLOTS:
private:
QStringList m_layoutsData;
QStringList m_data;
QList<QAction *>m_actions;

Loading…
Cancel
Save