mirror of
https://github.com/KDE/latte-dock.git
synced 2025-08-29 17:49:28 +03:00
improve identify applets expanded state
This commit is contained in:
@ -549,7 +549,7 @@ void View::statusChanged(Plasma::Types::ItemStatus status)
|
||||
|
||||
if (status == Plasma::Types::NeedsAttentionStatus) {
|
||||
m_visibility->addBlockHidingEvent(BLOCKHIDINGNEEDSATTENTIONTYPE);
|
||||
setFlags(flags() | Qt::WindowDoesNotAcceptFocus);
|
||||
m_visibility->initViewFlags();
|
||||
} else if (status == Plasma::Types::AcceptingInputStatus) {
|
||||
m_visibility->removeBlockHidingEvent(BLOCKHIDINGNEEDSATTENTIONTYPE);
|
||||
setFlags(flags() & ~Qt::WindowDoesNotAcceptFocus);
|
||||
@ -557,8 +557,8 @@ void View::statusChanged(Plasma::Types::ItemStatus status)
|
||||
} else {
|
||||
updateTransientWindowsTracking();
|
||||
m_visibility->removeBlockHidingEvent(BLOCKHIDINGNEEDSATTENTIONTYPE);
|
||||
setFlags(flags() | Qt::WindowDoesNotAcceptFocus);
|
||||
}
|
||||
m_visibility->initViewFlags();
|
||||
}
|
||||
}
|
||||
|
||||
void View::addTransientWindow(QWindow *window)
|
||||
@ -1454,10 +1454,15 @@ bool View::appletIsExpandable(const int id)
|
||||
|
||||
for (const auto applet : containment()->applets()) {
|
||||
if (applet->id() == (uint)id) {
|
||||
if (layout() && layout()->isInternalContainment(applet)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlasmaQuick::AppletQuickItem *ai = applet->property("_plasma_graphicObject").value<PlasmaQuick::AppletQuickItem *>();
|
||||
|
||||
if (ai) {
|
||||
return (ai->preferredRepresentation() != ai->fullRepresentation());
|
||||
return (ai->fullRepresentation() != nullptr
|
||||
&& ai->preferredRepresentation() != ai->fullRepresentation());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1465,6 +1470,26 @@ bool View::appletIsExpandable(const int id)
|
||||
return false;
|
||||
}
|
||||
|
||||
int View::expandedInternalContainment() const
|
||||
{
|
||||
return m_expandedInternalContainemt;
|
||||
}
|
||||
|
||||
void View::on_internalContainmentExpandedChanged()
|
||||
{
|
||||
PlasmaQuick::AppletQuickItem *internalContainmentAppletItem = static_cast<PlasmaQuick::AppletQuickItem *>(QObject::sender());
|
||||
|
||||
if (internalContainmentAppletItem) {
|
||||
if (internalContainmentAppletItem->isExpanded()) {
|
||||
m_expandedInternalContainemt = internalContainmentAppletItem->applet()->id();
|
||||
emit expandedInternalContainmentChanged();
|
||||
} else if (m_expandedInternalContainemt == (int)internalContainmentAppletItem->applet()->id()){
|
||||
m_expandedInternalContainemt = -1;
|
||||
emit expandedInternalContainmentChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool View::appletIsExpanded(const int id)
|
||||
{
|
||||
if (!containment()) {
|
||||
@ -1473,10 +1498,38 @@ bool View::appletIsExpanded(const int id)
|
||||
|
||||
for (const auto applet : containment()->applets()) {
|
||||
if (applet->id() == (uint)id) {
|
||||
PlasmaQuick::AppletQuickItem *ai = applet->property("_plasma_graphicObject").value<PlasmaQuick::AppletQuickItem *>();
|
||||
if (m_layout && m_layout->isInternalContainment(applet)) {
|
||||
//! internal containment case
|
||||
Plasma::Containment *internalC = layout()->internalContainmentOf(applet);
|
||||
PlasmaQuick::AppletQuickItem *contAi = applet->property("_plasma_graphicObject").value<PlasmaQuick::AppletQuickItem *>();
|
||||
|
||||
if (ai) {
|
||||
return (ai->isExpanded());
|
||||
if (contAi && !m_internalContainmentsConnections.contains(contAi)) {
|
||||
//! For some reason internal containments change their expanded state when showing their
|
||||
//! general popup with delay, we make sure to catch that signal correctly
|
||||
m_internalContainmentsConnections[contAi] = connect(contAi, &PlasmaQuick::AppletQuickItem::expandedChanged, this, &View::on_internalContainmentExpandedChanged);
|
||||
|
||||
connect(contAi, &QObject::destroyed, this, [&, contAi](){
|
||||
m_internalContainmentsConnections.remove(contAi);
|
||||
});
|
||||
}
|
||||
|
||||
for (const auto internalApplet : internalC->applets()) {
|
||||
PlasmaQuick::AppletQuickItem *ai = internalApplet->property("_plasma_graphicObject").value<PlasmaQuick::AppletQuickItem *>();
|
||||
|
||||
if (ai) {
|
||||
if (ai->isExpanded()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
PlasmaQuick::AppletQuickItem *ai = applet->property("_plasma_graphicObject").value<PlasmaQuick::AppletQuickItem *>();
|
||||
|
||||
if (ai) {
|
||||
return (ai->isExpanded());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,11 @@ class Corona;
|
||||
class Containment;
|
||||
}
|
||||
|
||||
namespace PlasmaQuick {
|
||||
class AppletQuickItem;
|
||||
}
|
||||
|
||||
|
||||
namespace KWayland {
|
||||
namespace Client {
|
||||
class PlasmaShellSurface;
|
||||
@ -94,6 +99,7 @@ class View : public PlasmaQuick::ContainmentView
|
||||
Q_PROPERTY(bool isTouchingTopViewAndIsBusy READ isTouchingTopViewAndIsBusy WRITE setIsTouchingTopViewAndIsBusy NOTIFY isTouchingTopViewAndIsBusyChanged)
|
||||
|
||||
Q_PROPERTY(int alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
||||
Q_PROPERTY(int expandedInternalContainment READ expandedInternalContainment NOTIFY expandedInternalContainmentChanged);
|
||||
Q_PROPERTY(int fontPixelSize READ fontPixelSize WRITE setFontPixelSize NOTIFY fontPixelSizeChanged)
|
||||
Q_PROPERTY(int x READ x NOTIFY xChanged)
|
||||
Q_PROPERTY(int y READ y NOTIFY yChanged)
|
||||
@ -175,6 +181,8 @@ public:
|
||||
int fontPixelSize() const;
|
||||
void setFontPixelSize(int size);
|
||||
|
||||
int expandedInternalContainment() const;
|
||||
|
||||
int editThickness() const;
|
||||
void setEditThickness(int thickness);
|
||||
|
||||
@ -280,6 +288,7 @@ signals:
|
||||
void dockLocationChanged();
|
||||
void editThicknessChanged();
|
||||
void effectsChanged();
|
||||
void expandedInternalContainmentChanged();
|
||||
void fontPixelSizeChanged();
|
||||
void forcedShown(); //[workaround] forced shown to avoid a KWin issue that hides windows when closing activities
|
||||
void widthChanged();
|
||||
@ -332,6 +341,8 @@ private slots:
|
||||
void addTransientWindow(QWindow *window);
|
||||
void removeTransientWindow(const bool &visible);
|
||||
|
||||
void on_internalContainmentExpandedChanged();
|
||||
|
||||
void restoreConfig();
|
||||
void saveConfig();
|
||||
|
||||
@ -362,6 +373,7 @@ private:
|
||||
|
||||
int m_fontPixelSize{ -1};
|
||||
int m_editThickness{24};
|
||||
int m_expandedInternalContainemt{-1};
|
||||
int m_maxThickness{24};
|
||||
int m_normalThickness{24};
|
||||
int m_offset{0};
|
||||
@ -404,6 +416,8 @@ private:
|
||||
//! Connections to release and bound for the assigned layout
|
||||
QList<QMetaObject::Connection> connectionsLayout;
|
||||
|
||||
QHash<PlasmaQuick::AppletQuickItem *, QMetaObject::Connection> m_internalContainmentsConnections;
|
||||
|
||||
//! track transientWindows
|
||||
QList<QWindow *> m_transientWindows;
|
||||
|
||||
|
@ -72,8 +72,7 @@ Item {
|
||||
&& applet.pluginName !== "org.kde.activeWindowControl"
|
||||
&& applet.pluginName !== "org.kde.plasma.appmenu")
|
||||
|
||||
property bool isExpanded: applet && applet.status >= PlasmaCore.Types.NeedsAttentionStatus
|
||||
&& applet.status !== PlasmaCore.Types.HiddenStatus
|
||||
property bool isExpanded: false
|
||||
|
||||
property bool isHidden: applet && applet.status === PlasmaCore.Types.HiddenStatus ? true : false
|
||||
property bool isInternalViewSplitter: (internalSplitterId > 0)
|
||||
@ -634,6 +633,11 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: applet
|
||||
onStatusChanged: appletItem.isExpanded = (root.latteView.appletIsExpandable(applet.id) && root.latteView.appletIsExpanded(applet.id));
|
||||
}
|
||||
|
||||
Connections {
|
||||
id: viewSignalsConnector
|
||||
target: root.latteView ? root.latteView : null
|
||||
|
@ -203,13 +203,11 @@ Item {
|
||||
|
||||
property bool plasmaBackgroundForPopups: plasmoid.configuration.plasmaBackgroundForPopups
|
||||
|
||||
readonly property bool hasExpandedApplet: plasmoid.applets.some(function (item) {
|
||||
return (item.status >= PlasmaCore.Types.NeedsAttentionStatus && item.status !== PlasmaCore.Types.HiddenStatus
|
||||
&& item.pluginName !== root.plasmoidName
|
||||
&& item.pluginName !== "org.kde.plasma.appmenu"
|
||||
&& item.pluginName !== "org.kde.windowappmenu"
|
||||
&& item.pluginName !== "org.kde.activeWindowControl");
|
||||
})
|
||||
readonly property bool hasExpandedApplet: (latteView && latteView.expandedInternalContainment>-1)
|
||||
|| plasmoid.applets.some(function (item) {
|
||||
var isExpanded = latteView.appletIsExpandable(item.id) && latteView.appletIsExpanded(item.id);
|
||||
return (latteView && item.status >= PlasmaCore.Types.UnknownStatus && isExpanded);
|
||||
});
|
||||
|
||||
readonly property bool hasUserSpecifiedBackground: (latteView && latteView.layout && latteView.layout.background.startsWith("/")) ?
|
||||
true : false
|
||||
|
Reference in New Issue
Block a user