mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-09 00:58:15 +03:00
sniff latte view id through contextData
--the menu is sending the containment id to Latte::Corona and afterwards calls for the menu data. These data now are including also the view type, memory usage, active layout name and of course the full layouts list shown to menu. This is improvement from D18918.
This commit is contained in:
parent
a375902442
commit
d2ea33e236
@ -16,8 +16,11 @@
|
||||
<method name="showSettingsWindow">
|
||||
<arg name="page" type="i" direction="in"/>
|
||||
</method>
|
||||
<method name="setContextMenuView">
|
||||
<arg name="id" type="i" direction="in"/>
|
||||
</method>
|
||||
<method name="contextMenuData">
|
||||
<arg name="data" type="as" direction="out"/>
|
||||
<arg name="data" type="as" direction="out"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
|
@ -959,11 +959,23 @@ void Corona::showSettingsWindow(int page)
|
||||
m_layoutManager->showLatteSettingsDialog(p);
|
||||
}
|
||||
|
||||
void Corona::setContextMenuView(int id)
|
||||
{
|
||||
//! set context menu view id
|
||||
m_contextMenuViewId = id;
|
||||
}
|
||||
|
||||
QStringList Corona::contextMenuData()
|
||||
{
|
||||
QStringList data;
|
||||
Types::ViewType viewType{Types::DockView};
|
||||
|
||||
Layout *currentLayout = m_layoutManager->currentLayout();
|
||||
|
||||
if (currentLayout) {
|
||||
viewType = currentLayout->latteViewType(m_contextMenuViewId);
|
||||
}
|
||||
|
||||
data << QString::number((int)m_layoutManager->memoryUsage());
|
||||
data << m_layoutManager->currentLayoutName();
|
||||
data << QString::number((int)viewType);
|
||||
@ -976,6 +988,8 @@ QStringList Corona::contextMenuData()
|
||||
}
|
||||
}
|
||||
|
||||
//! reset context menu view id
|
||||
m_contextMenuViewId = -1;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,7 @@ public:
|
||||
//! these functions are used from context menu through containmentactions
|
||||
void switchToLayout(QString layout);
|
||||
void showSettingsWindow(int page);
|
||||
void setContextMenuView(int id);
|
||||
QStringList contextMenuData();
|
||||
|
||||
public slots:
|
||||
@ -166,6 +167,8 @@ private:
|
||||
//!it can be used on startup to change memory usage from command line
|
||||
int m_userSetMemoryUsage{ -1};
|
||||
|
||||
int m_contextMenuViewId{-1};
|
||||
|
||||
QString m_layoutNameOnStartUp;
|
||||
|
||||
QList<KDeclarative::QmlObject *> m_alternativesObjects;
|
||||
|
@ -113,8 +113,7 @@ QList<QAction *> Menu::contextualActions()
|
||||
QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus());
|
||||
|
||||
if (iface.isValid()) {
|
||||
iface.call("contextMenuData", containment()->id());
|
||||
|
||||
iface.call("setContextMenuView", (int)containment()->id());
|
||||
QDBusReply<QStringList> replyData = iface.call("contextMenuData");
|
||||
|
||||
m_data = replyData.value();
|
||||
|
Loading…
x
Reference in New Issue
Block a user