Skip to content

Commit

Permalink
Changed to different font system
Browse files Browse the repository at this point in the history
We make all font sizes dependent on the system font size, so that the font sizes look fine
 on all operating systems. E.g. point size 11 looks fine on Linux but too small on MacOS.
  • Loading branch information
DavidLazarescu committed Oct 22, 2023
1 parent 9162c18 commit 282b915
Show file tree
Hide file tree
Showing 65 changed files with 2,921 additions and 3,492 deletions.
6 changes: 6 additions & 0 deletions src/adapters/controllers/app_info_controller.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "app_info_controller.hpp"
#include <QDir>
#include <QFontDatabase>

using namespace application;

Expand Down Expand Up @@ -81,4 +82,9 @@ void AppInfoController::updateApplication()
m_appInfoService->updateApplication();
}

int AppInfoController::getSystemFontSize() const
{
return QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize();
}

} // namespace adapters::controllers
10 changes: 5 additions & 5 deletions src/adapters/controllers/app_info_controller.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#include <QObject>
#include "i_app_info_service.hpp"
#include "i_app_info_controller.hpp"
#include "adapters_export.hpp"
#include "i_app_info_controller.hpp"
#include "i_app_info_service.hpp"

namespace adapters::controllers
{
Expand All @@ -12,8 +12,7 @@ class ADAPTERS_EXPORT AppInfoController : public IAppInfoController
Q_OBJECT

public:
AppInfoController(
application::IAppInfoService* appInfoService);
AppInfoController(application::IAppInfoService* appInfoService);

private:
QString getCurrentVersion() const override;
Expand All @@ -27,8 +26,9 @@ class ADAPTERS_EXPORT AppInfoController : public IAppInfoController
QString getCurrentQtVersion() const override;
QString getOperatingSystem() const override;
void updateApplication() override;
int getSystemFontSize() const override;

application::IAppInfoService* m_appInfoService;
};

} // namespace adapters::controllers
} // namespace adapters::controllers
10 changes: 6 additions & 4 deletions src/adapters/interfaces/controllers/i_app_info_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ namespace adapters

/**
* The AuthenticationController class is exposed to the UI code and thus is the
* "entry point" to the application's backend for application info operations. It
* acts as a layer of abstraction which maps the user data to a format usable
* "entry point" to the application's backend for application info operations.
* It acts as a layer of abstraction which maps the user data to a format usable
* for the application.
*/
class ADAPTERS_EXPORT IAppInfoController : public QObject
{
Q_OBJECT
Q_PROPERTY(QString currentVersion READ getCurrentVersion CONSTANT)
Q_PROPERTY(QString newestVersion READ getNewestVersion
NOTIFY newestVersionChanged)
Q_PROPERTY(
QString newestVersion READ getNewestVersion NOTIFY newestVersionChanged)
Q_PROPERTY(QString applicationName READ getApplicationName CONSTANT)
Q_PROPERTY(QString companyName READ getCompanyName CONSTANT)
Q_PROPERTY(QString website READ getWebsite CONSTANT)
Expand All @@ -26,6 +26,7 @@ class ADAPTERS_EXPORT IAppInfoController : public QObject
Q_PROPERTY(QString githubLink READ getGithubLink CONSTANT)
Q_PROPERTY(QString currentQtVersion READ getCurrentQtVersion CONSTANT)
Q_PROPERTY(QString operatingSystem READ getOperatingSystem CONSTANT)
Q_PROPERTY(int systemFontSize READ getSystemFontSize CONSTANT)

public:
virtual ~IAppInfoController() noexcept = default;
Expand All @@ -43,6 +44,7 @@ class ADAPTERS_EXPORT IAppInfoController : public QObject
virtual QString getGithubLink() const = 0;
virtual QString getCurrentQtVersion() const = 0;
virtual QString getOperatingSystem() const = 0;
virtual int getSystemFontSize() const = 0;

signals:
void newestVersionChanged();
Expand Down
3 changes: 3 additions & 0 deletions src/application/services/book_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ void BookService::addBookmark(const domain::entities::Bookmark& bookmark)
book->addBookmark(bookmark);
emit bookmarkInsertionEnded();

book->updateLastModified();
m_libraryService->updateBook(*book);
}

Expand All @@ -156,6 +157,7 @@ void BookService::renameBookmark(const QUuid& uuid, const QString& newName)
book->renameBookmark(uuid, newName);
emit bookmarkNameChanged(getIndexOfBookmark(uuid));

book->updateLastModified();
m_libraryService->updateBook(*book);
}

Expand All @@ -167,6 +169,7 @@ void BookService::removeBookmark(const QUuid& uuid)
book->removeBookmark(uuid);
emit bookmarkDeletionEnded();

book->updateLastModified();
m_libraryService->updateBook(*book);
}

Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ int main(int argc, char* argv[])
// Register types
qmlRegisterSingletonType(QUrl("qrc:/StyleSheet.qml"), "Librum.style", 1, 0, "Style");
qmlRegisterSingletonType(QUrl("qrc:/IconSheet.qml"), "Librum.icons", 1, 0, "Icons");
qmlRegisterSingletonType(QUrl("qrc:/FontSheet.qml"), "Librum.fonts", 1, 0, "Fonts");
qmlRegisterSingletonType(QUrl("qrc:/Globals.qml"), "Librum.globals", 1, 0, "Globals");
qmlRegisterType<adapters::data_models::LibraryProxyModel>("Librum.models", 1, 0, "LibraryProxyModel");
qmlRegisterType<adapters::data_models::FreeBooksModel>("Librum.models", 1, 0, "FreeBooksModel");
Expand Down
34 changes: 34 additions & 0 deletions src/presentation/FontSheet.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
pragma Singleton

import QtQuick
import Librum.controllers


/**
We make all font sizes dependent on the system font size, so that the font sizes look fine
on all operating systems. E.g. point size 11 looks fine on Linux but too small on MacOS.
*/
Item {
id: fontSheet

property int hugeSize: AppInfoController.systemFontSize + 4.5
property int largeSize: AppInfoController.systemFontSize + 4
property int bigSize: AppInfoController.systemFontSize + 3
property int baseSize: AppInfoController.systemFontSize + 2
property int mediumSize: AppInfoController.systemFontSize + 1.5
property int smallSize: AppInfoController.systemFontSize + 1
property int tinySize: AppInfoController.systemFontSize

property int smallTitleSize: AppInfoController.systemFontSize + 5
property int modestTitleSize: AppInfoController.systemFontSize + 6
property int baseTitleSize: AppInfoController.systemFontSize + 7
property int mediumTitleSize: AppInfoController.systemFontSize + 8
property int bigTitleSize: AppInfoController.systemFontSize + 10
property int veryBigTitleSize: AppInfoController.systemFontSize + 11
property int largeTitleSize: AppInfoController.systemFontSize + 13
property int hugeTitleSize: AppInfoController.systemFontSize + 14
property int enormousTitleSize: AppInfoController.systemFontSize + 17

property int baseHeaderSize: AppInfoController.systemFontSize + 33
property int bigHeaderSize: AppInfoController.systemFontSize + 37
}
31 changes: 17 additions & 14 deletions src/presentation/addOnsPage/MAddOnsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,37 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Librum.style
import Librum.fonts

Page
{
Page {
id: root
background: Rectangle { color: Style.colorPageBackground }

Item { id: topSpacer; height: parent.height / 2.3 }

Label
{
background: Rectangle {
color: Style.colorPageBackground
}

Item {
id: topSpacer
height: parent.height / 2.3
}

Label {
id: title
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: topSpacer.bottom
text: "Add-ons Page"
color: Style.colorTitle
font.pointSize: 22
font.pointSize: Fonts.largeTitleSize
font.bold: true
}

Label
{

Label {
id: description
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: title.bottom
anchors.topMargin: 6
text: "Currently in Development"
color: Style.colorPageSubtitle
font.pointSize: 16
font.pointSize: Fonts.baseTitleSize
font.bold: true
}
}
}
Loading

0 comments on commit 282b915

Please sign in to comment.