[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-multimedia
Subject:    Re: [PATCH] juk: save & restore playlist and tag editor sizes.
From:       Γι <ge
Date:       2011-05-09 9:43:20
Message-ID: BANLkTikpO1+zZ2MAaeoJCrx+BSCqiUz4Uw () mail ! gmail ! com
[Download RAW message or body]

2011/5/7 Michael Pyne <mpyne@kde.org>:
> On Saturday, May 07, 2011 01:10:31 Γιώργος Κυλάφας wrote:
>> the full motivation behind my proposed fix about the storing of
>> TagEditor's configuration on exit [1] was to show or not the TagEditor
>> *and* use the same size as the previous execution of JuK. However, the
>> latter was not supported, so I set out to implement it.
>>
>> I eventually came up with the attached patch. It follows the logic of
>> saving/restoring the PlaylistSplitter's size, applied to
>> "editorSplitter".
>>
>> I am not sure this is the proper/simpler/etc. way to accomplish this,
>> so I would appreciate your comments. :-)
>
> The patch works and is the right method.
>
> I'm not sure why you set sizes of 250/240 if no sizes were already saved
> though, doesn't the size hint for the tag editor give it a good default size?
> If so you wouldn't need to do anything special if there is no saved sized
> other than to not call m_editorSplitter->setSizes().
>
> Either way the patch should be fine to commit once you've figured out which
> looks more suitable (it's just that we don't all run the same resolution
> screens so I try to avoid fixed default sizes where I can ;)

Well, PlaylistSplitter's default sizes are 100/640, which I guessed
were derived from line "resize(750, 500)" in JuK::setupLayout(). i.e.
100 + 640 = 750 - 10. So, I used the same reasoning (250 + 240 = 500 -
10) for the m_editorSplitter as well. :-)

I tried not calling setSizes() if no sizes are saved, however the tag
editor would get very large compared to the playlist.

According to http://doc.qt.nokia.com/4.7/qsplitter.html#setSizes:
 "The overall size of the splitter widget is not affected. Instead,
any additional/missing space is distributed amongst the widgets
according to the relative weight of the sizes."

So, in the attached new version of my patch I ended up setting the
same size to both the editor and the playlist. Since the actual size
does not matter much (only the relative weight) and since we should
not use fixed sizes, I used the tag editor's height
(m_editor->height()).

Regards,

-- 
Γιώργος Κυλάφας (Giorgos Kylafas)
http://en.wikipedia.org/wiki/Posting_style#Inline_replying

["save-n-restore-tag-editor-size.patch" (text/x-diff)]

commit 26deee64da0bdb902bb2d2ccba4b0ff319bcdd1c
Author: Γιώργος Κυλάφας (Giorgos Kylafas) <gekylafas@gmail.com>
Date:   Fri May 6 01:48:55 2011 +0300

    juk: save & restore playlist and tag editor sizes.
    
    editorSplitter is turned to a member variable (m_editorSplitter) whose
    sizes are stored and retrieved the same way as PlaylistSplitter's.
    
    If no sizes are saved, use by default the same size for the playlist and
    the tag editor.

diff --git a/juk/playlistsplitter.cpp b/juk/playlistsplitter.cpp
index 4d1064d..7d08907 100644
--- a/juk/playlistsplitter.cpp
+++ b/juk/playlistsplitter.cpp
@@ -54,7 +54,8 @@ PlaylistSplitter::PlaylistSplitter(PlayerManager *player, QWidget *parent) :
     m_playlistStack(0),
     m_editor(0),
     m_nowPlaying(0),
-    m_player(player)
+    m_player(player),
+    m_editorSplitter(0)
 {
     setObjectName(QLatin1String("playlistSplitter"));
 
@@ -170,12 +171,12 @@ void PlaylistSplitter::setupLayout()
 
     // Create a splitter to go between the playlists and the editor.
 
-    QSplitter *editorSplitter = new QSplitter(Qt::Vertical, this);
-    editorSplitter->setObjectName( QLatin1String("editorSplitter" ));
+    m_editorSplitter = new QSplitter(Qt::Vertical, this);
+    m_editorSplitter->setObjectName( QLatin1String("editorSplitter" ));
 
     // Create the playlist and the editor.
 
-    QWidget *top = new QWidget(editorSplitter);
+    QWidget *top = new QWidget(m_editorSplitter);
     QVBoxLayout *topLayout = new QVBoxLayout(top);
     topLayout->setMargin(0);
     topLayout->setSpacing(0);
@@ -186,14 +187,9 @@ void PlaylistSplitter::setupLayout()
     m_playlistStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     m_playlistStack->hide(); // Will be shown after CollectionList filled.
 
-    m_editor = new TagEditor(editorSplitter);
+    m_editor = new TagEditor(m_editorSplitter);
     m_editor->setObjectName( QLatin1String("TagEditor" ));
 
-    // Make the editor as small as possible (or at least as small as recommended)
-
-    editorSplitter->setStretchFactor(editorSplitter->indexOf(m_editor), 0);
-    editorSplitter->setStretchFactor(editorSplitter->indexOf(top), 1);
-
     // Create the PlaylistBox
 
     m_playlistBox = new PlaylistBox(m_player, this, m_playlistStack);
@@ -261,6 +257,15 @@ void PlaylistSplitter::readConfig()
     bool showSearch = config.readEntry("ShowSearch", true);
     ActionCollection::action<KToggleAction>("showSearch")->setChecked(showSearch);
     m_searchWidget->setHidden(!showSearch);
+
+    splitterSizes = config.readEntry("EditorSplitterSizes",QList<int>());
+    if(splitterSizes.isEmpty()) {
+        // If no sizes are saved, use by default the same size for the playlist
+        // and the editor.
+        splitterSizes.append(m_editor->height());
+        splitterSizes.append(m_editor->height());
+    }
+    m_editorSplitter->setSizes(splitterSizes);
 }
 
 void PlaylistSplitter::saveConfig()
@@ -268,6 +273,7 @@ void PlaylistSplitter::saveConfig()
     KConfigGroup config(KGlobal::config(), "Splitter");
     config.writeEntry("PlaylistSplitterSizes", sizes());
     config.writeEntry("ShowSearch", ActionCollection::action<KToggleAction>("showSearch")->isChecked());
+    config.writeEntry("EditorSplitterSizes", m_editorSplitter->sizes());
 }
 
 void PlaylistSplitter::slotShowSearchResults()
diff --git a/juk/playlistsplitter.h b/juk/playlistsplitter.h
index 66387e8..4de0177 100644
--- a/juk/playlistsplitter.h
+++ b/juk/playlistsplitter.h
@@ -94,6 +94,7 @@ private:
     TagEditor *m_editor;
     NowPlaying *m_nowPlaying;
     PlayerManager *m_player;
+    QSplitter *m_editorSplitter;
 };
 
 #endif


_______________________________________________
kde-multimedia mailing list
kde-multimedia@kde.org
https://mail.kde.org/mailman/listinfo/kde-multimedia


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic