示例#1
0
void MainWindow::on_about()
{
	QCoreApplication * app = QCoreApplication::instance();
	QMessageBox::about(this, app->applicationName(), app->applicationName()
			+ ": example of Qt using marnav\n\nVersion: " + app->applicationVersion()
			+ "\n\nSee file: LICENSE");
}
KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url)
{
    QString parentApp;
    QCoreApplication *app = QCoreApplication::instance();
    if (app) {
        parentApp = app->applicationName();
    }

    auto filter = [&parentApp](const KPluginMetaData &md) -> bool
    {
        const QString pa = md.value(QStringLiteral("X-KDE-ParentApp"));
        return (pa.isEmpty() || pa == parentApp) && !md.value(QStringLiteral("X-Plasma-DropUrlPatterns")).isEmpty();
    };
    KPluginInfo::List allApplets =  KPluginInfo::fromMetaData(KPackage::PackageLoader::self()->findPackages("Plasma/Applet", QString(), filter).toVector());

    KPluginInfo::List filtered;
    foreach (const KPluginInfo &info, allApplets) {
        QStringList urlPatterns = info.property("X-Plasma-DropUrlPatterns").toStringList();
        foreach (const QString &glob, urlPatterns) {
            QRegExp rx(glob);
            rx.setPatternSyntax(QRegExp::Wildcard);
            if (rx.exactMatch(url.toString())) {
#ifndef NDEBUG
                // qCDebug(LOG_PLASMA) << info.name() << "matches" << glob << url;
#endif
                filtered << info;
            }
        }
示例#3
0
void MainWindow::getMayaWindow()
{
    QCoreApplication*  app = qApp;
    if (app) {
        cout << "Application name is '" << app->applicationName().toStdString() << "'" << endl;
    }
    else
    {
        cout << "No maya app detected: " << app << endl;
    }
}
示例#4
0
void MainWindow::on_about_qt()
{
	QCoreApplication * app = QCoreApplication::instance();
	QMessageBox::aboutQt(this, app->applicationName());
}
示例#5
0
QSqlDatabase SObjectManager::Private::connection()
{
    if (!mConnection.isValid()) {
        QString databasePath;
        QCoreApplication *a = QCoreApplication::instance();

        QString orgName = a->organizationName();
        QString appName = a->applicationName();

        a->setOrganizationName(QLatin1String("saesu"));
        a->setApplicationName(QLatin1String("clouds"));

        databasePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);

        QDir dirPath(databasePath);
        if (!dirPath.exists())
            dirPath.mkpath(databasePath);


        // restore app name/org details
        a->setOrganizationName(orgName);
        a->setApplicationName(appName);

        mConnection = QSqlDatabase::addDatabase("QSQLITE", QLatin1String("saesu-cloud://") + mTableName);
        mConnection.setDatabaseName(databasePath + "/" + mTableName);
        if (!mConnection.open()) {
            // TODO: error handling
            sWarning() << "Couldn't open database";
            return mConnection;
        }

        const int currentDbVersion = 3;

        // TODO: make this work with multiple ObjectManagers
        if (!mConnection.tables().contains("_saesu")) {
            QSqlQuery q(mConnection);
            mConnection.transaction();

            // create table(s)
            sDebug() << "Creating tables";

            q.exec("CREATE TABLE _saesu (version integer)");
            q.exec("INSERT INTO _saesu VALUES (" + QString::number(currentDbVersion) + ")");
            q.exec("CREATE TABLE objects (key primary key, timestamp integer, hash blob, object blob)");
            q.exec("CREATE TABLE deletelist (key primary key, timestamp integer)");

            mConnection.commit();
        } else {
            QSqlQuery q(mConnection);
            mConnection.transaction();

            sDebug() << "Checking for migration";
            q.exec("SELECT version FROM _saesu");
            q.next();
            qint64 dbVersion = q.value(0).toLongLong();
            
            switch (dbVersion) {
                case currentDbVersion:
                    sDebug() << "Database up to date";
                    break;
                case 1:
                case 2:
                    // need to add a 'deletelist' table.
                    q.exec("CREATE TABLE deletelist (key primary key, timestamp integer)");
                    sDebug() << "Migrated successfully from schema v1";
                    break;
                default:
                    qCritical("I don't understand schema version!");
                    
            }

            q.exec("UPDATE _saesu SET version = '" + QString::number(currentDbVersion) + "'");

            mConnection.commit();
        }
    }

    return mConnection;
}