]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
Handle font and palette changes in Dolphin list views.
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index 38ce63af0adf839cbfee987fc33fcc1363fc9f01..ab420cab15c05b6b1418e6663b14810924fc6095 100644 (file)
@@ -111,8 +111,7 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
 
     m_sizeHintResolver = new KItemListSizeHintResolver(this);
 
-    m_layouter = new KItemListViewLayouter(this);
-    m_layouter->setSizeHintResolver(m_sizeHintResolver);
+    m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this);
 
     m_animation = new KItemListViewAnimation(this);
     connect(m_animation, SIGNAL(finished(QGraphicsWidget*,KItemListViewAnimation::AnimationType)),
@@ -894,11 +893,23 @@ void KItemListView::onTransactionEnd()
 
 bool KItemListView::event(QEvent* event)
 {
-    // Forward all events to the controller and handle them there
-    if (!m_editingRole && m_controller && m_controller->processEvent(event, transform())) {
-        event->accept();
-        return true;
+    switch (event->type()) {
+    case QEvent::PaletteChange:
+        updatePalette();
+        break;
+
+    case QEvent::FontChange:
+        updateFont();
+        break;
+
+    default:
+        // Forward all other events to the controller and handle them there
+        if (!m_editingRole && m_controller && m_controller->processEvent(event, transform())) {
+            event->accept();
+            return true;
+        }
     }
+
     return QGraphicsWidget::event(event);
 }
 
@@ -951,6 +962,27 @@ QList<KItemListWidget*> KItemListView::visibleItemListWidgets() const
     return m_visibleItems.values();
 }
 
+void KItemListView::updateFont()
+{
+    if (scene() && !scene()->views().isEmpty()) {
+        KItemListStyleOption option = styleOption();
+        option.font = scene()->views().first()->font();
+        option.fontMetrics = QFontMetrics(option.font);
+
+        setStyleOption(option);
+    }
+}
+
+void KItemListView::updatePalette()
+{
+    if (scene() && !scene()->views().isEmpty()) {
+        KItemListStyleOption option = styleOption();
+        option.palette = scene()->views().first()->palette();
+
+        setStyleOption(option);
+    }
+}
+
 void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
 {
     if (m_itemSize.isEmpty()) {