Beispiel #1
0
void tst_QGetPutEnv::getSetCheck()
{
    const char varName[] = "should_not_exist";

    QVERIFY(!qEnvironmentVariableIsSet(varName));
    QVERIFY(qEnvironmentVariableIsEmpty(varName));
    QByteArray result = qgetenv(varName);
    QCOMPARE(result, QByteArray());

#ifndef Q_OS_WIN
    QVERIFY(qputenv(varName, "")); // deletes varName instead of making it empty, on Windows

    QVERIFY(qEnvironmentVariableIsSet(varName));
    QVERIFY(qEnvironmentVariableIsEmpty(varName));
#endif

    QVERIFY(qputenv(varName, QByteArray("supervalue")));

    QVERIFY(qEnvironmentVariableIsSet(varName));
    QVERIFY(!qEnvironmentVariableIsEmpty(varName));
    result = qgetenv(varName);
    QVERIFY(result == "supervalue");

    qputenv(varName,QByteArray());

    // Now test qunsetenv
    QVERIFY(qunsetenv(varName));
    QVERIFY(!qEnvironmentVariableIsSet(varName));
    QVERIFY(qEnvironmentVariableIsEmpty(varName));
    result = qgetenv(varName);
    QCOMPARE(result, QByteArray());
}
Beispiel #2
0
void QXcbConnection::initializeXInput2()
{
    // TODO Qt 6 (or perhaps earlier): remove these redundant env variables
    if (qEnvironmentVariableIsSet("KIS_QT_XCB_DEBUG_XINPUT"))
        const_cast<QLoggingCategory&>(lcQpaXInput()).setEnabled(QtDebugMsg, true);
    if (qEnvironmentVariableIsSet("KIS_QT_XCB_DEBUG_XINPUT_DEVICES"))
        const_cast<QLoggingCategory&>(lcQpaXInputDevices()).setEnabled(QtDebugMsg, true);
    Display *xDisplay = static_cast<Display *>(m_xlib_display);
    if (XQueryExtension(xDisplay, "XInputExtension", &m_xiOpCode, &m_xiEventBase, &m_xiErrorBase)) {
        int xiMajor = 2;
        m_xi2Minor = 2; // try 2.2 first, needed for TouchBegin/Update/End
        if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) {
            m_xi2Minor = 1; // for smooth scrolling 2.1 is enough
            if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) {
                m_xi2Minor = 0; // for tablet support 2.0 is enough
                m_xi2Enabled = XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) != BadRequest;
            } else
                m_xi2Enabled = true;
        } else
            m_xi2Enabled = true;
        if (m_xi2Enabled) {
#ifdef XCB_USE_XINPUT22
            qCDebug(lcQpaXInputDevices, "XInput version %d.%d is available and Qt supports 2.2 or greater", xiMajor, m_xi2Minor);
#else
            qCDebug(lcQpaXInputDevices, "XInput version %d.%d is available and Qt supports 2.0", xiMajor, m_xi2Minor);
#endif
        }

        xi2SetupDevices();
    }
}
Beispiel #3
0
/**
 * Program entry point.
 *
 * @param argc amount of command line arguments
 * @param argv command line arguments
 * @return @c 0 on successful exit
 */
int main(int argc, char** argv)
{
#if !defined(Q_OS_MAC)
	if (!qEnvironmentVariableIsSet("QT_DEVICE_PIXEL_RATIO")
			&& !qEnvironmentVariableIsSet("QT_AUTO_SCREEN_SCALE_FACTOR")
			&& !qEnvironmentVariableIsSet("QT_SCALE_FACTOR")
			&& !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) {
		QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
	}
#endif
	QApplication app(argc, argv);
	app.setApplicationName("Simsu");
	app.setApplicationVersion(VERSIONSTR);
	app.setApplicationDisplayName(Window::tr("Simsu"));
	app.setOrganizationDomain("gottcode.org");
	app.setOrganizationName("GottCode");
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
	app.setWindowIcon(QIcon::fromTheme("simsu", QIcon(":/simsu.png")));
	app.setDesktopFileName("simsu");
#endif
	app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);

	LocaleDialog::loadTranslator("simsu_");

	Window window;
	window.show();

	return app.exec();
}
Beispiel #4
0
QPCSC::QPCSC()
	: d( new QPCSCPrivate )
{
	const_cast<QLoggingCategory&>(SCard()).setEnabled(QtDebugMsg, qEnvironmentVariableIsSet("PCSC_DEBUG"));
	const_cast<QLoggingCategory&>(APDU()).setEnabled(QtDebugMsg, qEnvironmentVariableIsSet("APDU_DEBUG"));
	serviceRunning();
}
void CompositorLauncher::detectMode()
{
    // Can't detect mode when it was forced by arguments
    if (m_mode != UnknownMode)
        return;

    // Detect Wayland
    if (qEnvironmentVariableIsSet("WAYLAND_DISPLAY")) {
        m_mode = WaylandMode;
        return;
    }

    // Detect X11
    if (qEnvironmentVariableIsSet("DISPLAY")) {
        m_mode = X11Mode;
        return;
    }

    // Detect eglfs since Qt 5.5
    if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_INTEGRATION") || m_hardware != UnknownHardware) {
        m_mode = EglFSMode;
        return;
    }

    // Default to unknown mode
    m_mode = UnknownMode;
}
Beispiel #6
0
static const char *setHighDpiEnvironmentVariable() {
    const char *envVarName = 0;
    static const char ENV_VAR_QT_DEVICE_PIXEL_RATIO[] = "QT_DEVICE_PIXEL_RATIO";

#ifdef Q_OS_WIN
    bool isWindows = true;
#else
    bool isWindows = false;
#endif

#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0))
    if (isWindows
        && !qEnvironmentVariableIsSet(ENV_VAR_QT_DEVICE_PIXEL_RATIO)) {
        envVarName = ENV_VAR_QT_DEVICE_PIXEL_RATIO;
        qputenv(envVarName, "auto");
    }

#else
    if (isWindows
        && !qEnvironmentVariableIsSet(ENV_VAR_QT_DEVICE_PIXEL_RATIO)     // legacy in 5.6, but still functional
        && !qEnvironmentVariableIsSet("QT_AUTO_SCREEN_SCALE_FACTOR")
        && !qEnvironmentVariableIsSet("QT_SCALE_FACTOR")
        && !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    }

#endif // < Qt 5.6
    return envVarName;
}
Beispiel #7
0
bool MainWindow::mobileMode() const
{
#ifdef Q_OS_ANDROID
	static bool mobile_mode = qEnvironmentVariableIsSet("MAPPER_MOBILE_GUI")
	                          ? (qgetenv("MAPPER_MOBILE_GUI") != "0")
	                          : 1;
#else
	static bool mobile_mode = qEnvironmentVariableIsSet("MAPPER_MOBILE_GUI")
	                          ? (qgetenv("MAPPER_MOBILE_GUI") != "0")
	                          : 0;
#endif
	return mobile_mode;
}
/*!
    Creates and returns a source with the specified \a parent that reads
    from the system's default source of satellite update information, or the
    highest priority available plugin.

    Returns 0 if the system has no default satellite source, no valid plugins
    could be found or the user does not have the permission to access the satellite data.
*/
QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createDefaultSource(QObject *parent)
{
    QList<QJsonObject> plugins = QGeoPositionInfoSourcePrivate::pluginsSorted();
    foreach (const QJsonObject &obj, plugins) {
        if (obj.value(QStringLiteral("Satellite")).isBool()
                && obj.value(QStringLiteral("Satellite")).toBool())
        {
            const QString testableKey = QStringLiteral("Testable");
            if (obj.contains(testableKey) && !obj.value(testableKey).toBool()) {
                static bool inTest = qEnvironmentVariableIsSet("QT_QTESTLIB_RUNNING");
                if (inTest)
                    continue;
            }
            QGeoPositionInfoSourcePrivate d;
            d.metaData = obj;
            d.loadPlugin();
            QGeoSatelliteInfoSource *s = 0;
            if (d.factory)
                s = d.factory->satelliteInfoSource(parent);
            if (s)
                s->d->providerName = d.metaData.value(QStringLiteral("Provider")).toString();
            return s;
        }
    }

    return 0;
}
Beispiel #9
0
void KCrash::initialize()
{
    if (s_launchDrKonqi == 0) { // disabled by the program itself
        return;
    }
    const QStringList args = QCoreApplication::arguments();
    if (!qEnvironmentVariableIsSet("KDE_DEBUG")
        && !qEnvironmentVariableIsSet("KCRASH_AUTO_RESTARTED")) {
        // enable drkonqi
        KCrash::setDrKonqiEnabled(true);
    }

    KCrash::setApplicationFilePath(QCoreApplication::applicationFilePath());

    s_coreConfig(); // Initialize.
}
Beispiel #10
0
    OpenFileResult showOpenFile() const
    {
        QUrl dir;
        if ( controller->activeDocument() ) {
            dir = controller->activeDocument()->url().adjusted(QUrl::RemoveFilename);
        } else  {
            const auto cfg = KSharedConfig::openConfig()->group("Open File");
            dir = cfg.readEntry( "Last Open File Directory", Core::self()->projectController()->projectsBaseDirectory() );
        }

        const auto caption = i18n("Open File");
        const auto filter = i18n("*|Text File\n");
        auto parent = Core::self()->uiControllerInternal()->defaultMainWindow();

        // use special dialogs in a KDE session, native dialogs elsewhere
        if (qEnvironmentVariableIsSet("KDE_FULL_SESSION")) {
            const auto result = KEncodingFileDialog::getOpenUrlsAndEncoding(QString(), dir,
                filter, parent, caption);
            return {result.URLs, result.encoding};
        }

        // note: can't just filter on text files using the native dialog, just display all files
        // see https://phabricator.kde.org/D622#11679
        const auto urls = QFileDialog::getOpenFileUrls(parent, caption, dir);
        return {urls, QString()};
    }
FileInfo RemoteFileInfoGatherer::getInfo(const QString &path)
{
    QFileInfo finfo(path);
    FileInfo info = toFileInfo(finfo);
#if 0
    info.icon = m_iconProvider->icon(path);
    info.displayType = m_iconProvider->type(path);
#endif
#ifndef QT_NO_FILESYSTEMWATCHER
    // ### Not ready to listen all modifications by default
    static const bool watchFiles = qEnvironmentVariableIsSet("QT_FILESYSTEMMODEL_WATCH_FILES");
    if (watchFiles) {
        if (!finfo.exists() && !finfo.isSymLink()) {
            watcher->removePath(finfo.absoluteFilePath());
        } else {
            const QString path = finfo.absoluteFilePath();
            if (!path.isEmpty() && finfo.exists() && finfo.isFile() && finfo.isReadable()
                && !watcher->files().contains(path)) {
                watcher->addPath(path);
            }
        }
    }
#endif

#ifdef Q_OS_WIN
    if (m_resolveSymlinks && info.isSymLink(/* ignoreNtfsSymLinks = */ true)) {
        QFileInfo resolvedInfo(finfo.symLinkTarget());
        resolvedInfo = resolvedInfo.canonicalFilePath();
        if (resolvedInfo.exists()) {
            emit nameResolved(finfo.filePath(), resolvedInfo.fileName());
        }
    }
#endif
    return info;
}
Beispiel #12
0
// We have the a11y registry on the session bus.
// Subscribe to updates about a11y enabled state.
// Find out the bus address
void DBusConnection::serviceRegistered()
{
    // listen to enabled changes
    QDBusConnection c = QDBusConnection::sessionBus();
    OrgA11yStatusInterface *a11yStatus = new OrgA11yStatusInterface(A11Y_SERVICE, A11Y_PATH, c, this);

    //The variable was introduced because on some embedded platforms there are custom accessibility
    //clients which don't set Status.ScreenReaderEnabled to true. The variable is also useful for
    //debugging.
    static const bool a11yAlwaysOn = qEnvironmentVariableIsSet("QT_LINUX_ACCESSIBILITY_ALWAYS_ON");

    // a11yStatus->isEnabled() returns always true (since Gnome 3.6)
    bool enabled = a11yAlwaysOn || a11yStatus->screenReaderEnabled();

    if (enabled != m_enabled) {
        m_enabled = enabled;
        if (m_a11yConnection.isConnected()) {
            emit enabledChanged(m_enabled);
        } else {
            QDBusConnection c = QDBusConnection::sessionBus();
            QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String("org.a11y.Bus"),
                             QLatin1String("/org/a11y/bus"),
                             QLatin1String("org.a11y.Bus"), QLatin1String("GetAddress"));
            c.callWithCallback(m, this, SLOT(connectA11yBus(QString)), SLOT(dbusError(QDBusError)));
        }
    }

    //    connect(a11yStatus, ); QtDbus doesn't support notifications for property changes yet
}
void QWaylandIntegration::initializeServerBufferIntegration()
{
    mServerBufferIntegrationInitialized = true;

    QString targetKey;

    bool disableHardwareIntegration = qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_HW_INTEGRATION");
    disableHardwareIntegration = disableHardwareIntegration || !mDisplay->hardwareIntegration();
    if (disableHardwareIntegration) {
        QByteArray serverBufferIntegrationName = qgetenv("QT_WAYLAND_SERVER_BUFFER_INTEGRATION");
        QString targetKey = QString::fromLocal8Bit(serverBufferIntegrationName);
    } else {
        targetKey = mDisplay->hardwareIntegration()->serverBufferIntegration();
    }

    if (targetKey.isEmpty()) {
        qWarning("Failed to determine what server buffer integration to use");
        return;
    }

    QStringList keys = QWaylandServerBufferIntegrationFactory::keys();
    if (keys.contains(targetKey)) {
        mServerBufferIntegration = QWaylandServerBufferIntegrationFactory::create(targetKey, QStringList());
    }
    if (mServerBufferIntegration)
        mServerBufferIntegration->initialize(mDisplay);
    else
        qWarning("Failed to load server buffer integration %s\n", qPrintable(targetKey));
}
Beispiel #14
0
QString TableGenerator::findComposeFile()
{
    // check if XCOMPOSEFILE points to a Compose file
    if (qEnvironmentVariableIsSet("XCOMPOSEFILE")) {
        const QString path = QFile::decodeName(qgetenv("XCOMPOSEFILE"));
        if (QFile::exists(path))
            return path;
        else
            qWarning("$XCOMPOSEFILE doesn't point to an existing file");
    }

    // check if user’s home directory has a file named .XCompose
    if (cleanState()) {
        QString path = qgetenv("HOME") + QLatin1String("/.XCompose");
        if (QFile::exists(path))
            return path;
    }

    // check for the system provided compose files
    if (cleanState()) {
        QString table = composeTableForLocale();
        if (cleanState()) {
            if (table.isEmpty())
                // no table mappings for the system's locale in the compose.dir
                m_state = UnsupportedLocale;
            else {
                QString path = QDir(systemComposeDir()).filePath(table);
                if (QFile::exists(path))
                    return path;
            }
        }
    }
    return QString();
}
void QWaylandIntegration::initializeClientBufferIntegration()
{
    mClientBufferIntegrationInitialized = true;

    QString targetKey;
    bool disableHardwareIntegration = qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_HW_INTEGRATION");
    disableHardwareIntegration = disableHardwareIntegration || !mDisplay->hardwareIntegration();
    if (disableHardwareIntegration) {
        QByteArray clientBufferIntegrationName = qgetenv("QT_WAYLAND_CLIENT_BUFFER_INTEGRATION");
        if (clientBufferIntegrationName.isEmpty())
            clientBufferIntegrationName = QByteArrayLiteral("wayland-egl");
        targetKey = QString::fromLocal8Bit(clientBufferIntegrationName);
    } else {
        targetKey = mDisplay->hardwareIntegration()->clientBufferIntegration();
    }

    if (targetKey.isEmpty()) {
        qWarning("Failed to determine what client buffer integration to use");
        return;
    }

    QStringList keys = QWaylandClientBufferIntegrationFactory::keys();
    if (keys.contains(targetKey)) {
        mClientBufferIntegration = QWaylandClientBufferIntegrationFactory::create(targetKey, QStringList());
    }
    if (mClientBufferIntegration)
        mClientBufferIntegration->initialize(mDisplay);
    else
        qWarning("Failed to load client buffer integration: %s\n", qPrintable(targetKey));
}
Beispiel #16
0
QByteArray QXcbIntegration::wmClass() const
{
    if (m_wmClass.isEmpty()) {
        // Instance name according to ICCCM 4.1.2.5
        QString name;
        if (m_instanceName)
            name = QString::fromLocal8Bit(m_instanceName);
        if (name.isEmpty() && qEnvironmentVariableIsSet(resourceNameVar))
            name = QString::fromLocal8Bit(qgetenv(resourceNameVar));
        if (name.isEmpty())
            name = argv0BaseName();

        // Note: QCoreApplication::applicationName() cannot be called from the QGuiApplication constructor,
        // hence this delayed initialization.
        QString className = QCoreApplication::applicationName();
        if (className.isEmpty()) {
            className = argv0BaseName();
            if (!className.isEmpty() && className.at(0).isLower())
                className[0] = className.at(0).toUpper();
        }

        if (!name.isEmpty() && !className.isEmpty()) {
            m_wmClass = name.toLocal8Bit();
            m_wmClass.append('\0');
            m_wmClass.append(className.toLocal8Bit());
            m_wmClass.append('\0');
        }
    }
    return m_wmClass;
}
QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedRenderer()
{
#ifndef Q_OS_WINCE
    const char openGlVar[] = "QT_OPENGL";
    if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES)) {
        const Renderer glesRenderer = QWindowsOpenGLTester::requestedGlesRenderer();
        return glesRenderer != InvalidRenderer ? glesRenderer : Gles;
    }
    if (QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL))
        return QWindowsOpenGLTester::DesktopGl;
    if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL))
        return QWindowsOpenGLTester::SoftwareRasterizer;
    if (qEnvironmentVariableIsSet(openGlVar)) {
        const QByteArray requested = qgetenv(openGlVar);
        if (requested == "angle") {
            const Renderer glesRenderer = QWindowsOpenGLTester::requestedGlesRenderer();
            return glesRenderer != InvalidRenderer ? glesRenderer : Gles;
        }
        if (requested == "desktop")
            return QWindowsOpenGLTester::DesktopGl;
        if (requested == "software")
            return QWindowsOpenGLTester::SoftwareRasterizer;
        qCWarning(lcQpaGl) << "Invalid value set for " << openGlVar << ": " << requested;
    }
#endif // !Q_OS_WINCE
    return QWindowsOpenGLTester::InvalidRenderer;
}
Beispiel #18
0
bool uwsgiProcess::run(const QString &appFilename, int port, bool restart)
{
    QDir projectDir;
    if (!uwsgiProcess::findProjectDir(QDir::current(), &projectDir)) {
        qDebug() << "Error: failed to find project";
        return false;
    }

    QString localFilename = appFilename;
    if (localFilename.isEmpty()) {
        localFilename = findApplication(projectDir);
    }

    QFileInfo fileInfo(localFilename);
    if (!fileInfo.exists()) {
        qDebug() << "Error: Application file not found";
        return false;
    }

    QStringList args;
    args.append(QStringLiteral("--http-socket"));
    args.append(QLatin1String(":") % QString::number(port));

    args.append(QStringLiteral("--chdir"));
    args.append(projectDir.absolutePath());

    args.append(QStringLiteral("-M"));

    args.append(QStringLiteral("--plugin"));
    args.append(QStringLiteral("cutelyst"));

    args.append(QStringLiteral("--cutelyst-app"));
    args.append(localFilename);

    if (restart) {
        args.append(QStringLiteral("--lazy"));
        args.append(QStringLiteral("--touch-reload"));
        args.append(localFilename);
    }

#ifdef Q_OS_UNIX
    if (setup_unix_signal_handlers()) {
        return false;
    }
#endif

    qDebug() << "Running: uwsgi" << args.join(QStringLiteral(" ")).toLatin1().data();

    // Enable loggin if restart is set
    if (restart && !qEnvironmentVariableIsSet("QT_LOGGING_RULES")) {
        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
        env.insert(QStringLiteral("QT_LOGGING_RULES"), QStringLiteral("cutelyst.*=true"));
        m_proc->setProcessEnvironment(env);
    }

    m_proc->start(QStringLiteral("uwsgi"), args);

    return true;
}
Beispiel #19
0
static QString resolveHandler(const QString &scheme)
{
    QString candidatePath = QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/kpackagehandlers/%1handler").arg(scheme);
    if (qEnvironmentVariableIsSet("KPACKAGE_DEP_RESOLVERS_PATH")) {
        candidatePath = QStringLiteral("%1/%2handler").arg(qgetenv("KPACKAGE_DEP_RESOLVERS_PATH"), scheme);
    }
    return QFile::exists(candidatePath) ? candidatePath : QString();
}
Beispiel #20
0
Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    QVBoxLayout *layout = new QVBoxLayout;
    QSplitter *vsplit = new QSplitter(Qt::Vertical);
    layout->addWidget(vsplit);

    QSplitter *hsplit = new QSplitter;

    QVBoxLayout *settingsLayout = new QVBoxLayout;
    addVersions(settingsLayout);
    addProfiles(settingsLayout);
    addOptions(settingsLayout);
    addRenderableTypes(settingsLayout);
    hsplit->addWidget(widgetWithLayout(settingsLayout));

    QVBoxLayout *outputLayout = new QVBoxLayout;
    m_output = new QTextEdit;
    m_output->setReadOnly(true);
    outputLayout->addWidget(m_output);
    m_extensions = new QTextEdit;
    m_extensions->setReadOnly(true);
    outputLayout->addWidget(m_extensions);
    hsplit->addWidget(widgetWithLayout(outputLayout));

    hsplit->setStretchFactor(0, 4);
    hsplit->setStretchFactor(1, 6);
    vsplit->addWidget(hsplit);

    m_renderWindowLayout = new QVBoxLayout;
    vsplit->addWidget(widgetWithLayout(m_renderWindowLayout));
    vsplit->setStretchFactor(1, 5);

    m_renderWindowContainer = new QWidget;
    addRenderWindow();

    QString description;
    QTextStream str(&description);
    str << "Qt " << QT_VERSION_STR << ' ' << QGuiApplication::platformName();
    const char *openGlVariables[] =
        {"QT_ANGLE_PLATFORM", "QT_OPENGL", "QT_OPENGL_BUGLIST", "QT_OPENGL_DLL"};
    const size_t variableCount = sizeof(openGlVariables) / sizeof(openGlVariables[0]);
    for (size_t v = 0; v < variableCount; ++v) {
        if (qEnvironmentVariableIsSet(openGlVariables[v]))
            str << ' ' << openGlVariables[v] << '=' << qgetenv(openGlVariables[v]);
    }
    if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES))
        str << " Qt::AA_UseOpenGLES";
    if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL))
        str << " Qt::AA_UseSoftwareOpenGL";
    if (QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL))
        str << " Qt::AA_UseSoftwareOpenGL";
    layout->addWidget(new QLabel(description));

    setLayout(layout);
}
QT_BEGIN_NAMESPACE

static float qt_sg_envFloat(const char *name, float defaultValue)
{
    if (Q_LIKELY(!qEnvironmentVariableIsSet(name)))
        return defaultValue;
    bool ok = false;
    const float value = qgetenv(name).toFloat(&ok);
    return ok ? value : defaultValue;
}
Beispiel #22
0
bool QPCSCReader::isPinPad() const
{
	if(d->reader.contains("HID Global OMNIKEY 3x21 Smart Card Reader") ||
		d->reader.contains("HID Global OMNIKEY 6121 Smart Card Reader"))
		return false;
	if(qEnvironmentVariableIsSet("SMARTCARDPP_NOPINPAD"))
		return false;
	QHash<DRIVER_FEATURES,quint32> features = d->features();
	return features.contains(FEATURE_VERIFY_PIN_DIRECT) || features.contains(FEATURE_VERIFY_PIN_START);
}
Beispiel #23
0
void qdbus_unloadLibDBus()
{
    if (qdbus_libdbus) {
        if (qEnvironmentVariableIsSet("QDBUS_FORCE_SHUTDOWN"))
            qdbus_libdbus->resolve("dbus_shutdown")();
        qdbus_libdbus->unload();
    }
    delete qdbus_libdbus;
    qdbus_libdbus = 0;
}
QMinimal_i2cIntegration::QMinimal_i2cIntegration(const QStringList &)
          : m_fontDb(new QGenericUnixFontDatabase()) {
    if (qEnvironmentVariableIsSet(debugBackingStoreEnvironmentVariable)
        && qgetenv(debugBackingStoreEnvironmentVariable).toInt() > 0) {
        m_options |= DebugBackingStore;
    }

    mPrimaryScreen = new QMinimal_i2cScreen();
    screenAdded(mPrimaryScreen);
}
bool QQuickControlSettings::isMobile() const
{
#if defined(Q_OS_IOS) || defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_QNX) || defined(Q_OS_WINRT)
    return true;
#else
    if (qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MOBILE")) {
        return true;
    }
    return false;
#endif
}
Beispiel #26
0
void QSGContext::renderContextInitialized(QSGRenderContext *renderContext)
{
    Q_D(QSGContext);

    d->mutex.lock();
    if (d->antialiasingMethod == UndecidedAntialiasing) {
        if (Q_UNLIKELY(qEnvironmentVariableIsSet("QSG_ANTIALIASING_METHOD"))) {
            const QByteArray aaType = qgetenv("QSG_ANTIALIASING_METHOD");
            if (aaType == "msaa")
                d->antialiasingMethod = MsaaAntialiasing;
            else if (aaType == "vertex")
                d->antialiasingMethod = VertexAntialiasing;
        }
        if (d->antialiasingMethod == UndecidedAntialiasing) {
            if (renderContext->openglContext()->format().samples() > 0)
                d->antialiasingMethod = MsaaAntialiasing;
            else
                d->antialiasingMethod = VertexAntialiasing;
        }
    }

    // With OpenGL ES, except for Angle on Windows, use GrayAntialiasing, unless
    // some value had been requested explicitly. This could not be decided
    // before without a context. Now the context is ready.
    if (!d->distanceFieldAntialiasingDecided) {
        d->distanceFieldAntialiasingDecided = true;
#ifndef Q_OS_WIN32
        if (renderContext->openglContext()->isOpenGLES())
            d->distanceFieldAntialiasing = QSGGlyphNode::GrayAntialiasing;
#endif
    }

    static bool dumped = false;
    if (!dumped && QSG_LOG_INFO().isDebugEnabled()) {
        dumped = true;
        QSurfaceFormat format = renderContext->openglContext()->format();
        QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
        qCDebug(QSG_LOG_INFO) << "R/G/B/A Buffers:   " << format.redBufferSize() << format.greenBufferSize() << format.blueBufferSize() << format.alphaBufferSize();
        qCDebug(QSG_LOG_INFO) << "Depth Buffer:      " << format.depthBufferSize();
        qCDebug(QSG_LOG_INFO) << "Stencil Buffer:    " << format.stencilBufferSize();
        qCDebug(QSG_LOG_INFO) << "Samples:           " << format.samples();
        qCDebug(QSG_LOG_INFO) << "GL_VENDOR:         " << (const char *) funcs->glGetString(GL_VENDOR);
        qCDebug(QSG_LOG_INFO) << "GL_RENDERER:       " << (const char *) funcs->glGetString(GL_RENDERER);
        qCDebug(QSG_LOG_INFO) << "GL_VERSION:        " << (const char *) funcs->glGetString(GL_VERSION);
        QSet<QByteArray> exts = renderContext->openglContext()->extensions();
        QByteArray all; foreach (const QByteArray &e, exts) all += ' ' + e;
        qCDebug(QSG_LOG_INFO) << "GL_EXTENSIONS:    " << all.constData();
        qCDebug(QSG_LOG_INFO) << "Max Texture Size: " << renderContext->maxTextureSize();
        qCDebug(QSG_LOG_INFO) << "Debug context:    " << format.testOption(QSurfaceFormat::DebugContext);
    }
Beispiel #27
0
void KSecretServiceTest::setupKeyring()
{
    const char* KSS_TEST_USER = "******";
    QVERIFY(qEnvironmentVariableIsSet(KSS_TEST_USER));
    QVERIFY(!qEnvironmentVariableIsEmpty(KSS_TEST_USER));
    auto testUser = qgetenv(KSS_TEST_USER);

    const char* KSS_TEST_PASSWORD = "******";
    QVERIFY(qEnvironmentVariableIsSet(KSS_TEST_PASSWORD));
    QVERIFY(!qEnvironmentVariableIsEmpty(KSS_TEST_PASSWORD));
    auto testPass = qgetenv(KSS_TEST_PASSWORD);

    const char* KEYNAME_ENCRYPTING = "ksecrets-test:encrypting";
    const char* KEYNAME_MAC = "ksecrets-test:mac";

    /* second prevention measure - change keyring keynames */
    sharedConfig->group(QLatin1String("keyring"))
        .writeEntry("keyname_encrypt", KEYNAME_ENCRYPTING);
    sharedConfig->group(QLatin1String("keyring"))
        .writeEntry("keyname_mac", KEYNAME_MAC);

    /* third prevention measure - the encrypting key should not be present
     * into the kernel keyring */
    key_serial_t key;
    key = request_key("user", KEYNAME_ENCRYPTING, 0, KEY_SPEC_SESSION_KEYRING);
    QVERIFY(-1 == key);

    /* now go setup user's keyring */
    QVERIFY(1 == kss_set_credentials(testUser.constData(), testPass.constData(), secretsFilePath.toLocal8Bit().constData()));

    // the right keys should be present into the kernel keyring
    key = request_key("user", KEYNAME_ENCRYPTING, 0, KEY_SPEC_SESSION_KEYRING);
    QVERIFY(-1 != key);
    key = request_key("user", KEYNAME_MAC, 0, KEY_SPEC_SESSION_KEYRING);
    QVERIFY(-1 != key);
}
Beispiel #28
0
// Suggest a scale factor by checking monitor sizes.
int QWindowsScaling::determineUiScaleFactor()
{
    if (!qEnvironmentVariableIsSet(devicePixelRatioEnvVar))
        return 1;
    const QByteArray envDevicePixelRatioEnv = qgetenv(devicePixelRatioEnvVar);
    // Auto: Suggest a scale factor by checking monitor resolution.
    if (envDevicePixelRatioEnv == "auto") {
        const int maxResolution = QWindowsScreen::maxMonitorHorizResolution();
        return maxResolution > 180 ? maxResolution / 96 : 1;
    }
    // Get factor from environment
    bool ok = false;
    const int envFactor = envDevicePixelRatioEnv.toInt(&ok);
    return ok && envFactor > 0 ? envFactor : 1;
}
void TableGenerator::findComposeFile()
{
    bool found = false;
    // check if XCOMPOSEFILE points to a Compose file
    if (qEnvironmentVariableIsSet("XCOMPOSEFILE")) {
        QString composeFile(qgetenv("XCOMPOSEFILE"));
        if (composeFile.endsWith(QLatin1String("Compose")))
            found = processFile(composeFile);
        else
            qWarning("Qt Warning: XCOMPOSEFILE doesn't point to a valid Compose file");
#ifdef DEBUG_GENERATOR
        if (found)
            qDebug() << "Using Compose file from: " << composeFile;
#endif
    }
    // check if user’s home directory has a file named .XCompose
    if (!found && cleanState()) {
        QString composeFile = qgetenv("HOME") + QStringLiteral("/.XCompose");
        if (QFile(composeFile).exists())
            found = processFile(composeFile);
#ifdef DEBUG_GENERATOR
        if (found)
            qDebug() << "Using Compose file from: " << composeFile;
#endif
    }
    // check for the system provided compose files
    if (!found && cleanState()) {
        QString table = composeTableForLocale();
        if (cleanState()) {
            if (table.isEmpty())
                // no table mappings for the system's locale in the compose.dir
                m_state = UnsupportedLocale;
            else
                found = processFile(systemComposeDir() + QLatin1Char('/') + table);
#ifdef DEBUG_GENERATOR
            if (found)
                qDebug() << "Using Compose file from: " <<
                            systemComposeDir() + QLatin1Char('/') + table;
#endif
        }
    }

    if (found && m_composeTable.isEmpty())
        m_state = EmptyTable;

    if (!found)
        m_state = MissingComposeFile;
}
void SessionManager::setupEnvironment()
{
    // Set paths only if we are installed onto a non standard location
    QString path;

    if (qEnvironmentVariableIsSet("PATH")) {
        path = QStringLiteral("%1:%2").arg(INSTALL_BINDIR).arg(QString(qgetenv("PATH")));
        qputenv("PATH", path.toUtf8());
    }

    if (qEnvironmentVariableIsSet("QT_PLUGIN_PATH")) {
        path = QStringLiteral("%1:%2").arg(INSTALL_PLUGINDIR).arg(QString(qgetenv("QT_PLUGIN_PATH")));
        qputenv("QT_PLUGIN_PATH", path.toUtf8());
    }

    if (qEnvironmentVariableIsSet("QML2_IMPORT_PATH")) {
        path = QStringLiteral("%1:%2").arg(INSTALL_QMLDIR).arg(QString(qgetenv("QML2_IMPORT_PATH")));
        qputenv("QML2_IMPORT_PATH", path.toUtf8());
    }

    if (qEnvironmentVariableIsSet("XDG_DATA_DIRS")) {
        path = QStringLiteral("%1:%2").arg(INSTALL_DATADIR).arg(QString(qgetenv("XDG_DATA_DIRS")));
        qputenv("XDG_DATA_DIRS", path.toUtf8());
    }

    if (qEnvironmentVariableIsSet("XDG_CONFIG_DIRS")) {
        path = QStringLiteral("%1:%2:/etc/xdg").arg(INSTALL_CONFIGDIR).arg(QString(qgetenv("XDG_CONFIG_DIRS")));
        qputenv("XDG_CONFIG_DIRS", path.toUtf8());
    }

    if (qEnvironmentVariableIsSet("XCURSOR_PATH")) {
       path = QStringLiteral("%1:%2").arg(INSTALL_DATADIR "/icons").arg(QString(qgetenv("XCURSOR_PATH")));
        qputenv("XCURSOR_PATH", path.toUtf8());
    }

    // Set XDG environment variables
    if (qEnvironmentVariableIsEmpty("XDG_DATA_HOME")) {
        QString path = QStringLiteral("%1/.local/share").arg(QString(qgetenv("HOME")));
        qputenv("XDG_DATA_HOME", path.toUtf8());
    }
    if (qEnvironmentVariableIsEmpty("XDG_CONFIG_HOME")) {
        QString path = QStringLiteral("%1/.config").arg(QString(qgetenv("HOME")));
        qputenv("XDG_CONFIG_HOME", path.toUtf8());
    }

    // Set platform integration
    qputenv("SAL_USE_VCLPLUGIN", QByteArray("kde"));
//    qputenv("QT_PLATFORM_PLUGIN", QByteArray("Material"));
//    qputenv("QT_QPA_PLATFORMTHEME", QByteArray("Material"));
//    qputenv("QT_QUICK_CONTROLS_STYLE", QByteArray("Material"));
    // qputenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", QByteArray("1"));
//    qputenv("XDG_CURRENT_DESKTOP", QByteArray("U2T"));
//    qputenv("XCURSOR_THEME", QByteArray("Adwaita"));
//    qputenv("XCURSOR_SIZE", QByteArray("16"));
}