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
baeb6713
Commit
baeb6713
authored
May 04, 2009
by
Thorbjørn Lindeijer
Browse files
Removed the fancy folding bar
The improved traditional bar will hopefully keep everybody happy.
parent
3236678c
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/basetexteditor.cpp
View file @
baeb6713
...
...
@@ -1498,10 +1498,8 @@ QRect BaseTextEditor::collapseBox()
QTextBlock
begin
=
document
()
->
findBlockByNumber
(
d
->
m_highlightBlocksInfo
.
open
.
last
());
if
(
true
||
!
d
->
m_displaySettings
.
m_fancyFoldingBar
)
{
if
(
TextBlockUserData
::
hasCollapseAfter
(
begin
.
previous
()))
begin
=
begin
.
previous
();
}
if
(
TextBlockUserData
::
hasCollapseAfter
(
begin
.
previous
()))
begin
=
begin
.
previous
();
QTextBlock
end
=
document
()
->
findBlockByNumber
(
d
->
m_highlightBlocksInfo
.
close
.
first
());
if
(
!
begin
.
isValid
()
||
!
end
.
isValid
())
...
...
@@ -1694,13 +1692,6 @@ void BaseTextEditorPrivate::moveCursorVisible(bool ensureVisible)
q
->
ensureCursorVisible
();
}
static
QColor
calcMixColor
(
const
QColor
&
one
,
const
QColor
&
two
)
{
return
QColor
((
one
.
red
()
+
two
.
red
())
/
2
,
(
one
.
green
()
+
two
.
green
())
/
2
,
(
one
.
blue
()
+
two
.
blue
())
/
2
);
}
static
QColor
calcBlendColor
(
const
QColor
&
baseColor
,
int
factor
=
1
)
{
const
int
blendBase
=
(
baseColor
.
value
()
>
128
)
?
0
:
255
;
...
...
@@ -2313,71 +2304,7 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e)
}
}
if
(
d
->
m_codeFoldingVisible
&&
d
->
m_displaySettings
.
m_fancyFoldingBar
)
{
QRect
r
(
extraAreaWidth
+
2
,
top
,
collapseBoxWidth
-
4
,
bottom
-
top
);
int
extraAreaHighlightCollapseBlockNumber
=
-
1
;
int
extraAreaHighlightCollapseEndBlockNumber
=
-
1
;
if
(
!
d
->
m_highlightBlocksInfo
.
isEmpty
())
{
extraAreaHighlightCollapseBlockNumber
=
d
->
m_highlightBlocksInfo
.
open
.
last
();
extraAreaHighlightCollapseEndBlockNumber
=
d
->
m_highlightBlocksInfo
.
close
.
first
();
QTextBlock
before
=
doc
->
findBlockByNumber
(
extraAreaHighlightCollapseBlockNumber
-
1
);
if
(
TextBlockUserData
::
hasCollapseAfter
(
before
))
{
extraAreaHighlightCollapseBlockNumber
--
;
}
}
int
minBraceDepth
=
qMax
(
braceDepth
,
previousBraceDepth
);
QColor
color
=
calcBlendColor
(
baseColor
,
minBraceDepth
);
if
(
!
d
->
m_highlightBlocksInfo
.
isEmpty
()
&&
blockNumber
>=
extraAreaHighlightCollapseBlockNumber
&&
blockNumber
<=
extraAreaHighlightCollapseEndBlockNumber
)
color
=
calcMixColor
(
pal
.
highlight
().
color
(),
color
);
painter
.
fillRect
(
r
,
color
);
bool
drawBox
=
!
nextBlock
.
isVisible
();
bool
drawDown
=
!
d
->
m_highlightBlocksInfo
.
isEmpty
()
&&
blockNumber
==
extraAreaHighlightCollapseBlockNumber
;
bool
drawUp
=
!
d
->
m_highlightBlocksInfo
.
isEmpty
()
&&
blockNumber
==
extraAreaHighlightCollapseEndBlockNumber
;
if
(
drawBox
||
drawDown
||
drawUp
)
{
painter
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
painter
.
translate
(
.5
,
.5
);
painter
.
setPen
(
pal
.
text
().
color
());
painter
.
setBrush
(
pal
.
text
().
color
());
if
(
drawBox
)
{
QPointF
points1
[
3
]
=
{
QPointF
(
r
.
left
(),
r
.
center
().
y
()
-
1
),
QPointF
(
r
.
center
().
x
(),
r
.
top
()),
QPointF
(
r
.
right
(),
r
.
center
().
y
()
-
1
)
};
QPointF
points2
[
3
]
=
{
QPointF
(
r
.
left
(),
r
.
center
().
y
()
+
1
),
QPointF
(
r
.
center
().
x
(),
r
.
bottom
()
-
1
),
QPointF
(
r
.
right
(),
r
.
center
().
y
()
+
1
)
};
painter
.
drawPolygon
(
points1
,
3
);
painter
.
drawPolygon
(
points2
,
3
);
}
else
if
(
drawUp
)
{
// check that we are not collapsed
QTextBlock
open
=
doc
->
findBlockByNumber
(
extraAreaHighlightCollapseBlockNumber
);
if
(
open
.
next
().
isVisible
())
{
QPointF
points
[
3
]
=
{
QPointF
(
r
.
left
(),
r
.
bottom
()
-
1
),
QPointF
(
r
.
center
().
x
(),
r
.
center
().
y
()),
QPointF
(
r
.
right
(),
r
.
bottom
()
-
1
)
};
painter
.
drawPolygon
(
points
,
3
);
}
}
else
if
(
drawDown
)
{
QPointF
points
[
3
]
=
{
QPointF
(
r
.
left
(),
r
.
top
()),
QPointF
(
r
.
center
().
x
(),
r
.
center
().
y
()),
QPointF
(
r
.
right
(),
r
.
top
())
};
painter
.
drawPolygon
(
points
,
3
);
}
painter
.
translate
(
-
.5
,
-
.5
);
painter
.
setRenderHint
(
QPainter
::
Antialiasing
,
false
);
}
}
else
if
(
d
->
m_codeFoldingVisible
)
{
if
(
d
->
m_codeFoldingVisible
)
{
bool
collapseThis
=
false
;
bool
collapseAfter
=
false
;
...
...
@@ -2473,13 +2400,6 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e)
block
=
nextVisibleBlock
;
blockNumber
=
nextVisibleBlockNumber
;
}
if
(
d
->
m_codeFoldingVisible
&&
d
->
m_displaySettings
.
m_fancyFoldingBar
)
{
painter
.
drawLine
(
extraAreaWidth
,
0
,
extraAreaWidth
,
viewport
()
->
height
());
painter
.
drawLine
(
extraAreaWidth
+
collapseBoxWidth
-
1
,
0
,
extraAreaWidth
+
collapseBoxWidth
-
1
,
viewport
()
->
height
());
}
}
void
BaseTextEditor
::
drawFoldingMarker
(
QPainter
*
painter
,
const
QRect
&
rect
,
...
...
@@ -2707,15 +2627,13 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
d
->
extraAreaHighlightCollapseBlockNumber
=
-
1
;
d
->
extraAreaHighlightCollapseColumn
=
-
1
;
int
collapseBoxWidth
=
fontMetrics
().
lineSpacing
()
+
1
;
if
(
e
->
pos
().
x
()
>
extraArea
()
->
width
()
-
collapseBoxWidth
)
{
d
->
extraAreaHighlightCollapseBlockNumber
=
cursor
.
blockNumber
();
if
(
TextBlockUserData
::
canCollapse
(
cursor
.
block
())
||
!
TextBlockUserData
::
hasClosingCollapse
(
cursor
.
block
()))
d
->
extraAreaHighlightCollapseColumn
=
cursor
.
block
().
length
()
-
1
;
if
((
true
||
!
d
->
m_displaySettings
.
m_fancyFoldingBar
)
&&
TextBlockUserData
::
hasCollapseAfter
(
cursor
.
block
()))
{
if
(
TextBlockUserData
::
hasCollapseAfter
(
cursor
.
block
()))
{
d
->
extraAreaHighlightCollapseBlockNumber
++
;
d
->
extraAreaHighlightCollapseColumn
=
-
1
;
if
(
TextBlockUserData
::
canCollapse
(
cursor
.
block
().
next
())
...
...
src/plugins/texteditor/displaysettings.cpp
View file @
baeb6713
...
...
@@ -43,7 +43,6 @@ static const char * const displayFoldingMarkersKey = "DisplayFoldingMarkers";
static
const
char
*
const
highlightCurrentLineKey
=
"HighlightCurrentLineKeyV2"
;
static
const
char
*
const
highlightBlocksKey
=
"HighlightBlocksKey"
;
static
const
char
*
const
animateMatchingParenthesesKey
=
"AnimateMatchingParenthesesKey"
;
static
const
char
*
const
fancyFoldingBarKey
=
"FancyFoldingBarKey"
;
static
const
char
*
const
groupPostfix
=
"DisplaySettings"
;
namespace
TextEditor
{
...
...
@@ -57,8 +56,7 @@ DisplaySettings::DisplaySettings() :
m_displayFoldingMarkers
(
true
),
m_highlightCurrentLine
(
false
),
m_highlightBlocks
(
false
),
m_animateMatchingParentheses
(
true
),
m_fancyFoldingBar
(
false
)
m_animateMatchingParentheses
(
true
)
{
}
...
...
@@ -77,7 +75,6 @@ void DisplaySettings::toSettings(const QString &category, QSettings *s) const
s
->
setValue
(
QLatin1String
(
highlightCurrentLineKey
),
m_highlightCurrentLine
);
s
->
setValue
(
QLatin1String
(
highlightBlocksKey
),
m_highlightBlocks
);
s
->
setValue
(
QLatin1String
(
animateMatchingParenthesesKey
),
m_animateMatchingParentheses
);
s
->
setValue
(
QLatin1String
(
fancyFoldingBarKey
),
m_fancyFoldingBar
);
s
->
endGroup
();
}
...
...
@@ -99,7 +96,6 @@ void DisplaySettings::fromSettings(const QString &category, const QSettings *s)
m_highlightCurrentLine
=
s
->
value
(
group
+
QLatin1String
(
highlightCurrentLineKey
),
m_highlightCurrentLine
).
toBool
();
m_highlightBlocks
=
s
->
value
(
group
+
QLatin1String
(
highlightBlocksKey
),
m_highlightBlocks
).
toBool
();
m_animateMatchingParentheses
=
s
->
value
(
group
+
QLatin1String
(
animateMatchingParenthesesKey
),
m_animateMatchingParentheses
).
toBool
();
m_fancyFoldingBar
=
s
->
value
(
group
+
QLatin1String
(
fancyFoldingBarKey
),
m_fancyFoldingBar
).
toBool
();
}
bool
DisplaySettings
::
equals
(
const
DisplaySettings
&
ds
)
const
...
...
@@ -113,7 +109,6 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const
&&
m_highlightCurrentLine
==
ds
.
m_highlightCurrentLine
&&
m_highlightBlocks
==
ds
.
m_highlightBlocks
&&
m_animateMatchingParentheses
==
ds
.
m_animateMatchingParentheses
&&
m_fancyFoldingBar
==
ds
.
m_fancyFoldingBar
;
}
...
...
src/plugins/texteditor/displaysettings.h
View file @
baeb6713
...
...
@@ -54,7 +54,6 @@ struct TEXTEDITOR_EXPORT DisplaySettings
bool
m_highlightCurrentLine
;
bool
m_highlightBlocks
;
bool
m_animateMatchingParentheses
;
bool
m_fancyFoldingBar
;
bool
equals
(
const
DisplaySettings
&
ds
)
const
;
};
...
...
src/plugins/texteditor/displaysettingspage.cpp
View file @
baeb6713
...
...
@@ -124,7 +124,6 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
displaySettings
.
m_highlightCurrentLine
=
m_d
->
m_page
.
highlightCurrentLine
->
isChecked
();
displaySettings
.
m_highlightBlocks
=
m_d
->
m_page
.
highlightBlocks
->
isChecked
();
displaySettings
.
m_animateMatchingParentheses
=
m_d
->
m_page
.
animateMatchingParentheses
->
isChecked
();
displaySettings
.
m_fancyFoldingBar
=
m_d
->
m_page
.
fancyFoldingBar
->
isChecked
();
}
void
DisplaySettingsPage
::
settingsToUI
()
...
...
@@ -139,7 +138,6 @@ void DisplaySettingsPage::settingsToUI()
m_d
->
m_page
.
highlightCurrentLine
->
setChecked
(
displaySettings
.
m_highlightCurrentLine
);
m_d
->
m_page
.
highlightBlocks
->
setChecked
(
displaySettings
.
m_highlightBlocks
);
m_d
->
m_page
.
animateMatchingParentheses
->
setChecked
(
displaySettings
.
m_animateMatchingParentheses
);
m_d
->
m_page
.
fancyFoldingBar
->
setChecked
(
displaySettings
.
m_fancyFoldingBar
);
}
DisplaySettings
DisplaySettingsPage
::
displaySettings
()
const
...
...
src/plugins/texteditor/displaysettingspage.ui
View file @
baeb6713
...
...
@@ -47,36 +47,6 @@
</property>
</widget>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<item>
<spacer
name=
"horizontalSpacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeType"
>
<enum>
QSizePolicy::Fixed
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"fancyFoldingBar"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
<property
name=
"text"
>
<string>
Use fancy style
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"visualizeWhitespace"
>
<property
name=
"toolTip"
>
...
...
@@ -181,21 +151,5 @@
</hint>
</hints>
</connection>
<connection>
<sender>
displayFoldingMarkers
</sender>
<signal>
toggled(bool)
</signal>
<receiver>
fancyFoldingBar
</receiver>
<slot>
setEnabled(bool)
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
60
</x>
<y>
161
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
87
</x>
<y>
179
</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Write
Preview
Supports
Markdown
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