tsujan / FeatherNotes

Lightweight Qt Notes-Manager for Linux
GNU General Public License v3.0
109 stars 22 forks source link

An option for not opening the same doc twice #271

Closed tio-trom closed 2 years ago

tio-trom commented 2 years ago

At times I find myself opening multiple feathernotes simply because I have it setup to minimize in the tray area when closed. A useful feature. Is it possible to only allow 1 instance running?

tsujan commented 2 years ago

Is it possible to only allow 1 instance running?

Yes, of course. For example, FeatherPad is a single-instance app. The single-instance property is useful only when (1) different windows of the same app need to know about each other (in FeatherPad they do, e.g., for tab DND), or (2) there shouldn't be more than one window (like in most media players). Neither applies to FeatherNotes.

Or did you have something else in mind?

tio-trom commented 2 years ago

I meant to only allow 1 instance of the app to be opened. Now I can open multiple. I only want 1. Is that possible?

tsujan commented 2 years ago

That's (2). It's possible but not realistic. The user should be able to open multiple FeatherNotes files.

tio-trom commented 2 years ago

That's (2). It's possible but not realistic. The user should be able to open multiple FeatherNotes files.

I understand but when you use the option to minimize to tray, you may by mistake open a new instance of Feathernotes. At least when that option is present, maybe it makes sense to re-open it? I have tested this with several users for our TROMjaro distro that ships with Feathernotes by default, and out of 5 people 5 failed to realize that they have opened multiple instances of the app. 5 people is not enough but I thought to ask about this.

tsujan commented 2 years ago

...maybe it makes sense to re-open it?

Only if the same FeatherNotes doc is going to be opened again, not FeatherNotes' window with another doc or without any doc.

That's quite different and is a good feature. I changed the title....

tio-trom commented 2 years ago

Ok. However it won't solve the issue of opening, by mistake, multiple instances of Feathernotes. It is good to add what you are suggesting, but I'd say if the user selects to minimize on tray, you should perhaps prevent a new instance from opening as new....

Let me give you an example. I have tested multiple notes apps and if the notes app is already opened, then trying to open a new instance of that app will switch to the opened app. However if I try to open a file with the app it opens as a new instance. This way it prevents opening by mistake too many instances.

In any case is up to you. I thought to report it but you know best what makes sense for your app.

tsujan commented 2 years ago

This is the plan:

If doc0 is already opened, opening doc0 again in the file manager will result in activating its window; and similarly for doc1, doc2, etc. If no doc is opened but there is an open window without doc, it'll be activated on clicking the app icon in DE's main menu.

I'm afraid, anything else would be impractical. FeatherNotes should be able to open different FeatherNotes documents in separate windows, regardless of what other notes manager may do.

tio-trom commented 2 years ago

That sounds good actually. Makes sense!

tsujan commented 2 years ago

BTW, this feature requires changing of the whole code structure. So, its implementation may take some time.

Thanks a lot for the idea!

tio-trom commented 2 years ago

I understand. It is important that it will be implemented. Thank you for your work!

tsujan commented 2 years ago

Done in this huge commit: https://github.com/tsujan/FeatherNotes/commit/3c69a7b83d636150e02d187e9696446b16de5aca

Now, FeatherNotes is a single-process, multi-window app, with emphasis on opening each file only in one window. That's done by D-Bus — users of (non-Linux) systems without D-Bus won't see a difference.

I'll recheck the code and use the app for a while, before releasing version 1.0.0.

tio-trom commented 2 years ago

Oh wonderful and so fast. Thank you so much for this! I think it is a good improvement.

tsujan commented 2 years ago

You're welcome.

The main code was finished in an hour. Most of the time was spent on circumventing an old Qt issue that has never been fixed, not even in Qt6.