GUI: try to improve font size consistency.
- Use px everywhere. - Get rid of confusing never used compile time option. - Fix reslist not reacting to zoomIn/zoomOut - Other small adjustements.
This commit is contained in:
parent
96ebb369a5
commit
7ceb9c6837
@ -427,7 +427,7 @@ void rwSettings(bool writing)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_REGEX
|
#ifdef USE_REGEX
|
||||||
/* font-size: 10pt; */
|
/* font-size: 10px; */
|
||||||
static const std::string fntsz_exp(
|
static const std::string fntsz_exp(
|
||||||
R"((\s*font-size\s*:\s*)([0-9]+)(p[tx]\s*;\s*))"
|
R"((\s*font-size\s*:\s*)([0-9]+)(p[tx]\s*;\s*))"
|
||||||
);
|
);
|
||||||
@ -463,24 +463,6 @@ std::string PrefsPack::scaleFonts(const std::string& style, float multiplier)
|
|||||||
return nstyle;
|
return nstyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PrefsPack::fontsize()
|
|
||||||
{
|
|
||||||
// While building the kio, we don't really care about QT Gui
|
|
||||||
// defaults and referencing QFont introduces a useless dependency
|
|
||||||
#ifdef BUILDING_RECOLLGUI
|
|
||||||
int fs;
|
|
||||||
if (prefs.reslistfontsize > 0) {
|
|
||||||
fs = prefs.reslistfontsize;
|
|
||||||
} else {
|
|
||||||
fs = QWidget().font().pixelSize();
|
|
||||||
}
|
|
||||||
fs = round(fs * prefs.wholeuiscale);
|
|
||||||
return fs;
|
|
||||||
#else
|
|
||||||
return 12;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string PrefsPack::htmlHeaderContents()
|
std::string PrefsPack::htmlHeaderContents()
|
||||||
{
|
{
|
||||||
auto comfn = path_cat(path_cat(theconfig->getDatadir(), "examples"), "recoll-common.css");
|
auto comfn = path_cat(path_cat(theconfig->getDatadir(), "examples"), "recoll-common.css");
|
||||||
@ -489,13 +471,10 @@ std::string PrefsPack::htmlHeaderContents()
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << comcss << "\n";
|
oss << comcss << "\n";
|
||||||
oss << "<style type=\"text/css\">\nhtml,body,form, fieldset,table,tr,td,img,select,input {\n";
|
oss << "<style type=\"text/css\">\nhtml,body,form, fieldset,table,tr,td,img,select,input {\n";
|
||||||
#ifdef SETFONT_WITH_HEADSTYLE
|
|
||||||
if (!prefs.reslistfontfamily.isEmpty()) {
|
if (!prefs.reslistfontfamily.isEmpty()) {
|
||||||
oss << "font-family: \"" << qs2utf8s(prefs.reslistfontfamily) << "\";\n";
|
oss << "font-family: \"" << qs2utf8s(prefs.reslistfontfamily) << "\";\n";
|
||||||
}
|
}
|
||||||
oss << "font-size: " << round(prefs.reslistfontsize * 1.2) << "px;\n";
|
oss << "font-size: " << round(prefs.reslistfontsize * 1.1) << "px;\n";
|
||||||
#endif
|
|
||||||
oss << "color: " << qs2utf8s(prefs.fontcolor) << ";\n";
|
|
||||||
oss << "}\n</style>\n";
|
oss << "}\n</style>\n";
|
||||||
oss << qs2utf8s(prefs.darkreslistheadertext) << qs2utf8s(prefs.reslistheadertext);
|
oss << qs2utf8s(prefs.darkreslistheadertext) << qs2utf8s(prefs.reslistheadertext);
|
||||||
|
|
||||||
|
|||||||
@ -51,10 +51,6 @@ public:
|
|||||||
int maxhltextkbs;
|
int maxhltextkbs;
|
||||||
QString reslistfontfamily;
|
QString reslistfontfamily;
|
||||||
int reslistfontsize;
|
int reslistfontsize;
|
||||||
// Not saved in prefs for now. Computed from qt defaults and used to
|
|
||||||
// set main character color for webkit/textbrowser reslist and
|
|
||||||
// snippets window.
|
|
||||||
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
|
||||||
// Result list format string
|
// Result list format string
|
||||||
QString reslistformat;
|
QString reslistformat;
|
||||||
@ -190,7 +186,6 @@ public:
|
|||||||
// Scale font-sizes inside css or qss input and return changed sheet. The font-size statements
|
// Scale font-sizes inside css or qss input and return changed sheet. The font-size statements
|
||||||
// need to be on their own line.
|
// need to be on their own line.
|
||||||
static std::string scaleFonts(const std::string& style, float multiplier);
|
static std::string scaleFonts(const std::string& style, float multiplier);
|
||||||
int fontsize();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Global preferences record */
|
/** Global preferences record */
|
||||||
|
|||||||
@ -318,7 +318,9 @@ void RclMain::zoomIn()
|
|||||||
}
|
}
|
||||||
void RclMain::zoomOut()
|
void RclMain::zoomOut()
|
||||||
{
|
{
|
||||||
prefs.reslistfontsize--;
|
if (prefs.reslistfontsize > 1) {
|
||||||
|
prefs.reslistfontsize--;
|
||||||
|
}
|
||||||
emit uiPrefsChanged();
|
emit uiPrefsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,11 +5,6 @@ VPATH = @srcdir@
|
|||||||
DEFINES += BUILDING_RECOLL
|
DEFINES += BUILDING_RECOLL
|
||||||
DEFINES += BUILDING_RECOLLGUI
|
DEFINES += BUILDING_RECOLLGUI
|
||||||
|
|
||||||
# Decide if we set font family and style with a css section in the html <head> or with qwebsettings
|
|
||||||
# setfont... calls. We used to do it with websettings because it gave a faster redisplay, and the
|
|
||||||
# css has a tendancy to not find some system fonts. We currently do it with css anyway.
|
|
||||||
DEFINES += SETFONT_WITH_HEADSTYLE=1
|
|
||||||
|
|
||||||
@QMAKE_ENABLE_WEBKIT@ QT += webkit
|
@QMAKE_ENABLE_WEBKIT@ QT += webkit
|
||||||
@QMAKE_ENABLE_WEBKIT@ DEFINES += USING_WEBKIT
|
@QMAKE_ENABLE_WEBKIT@ DEFINES += USING_WEBKIT
|
||||||
|
|
||||||
|
|||||||
@ -409,23 +409,13 @@ void ResList::runJS(const QString& js)
|
|||||||
void ResList::onUiPrefsChanged()
|
void ResList::onUiPrefsChanged()
|
||||||
{
|
{
|
||||||
setFont();
|
setFont();
|
||||||
|
displayPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResList::setFont()
|
void ResList::setFont()
|
||||||
{
|
{
|
||||||
#if defined(USING_WEBKIT) || defined(USING_WEBENGINE)
|
#if !defined(USING_WEBKIT) && !defined(USING_WEBENGINE)
|
||||||
#ifndef SETFONT_WITH_HEADSTYLE
|
// Using QTextBrowser
|
||||||
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);
|
|
||||||
} else {
|
|
||||||
settings()->setFontSize(QWEBSETTINGS::DefaultFontSize, prefs.reslistfontsize + 3);
|
|
||||||
settings()->resetFontFamily(QWEBSETTINGS::StandardFont);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
if (prefs.reslistfontfamily != "") {
|
if (prefs.reslistfontfamily != "") {
|
||||||
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||||
QTextBrowser::setFont(nfont);
|
QTextBrowser::setFont(nfont);
|
||||||
|
|||||||
@ -67,8 +67,8 @@ static const QKeySequence closeKeySeq("Ctrl+w");
|
|||||||
static const int ROWHEIGHTPAD = 2;
|
static const int ROWHEIGHTPAD = 2;
|
||||||
static const int TEXTINCELLVTRANS = -4;
|
static const int TEXTINCELLVTRANS = -4;
|
||||||
|
|
||||||
// Adjust font size from prefs, display is slightly different here
|
// Adjust font size from prefs, display is slightly different in the table??
|
||||||
static const int fsadjustdetail = 1;
|
static const int fsadjustdetail = -1;
|
||||||
|
|
||||||
static PlainToRichQtReslist g_hiliter;
|
static PlainToRichQtReslist g_hiliter;
|
||||||
|
|
||||||
@ -92,9 +92,7 @@ public:
|
|||||||
virtual string absSep() override {
|
virtual string absSep() override {
|
||||||
return (const char *)(prefs.abssep.toUtf8());}
|
return (const char *)(prefs.abssep.toUtf8());}
|
||||||
virtual string headerContent() override {
|
virtual string headerContent() override {
|
||||||
// Note: the detail area is a qtextbrowser which gets confused by the general Html
|
return prefs.htmlHeaderContents();
|
||||||
// header. So we manage it differently from the snippets or main result list.
|
|
||||||
return qs2utf8s(prefs.darkreslistheadertext) + qs2utf8s(prefs.reslistheadertext);
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
ResTable *m_parent;
|
ResTable *m_parent;
|
||||||
@ -156,13 +154,13 @@ void ResTableDetailArea::createPopupMenu(const QPoint& pos)
|
|||||||
|
|
||||||
void ResTableDetailArea::setFont()
|
void ResTableDetailArea::setFont()
|
||||||
{
|
{
|
||||||
int fs = prefs.fontsize() - fsadjustdetail;
|
int fs = m_table->fontsize();
|
||||||
if (prefs.reslistfontfamily != "") {
|
if (prefs.reslistfontfamily != "") {
|
||||||
QFont nfont(prefs.reslistfontfamily, fs);
|
QFont nfont(prefs.reslistfontfamily, fs);
|
||||||
QTextBrowser::setFont(nfont);
|
QTextBrowser::setFont(nfont);
|
||||||
} else {
|
} else {
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setPointSize(fs);
|
font.setPixelSize(fs);
|
||||||
QTextBrowser::setFont(font);
|
QTextBrowser::setFont(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,8 +388,8 @@ QVariant RecollModel::data(const QModelIndex& index, int role) const
|
|||||||
// this to adjust the row height (there is probably a better way
|
// this to adjust the row height (there is probably a better way
|
||||||
// to do it in the delegate?)
|
// to do it in the delegate?)
|
||||||
if (role == Qt::FontRole && (prefs.reslistfontsize > 0 || prefs.wholeuiscale != 1.0)) {
|
if (role == Qt::FontRole && (prefs.reslistfontsize > 0 || prefs.wholeuiscale != 1.0)) {
|
||||||
if (m_reslfntszforcached != prefs.fontsize() - fsadjustdetail) {
|
if (m_reslfntszforcached != m_table->fontsize() - fsadjustdetail) {
|
||||||
m_reslfntszforcached = prefs.fontsize() - fsadjustdetail;
|
m_reslfntszforcached = m_table->fontsize() - fsadjustdetail;
|
||||||
m_table->setDefRowHeight();
|
m_table->setDefRowHeight();
|
||||||
m_cachedfont = m_table->font();
|
m_cachedfont = m_table->font();
|
||||||
m_cachedfont.setPixelSize(m_reslfntszforcached);
|
m_cachedfont.setPixelSize(m_reslfntszforcached);
|
||||||
@ -533,13 +531,11 @@ public:
|
|||||||
QString color = opt.palette.color(QPalette::Base).name();
|
QString color = opt.palette.color(QPalette::Base).name();
|
||||||
QString textcolor = opt.palette.color(QPalette::Text).name();
|
QString textcolor = opt.palette.color(QPalette::Text).name();
|
||||||
QString selcolor = opt.palette.color(QPalette::Highlight).name();
|
QString selcolor = opt.palette.color(QPalette::Highlight).name();
|
||||||
QString seltextcolor =
|
QString seltextcolor = opt.palette.color(QPalette::HighlightedText).name();
|
||||||
opt.palette.color(QPalette::HighlightedText).name();
|
|
||||||
QString fstyle;
|
QString fstyle;
|
||||||
if (prefs.reslistfontsize > 0 || prefs.wholeuiscale != 1.0) {
|
QFont fnt = qvariant_cast<QFont>(index.data(Qt::FontRole));
|
||||||
int fs = prefs.fontsize() - fsadjustdetail;
|
int fs = fnt.pixelSize();
|
||||||
fstyle = QString("font-size: %1pt").arg(fs);
|
fstyle = QString("font-size: %1px").arg(fs) + ";";
|
||||||
}
|
|
||||||
QString ntxt("<div style='");
|
QString ntxt("<div style='");
|
||||||
ntxt += " color:";
|
ntxt += " color:";
|
||||||
ntxt += (opt.state & QStyle::State_Selected)? seltextcolor:textcolor;
|
ntxt += (opt.state & QStyle::State_Selected)? seltextcolor:textcolor;
|
||||||
@ -550,7 +546,6 @@ public:
|
|||||||
ntxt += fstyle;
|
ntxt += fstyle;
|
||||||
ntxt += QString("'>") + text + QString("</div>");
|
ntxt += QString("'>") + text + QString("</div>");
|
||||||
text.swap(ntxt);
|
text.swap(ntxt);
|
||||||
|
|
||||||
painter->setClipRect(opt.rect);
|
painter->setClipRect(opt.rect);
|
||||||
QPoint where = option.rect.topLeft();
|
QPoint where = option.rect.topLeft();
|
||||||
where.ry() += TEXTINCELLVTRANS;
|
where.ry() += TEXTINCELLVTRANS;
|
||||||
@ -562,6 +557,19 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int ResTable::fontsize()
|
||||||
|
{
|
||||||
|
int fs;
|
||||||
|
if (prefs.reslistfontsize > 0) {
|
||||||
|
fs = prefs.reslistfontsize;
|
||||||
|
} else {
|
||||||
|
fs = QWidget(this).font().pixelSize();
|
||||||
|
}
|
||||||
|
fs = round(fs * prefs.wholeuiscale);
|
||||||
|
return fs;
|
||||||
|
}
|
||||||
|
|
||||||
void ResTable::setDefRowHeight()
|
void ResTable::setDefRowHeight()
|
||||||
{
|
{
|
||||||
QHeaderView *header = tableView->verticalHeader();
|
QHeaderView *header = tableView->verticalHeader();
|
||||||
@ -574,9 +582,9 @@ void ResTable::setDefRowHeight()
|
|||||||
// header->setSectionResizeMode(QHeaderView::ResizeToContents);
|
// header->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
// Compute ourselves instead, for one row.
|
// Compute ourselves instead, for one row.
|
||||||
QFont font = tableView->font();
|
QFont font = tableView->font();
|
||||||
int fs = prefs.fontsize() - fsadjustdetail;
|
int fs = fontsize() - fsadjustdetail;
|
||||||
if (fs > 0)
|
if (fs > 0)
|
||||||
font.setPointSize(fs);
|
font.setPixelSize(fs);
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
header->setDefaultSectionSize(fm.height() + ROWHEIGHTPAD);
|
header->setDefaultSectionSize(fm.height() + ROWHEIGHTPAD);
|
||||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||||
|
|||||||
@ -139,9 +139,9 @@ class ResTable : public QWidget, public Ui::ResTable
|
|||||||
public:
|
public:
|
||||||
ResTable(QWidget* parent = 0, QStringList fields = QStringList())
|
ResTable(QWidget* parent = 0, QStringList fields = QStringList())
|
||||||
: QWidget(parent) {
|
: QWidget(parent) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
init(fields);
|
init(fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ResTable() {}
|
virtual ~ResTable() {}
|
||||||
ResTable(const ResTable&) = delete;
|
ResTable(const ResTable&) = delete;
|
||||||
@ -152,6 +152,7 @@ public:
|
|||||||
|
|
||||||
void setRclMain(RclMain *m, bool ismain);
|
void setRclMain(RclMain *m, bool ismain);
|
||||||
void setDefRowHeight();
|
void setDefRowHeight();
|
||||||
|
int fontsize();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void onTableView_currentChanged(const QModelIndex&);
|
virtual void onTableView_currentChanged(const QModelIndex&);
|
||||||
|
|||||||
@ -106,13 +106,6 @@ void SnippetsW::init()
|
|||||||
connect(browser, SIGNAL(linkClicked(const QUrl &)), this, SLOT(onLinkClicked(const QUrl &)));
|
connect(browser, SIGNAL(linkClicked(const QUrl &)), this, SLOT(onLinkClicked(const QUrl &)));
|
||||||
browser->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
browser->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
||||||
browser->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
|
browser->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
|
||||||
#ifndef SETFONT_WITH_HEADSTYLE
|
|
||||||
QWEBSETTINGS *ws = browser->page()->settings();
|
|
||||||
if (prefs.reslistfontfamily != "") {
|
|
||||||
ws->setFontFamily(QWEBSETTINGS::StandardFont, prefs.reslistfontfamily);
|
|
||||||
ws->setFontSize(QWEBSETTINGS::DefaultFontSize, prefs.reslistfontsize);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
browserw->setContextMenuPolicy(Qt::CustomContextMenu);
|
browserw->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(browserw, SIGNAL(customContextMenuRequested(const QPoint&)),
|
connect(browserw, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||||
this, SLOT(createPopupMenu(const QPoint&)));
|
this, SLOT(createPopupMenu(const QPoint&)));
|
||||||
@ -120,13 +113,6 @@ void SnippetsW::init()
|
|||||||
browserw = new QWebEngineView(this);
|
browserw = new QWebEngineView(this);
|
||||||
verticalLayout->insertWidget(0, browserw);
|
verticalLayout->insertWidget(0, browserw);
|
||||||
browser->setPage(new SnipWebPage(this));
|
browser->setPage(new SnipWebPage(this));
|
||||||
#ifndef SETFONT_WITH_HEADSTYLE
|
|
||||||
QWEBSETTINGS *ws = browser->page()->settings();
|
|
||||||
if (prefs.reslistfontfamily != "") {
|
|
||||||
ws->setFontFamily(QWEBSETTINGS::StandardFont, prefs.reslistfontfamily);
|
|
||||||
ws->setFontSize(QWEBSETTINGS::DefaultFontSize, prefs.reslistfontsize);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Stylesheet TBD
|
// Stylesheet TBD
|
||||||
browserw->setContextMenuPolicy(Qt::CustomContextMenu);
|
browserw->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(browserw, SIGNAL(customContextMenuRequested(const QPoint&)),
|
connect(browserw, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||||
|
|||||||
@ -53,5 +53,5 @@ Preview QTextEdit {
|
|||||||
background: white;
|
background: white;
|
||||||
color: black;
|
color: black;
|
||||||
font-family: Serif;
|
font-family: Serif;
|
||||||
font-size: 12pt;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user