Bug 183826 - Plasmoid: Easier way to cycle through torrents needed
Summary: Plasmoid: Easier way to cycle through torrents needed
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-09 20:38 UTC by Xenophon
Modified: 2009-05-03 10:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
torrent selection/navigation arrows and other fixes and enhancements (28.62 KB, patch)
2009-04-30 21:45 UTC, Amichai Rothman
Details
torrent selection/navigation arrows and other fixes and enhancements (28.58 KB, patch)
2009-05-01 16:01 UTC, Amichai Rothman
Details
torrent selection/navigation arrows and other fixes and enhancements (33.27 KB, patch)
2009-05-02 18:37 UTC, Amichai Rothman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xenophon 2009-02-09 20:38:41 UTC
Version:           3.2rc1 (using 4.2.00 (KDE 4.2.0), Kubuntu packages)
Compiler:          cc
OS:                Linux (i686) release 2.6.27-11-generic

The plasmoid only tracks a single torrent at a time. While this is fine, change the torrent being tracker currently involves the rather tedious process of going into the configuration window and choosing it manually. It might be worthwhile to:

a) have buttons in the widget and keyboard shortcuts to cycle through torrents.
b) have a configuration option to restrict the torrents that can be tracked to one of the groups (built-in ktorrent, custom or tracker groups).

Cheers,
-K
Comment 1 Amichai Rothman 2009-04-30 21:45:20 UTC
Created attachment 33250 [details]
torrent selection/navigation arrows and other fixes and enhancements
Comment 2 Amichai Rothman 2009-04-30 21:45:48 UTC
Made a patch with this and other improvements:
- added (fading) navigation arrows to cycle through torrents
- fixed configuration dialog size to make room for torrent names combobox
- fixed plasmoid initial size and rendering bugs (once in a while)
- fixed plasmoid incorrect data shown for large torrents (use qlonglong instead of int)
- added percent complete to displayed data
- made plasmoid movable by dragging anywhere (not just the chunkbar, which was probably a glitch)
- made init() method properly reentrant (oddly, it's being called more than once...)
- extracted duplicate functionality into separate methods, separated data from gui handling in some places, reorganized, added comments, misc small changes


caveats:
- no handling of torrent groups as suggested above
- the FadingItem class was shamelessly copied (unmodified) from the comics plasmoid, which is bad (not the plasmoid - the copying :-) ). I don't know if there's a way of including it straight from there, or better yet, moving it (and other) useful widgets into the plasma core libs to be reusable by all plasmoids. Any thoughts?
- drag-n-dropping form ktorrent seems broken. I compiled the plasmoid from before the last couple of patches, and it's still broken, so it might be a problem outside the plasmoid, or I might be missing something. the tmp file passed in the drop contains a bunch of 0xFFs which seems off (no pun intended). I'm mentioning this because I couldn't test it to make sure there's no regression... or maybe it is a bug in this or the previous patch.
Comment 3 Joris Guisson 2009-05-01 10:03:46 UTC
It's an elegant solution for switching. There is one problem though :

http://ktorrent.org/tmp/plasma_applet_cutoff.png

The last line of text is cut off, and if you enlarge the applet it remains cut off.

Dragging from ktorrent to the desktop works for me. (you need at least KDE 4.2 for this to work)
Comment 4 Joris Guisson 2009-05-01 10:09:15 UTC
There is another problem with drag and drop, it doesn't matter which torrent you drag, the same one is always dropped. Not sure if this is caused by the patch, or an existing problem.
Comment 5 Joris Guisson 2009-05-01 10:17:21 UTC
It's an existing problem.
Comment 6 Joris Guisson 2009-05-01 10:20:59 UTC
OK, I think I'm seeing the same problem as you, the tmp files only contain 0xFF's.
Comment 7 Amichai Rothman 2009-05-01 10:25:26 UTC
sorry I wasn't explicit enough - dragging does open the plasmoid, but does not show the correct draggec torrent - that's the problem I was referring to.
Comment 8 Amichai Rothman 2009-05-01 10:40:42 UTC
as for the cutoff - the spacing seems different on my machine than on urs - less space between lines, so it renders correctly. so I can't really recreate that artifact or be sure if it's working right... though my guess would be that it has to do with the misc->setMinimumSize and misc->setPreferredSize lines in the graphicsWidget method. It took me a while to get it right on my machine, so I'm sorry to hear it's broken elsewhere...

in short, the goal was to prevent the plasmoid from being too small (either by default, or by resizing) which causes the misc widget (the html table) to break lines, becoming ugly and causing lines to really get cut off the bottom (since it renders into more lines than before after breaking the lines). On the other hand, if for instance I remove the setPrefferedSize call, then the plasmoid becomes much taller, with lots of black space above and below the html table...

In short, having only a few days of experience with QT/KDE (just migrated from windows a couple months ago), I still didn't get a good grip of how to get it to layout a widget properly. So any help would be appreciated :-)

btw same goes for the fix for the config dialog - populating the combobox before adding the config page fixed the problem, but I couldn't find any way to just resize the dialog to properly contain it's contents when the reverse order still applied. I expected a simple adjustSize() or so to do the trick, but no variant of playing with size seemed to work. If u know how this would be done, I'd be happy to learn (though the fix as it is is good - no need to change it).

thanks...
Comment 9 Joris Guisson 2009-05-01 10:54:01 UTC
The point of the layout classes, is that you don't have to mess around with the size. This works perfectly for normal QWidget's but not for QGraphicsItem. I have messed around a lot trying to find a good solution for the plasma applet, but never really found one which wasn't a hack.
Comment 10 Amichai Rothman 2009-05-01 14:34:44 UTC
so -

1. the dragndrop bug is confirmed external to the plasmoid? should I open a separate bug report for it?
2. any way to reuse the comic's fadingitem class without code duplication?
3. any good fix for the layout issue? I'm guessing removing the misc->setPreferredSize() call will render correctly, even if it's a bit wasteful on vertical realestate. or the minimumSize can be expanded a bit (but no guarantee it'll break on someone else's system with huge fonts?)
4. anything else I can do?
Comment 11 Amichai Rothman 2009-05-01 16:01:01 UTC
Created attachment 33277 [details]
torrent selection/navigation arrows and other fixes and enhancements

just removed two unnecessary lines, and enlarged the table's size a bit.
Comment 12 Joris Guisson 2009-05-02 12:13:22 UTC
> 1. the dragndrop bug is confirmed external to the plasmoid? should I open a
> separate bug report for it?

Not yet, I'm gonna contact Aaron Seigo (he contributed the drag and drop).

> 2. any way to reuse the comic's fadingitem class without code duplication?

I'll raise that with Aaron, but if it is going to be included, it will take some time, and it will probably not be part of the next KDE release.

> 3. any good fix for the layout issue? I'm guessing removing the
> misc->setPreferredSize() call will render correctly, even if it's a bit
> wasteful on vertical realestate. or the minimumSize can be expanded a bit (but
> no guarantee it'll break on someone else's system with huge fonts?)

Ideally it is probably best to actually calculate the minimum size, the moment the current torrent changes.
Comment 13 Joris Guisson 2009-05-02 12:45:10 UTC
Did some more investigation into the drag and drop bug, and it turns out that the problem was ktorrent not passing the right data when the drag was initiated. This is now fixed.
Comment 14 Amichai Rothman 2009-05-02 18:37:52 UTC
Created attachment 33297 [details]
torrent selection/navigation arrows and other fixes and enhancements

Extracted a generic FadingNavigationWidget class for better code separation and component reuse.

Also changed the layout handling (limiting only width, to prevent table screwup, but not height) - it looks ok here, but I can't recreate the cutoff problem to see if it's better...

As for the code reuse - I suppose there's no point in waiting - may as well use the code as it is, and in the future replace with a common plasma widget when it becomes available. The code is well separated and organized, so it shouldn't be a problem to swap around later.
Comment 15 Joris Guisson 2009-05-03 10:33:54 UTC
SVN commit 962742 by guisson:

Add patch from amichai which adds easier navigation between torrents in plasma applet 

BUG: 183826


 M  +1 -0      ChangeLog  
 M  +1 -1      plasma/applet/CMakeLists.txt  
 M  +170 -156  plasma/applet/applet.cpp  
 M  +17 -7     plasma/applet/applet.h  
 M  +15 -27    plasma/applet/chunkbar.cpp  
 M  +4 -0      plasma/applet/chunkbar.h  
 A             plasma/applet/fadingitem.cpp   [License: GPL (v2+)]
 A             plasma/applet/fadingitem.h   [License: GPL (v2+)]
 A             plasma/applet/fadingnavigationwidget.cpp   [License: GPL (v2+)]
 A             plasma/applet/fadingnavigationwidget.h   [License: GPL (v2+)]


WebSVN link: http://websvn.kde.org/?view=rev&revision=962742