MasterPasswordDialog::MasterPasswordDialog(QWidget *parent)
  : QDialog(parent)
  , ui(new Ui::MasterPasswordDialog)
  , d_ptr(new MasterPasswordDialogPrivate)
{
  ui->setupUi(this);
  setWindowIcon(QIcon(":/images/ctSESAM.ico"));
  ui->infoLabel->setStyleSheet("font-weight: bold");
  setWindowTitle(QString("%1 %2").arg(AppName).arg(isPortable() ? " - PORTABLE" : ""));
  QObject::connect(ui->okPushButton, SIGNAL(pressed()), SLOT(okClicked()));
  QObject::connect(ui->passwordLineEdit, SIGNAL(textEdited(QString)), SLOT(checkPasswords()));
  QObject::connect(ui->repeatPasswordLineEdit, SIGNAL(textEdited(QString)), SLOT(checkPasswords()));
  setRepeatPassword(false);
  invalidatePassword();
  checkPasswords();
  resize(width(), 1);
}
void AppPathManager::initAppPath()
{
    QApplication::setOrganizationName(V_COMPANY);
    QApplication::setOrganizationDomain(V_PGE_URL);
    QApplication::setApplicationName("Playable Character Calibrator");

    #ifdef __APPLE__
    {
        CFURLRef appUrlRef;
        appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
        CFStringRef filePathRef = CFURLGetString(appUrlRef);
        //const char* filePath = CFStringGetCStringPtr(filePathRef, kCFStringEncodingUTF8);
        ApplicationPath = QUrl(QString::fromCFString(filePathRef)).toLocalFile();
        {
            int i = ApplicationPath.lastIndexOf(".app");
            i = ApplicationPath.lastIndexOf('/', i);
            ApplicationPath.remove(i, ApplicationPath.size() - i);
        }
        //CFRelease(filePathRef);
        CFRelease(appUrlRef);

        //! If it's a path randomizer
        if(ApplicationPath.startsWith("/private/var/"))
        {
            QString realAppPath("/Applications/PGE Project");
            if(QDir(realAppPath).exists())
            {
                ApplicationPath = realAppPath;
            }
        }
    }
    #else
    ApplicationPath = QApplication::applicationDirPath();
    #endif
    ApplicationPath_x = ApplicationPath;

    if(isPortable())
        return;

#if defined(__ANDROID__) || defined(__APPLE__)
    QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
#else
    QString path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
#endif
    if(!path.isEmpty())
    {
        QDir appDir(path+UserDirName);
        if(!appDir.exists())
            if(!appDir.mkpath(path+UserDirName))
                goto defaultSettingsPath;

        m_userPath = appDir.absolutePath();
        initSettingsPath();
    }
    else
    {
        goto defaultSettingsPath;
    }

    return;
defaultSettingsPath:
    m_userPath = ApplicationPath;
    initSettingsPath();
}
Beispiel #3
0
void AppPathManager::initAppPath()
{
    QApplication::setOrganizationName(_COMPANY);
    QApplication::setOrganizationDomain(_PGE_URL);
    QApplication::setApplicationName("Playable Character Calibrator");

    ApplicationPath = QApplication::applicationDirPath();
    ApplicationPath_x = QApplication::applicationDirPath();

    #ifdef __APPLE__
    //Application path relative bundle folder of application
    ApplicationPath = QFileInfo(ApplicationPath_x+"../../..").absoluteDir().absolutePath();
    #endif

    /*
    QString osX_bundle = QApplication::applicationName()+".app/Contents/MacOS";
    QString test="/home/vasya/pge/"+osX_bundle;
    qDebug() << test << " <- before";
    if(test.endsWith(osX_bundle, Qt::CaseInsensitive))
        test.remove(test.length()-osX_bundle.length()-1, osX_bundle.length()+1);
    qDebug() << test << " <- after";
    */

    if(isPortable())
        return;

    QSettings setup;
    bool userDir;
    #if __ANDROID__ || __APPLE__
    userDir = true;
    #else
    userDir = setup.value("EnableUserDir", false).toBool();
    #endif

    if(userDir)
    {
        #if __ANDROID__||__APPLE__
        QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
        #else
        QString path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
        #endif
        if(!path.isEmpty())
        {
            QDir appDir(path+UserDirName);
            if(!appDir.exists())
                if(!appDir.mkpath(path+UserDirName))
                    goto defaultSettingsPath;

            _settingsPath = appDir.absolutePath();
        }
        else
        {
            goto defaultSettingsPath;
        }
    }
    else
    {
        goto defaultSettingsPath;
    }

    return;
defaultSettingsPath:
    _settingsPath = ApplicationPath;
}
Beispiel #4
0
// Config --------------------------------------------------------------------
Config::Config() {

    mSettings = isPortable() ? QSharedPointer<QSettings>(new QSettings(createSettingsFilePath(), QSettings::IniFormat)) : QSharedPointer<QSettings>(new QSettings());
    load();
}
Beispiel #5
0
void AppPathManager::initAppPath()
{
    QApplication::setOrganizationName(_COMPANY);
    QApplication::setOrganizationDomain(_PGE_URL);
    QApplication::setApplicationName("PGE Content Manager");

    ApplicationPath = QApplication::applicationDirPath();
    ApplicationPath_x = QApplication::applicationDirPath();

    #ifdef __APPLE__
    //Application path relative bundle folder of application
    QString osX_bundle = QApplication::applicationName()+".app/Contents/MacOS";
    if(ApplicationPath.endsWith(osX_bundle, Qt::CaseInsensitive))
        ApplicationPath.remove(ApplicationPath.length()-osX_bundle.length()-1, osX_bundle.length()+1);
    #elif __ANDROID__
    ApplicationPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/PGE Project Data";
    QDir appPath(ApplicationPath);
    if(!appPath.exists())
        appPath.mkpath(ApplicationPath);

    /*
    QDir languagesFolder(ApplicationPath+"/languages");
    if(!languagesFolder.exists())
    {
        languagesFolder.mkpath(ApplicationPath+"/languages");
        DirCopy::copy("assets:/languages", languagesFolder.absolutePath());
    }

    QDir themesFolder(ApplicationPath+"/themes");
    if(!themesFolder.exists())
    {
        themesFolder.mkpath(ApplicationPath+"/themes");
        DirCopy::copy("assets:/themes", themesFolder.absolutePath());
    }*/
    #endif

    /*
    QString osX_bundle = QApplication::applicationName()+".app/Contents/MacOS";
    QString test="/home/vasya/pge/"+osX_bundle;
    qDebug() << test << " <- before";
    if(test.endsWith(osX_bundle, Qt::CaseInsensitive))
        test.remove(test.length()-osX_bundle.length()-1, osX_bundle.length()+1);
    qDebug() << test << " <- after";
    */

    if(isPortable())
        return;

    QSettings setup;
    bool userDir;
    userDir = setup.value("EnableUserDir", true).toBool();
//openUserDir:

    if(userDir)
    {
        #ifndef __ANDROID__
        QString path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
        #else
        QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
        #endif
        if(!path.isEmpty())
        {
            QDir appDir(path+UserDirName);
            if(!appDir.exists())
                if(!appDir.mkpath(path+UserDirName))
                    goto defaultSettingsPath;

            _settingsPath = appDir.absolutePath();
        }
        else
        {
            goto defaultSettingsPath;
        }
    }
    else
    {
        goto defaultSettingsPath;
    }

    return;
defaultSettingsPath:
    _settingsPath = ApplicationPath;
}