[Patch] make UI more usable on small screens

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Patch] make UI more usable on small screens

Matthias Welwarsky
Hi,

what do you think about the following changes to make UI more usable on small
screens:

     - SideBarWidget is now a QScrollArea
     - minimumSizeHint() enforces minimum width of 20% of screen width,
regardless of minimum sizes of managed widgets
     - adjust left sidebar widgets to play nice with QScrollArea

diff --git a/digikam/leftsidebarwidgets.cpp b/digikam/leftsidebarwidgets.cpp
index 6a27fe1..8cdcd68 100644
--- a/digikam/leftsidebarwidgets.cpp
+++ b/digikam/leftsidebarwidgets.cpp
@@ -87,20 +87,24 @@
AlbumFolderViewSideBarWidget::AlbumFolderViewSideBarWidget(QWidget* parent,
Albu
 
     d->albumModificationHelper = albumModificationHelper;
 
-    QVBoxLayout* layout = new QVBoxLayout(this);
+    QWidget *mainWidget = new QWidget(this);
+    QVBoxLayout* layout = new QVBoxLayout(mainWidget);
 
-    d->albumFolderView = new AlbumSelectionTreeView(this, model, d-
>albumModificationHelper);
+    d->albumFolderView = new AlbumSelectionTreeView(mainWidget, model, d-
>albumModificationHelper);
     d->albumFolderView->setObjectName("AlbumFolderView");
     d->albumFolderView->setConfigGroup(getConfigGroup());
     d->albumFolderView->setExpandNewCurrentItem(true);
     d->albumFolderView->setAlbumManagerCurrentAlbum(true);
-    d->searchTextBar   = new SearchTextBar(this,
"DigikamViewFolderSearchBar");
+    d->searchTextBar   = new SearchTextBar(mainWidget,
"DigikamViewFolderSearchBar");
     d->searchTextBar->setHighlightOnResult(true);
     d->searchTextBar->setModel(model, AbstractAlbumModel::AlbumIdRole,
AbstractAlbumModel::AlbumTitleRole);
     d->searchTextBar->setFilterModel(d->albumFolderView->albumFilterModel());
 
     layout->addWidget(d->albumFolderView);
     layout->addWidget(d->searchTextBar);
+    
+    setWidget(mainWidget);
+    setWidgetResizable(true);
 
     // setup connection
     connect(d->albumFolderView, SIGNAL(signalFindDuplicatesInAlbum(Album*)),
@@ -187,19 +191,23 @@ TagViewSideBarWidget::TagViewSideBarWidget(QWidget*
parent, TagModel* model)
 
     d->tagModel = model;
 
-    QVBoxLayout* layout = new QVBoxLayout(this);
+    QWidget *mainWidget = new QWidget(this);
+    QVBoxLayout* layout = new QVBoxLayout(mainWidget);
 
-    d->tagFolderView = new TagFolderView(this, model);
+    d->tagFolderView = new TagFolderView(mainWidget, model);
     d->tagFolderView->setConfigGroup(getConfigGroup());
     d->tagFolderView->setExpandNewCurrentItem(true);
     d->tagFolderView->setAlbumManagerCurrentAlbum(true);
-    d->tagSearchBar  = new SearchTextBar(this, "DigikamViewTagSearchBar");
+    d->tagSearchBar  = new SearchTextBar(mainWidget,
"DigikamViewTagSearchBar");
     d->tagSearchBar->setHighlightOnResult(true);
     d->tagSearchBar->setModel(model, AbstractAlbumModel::AlbumIdRole,
AbstractAlbumModel::AlbumTitleRole);
     d->tagSearchBar->setFilterModel(d->tagFolderView->albumFilterModel());
 
     layout->addWidget(d->tagFolderView);
     layout->addWidget(d->tagSearchBar);
+    
+    setWidget(mainWidget);
+    setWidgetResizable(true);
 
     connect(d->tagFolderView, SIGNAL(signalFindDuplicatesInAlbum(Album*)),
             this, SIGNAL(signalFindDuplicatesInAlbum(Album*)));
@@ -284,6 +292,9 @@
DateFolderViewSideBarWidget::DateFolderViewSideBarWidget(QWidget* parent,
DateAl
     d->dateFolderView->setImageModel(imageFilterModel);
 
     layout->addWidget(d->dateFolderView);
+    
+    setWidget(d->dateFolderView);
+    setWidgetResizable(true);
 }
 
 DateFolderViewSideBarWidget::~DateFolderViewSideBarWidget()
@@ -396,9 +407,11 @@ TimelineSideBarWidget::TimelineSideBarWidget(QWidget*
parent, SearchModel* searc
     d->searchModificationHelper = searchModificationHelper;
     d->timer                    = new QTimer(this);
     setAttribute(Qt::WA_DeleteOnClose);
-
-    QVBoxLayout* vlay = new QVBoxLayout(this);
-    QFrame* panel     = new QFrame(this);
+    
+    QWidget* mainWidget = new QWidget(this);
+    
+    QVBoxLayout* vlay = new QVBoxLayout(mainWidget);
+    QFrame* panel     = new QFrame(mainWidget);
     panel->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
     panel->setLineWidth(1);
 
@@ -521,6 +534,9 @@ TimelineSideBarWidget::TimelineSideBarWidget(QWidget*
parent, SearchModel* searc
     vlay->setMargin(0);
     vlay->setSpacing(0);
 
+    setWidget(mainWidget);
+    setWidgetResizable(true);
+    
     // ---------------------------------------------------------------
 
     connect(AlbumManager::instance(), SIGNAL(signalDatesMapDirty(const
QMap<QDateTime, int>&)),
@@ -819,16 +835,17 @@ SearchSideBarWidget::SearchSideBarWidget(QWidget*
parent, SearchModel* searchMod
 
     d->searchModel      = searchModel;
 
-    QVBoxLayout* layout = new QVBoxLayout(this);
+    QWidget *mainWidget = new QWidget(this);
+    QVBoxLayout* layout = new QVBoxLayout(mainWidget);
 
-    d->searchTabHeader  = new SearchTabHeader(this);
-    d->searchTreeView   = new NormalSearchTreeView(this, searchModel,
+    d->searchTabHeader  = new SearchTabHeader(mainWidget);
+    d->searchTreeView   = new NormalSearchTreeView(mainWidget, searchModel,
             searchModeificationHelper);
     d->searchTreeView->setConfigGroup(getConfigGroup());
     d->searchTreeView->filteredModel()->listNormalSearches();
     d->searchTreeView->filteredModel()->setListTemporarySearches(true);
     d->searchTreeView->setAlbumManagerCurrentAlbum(true);
-    d->searchSearchBar  = new SearchTextBar(this,
"DigikamViewSearchSearchBar");
+    d->searchSearchBar  = new SearchTextBar(mainWidget,
"DigikamViewSearchSearchBar");
     d->searchSearchBar->setModel(d->searchTreeView->filteredModel(),
                                  AbstractAlbumModel::AlbumIdRole,
AbstractAlbumModel::AlbumTitleRole);
     d->searchSearchBar->setFilterModel(d->searchTreeView-
>albumFilterModel());
@@ -837,6 +854,9 @@ SearchSideBarWidget::SearchSideBarWidget(QWidget* parent,
SearchModel* searchMod
     layout->addWidget(d->searchTreeView);
     layout->setStretchFactor(d->searchTreeView, 1);
     layout->addWidget(d->searchSearchBar);
+    
+    setWidget(mainWidget);
+    setWidgetResizable(true);
 
     connect(d->searchTreeView, SIGNAL(newSearch()),
             d->searchTabHeader, SLOT(newAdvancedSearch()));
@@ -935,6 +955,9 @@
FuzzySearchSideBarWidget::FuzzySearchSideBarWidget(QWidget* parent,
SearchModel*
 
     layout->addWidget(d->fuzzySearchView);
 
+    setWidget(d->fuzzySearchView->mainWidget());
+    setWidgetResizable(true);
+
     connect(d->fuzzySearchView, SIGNAL(signalUpdateFingerPrints()),
             this, SIGNAL(signalUpdateFingerPrints()));
 
@@ -1032,7 +1055,10 @@ GPSSearchSideBarWidget::GPSSearchSideBarWidget(QWidget*
parent, SearchModel* sea
     QVBoxLayout* layout = new QVBoxLayout(this);
 
     layout->addWidget(d->gpsSearchView);
-
+    
+    setWidget(d->gpsSearchView);
+    setWidgetResizable(true);
+    
     connect(d->gpsSearchView, SIGNAL(signalMapSoloItems(const
QList<qlonglong>&, const QString&)),
             this, SIGNAL(signalMapSoloItems(const QList<qlonglong>&, const
QString&)));
 }
@@ -1106,10 +1132,11 @@ PeopleSideBarWidget::PeopleSideBarWidget(QWidget*
parent, TagModel* model,
     d->tagModel = model;
     d->searchModificationHelper = searchModificationHelper;
 
-    QVBoxLayout* layout = new QVBoxLayout;
+    QWidget *mainWidget = new QWidget(this);
+    QVBoxLayout* layout = new QVBoxLayout(mainWidget);
     QHBoxLayout* hlay = new QHBoxLayout;
 
-    d->tagFolderView = new TagFolderView(this, model);
+    d->tagFolderView = new TagFolderView(mainWidget, model);
     d->tagFolderView->setConfigGroup(getConfigGroup());
     d->tagFolderView->setExpandNewCurrentItem(true);
     d->tagFolderView->setAlbumManagerCurrentAlbum(true);
@@ -1117,7 +1144,7 @@ PeopleSideBarWidget::PeopleSideBarWidget(QWidget*
parent, TagModel* model,
     d->tagFolderView->filteredModel()->listOnlyTagsWithProperty("person");
     d->tagFolderView->filteredModel()-
>setFilterBehavior(AlbumFilterModel::StrictFiltering);
 
-    d->tagSearchBar  = new SearchTextBar(this, "DigikamViewPeopleSearchBar");
+    d->tagSearchBar  = new SearchTextBar(mainWidget,
"DigikamViewPeopleSearchBar");
     d->tagSearchBar->setHighlightOnResult(true);
     d->tagSearchBar->setModel(d->tagFolderView->filteredModel(),
                               AbstractAlbumModel::AlbumIdRole,
AbstractAlbumModel::AlbumTitleRole);
@@ -1142,7 +1169,8 @@ PeopleSideBarWidget::PeopleSideBarWidget(QWidget*
parent, TagModel* model,
     layout->addWidget(d->tagFolderView);
     layout->addWidget(d->tagSearchBar);
 
-    setLayout(layout);
+    setWidget(mainWidget);
+    setWidgetResizable(true);
 
     connect(d->tagFolderView, SIGNAL(signalFindDuplicatesInAlbum(Album*)),
             this, SIGNAL(signalFindDuplicatesInAlbum(Album*)));
diff --git a/digikam/sidebarwidget.cpp b/digikam/sidebarwidget.cpp
index cd6b329..065f0e8 100644
--- a/digikam/sidebarwidget.cpp
+++ b/digikam/sidebarwidget.cpp
@@ -21,13 +21,19 @@
  *
  * ============================================================ */
 
+// Qt includes
+#include <QScrollBar>
+
+// KDE includes
+#include <kglobalsettings.h>
+
 #include "sidebarwidget.moc"
 
 namespace Digikam
 {
 
 SidebarWidget::SidebarWidget(QWidget* parent) :
-    QWidget(parent), StateSavingObject(this)
+    QScrollArea(parent), StateSavingObject(this)
 {
 }
 
@@ -35,4 +41,20 @@ SidebarWidget::~SidebarWidget()
 {
 }
 
+QSize SidebarWidget::minimumSizeHint() const
+{
+    // Set scroll area to a horizontal minimum size sufficient for the
widgets.
+    // Do not touch vertical size hint.
+    // Limit to 20% of the desktop width.
+    const QWidget *w = widget();
+    if (0 == w)
+ return QScrollArea::minimumSizeHint();
+    
+    QSize hint        = w->minimumSizeHint();
+    QRect desktopRect = KGlobalSettings::desktopGeometry(w);
+    int wSB           = verticalScrollBar()->height();
+    hint.setWidth(qMin(w->minimumSizeHint().width() + wSB,
desktopRect.width() / 5 ));
+    return hint;
+}
+
 }
diff --git a/digikam/sidebarwidget.h b/digikam/sidebarwidget.h
index 4b9ddd0..a0c119a 100644
--- a/digikam/sidebarwidget.h
+++ b/digikam/sidebarwidget.h
@@ -28,6 +28,7 @@
 
 #include <qpixmap.h>
 #include <qwidget.h>
+#include <qscrollarea.h>
 
 // KDE includes
 
@@ -48,7 +49,7 @@ namespace Digikam
  *
  * @author jwienke
  */
-class SidebarWidget: public QWidget, public StateSavingObject
+class SidebarWidget: public QScrollArea, public StateSavingObject
 {
     Q_OBJECT
 public:
@@ -99,6 +100,11 @@ public:
      * @return localized title string
      */
     virtual QString getCaption() = 0;
+    
+    /**
+     * Reimplemented to provide a sensible size hint towards the container
+     */
+    virtual QSize minimumSizeHint() const;
 
 Q_SIGNALS:
 
diff --git a/utilities/fuzzysearch/fuzzysearchview.cpp
b/utilities/fuzzysearch/fuzzysearchview.cpp
index 28c0168..ad163ba 100644
--- a/utilities/fuzzysearch/fuzzysearchview.cpp
+++ b/utilities/fuzzysearch/fuzzysearchview.cpp
@@ -122,7 +122,8 @@ public:
         imageSAlbum(0),
         sketchSAlbum(0),
         searchModel(0),
-        searchModificationHelper(0)
+        searchModificationHelper(0),
+        mainWidget(0)
     {
     }
 
@@ -185,6 +186,8 @@ public:
 
     SearchModel*              searchModel;
     SearchModificationHelper* searchModificationHelper;
+    
+    QWidget*                  mainWidget;
 };
 const QString
FuzzySearchView::FuzzySearchViewPriv::configTabEntry("FuzzySearch Tab");
 const QString
FuzzySearchView::FuzzySearchViewPriv::configPenSketchSizeEntry("Pen Sketch
Size");
@@ -199,7 +202,7 @@ const QString
FuzzySearchView::FuzzySearchViewPriv::configSimilarsThresholdEntry
 FuzzySearchView::FuzzySearchView(SearchModel* searchModel,
                                  SearchModificationHelper*
searchModificationHelper,
                                  QWidget* parent)
-    : QScrollArea(parent), StateSavingObject(this),
+    : QWidget(parent), StateSavingObject(this),
       d(new FuzzySearchViewPriv)
 {
     d->thumbLoadThread = ThumbnailLoadThread::defaultThread();
@@ -207,10 +210,8 @@ FuzzySearchView::FuzzySearchView(SearchModel*
searchModel,
     d->searchModel = searchModel;
     d->searchModificationHelper = searchModificationHelper;
 
-    setWidgetResizable(true);
     setAttribute(Qt::WA_DeleteOnClose);
     setAcceptDrops(true);
-    viewport()->setAcceptDrops(true);
 
     // ---------------------------------------------------------------
 
@@ -240,18 +241,16 @@ FuzzySearchView::FuzzySearchView(SearchModel*
searchModel,
 
     // ---------------------------------------------------------------
 
-    QWidget* mainWidget     = new QWidget(this);
+    d->mainWidget     = new QWidget(this);
     QVBoxLayout* mainLayout = new QVBoxLayout();
     mainLayout->addWidget(d->tabWidget);
     mainLayout->addWidget(d->folderView);
     mainLayout->setMargin(0);
     mainLayout->setSpacing(0);
-    mainWidget->setLayout(mainLayout);
+    d->mainWidget->setLayout(mainLayout);
 
-    setWidget(mainWidget);
     setAutoFillBackground(false);
-    mainWidget->setAutoFillBackground(false);
-    viewport()->setAutoFillBackground(false);
+    d->mainWidget->setAutoFillBackground(false);
 
     // ---------------------------------------------------------------
 
@@ -263,6 +262,11 @@ FuzzySearchView::FuzzySearchView(SearchModel*
searchModel,
     slotCheckNameEditImageConditions();
 }
 
+QWidget* FuzzySearchView::mainWidget() const
+{
+ return d->mainWidget;
+}
+
 QWidget* FuzzySearchView::setupFindSimilarPanel()
 {
     KHBox* imageBox     = new KHBox();
diff --git a/utilities/fuzzysearch/fuzzysearchview.h
b/utilities/fuzzysearch/fuzzysearchview.h
index 542d8c4..7cca7fe 100644
--- a/utilities/fuzzysearch/fuzzysearchview.h
+++ b/utilities/fuzzysearch/fuzzysearchview.h
@@ -49,7 +49,7 @@ class SearchModel;
 class SearchModificationHelper;
 class SearchTextBar;
 
-class FuzzySearchView : public QScrollArea, public StateSavingObject
+class FuzzySearchView : public QWidget, public StateSavingObject
 {
     Q_OBJECT
 
@@ -71,6 +71,8 @@ public:
     virtual void setConfigGroup(KConfigGroup group);
     void doLoadState();
     void doSaveState();
+    
+    QWidget* mainWidget() const;
 
 Q_SIGNALS:
 

_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] make UI more usable on small screens

Gilles Caulier-4
Thanks matthias for this patch.

It's done against digiKam 1.x or 2.0 ?

Gilles Caulier

2011/2/10 Matthias Welwarsky <[hidden email]>:

> Hi,
>
> what do you think about the following changes to make UI more usable on small
> screens:
>
>     - SideBarWidget is now a QScrollArea
>     - minimumSizeHint() enforces minimum width of 20% of screen width,
> regardless of minimum sizes of managed widgets
>     - adjust left sidebar widgets to play nice with QScrollArea
>
> diff --git a/digikam/leftsidebarwidgets.cpp b/digikam/leftsidebarwidgets.cpp
> index 6a27fe1..8cdcd68 100644
> --- a/digikam/leftsidebarwidgets.cpp
> +++ b/digikam/leftsidebarwidgets.cpp
> @@ -87,20 +87,24 @@
> AlbumFolderViewSideBarWidget::AlbumFolderViewSideBarWidget(QWidget* parent,
> Albu
>
>     d->albumModificationHelper = albumModificationHelper;
>
> -    QVBoxLayout* layout = new QVBoxLayout(this);
> +    QWidget *mainWidget = new QWidget(this);
> +    QVBoxLayout* layout = new QVBoxLayout(mainWidget);
>
> -    d->albumFolderView = new AlbumSelectionTreeView(this, model, d-
>>albumModificationHelper);
> +    d->albumFolderView = new AlbumSelectionTreeView(mainWidget, model, d-
>>albumModificationHelper);
>     d->albumFolderView->setObjectName("AlbumFolderView");
>     d->albumFolderView->setConfigGroup(getConfigGroup());
>     d->albumFolderView->setExpandNewCurrentItem(true);
>     d->albumFolderView->setAlbumManagerCurrentAlbum(true);
> -    d->searchTextBar   = new SearchTextBar(this,
> "DigikamViewFolderSearchBar");
> +    d->searchTextBar   = new SearchTextBar(mainWidget,
> "DigikamViewFolderSearchBar");
>     d->searchTextBar->setHighlightOnResult(true);
>     d->searchTextBar->setModel(model, AbstractAlbumModel::AlbumIdRole,
> AbstractAlbumModel::AlbumTitleRole);
>     d->searchTextBar->setFilterModel(d->albumFolderView->albumFilterModel());
>
>     layout->addWidget(d->albumFolderView);
>     layout->addWidget(d->searchTextBar);
> +
> +    setWidget(mainWidget);
> +    setWidgetResizable(true);
>
>     // setup connection
>     connect(d->albumFolderView, SIGNAL(signalFindDuplicatesInAlbum(Album*)),
> @@ -187,19 +191,23 @@ TagViewSideBarWidget::TagViewSideBarWidget(QWidget*
> parent, TagModel* model)
>
>     d->tagModel = model;
>
> -    QVBoxLayout* layout = new QVBoxLayout(this);
> +    QWidget *mainWidget = new QWidget(this);
> +    QVBoxLayout* layout = new QVBoxLayout(mainWidget);
>
> -    d->tagFolderView = new TagFolderView(this, model);
> +    d->tagFolderView = new TagFolderView(mainWidget, model);
>     d->tagFolderView->setConfigGroup(getConfigGroup());
>     d->tagFolderView->setExpandNewCurrentItem(true);
>     d->tagFolderView->setAlbumManagerCurrentAlbum(true);
> -    d->tagSearchBar  = new SearchTextBar(this, "DigikamViewTagSearchBar");
> +    d->tagSearchBar  = new SearchTextBar(mainWidget,
> "DigikamViewTagSearchBar");
>     d->tagSearchBar->setHighlightOnResult(true);
>     d->tagSearchBar->setModel(model, AbstractAlbumModel::AlbumIdRole,
> AbstractAlbumModel::AlbumTitleRole);
>     d->tagSearchBar->setFilterModel(d->tagFolderView->albumFilterModel());
>
>     layout->addWidget(d->tagFolderView);
>     layout->addWidget(d->tagSearchBar);
> +
> +    setWidget(mainWidget);
> +    setWidgetResizable(true);
>
>     connect(d->tagFolderView, SIGNAL(signalFindDuplicatesInAlbum(Album*)),
>             this, SIGNAL(signalFindDuplicatesInAlbum(Album*)));
> @@ -284,6 +292,9 @@
> DateFolderViewSideBarWidget::DateFolderViewSideBarWidget(QWidget* parent,
> DateAl
>     d->dateFolderView->setImageModel(imageFilterModel);
>
>     layout->addWidget(d->dateFolderView);
> +
> +    setWidget(d->dateFolderView);
> +    setWidgetResizable(true);
>  }
>
>  DateFolderViewSideBarWidget::~DateFolderViewSideBarWidget()
> @@ -396,9 +407,11 @@ TimelineSideBarWidget::TimelineSideBarWidget(QWidget*
> parent, SearchModel* searc
>     d->searchModificationHelper = searchModificationHelper;
>     d->timer                    = new QTimer(this);
>     setAttribute(Qt::WA_DeleteOnClose);
> -
> -    QVBoxLayout* vlay = new QVBoxLayout(this);
> -    QFrame* panel     = new QFrame(this);
> +
> +    QWidget* mainWidget = new QWidget(this);
> +
> +    QVBoxLayout* vlay = new QVBoxLayout(mainWidget);
> +    QFrame* panel     = new QFrame(mainWidget);
>     panel->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
>     panel->setLineWidth(1);
>
> @@ -521,6 +534,9 @@ TimelineSideBarWidget::TimelineSideBarWidget(QWidget*
> parent, SearchModel* searc
>     vlay->setMargin(0);
>     vlay->setSpacing(0);
>
> +    setWidget(mainWidget);
> +    setWidgetResizable(true);
> +
>     // ---------------------------------------------------------------
>
>     connect(AlbumManager::instance(), SIGNAL(signalDatesMapDirty(const
> QMap<QDateTime, int>&)),
> @@ -819,16 +835,17 @@ SearchSideBarWidget::SearchSideBarWidget(QWidget*
> parent, SearchModel* searchMod
>
>     d->searchModel      = searchModel;
>
> -    QVBoxLayout* layout = new QVBoxLayout(this);
> +    QWidget *mainWidget = new QWidget(this);
> +    QVBoxLayout* layout = new QVBoxLayout(mainWidget);
>
> -    d->searchTabHeader  = new SearchTabHeader(this);
> -    d->searchTreeView   = new NormalSearchTreeView(this, searchModel,
> +    d->searchTabHeader  = new SearchTabHeader(mainWidget);
> +    d->searchTreeView   = new NormalSearchTreeView(mainWidget, searchModel,
>             searchModeificationHelper);
>     d->searchTreeView->setConfigGroup(getConfigGroup());
>     d->searchTreeView->filteredModel()->listNormalSearches();
>     d->searchTreeView->filteredModel()->setListTemporarySearches(true);
>     d->searchTreeView->setAlbumManagerCurrentAlbum(true);
> -    d->searchSearchBar  = new SearchTextBar(this,
> "DigikamViewSearchSearchBar");
> +    d->searchSearchBar  = new SearchTextBar(mainWidget,
> "DigikamViewSearchSearchBar");
>     d->searchSearchBar->setModel(d->searchTreeView->filteredModel(),
>                                  AbstractAlbumModel::AlbumIdRole,
> AbstractAlbumModel::AlbumTitleRole);
>     d->searchSearchBar->setFilterModel(d->searchTreeView-
>>albumFilterModel());
> @@ -837,6 +854,9 @@ SearchSideBarWidget::SearchSideBarWidget(QWidget* parent,
> SearchModel* searchMod
>     layout->addWidget(d->searchTreeView);
>     layout->setStretchFactor(d->searchTreeView, 1);
>     layout->addWidget(d->searchSearchBar);
> +
> +    setWidget(mainWidget);
> +    setWidgetResizable(true);
>
>     connect(d->searchTreeView, SIGNAL(newSearch()),
>             d->searchTabHeader, SLOT(newAdvancedSearch()));
> @@ -935,6 +955,9 @@
> FuzzySearchSideBarWidget::FuzzySearchSideBarWidget(QWidget* parent,
> SearchModel*
>
>     layout->addWidget(d->fuzzySearchView);
>
> +    setWidget(d->fuzzySearchView->mainWidget());
> +    setWidgetResizable(true);
> +
>     connect(d->fuzzySearchView, SIGNAL(signalUpdateFingerPrints()),
>             this, SIGNAL(signalUpdateFingerPrints()));
>
> @@ -1032,7 +1055,10 @@ GPSSearchSideBarWidget::GPSSearchSideBarWidget(QWidget*
> parent, SearchModel* sea
>     QVBoxLayout* layout = new QVBoxLayout(this);
>
>     layout->addWidget(d->gpsSearchView);
> -
> +
> +    setWidget(d->gpsSearchView);
> +    setWidgetResizable(true);
> +
>     connect(d->gpsSearchView, SIGNAL(signalMapSoloItems(const
> QList<qlonglong>&, const QString&)),
>             this, SIGNAL(signalMapSoloItems(const QList<qlonglong>&, const
> QString&)));
>  }
> @@ -1106,10 +1132,11 @@ PeopleSideBarWidget::PeopleSideBarWidget(QWidget*
> parent, TagModel* model,
>     d->tagModel = model;
>     d->searchModificationHelper = searchModificationHelper;
>
> -    QVBoxLayout* layout = new QVBoxLayout;
> +    QWidget *mainWidget = new QWidget(this);
> +    QVBoxLayout* layout = new QVBoxLayout(mainWidget);
>     QHBoxLayout* hlay = new QHBoxLayout;
>
> -    d->tagFolderView = new TagFolderView(this, model);
> +    d->tagFolderView = new TagFolderView(mainWidget, model);
>     d->tagFolderView->setConfigGroup(getConfigGroup());
>     d->tagFolderView->setExpandNewCurrentItem(true);
>     d->tagFolderView->setAlbumManagerCurrentAlbum(true);
> @@ -1117,7 +1144,7 @@ PeopleSideBarWidget::PeopleSideBarWidget(QWidget*
> parent, TagModel* model,
>     d->tagFolderView->filteredModel()->listOnlyTagsWithProperty("person");
>     d->tagFolderView->filteredModel()-
>>setFilterBehavior(AlbumFilterModel::StrictFiltering);
>
> -    d->tagSearchBar  = new SearchTextBar(this, "DigikamViewPeopleSearchBar");
> +    d->tagSearchBar  = new SearchTextBar(mainWidget,
> "DigikamViewPeopleSearchBar");
>     d->tagSearchBar->setHighlightOnResult(true);
>     d->tagSearchBar->setModel(d->tagFolderView->filteredModel(),
>                               AbstractAlbumModel::AlbumIdRole,
> AbstractAlbumModel::AlbumTitleRole);
> @@ -1142,7 +1169,8 @@ PeopleSideBarWidget::PeopleSideBarWidget(QWidget*
> parent, TagModel* model,
>     layout->addWidget(d->tagFolderView);
>     layout->addWidget(d->tagSearchBar);
>
> -    setLayout(layout);
> +    setWidget(mainWidget);
> +    setWidgetResizable(true);
>
>     connect(d->tagFolderView, SIGNAL(signalFindDuplicatesInAlbum(Album*)),
>             this, SIGNAL(signalFindDuplicatesInAlbum(Album*)));
> diff --git a/digikam/sidebarwidget.cpp b/digikam/sidebarwidget.cpp
> index cd6b329..065f0e8 100644
> --- a/digikam/sidebarwidget.cpp
> +++ b/digikam/sidebarwidget.cpp
> @@ -21,13 +21,19 @@
>  *
>  * ============================================================ */
>
> +// Qt includes
> +#include <QScrollBar>
> +
> +// KDE includes
> +#include <kglobalsettings.h>
> +
>  #include "sidebarwidget.moc"
>
>  namespace Digikam
>  {
>
>  SidebarWidget::SidebarWidget(QWidget* parent) :
> -    QWidget(parent), StateSavingObject(this)
> +    QScrollArea(parent), StateSavingObject(this)
>  {
>  }
>
> @@ -35,4 +41,20 @@ SidebarWidget::~SidebarWidget()
>  {
>  }
>
> +QSize SidebarWidget::minimumSizeHint() const
> +{
> +    // Set scroll area to a horizontal minimum size sufficient for the
> widgets.
> +    // Do not touch vertical size hint.
> +    // Limit to 20% of the desktop width.
> +    const QWidget *w = widget();
> +    if (0 == w)
> +       return QScrollArea::minimumSizeHint();
> +
> +    QSize hint        = w->minimumSizeHint();
> +    QRect desktopRect = KGlobalSettings::desktopGeometry(w);
> +    int wSB           = verticalScrollBar()->height();
> +    hint.setWidth(qMin(w->minimumSizeHint().width() + wSB,
> desktopRect.width() / 5 ));
> +    return hint;
> +}
> +
>  }
> diff --git a/digikam/sidebarwidget.h b/digikam/sidebarwidget.h
> index 4b9ddd0..a0c119a 100644
> --- a/digikam/sidebarwidget.h
> +++ b/digikam/sidebarwidget.h
> @@ -28,6 +28,7 @@
>
>  #include <qpixmap.h>
>  #include <qwidget.h>
> +#include <qscrollarea.h>
>
>  // KDE includes
>
> @@ -48,7 +49,7 @@ namespace Digikam
>  *
>  * @author jwienke
>  */
> -class SidebarWidget: public QWidget, public StateSavingObject
> +class SidebarWidget: public QScrollArea, public StateSavingObject
>  {
>     Q_OBJECT
>  public:
> @@ -99,6 +100,11 @@ public:
>      * @return localized title string
>      */
>     virtual QString getCaption() = 0;
> +
> +    /**
> +     * Reimplemented to provide a sensible size hint towards the container
> +     */
> +    virtual QSize minimumSizeHint() const;
>
>  Q_SIGNALS:
>
> diff --git a/utilities/fuzzysearch/fuzzysearchview.cpp
> b/utilities/fuzzysearch/fuzzysearchview.cpp
> index 28c0168..ad163ba 100644
> --- a/utilities/fuzzysearch/fuzzysearchview.cpp
> +++ b/utilities/fuzzysearch/fuzzysearchview.cpp
> @@ -122,7 +122,8 @@ public:
>         imageSAlbum(0),
>         sketchSAlbum(0),
>         searchModel(0),
> -        searchModificationHelper(0)
> +        searchModificationHelper(0),
> +        mainWidget(0)
>     {
>     }
>
> @@ -185,6 +186,8 @@ public:
>
>     SearchModel*              searchModel;
>     SearchModificationHelper* searchModificationHelper;
> +
> +    QWidget*                  mainWidget;
>  };
>  const QString
> FuzzySearchView::FuzzySearchViewPriv::configTabEntry("FuzzySearch Tab");
>  const QString
> FuzzySearchView::FuzzySearchViewPriv::configPenSketchSizeEntry("Pen Sketch
> Size");
> @@ -199,7 +202,7 @@ const QString
> FuzzySearchView::FuzzySearchViewPriv::configSimilarsThresholdEntry
>  FuzzySearchView::FuzzySearchView(SearchModel* searchModel,
>                                  SearchModificationHelper*
> searchModificationHelper,
>                                  QWidget* parent)
> -    : QScrollArea(parent), StateSavingObject(this),
> +    : QWidget(parent), StateSavingObject(this),
>       d(new FuzzySearchViewPriv)
>  {
>     d->thumbLoadThread = ThumbnailLoadThread::defaultThread();
> @@ -207,10 +210,8 @@ FuzzySearchView::FuzzySearchView(SearchModel*
> searchModel,
>     d->searchModel = searchModel;
>     d->searchModificationHelper = searchModificationHelper;
>
> -    setWidgetResizable(true);
>     setAttribute(Qt::WA_DeleteOnClose);
>     setAcceptDrops(true);
> -    viewport()->setAcceptDrops(true);
>
>     // ---------------------------------------------------------------
>
> @@ -240,18 +241,16 @@ FuzzySearchView::FuzzySearchView(SearchModel*
> searchModel,
>
>     // ---------------------------------------------------------------
>
> -    QWidget* mainWidget     = new QWidget(this);
> +    d->mainWidget     = new QWidget(this);
>     QVBoxLayout* mainLayout = new QVBoxLayout();
>     mainLayout->addWidget(d->tabWidget);
>     mainLayout->addWidget(d->folderView);
>     mainLayout->setMargin(0);
>     mainLayout->setSpacing(0);
> -    mainWidget->setLayout(mainLayout);
> +    d->mainWidget->setLayout(mainLayout);
>
> -    setWidget(mainWidget);
>     setAutoFillBackground(false);
> -    mainWidget->setAutoFillBackground(false);
> -    viewport()->setAutoFillBackground(false);
> +    d->mainWidget->setAutoFillBackground(false);
>
>     // ---------------------------------------------------------------
>
> @@ -263,6 +262,11 @@ FuzzySearchView::FuzzySearchView(SearchModel*
> searchModel,
>     slotCheckNameEditImageConditions();
>  }
>
> +QWidget* FuzzySearchView::mainWidget() const
> +{
> +       return d->mainWidget;
> +}
> +
>  QWidget* FuzzySearchView::setupFindSimilarPanel()
>  {
>     KHBox* imageBox     = new KHBox();
> diff --git a/utilities/fuzzysearch/fuzzysearchview.h
> b/utilities/fuzzysearch/fuzzysearchview.h
> index 542d8c4..7cca7fe 100644
> --- a/utilities/fuzzysearch/fuzzysearchview.h
> +++ b/utilities/fuzzysearch/fuzzysearchview.h
> @@ -49,7 +49,7 @@ class SearchModel;
>  class SearchModificationHelper;
>  class SearchTextBar;
>
> -class FuzzySearchView : public QScrollArea, public StateSavingObject
> +class FuzzySearchView : public QWidget, public StateSavingObject
>  {
>     Q_OBJECT
>
> @@ -71,6 +71,8 @@ public:
>     virtual void setConfigGroup(KConfigGroup group);
>     void doLoadState();
>     void doSaveState();
> +
> +    QWidget* mainWidget() const;
>
>  Q_SIGNALS:
>
>
> _______________________________________________
> Digikam-devel mailing list
> [hidden email]
> https://mail.kde.org/mailman/listinfo/digikam-devel
>
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] make UI more usable on small screens

Marcel Wiesweg
In reply to this post by Matthias Welwarsky


> what do you think about the following changes to make UI more usable on
> small screens:
>
>      - SideBarWidget is now a QScrollArea
>      - minimumSizeHint() enforces minimum width of 20% of screen width,
> regardless of minimum sizes of managed widgets
>      - adjust left sidebar widgets to play nice with QScrollArea

It's all right for me if it works.
Things to avoid though:
- scrollbars per default on a normal screen (netbook, small laptop)
- scrollbars within scrollbars
- important UI elements disappearing

Marcel
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] make UI more usable on small screens

Matthias Welwarsky
On Thursday 10 February 2011 19:39:33 Marcel Wiesweg wrote:

> > what do you think about the following changes to make UI more usable on
> >
> > small screens:
> >      - SideBarWidget is now a QScrollArea
> >      - minimumSizeHint() enforces minimum width of 20% of screen width,
> >
> > regardless of minimum sizes of managed widgets
> >
> >      - adjust left sidebar widgets to play nice with QScrollArea
>
> It's all right for me if it works.
> Things to avoid though:
> - scrollbars per default on a normal screen (netbook, small laptop)
> - scrollbars within scrollbars
> - important UI elements disappearing

With the patch, any SidebarWidget derivative actually becomes a QScrollArea,
which contains the actual tool view. To determine an appropriate
minimumSizeHint(), it requests the minimumSizeHint() of the widget it contains
and makes sure the width is not larger than 20% of the screen width.

Before, the largest minimumSizeHint() of all widgets in the sidebar would
determine its minimum width. For widgets like the gpssearch this was > 300
pixels, which means the sidebar took more than 1/3rd of a 1024 pixel screen,
no matter which tool was opened.

The patch allows the sidebar to become smaller than what the largest tool
widget demands. To achieve this, overriding the minimumSizeHint() in class
SidebarWidget would have been enough, but then tools demanding larger size
become squeezed pretty badly.  Hence the addition of a QScrollArea.

The patch is against 2.0, by the way.

>
> Marcel
> _______________________________________________
> Digikam-devel mailing list
> [hidden email]
> https://mail.kde.org/mailman/listinfo/digikam-devel

_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] make UI more usable on small screens

Matthias Welwarsky
On Thursday 10 February 2011 20:46:45 Matthias Welwarsky wrote:

> With the patch, any SidebarWidget derivative actually becomes a
> QScrollArea, which contains the actual tool view. To determine an
> appropriate
> minimumSizeHint(), it requests the minimumSizeHint() of the widget it
> contains and makes sure the width is not larger than 20% of the screen
> width.
>
> Before, the largest minimumSizeHint() of all widgets in the sidebar would
> determine its minimum width. For widgets like the gpssearch this was > 300
> pixels, which means the sidebar took more than 1/3rd of a 1024 pixel
> screen, no matter which tool was opened.
>
> The patch allows the sidebar to become smaller than what the largest tool
> widget demands. To achieve this, overriding the minimumSizeHint() in class
> SidebarWidget would have been enough, but then tools demanding larger size
> become squeezed pretty badly.  Hence the addition of a QScrollArea.

However, there is a problem now that the minimum height becomes too large. The
app window won't resize smaller than 638 pixels high, which is not good. I'll
need to fix that first.

> Digikam-devel mailing list
> [hidden email]
> https://mail.kde.org/mailman/listinfo/digikam-devel

_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] make UI more usable on small screens

Gilles Caulier-4
2011/2/11 Matthias Welwarsky <[hidden email]>:

> On Thursday 10 February 2011 20:46:45 Matthias Welwarsky wrote:
>> With the patch, any SidebarWidget derivative actually becomes a
>> QScrollArea, which contains the actual tool view. To determine an
>> appropriate
>> minimumSizeHint(), it requests the minimumSizeHint() of the widget it
>> contains and makes sure the width is not larger than 20% of the screen
>> width.
>>
>> Before, the largest minimumSizeHint() of all widgets in the sidebar would
>> determine its minimum width. For widgets like the gpssearch this was > 300
>> pixels, which means the sidebar took more than 1/3rd of a 1024 pixel
>> screen, no matter which tool was opened.
>>
>> The patch allows the sidebar to become smaller than what the largest tool
>> widget demands. To achieve this, overriding the minimumSizeHint() in class
>> SidebarWidget would have been enough, but then tools demanding larger size
>> become squeezed pretty badly.  Hence the addition of a QScrollArea.
>
> However, there is a problem now that the minimum height becomes too large. The
> app window won't resize smaller than 638 pixels high, which is not good. I'll
> need to fix that first.

Matthias,

I recommend you to create a new entry in bugzilla into
digiKam/Usability component and attach patch at this place. it's
better to follow in time than mailling list...

I will check too your future patch with my netbook

Gilles Caulier
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] make UI more usable on small screens

Gilles Caulier-4
Mathias,

Some progress over your patch in Bugzilla ?

Gilles Caulier

2011/2/11 Gilles Caulier <[hidden email]>:

> 2011/2/11 Matthias Welwarsky <[hidden email]>:
>> On Thursday 10 February 2011 20:46:45 Matthias Welwarsky wrote:
>>> With the patch, any SidebarWidget derivative actually becomes a
>>> QScrollArea, which contains the actual tool view. To determine an
>>> appropriate
>>> minimumSizeHint(), it requests the minimumSizeHint() of the widget it
>>> contains and makes sure the width is not larger than 20% of the screen
>>> width.
>>>
>>> Before, the largest minimumSizeHint() of all widgets in the sidebar would
>>> determine its minimum width. For widgets like the gpssearch this was > 300
>>> pixels, which means the sidebar took more than 1/3rd of a 1024 pixel
>>> screen, no matter which tool was opened.
>>>
>>> The patch allows the sidebar to become smaller than what the largest tool
>>> widget demands. To achieve this, overriding the minimumSizeHint() in class
>>> SidebarWidget would have been enough, but then tools demanding larger size
>>> become squeezed pretty badly.  Hence the addition of a QScrollArea.
>>
>> However, there is a problem now that the minimum height becomes too large. The
>> app window won't resize smaller than 638 pixels high, which is not good. I'll
>> need to fix that first.
>
> Matthias,
>
> I recommend you to create a new entry in bugzilla into
> digiKam/Usability component and attach patch at this place. it's
> better to follow in time than mailling list...
>
> I will check too your future patch with my netbook
>
> Gilles Caulier
>
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] make UI more usable on small screens

Matthias Welwarsky-2
On Friday 18 February 2011 10:58:43 Gilles Caulier wrote:
> Mathias,
>
> Some progress over your patch in Bugzilla ?
>
> Gilles Caulier

Gilles, it all boils down to this (trivial) patch:

diff --git a/digikam/views/leftsidebarwidgets.cpp b/digikam/views/leftsidebarwidgets.cpp
index 8cf45b2..61c0d28 100644
--- a/digikam/views/leftsidebarwidgets.cpp
+++ b/digikam/views/leftsidebarwidgets.cpp
@@ -1029,9 +1029,13 @@ GPSSearchSideBarWidget::GPSSearchSideBarWidget(QWidget* parent, SearchModel* sea
     d->gpsSearchView = new GPSSearchView(this, searchModel, searchModificationHelper, imageFilterModel, itemSelectionModel);
     d->gpsSearchView->setConfigGroup(getConfigGroup());
 
+    QScrollArea *scrollArea = new QScrollArea(this);
+
     QVBoxLayout* layout = new QVBoxLayout(this);
 
-    layout->addWidget(d->gpsSearchView);
+    layout->addWidget(scrollArea);
+    scrollArea->setWidget(d->gpsSearchView);
+    scrollArea->setWidgetResizable(true);
 
     connect(d->gpsSearchView, SIGNAL(signalMapSoloItems(const QList<qlonglong>&, const QString&)),
             this, SIGNAL(signalMapSoloItems(const QList<qlonglong>&, const QString&)));

It achieves the same as my previous patch and is much less intrusive.
If no objections, I'll push it to the development/2.0 branch

>
> 2011/2/11 Gilles Caulier <[hidden email]>:
> > 2011/2/11 Matthias Welwarsky <[hidden email]>:
> >> On Thursday 10 February 2011 20:46:45 Matthias Welwarsky wrote:
> >>> With the patch, any SidebarWidget derivative actually becomes a
> >>> QScrollArea, which contains the actual tool view. To determine an
> >>> appropriate
> >>> minimumSizeHint(), it requests the minimumSizeHint() of the widget it
> >>> contains and makes sure the width is not larger than 20% of the screen
> >>> width.
> >>>
> >>> Before, the largest minimumSizeHint() of all widgets in the sidebar
> >>> would determine its minimum width. For widgets like the gpssearch this
> >>> was > 300 pixels, which means the sidebar took more than 1/3rd of a
> >>> 1024 pixel screen, no matter which tool was opened.
> >>>
> >>> The patch allows the sidebar to become smaller than what the largest
> >>> tool widget demands. To achieve this, overriding the minimumSizeHint()
> >>> in class SidebarWidget would have been enough, but then tools
> >>> demanding larger size become squeezed pretty badly.  Hence the
> >>> addition of a QScrollArea.
> >>
> >> However, there is a problem now that the minimum height becomes too
> >> large. The app window won't resize smaller than 638 pixels high, which
> >> is not good. I'll need to fix that first.
> >
> > Matthias,
> >
> > I recommend you to create a new entry in bugzilla into
> > digiKam/Usability component and attach patch at this place. it's
> > better to follow in time than mailling list...
> >
> > I will check too your future patch with my netbook
> >
> > Gilles Caulier
>
> _______________________________________________
> Digikam-devel mailing list
> [hidden email]
> https://mail.kde.org/mailman/listinfo/digikam-devel

_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel