Skip to content

Commit d33fd81

Browse files
committed
QPA: move createRoleFonts to qhaikutheme module, cleanup
1 parent 4f7f220 commit d33fd81

File tree

5 files changed

+71
-189
lines changed

5 files changed

+71
-189
lines changed

platforms/qhaikuplatform/haiku/haiku.pro

-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ SOURCES = main.cpp \
2323
qhaikuwindow.cpp \
2424
qhaikucommon.cpp \
2525
qhaikutheme.cpp \
26-
qhaikusystemsettings.cpp \
2726
qhaikusystemtrayicon.cpp \
2827
qhaikuclipboard.cpp \
2928
qhaikuplatformdialoghelpers.cpp \
@@ -39,7 +38,6 @@ HEADERS = qhaikuintegration.h \
3938
qhaikuwindow.h \
4039
qhaikucommon.h \
4140
qhaikutheme.h \
42-
qhaikusystemsettings.h \
4341
qhaikusystemtrayicon.h \
4442
qhaikuclipboard.h \
4543
qhaikuplatformdialoghelpers.h \

platforms/qhaikuplatform/haiku/qhaikusystemsettings.cpp

-129
This file was deleted.

platforms/qhaikuplatform/haiku/qhaikusystemsettings.h

-55
This file was deleted.

platforms/qhaikuplatform/haiku/qhaikutheme.cpp

+70-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include "qhaikutheme.h"
4242
#include "qhaikusettings.h"
4343
#include "qhaikuplatformdialoghelpers.h"
44-
#include "qhaikusystemsettings.h"
4544
#include "qhaikuintegration.h"
4645
#include "qhaikusystemtrayicon.h"
4746

@@ -216,8 +215,76 @@ const QFont *QHaikuTheme::font(Font type) const
216215
{
217216
QPlatformFontDatabase *fontDatabase = m_integration->fontDatabase();
218217

219-
if (fontDatabase && m_fonts.isEmpty())
220-
m_fonts = qt_haiku_createRoleFonts(fontDatabase);
218+
if (fontDatabase && m_fonts.isEmpty()) {
219+
QFontDatabase db;
220+
221+
font_family plainFontFamily;
222+
font_style plainFontStyle;
223+
BFont haikuPlainFont = *be_plain_font;
224+
haikuPlainFont.GetFamilyAndStyle(&plainFontFamily, &plainFontStyle);
225+
226+
font_family boldFontFamily;
227+
font_style boldFontStyle;
228+
BFont haikuBoldFont = *be_bold_font;
229+
haikuBoldFont.GetFamilyAndStyle(&boldFontFamily, &boldFontStyle);
230+
231+
font_family fixedFontFamily;
232+
font_style fixedFontStyle;
233+
BFont haikuFixedFont = *be_fixed_font;
234+
haikuFixedFont.GetFamilyAndStyle(&fixedFontFamily, &fixedFontStyle);
235+
236+
menu_info haikuMenuFontInfo;
237+
get_menu_info(&haikuMenuFontInfo);
238+
239+
float kSmallFont = 0.7;
240+
float kBold = 0.96;
241+
242+
QFont baseFont = db.font(plainFontFamily, plainFontStyle, haikuPlainFont.Size());
243+
if (haikuPlainFont.Size() >= 0)
244+
baseFont.setPointSizeF(haikuPlainFont.Size());
245+
baseFont.setStretch(QFont::Unstretched);
246+
247+
QFont boldFont = db.font(boldFontFamily, boldFontStyle, haikuBoldFont.Size() * kBold);
248+
if (haikuBoldFont.Size() >= 0)
249+
boldFont.setPointSizeF(haikuBoldFont.Size() * kBold);
250+
boldFont.setStretch(QFont::Unstretched);
251+
252+
QFont monoFont = db.font(fixedFontFamily, fixedFontStyle, haikuFixedFont.Size());
253+
if (haikuFixedFont.Size() >= 0)
254+
monoFont.setPointSizeF(haikuFixedFont.Size());
255+
monoFont.setStretch(QFont::Unstretched);
256+
257+
QFont menuFont = db.font(haikuMenuFontInfo.f_family, haikuMenuFontInfo.f_style, haikuMenuFontInfo.font_size);
258+
if (haikuMenuFontInfo.font_size >= 0)
259+
menuFont.setPointSizeF(haikuMenuFontInfo.font_size);
260+
menuFont.setStretch(QFont::Unstretched);
261+
262+
QHash<QPlatformTheme::Font, QFont *> fonts;
263+
fonts.insert(QPlatformTheme::SystemFont, new QFont(baseFont));
264+
fonts.insert(QPlatformTheme::PushButtonFont, new QFont(baseFont));
265+
fonts.insert(QPlatformTheme::ListViewFont, new QFont(baseFont));
266+
fonts.insert(QPlatformTheme::ListBoxFont, new QFont(baseFont));
267+
fonts.insert(QPlatformTheme::TitleBarFont, new QFont(boldFont));
268+
fonts.insert(QPlatformTheme::GroupBoxTitleFont, new QFont(boldFont));
269+
fonts.insert(QPlatformTheme::MdiSubWindowTitleFont, new QFont(boldFont));
270+
fonts.insert(QPlatformTheme::MenuFont, new QFont(menuFont));
271+
fonts.insert(QPlatformTheme::MenuBarFont, new QFont(menuFont));
272+
fonts.insert(QPlatformTheme::ComboMenuItemFont, new QFont(menuFont));
273+
fonts.insert(QPlatformTheme::HeaderViewFont, new QFont(baseFont));
274+
fonts.insert(QPlatformTheme::TipLabelFont, new QFont(baseFont));
275+
fonts.insert(QPlatformTheme::LabelFont, new QFont(baseFont));
276+
fonts.insert(QPlatformTheme::ToolButtonFont, new QFont(baseFont));
277+
fonts.insert(QPlatformTheme::MenuItemFont, new QFont(menuFont));
278+
fonts.insert(QPlatformTheme::ComboLineEditFont, new QFont(baseFont));
279+
fonts.insert(QPlatformTheme::FixedFont, new QFont(monoFont));
280+
281+
QFont smallFont(baseFont);
282+
smallFont.setPointSizeF(haikuPlainFont.Size() * kSmallFont);
283+
fonts.insert(QPlatformTheme::SmallFont, new QFont(smallFont));
284+
fonts.insert(QPlatformTheme::MiniFont, new QFont(smallFont));
285+
286+
m_fonts = fonts;
287+
}
221288
return m_fonts.value(type, 0);
222289
}
223290

platforms/qhaikuplatform/haiku/qhaikutheme.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#define QHAIKUTHEME_H
4343

4444
#include <qpa/qplatformtheme.h>
45+
#include <qpa/qplatformfontdatabase.h>
4546

4647
#include <QtGui/qfont.h>
4748
#include <QtCore/qhash.h>

0 commit comments

Comments
 (0)