mirukana / mirage

A fancy, customizable, keyboard-operable Qt/QML & Python Matrix chat client for encrypted and decentralized communication.
GNU Lesser General Public License v3.0
411 stars 40 forks source link

Minimize to tray behaviour addition #127

Open apollo1917 opened 4 years ago

apollo1917 commented 4 years ago

Description

For convenience it would be nice if the mirage window could also be opened from latte dock when minimized to tray. This is the behavior in most other chat apps when minimized to tray.

Observed behavior: When mirage is minimized to tray attempting to open mirage from an app launcher, app menu or dock does nothing.

Expected behavior: When mirage is minimized to tray attempting to launch mirage from an app launcher, app menu or dock should open the minimized mirage window (the same behavior as left clicking on the tray icon).

Your environment

vSLG commented 4 years ago

Can you please check if there is a file called .show on your config directory (~/.config/mirage)?

apollo1917 commented 4 years ago

.show is present in my ~/.config/mirage

vSLG commented 4 years ago

This file is created when you try to launch Mirage and there is a valid lock file in your configuration directory. There is a file watcher looking for this .show file, so when it exists, Mirage will show up. Apparently, its code is not working properly on your side. I will further investigate it.

apollo1917 commented 4 years ago

To add, if I try to run mirage from the terminal while a mirage instance is minimized to tray I get a message:

"Opening already running instance"

But nothing happens

apollo1917 commented 4 years ago

Thanks for looking into it!

vSLG commented 4 years ago

Can you test if this branch of my Mirage fork is behaving properly? I ran into some problems too when coding this file watcher.

We use SystemTrayIcon QML type for the tray icon, and I created the file watcher (FolderListModel) as a property of SystemTrayIcon. It happens that SystemTrayIcon is not a visual type, thus it cannot have children objects of visual type. What is happening, is that FolderListModel is not being created, apparently, because it is a visual type (I know because I tried to create it as direct child and QML refused to create the object).

So here is what I did: instead of having FolderListModel as property of SystemTrayIcon, I made a parent object for both:

Item {
  SystemTrayIcon { ... }
  FolderListModel { ... }
}

I can say it is functional on my side.

apollo1917 commented 4 years ago

For me this branch has the same behavior as before, ".show" is created when trying to open from the dock when minimized to tray but the file watcher does not seem to recognize or act on the creation of the file as nothing happens after that.

vSLG commented 4 years ago

Let's check if the FolderListModel is being created on the first place. I added 2 print statements on the FolderListModel code:

FolderListModel {
  ...
  Component.onCompleted: print(folder)
  onFolderChanged: print(folder)
  ...
}

The first should print the Mirage binary location or your current location. The second one should print your config directory.

Can you please pull, test and report results?

apollo1917 commented 4 years ago

I see the first print, my current directory, but not the second print.

vSLG commented 4 years ago

I added more print statements. Can you test again?

vSLG commented 4 years ago

It seems FolderListModel is not getting the property change from C++ side. On this line, we set the settingsFolder property of Window.qml, that will be used on FolderListModel.

When programming the system tray, I had problems with aliases when trying to set their value from C++, their value would not be set. In the last commit, I also removed the alias for the settingsFolder of TrayIcon.qml and I am now using the window object directly.

apollo1917 commented 4 years ago

I now see one print of the current dir and one print of the settings dir.

mirukana commented 4 years ago

Can you test if this branch of my Mirage fork is behaving properly? I ran into some problems too when coding this file watcher.

We use SystemTrayIcon QML type for the tray icon, and I created the file watcher (FolderListModel) as a property of SystemTrayIcon. It happens that SystemTrayIcon is not a visual type, thus it cannot have children objects of visual type. What is happening, is that FolderListModel is not being created, apparently, because it is a visual type (I know because I tried to create it as direct child and QML refused to create the object).

So here is what I did: instead of having FolderListModel as property of SystemTrayIcon, I made a parent object for both:

Item {
  SystemTrayIcon { ... }
  FolderListModel { ... }
}

I can say it is functional on my side.

FolderListModel is not a visual type. You can't make it a direct child of SystemTrayIcon because the SystemTrayIcon type doesn't inherit from Item, which has a default data property; but having the FolderListModel as a property of the SystemTrayIcon is no problem.