Skip to content

Commit f20d897

Browse files
authored
Unify Font Size in Search Result Dock (dail8859#834)
Closes dail8859#827
1 parent 303d7a7 commit f20d897

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/NotepadNext/docks/SearchResultsDock.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818

1919

20+
#include "ApplicationSettings.h"
21+
#include "NotepadNextApplication.h"
2022
#include "SearchResultHighlighterDelegate.h"
2123
#include "SearchResultData.h"
2224
#include "SearchResultsDock.h"
@@ -36,12 +38,6 @@ SearchResultsDock::SearchResultsDock(QWidget *parent) :
3638
{
3739
ui->setupUi(this);
3840

39-
#ifdef Q_OS_MACOS
40-
// Set a slightly larger font on MacOS
41-
QFont font("Courier New", 14);
42-
ui->treeWidget->setFont(font);
43-
#endif
44-
4541
// Close the results when escape is pressed
4642
new QShortcut(QKeySequence::Cancel, this, this, &SearchResultsDock::close, Qt::WidgetWithChildrenShortcut);
4743

@@ -69,6 +65,16 @@ SearchResultsDock::SearchResultsDock(QWidget *parent) :
6965
});
7066

7167
ui->treeWidget->setItemDelegate(new SearchResultHighlighterDelegate(ui->treeWidget));
68+
69+
ApplicationSettings *settings = qobject_cast<NotepadNextApplication*>(qApp)->getSettings();
70+
auto updateTreeWidgetFont = [=]() {
71+
QFont f(settings->fontName(), settings->fontSize());
72+
ui->treeWidget->setFont(f);
73+
ui->treeWidget->resizeColumnToContents(0);
74+
};
75+
connect(settings, &ApplicationSettings::fontNameChanged, this, updateTreeWidgetFont);
76+
connect(settings, &ApplicationSettings::fontSizeChanged, this, updateTreeWidgetFont);
77+
updateTreeWidgetFont();
7278
}
7379

7480
SearchResultsDock::~SearchResultsDock()

0 commit comments

Comments
 (0)