Skip to content
GitLab
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
bfc04b98
Commit
bfc04b98
authored
Jun 25, 2009
by
kh
Browse files
Store and restore font size for help viewers. Add font reset shortcut.
Task-number: 253365 Reviewed-by: kh
parent
c798f54f
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/plugins/help/centralwidget.cpp
View file @
bfc04b98
...
...
@@ -131,14 +131,18 @@ CentralWidget::~CentralWidget()
if
(
!
engine
.
setupData
())
return
;
QString
zoomCount
;
QString
currentPages
;
for
(
int
i
=
0
;
i
<
tabWidget
->
count
();
++
i
)
{
HelpViewer
*
viewer
=
qobject_cast
<
HelpViewer
*>
(
tabWidget
->
widget
(
i
));
if
(
viewer
&&
viewer
->
source
().
isValid
())
if
(
viewer
&&
viewer
->
source
().
isValid
())
{
currentPages
+=
(
viewer
->
source
().
toString
()
+
QLatin1Char
(
'|'
));
zoomCount
+=
QString
::
number
(
viewer
->
zoom
())
+
QLatin1Char
(
'|'
);
}
}
engine
.
setCustomValue
(
QLatin1String
(
"LastTabPage"
),
lastTabPage
);
engine
.
setCustomValue
(
QLatin1String
(
"LastShownPages"
),
currentPages
);
engine
.
setCustomValue
(
QLatin1String
(
"LastShownPagesZoom"
),
zoomCount
);
}
CentralWidget
*
CentralWidget
::
instance
()
...
...
@@ -250,9 +254,21 @@ void CentralWidget::setLastShownPages()
return
;
}
value
=
helpEngine
->
customValue
(
QLatin1String
(
"LastShownPagesZoom"
),
QString
()).
toString
();
QVector
<
QString
>
zoomVector
=
value
.
split
(
QLatin1Char
(
'|'
),
QString
::
SkipEmptyParts
).
toVector
();
const
int
zoomCount
=
zoomVector
.
count
();
zoomVector
.
insert
(
zoomCount
,
pageCount
-
zoomCount
,
QLatin1String
(
"0"
));
QVector
<
QString
>::
const_iterator
zIt
=
zoomVector
.
constBegin
();
QStringList
::
const_iterator
it
=
lastShownPageList
.
constBegin
();
for
(;
it
!=
lastShownPageList
.
constEnd
();
++
it
)
setSourceInNewTab
((
*
it
));
for
(;
it
!=
lastShownPageList
.
constEnd
();
++
it
,
++
zIt
)
setSourceInNewTab
((
*
it
),
(
*
zIt
).
toInt
());
int
tab
=
helpEngine
->
customValue
(
QLatin1String
(
"LastTabPage"
),
0
).
toInt
();
tabWidget
->
setCurrentIndex
(
tab
);
}
bool
CentralWidget
::
hasSelection
()
const
...
...
@@ -404,12 +420,20 @@ void CentralWidget::setGlobalActions(const QList<QAction*> &actions)
globalActionList
=
actions
;
}
void
CentralWidget
::
setSourceInNewTab
(
const
QUrl
&
url
)
void
CentralWidget
::
setSourceInNewTab
(
const
QUrl
&
url
,
int
zoom
)
{
HelpViewer
*
viewer
=
new
HelpViewer
(
helpEngine
,
this
);
viewer
->
installEventFilter
(
this
);
viewer
->
setZoom
(
zoom
);
viewer
->
setSource
(
url
);
viewer
->
setFocus
(
Qt
::
OtherFocusReason
);
#if defined(QT_NO_WEBKIT)
QFont
font
=
viewer
->
font
();
font
.
setPointSize
(
font
.
pointSize
()
+
int
(
zoom
));
viewer
->
setFont
(
font
);
#endif
tabWidget
->
setCurrentIndex
(
tabWidget
->
addTab
(
viewer
,
quoteTabTitle
(
viewer
->
documentTitle
())));
...
...
src/plugins/help/centralwidget.h
View file @
bfc04b98
...
...
@@ -90,7 +90,7 @@ public slots:
void
pageSetup
();
void
printPreview
();
void
setSource
(
const
QUrl
&
url
);
void
setSourceInNewTab
(
const
QUrl
&
url
);
void
setSourceInNewTab
(
const
QUrl
&
url
,
int
zoom
=
0
);
HelpViewer
*
newEmptyTab
();
void
home
();
void
forward
();
...
...
src/plugins/help/helpplugin.cpp
View file @
bfc04b98
...
...
@@ -404,6 +404,13 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
cmd
->
setDefaultKeySequence
(
QKeySequence
(
tr
(
"Ctrl+-"
)));
connect
(
a
,
SIGNAL
(
triggered
()),
m_centralWidget
,
SLOT
(
zoomOut
()));
advancedMenu
->
addAction
(
cmd
,
Core
::
Constants
::
G_EDIT_FONT
);
a
=
new
QAction
(
tr
(
"Reset Font Size"
),
this
);
cmd
=
am
->
registerAction
(
a
,
QLatin1String
(
"Help.ResetFontSize"
),
modecontext
);
cmd
->
setDefaultKeySequence
(
QKeySequence
(
tr
(
"Ctrl+0"
)));
connect
(
a
,
SIGNAL
(
triggered
()),
m_centralWidget
,
SLOT
(
resetZoom
()));
advancedMenu
->
addAction
(
cmd
,
Core
::
Constants
::
G_EDIT_FONT
);
}
return
true
;
...
...
src/shared/help/helpviewer.cpp
View file @
bfc04b98
...
...
@@ -277,14 +277,20 @@ void HelpViewer::resetZoom()
setTextSizeMultiplier
(
1.0
);
}
void
HelpViewer
::
zoomIn
(
qreal
range
)
void
HelpViewer
::
zoomIn
(
int
range
)
{
setTextSizeMultiplier
(
qMin
(
2.0
,
textSizeMultiplier
()
+
range
/
10.0
));
}
void
HelpViewer
::
zoomOut
(
int
range
)
{
setTextSizeMultiplier
(
textSizeMultiplier
()
+
range
/
10.0
);
setTextSizeMultiplier
(
qMax
(
0.5
,
textSizeMultiplier
()
-
range
/
10.0
)
)
;
}
void
HelpViewer
::
zoom
Out
(
qreal
range
)
int
HelpViewer
::
zoom
()
const
{
setTextSizeMultiplier
(
qMax
(
0.0
,
textSizeMultiplier
()
-
range
/
10.0
));
qreal
zoom
=
textSizeMultiplier
()
*
10.0
;
return
(
zoom
<
10.0
?
zoom
*
-
1.0
:
zoom
-
10.0
);
}
void
HelpViewer
::
home
()
...
...
src/shared/help/helpviewer.h
View file @
bfc04b98
...
...
@@ -76,9 +76,12 @@ public:
inline
bool
hasSelection
()
const
{
return
!
selectedText
().
isEmpty
();
}
// ### this is suboptimal
void
zoomIn
(
int
range
=
1
);
void
zoomOut
(
int
range
=
1
);
void
resetZoom
();
void
zoom
In
(
qreal
range
=
1
)
;
void
zoomOut
(
qreal
range
=
1
);
int
zoom
()
const
;
void
setZoom
(
int
zoom
)
{
zoomIn
(
zoom
);
}
inline
void
copy
()
{
return
triggerPageAction
(
QWebPage
::
Copy
);
}
...
...
@@ -124,9 +127,10 @@ public:
HelpViewer
(
QHelpEngine
*
helpEngine
,
Help
::
Internal
::
CentralWidget
*
parent
);
void
setSource
(
const
QUrl
&
url
);
void
resetZoom
();
void
zoomIn
(
int
range
=
1
);
void
zoomOut
(
int
range
=
1
);
void
resetZoom
();
int
zoom
()
const
{
return
zoomCount
;
}
void
setZoom
(
int
zoom
)
{
zoomCount
=
zoom
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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