make font settings cross platform
This commit is contained in:
parent
2561b03583
commit
f260bc2b0c
5 changed files with 12 additions and 13 deletions
|
@ -13,7 +13,7 @@ std::string formatCentAsEuroString(const int cent, int width)
|
|||
currStream << std::right << std::setw(width) << std::showbase
|
||||
<< std::put_money(cent, false);
|
||||
} catch (std::runtime_error& err) {
|
||||
currStream << std::fixed << std::setw(width) << std::setprecision(2) << cent / 100.0L
|
||||
currStream << std::fixed << std::setw(width - 2) << std::setprecision(2) << cent / 100.0L
|
||||
<< " €";
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QFont>
|
||||
#include <QSettings>
|
||||
#include <QFontDatabase>
|
||||
|
||||
BasketModel::BasketModel(Marketplace* market, QObject* parent)
|
||||
: QAbstractTableModel(parent), marketplace_(market)
|
||||
|
@ -24,13 +25,11 @@ QVariant BasketModel::data(const QModelIndex& index, int role) const
|
|||
case 0:
|
||||
[[fallthrough]];
|
||||
case 1:
|
||||
myFont.setFamily("monospace");
|
||||
return myFont;
|
||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
case 2:
|
||||
return myFont;
|
||||
case 3:
|
||||
myFont.setFamily("monospace");
|
||||
return myFont;
|
||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <posprinter.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFontDatabase>
|
||||
#include <QPainter>
|
||||
#include <QSettings>
|
||||
#include <QtPrintSupport/QPrintDialog>
|
||||
|
@ -74,7 +75,7 @@ void ReportDialog::onPrintReportButtonClicked()
|
|||
painter.setFont(QFont("Arial", 16, QFont::Bold));
|
||||
painter.drawText(QRect(0, 0, width, height), Qt::AlignTop | Qt::AlignHCenter,
|
||||
"Auswertung Kindersachenmarkt");
|
||||
painter.setFont(QFont("monospace", 12));
|
||||
painter.setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
QString content;
|
||||
content += QString("%1 %2 %3 %4 %5 %6 %7")
|
||||
.arg("Nr.", -3)
|
||||
|
@ -109,7 +110,7 @@ void ReportDialog::onPrintReportButtonClicked()
|
|||
painter.setFont(QFont("Arial", 16, QFont::Bold));
|
||||
painter.drawText(QRect(0, 0, width, height), Qt::AlignTop | Qt::AlignHCenter,
|
||||
"Auswertung Kindersachenmarkt");
|
||||
painter.setFont(QFont("monospace", 12));
|
||||
painter.setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
QString content("Einzelteile ohne Nummer\n=======================\n\n");
|
||||
unsigned int lines{0};
|
||||
unsigned int pages{1};
|
||||
|
@ -138,7 +139,7 @@ void ReportDialog::onPrintReportButtonClicked()
|
|||
painter.setFont(QFont("Arial", 16, QFont::Bold));
|
||||
painter.drawText(QRect(0, 0, width, height), Qt::AlignTop | Qt::AlignHCenter,
|
||||
"Auswertung Kindersachenmarkt");
|
||||
painter.setFont(QFont("monospace", 12));
|
||||
painter.setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
QString content("Gesamtstatistik\n===============\n\n");
|
||||
content += QString("Registrierte Verkäufer: %1\n").arg(sellers.size(), 6);
|
||||
content += QString("Verkaufte Artikel: %1\n\n").arg(6, 6);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "reportmodel.h"
|
||||
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
#include <QSettings>
|
||||
|
||||
ReportModel::ReportModel(Marketplace* market, QObject* parent)
|
||||
|
@ -9,7 +10,6 @@ ReportModel::ReportModel(Marketplace* market, QObject* parent)
|
|||
QSettings settings;
|
||||
feeInPercent_ = settings.value("global/feeInPercent").toInt();
|
||||
maxFeeInCent_ = settings.value("global/maxFeeInEuro").toInt() * 100;
|
||||
|
||||
}
|
||||
|
||||
int ReportModel::rowCount([[maybe_unused]] const QModelIndex& parent) const
|
||||
|
@ -30,8 +30,7 @@ QVariant ReportModel::data(const QModelIndex& index, int role) const
|
|||
case 5:
|
||||
[[fallthrough]];
|
||||
case 6:
|
||||
myFont.setFamily("monospace");
|
||||
return myFont;
|
||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
default:
|
||||
return myFont;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
|
||||
SaleModel::SaleModel(Marketplace* market, QObject* parent) : QAbstractItemModel(parent)
|
||||
{
|
||||
|
@ -83,8 +84,7 @@ QVariant SaleModel::data(const QModelIndex& index, int role) const
|
|||
case 0:
|
||||
return myFont;
|
||||
case 1:
|
||||
myFont.setFamily("monospace");
|
||||
return myFont;
|
||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
default:
|
||||
return myFont;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue