Exemplo n.º 1
0
qreal Theme::GetDPI() const
{
    QScreen *srn = QApplication::screens().at(0);
    qreal dotsPerInch = (qreal)srn->physicalDotsPerInch();

    return dotsPerInch;
}
Exemplo n.º 2
0
DBThread::DBThread()
 : database(new osmscout::Database(databaseParameter)),
/*
DBThread::DBThread(const SettingsRef& settings)
 : settings(settings),
   painter(NULL),
   database(new osmscout::Database(databaseParameter)),
*/
   locationService(new osmscout::LocationService(database)),
   mapService(new osmscout::MapService(database)),
   painter(NULL),
   iconDirectory(),
   currentImage(NULL),
   currentLat(0.0),
   currentLon(0.0),
   currentAngle(0.0),
   currentMagnification(0),
   finishedImage(NULL),
   finishedLat(0.0),
   finishedLon(0.0),
   finishedMagnification(0),
   currentRenderRequest(),
   doRender(false),
   renderBreaker(new QBreaker()),
   renderBreakerRef(renderBreaker)
{
    QScreen *srn = QApplication::screens().at(0);

    dpi = (double)srn->physicalDotsPerInch();
}
Exemplo n.º 3
0
float QNanoFont::ptToPx(float pt)
{
    qreal ldp = 1.0;
    QScreen *screen = QGuiApplication::screens().at(0);
    if (screen) {
        ldp = screen->physicalDotsPerInch();
    } else {
        qWarning() << "QScreen required for ptToPx";
    }
    return pt * (ldp/72.0);
}
Exemplo n.º 4
0
void UnitsAttached::screenChanged(QScreen *screen)
{
    if (screen != m_screen) {
        QScreen *oldScreen = m_screen;
        m_screen = screen;

        if (oldScreen)
            oldScreen->disconnect(this);

        if (oldScreen == nullptr || screen == nullptr ||
            screen->physicalDotsPerInch() != oldScreen->physicalDotsPerInch() ||
            screen->logicalDotsPerInch() != oldScreen->logicalDotsPerInch() ||
            screen->devicePixelRatio() != oldScreen->devicePixelRatio()) {
            updateDPI();
            emit dpChanged();
        }
    }
}
Exemplo n.º 5
0
void Theme::initDisplays()
{
#ifdef QT_DEBUG
    m_displays = {
        { "iPhone 4 (4, 4S)", 960, 640, 12.83464566929 },
        { "Galaxy SIII", 1280, 720, 12.04724409449 },
        { "iPhone 5 (5c, 5s)", 1136, 640, 12.83464566929 },
        { "Galaxy SII", 800, 480, 8.622047244094 },
        { "Google Nexus 4 by LG", 1280, 768, 12.59842519685 },
        { "Google Nexus 5 by LG", 1920, 1080, 17.36220472441 },
        { "Galaxy Nexus", 1280, 720, 12.44094488189 },
        { "Galaxy SIV", 1920, 1080, 17.36220472441 },
        { "Galaxy S Plus", 800, 480, 9.173228346457 },
        { "Galaxy Note II", 1280, 720, 10.51181102362 },
        { "Galaxy S Plus", 800, 480, 9.173228346457 },
        { "Galaxy Note", 1280, 800, 11.22047244094 },
        { "Nokia Lumia 925", 1280, 768, 13.07086614173 },
        { "iPhone (Original - 3GS)", 480, 320, 12.59842519685 },
        { "Nokia Lumia 920", 1280, 768, 13.07086614173 },
        { "Nokia Lumia (710, 800)", 800, 480, 9.92125984252 },
        { "Test", 800, 480, 15.7874015748 },
        { "Nokia Lumia 900", 800, 480, 8.543307086614 },
        { "Nokia Lumia 620", 800, 480, 9.685039370079 },
        { "Nokia Lumia 720", 800, 480, 8.543307086614 },
        { "HTC One", 1920, 1080, 18.42519685039 },
        { "Droid Razr", 960, 540, 10.07874015748 },
        { "Droid 3 & 4", 960, 540, 11.02362204724 },
        { "Droid", 854, 480, 10.43307086614 },
        { "Sony Xperia Z", 1920, 1080, 17.36220472441 },
        { "BlackBerry Q10", 720, 720, 12.99212598425 },
        { "BlackBerry Z10", 1280, 768, 14.0157480315 },
        { "Alcatel One Touch Idol Ultra", 1280, 720, 12.44094488189 },
        { "Samsung Nexus S", 800, 480, 9.251968503937 },
        { "iPhone 6+", 1920, 1080, 15.7874015748 },
        { "iPhone 6", 1334, 750, 12.83464566929 }
    };
#else
    QScreen *screen = qApp->primaryScreen();
    Q_ASSERT(screen);
    m_displays = {{ "", screen->size().height(), screen->size().width(), screen->physicalDotsPerInch() * 0.03937007874016 }};
#endif
}
Exemplo n.º 6
0
QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
{
    switch (hint) {
    case StyleNames:
        if (qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_STYLE")
                && m_androidStyleData) {
            return QStringList("android");
        }
        return QStringList("fusion");

    case MouseDoubleClickDistance:
    {
            int minimumDistance = qEnvironmentVariableIntValue("QT_ANDROID_MINIMUM_MOUSE_DOUBLE_CLICK_DISTANCE");
            int ret = minimumDistance;

            QAndroidPlatformIntegration *platformIntegration
                    = static_cast<QAndroidPlatformIntegration *>(QGuiApplicationPrivate::platformIntegration());
            QAndroidPlatformScreen *platformScreen = platformIntegration->screen();
            if (platformScreen != 0) {
                QScreen *screen = platformScreen->screen();
                qreal dotsPerInch = screen->physicalDotsPerInch();

                // Allow 15% of an inch between clicks when double clicking
                int distance = qRound(dotsPerInch * 0.15);
                if (distance > minimumDistance)
                    ret = distance;
            }

            if (ret > 0)
                return ret;

            // fall through
    }
    default:
        return QPlatformTheme::themeHint(hint);
    }
}
Exemplo n.º 7
0
int main(int argc, char *argv[])
{
    QOptions options(get_common_options());
    options.add(QLatin1String("QMLPlayer options"))
            ("scale", 1.0, QLatin1String("scale of graphics context. 0: auto"))
            ;
    options.parse(argc, argv);
    if (options.value(QLatin1String("help")).toBool()) {
        options.print();
        return 0;
    }

    QGuiApplication app(argc, argv);
    QDir::setCurrent(qApp->applicationDirPath());
    qDebug() << "arguments======= " << app.arguments();
    set_opengl_backend(options.option(QStringLiteral("gl")).value().toString(), app.arguments().first());
    load_qm(QStringList() << QStringLiteral("QMLPlayer"), options.value(QStringLiteral("language")).toString());
    QtQuick2ApplicationViewer viewer;
    QString binDir = qApp->applicationDirPath();
    if (binDir.endsWith(QLatin1String(".app/Contents/MacOS"))) {
        binDir.remove(QLatin1String(".app/Contents/MacOS"));
        binDir = binDir.left(binDir.lastIndexOf(QLatin1String("/")));
    }
    QQmlEngine *engine = viewer.engine();
    if (!engine->importPathList().contains(binDir))
        engine->addImportPath(binDir);
    qDebug() << engine->importPathList();
    engine->rootContext()->setContextProperty(QStringLiteral("PlayerConfig"), &Config::instance());
    qDebug(">>>>>>>>devicePixelRatio: %f", qApp->devicePixelRatio());
    QScreen *sc = app.primaryScreen();
    qDebug() << "dpi phy: " << sc->physicalDotsPerInch() << ", logical: " << sc->logicalDotsPerInch() << ", dpr: " << sc->devicePixelRatio()
                << "; vis rect:" << sc->virtualGeometry();
    // define a global var for js and qml
    engine->rootContext()->setContextProperty(QStringLiteral("screenPixelDensity"), qApp->primaryScreen()->physicalDotsPerInch()*qApp->primaryScreen()->devicePixelRatio());
    qreal r = sc->physicalDotsPerInch()/sc->logicalDotsPerInch();
    if (std::isinf(r) || std::isnan(r))
#if defined(Q_OS_ANDROID)
        r = 2.0;
#else
        r = 1.0;
#endif
    float sr = options.value(QStringLiteral("scale")).toFloat();
#if defined(Q_OS_ANDROID)
    sr = r;
    if (sr > 2.0)
        sr = 2.0; //FIXME
#endif
    if (qFuzzyIsNull(sr))
        sr = r;
    engine->rootContext()->setContextProperty(QStringLiteral("scaleRatio"), sr);
    QString qml = QStringLiteral("qml/QMLPlayer/main.qml");
    if (QFile(qApp->applicationDirPath() + QLatin1String("/") + qml).exists())
        qml.prepend(qApp->applicationDirPath() + QLatin1String("/"));
    else
        qml.prepend(QLatin1String("qrc:///"));
    viewer.setMainQmlFile(qml);
    viewer.show();
    QOption op = options.option(QStringLiteral("width"));
    if (op.isSet())
        viewer.setWidth(op.value().toInt());
    op = options.option(QStringLiteral("height"));
    if (op.isSet())
        viewer.setHeight(op.value().toInt());
    op = options.option(QStringLiteral("x"));
    if (op.isSet())
        viewer.setX(op.value().toInt());
    op = options.option(QStringLiteral("y"));
    if (op.isSet())
        viewer.setY(op.value().toInt());
    if (options.value(QStringLiteral("fullscreen")).toBool())
        viewer.showFullScreen();

    viewer.setTitle(QStringLiteral("QMLPlayer based on QtAV. [email protected]"));
    /*
     * find root item, then root.init(argv). so we can deal with argv in qml
     */
#if 1
    QString json = app.arguments().join(QStringLiteral("\",\""));
    json.prepend(QLatin1String("[\"")).append(QLatin1String("\"]"));
    json.replace(QLatin1String("\\"), QLatin1String("/")); //FIXME
    QMetaObject::invokeMethod(viewer.rootObject(), "init", Q_ARG(QVariant, json));
//#else
    QObject *player = viewer.rootObject()->findChild<QObject*>(QStringLiteral("player"));
    if (player) {
        AppEventFilter *ae = new AppEventFilter(player, player);
        qApp->installEventFilter(ae);
    }
    QString file;
#ifdef Q_OS_ANDROID
    file = QAndroidJniObject::callStaticObjectMethod("org.qtav.qmlplayer.QMLPlayerActivity"
                                                                              , "getUrl"
                                                                              , "()Ljava/lang/String;")
            .toString();
#endif
    if (app.arguments().size() > 1) {
        file = options.value(QStringLiteral("file")).toString();
        if (file.isEmpty()) {
            if (argc > 1 && !app.arguments().last().startsWith(QLatin1Char('-')) && !app.arguments().at(argc-2).startsWith(QLatin1Char('-')))
                file = app.arguments().last();
        }
    }
    qDebug() << "file: " << file;
    if (player && !file.isEmpty()) {
        if (!file.startsWith(QLatin1String("file:")) && QFile(file).exists())
            file.prepend(QLatin1String("file:")); //qml use url and will add qrc: if no scheme
        file.replace(QLatin1String("\\"), QLatin1String("/")); //qurl
        QMetaObject::invokeMethod(player, "play", Q_ARG(QUrl, QUrl(file)));
    }
#endif
    QObject::connect(viewer.rootObject(), SIGNAL(requestFullScreen()), &viewer, SLOT(showFullScreen()));
    QObject::connect(viewer.rootObject(), SIGNAL(requestNormalSize()), &viewer, SLOT(showNormal()));
    ScreenSaver::instance().disable(); //restore in dtor
    return app.exec();
}
Exemplo n.º 8
0
void run_ui()
{

#ifdef SUBSURFACE_MOBILE
	QQmlApplicationEngine engine;
	register_qml_types(&engine);
	LOG_STP("run_ui qml engine started");
	KirigamiPlugin::getInstance().registerTypes();
#if defined(__APPLE__) && !defined(Q_OS_IOS)
	// when running the QML UI on a Mac the deployment of the QML Components seems
	// to fail and the search path for the components is rather odd - simply the
	// same directory the executable was started from <bundle>/Contents/MacOS/
	// To work around this we need to manually copy the components at install time
	// to Contents/Frameworks/qml and make sure that we add the correct import path
	const QStringList importPathList = engine.importPathList();
	for (QString importPath: importPathList) {
		if (importPath.contains("MacOS"))
			engine.addImportPath(importPath.replace("MacOS", "Frameworks"));
	}
	qDebug() << "QML import path" << engine.importPathList();
#endif // __APPLE__ not Q_OS_IOS
	engine.addImportPath("qrc://imports");
	DiveListModel diveListModel;
	LOG_STP("run_ui diveListModel started");
	DiveListSortModel *sortModel = new DiveListSortModel(0);
	sortModel->setSourceModel(&diveListModel);
	sortModel->setDynamicSortFilter(true);
	sortModel->setSortRole(DiveListModel::DiveDateRole);
	sortModel->sort(0, Qt::DescendingOrder);
	LOG_STP("run_ui diveListModel sorted");
	GpsListModel gpsListModel;
	QSortFilterProxyModel *gpsSortModel = new QSortFilterProxyModel(0);
	gpsSortModel->setSourceModel(&gpsListModel);
	gpsSortModel->setDynamicSortFilter(true);
	gpsSortModel->setSortRole(GpsListModel::GpsWhenRole);
	gpsSortModel->sort(0, Qt::DescendingOrder);
	QQmlContext *ctxt = engine.rootContext();
	ctxt->setContextProperty("diveModel", sortModel);
	ctxt->setContextProperty("gpsModel", gpsSortModel);
	ctxt->setContextProperty("vendorList", vendorList);
	set_non_bt_addresses();
	LOG_STP("run_ui set_non_bt_adresses");

	ctxt->setContextProperty("connectionListModel", &connectionListModel);
	ctxt->setContextProperty("logModel", MessageHandlerModel::self());

	engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
	LOG_STP("run_ui qml loaded");
	qqWindowObject = engine.rootObjects().value(0);
	if (!qqWindowObject) {
		fprintf(stderr, "can't create window object\n");
		exit(1);
	}
	QQuickWindow *qml_window = qobject_cast<QQuickWindow *>(qqWindowObject);
	qml_window->setIcon(QIcon(":subsurface-mobile-icon"));
	qDebug() << "qqwindow devicePixelRatio" << qml_window->devicePixelRatio() << qml_window->screen()->devicePixelRatio();
	QScreen *screen = qml_window->screen();
	QObject::connect(qml_window, &QQuickWindow::screenChanged, QMLManager::instance(), &QMLManager::screenChanged);
	QMLManager *manager = QMLManager::instance();
	LOG_STP("run_ui qmlmanager instance started");
	// now that the log file is initialized...
	show_computer_list();
	LOG_STP("run_ui show_computer_list");

	manager->setDevicePixelRatio(qml_window->devicePixelRatio(), qml_window->screen());
	manager->dlSortModel = sortModel;
	manager->qmlWindow = qqWindowObject;
	manager->screenChanged(screen);
	qDebug() << "qqwindow screen has ldpi/pdpi" << screen->logicalDotsPerInch() << screen->physicalDotsPerInch();
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
	qml_window->setHeight(1200);
	qml_window->setWidth(800);
#endif // not Q_OS_ANDROID and not Q_OS_IOS
	qml_window->show();
	LOG_STP("run_ui running exec");
#else
	MainWindow::instance()->show();
#endif // SUBSURFACE_MOBILE
	qApp->exec();
}
Exemplo n.º 9
0
int main(int argc, char *argv[])
{
    QOptions options(get_common_options());
    options.add("QMLPlayer options")
            ("scale", 1.0, "scale of graphics context. 0: auto")
            ;
    options.parse(argc, argv);
    if (options.value("help").toBool()) {
        options.print();
        return 0;
    }

    QGuiApplication app(argc, argv);
    QtQuick2ApplicationViewer viewer;
    qDebug(">>>>>>>>devicePixelRatio: %f", qApp->devicePixelRatio());
    QScreen *sc = app.primaryScreen();
    qDebug() << "dpi phy: " << sc->physicalDotsPerInch() << ", logical: " << sc->logicalDotsPerInch() << ", dpr: " << sc->devicePixelRatio()
                << "; vis rect:" << sc->virtualGeometry();
    // define a global var for js and qml
    viewer.engine()->rootContext()->setContextProperty("screenPixelDensity", qApp->primaryScreen()->physicalDotsPerInch()*qApp->primaryScreen()->devicePixelRatio());
    qreal r = sc->physicalDotsPerInch()/sc->logicalDotsPerInch();
    if (std::isinf(r) || std::isnan(r))
#if defined(Q_OS_ANDROID)
        r = 2.0;
#else
        r = 1.0;
#endif
    float sr = options.value("scale").toFloat();
    if (qFuzzyIsNull(sr))
        sr = r;
    viewer.engine()->rootContext()->setContextProperty("scaleRatio", sr);
    QString qml = "qml/QMLPlayer/main.qml";
    if (QFile(qApp->applicationDirPath() + "/" + qml).exists())
        qml.prepend(qApp->applicationDirPath() + "/");
    else
        qml.prepend("qrc:///");
    viewer.setMainQmlFile(qml);
    viewer.showExpanded();
    QOption op = options.option("width");
    if (op.isSet())
        viewer.setWidth(op.value().toInt());
    op = options.option("height");
    if (op.isSet())
        viewer.setHeight(op.value().toInt());
    op = options.option("x");
    if (op.isSet())
        viewer.setX(op.value().toInt());
    op = options.option("y");
    if (op.isSet())
        viewer.setY(op.value().toInt());
    if (options.value("fullscreen").toBool())
        viewer.showFullScreen();

    viewer.setTitle("QMLPlayer based on QtAV. [email protected]");
    /*
     * find root item, then root.init(argv). so we can deal with argv in qml
     */
#if 1
    QString json = app.arguments().join("\",\"");
    json.prepend("[\"").append("\"]");
    json.replace("\\", "/"); //FIXME
    QMetaObject::invokeMethod(viewer.rootObject(), "init", Q_ARG(QVariant, json));
//#else
    if (app.arguments().size() > 1) {
        qDebug("arguments > 1");
        QObject *player = viewer.rootObject()->findChild<QObject*>("player");
        QString file = options.value("file").toString();
        if (player && !file.isEmpty()) {
            if (QFile(file).exists())
                file.prepend("file://");
            file.replace("\\", "/"); //qurl
            QMetaObject::invokeMethod(player, "play", Q_ARG(QUrl, QUrl(file)));
        }
    }
#endif
    QObject::connect(viewer.rootObject(), SIGNAL(requestFullScreen()), &viewer, SLOT(showFullScreen()));
    QObject::connect(viewer.rootObject(), SIGNAL(requestNormalSize()), &viewer, SLOT(showNormal()));
    ScreenSaver::instance().disable(); //restore in dtor
    return app.exec();
}
qreal QWaylandMaterialDecoration::pixelDensity() const
{
    QScreen *screen = window()->screen();
    return screen->physicalDotsPerInch() / 25.4;
}
Exemplo n.º 11
0
float AdCtl_platform_interface::getDensity() const{
    QScreen *screen = qApp->primaryScreen();
    return screen->physicalDotsPerInch();
}