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
d6e4a787
Commit
d6e4a787
authored
Nov 30, 2009
by
mae
Browse files
separate font zoom from font size
Introduce "Reset Font Size" action, bound to Ctrl+0
parent
85b6ee64
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/plugins/help/helpplugin.cpp
View file @
d6e4a787
...
...
@@ -427,7 +427,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
advancedMenu
->
addAction
(
cmd
,
Core
::
Constants
::
G_EDIT_FONT
);
a
=
new
QAction
(
tr
(
"Reset Font Size"
),
this
);
cmd
=
am
->
registerAction
(
a
,
QLatin1String
(
"Help.ResetFontSize"
)
,
cmd
=
am
->
registerAction
(
a
,
TextEditor
::
Constants
::
DECREASE_FONT_SIZE
,
modecontext
);
cmd
->
setDefaultKeySequence
(
QKeySequence
(
tr
(
"Ctrl+0"
)));
connect
(
a
,
SIGNAL
(
triggered
()),
m_centralWidget
,
SLOT
(
resetZoom
()));
...
...
src/plugins/texteditor/basetexteditor.cpp
View file @
d6e4a787
...
...
@@ -3411,14 +3411,8 @@ void BaseTextEditor::wheelEvent(QWheelEvent *e)
void
BaseTextEditor
::
zoomIn
(
int
range
)
{
d
->
clearVisibleCollapsedBlock
();
QFont
f
=
font
();
const
int
newSize
=
f
.
pointSize
()
+
range
;
if
(
newSize
<=
0
)
return
;
emit
requestFontSize
(
newSize
);
// f.setPointSize(newSize);
// setFont(f);
d
->
clearVisibleCollapsedBlock
();
emit
requestFontZoom
(
range
*
10
);
}
void
BaseTextEditor
::
zoomOut
(
int
range
)
...
...
@@ -3426,6 +3420,11 @@ void BaseTextEditor::zoomOut(int range)
zoomIn
(
-
range
);
}
void
BaseTextEditor
::
zoomReset
()
{
emit
requestZoomReset
();
}
bool
BaseTextEditor
::
isElectricCharacter
(
const
QChar
&
)
const
{
return
false
;
...
...
src/plugins/texteditor/basetexteditor.h
View file @
d6e4a787
...
...
@@ -382,6 +382,7 @@ public slots:
void
zoomIn
(
int
range
=
1
);
void
zoomOut
(
int
range
=
1
);
void
zoomReset
();
void
cutLine
();
void
deleteLine
();
...
...
@@ -579,7 +580,8 @@ protected slots:
virtual
void
slotUpdateBlockNotify
(
const
QTextBlock
&
);
signals:
void
requestFontSize
(
int
pointSize
);
void
requestFontZoom
(
int
zoom
);
void
requestZoomReset
();
void
requestBlockUpdate
(
const
QTextBlock
&
);
void
requestAutoCompletion
(
TextEditor
::
ITextEditable
*
editor
,
bool
forced
);
void
requestQuickFix
(
TextEditor
::
ITextEditable
*
editor
);
...
...
src/plugins/texteditor/fontsettings.cpp
View file @
d6e4a787
...
...
@@ -39,6 +39,7 @@
static
const
char
*
fontFamilyKey
=
"FontFamily"
;
static
const
char
*
fontSizeKey
=
"FontSize"
;
static
const
char
*
fontZoomKey
=
"FontZoom"
;
static
const
char
*
antialiasKey
=
"FontAntialias"
;
static
const
char
*
schemeFileNameKey
=
"ColorScheme"
;
...
...
@@ -65,6 +66,7 @@ namespace TextEditor {
FontSettings
::
FontSettings
()
:
m_family
(
defaultFixedFontFamily
()),
m_fontSize
(
DEFAULT_FONT_SIZE
),
m_fontZoom
(
100
),
m_antialias
(
DEFAULT_ANTIALIAS
)
{
}
...
...
@@ -73,6 +75,7 @@ void FontSettings::clear()
{
m_family
=
defaultFixedFontFamily
();
m_fontSize
=
DEFAULT_FONT_SIZE
;
m_fontZoom
=
100
;
m_antialias
=
DEFAULT_ANTIALIAS
;
m_scheme
.
clear
();
}
...
...
@@ -87,6 +90,9 @@ void FontSettings::toSettings(const QString &category,
if
(
m_fontSize
!=
DEFAULT_FONT_SIZE
||
s
->
contains
(
QLatin1String
(
fontSizeKey
)))
s
->
setValue
(
QLatin1String
(
fontSizeKey
),
m_fontSize
);
if
(
m_fontZoom
!=
100
||
s
->
contains
(
QLatin1String
(
fontZoomKey
)))
s
->
setValue
(
QLatin1String
(
fontZoomKey
),
m_fontZoom
);
if
(
m_antialias
!=
DEFAULT_ANTIALIAS
||
s
->
contains
(
QLatin1String
(
antialiasKey
)))
s
->
setValue
(
QLatin1String
(
antialiasKey
),
m_antialias
);
...
...
@@ -110,6 +116,7 @@ bool FontSettings::fromSettings(const QString &category,
m_family
=
s
->
value
(
group
+
QLatin1String
(
fontFamilyKey
),
defaultFixedFontFamily
()).
toString
();
m_fontSize
=
s
->
value
(
group
+
QLatin1String
(
fontSizeKey
),
m_fontSize
).
toInt
();
m_fontZoom
=
s
->
value
(
group
+
QLatin1String
(
fontZoomKey
),
m_fontZoom
).
toInt
();
m_antialias
=
s
->
value
(
group
+
QLatin1String
(
antialiasKey
),
DEFAULT_ANTIALIAS
).
toBool
();
if
(
s
->
contains
(
group
+
QLatin1String
(
schemeFileNameKey
)))
{
...
...
@@ -144,6 +151,7 @@ bool FontSettings::equals(const FontSettings &f) const
return
m_family
==
f
.
m_family
&&
m_schemeFileName
==
f
.
m_schemeFileName
&&
m_fontSize
==
f
.
m_fontSize
&&
m_fontZoom
==
f
.
m_fontZoom
&&
m_antialias
==
f
.
m_antialias
&&
m_scheme
==
f
.
m_scheme
;
}
...
...
@@ -160,7 +168,7 @@ QTextCharFormat FontSettings::toTextCharFormat(const QString &category) const
if
(
category
==
textCategory
)
{
tf
.
setFontFamily
(
m_family
);
tf
.
setFontPointSize
(
m_fontSize
);
tf
.
setFontPointSize
(
m_fontSize
*
m_fontZoom
/
100
);
tf
.
setFontStyleStrategy
(
m_antialias
?
QFont
::
PreferAntialias
:
QFont
::
NoAntialias
);
}
...
...
@@ -213,6 +221,19 @@ void FontSettings::setFontSize(int size)
m_fontSize
=
size
;
}
/**
* Returns the configured font zoom factor in percent.
*/
int
FontSettings
::
fontZoom
()
const
{
return
m_fontZoom
;
}
void
FontSettings
::
setFontZoom
(
int
zoom
)
{
m_fontZoom
=
zoom
;
}
/**
* Returns the configured antialiasing behavior.
*/
...
...
src/plugins/texteditor/fontsettings.h
View file @
d6e4a787
...
...
@@ -78,6 +78,9 @@ public:
int
fontSize
()
const
;
void
setFontSize
(
int
size
);
int
fontZoom
()
const
;
void
setFontZoom
(
int
zoom
);
QFont
font
()
const
{
return
QFont
(
family
(),
fontSize
());
}
...
...
@@ -105,6 +108,7 @@ private:
QString
m_family
;
QString
m_schemeFileName
;
int
m_fontSize
;
int
m_fontZoom
;
bool
m_antialias
;
ColorScheme
m_scheme
;
};
...
...
src/plugins/texteditor/fontsettingspage.cpp
View file @
d6e4a787
...
...
@@ -360,6 +360,7 @@ QWidget *FontSettingsPage::createPage(QWidget *parent)
d_ptr
->
ui
.
familyComboBox
->
setCurrentIndex
(
idx
);
d_ptr
->
ui
.
antialias
->
setChecked
(
d_ptr
->
m_value
.
antialias
());
d_ptr
->
ui
.
zoomSpinBox
->
setValue
(
d_ptr
->
m_value
.
fontZoom
());
d_ptr
->
ui
.
schemeEdit
->
setFormatDescriptions
(
d_ptr
->
m_descriptions
);
d_ptr
->
ui
.
schemeEdit
->
setBaseFont
(
d_ptr
->
m_value
.
font
());
...
...
@@ -367,10 +368,12 @@ QWidget *FontSettingsPage::createPage(QWidget *parent)
connect
(
d_ptr
->
ui
.
familyComboBox
,
SIGNAL
(
currentIndexChanged
(
QString
)),
this
,
SLOT
(
fontFamilySelected
(
QString
)));
connect
(
d_ptr
->
ui
.
sizeComboBox
,
SIGNAL
(
currentIndexChanged
(
QString
)),
this
,
SLOT
(
fontSizeSelected
(
QString
)));
connect
(
d_ptr
->
ui
.
zoomSpinBox
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
fontZoomChanged
()));
connect
(
d_ptr
->
ui
.
schemeComboBox
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
colorSchemeSelected
(
int
)));
connect
(
d_ptr
->
ui
.
copyButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
copyColorScheme
()));
connect
(
d_ptr
->
ui
.
deleteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
confirmDeleteColorScheme
()));
updatePointSizes
();
refreshColorSchemeList
();
d_ptr
->
m_lastValue
=
d_ptr
->
m_value
;
...
...
@@ -421,6 +424,11 @@ void FontSettingsPage::fontSizeSelected(const QString &sizeString)
}
}
void
FontSettingsPage
::
fontZoomChanged
()
{
d_ptr
->
m_value
.
setFontZoom
(
d_ptr
->
ui
.
zoomSpinBox
->
value
());
}
void
FontSettingsPage
::
colorSchemeSelected
(
int
index
)
{
bool
readOnly
=
true
;
...
...
src/plugins/texteditor/fontsettingspage.h
View file @
d6e4a787
...
...
@@ -111,6 +111,7 @@ private slots:
void
delayedChange
();
void
fontFamilySelected
(
const
QString
&
family
);
void
fontSizeSelected
(
const
QString
&
sizeString
);
void
fontZoomChanged
();
void
colorSchemeSelected
(
int
index
);
void
copyColorScheme
();
void
copyColorScheme
(
const
QString
&
name
);
...
...
src/plugins/texteditor/fontsettingspage.ui
View file @
d6e4a787
...
...
@@ -6,7 +6,7 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
344
</width>
<width>
402
</width>
<height>
306
</height>
</rect>
</property>
...
...
@@ -84,9 +84,12 @@
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeType"
>
<enum>
QSizePolicy::Preferred
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
4
0
</width>
<width>
2
0
</width>
<height>
20
</height>
</size>
</property>
...
...
@@ -99,6 +102,45 @@
</property>
</widget>
</item>
<item
row=
"0"
column=
"7"
>
<widget
class=
"QSpinBox"
name=
"zoomSpinBox"
>
<property
name=
"suffix"
>
<string>
%
</string>
</property>
<property
name=
"minimum"
>
<number>
10
</number>
</property>
<property
name=
"maximum"
>
<number>
300
</number>
</property>
<property
name=
"singleStep"
>
<number>
10
</number>
</property>
<property
name=
"value"
>
<number>
100
</number>
</property>
</widget>
</item>
<item
row=
"0"
column=
"8"
>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item
row=
"0"
column=
"6"
>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
Zoom:
</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
...
...
src/plugins/texteditor/texteditoractionhandler.cpp
View file @
d6e4a787
...
...
@@ -73,6 +73,7 @@ TextEditorActionHandler::TextEditorActionHandler(const QString &context,
m_selectEncodingAction
(
0
),
m_increaseFontSizeAction
(
0
),
m_decreaseFontSizeAction
(
0
),
m_resetFontSizeAction
(
0
),
m_gotoBlockStartAction
(
0
),
m_gotoBlockEndAction
(
0
),
m_gotoBlockStartWithSelectionAction
(
0
),
...
...
@@ -221,6 +222,12 @@ void TextEditorActionHandler::createActions()
connect
(
m_decreaseFontSizeAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
decreaseFontSize
()));
advancedMenu
->
addAction
(
command
,
Core
::
Constants
::
G_EDIT_FONT
);
m_resetFontSizeAction
=
new
QAction
(
tr
(
"Reset Font Size"
),
this
);
command
=
am
->
registerAction
(
m_resetFontSizeAction
,
Constants
::
RESET_FONT_SIZE
,
m_contextId
);
command
->
setDefaultKeySequence
(
QKeySequence
(
tr
(
"Ctrl+0"
)));
connect
(
m_resetFontSizeAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
resetFontSize
()));
advancedMenu
->
addAction
(
command
,
Core
::
Constants
::
G_EDIT_FONT
);
m_gotoBlockStartAction
=
new
QAction
(
tr
(
"Goto Block Start"
),
this
);
command
=
am
->
registerAction
(
m_gotoBlockStartAction
,
Constants
::
GOTO_BLOCK_START
,
m_contextId
);
command
->
setDefaultKeySequence
(
QKeySequence
(
tr
(
"Ctrl+["
)));
...
...
@@ -422,6 +429,7 @@ FUNCTION(collapse)
FUNCTION
(
expand
)
FUNCTION2
(
increaseFontSize
,
zoomIn
)
FUNCTION2
(
decreaseFontSize
,
zoomOut
)
FUNCTION2
(
resetFontSize
,
zoomReset
)
FUNCTION
(
selectEncoding
)
FUNCTION
(
gotoBlockStart
)
FUNCTION
(
gotoBlockEnd
)
...
...
src/plugins/texteditor/texteditoractionhandler.h
View file @
d6e4a787
...
...
@@ -104,6 +104,7 @@ private slots:
void
selectEncoding
();
void
increaseFontSize
();
void
decreaseFontSize
();
void
resetFontSize
();
void
gotoBlockStart
();
void
gotoBlockEnd
();
void
gotoBlockStartWithSelection
();
...
...
@@ -139,6 +140,7 @@ private:
QAction
*
m_selectEncodingAction
;
QAction
*
m_increaseFontSizeAction
;
QAction
*
m_decreaseFontSizeAction
;
QAction
*
m_resetFontSizeAction
;
QAction
*
m_gotoBlockStartAction
;
QAction
*
m_gotoBlockEndAction
;
QAction
*
m_gotoBlockStartWithSelectionAction
;
...
...
src/plugins/texteditor/texteditorconstants.h
View file @
d6e4a787
...
...
@@ -49,6 +49,7 @@ const char * const UN_COLLAPSE_ALL = "TextEditor.UnCollapseAll";
const
char
*
const
AUTO_INDENT_SELECTION
=
"TextEditor.AutoIndentSelection"
;
const
char
*
const
INCREASE_FONT_SIZE
=
"TextEditor.IncreaseFontSize"
;
const
char
*
const
DECREASE_FONT_SIZE
=
"TextEditor.DecreaseFontSize"
;
const
char
*
const
RESET_FONT_SIZE
=
"TextEditor.ResetFontSize"
;
const
char
*
const
GOTO_BLOCK_START
=
"TextEditor.GotoBlockStart"
;
const
char
*
const
GOTO_BLOCK_START_WITH_SELECTION
=
"TextEditor.GotoBlockStartWithSelection"
;
const
char
*
const
GOTO_BLOCK_END
=
"TextEditor.GotoBlockEnd"
;
...
...
src/plugins/texteditor/texteditorsettings.cpp
View file @
d6e4a787
...
...
@@ -170,8 +170,10 @@ void TextEditorSettings::initializeEditor(BaseTextEditor *editor)
connect
(
this
,
SIGNAL
(
displaySettingsChanged
(
TextEditor
::
DisplaySettings
)),
editor
,
SLOT
(
setDisplaySettings
(
TextEditor
::
DisplaySettings
)));
connect
(
editor
,
SIGNAL
(
requestFontSize
(
int
)),
this
,
SLOT
(
fontSizeRequested
(
int
)));
connect
(
editor
,
SIGNAL
(
requestFontZoom
(
int
)),
this
,
SLOT
(
fontZoomRequested
(
int
)));
connect
(
editor
,
SIGNAL
(
requestZoomReset
()),
this
,
SLOT
(
zoomResetRequested
()));
// Apply current settings (tab settings depend on font settings)
editor
->
setFontSettings
(
fontSettings
());
...
...
@@ -181,10 +183,17 @@ void TextEditorSettings::initializeEditor(BaseTextEditor *editor)
}
void
TextEditorSettings
::
font
Size
Requested
(
int
pointSize
)
void
TextEditorSettings
::
font
Zoom
Requested
(
int
zoom
)
{
FontSettings
&
fs
=
const_cast
<
FontSettings
&>
(
m_fontSettingsPage
->
fontSettings
());
fs
.
setFontSize
(
pointSize
);
fs
.
setFontZoom
(
qMax
(
10
,
fs
.
fontZoom
()
+
zoom
));
m_fontSettingsPage
->
saveSettings
();
}
void
TextEditorSettings
::
zoomResetRequested
()
{
FontSettings
&
fs
=
const_cast
<
FontSettings
&>
(
m_fontSettingsPage
->
fontSettings
());
fs
.
setFontZoom
(
100
);
m_fontSettingsPage
->
saveSettings
();
}
...
...
src/plugins/texteditor/texteditorsettings.h
View file @
d6e4a787
...
...
@@ -74,7 +74,8 @@ signals:
void
displaySettingsChanged
(
const
TextEditor
::
DisplaySettings
&
);
private
slots
:
void
fontSizeRequested
(
int
pointSize
);
void
fontZoomRequested
(
int
pointSize
);
void
zoomResetRequested
();
private:
FontSettingsPage
*
m_fontSettingsPage
;
...
...
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