mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Handle font and palette changes in Dolphin list views.
Also update the font of the meta data widget in InformationPanelContent (smallest readable font). BUG: 329186 BUG: 315061 FIXED-IN: 4.13 REVIEW: 115958
This commit is contained in:
parent
c2887688f1
commit
0d37038b40
|
@ -893,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);
|
||||
}
|
||||
|
||||
|
@ -950,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()) {
|
||||
|
|
|
@ -388,6 +388,9 @@ protected:
|
|||
|
||||
QList<KItemListWidget*> visibleItemListWidgets() const;
|
||||
|
||||
virtual void updateFont();
|
||||
virtual void updatePalette();
|
||||
|
||||
protected slots:
|
||||
virtual void slotItemsInserted(const KItemRangeList& itemRanges);
|
||||
virtual void slotItemsRemoved(const KItemRangeList& itemRanges);
|
||||
|
|
|
@ -271,6 +271,10 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
|
|||
adjustWidgetSizes(parentWidget()->width());
|
||||
break;
|
||||
|
||||
case QEvent::FontChange:
|
||||
m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -144,6 +144,26 @@ void DolphinItemListView::onVisibleRolesChanged(const QList<QByteArray>& current
|
|||
updateGridSize();
|
||||
}
|
||||
|
||||
void DolphinItemListView::updateFont()
|
||||
{
|
||||
const ViewModeSettings settings(viewMode());
|
||||
|
||||
if (settings.useSystemFont()) {
|
||||
KItemListView::updateFont();
|
||||
} else {
|
||||
QFont font(settings.fontFamily(), qRound(settings.fontSize()));
|
||||
font.setItalic(settings.italicFont());
|
||||
font.setWeight(settings.fontWeight());
|
||||
font.setPointSizeF(settings.fontSize());
|
||||
|
||||
KItemListStyleOption option = styleOption();
|
||||
option.font = font;
|
||||
option.fontMetrics = QFontMetrics(font);
|
||||
|
||||
setStyleOption(option);
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinItemListView::updateGridSize()
|
||||
{
|
||||
const ViewModeSettings settings(viewMode());
|
||||
|
@ -231,23 +251,6 @@ void DolphinItemListView::updateGridSize()
|
|||
endTransaction();
|
||||
}
|
||||
|
||||
void DolphinItemListView::updateFont()
|
||||
{
|
||||
KItemListStyleOption option = styleOption();
|
||||
|
||||
const ViewModeSettings settings(viewMode());
|
||||
|
||||
QFont font(settings.fontFamily(), qRound(settings.fontSize()));
|
||||
font.setItalic(settings.italicFont());
|
||||
font.setWeight(settings.fontWeight());
|
||||
font.setPointSizeF(settings.fontSize());
|
||||
|
||||
option.font = font;
|
||||
option.fontMetrics = QFontMetrics(font);
|
||||
|
||||
setStyleOption(option);
|
||||
}
|
||||
|
||||
ViewModeSettings::ViewMode DolphinItemListView::viewMode() const
|
||||
{
|
||||
ViewModeSettings::ViewMode mode;
|
||||
|
|
|
@ -56,9 +56,10 @@ protected:
|
|||
virtual void onVisibleRolesChanged(const QList<QByteArray>& current,
|
||||
const QList<QByteArray>& previous);
|
||||
|
||||
virtual void updateFont();
|
||||
|
||||
private:
|
||||
void updateGridSize();
|
||||
void updateFont();
|
||||
|
||||
ViewModeSettings::ViewMode viewMode() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue