appmenu.visible is not properly updated for windows without menu or that do not export it
Closed this issue · 5 comments
Not sure if this is an upstream bug...:
The responsible variable is appmenuEnabledAndNonEmpty which does not change from true to false immediately.
On top of your version I set a function to change window title, so the full title is shown for windows without menu export, but only the name of the app for those that do (this avoids superlong window titles together with the menu).
Now to the point:
What I see is that kf5 dependent apps (those that export the menu) show appmenuEnabledAndNonEmpty = false
immediately after moving from an application that does not export the menu, which is wrong as kf5-based applications should have appmenuEnabledAndNonEmpty = true
.
@kotelnik, Could you please try to confirm?
From here two things then happen:
- if you move to another kf5-dependent app, everything comes back to normal
- but if you move to another non-exporting menu app, then
appmenuEnabledAndNonEmpty = true
, even if that is not the case. And the improper bool value stays (ie, impropertrue
for non-exporting menu apps and improperfalse
for exporting menu apps) while switching between exporting and non-exporting menu apps.
I tried to figure out what is wrong in appmenuEnabledAndNonEmpty, but could not figure it out...
So far I cannot replicate this issue. Please send me your diff so I can test the same code you have problems with. Thanks!
Please see below:
diff --git a/.gitignore b/.gitignore
index 6d4ec1c..d709cf5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,6 @@
+<<<<<<< HEAD
+build
+=======
#the build directory
build/
+>>>>>>> master
diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml
index 97caae1..f914d35 100644
--- a/package/contents/ui/main.qml
+++ b/package/contents/ui/main.qml
@@ -146,7 +146,7 @@ Item {
windowTitleText.text = plasmoid.configuration.noWindowText
iconItem.source = plasmoid.configuration.noWindowIcon
} else {
- windowTitleText.text = textType === 1 ? actTask.AppName : replaceTitle(actTask.display)
+ windowTitleText.text = textType === 1 ? actTask.AppName : reverseTitleOrder(fineTuning(actTask.display)) // modification by regexp is not sufficient for my needs, using fineTuning and reverseTitleOrder instead // actTask.AppName : replaceTitle(actTask.display)
iconItem.source = actTask.decoration
}
}
@@ -290,6 +290,72 @@ Item {
}
}
+ function reverseTitleOrder(title) {
+ // FIXME this does not work as expected as this moment
+ var enableSuffix = (!appmenu.visible || !appmenuNextToIconAndText);
+ // using this alternative for now -- no suffix for any application
+ // var enableSuffix = !appmenuNextToIconAndText;
+ var revTitle;
+ var lastPos = title.lastIndexOf(" — "); // U+2014 "EM DASH"
+ if (lastPos > -1) {
+ revTitle = title.slice(lastPos+3,title.length);
+ if (enableSuffix) {
+ revTitle = revTitle.concat(" — "); // U+2014 "EM DASH"
+ revTitle = revTitle.concat(title.slice(0, lastPos));
+ }
+ }
+ else {
+ lastPos = title.lastIndexOf(" – "); // U+2013 "EN DASH"
+ if (lastPos > -1) {
+ revTitle = title.slice(lastPos+3,title.length);
+ if (enableSuffix) {
+ revTitle = revTitle.concat(" — "); // U+2014 "EM DASH"
+ revTitle = revTitle.concat(title.slice(0, lastPos));
+ }
+ }
+ else {
+ lastPos = title.lastIndexOf(" - "); // ASCII Dash
+ if (lastPos > -1) {
+ revTitle = title.slice(lastPos+3,title.length);
+ if (enableSuffix) {
+ revTitle = revTitle.concat(" — "); // U+2014 "EM DASH"
+ revTitle = revTitle.concat(title.slice(0, lastPos));
+ }
+ }
+ else {
+ lastPos = title.lastIndexOf(": "); // semicolon (Chromium)
+ if (lastPos > -1) {
+ revTitle = title.slice(lastPos+2,title.length);
+ if (enableSuffix) {
+ revTitle = revTitle.concat(" — "); // U+2014 "EM DASH"
+ revTitle = revTitle.concat(title.slice(0, lastPos));
+ }
+ }
+ else
+ revTitle = title;
+ }
+ }
+ }
+ return revTitle;
+ }
+
+ function fineTuning(title) {
+ title = title.replace("Mozilla ", ""); // Remove Mozilla prefix from Mozilla Apps
+ title = title.replace("Google ", ""); // Remove Google prefix from Google Apps
+ title = title.replace(" Player", ""); // Remove Player suffix from Dragon Player
+ title = title.replace(" Documents", ""); // Remove Documents suffix from Utopia Documents
+ title = title.replace("DDD: Debugger Console", "Debugger Console — DDD"); // Remove suffix from DDD
+ var lastPos = title.lastIndexOf("MATLAB "); // Matlab
+ if (lastPos > -1) {
+ title = title.slice(lastPos+7,title.length) + " — Matlab";
+ }
+ var lastPos = title.lastIndexOf("Utopia "); // Utopia
+ if (lastPos > -1) {
+ title = title.slice(lastPos+7,title.length) + " — Utopia";
+ }
+ return title;
+ }
+
function replaceTitle(title) {
if (!plasmoid.configuration.useWindowTitleReplace) {
return title
Have you been able to test this issue in your system with the above diff? Thanks in advance for checking this out!
Sorry for the delay... The problem is that visibility of the AppMenu is in this case determined after the title change, so too late for processing. These 2 lines in main.qml fix the issue:
property bool appmenuVisible: appmenu.visible
onAppmenuVisibleChanged: updateActiveWindowInfo()
It worked like a charm. Many thanks!