diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index cca8df87..f31120a4 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -297,6 +297,7 @@ void RclMain::init() this, SLOT(onSetDescription(QString))); connect(sSearch, SIGNAL(clearSearch()), this, SLOT(resetSearch())); + connect(this, SIGNAL(uiPrefsChanged()), sSearch, SLOT(setPrefs())); connect(preferencesMenu, SIGNAL(triggered(QAction*)), this, SLOT(setStemLang(QAction*))); connect(preferencesMenu, SIGNAL(aboutToShow()), @@ -373,6 +374,7 @@ void RclMain::init() restable, SLOT(readDocSource())); connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)), restable, SLOT(onSortDataChanged(DocSeqSortSpec))); + connect(this, SIGNAL(uiPrefsChanged()), restable, SLOT(onUiPrefsChanged())); connect(restable->getModel(), SIGNAL(sortDataChanged(DocSeqSortSpec)), this, SLOT(onSortDataChanged(DocSeqSortSpec))); @@ -399,7 +401,8 @@ void RclMain::init() reslist, SLOT(resetList())); connect(this, SIGNAL(resultsReady()), reslist, SLOT(readDocSource())); - + connect(this, SIGNAL(uiPrefsChanged()), reslist, SLOT(onUiPrefsChanged())); + connect(reslist, SIGNAL(hasResults(int)), this, SLOT(resultCount(int))); connect(reslist, SIGNAL(wordSelect(QString)), @@ -1091,8 +1094,7 @@ void RclMain::setUIPrefs() if (!uiprefs) return; LOGDEB("Recollmain::setUIPrefs\n"); - reslist->setFont(); - sSearch->setPrefs(); + emit uiPrefsChanged(); enbSynAction->setDisabled(prefs.synFile.isEmpty()); enbSynAction->setChecked(prefs.synFileEnable); } diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index df9235cc..9b07687c 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -168,6 +168,7 @@ signals: void sortDataChanged(DocSeqSortSpec); void resultsReady(); void searchReset(); + void uiPrefsChanged(); protected: virtual void closeEvent(QCloseEvent *); diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index d46a6b97..2e87db50 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -453,6 +453,11 @@ void ResList::runJS(const QString& js) #endif } +void ResList::onUiPrefsChanged() +{ + setFont(); +} + void ResList::setFont() { #if defined(USING_WEBKIT) || defined(USING_WEBENGINE) diff --git a/src/qtgui/reslist.h b/src/qtgui/reslist.h index be9542cb..5c02c88f 100644 --- a/src/qtgui/reslist.h +++ b/src/qtgui/reslist.h @@ -93,7 +93,8 @@ public slots: virtual void highlighted(const QString& link); virtual void createPopupMenu(const QPoint& pos); virtual void showQueryDetails(); - + virtual void onUiPrefsChanged(); + signals: void nextPageAvailable(bool); void prevPageAvailable(bool); diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index e8389344..6e909e62 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -63,6 +63,10 @@ static const QKeySequence closeKeySeq("Ctrl+w"); static const int ROWHEIGHTPAD = 2; static const int TEXTINCELLVTRANS = -4; +// Adjust font size from prefs, display is slightly different here +static const int fsadjustdetail = 1; +static const int fsadjusttable = 1; + static PlainToRichQtReslist g_hiliter; ////////////////////////////////////////////////////////////////////////// @@ -144,6 +148,21 @@ void ResTableDetailArea::createPopupMenu(const QPoint& pos) } } +void ResTableDetailArea::setFont() +{ + if (prefs.reslistfontsize) { + // fs shows slightly bigger in qtextbrowser? adjust. + int fs = prefs.reslistfontsize; + if (prefs.reslistfontsize > fsadjustdetail) { + fs -= fsadjustdetail; + } + QFont nfont(prefs.reslistfontfamily, fs); + QTextBrowser::setFont(nfont); + } else { + QTextBrowser::setFont(QFont()); + } +} + ////////////////////////////////////////////////////////////////////////////// //// Data model methods //// @@ -356,6 +375,18 @@ QVariant RecollModel::data(const QModelIndex& index, int role) const { LOGDEB2("RecollModel::data: row " << index.row() << " col " << index.column() << " role " << role << "\n"); + + // The font is actually set in the custom delegate, but we need + // this to adjust the row height (there is probably a better way + // to do it in the delegate?) + if (role == Qt::FontRole && prefs.reslistfontsize > 0) { + QFont font = m_table->font(); + int fs = prefs.reslistfontsize <= fsadjusttable ? prefs.reslistfontsize: + prefs.reslistfontsize - fsadjusttable; + font.setPointSize(fs); + return font; + } + if (!m_source || role != Qt::DisplayRole || !index.isValid() || index.column() >= int(m_fields.size())) { return QVariant(); @@ -460,44 +491,56 @@ public: // and a way to pass an indicator from data(), a bit more // difficult. Anyway, the display seems fast enough as is. void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const - { - QStyleOptionViewItem opt = option; - initStyleOption(&opt, index); - QVariant value = index.data(Qt::DisplayRole); - if (value.isValid() && !value.isNull()) { - QString text = value.toString(); - if (!text.isEmpty()) { - QTextDocument document; - painter->save(); - if (opt.state & QStyle::State_Selected) { - painter->fillRect(opt.rect, opt.palette.highlight()); - // Set the foreground color. The pen approach does - // not seem to work, probably it's reset by the - // textdocument. Couldn't use - // setdefaultstylesheet() either. the div thing is - // an ugly hack. Works for now -#if 0 - QPen pen = painter->pen(); - pen.setBrush(opt.palette.brush(QPalette::HighlightedText)); - painter->setPen(pen); -#else - text = QString::fromUtf8("