Bug 363852 - Ktorrent no longer starts hidden in tray
Summary: Ktorrent no longer starts hidden in tray
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (show other bugs)
Version: 5.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
: 395495 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-06-02 18:17 UTC by Matt Scheirer
Modified: 2020-06-12 10:33 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
one liner fix (773 bytes, patch)
2020-05-17 06:42 UTC, Matt Scheirer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Scheirer 2016-06-02 18:17:06 UTC
GUI::loadState has functionality to start ktorrent minimized when Settings::showSystemTrayIcon() && hidden_on_exit is true. Since 5.0, this code still works, but something else (outside GUI) is showing the window, when I overrided QWidget::setVisible it would always happen twice - first, the loadState function is called, and then QWidget is set visible even when loadState sets it false, within 2 log entries every time.

The only other functionality within ktorrent itself that interacts with widget visibility is the function GUI::showOrHide, which is linked to the signal show_kt_action, which is NOT what causes the visibility toggle.

So whatever it is, its somewhere up the stack, in either KMainWindow or QWidget, and it probably has something to do with refactoring in the Qt5 widget changes, but I'm personally out of ideas at this point and spent way too much time recompiling ktorrent wondering why in the world this was happening! Hopefully someone else has an idea.
Comment 1 David Zaslavsky 2017-04-11 21:36:51 UTC
I'm experiencing the same issue, that KTorrent always starts up with a full window, whereas I'd like it to start minimized in the tray. Unfortunately I'm not familiar with the code base so I'm unlikely to be of much help fixing the bug, but I suppose this is some kind of independent confirmation that it does happen.
Comment 2 Lastique 2017-11-04 10:30:53 UTC
Happens to me as well on Kubuntu 17.10, Ktorrent 5.1.0.
Comment 3 Janek 2018-05-29 21:04:24 UTC
This is still happening! It bugs me that a KTorrent window opens every single time upon startup. I might stop it from autostarting due to that, which means I'd stop seeding. I don'T want to do that, but why is such a seemingly simple issue still not fixed?
Comment 4 Kevin Zeidler 2018-08-15 01:40:32 UTC
I'm also experiencing this. Kubuntu 18.04, Ktorrent 5.1.0. Oddly, attempts to activate the window elicit a stale notification warning about attempting to add a duplicate torrent. When I asked Kubuntu not to notify me of those events, it started warning me instead that "preferences" is a malformed URL. It also keeps sending erroneous notifications that a particular large file I'm downloading (70GB) is finished downloading. Strange stuff. Seems like it's having trouble transitioning out of error states, like it didn't release a warning it broadcast earlier to ibus so every interaction it thinks is an error condition.
Comment 5 Andrew Shark 2018-09-21 09:02:10 UTC
As a partial workaround, I have done the following: 
Right click on the window title ->  More Actions -> Special Application Settings... New window will appear. Go to "Size & Position" tab and enable checkbox "Minimized", choose "Apply Initially" and enable "yes" radio button. Then press OK button.

Now KTorrent window will be minimized in task manager every startup. But still it will not be completely hidden in system tray and you need to close minimized window by right clicking in task manager. At least this workaround makes your desktop less cluttered at startup (which is especially annoying when you reboot often).
Comment 6 Andrew Shark 2018-09-21 09:33:03 UTC
Why there is no such option to start KTorrent in tray? For example, in Kopete there is checkbox "Start with hidden main window" in Behavior settings. I would like to see the same checkbox in KTorrent.
I have also found Bug 251864, but they suggested that ktorrent was double starting and because of that its window appeared (second calling of ktorrent just showed ktorrent window of already running application instead of launching second instance of application). It is not a case for me, because I do not have ktorrent in autostart applications, so it is starting once when session is restoring after login in kde.
Comment 7 Andrew Shark 2018-09-25 05:32:56 UTC
I have found a better workaround. You can download my script at https://github.com/Ashark/Ashark-bin/blob/master/ktorrent-window-closer and set kde to autostart it.
The main idea is to run wmctrl -x -c "ktorrent" command, which closes ktorrent window.
Now it behaves exactly as expected: no window at startup (at all, not  minimized to task manager), but still running in tray.
Comment 8 kikox1 2019-08-07 15:30:56 UTC
In debian 10 the problem persist.

In this link (https://forum.manjaro.org/t/how-to-start-programs-minimized-to-system-tray/48159/6) I found an workarround

In application settings for it (in Window Rules) (click right buttom in title bar of ktorrent)

Size & Position: minimized - apply initially 
Arrangement & Access: skip taskbar - apply initially
Comment 9 Lastique 2019-08-19 16:55:04 UTC
(In reply to kikox1 from comment #8)
> I found an workarround
> 
> In application settings for it (in Window Rules) (click right buttom in
> title bar of ktorrent)
> 
> Size & Position: minimized - apply initially 
> Arrangement & Access: skip taskbar - apply initially

This doesn't work as intended. After these steps Ktorrent never appears in the taskbar, neither after start, nor after minimizing and restoring.

Size & Position workaround has the tendency to affect other Ktorrent windows beside the main window. For example, the dialog for adding a new torrent gets created minimized. You have to create a very specific rule to match just the main window (in my case, I have to match the window title, and I'm not sure how stable the title is).
Comment 10 Lastique 2019-08-19 16:58:44 UTC
Oh, and Size & Position is also applied when Ktorrent gets restored from the tray icon, which means it always gets restored minimized.
Comment 11 kikox1 2019-08-22 16:20:42 UTC
(In reply to Lastique from comment #9)
> (In reply to kikox1 from comment #8)
> > I found an workarround
> > 
> > In application settings for it (in Window Rules) (click right buttom in
> > title bar of ktorrent)
> > 
> > Size & Position: minimized - apply initially 
> > Arrangement & Access: skip taskbar - apply initially
> 
> This doesn't work as intended. After these steps Ktorrent never appears in
> the taskbar, neither after start, nor after minimizing and restoring.
> 
> Size & Position workaround has the tendency to affect other Ktorrent windows
> beside the main window. For example, the dialog for adding a new torrent
> gets created minimized. You have to create a very specific rule to match
> just the main window (in my case, I have to match the window title, and I'm
> not sure how stable the title is).

Yes it works for me like this:
Ktorrent never appears on the taskbar, either after startup, or after minimizing and restoring. It only appears in the tray. When restoring the window opens and does not appear in the taskbar.
If the dialog is opened from the application menu when the window is open, it looks good if it opens with the menu that appears by pressing the right mouse button on the tray icon, the dialogs appear minimized.

What you get is that it does not appear open when you start the pc
What you get is that it never appears on the taskbar

Skip taskbar
    Toggle whether to display the window in the taskbar.
Comment 12 Christoph Feck 2020-05-14 14:25:40 UTC
*** Bug 395495 has been marked as a duplicate of this bug. ***
Comment 13 Matt Scheirer 2020-05-17 06:42:51 UTC
Created attachment 128536 [details]
one liner fix
Comment 14 Matt Scheirer 2020-05-17 06:45:46 UTC
Were coming on the four year mark that I reported this and nobody ever fixed it, so heres the fix after an hour counting show() calls on GUI to make sure I wasn't missing something obvious with a one liner fix like this.

main doesn't need to show the GUI because GUI::loadState will already show the window whenever its appropriate on startup. This redundant call after constructing GUI just means the window always shows and happens after the check to start in the tray.

Removing it means the logic in loadState actually dictates if the window is shown on startup or not. Tested it with all the combinations of options - works as intended from what I can see.
Comment 15 Christoph Feck 2020-05-22 20:49:02 UTC
Could you please submit your patch for review by our developers?

See https://community.kde.org/Get_Involved/development#Submit_a_patch
Comment 16 Matt Scheirer 2020-05-24 23:35:19 UTC
I did go and make a pull request on Invent for the fix @ https://invent.kde.org/network/ktorrent/-/merge_requests/1. Don't think anyone with access is paying attention to Gitlab yet.
Comment 17 Christoph Feck 2020-06-12 10:33:13 UTC
Fix from comment 16 got merged.