git-svn-id: svn://db.shs.com.ru/libs@462 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
#include "qad_types.h"
|
||||
#include <QApplication>
|
||||
#include <QFontMetrics>
|
||||
#include <QWidget>
|
||||
#if QT_VERSION >= 0x050000
|
||||
# include <QWindow>
|
||||
# include <QScreen>
|
||||
#endif
|
||||
|
||||
|
||||
__QADTypesRegistrator__ __registrator__;
|
||||
@@ -125,22 +130,43 @@ QString uniqueName(QString n, const QStringList & names) {
|
||||
}
|
||||
|
||||
|
||||
int fontHeight() {
|
||||
int fontHeight(QWidget * w) {
|
||||
#ifdef Q_OS_ANDROID
|
||||
static int ret = QApplication::fontMetrics().size(0, "0").height();
|
||||
return ret;
|
||||
#else
|
||||
# if QT_VERSION >= 0x050000
|
||||
//qDebug() << "fontHeight" << w;
|
||||
if (w) {
|
||||
QWidget * pw = w->window();
|
||||
if (pw) {
|
||||
/*QWindow * wnd = pw->windowHandle();
|
||||
//qDebug() << "wnd" << wnd;
|
||||
if (wnd) {
|
||||
QScreen * s = wnd->screen();
|
||||
qDebug() << "s" << s;
|
||||
if (s) {
|
||||
qDebug() << "scales:";
|
||||
qDebug() << QApplication::fontMetrics().size(0, "0").height() << QApplication::fontMetrics().xHeight();
|
||||
qDebug() << s->logicalDotsPerInch() << s->logicalDotsPerInch()/96.*QApplication::font().pointSizeF();
|
||||
}
|
||||
}*/
|
||||
return QFontMetrics(QApplication::font(), pw).size(0, "0").height();
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
return QApplication::fontMetrics().size(0, "0").height();
|
||||
}
|
||||
|
||||
|
||||
int lineThickness() {
|
||||
return qMax<int>(qRound(fontHeight() / 15.), 1);
|
||||
int lineThickness(QWidget * w) {
|
||||
return qMax<int>(qRound(fontHeight(w) / 15.), 1);
|
||||
}
|
||||
|
||||
|
||||
QSize preferredIconSize(float x) {
|
||||
int s = qMax<int>(8, qRound(fontHeight() * x));
|
||||
QSize preferredIconSize(float x, QWidget * w) {
|
||||
int s = qMax<int>(8, qRound(fontHeight(w) * x));
|
||||
#ifdef Q_OS_MACOS
|
||||
s /= 1.25;
|
||||
#endif
|
||||
@@ -148,6 +174,6 @@ QSize preferredIconSize(float x) {
|
||||
}
|
||||
|
||||
|
||||
double appScale() {
|
||||
return qMax<double>(fontHeight() / 15., 1.);
|
||||
double appScale(QWidget * w) {
|
||||
return qMax<double>(fontHeight(w) / 15., 1.);
|
||||
}
|
||||
|
||||
@@ -117,10 +117,11 @@ inline QRectF enlargedRect(const QRectF & r, qreal dx, qreal dy, qreal v) {
|
||||
|
||||
QVariant::Type typeFromLetter(const QString & l);
|
||||
QString uniqueName(QString n, const QStringList & names);
|
||||
int fontHeight();
|
||||
int lineThickness();
|
||||
QSize preferredIconSize(float x = 1.f);
|
||||
double appScale();
|
||||
|
||||
int fontHeight(QWidget * w = 0);
|
||||
int lineThickness(QWidget * w = 0);
|
||||
QSize preferredIconSize(float x = 1.f, QWidget * w = 0);
|
||||
double appScale(QWidget * w = 0);
|
||||
|
||||
|
||||
#endif // QAD_TYPES_H
|
||||
|
||||
Reference in New Issue
Block a user