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
Tobias Hunger
qt-creator
Commits
70b70770
Commit
70b70770
authored
Feb 25, 2011
by
Thorbjørn Lindeijer
Browse files
Fixed layout issues in some editor toolbars
Cleaned up some hacky code in the process. Done-with: Tobias Hunger
parent
b3169701
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppeditor.cpp
View file @
70b70770
...
...
@@ -465,7 +465,7 @@ TextEditor::BaseTextEditor *CPPEditorWidget::createEditor()
return
editable
;
}
void
CPPEditorWidget
::
createToolBar
(
CPPEditor
*
edit
able
)
void
CPPEditorWidget
::
createToolBar
(
CPPEditor
*
edit
or
)
{
m_outlineCombo
=
new
QComboBox
;
m_outlineCombo
->
setMinimumContentsLength
(
22
);
...
...
@@ -528,10 +528,7 @@ void CPPEditorWidget::createToolBar(CPPEditor *editable)
connect
(
m_semanticHighlighter
,
SIGNAL
(
changed
(
CppEditor
::
Internal
::
SemanticInfo
)),
this
,
SLOT
(
updateSemanticInfo
(
CppEditor
::
Internal
::
SemanticInfo
)));
QToolBar
*
toolBar
=
static_cast
<
QToolBar
*>
(
editable
->
toolBar
());
QList
<
QAction
*>
actions
=
toolBar
->
actions
();
QWidget
*
w
=
toolBar
->
widgetForAction
(
actions
.
first
());
static_cast
<
QHBoxLayout
*>
(
w
->
layout
())
->
insertWidget
(
0
,
m_outlineCombo
,
1
);
editor
->
insertExtraToolBarWidget
(
TextEditor
::
BaseTextEditor
::
Left
,
m_outlineCombo
);
}
void
CPPEditorWidget
::
paste
()
...
...
src/plugins/git/gitclient.cpp
View file @
70b70770
...
...
@@ -106,6 +106,7 @@ public:
{
QHBoxLayout
*
layout
=
new
QHBoxLayout
(
this
);
layout
->
setContentsMargins
(
3
,
0
,
3
,
0
);
layout
->
setSpacing
(
2
);
m_patience
->
setToolTip
(
tr
(
"Use the patience algorithmn for calculating the diff"
));
m_patience
->
setText
(
tr
(
"Patience"
));
...
...
@@ -236,6 +237,7 @@ public:
{
QHBoxLayout
*
layout
=
new
QHBoxLayout
(
this
);
layout
->
setContentsMargins
(
3
,
0
,
3
,
0
);
layout
->
setSpacing
(
2
);
m_prettyFormat
->
setToolTip
(
tr
(
"Select the pretty printing format"
));
m_prettyFormat
->
addItem
(
tr
(
"oneline"
),
QLatin1String
(
"oneline"
));
...
...
@@ -247,6 +249,7 @@ public:
m_prettyFormat
->
addItem
(
tr
(
"raw"
),
QLatin1String
(
"raw"
));
layout
->
addWidget
(
m_prettyFormat
);
m_prettyFormat
->
setCurrentIndex
(
m_settings
->
showPrettyFormat
);
m_prettyFormat
->
setSizePolicy
(
QSizePolicy
::
Maximum
,
QSizePolicy
::
Preferred
);
connect
(
m_prettyFormat
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
testForArgumentsChanged
()));
}
...
...
@@ -304,6 +307,7 @@ public:
{
QHBoxLayout
*
layout
=
new
QHBoxLayout
(
this
);
layout
->
setContentsMargins
(
3
,
0
,
3
,
0
);
layout
->
setSpacing
(
2
);
m_omitDate
=
new
QToolButton
;
m_omitDate
->
setToolTip
(
tr
(
"Do not show the date a change was made in the output"
));
...
...
src/plugins/glsleditor/glsleditor.cpp
View file @
70b70770
...
...
@@ -274,7 +274,7 @@ TextEditor::BaseTextEditor *GLSLTextEditorWidget::createEditor()
return
editable
;
}
void
GLSLTextEditorWidget
::
createToolBar
(
GLSLEditorEditable
*
edit
able
)
void
GLSLTextEditorWidget
::
createToolBar
(
GLSLEditorEditable
*
edit
or
)
{
m_outlineCombo
=
new
QComboBox
;
m_outlineCombo
->
setMinimumContentsLength
(
22
);
...
...
@@ -295,10 +295,7 @@ void GLSLTextEditorWidget::createToolBar(GLSLEditorEditable *editable)
policy
.
setHorizontalPolicy
(
QSizePolicy
::
Expanding
);
m_outlineCombo
->
setSizePolicy
(
policy
);
QToolBar
*
toolBar
=
static_cast
<
QToolBar
*>
(
editable
->
toolBar
());
QList
<
QAction
*>
actions
=
toolBar
->
actions
();
toolBar
->
insertWidget
(
actions
.
first
(),
m_outlineCombo
);
editor
->
insertExtraToolBarWidget
(
TextEditor
::
BaseTextEditor
::
Left
,
m_outlineCombo
);
}
bool
GLSLTextEditorWidget
::
event
(
QEvent
*
e
)
...
...
src/plugins/qmljseditor/qmljseditor.cpp
View file @
70b70770
...
...
@@ -1222,7 +1222,7 @@ TextEditor::BaseTextEditor *QmlJSTextEditorWidget::createEditor()
return
editable
;
}
void
QmlJSTextEditorWidget
::
createToolBar
(
QmlJSEditorEditable
*
edit
able
)
void
QmlJSTextEditorWidget
::
createToolBar
(
QmlJSEditorEditable
*
edit
or
)
{
m_outlineCombo
=
new
QComboBox
;
m_outlineCombo
->
setMinimumContentsLength
(
22
);
...
...
@@ -1247,10 +1247,7 @@ void QmlJSTextEditorWidget::createToolBar(QmlJSEditorEditable *editable)
connect
(
file
(),
SIGNAL
(
changed
()),
this
,
SLOT
(
updateFileName
()));
QToolBar
*
toolBar
=
static_cast
<
QToolBar
*>
(
editable
->
toolBar
());
QList
<
QAction
*>
actions
=
toolBar
->
actions
();
toolBar
->
insertWidget
(
actions
.
first
(),
m_outlineCombo
);
editor
->
insertExtraToolBarWidget
(
TextEditor
::
BaseTextEditor
::
Left
,
m_outlineCombo
);
}
TextEditor
::
BaseTextEditorWidget
::
Link
QmlJSTextEditorWidget
::
findLinkAt
(
const
QTextCursor
&
cursor
,
bool
/*resolveTarget*/
)
...
...
src/plugins/texteditor/basetexteditor.cpp
View file @
70b70770
...
...
@@ -5775,17 +5775,13 @@ BaseTextEditor::BaseTextEditor(BaseTextEditorWidget *editor)
m_cursorPositionLabel
=
new
Utils
::
LineColumnLabel
;
QHBoxLayout
*
l
=
new
QHBoxLayout
;
QWidget
*
w
=
new
QWidget
;
l
->
setMargin
(
0
);
l
->
setContentsMargins
(
5
,
0
,
5
,
0
);
// l->addStretch(0);
l
->
addWidget
(
m_cursorPositionLabel
);
w
->
setLayout
(
l
);
m_stretchWidget
=
new
QWidget
;
m_stretchWidget
->
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Preferred
);
m_toolBar
=
new
QToolBar
;
m_toolBar
->
setSizePolicy
(
QSizePolicy
::
Minimum
,
QSizePolicy
::
Minimum
);
m_toolBar
->
addWidget
(
w
);
m_toolBar
->
setSizePolicy
(
QSizePolicy
::
MinimumExpanding
,
QSizePolicy
::
Minimum
);
m_toolBar
->
addWidget
(
m_stretchWidget
);
m_cursorPositionLabelAction
=
m_toolBar
->
addWidget
(
m_cursorPositionLabel
);
connect
(
editor
,
SIGNAL
(
cursorPositionChanged
()),
this
,
SLOT
(
updateCursorPosition
()));
}
...
...
@@ -5801,6 +5797,21 @@ QWidget *BaseTextEditor::toolBar()
return
m_toolBar
;
}
void
BaseTextEditor
::
insertExtraToolBarWidget
(
BaseTextEditor
::
Side
side
,
QWidget
*
widget
)
{
if
(
widget
->
sizePolicy
().
horizontalPolicy
()
&
QSizePolicy
::
ExpandFlag
)
{
if
(
m_stretchWidget
)
m_stretchWidget
->
deleteLater
();
m_stretchWidget
=
0
;
}
if
(
side
==
Right
)
m_toolBar
->
insertWidget
(
m_cursorPositionLabelAction
,
widget
);
else
m_toolBar
->
insertWidget
(
m_toolBar
->
actions
().
first
(),
widget
);
}
int
BaseTextEditor
::
find
(
const
QString
&
)
const
{
return
0
;
...
...
src/plugins/texteditor/basetexteditor.h
View file @
70b70770
...
...
@@ -567,6 +567,9 @@ public:
bool
restoreState
(
const
QByteArray
&
state
)
{
return
e
->
restoreState
(
state
);
}
QWidget
*
toolBar
();
enum
Side
{
Left
,
Right
};
void
insertExtraToolBarWidget
(
Side
side
,
QWidget
*
widget
);
// ITextEditor
int
find
(
const
QString
&
string
)
const
;
int
currentLine
()
const
;
...
...
@@ -609,6 +612,8 @@ private:
BaseTextEditorWidget
*
e
;
mutable
QString
m_contextHelpId
;
QToolBar
*
m_toolBar
;
QWidget
*
m_stretchWidget
;
QAction
*
m_cursorPositionLabelAction
;
Utils
::
LineColumnLabel
*
m_cursorPositionLabel
;
};
...
...
src/plugins/vcsbase/vcsbaseeditor.cpp
View file @
70b70770
...
...
@@ -120,39 +120,31 @@ class VCSBaseDiffEditor : public VCSBaseEditor
{
public:
VCSBaseDiffEditor
(
VCSBaseEditorWidget
*
,
const
VCSBaseEditorParameters
*
type
);
~
VCSBaseDiffEditor
();
virtual
QWidget
*
toolBar
()
{
return
m_toolBar
;
}
QComboBox
*
diffFileBrowseComboBox
()
const
{
return
m_diffFileBrowseComboBox
;
}
QComboBox
*
diffFileBrowseComboBox
()
const
{
return
m_diffFileBrowseComboBox
;
}
private:
QToolBar
*
m_toolBar
;
QComboBox
*
m_diffFileBrowseComboBox
;
};
VCSBaseDiffEditor
::
VCSBaseDiffEditor
(
VCSBaseEditorWidget
*
w
,
const
VCSBaseEditorParameters
*
type
)
:
VCSBaseEditor
(
w
,
type
),
m_toolBar
(
new
QToolBar
),
m_diffFileBrowseComboBox
(
new
QComboBox
(
m_toolBar
))
m_diffFileBrowseComboBox
(
new
QComboBox
)
{
m_diffFileBrowseComboBox
->
setMinimumContentsLength
(
20
);
// Make the combo box prefer to expand
QSizePolicy
policy
=
m_diffFileBrowseComboBox
->
sizePolicy
();
policy
.
setHorizontalPolicy
(
QSizePolicy
::
Expanding
);
m_diffFileBrowseComboBox
->
setSizePolicy
(
policy
);
m_toolBar
->
addWidget
(
m_diffFileBrowseComboBox
);
}
VCSBaseDiffEditor
::~
VCSBaseDiffEditor
()
{
delete
m_toolBar
;
insertExtraToolBarWidget
(
Left
,
m_diffFileBrowseComboBox
);
}
// ----------- VCSBaseEditorPrivate
struct
VCSBaseEditorPrivate
struct
VCSBaseEditor
Widget
Private
{
VCSBaseEditorPrivate
(
const
VCSBaseEditorParameters
*
type
);
VCSBaseEditor
Widget
Private
(
const
VCSBaseEditorParameters
*
type
);
const
VCSBaseEditorParameters
*
m_parameters
;
...
...
@@ -167,17 +159,17 @@ struct VCSBaseEditorPrivate
QString
m_annotatePreviousRevisionTextFormat
;
QString
m_copyRevisionTextFormat
;
bool
m_fileLogAnnotateEnabled
;
QToolBar
*
m_toolBa
r
;
TextEditor
::
BaseTextEditor
*
m_edito
r
;
QWidget
*
m_configurationWidget
;
};
VCSBaseEditorPrivate
::
VCSBaseEditorPrivate
(
const
VCSBaseEditorParameters
*
type
)
:
VCSBaseEditor
Widget
Private
::
VCSBaseEditor
Widget
Private
(
const
VCSBaseEditorParameters
*
type
)
:
m_parameters
(
type
),
m_cursorLine
(
-
1
),
m_annotateRevisionTextFormat
(
VCSBaseEditorWidget
::
tr
(
"Annotate
\"
%1
\"
"
)),
m_copyRevisionTextFormat
(
VCSBaseEditorWidget
::
tr
(
"Copy
\"
%1
\"
"
)),
m_fileLogAnnotateEnabled
(
false
),
m_
toolBa
r
(
0
),
m_
edito
r
(
0
),
m_configurationWidget
(
0
)
{
}
...
...
@@ -185,7 +177,7 @@ VCSBaseEditorPrivate::VCSBaseEditorPrivate(const VCSBaseEditorParameters *type)
// ------------ VCSBaseEditor
VCSBaseEditorWidget
::
VCSBaseEditorWidget
(
const
VCSBaseEditorParameters
*
type
,
QWidget
*
parent
)
:
BaseTextEditorWidget
(
parent
),
d
(
new
VCSBaseEditorPrivate
(
type
))
d
(
new
VCSBaseEditor
Widget
Private
(
type
))
{
if
(
VCSBase
::
Constants
::
Internal
::
debug
)
qDebug
()
<<
"VCSBaseEditor::VCSBaseEditor"
<<
type
->
type
<<
type
->
id
;
...
...
@@ -334,7 +326,7 @@ TextEditor::BaseTextEditor *VCSBaseEditorWidget::createEditor()
}
else
{
editor
=
new
VCSBaseEditor
(
this
,
d
->
m_parameters
);
}
d
->
m_
toolBar
=
qobject_cast
<
QToolBar
*>
(
editor
->
toolBar
())
;
d
->
m_
editor
=
editor
;
// Pass on signals.
connect
(
this
,
SIGNAL
(
describeRequested
(
QString
,
QString
)),
...
...
@@ -842,20 +834,12 @@ QString VCSBaseEditorWidget::getTitleId(const QString &workingDirectory,
bool
VCSBaseEditorWidget
::
setConfigurationWidget
(
QWidget
*
w
)
{
if
(
!
d
->
m_
toolBa
r
||
d
->
m_configurationWidget
)
if
(
!
d
->
m_
edito
r
||
d
->
m_configurationWidget
)
return
false
;
d
->
m_configurationWidget
=
w
;
if
(
contentType
()
==
AnnotateOutput
)
{
QList
<
QAction
*>
actions
=
d
->
m_toolBar
->
actions
();
Q_ASSERT
(
actions
.
count
()
>=
1
);
QWidget
*
spacer
=
new
QWidget
(
d
->
m_toolBar
);
spacer
->
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Minimum
);
QAction
*
configAction
=
d
->
m_toolBar
->
insertWidget
(
actions
.
at
(
0
),
w
);
d
->
m_toolBar
->
insertWidget
(
configAction
,
spacer
);
}
else
{
d
->
m_toolBar
->
addWidget
(
w
);
}
d
->
m_editor
->
insertExtraToolBarWidget
(
TextEditor
::
BaseTextEditor
::
Right
,
w
);
return
true
;
}
...
...
src/plugins/vcsbase/vcsbaseeditor.h
View file @
70b70770
...
...
@@ -52,7 +52,7 @@ namespace Core {
namespace
VCSBase
{
struct
VCSBaseEditorPrivate
;
struct
VCSBaseEditor
Widget
Private
;
class
DiffHighlighter
;
class
BaseAnnotationHighlighter
;
...
...
@@ -248,7 +248,7 @@ private:
QAction
*
createAnnotateAction
(
const
QString
&
change
,
bool
previous
=
false
);
QAction
*
createCopyRevisionAction
(
const
QString
&
change
);
VCSBaseEditorPrivate
*
d
;
VCSBaseEditor
Widget
Private
*
d
;
};
}
// namespace VCSBase
...
...
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