Add View menu entries for adjusting font size. Make sure that the result table position does not change when changing font size

This commit is contained in:
Jean-Francois Dockes 2021-03-27 10:00:37 +01:00
parent 8da0bf28cc
commit ec389f89f5
5 changed files with 42 additions and 16 deletions

View File

@ -67,7 +67,9 @@ void RclMain::buildMenus()
viewMenu->addSeparator();
viewMenu->addAction(toggleFullScreenAction);
viewMenu->addAction(zoomInAction);
viewMenu->addAction(zoomOutAction);
toolsMenu->addAction(toolsDoc_HistoryAction);
toolsMenu->addAction(toolsAdvanced_SearchAction);
toolsMenu->addAction(toolsSpellAction);

View File

@ -65,7 +65,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>25</height>
<height>20</height>
</rect>
</property>
<addaction name="separator"/>
@ -346,6 +346,28 @@
<cstring>toggleFullScreenAction</cstring>
</property>
</action>
<action name="zoomInAction">
<property name="text">
<string>Increase results text font size</string>
</property>
<property name="iconText">
<string>Increase Font Size</string>
</property>
<property name="name" stdset="0">
<cstring>zoomInAction</cstring>
</property>
</action>
<action name="zoomOutAction">
<property name="text">
<string>Decrease results text font size</string>
</property>
<property name="iconText">
<string>Decrease Font Size</string>
</property>
<property name="name" stdset="0">
<cstring>zoomOutAction</cstring>
</property>
</action>
<action name="actionSortByDateAsc">
<property name="checkable">
<bool>true</bool>

View File

@ -240,8 +240,12 @@ void RclMain::init()
connect(enbSynAction, SIGNAL(toggled(bool)),
this, SLOT(setSynEnabled(bool)));
connect(toggleFullScreenAction, SIGNAL(triggered()),
this, SLOT(toggleFullScreen()));
connect(toggleFullScreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
zoomInAction->setShortcut(QKeySequence::ZoomIn);
connect(zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn()));
zoomOutAction->setShortcut(QKeySequence::ZoomOut);
connect(zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut()));
connect(actionShowQueryDetails, SIGNAL(triggered()),
reslist, SLOT(showQueryDetails()));
connect(periodictimer, SIGNAL(timeout()),
@ -288,8 +292,6 @@ void RclMain::init()
connect(this, SIGNAL(resultsReady()),
reslist, SLOT(readDocSource()));
connect(this, SIGNAL(uiPrefsChanged()), reslist, SLOT(onUiPrefsChanged()));
connect(new QShortcut(QKeySequence::ZoomIn,this), SIGNAL (activated()), this, SLOT (zoomIn()));
connect(new QShortcut(QKeySequence::ZoomOut,this),SIGNAL (activated()), this, SLOT (zoomOut()));
connect(reslist, SIGNAL(hasResults(int)),
this, SLOT(resultCount(int)));

View File

@ -438,19 +438,17 @@ void ResList::onUiPrefsChanged()
void ResList::setFont()
{
#if defined(USING_WEBKIT) || defined(USING_WEBENGINE)
# ifndef SETFONT_WITH_HEADSTYLE
#ifndef SETFONT_WITH_HEADSTYLE
if (prefs.reslistfontfamily != "") {
// For some reason there is (12-2014) an offset of 3 between what
// we request from webkit and what we get.
settings()->setFontSize(QWEBSETTINGS::DefaultFontSize,
prefs.reslistfontsize + 3);
settings()->setFontFamily(QWEBSETTINGS::StandardFont,
prefs.reslistfontfamily);
settings()->setFontSize(QWEBSETTINGS::DefaultFontSize, prefs.reslistfontsize + 3);
settings()->setFontFamily(QWEBSETTINGS::StandardFont, prefs.reslistfontfamily);
} else {
settings()->setFontSize(QWEBSETTINGS::DefaultFontSize, prefs.reslistfontsize + 3);
settings()->resetFontFamily(QWEBSETTINGS::StandardFont);
}
# endif
#endif
#else
if (prefs.reslistfontfamily != "") {
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);

View File

@ -811,10 +811,12 @@ void ResTable::onUiPrefsChanged()
if (m_detail) {
m_detail->setFont();
}
// Not sure that this is the right way, but something is needed to
// repaint with a possible new font. Toggling alternaterowcolors
// works too
tableView->update(tableView->indexAt(QPoint(0, 0)));
auto index = tableView->indexAt(QPoint(0, 0));
// There may be a better way to force repainting all visible rows
// with the possibly new font, but this works...
tableView->setAlternatingRowColors(false);
tableView->setAlternatingRowColors(true);
makeRowVisible(index.row());
if (prefs.noResTableHeader) {
tableView->horizontalHeader()->hide();
} else {