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; } } }
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); }
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; }