Changeset View
Changeset View
Standalone View
Standalone View
krusader/Panel/krpreviewpopup.cpp
Show All 36 Lines | |||||
37 | #include "../KViewer/krviewer.h" | 37 | #include "../KViewer/krviewer.h" | ||
38 | 38 | | |||
39 | class KrPreviewPopup::ProxyStyle : public QProxyStyle | 39 | class KrPreviewPopup::ProxyStyle : public QProxyStyle | ||
40 | { | 40 | { | ||
41 | public: | 41 | public: | ||
42 | ProxyStyle() : QProxyStyle(QApplication::style()) {} | 42 | ProxyStyle() : QProxyStyle(QApplication::style()) {} | ||
43 | 43 | | |||
44 | QSize sizeFromContents(ContentsType type, const QStyleOption *option, | 44 | QSize sizeFromContents(ContentsType type, const QStyleOption *option, | ||
45 | const QSize &contentsSize, const QWidget *widget = nullptr) const Q_DECL_OVERRIDE | 45 | const QSize &contentsSize, const QWidget *widget = nullptr) const override | ||
46 | { | 46 | { | ||
47 | if(type == QStyle::CT_MenuItem) { | 47 | if(type == QStyle::CT_MenuItem) { | ||
48 | const auto *menuItem = | 48 | const auto *menuItem = | ||
49 | qstyleoption_cast<const QStyleOptionMenuItem*>(option); | 49 | qstyleoption_cast<const QStyleOptionMenuItem*>(option); | ||
50 | 50 | | |||
51 | QFontMetrics fontMetrics(menuItem->font); | 51 | QFontMetrics fontMetrics(menuItem->font); | ||
52 | QSize iconSize = menuItem->icon.actualSize(QSize(MAX_SIZE, MAX_SIZE)); | 52 | QSize iconSize = menuItem->icon.actualSize(QSize(MAX_SIZE, MAX_SIZE)); | ||
53 | QSize textSize = QSize(fontMetrics.boundingRect(menuItem->text).width(), | 53 | QSize textSize = QSize(fontMetrics.boundingRect(menuItem->text).width(), | ||
54 | fontMetrics.height()); | 54 | fontMetrics.height()); | ||
55 | 55 | | |||
56 | return QSize(std::max(iconSize.width(), textSize.width()) + MARGIN*2, | 56 | return QSize(std::max(iconSize.width(), textSize.width()) + MARGIN*2, | ||
57 | iconSize.height() + textSize.height() + MARGIN*2); | 57 | iconSize.height() + textSize.height() + MARGIN*2); | ||
58 | } else | 58 | } else | ||
59 | return QProxyStyle::sizeFromContents(type, option, contentsSize, widget); | 59 | return QProxyStyle::sizeFromContents(type, option, contentsSize, widget); | ||
60 | } | 60 | } | ||
61 | 61 | | |||
62 | void drawControl(ControlElement element, const QStyleOption *option, | 62 | void drawControl(ControlElement element, const QStyleOption *option, | ||
63 | QPainter *painter, const QWidget *widget = nullptr ) const Q_DECL_OVERRIDE | 63 | QPainter *painter, const QWidget *widget = nullptr ) const override | ||
64 | { | 64 | { | ||
65 | if(element == QStyle::CE_MenuItem) { | 65 | if(element == QStyle::CE_MenuItem) { | ||
66 | painter->save(); | 66 | painter->save(); | ||
67 | 67 | | |||
68 | const auto *menuItem = | 68 | const auto *menuItem = | ||
69 | qstyleoption_cast<const QStyleOptionMenuItem*>(option); | 69 | qstyleoption_cast<const QStyleOptionMenuItem*>(option); | ||
70 | 70 | | |||
71 | bool active = menuItem->state & State_Selected; | 71 | bool active = menuItem->state & State_Selected; | ||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |