GUI: support Ctrl+Plus/Ctrl+Minus to increase or decrease the font size (results and preview)
This commit is contained in:
parent
d54ee6040a
commit
fbec7a6adb
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
RclDynConf *g_dynconf;
|
RclDynConf *g_dynconf;
|
||||||
AdvSearchHist *g_advshistory;
|
AdvSearchHist *g_advshistory;
|
||||||
@ -200,7 +201,7 @@ void rwSettings(bool writing)
|
|||||||
SETTING_RW(prefs.reslistfontfamily, "/Recoll/prefs/reslist/fontFamily",
|
SETTING_RW(prefs.reslistfontfamily, "/Recoll/prefs/reslist/fontFamily",
|
||||||
String, "");
|
String, "");
|
||||||
SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Int,
|
SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Int,
|
||||||
10);
|
QFont().pointSize());
|
||||||
|
|
||||||
QString rlfDflt = QString::fromUtf8(prefs.dfltResListFormat);
|
QString rlfDflt = QString::fromUtf8(prefs.dfltResListFormat);
|
||||||
if (writing) {
|
if (writing) {
|
||||||
|
|||||||
@ -49,12 +49,12 @@ public:
|
|||||||
int historysize{0};
|
int historysize{0};
|
||||||
int maxhltextkbs;
|
int maxhltextkbs;
|
||||||
QString reslistfontfamily;
|
QString reslistfontfamily;
|
||||||
|
int reslistfontsize;
|
||||||
// Not saved in prefs for now. Computed from qt defaults and used to
|
// Not saved in prefs for now. Computed from qt defaults and used to
|
||||||
// set main character color for webkit/textbrowser reslist and
|
// set main character color for webkit/textbrowser reslist and
|
||||||
// snippets window.
|
// snippets window.
|
||||||
QString fontcolor;
|
QString fontcolor;
|
||||||
QString qtermstyle; // CSS style for query terms in reslist and other places
|
QString qtermstyle; // CSS style for query terms in reslist and other places
|
||||||
int reslistfontsize;
|
|
||||||
// Result list format string
|
// Result list format string
|
||||||
QString reslistformat;
|
QString reslistformat;
|
||||||
string creslistformat;
|
string creslistformat;
|
||||||
|
|||||||
@ -123,11 +123,20 @@ void Preview::init()
|
|||||||
resize(QSize(640, 480).expandedTo(minimumSizeHint()));
|
resize(QSize(640, 480).expandedTo(minimumSizeHint()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prefs.reslistfontfamily != "") {
|
||||||
|
m_font = QFont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||||
|
} else {
|
||||||
|
m_font = QFont();
|
||||||
|
m_font.setPointSize(prefs.reslistfontsize);
|
||||||
|
}
|
||||||
|
|
||||||
(void)new HelpClient(this);
|
(void)new HelpClient(this);
|
||||||
HelpClient::installMap((const char *)objectName().toUtf8(),
|
HelpClient::installMap((const char *)objectName().toUtf8(),
|
||||||
"RCL.SEARCH.GUI.PREVIEW");
|
"RCL.SEARCH.GUI.PREVIEW");
|
||||||
|
|
||||||
// signals and slots connections
|
// signals and slots connections
|
||||||
|
connect(new QShortcut(QKeySequence::ZoomIn,this), SIGNAL (activated()), this, SLOT (zoomIn()));
|
||||||
|
connect(new QShortcut(QKeySequence::ZoomOut,this),SIGNAL (activated()), this, SLOT (zoomOut()));
|
||||||
connect(searchTextCMB, SIGNAL(editTextChanged(const QString&)),
|
connect(searchTextCMB, SIGNAL(editTextChanged(const QString&)),
|
||||||
this, SLOT(searchTextChanged(const QString&)));
|
this, SLOT(searchTextChanged(const QString&)));
|
||||||
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
|
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
|
||||||
@ -168,6 +177,24 @@ void Preview::onNewShortcuts()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Preview::zoomIn()
|
||||||
|
{
|
||||||
|
m_font.setPointSize(m_font.pointSize()+1);
|
||||||
|
PreviewTextEdit *edit = currentEditor();
|
||||||
|
if (edit) {
|
||||||
|
edit->displayText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Preview::zoomOut()
|
||||||
|
{
|
||||||
|
m_font.setPointSize(m_font.pointSize()-1);
|
||||||
|
PreviewTextEdit *edit = currentEditor();
|
||||||
|
if (edit) {
|
||||||
|
edit->displayText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Preview::listShortcuts()
|
void Preview::listShortcuts()
|
||||||
{
|
{
|
||||||
LISTSHORTCUT(null, "preview:151", tr("Preview Window"),
|
LISTSHORTCUT(null, "preview:151", tr("Preview Window"),
|
||||||
@ -806,6 +833,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
editor->setFont(m_font);
|
||||||
editor->setHtml("");
|
editor->setHtml("");
|
||||||
editor->m_format = Qt::RichText;
|
editor->m_format = Qt::RichText;
|
||||||
bool inputishtml = !lthr.fdoc.mimetype.compare("text/html");
|
bool inputishtml = !lthr.fdoc.mimetype.compare("text/html");
|
||||||
@ -1048,10 +1076,27 @@ void PreviewTextEdit::createPopupMenu(const QPoint& pos)
|
|||||||
void PreviewTextEdit::displayText()
|
void PreviewTextEdit::displayText()
|
||||||
{
|
{
|
||||||
LOGDEB1("PreviewTextEdit::displayText()\n");
|
LOGDEB1("PreviewTextEdit::displayText()\n");
|
||||||
|
// Ensuring that the view does not move when changing the font
|
||||||
|
// size and redisplaying the text: can't find a good way to do
|
||||||
|
// it. The only imperfect way I found was to get the position for
|
||||||
|
// the last line (approximately), and make the position visible
|
||||||
|
// after the change.
|
||||||
|
auto c = cursorForPosition(QPoint(0,height()-20));
|
||||||
|
int pos = c.position();
|
||||||
|
// static int lastpos;
|
||||||
|
// std::cerr << "POSITION: " << pos << " DELTA " << pos -lastpos << "\n";
|
||||||
|
// lastpos = pos;
|
||||||
|
setFont(m_preview->m_font);
|
||||||
if (m_format == Qt::PlainText)
|
if (m_format == Qt::PlainText)
|
||||||
setPlainText(m_richtxt);
|
setPlainText(m_richtxt);
|
||||||
else
|
else
|
||||||
setHtml(m_richtxt);
|
setHtml(m_richtxt);
|
||||||
|
if (m_curdsp == PTE_DSPTXT) {
|
||||||
|
auto cursor = textCursor();
|
||||||
|
cursor.setPosition(pos);
|
||||||
|
setTextCursor(cursor);
|
||||||
|
ensureCursorVisible();
|
||||||
|
}
|
||||||
m_curdsp = PTE_DSPTXT;
|
m_curdsp = PTE_DSPTXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1060,6 +1105,7 @@ void PreviewTextEdit::displayFields()
|
|||||||
{
|
{
|
||||||
LOGDEB1("PreviewTextEdit::displayFields()\n");
|
LOGDEB1("PreviewTextEdit::displayFields()\n");
|
||||||
|
|
||||||
|
setFont(m_preview->m_font);
|
||||||
QString txt = "<html><head></head><body>\n";
|
QString txt = "<html><head></head><body>\n";
|
||||||
txt += "<b>" + path2qs(m_url);
|
txt += "<b>" + path2qs(m_url);
|
||||||
if (!m_ipath.empty())
|
if (!m_ipath.empty())
|
||||||
@ -1080,6 +1126,7 @@ void PreviewTextEdit::displayFields()
|
|||||||
void PreviewTextEdit::displayImage()
|
void PreviewTextEdit::displayImage()
|
||||||
{
|
{
|
||||||
LOGDEB1("PreviewTextEdit::displayImage()\n");
|
LOGDEB1("PreviewTextEdit::displayImage()\n");
|
||||||
|
setFont(m_preview->m_font);
|
||||||
if (m_image.isNull())
|
if (m_image.isNull())
|
||||||
displayText();
|
displayText();
|
||||||
|
|
||||||
|
|||||||
@ -29,8 +29,9 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <qvariant.h>
|
#include <QVariant>
|
||||||
#include <qwidget.h>
|
#include <QWidget>
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
#ifdef PREVIEW_TEXTBROWSER
|
#ifdef PREVIEW_TEXTBROWSER
|
||||||
#include <QTextBrowser>
|
#include <QTextBrowser>
|
||||||
@ -164,6 +165,9 @@ public slots:
|
|||||||
virtual void emitEditRequested();
|
virtual void emitEditRequested();
|
||||||
virtual void togglePlainPre();
|
virtual void togglePlainPre();
|
||||||
virtual void onNewShortcuts();
|
virtual void onNewShortcuts();
|
||||||
|
// Other
|
||||||
|
virtual void zoomIn();
|
||||||
|
virtual void zoomOut();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void previewClosed(Preview *);
|
void previewClosed(Preview *);
|
||||||
@ -190,6 +194,7 @@ private:
|
|||||||
bool m_loading{false};
|
bool m_loading{false};
|
||||||
HighlightData m_hData;
|
HighlightData m_hData;
|
||||||
bool m_justCreated{true}; // First tab create is different
|
bool m_justCreated{true}; // First tab create is different
|
||||||
|
QFont m_font;
|
||||||
QShortcut *m_closewinsc{nullptr};
|
QShortcut *m_closewinsc{nullptr};
|
||||||
QShortcut *m_nextdocsc{nullptr};
|
QShortcut *m_nextdocsc{nullptr};
|
||||||
QShortcut *m_prevdocsc{nullptr};
|
QShortcut *m_prevdocsc{nullptr};
|
||||||
|
|||||||
@ -288,6 +288,8 @@ void RclMain::init()
|
|||||||
connect(this, SIGNAL(resultsReady()),
|
connect(this, SIGNAL(resultsReady()),
|
||||||
reslist, SLOT(readDocSource()));
|
reslist, SLOT(readDocSource()));
|
||||||
connect(this, SIGNAL(uiPrefsChanged()), reslist, SLOT(onUiPrefsChanged()));
|
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)),
|
connect(reslist, SIGNAL(hasResults(int)),
|
||||||
this, SLOT(resultCount(int)));
|
this, SLOT(resultCount(int)));
|
||||||
@ -337,6 +339,17 @@ void RclMain::init()
|
|||||||
periodictimer->start(1000);
|
periodictimer->start(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RclMain::zoomIn()
|
||||||
|
{
|
||||||
|
prefs.reslistfontsize++;
|
||||||
|
emit uiPrefsChanged();
|
||||||
|
}
|
||||||
|
void RclMain::zoomOut()
|
||||||
|
{
|
||||||
|
prefs.reslistfontsize--;
|
||||||
|
emit uiPrefsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void RclMain::onNewShortcuts()
|
void RclMain::onNewShortcuts()
|
||||||
{
|
{
|
||||||
SCBase& scb = SCBase::scBase();
|
SCBase& scb = SCBase::scBase();
|
||||||
|
|||||||
@ -168,6 +168,8 @@ public slots:
|
|||||||
virtual void onNewShortcuts();
|
virtual void onNewShortcuts();
|
||||||
virtual void toggleTable();
|
virtual void toggleTable();
|
||||||
virtual void hideToolTip();
|
virtual void hideToolTip();
|
||||||
|
virtual void zoomIn();
|
||||||
|
virtual void zoomOut();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
virtual void updateIdxStatus();
|
virtual void updateIdxStatus();
|
||||||
|
|||||||
@ -439,7 +439,7 @@ void ResList::setFont()
|
|||||||
{
|
{
|
||||||
#if defined(USING_WEBKIT) || defined(USING_WEBENGINE)
|
#if defined(USING_WEBKIT) || defined(USING_WEBENGINE)
|
||||||
# ifndef SETFONT_WITH_HEADSTYLE
|
# ifndef SETFONT_WITH_HEADSTYLE
|
||||||
if (prefs.reslistfontfamily.length()) {
|
if (prefs.reslistfontfamily != "") {
|
||||||
// For some reason there is (12-2014) an offset of 3 between what
|
// For some reason there is (12-2014) an offset of 3 between what
|
||||||
// we request from webkit and what we get.
|
// we request from webkit and what we get.
|
||||||
settings()->setFontSize(QWEBSETTINGS::DefaultFontSize,
|
settings()->setFontSize(QWEBSETTINGS::DefaultFontSize,
|
||||||
@ -447,16 +447,18 @@ void ResList::setFont()
|
|||||||
settings()->setFontFamily(QWEBSETTINGS::StandardFont,
|
settings()->setFontFamily(QWEBSETTINGS::StandardFont,
|
||||||
prefs.reslistfontfamily);
|
prefs.reslistfontfamily);
|
||||||
} else {
|
} else {
|
||||||
settings()->resetFontSize(QWEBSETTINGS::DefaultFontSize);
|
settings()->setFontSize(QWEBSETTINGS::DefaultFontSize, prefs.reslistfontsize + 3);
|
||||||
settings()->resetFontFamily(QWEBSETTINGS::StandardFont);
|
settings()->resetFontFamily(QWEBSETTINGS::StandardFont);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
if (prefs.reslistfontfamily.length()) {
|
if (prefs.reslistfontfamily != "") {
|
||||||
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||||
QTextBrowser::setFont(nfont);
|
QTextBrowser::setFont(nfont);
|
||||||
} else {
|
} else {
|
||||||
QTextBrowser::setFont(QFont());
|
QFont font;
|
||||||
|
font.setPointSize(prefs.reslistfontsize);
|
||||||
|
QTextBrowser::setFont(font);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,16 +156,18 @@ void ResTableDetailArea::createPopupMenu(const QPoint& pos)
|
|||||||
|
|
||||||
void ResTableDetailArea::setFont()
|
void ResTableDetailArea::setFont()
|
||||||
{
|
{
|
||||||
if (prefs.reslistfontsize) {
|
int fs = prefs.reslistfontsize;
|
||||||
// fs shows slightly bigger in qtextbrowser? adjust.
|
// fs shows slightly bigger in qtextbrowser? adjust.
|
||||||
int fs = prefs.reslistfontsize;
|
if (prefs.reslistfontsize > fsadjustdetail) {
|
||||||
if (prefs.reslistfontsize > fsadjustdetail) {
|
fs -= fsadjustdetail;
|
||||||
fs -= fsadjustdetail;
|
}
|
||||||
}
|
if (prefs.reslistfontfamily != "") {
|
||||||
QFont nfont(prefs.reslistfontfamily, fs);
|
QFont nfont(prefs.reslistfontfamily, fs);
|
||||||
QTextBrowser::setFont(nfont);
|
QTextBrowser::setFont(nfont);
|
||||||
} else {
|
} else {
|
||||||
QTextBrowser::setFont(QFont());
|
QFont font;
|
||||||
|
font.setPointSize(fs);
|
||||||
|
QTextBrowser::setFont(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,8 +809,12 @@ void ResTable::toggleVHeader()
|
|||||||
void ResTable::onUiPrefsChanged()
|
void ResTable::onUiPrefsChanged()
|
||||||
{
|
{
|
||||||
if (m_detail) {
|
if (m_detail) {
|
||||||
m_detail->init();
|
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)));
|
||||||
if (prefs.noResTableHeader) {
|
if (prefs.noResTableHeader) {
|
||||||
tableView->horizontalHeader()->hide();
|
tableView->horizontalHeader()->hide();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -142,7 +142,7 @@ void SnippetsW::init()
|
|||||||
browser->setUndoRedoEnabled(false);
|
browser->setUndoRedoEnabled(false);
|
||||||
browser->setOpenLinks(false);
|
browser->setOpenLinks(false);
|
||||||
browser->setTabChangesFocus(true);
|
browser->setTabChangesFocus(true);
|
||||||
if (prefs.reslistfontfamily.length()) {
|
if (prefs.reslistfontfamily != "") {
|
||||||
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||||
browser->setFont(nfont);
|
browser->setFont(nfont);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -627,7 +627,7 @@ void UIPrefsDialog::showSynFileDialog()
|
|||||||
void UIPrefsDialog::resetReslistFont()
|
void UIPrefsDialog::resetReslistFont()
|
||||||
{
|
{
|
||||||
reslistFontFamily = "";
|
reslistFontFamily = "";
|
||||||
reslistFontSize = 0;
|
reslistFontSize = QFont().pointSize();
|
||||||
setupReslistFontPB();
|
setupReslistFontPB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user