Bugzilla – Attachment 150541 Details for
Bug 105884
Make the tabs of tabbed Notebookbar follow KDE style
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Qt5 tab theming (broken)
qt5-tabbed-theming.diff (text/plain), 10.48 KB, created by
Jan-Marek Glogowski
on 2019-04-05 00:23:59 UTC
(
hide
)
Description:
Qt5 tab theming (broken)
Filename:
MIME Type:
Creator:
Jan-Marek Glogowski
Created:
2019-04-05 00:23:59 UTC
Size:
10.48 KB
patch
obsolete
>diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx >index 4cc108f55043..22eb406f34eb 100644 >--- a/vcl/qt5/Qt5Graphics_Controls.cxx >+++ b/vcl/qt5/Qt5Graphics_Controls.cxx >@@ -105,6 +105,12 @@ bool Qt5Graphics_Controls::IsNativeControlSupported(ControlType type, ControlPar > case ControlType::Slider: > return (part == ControlPart::TrackHorzArea || part == ControlPart::TrackVertArea); > >+ case ControlType::TabItem: >+ case ControlType::TabPane: >+ case ControlType::TabHeader: >+ case ControlType::TabBody: >+ return (part == ControlPart::Entire || part == ControlPart::TabsDrawRtl); >+ > default: > break; > } >@@ -145,23 +151,43 @@ void draw(QStyle::ComplexControl element, QStyleOptionComplex* option, QImage* i > QApplication::style()->drawComplexControl(element, option, &painter); > } > >-void lcl_drawFrame(QStyle::PrimitiveElement element, QImage* image, QStyle::State const& state, >- bool bClip = true, >+void lcl_drawFrame(QStyle::PrimitiveElement element, QImage* image, >+ const ImplControlValue& aValue, bool bClip = true, > QStyle::PixelMetric eLineMetric = QStyle::PM_DefaultFrameWidth) > { >+ static int no = 0; > const int fw = QApplication::style()->pixelMetric(eLineMetric); > QStyleOptionFrame option; >- option.frameShape = QFrame::StyledPanel; >- option.state = QStyle::State_Sunken | state; >+ >+ if (element == QStyle::PE_Frame) >+ { >+ option.frameShape = QFrame::StyledPanel; >+ const DrawFrameStyle nStyle = static_cast<DrawFrameStyle>(aValue.getNumericVal() & 0x0f); >+ if (nStyle == DrawFrameStyle::In) >+ option.state = QStyle::State_Sunken; >+ else if (nStyle == DrawFrameStyle::Out) >+ option.state = QStyle::State_Raised; >+ else >+ option.frameShape = QFrame::Box; >+ } >+ else >+ option.frameShape = QFrame::Panel; > option.lineWidth = fw; > > QRect aRect(image->rect()); > option.rect = aRect; > >+ image->save(QString("/tmp/frame%1_in.png").arg(no)); > QPainter painter(image); > if (bClip) > painter.setClipRegion(QRegion(aRect).subtracted(aRect.adjusted(fw, fw, -fw, -fw))); >- QApplication::style()->drawPrimitive(element, &option, &painter); >+ if (element == QStyle::PE_Frame) >+ QApplication::style()->drawControl(QStyle::CE_ShapedFrame, &option, &painter); >+ else >+ QApplication::style()->drawPrimitive(element, &option, &painter); >+ SAL_DEBUG("Frame " << no << ": " << (int) element); >+ image->save(QString("/tmp/frame%1_out.png").arg(no)); >+ no++; > } > } > >@@ -209,6 +235,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, > m_image->fill(QApplication::palette().color(QPalette::Window).rgb()); > break; > case ControlType::Tooltip: >+ // case ControlType::TabPane: > m_image->fill(QApplication::palette().color(QPalette::ToolTipBase).rgb()); > break; > case ControlType::Scrollbar: >@@ -336,15 +363,14 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, > } > else if (part == ControlPart::Entire) > { >- QStyleOptionMenuItem option; >- draw(QStyle::PE_PanelMenu, &option, m_image.get(), >- vclStateValue2StateFlag(nControlState, value)); >- // Try hard to get any frame! >- QStyleOptionFrame frame; >- draw(QStyle::PE_FrameMenu, &frame, m_image.get(), >- vclStateValue2StateFlag(nControlState, value)); >- draw(QStyle::PE_FrameWindow, &frame, m_image.get(), >- vclStateValue2StateFlag(nControlState, value)); >+ const int fw = QApplication::style()->pixelMetric(QStyle::PM_MenuPanelWidth); >+ if (fw) >+ { >+ QStyleOptionFrame frame; >+ frame.lineWidth = fw; >+ frame.midLineWidth = 0; >+ draw(QStyle::PE_FrameMenu, &frame, m_image.get(), QStyle::State_None); >+ } > m_lastPopupRect = widgetRect; > } > else >@@ -396,8 +422,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, > } > else if (type == ControlType::Editbox || type == ControlType::MultilineEditbox) > { >- lcl_drawFrame(QStyle::PE_FrameLineEdit, m_image.get(), >- vclStateValue2StateFlag(nControlState, value), false); >+ lcl_drawFrame(QStyle::PE_FrameLineEdit, m_image.get(), value, false); > } > else if (type == ControlType::Combobox) > { >@@ -413,9 +438,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, > switch (part) > { > case ControlPart::ListboxWindow: >- lcl_drawFrame(QStyle::PE_Frame, m_image.get(), >- vclStateValue2StateFlag(nControlState, value), true, >- QStyle::PM_ComboBoxFrameWidth); >+ lcl_drawFrame(QStyle::PE_Frame, m_image.get(), value, true, QStyle::PM_ComboBoxFrameWidth); > break; > case ControlPart::SubEdit: > draw(QStyle::CE_ComboBoxLabel, &option, m_image.get(), >@@ -559,8 +582,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, > } > else if (type == ControlType::Frame) > { >- lcl_drawFrame(QStyle::PE_Frame, m_image.get(), >- vclStateValue2StateFlag(nControlState, value)); >+ lcl_drawFrame(QStyle::PE_Frame, m_image.get(), value); > } > else if (type == ControlType::WindowBackground) > { >@@ -609,6 +631,52 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, > draw(QStyle::CE_ProgressBar, &option, m_image.get(), > vclStateValue2StateFlag(nControlState, value)); > } >+ else if (type == ControlType::TabItem && part == ControlPart::Entire) >+ { >+ SAL_DEBUG("TabItem " << rControlRegion); >+ const TabitemValue& rValue = static_cast<const TabitemValue&>(value); >+ QStyleOptionTab st; >+ if (rValue.isFirst()) >+ st.position >+ = rValue.isLast() ? QStyleOptionTab::OnlyOneTab : QStyleOptionTab::Beginning; >+ else if (rValue.isLast()) >+ st.position = rValue.isFirst() ? QStyleOptionTab::OnlyOneTab : QStyleOptionTab::End; >+ else >+ st.position = QStyleOptionTab::Middle; >+ >+ draw(QStyle::CE_TabBarTabShape, &st, m_image.get(), >+ vclStateValue2StateFlag(nControlState, value)); >+ } >+ else if (type == ControlType::TabPane && part == ControlPart::Entire) >+ { >+ SAL_DEBUG("TabPane " << rControlRegion); >+ QStyleOptionTabWidgetFrame option; >+ option.lineWidth = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth); >+ option.midLineWidth = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth) - 2; >+ option.tabBarRect = QRect(5, 5, m_image->width() - 10, 20); >+ option.selectedTabRect = QRect(0, 0, 20, 20); >+ option.shape = QTabBar::TriangularNorth; >+ option.tabBarSize = QSize(0, m_image->width()); >+ option.leftCornerWidgetSize = QSize(0, 0); >+ option.rightCornerWidgetSize = QSize(0, 0); >+ option.rect = QRect(5, 25, m_image->width() - 10, m_image->height() - 30); >+ { >+ QPainter painter(m_image.get()); >+ QApplication::style()->drawPrimitive(QStyle::PE_FrameTabWidget, &option, &painter); >+ } >+ // lcl_drawFrame(QStyle::PE_FrameLineEdit, m_image.get(), >+ // vclStateValue2StateFlag(nControlState, value)); >+ m_image->save("/tmp/test.png"); >+ } >+ else if (type == ControlType::TabHeader && part == ControlPart::Entire) >+ { >+ SAL_DEBUG("TabHeader " << rControlRegion); >+ } >+ else if (type == ControlType::TabBody && part == ControlPart::Entire) >+ { >+ SAL_DEBUG("TabBody " << rControlRegion); >+ lcl_drawFrame(QStyle::PE_FrameTabWidget, m_image.get(), value); >+ } > else > { > returnVal = false; >@@ -650,9 +718,12 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart > case ControlType::Editbox: > case ControlType::MultilineEditbox: > { >+ SAL_DEBUG("In " << controlRegion); > QStyleOptionFrame fo; >- fo.frameShape = QFrame::StyledPanel; >- fo.state = QStyle::State_Sunken; >+ fo.rect = contentRect; >+ fo.state = vclStateValue2StateFlag(controlState, val); >+// fo.frameShape = QFrame::StyledPanel; >+// fo.state = QStyle::State_Sunken; > fo.lineWidth = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth); > QSize aMinSize = QApplication::style()->sizeFromContents(QStyle::CT_LineEdit, &fo, > contentRect.size()); >@@ -668,6 +739,8 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart > assert(0 == (aMinSize.width() - boundingRect.width()) % 2); > boundingRect.adjust(-nWidth, 0, nWidth, 0); > } >+ SAL_DEBUG(toRectangle(boundingRect)); >+ > retVal = true; > break; > } >@@ -818,7 +891,7 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart > auto nStyle = static_cast<DrawFrameFlags>(val.getNumericVal() & 0xFFF0); > if (nStyle & DrawFrameFlags::NoDraw) > { >- int nFrameWidth >+ const int nFrameWidth > = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth); > contentRect.adjust(nFrameWidth, nFrameWidth, -nFrameWidth, -nFrameWidth); > } >@@ -912,7 +985,19 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart > } > break; > } >+ case ControlType::TabItem: >+ { >+ const int w = QApplication::style()->pixelMetric(QStyle::PM_TabBarTabHSpace); >+ const int h = QApplication::style()->pixelMetric(QStyle::PM_TabBarTabVSpace); >+ contentRect.adjust(0, 0, w, h); >+ boundingRect = contentRect; >+ retVal = true; >+ break; >+ } > default: >+ assert(type != ControlType::TabPane); >+ assert(type != ControlType::TabBody); >+ assert(type != ControlType::TabHeader); > break; > } > if (retVal)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 105884
:
131043
|
131151
|
131152
|
131153
|
131285
|
131763
|
150391
| 150541 |
152468