예제 #1
0
void VersionManager::addVersion_Click(){

    if (askSaveChangeds()){
        currentVersionChanged_ = false;
    } else {
        return;
    }

    bool ok;
    QString name;
    Version *vers = new Version();

    name = QInputDialog::getText(this, tr("Add version"),
                                 tr("Version name:"), QLineEdit::Normal,
                                 "", &ok);
    if (ok && !name.isEmpty()){
        vers->name_ = name;
        while (vers->load()){
            name = QInputDialog::getText(this, tr("Add version"),
                                         tr("Sorry. It seems that the version name already exists.<br>Please choose another version name."), QLineEdit::Normal,
                                         name, &ok);
            if (!ok || name.isEmpty())
                break;

            vers->clear();
            vers->name_ = name;
        }

        if (vers->save()){
            getVersions();
            setVersionFocus(vers->name_);
            currentVersionChanged_ = true;
        }
    }
}
예제 #2
0
void PrefixSettings::txtRunString_Changed(){
    QString run_string = txtRunString->toPlainText().replace("\"", "\\\"");

    QString console_bin = CoreLib->getSetting("console", "bin").toString();
    QString console_args = CoreLib->getSetting("console", "args", false).toString();

    if (console_bin.split("/").last() == "konsole"){
        console_args.append(" /bin/sh -c ");
    }

    run_string.replace("%CONSOLE_BIN%", console_bin);
    run_string.replace("%CONSOLE_ARGS%", QString("%1 \"").arg(console_args));

    Version ver;
    if (!txtWineBin->text().isEmpty()){
        ver.wine_exec_ = txtWineBin->text();
        ver.wine_loader_ = txtWineLoaderBin->text();
        ver.wine_server_ = txtWineServerBin->text();
        ver.wine_dllpath32_ = txtWineLibs->text();
        ver.wine_dllpath64_ = txtWineLibs->text();
    } else {
        ver.clear();
        ver.name_ = comboVersionList->currentText();
        if (!ver.load()){
            QMessageBox::critical(this, tr("Error"), tr("Unable to load version by name: %1").arg(ver.name_));
            return;
        }
    }

    QString env;
    env.append(QString(" WINE='%1' ").arg(ver.wine_exec_));
    env.append(QString(" WINEPREFIX='%1' ").arg(txtPrefixPath->text()));
    env.append(QString(" WINESERVER='%1' ").arg(ver.wine_server_));
    env.append(QString(" WINELOADER='%1' ").arg(ver.wine_loader_));
    if (comboArchList->currentText()=="win64"){
        env.append(QString(" WINEDLLPATH='%1' ").arg(ver.wine_dllpath64_));
    } else if (comboArchList->currentText()=="win32"){
        env.append(QString(" WINEDLLPATH='%1' ").arg(ver.wine_dllpath32_));
    }
    env.append(QString(" WINEARCH='%1' ").arg(comboArchList->currentText()));
    env.append(QString(" WINEDEBUG='%1' ").arg("-all"));
    env.append(QString(" WINEDLLOVERRIDES='' "));
    env.append(QString(" LANG='' "));

    run_string.replace("%ENV_BIN%", CoreLib->getWhichOut("env"));
    run_string.replace("%ENV_ARGS%", env);

    run_string.replace("%WORK_DIR%", QString("cd \'%1\' &&").arg(QDir::homePath()));
    run_string.replace("%SET_NICE%", QString("%1 -n 10").arg(CoreLib->getSetting("system", "nice", false).toString()));

    run_string.replace("%WINE_BIN%", ver.wine_exec_);

    run_string.replace("%VIRTUAL_DESKTOP%", " explorer.exe /desktop=winecfg,800x600 ");
    run_string.replace("%PROGRAM_BIN%", "\'winecfg\'");
    run_string.replace("%PROGRAM_ARGS%", "-h");
    run_string.append(" \"");

    lblTemalate->setText(run_string);
}
예제 #3
0
void VersionManager::itemClicked (QListWidgetItem *item){
    if (!item)
        return;

    if (currentVersion.get())
        if (item->text() == currentVersion->name_)
            return;

    Version* ver = new Version();
    ver->name_ = item->text();

    emit(setVersion(ver->name_));

    if (!ver->load()){
        qDebug() << "[EE] Fail to load version by name: " << ver->name_;
        return;
    }

    currentVersion.reset(ver);

    this->txtWineBin->setText(currentVersion->wine_exec_);
    this->txtWineServerBin->setText(currentVersion->wine_server_);
    this->txtWineLoaderBin->setText(currentVersion->wine_loader_);
    this->txtWineLibs32->setText(currentVersion->wine_dllpath32_);
    this->txtWineLibs64->setText(currentVersion->wine_dllpath64_);

    delVersion->setEnabled(true);
    saveVersion->setEnabled(true);
    cmdGetWineBin->setEnabled(true);
    cmdGetWineLibs32->setEnabled(true);
    cmdGetWineLibs64->setEnabled(true);
    cmdGetWineLoaderBin->setEnabled(true);
    cmdGetWineServerBin->setEnabled(true);
    txtWineBin->setEnabled(true);
    txtWineLibs32->setEnabled(true);
    txtWineLibs64->setEnabled(true);
    txtWineLoaderBin->setEnabled(true);
    txtWineServerBin->setEnabled(true);

    currentVersionChanged_ = false;

    return;
}
예제 #4
0
void PrefixSettings::cmdOk_Click(){
    if (txtPrefixName->text().isEmpty()){
        QMessageBox::warning(this, tr("Error"), tr("Enter a prefix name"));
        return;
    }

    if (prefix_name!=txtPrefixName->text()){
        if (db_prefix.isExistsByName(txtPrefixName->text())){
            QMessageBox::warning(this, tr("Error"), tr("Sorry, but prefix named %1 already exists.").arg(txtPrefixName->text()));
            return;
        }
    }

    QString path = txtPrefixPath->text();
    if (path.right(1)=="/"){
        path=path.left(path.length()-1);
        txtPrefixPath->setText(path);
    }

    Version ver;
    ver.name_ = comboVersionList->currentText();
    if (!ver.load()){
        QMessageBox::critical(this, tr("Error"), tr("Fail to load version by name: %1").arg(ver.name_));
        return;
    }

    if (this->addNew){

        QDir directory(path);
        if (directory.exists()){
            if(QMessageBox::warning(this, tr("Warning"), tr("Directory \"%1\" already exists. Do you wish to use it anyway?").arg(path), QMessageBox::Yes, QMessageBox::No)==QMessageBox::No)
                return;
        } else {
            // In case of non default arch, wine will fail to run wine programs from existent
            // empty prefix directory.
            // So we will try to create parent folders, but not prefix dir itself.
            if (!directory.mkpath("./../")) {
                QMessageBox::critical(this, tr("Error"), tr("The directory \"%1\" could not be created.").arg(path), QMessageBox::Ok);
                return;
            }
        }

        if (!db_prefix.addPrefix(txtPrefixName->text(),  txtPrefixPath->text(), txtWineBin->text(), txtWineServerBin->text(), txtWineLoaderBin->text(), txtWineLibs->text(), txtMountPoint->text(), comboArchList->currentText(), this->comboWinDrive->currentText(), this->txtRunString->toPlainText(), ver.id_))
            reject();

        CoreLib->createPrefixDBStructure(txtPrefixName->text());
#ifndef _OS_DARWIN_
        if (CoreLib->getSetting("Plugins", "enableMenuDesktop", false, true).toBool())
            sys_menu.generateSystemMenu(txtPrefixName->text());
#endif
    } else {
        if (!db_prefix.updatePrefix(txtPrefixName->text(), txtPrefixPath->text(), txtWineBin->text(), txtWineServerBin->text(), txtWineLoaderBin->text(), txtWineLibs->text(), txtMountPoint->text(), this->prefix_name, comboArchList->currentText(), this->comboWinDrive->currentText(), this->txtRunString->toPlainText(), ver.id_))
            reject();
#ifndef _OS_DARWIN_
        if (CoreLib->getSetting("Plugins", "enableMenuDesktop", false, true).toBool()){
            if (this->prefix_name != txtPrefixName->text()){
                sys_menu.remove_dir_info(this->prefix_name);
                sys_menu.generateSystemMenu(txtPrefixName->text());
            }
        }
#endif
    }

    accept();
    return;
}
예제 #5
0
PrefixSettings::PrefixSettings(QString prefix_name, QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f)
{
    // Setup base UI
    setupUi(this);

    // Setting class prefix name
    this->prefix_name=prefix_name;

    // Loading libq4wine-core.so
#ifdef RELEASE
    libq4wine.setFileName(_CORELIB_PATH_);
#else
    libq4wine.setFileName("../q4wine-lib/libq4wine-core");
#endif
    if (!libq4wine.load()){
        libq4wine.load();
    }

    // Getting corelib calss pointer
    CoreLibClassPointer = (CoreLibPrototype *) libq4wine.resolve("createCoreLib");
    CoreLib.reset((corelib *)CoreLibClassPointer(true));

    this->addNew=false;
    this->loadThemeIcons();

    setWindowIcon(CoreLib->loadIcon(CoreLib->getSetting("app", "icon", false, "q4wine").toString()));

    QHash<QString,QString> result = db_prefix.getByName(prefix_name);
    if (result.value("id").isEmpty())
        return;

    prefix_id=result.value("id");

    Version ver;
    ver.id_ = result.value("version_id");
    if (!ver.load()){
        ver.clear();
        ver.name_ = "Default";
        if (!ver.load()){
            QMessageBox::critical(this, tr("Error"), tr("Unable to load version by name: %1").arg(ver.name_));
            return;
        }
    }
    version_name=ver.name_;

    txtMountPoint->setText(result.value("mount"));

    connect(txtMountPoint, SIGNAL(editingFinished()), this, SLOT(getWineCdromLetter()));

    if (prefix_name=="Default"){
        txtPrefixName->setEnabled(false);
        txtPrefixPath->setEnabled(false);

        cmdGetPrefixPath->setEnabled(false);

        txtWineLibs->setText("");
        txtWineLoaderBin->setText("");
        txtWineServerBin->setText("");
        txtWineBin->setText("");
    } else {
        cmdGetPrefixPath->installEventFilter(this);

        txtWineLibs->setText(result.value("libs"));
        txtWineLoaderBin->setText(result.value("loader"));
        txtWineServerBin->setText(result.value("server"));
        txtWineBin->setText(result.value("bin"));

        if (!result.value("libs").isEmpty())
            cmdClnWineLibs->setEnabled(true);

        if (!result.value("loader").isEmpty())
            cmdClnWineLoaderBin->setEnabled(true);

        if (!result.value("server").isEmpty())
            cmdClnWineServerBin->setEnabled(true);

        if (!result.value("bin").isEmpty())
            cmdClnWineBin->setEnabled(true);
    }

    // Hide advanced settings if there are no deprecated settings defined
    if ((txtWineBin->text().isEmpty()) && (txtWineLoaderBin->text().isEmpty()) && (txtWineServerBin->text().isEmpty()) && (txtWineBin->text().isEmpty())){
        widDeprecated->setVisible(false);
    }

    if (!result.value("arch").isEmpty())
        comboArchList->setCurrentIndex(comboArchList->findText(result.value("arch")));
    if (!result.value("mountpoint_windrive").isEmpty()){
        comboWinDrive->setCurrentIndex(comboWinDrive->findText(result.value("mountpoint_windrive")));
    } else {
        this->getWineCdromLetter();
    }

    txtPrefixName->setText(prefix_name);
    txtPrefixPath->setText(result.value("path"));

    connect(cmdCancel, SIGNAL(clicked()), this, SLOT(cmdCancel_Click()));
    connect(cmdOk, SIGNAL(clicked()), this, SLOT(cmdOk_Click()));
    connect(cmdHelp, SIGNAL(clicked()), this, SLOT(cmdHelp_Click()));

    connect(cmdClnWineBin, SIGNAL(clicked()), this, SLOT(cmdClnWineBin_Click()));
    connect(cmdClnWineServerBin, SIGNAL(clicked()), this, SLOT(cmdClnWineServerBin_Click()));
    connect(cmdClnWineLoaderBin, SIGNAL(clicked()), this, SLOT(cmdClnWineLoaderBin_Click()));
    connect(cmdClnWineLibs, SIGNAL(clicked()), this, SLOT(cmdClnWineLibs_Click()));

    connect(comboVersionList, SIGNAL(currentIndexChanged(const QString)), this, SLOT(comboVersionList_Change(const QString)));
    connect(comboTemplatesList, SIGNAL(currentIndexChanged(const int)), this, SLOT(comboTemplatesList_Change(const int)));
    connect(cmdAddVersion, SIGNAL(clicked()), this, SLOT(cmdAddVersion_Click()));

    getVersionsList();
    connect(txtRunString, SIGNAL(textChanged()), this, SLOT(txtRunString_Changed()));
       // comboArchList->setEnabled(false);

    txtRunString->setText(result.value("run_string"));


    cmdGetMountPoint->installEventFilter(this);

    cmdOk->setFocus(Qt::ActiveWindowFocusReason);

    return;
}