Adjust the restable font sizes based on the result list ones
This commit is contained in:
parent
0f6b5911d5
commit
450867c45b
@ -297,6 +297,7 @@ void RclMain::init()
|
|||||||
this, SLOT(onSetDescription(QString)));
|
this, SLOT(onSetDescription(QString)));
|
||||||
connect(sSearch, SIGNAL(clearSearch()),
|
connect(sSearch, SIGNAL(clearSearch()),
|
||||||
this, SLOT(resetSearch()));
|
this, SLOT(resetSearch()));
|
||||||
|
connect(this, SIGNAL(uiPrefsChanged()), sSearch, SLOT(setPrefs()));
|
||||||
connect(preferencesMenu, SIGNAL(triggered(QAction*)),
|
connect(preferencesMenu, SIGNAL(triggered(QAction*)),
|
||||||
this, SLOT(setStemLang(QAction*)));
|
this, SLOT(setStemLang(QAction*)));
|
||||||
connect(preferencesMenu, SIGNAL(aboutToShow()),
|
connect(preferencesMenu, SIGNAL(aboutToShow()),
|
||||||
@ -373,6 +374,7 @@ void RclMain::init()
|
|||||||
restable, SLOT(readDocSource()));
|
restable, SLOT(readDocSource()));
|
||||||
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||||
restable, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
restable, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
||||||
|
connect(this, SIGNAL(uiPrefsChanged()), restable, SLOT(onUiPrefsChanged()));
|
||||||
|
|
||||||
connect(restable->getModel(), SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
connect(restable->getModel(), SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||||
this, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
this, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
||||||
@ -399,7 +401,8 @@ void RclMain::init()
|
|||||||
reslist, SLOT(resetList()));
|
reslist, SLOT(resetList()));
|
||||||
connect(this, SIGNAL(resultsReady()),
|
connect(this, SIGNAL(resultsReady()),
|
||||||
reslist, SLOT(readDocSource()));
|
reslist, SLOT(readDocSource()));
|
||||||
|
connect(this, SIGNAL(uiPrefsChanged()), reslist, SLOT(onUiPrefsChanged()));
|
||||||
|
|
||||||
connect(reslist, SIGNAL(hasResults(int)),
|
connect(reslist, SIGNAL(hasResults(int)),
|
||||||
this, SLOT(resultCount(int)));
|
this, SLOT(resultCount(int)));
|
||||||
connect(reslist, SIGNAL(wordSelect(QString)),
|
connect(reslist, SIGNAL(wordSelect(QString)),
|
||||||
@ -1091,8 +1094,7 @@ void RclMain::setUIPrefs()
|
|||||||
if (!uiprefs)
|
if (!uiprefs)
|
||||||
return;
|
return;
|
||||||
LOGDEB("Recollmain::setUIPrefs\n");
|
LOGDEB("Recollmain::setUIPrefs\n");
|
||||||
reslist->setFont();
|
emit uiPrefsChanged();
|
||||||
sSearch->setPrefs();
|
|
||||||
enbSynAction->setDisabled(prefs.synFile.isEmpty());
|
enbSynAction->setDisabled(prefs.synFile.isEmpty());
|
||||||
enbSynAction->setChecked(prefs.synFileEnable);
|
enbSynAction->setChecked(prefs.synFileEnable);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -168,6 +168,7 @@ signals:
|
|||||||
void sortDataChanged(DocSeqSortSpec);
|
void sortDataChanged(DocSeqSortSpec);
|
||||||
void resultsReady();
|
void resultsReady();
|
||||||
void searchReset();
|
void searchReset();
|
||||||
|
void uiPrefsChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent(QCloseEvent *);
|
virtual void closeEvent(QCloseEvent *);
|
||||||
|
|||||||
@ -453,6 +453,11 @@ void ResList::runJS(const QString& js)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResList::onUiPrefsChanged()
|
||||||
|
{
|
||||||
|
setFont();
|
||||||
|
}
|
||||||
|
|
||||||
void ResList::setFont()
|
void ResList::setFont()
|
||||||
{
|
{
|
||||||
#if defined(USING_WEBKIT) || defined(USING_WEBENGINE)
|
#if defined(USING_WEBKIT) || defined(USING_WEBENGINE)
|
||||||
|
|||||||
@ -93,7 +93,8 @@ public slots:
|
|||||||
virtual void highlighted(const QString& link);
|
virtual void highlighted(const QString& link);
|
||||||
virtual void createPopupMenu(const QPoint& pos);
|
virtual void createPopupMenu(const QPoint& pos);
|
||||||
virtual void showQueryDetails();
|
virtual void showQueryDetails();
|
||||||
|
virtual void onUiPrefsChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nextPageAvailable(bool);
|
void nextPageAvailable(bool);
|
||||||
void prevPageAvailable(bool);
|
void prevPageAvailable(bool);
|
||||||
|
|||||||
@ -63,6 +63,10 @@ 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
|
||||||
|
static const int fsadjustdetail = 1;
|
||||||
|
static const int fsadjusttable = 1;
|
||||||
|
|
||||||
static PlainToRichQtReslist g_hiliter;
|
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
|
//// Data model methods
|
||||||
////
|
////
|
||||||
@ -356,6 +375,18 @@ QVariant RecollModel::data(const QModelIndex& index, int role) const
|
|||||||
{
|
{
|
||||||
LOGDEB2("RecollModel::data: row " << index.row() << " col " <<
|
LOGDEB2("RecollModel::data: row " << index.row() << " col " <<
|
||||||
index.column() << " role " << role << "\n");
|
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() ||
|
if (!m_source || role != Qt::DisplayRole || !index.isValid() ||
|
||||||
index.column() >= int(m_fields.size())) {
|
index.column() >= int(m_fields.size())) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -460,44 +491,56 @@ public:
|
|||||||
// and a way to pass an indicator from data(), a bit more
|
// and a way to pass an indicator from data(), a bit more
|
||||||
// difficult. Anyway, the display seems fast enough as is.
|
// difficult. Anyway, the display seems fast enough as is.
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const
|
const QModelIndex &index) const {
|
||||||
{
|
QStyleOptionViewItem opt = option;
|
||||||
QStyleOptionViewItem opt = option;
|
initStyleOption(&opt, index);
|
||||||
initStyleOption(&opt, index);
|
QVariant value = index.data(Qt::DisplayRole);
|
||||||
QVariant value = index.data(Qt::DisplayRole);
|
if (value.isValid() && !value.isNull()) {
|
||||||
if (value.isValid() && !value.isNull()) {
|
QString text = value.toString();
|
||||||
QString text = value.toString();
|
if (!text.isEmpty()) {
|
||||||
if (!text.isEmpty()) {
|
QTextDocument document;
|
||||||
QTextDocument document;
|
painter->save();
|
||||||
painter->save();
|
QString fstyle;
|
||||||
if (opt.state & QStyle::State_Selected) {
|
if (prefs.reslistfontsize > 0) {
|
||||||
painter->fillRect(opt.rect, opt.palette.highlight());
|
int fs = prefs.reslistfontsize <= fsadjusttable ?
|
||||||
// Set the foreground color. The pen approach does
|
prefs.reslistfontsize :
|
||||||
// not seem to work, probably it's reset by the
|
prefs.reslistfontsize - fsadjusttable;
|
||||||
// textdocument. Couldn't use
|
fstyle = QString("font-size: %1pt").arg(fs);
|
||||||
// setdefaultstylesheet() either. the div thing is
|
}
|
||||||
// an ugly hack. Works for now
|
if (opt.state & QStyle::State_Selected) {
|
||||||
#if 0
|
painter->fillRect(opt.rect, opt.palette.highlight());
|
||||||
QPen pen = painter->pen();
|
// Set the foreground color. Tried with pen
|
||||||
pen.setBrush(opt.palette.brush(QPalette::HighlightedText));
|
// approach did not seem to work, probably it's
|
||||||
painter->setPen(pen);
|
// reset by the textdocument. Couldn't use
|
||||||
#else
|
// setdefaultstylesheet() either. the div thing is
|
||||||
text = QString::fromUtf8("<div style='color: white'> ") +
|
// an ugly hack. Works for now
|
||||||
text + QString::fromUtf8("</div>");
|
QString ntxt("<div style='color: white");
|
||||||
#endif
|
if (!fstyle.isEmpty()) {
|
||||||
}
|
ntxt += QString(";") + fstyle;
|
||||||
painter->setClipRect(option.rect);
|
}
|
||||||
QPoint where = option.rect.topLeft();
|
ntxt += "'>";
|
||||||
where.ry() += TEXTINCELLVTRANS;
|
ntxt += text + QString::fromUtf8("</div>");
|
||||||
painter->translate(where);
|
text.swap(ntxt);
|
||||||
document.setHtml(text);
|
} else {
|
||||||
document.drawContents(painter);
|
if (!fstyle.isEmpty()) {
|
||||||
painter->restore();
|
QString ntxt("<div style='");
|
||||||
return;
|
ntxt += fstyle;
|
||||||
}
|
ntxt += QString("'>") + text + QString("</div>");
|
||||||
}
|
text.swap(ntxt);
|
||||||
QStyledItemDelegate::paint(painter, option, index);
|
}
|
||||||
|
}
|
||||||
|
painter->setClipRect(option.rect);
|
||||||
|
QPoint where = option.rect.topLeft();
|
||||||
|
where.ry() += TEXTINCELLVTRANS;
|
||||||
|
painter->translate(where);
|
||||||
|
document.setHtml(text);
|
||||||
|
document.drawContents(painter);
|
||||||
|
painter->restore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
QStyledItemDelegate::paint(painter, option, index);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void ResTable::init()
|
void ResTable::init()
|
||||||
@ -543,6 +586,7 @@ void ResTable::init()
|
|||||||
if (header) {
|
if (header) {
|
||||||
header->setDefaultSectionSize(QApplication::fontMetrics().height() +
|
header->setDefaultSectionSize(QApplication::fontMetrics().height() +
|
||||||
ROWHEIGHTPAD);
|
ROWHEIGHTPAD);
|
||||||
|
header->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
QShortcut *sc = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
QShortcut *sc = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
||||||
@ -571,6 +615,7 @@ void ResTable::init()
|
|||||||
m_detail->setReadOnly(true);
|
m_detail->setReadOnly(true);
|
||||||
m_detail->setUndoRedoEnabled(false);
|
m_detail->setUndoRedoEnabled(false);
|
||||||
m_detail->setOpenLinks(false);
|
m_detail->setOpenLinks(false);
|
||||||
|
m_detail->setFont();
|
||||||
// signals and slots connections
|
// signals and slots connections
|
||||||
connect(m_detail, SIGNAL(anchorClicked(const QUrl &)),
|
connect(m_detail, SIGNAL(anchorClicked(const QUrl &)),
|
||||||
this, SLOT(linkWasClicked(const QUrl &)));
|
this, SLOT(linkWasClicked(const QUrl &)));
|
||||||
@ -626,6 +671,12 @@ void ResTable::setRclMain(RclMain *m, bool ismain)
|
|||||||
m_rclmain, SLOT(showSnippets(Rcl::Doc)));
|
m_rclmain, SLOT(showSnippets(Rcl::Doc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResTable::onUiPrefsChanged()
|
||||||
|
{
|
||||||
|
if (m_detail)
|
||||||
|
m_detail->setFont();
|
||||||
|
}
|
||||||
|
|
||||||
int ResTable::getDetailDocNumOrTopRow()
|
int ResTable::getDetailDocNumOrTopRow()
|
||||||
{
|
{
|
||||||
if (m_detaildocnum >= 0)
|
if (m_detaildocnum >= 0)
|
||||||
@ -835,8 +886,8 @@ void ResTable::linkWasClicked(const QUrl &url)
|
|||||||
// Open parent folder
|
// Open parent folder
|
||||||
case 'F':
|
case 'F':
|
||||||
{
|
{
|
||||||
emit editRequested(ResultPopup::getParent(std::shared_ptr<DocSequence>(),
|
emit editRequested(ResultPopup::getParent(
|
||||||
m_detaildoc));
|
std::shared_ptr<DocSequence>(), m_detaildoc));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1084,4 +1135,3 @@ void ResTable::addColumn()
|
|||||||
qs2utf8s(action->data().toString()) << "\n");
|
qs2utf8s(action->data().toString()) << "\n");
|
||||||
m_model->addColumn(m_popcolumn, qs2utf8s(action->data().toString()));
|
m_model->addColumn(m_popcolumn, qs2utf8s(action->data().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,8 @@ class ResTableDetailArea : public QTextBrowser {
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void createPopupMenu(const QPoint& pos);
|
virtual void createPopupMenu(const QPoint& pos);
|
||||||
|
virtual void setFont();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResTable *m_table;
|
ResTable *m_table;
|
||||||
};
|
};
|
||||||
@ -156,7 +157,8 @@ public slots:
|
|||||||
virtual void linkWasClicked(const QUrl&);
|
virtual void linkWasClicked(const QUrl&);
|
||||||
virtual void makeRowVisible(int row);
|
virtual void makeRowVisible(int row);
|
||||||
virtual void takeFocus();
|
virtual void takeFocus();
|
||||||
|
virtual void onUiPrefsChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void docPreviewClicked(int, Rcl::Doc, int);
|
void docPreviewClicked(int, Rcl::Doc, int);
|
||||||
void docSaveToFileClicked(Rcl::Doc);
|
void docSaveToFileClicked(Rcl::Doc);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user