Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
c94e06bb
Commit
c94e06bb
authored
Feb 23, 2010
by
Jens Bache-Wiig
Browse files
Migrate ManhattanStyle to use QProxyStyle
parent
f717a7df
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/coreplugin/manhattanstyle.cpp
View file @
c94e06bb
...
...
@@ -120,18 +120,10 @@ bool lightColored(const QWidget *widget)
class
ManhattanStylePrivate
{
public:
explicit
ManhattanStylePrivate
(
const
QString
&
baseStyleName
);
~
ManhattanStylePrivate
()
{
delete
style
;
style
=
0
;
}
explicit
ManhattanStylePrivate
();
void
init
();
public:
QStyle
*
style
;
const
QImage
lineeditImage
;
const
QImage
lineeditImage_disabled
;
const
QPixmap
extButtonPixmap
;
...
...
@@ -139,18 +131,17 @@ public:
StyleAnimator
animator
;
};
ManhattanStylePrivate
::
ManhattanStylePrivate
(
const
QString
&
baseStyleName
)
:
style
(
QStyleFactory
::
create
(
baseStyleName
)),
ManhattanStylePrivate
::
ManhattanStylePrivate
()
:
lineeditImage
(
QLatin1String
(
":/core/images/inputfield.png"
)),
lineeditImage_disabled
(
QLatin1String
(
":/core/images/inputfield_disabled.png"
)),
extButtonPixmap
(
QLatin1String
(
":/core/images/extension.png"
)),
closeButtonPixmap
(
QLatin1String
(
":/core/images/closebutton.png"
))
{
QTC_ASSERT
(
style
,
/**/
);
}
ManhattanStyle
::
ManhattanStyle
(
const
QString
&
baseStyleName
)
:
QWindowsStyle
(),
d
(
new
ManhattanStylePrivate
(
baseStyleName
))
:
QProxyStyle
(
QStyleFactory
::
create
(
baseStyleName
)),
d
(
new
ManhattanStylePrivate
())
{
}
...
...
@@ -160,11 +151,6 @@ ManhattanStyle::~ManhattanStyle()
d
=
0
;
}
QStyle
*
ManhattanStyle
::
systemStyle
()
const
{
return
d
->
style
;
}
// Draws a CSS-like border image where the defined borders are not stretched
void
drawCornerImage
(
const
QImage
&
img
,
QPainter
*
painter
,
QRect
rect
,
int
left
=
0
,
int
top
=
0
,
int
right
=
0
,
...
...
@@ -209,25 +195,13 @@ void drawCornerImage(const QImage &img, QPainter *painter, QRect rect,
QPixmap
ManhattanStyle
::
generatedIconPixmap
(
QIcon
::
Mode
iconMode
,
const
QPixmap
&
pixmap
,
const
QStyleOption
*
opt
)
const
{
QPixmap
result
;
result
=
d
->
style
->
generatedIconPixmap
(
iconMode
,
pixmap
,
opt
);
return
result
;
}
int
ManhattanStyle
::
layoutSpacingImplementation
(
QSizePolicy
::
ControlType
control1
,
QSizePolicy
::
ControlType
control2
,
Qt
::
Orientation
orientation
,
const
QStyleOption
*
option
,
const
QWidget
*
widget
)
const
{
return
d
->
style
->
layoutSpacing
(
control1
,
control2
,
orientation
,
option
,
widget
);
return
QProxyStyle
::
generatedIconPixmap
(
iconMode
,
pixmap
,
opt
);
}
QSize
ManhattanStyle
::
sizeFromContents
(
ContentsType
type
,
const
QStyleOption
*
option
,
const
QSize
&
size
,
const
QWidget
*
widget
)
const
{
QSize
newSize
=
d
->
s
tyle
->
sizeFromContents
(
type
,
option
,
size
,
widget
);
QSize
newSize
=
QProxyS
tyle
::
sizeFromContents
(
type
,
option
,
size
,
widget
);
if
(
type
==
CT_Splitter
&&
widget
&&
widget
->
property
(
"minisplitter"
).
toBool
())
return
QSize
(
1
,
1
);
...
...
@@ -238,31 +212,25 @@ QSize ManhattanStyle::sizeFromContents(ContentsType type, const QStyleOption *op
QRect
ManhattanStyle
::
subElementRect
(
SubElement
element
,
const
QStyleOption
*
option
,
const
QWidget
*
widget
)
const
{
QRect
rect
;
rect
=
d
->
style
->
subElementRect
(
element
,
option
,
widget
);
return
rect
;
return
QProxyStyle
::
subElementRect
(
element
,
option
,
widget
);
}
QRect
ManhattanStyle
::
subControlRect
(
ComplexControl
control
,
const
QStyleOptionComplex
*
option
,
SubControl
subControl
,
const
QWidget
*
widget
)
const
{
QRect
rect
;
rect
=
d
->
style
->
subControlRect
(
control
,
option
,
subControl
,
widget
);
return
rect
;
return
QProxyStyle
::
subControlRect
(
control
,
option
,
subControl
,
widget
);
}
QStyle
::
SubControl
ManhattanStyle
::
hitTestComplexControl
(
ComplexControl
control
,
const
QStyleOptionComplex
*
option
,
const
QPoint
&
pos
,
const
QWidget
*
widget
)
const
{
SubControl
result
=
QStyle
::
SC_None
;
result
=
d
->
style
->
hitTestComplexControl
(
control
,
option
,
pos
,
widget
);
return
result
;
return
QProxyStyle
::
hitTestComplexControl
(
control
,
option
,
pos
,
widget
);
}
int
ManhattanStyle
::
pixelMetric
(
PixelMetric
metric
,
const
QStyleOption
*
option
,
const
QWidget
*
widget
)
const
{
int
retval
=
0
;
retval
=
d
->
s
tyle
->
pixelMetric
(
metric
,
option
,
widget
);
retval
=
QProxyS
tyle
::
pixelMetric
(
metric
,
option
,
widget
);
switch
(
metric
)
{
case
PM_SplitterWidth
:
if
(
widget
&&
widget
->
property
(
"minisplitter"
).
toBool
())
...
...
@@ -299,19 +267,17 @@ int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
QPalette
ManhattanStyle
::
standardPalette
()
const
{
QPalette
result
;
result
=
d
->
style
->
standardPalette
();
return
result
;
return
QProxyStyle
::
standardPalette
();
}
void
ManhattanStyle
::
polish
(
QApplication
*
app
)
{
d
->
s
tyle
->
polish
(
app
);
return
QProxyS
tyle
::
polish
(
app
);
}
void
ManhattanStyle
::
unpolish
(
QApplication
*
app
)
{
d
->
s
tyle
->
unpolish
(
app
);
return
QProxyS
tyle
::
unpolish
(
app
);
}
QPalette
panelPalette
(
const
QPalette
&
oldPalette
,
bool
lightColored
=
false
)
...
...
@@ -330,12 +296,12 @@ QPalette panelPalette(const QPalette &oldPalette, bool lightColored = false)
void
ManhattanStyle
::
polish
(
QWidget
*
widget
)
{
d
->
s
tyle
->
polish
(
widget
);
QProxyS
tyle
::
polish
(
widget
);
// OxygenStyle forces a rounded widget mask on toolbars
if
(
d
->
s
tyle
->
inherits
(
"OxygenStyle"
))
{
if
(
baseS
tyle
()
->
inherits
(
"OxygenStyle"
))
{
if
(
qobject_cast
<
QToolBar
*>
(
widget
))
widget
->
removeEventFilter
(
d
->
s
tyle
);
widget
->
removeEventFilter
(
baseS
tyle
()
);
}
if
(
panelWidget
(
widget
))
{
widget
->
setAttribute
(
Qt
::
WA_LayoutUsesWidgetRect
,
true
);
...
...
@@ -362,7 +328,7 @@ void ManhattanStyle::polish(QWidget *widget)
void
ManhattanStyle
::
unpolish
(
QWidget
*
widget
)
{
d
->
s
tyle
->
unpolish
(
widget
);
QProxyS
tyle
::
unpolish
(
widget
);
if
(
panelWidget
(
widget
))
{
widget
->
setAttribute
(
Qt
::
WA_LayoutUsesWidgetRect
,
false
);
if
(
qobject_cast
<
QTabBar
*>
(
widget
))
...
...
@@ -376,11 +342,10 @@ void ManhattanStyle::unpolish(QWidget *widget)
void
ManhattanStyle
::
polish
(
QPalette
&
pal
)
{
d
->
s
tyle
->
polish
(
pal
);
QProxyS
tyle
::
polish
(
pal
);
}
QIcon
ManhattanStyle
::
standardIconImplementation
(
StandardPixmap
standardIcon
,
const
QStyleOption
*
option
,
const
QWidget
*
widget
)
const
QIcon
ManhattanStyle
::
standardIconImplementation
(
StandardPixmap
standardIcon
,
const
QStyleOption
*
option
,
const
QWidget
*
widget
)
const
{
QIcon
icon
;
switch
(
standardIcon
)
{
...
...
@@ -388,7 +353,7 @@ QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, co
case
QStyle
::
SP_ToolBarHorizontalExtensionButton
:
return
QIcon
(
standardPixmap
(
standardIcon
,
option
,
widget
));
default:
icon
=
d
->
s
tyle
->
standardIcon
(
standardIcon
,
option
,
widget
);
icon
=
baseS
tyle
()
->
standardIcon
(
standardIcon
,
option
,
widget
);
}
return
icon
;
}
...
...
@@ -397,7 +362,7 @@ QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QSty
const
QWidget
*
widget
)
const
{
if
(
widget
&&
!
panelWidget
(
widget
))
return
d
->
s
tyle
->
standardPixmap
(
standardPixmap
,
opt
,
widget
);
return
QProxyS
tyle
::
standardPixmap
(
standardPixmap
,
opt
,
widget
);
QPixmap
pixmap
;
switch
(
standardPixmap
)
{
...
...
@@ -408,7 +373,7 @@ QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QSty
pixmap
=
d
->
closeButtonPixmap
;
break
;
default:
pixmap
=
d
->
s
tyle
->
standardPixmap
(
standardPixmap
,
opt
,
widget
);
pixmap
=
QProxyS
tyle
::
standardPixmap
(
standardPixmap
,
opt
,
widget
);
break
;
}
return
pixmap
;
...
...
@@ -417,7 +382,7 @@ QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QSty
int
ManhattanStyle
::
styleHint
(
StyleHint
hint
,
const
QStyleOption
*
option
,
const
QWidget
*
widget
,
QStyleHintReturn
*
returnData
)
const
{
int
ret
=
d
->
s
tyle
->
styleHint
(
hint
,
option
,
widget
,
returnData
);
int
ret
=
QProxyS
tyle
::
styleHint
(
hint
,
option
,
widget
,
returnData
);
switch
(
hint
)
{
// Make project explorer alternate rows all the way
case
QStyle
::
SH_ItemView_PaintAlternatingRowColorsForEmptyArea
:
...
...
@@ -441,7 +406,7 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
QPainter
*
painter
,
const
QWidget
*
widget
)
const
{
if
(
!
panelWidget
(
widget
))
return
d
->
s
tyle
->
drawPrimitive
(
element
,
option
,
painter
,
widget
);
return
QProxyS
tyle
::
drawPrimitive
(
element
,
option
,
painter
,
widget
);
bool
animating
=
(
option
->
state
&
State_Animating
);
int
state
=
option
->
state
;
...
...
@@ -499,7 +464,8 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
}
switch
(
element
)
{
case
PE_PanelItemViewItem
:
/*
case PE_PanelItemViewItem:
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
if (vopt->state & State_Selected) {
QLinearGradient gradient;
...
...
@@ -507,7 +473,7 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
gradient.setFinalStop(option->rect.bottomRight());
gradient.setColorAt(0, option->palette.highlight().color().lighter(115));
gradient.setColorAt(1, option->palette.highlight().color().darker(135));
painter
->
fillRect
(
option
->
rect
,
Qt
::
blue
);
painter->fillRect(option->rect,
gradient
);
} else {
if (vopt->backgroundBrush.style() != Qt::NoBrush) {
QPointF oldBO = painter->brushOrigin();
...
...
@@ -518,6 +484,7 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
}
}
break;
*/
case
PE_PanelLineEdit
:
{
painter
->
save
();
...
...
@@ -668,7 +635,7 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
break
;
default:
d
->
s
tyle
->
drawPrimitive
(
element
,
option
,
painter
,
widget
);
QProxyS
tyle
::
drawPrimitive
(
element
,
option
,
painter
,
widget
);
break
;
}
}
...
...
@@ -677,7 +644,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
QPainter
*
painter
,
const
QWidget
*
widget
)
const
{
if
(
!
panelWidget
(
widget
))
return
d
->
s
tyle
->
drawControl
(
element
,
option
,
painter
,
widget
);
return
QProxyS
tyle
::
drawControl
(
element
,
option
,
painter
,
widget
);
switch
(
element
)
{
case
CE_MenuBarItem
:
...
...
@@ -765,7 +732,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
visualAlignment
(
option
->
direction
,
Qt
::
AlignLeft
|
Qt
::
AlignVCenter
),
customPal
,
cb
->
state
&
State_Enabled
,
text
,
QPalette
::
ButtonText
);
}
else
{
d
->
s
tyle
->
drawControl
(
element
,
option
,
painter
,
widget
);
QProxyS
tyle
::
drawControl
(
element
,
option
,
painter
,
widget
);
}
}
break
;
...
...
@@ -874,7 +841,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
}
break
;
default:
d
->
s
tyle
->
drawControl
(
element
,
option
,
painter
,
widget
);
QProxyS
tyle
::
drawControl
(
element
,
option
,
painter
,
widget
);
break
;
}
}
...
...
@@ -883,7 +850,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
QPainter
*
painter
,
const
QWidget
*
widget
)
const
{
if
(
!
panelWidget
(
widget
))
return
d
->
s
tyle
->
drawComplexControl
(
control
,
option
,
painter
,
widget
);
return
QProxyS
tyle
::
drawComplexControl
(
control
,
option
,
painter
,
widget
);
QRect
rect
=
option
->
rect
;
switch
(
control
)
{
...
...
@@ -1009,8 +976,8 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
int
right
=
!
reverse
?
rect
.
right
()
:
rect
.
left
()
+
menuButtonWidth
;
QRect
arrowRect
((
left
+
right
)
/
2
+
(
reverse
?
6
:
-
6
),
rect
.
center
().
y
()
-
3
,
9
,
9
);
if
(
option
->
state
&
State_On
)
arrowRect
.
translate
(
d
->
s
tyle
->
pixelMetric
(
PM_ButtonShiftHorizontal
,
option
,
widget
),
d
->
s
tyle
->
pixelMetric
(
PM_ButtonShiftVertical
,
option
,
widget
));
arrowRect
.
translate
(
QProxyS
tyle
::
pixelMetric
(
PM_ButtonShiftHorizontal
,
option
,
widget
),
QProxyS
tyle
::
pixelMetric
(
PM_ButtonShiftVertical
,
option
,
widget
));
QStyleOption
arrowOpt
=
*
option
;
arrowOpt
.
rect
=
arrowRect
;
...
...
@@ -1029,15 +996,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
}
break
;
default:
d
->
s
tyle
->
drawComplexControl
(
control
,
option
,
painter
,
widget
);
QProxyS
tyle
::
drawComplexControl
(
control
,
option
,
painter
,
widget
);
break
;
}
}
// Mac style reimplements this to control the
// focus widget among other things
bool
ManhattanStyle
::
event
(
QEvent
*
e
)
{
Q_ASSERT
(
d
->
style
);
return
d
->
style
->
event
(
e
);
}
src/plugins/coreplugin/manhattanstyle.h
View file @
c94e06bb
...
...
@@ -32,7 +32,7 @@
#include "core_global.h"
#include <QtGui/Q
Windows
Style>
#include <QtGui/Q
Proxy
Style>
QT_BEGIN_NAMESPACE
class
QLinearGradient
;
...
...
@@ -41,7 +41,7 @@ QT_END_NAMESPACE
class
ManhattanStylePrivate
;
class
CORE_EXPORT
ManhattanStyle
:
public
Q
Windows
Style
class
CORE_EXPORT
ManhattanStyle
:
public
Q
Proxy
Style
{
Q_OBJECT
...
...
@@ -50,8 +50,6 @@ public:
~
ManhattanStyle
();
QStyle
*
systemStyle
()
const
;
void
drawPrimitive
(
PrimitiveElement
element
,
const
QStyleOption
*
option
,
QPainter
*
painter
,
const
QWidget
*
widget
=
0
)
const
;
void
drawControl
(
ControlElement
element
,
const
QStyleOption
*
option
,
QPainter
*
painter
,
const
QWidget
*
widget
=
0
)
const
;
void
drawComplexControl
(
ComplexControl
control
,
const
QStyleOptionComplex
*
option
,
QPainter
*
painter
,
const
QWidget
*
widget
=
0
)
const
;
...
...
@@ -76,17 +74,8 @@ public:
void
unpolish
(
QWidget
*
widget
);
void
unpolish
(
QApplication
*
app
);
protected:
bool
event
(
QEvent
*
e
);
protected
Q_SLOTS
:
QIcon
standardIconImplementation
(
StandardPixmap
standardIcon
,
const
QStyleOption
*
option
,
const
QWidget
*
widget
)
const
;
int
layoutSpacingImplementation
(
QSizePolicy
::
ControlType
control1
,
QSizePolicy
::
ControlType
control2
,
Qt
::
Orientation
orientation
,
const
QStyleOption
*
option
=
0
,
const
QWidget
*
widget
=
0
)
const
;
private:
ManhattanStylePrivate
*
d
;
...
...
src/plugins/debugger/debuggerplugin.cpp
View file @
c94e06bb
...
...
@@ -412,7 +412,7 @@ bool CommonOptionsPage::matches(const QString &s) const
static
inline
bool
oxygenStyle
()
{
if
(
const
ManhattanStyle
*
ms
=
qobject_cast
<
const
ManhattanStyle
*>
(
qApp
->
style
()))
return
!
qstrcmp
(
"OxygenStyle"
,
ms
->
system
Style
()
->
metaObject
()
->
className
());
return
!
qstrcmp
(
"OxygenStyle"
,
ms
->
base
Style
()
->
metaObject
()
->
className
());
return
false
;
}
...
...
src/plugins/texteditor/basetexteditor.cpp
View file @
c94e06bb
...
...
@@ -3055,7 +3055,7 @@ void BaseTextEditor::drawFoldingMarker(QPainter *painter, const QPalette &pal,
Q_UNUSED
(
hovered
)
QStyle
*
s
=
style
();
if
(
ManhattanStyle
*
ms
=
qobject_cast
<
ManhattanStyle
*>
(
s
))
s
=
ms
->
system
Style
();
s
=
ms
->
base
Style
();
if
(
!
qstrcmp
(
s
->
metaObject
()
->
className
(),
"OxygenStyle"
))
{
painter
->
save
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment