]> cloud.milkyroute.net Git - dolphin.git/commitdiff
layout improvements
authorPeter Penz <peter.penz19@gmail.com>
Sat, 10 Oct 2009 22:29:05 +0000 (22:29 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 10 Oct 2009 22:29:05 +0000 (22:29 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1033744

src/panels/information/commentwidget.cpp
src/panels/information/informationpanelcontent.cpp
src/panels/information/metadatawidget.cpp
src/panels/information/taggingwidget.cpp

index 6397bc39a87b5f1eacbd8d80c913f8c0a09388b9..173a2ee6d8ee40c46af6d2b1856e099dea64afe3 100644 (file)
@@ -21,6 +21,7 @@
 #include "commentwidget_p.h"
 
 #include <kdialog.h>
+#include <kglobalsettings.h>
 #include <klocale.h>
 
 #include <QLabel>
@@ -33,6 +34,7 @@ CommentWidget::CommentWidget(QWidget* parent) :
     m_comment()
 {
     m_label = new QLabel(this);
+    m_label->setFont(KGlobalSettings::smallestReadableFont());
     connect(m_label, SIGNAL(linkActivated(const QString&)), this, SLOT(slotLinkActivated(const QString&)));
 
     QVBoxLayout* layout = new QVBoxLayout(this);
index 4ddbf656201ab27c3f87a13401ac9f322592a17c..5431b8ed3d7b69a9169d6a18424c80f44d693200 100644 (file)
@@ -117,9 +117,20 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
     m_previewSeparator->setVisible(showPreview);
 
     m_metaDataWidget = new MetaDataWidget(parent);
+    m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
+
+    // Encapsulate the MetaDataWidget inside a container that has a dummy widget
+    // at the bottom. This prevents that the meta data widget gets vertically stretched
+    // in the case where the height of m_metaDataArea > m_metaDataWidget.
+    QWidget* metaDataWidgetContainer = new QWidget(parent);
+    QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer);
+    containerLayout->setContentsMargins(0, 0, 0, 0);
+    containerLayout->setSpacing(0);
+    containerLayout->addWidget(m_metaDataWidget);
+    containerLayout->addWidget(new QWidget(metaDataWidgetContainer));
 
     m_metaDataArea = new QScrollArea(parent);
-    //m_metaDataArea->setWidget(m_metaDataArea);
+    m_metaDataArea->setWidget(metaDataWidgetContainer);
     m_metaDataArea->setWidgetResizable(true);
     m_metaDataArea->setFrameShape(QFrame::NoFrame);
 
@@ -135,9 +146,6 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
     layout->addWidget(m_preview);
     layout->addWidget(m_phononWidget);
     layout->addWidget(m_previewSeparator);
-    if (m_metaDataWidget != 0) {
-        layout->addWidget(m_metaDataWidget);
-    }
     layout->addWidget(m_metaDataArea);
     parent->setLayout(layout);
 }
@@ -238,7 +246,7 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
         if (obj == m_metaDataArea->viewport()) {
             // The size of the meta text area has changed. Adjust the fixed
             // width in a way that no horizontal scrollbar needs to be shown.
-            //m_metaDataWidget->setFixedWidth(resizeEvent->size().width());
+            m_metaDataWidget->setFixedWidth(resizeEvent->size().width());
         } else if (obj == parent()) {
             // If the text inside the name label or the info label cannot
             // get wrapped, then the maximum width of the label is increased
@@ -251,7 +259,7 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
             // The metadata widget also contains a text widget which may return
             // a large preferred width.
             if (m_metaDataWidget != 0) {
-                //m_metaDataWidget->setMaximumWidth(maxWidth);
+                m_metaDataWidget->setMaximumWidth(maxWidth);
             }
 
             // try to increase the preview as large as possible
index 30bdb904f3acd13a4897f4a3af88680c7ba65091..d4d4319355f6fd1e685b31639f5e2b07baaab9d3 100644 (file)
@@ -21,6 +21,7 @@
 #include "metadatawidget.h"
 
 #include <kfileitem.h>
+#include <kglobalsettings.h>
 #include <klocale.h>
 
 #include <QGridLayout>
@@ -155,6 +156,8 @@ MetaDataWidget::Private::Private(MetaDataWidget* parent) :
     q(parent)
 {
     m_gridLayout = new QGridLayout(parent);
+    m_gridLayout->setContentsMargins(0, 0, 0, 0);
+    m_gridLayout->setSpacing(0);
 
     m_typeInfo = new QLabel(parent);
     m_sizeLabel = new QLabel(parent);
@@ -198,12 +201,21 @@ void MetaDataWidget::Private::addRow(QLabel* label, QWidget* infoWidget)
     row.infoWidget = infoWidget;
     m_rows.append(row);
 
-    // use a brighter color for the label
+    // use a brighter color for the label and a small font size
     QPalette palette = label->palette();
     QColor textColor = palette.color(QPalette::Text);
     textColor.setAlpha(128);
     palette.setColor(QPalette::WindowText, textColor);
     label->setPalette(palette);
+    label->setFont(KGlobalSettings::smallestReadableFont());
+    label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+
+    QLabel* infoLabel = qobject_cast<QLabel*>(infoWidget);
+    if (infoLabel != 0) {
+        infoLabel->setFont(KGlobalSettings::smallestReadableFont());
+        infoLabel->setWordWrap(true);
+        infoLabel->setAlignment(Qt::AlignTop | Qt::AlignRight);
+    }
 
     // add the row to grid layout
     const int rowIndex = m_rows.count();
@@ -254,6 +266,9 @@ void MetaDataWidget::Private::slotLoadingFinished()
         }
         ++index;
     }
+    if (metaInfoCount > 0) {
+        --index;
+    }
 
     // remove rows that are not needed anymore
     for (int i = rowCount - 1; i > index; --i) {
index 7c9616d9511f1c241ba7e2920d71f7a7d71ebd59..90252d4109f5910361338a43926f66492acb74c9 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "taggingwidget_p.h"
 
+#include <kglobalsettings.h>
 #include <klocale.h>
 
 #include <QLabel>
@@ -31,6 +32,7 @@ TaggingWidget::TaggingWidget(QWidget* parent) :
     m_tagsText()
 {
     m_label = new QLabel(this);
+    m_label->setFont(KGlobalSettings::smallestReadableFont());
     connect(m_label, SIGNAL(linkActivated(const QString&)), this, SLOT(slotLinkActivated(const QString&)));
 
     QVBoxLayout* layout = new QVBoxLayout(this);