mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Moved functions around for better readability
This commit is contained in:
parent
d3143c6e52
commit
ac965af671
@ -130,99 +130,6 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
|
||||
setupConfig();
|
||||
}
|
||||
|
||||
void DataFilesPage::newProfile()
|
||||
{
|
||||
bool ok;
|
||||
QString text = QInputDialog::getText(this, tr("New Profile"),
|
||||
tr("Profile Name:"), QLineEdit::Normal,
|
||||
tr("New Profile"), &ok);
|
||||
if (ok && !text.isEmpty()) {
|
||||
if (mProfilesComboBox->findText(text) != -1)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Profile already exists"),
|
||||
tr("the profile <b>%0</b> already exists.").arg(text),
|
||||
QMessageBox::Ok);
|
||||
} else {
|
||||
// Add the new profile to the combobox
|
||||
mProfilesComboBox->addItem(text);
|
||||
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DataFilesPage::copyProfile()
|
||||
{
|
||||
QString profile = mProfilesComboBox->currentText();
|
||||
bool ok;
|
||||
|
||||
QString text = QInputDialog::getText(this, tr("Copy Profile"),
|
||||
tr("Profile Name:"), QLineEdit::Normal,
|
||||
tr("%0 Copy").arg(profile), &ok);
|
||||
if (ok && !text.isEmpty()) {
|
||||
if (mProfilesComboBox->findText(text) != -1)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Profile already exists"),
|
||||
tr("the profile <b>%0</b> already exists.").arg(text),
|
||||
QMessageBox::Ok);
|
||||
} else {
|
||||
// Add the new profile to the combobox
|
||||
mProfilesComboBox->addItem(text);
|
||||
|
||||
// First write the current profile as the new profile
|
||||
writeConfig(text);
|
||||
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DataFilesPage::deleteProfile()
|
||||
{
|
||||
QString profile = mProfilesComboBox->currentText();
|
||||
|
||||
|
||||
if (profile.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QMessageBox deleteMessageBox(this);
|
||||
deleteMessageBox.setWindowTitle(tr("Delete Profile"));
|
||||
deleteMessageBox.setText(tr("Are you sure you want to delete <b>%0</b>?").arg(profile));
|
||||
deleteMessageBox.setIcon(QMessageBox::Warning);
|
||||
QAbstractButton *deleteButton =
|
||||
deleteMessageBox.addButton(tr("Delete"), QMessageBox::ActionRole);
|
||||
|
||||
deleteMessageBox.addButton(QMessageBox::Cancel);
|
||||
|
||||
deleteMessageBox.exec();
|
||||
|
||||
if (deleteMessageBox.clickedButton() == deleteButton) {
|
||||
|
||||
qDebug() << "Delete profile " << profile;
|
||||
|
||||
// Make sure we have no groups open
|
||||
while (!mLauncherConfig->group().isEmpty()) {
|
||||
mLauncherConfig->endGroup();
|
||||
}
|
||||
|
||||
mLauncherConfig->beginGroup("Profiles");
|
||||
|
||||
// Open the profile-name subgroup
|
||||
mLauncherConfig->beginGroup(profile);
|
||||
mLauncherConfig->remove(""); // Clear the subgroup
|
||||
mLauncherConfig->endGroup();
|
||||
mLauncherConfig->endGroup();
|
||||
|
||||
// Remove the profile from the combobox
|
||||
mProfilesComboBox->removeItem(mProfilesComboBox->findText(profile));
|
||||
}
|
||||
}
|
||||
|
||||
void DataFilesPage::setupDataFiles(const QString &path)
|
||||
{
|
||||
qDebug() << "setupDataFiles called!";
|
||||
@ -361,6 +268,99 @@ void DataFilesPage::setupConfig()
|
||||
connect(mProfilesComboBox, SIGNAL(textChanged(const QString&, const QString&)), this, SLOT(profileChanged(const QString&, const QString&)));
|
||||
}
|
||||
|
||||
void DataFilesPage::newProfile()
|
||||
{
|
||||
bool ok;
|
||||
QString text = QInputDialog::getText(this, tr("New Profile"),
|
||||
tr("Profile Name:"), QLineEdit::Normal,
|
||||
tr("New Profile"), &ok);
|
||||
if (ok && !text.isEmpty()) {
|
||||
if (mProfilesComboBox->findText(text) != -1)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Profile already exists"),
|
||||
tr("the profile <b>%0</b> already exists.").arg(text),
|
||||
QMessageBox::Ok);
|
||||
} else {
|
||||
// Add the new profile to the combobox
|
||||
mProfilesComboBox->addItem(text);
|
||||
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DataFilesPage::copyProfile()
|
||||
{
|
||||
QString profile = mProfilesComboBox->currentText();
|
||||
bool ok;
|
||||
|
||||
QString text = QInputDialog::getText(this, tr("Copy Profile"),
|
||||
tr("Profile Name:"), QLineEdit::Normal,
|
||||
tr("%0 Copy").arg(profile), &ok);
|
||||
if (ok && !text.isEmpty()) {
|
||||
if (mProfilesComboBox->findText(text) != -1)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Profile already exists"),
|
||||
tr("the profile <b>%0</b> already exists.").arg(text),
|
||||
QMessageBox::Ok);
|
||||
} else {
|
||||
// Add the new profile to the combobox
|
||||
mProfilesComboBox->addItem(text);
|
||||
|
||||
// First write the current profile as the new profile
|
||||
writeConfig(text);
|
||||
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DataFilesPage::deleteProfile()
|
||||
{
|
||||
QString profile = mProfilesComboBox->currentText();
|
||||
|
||||
|
||||
if (profile.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QMessageBox deleteMessageBox(this);
|
||||
deleteMessageBox.setWindowTitle(tr("Delete Profile"));
|
||||
deleteMessageBox.setText(tr("Are you sure you want to delete <b>%0</b>?").arg(profile));
|
||||
deleteMessageBox.setIcon(QMessageBox::Warning);
|
||||
QAbstractButton *deleteButton =
|
||||
deleteMessageBox.addButton(tr("Delete"), QMessageBox::ActionRole);
|
||||
|
||||
deleteMessageBox.addButton(QMessageBox::Cancel);
|
||||
|
||||
deleteMessageBox.exec();
|
||||
|
||||
if (deleteMessageBox.clickedButton() == deleteButton) {
|
||||
|
||||
qDebug() << "Delete profile " << profile;
|
||||
|
||||
// Make sure we have no groups open
|
||||
while (!mLauncherConfig->group().isEmpty()) {
|
||||
mLauncherConfig->endGroup();
|
||||
}
|
||||
|
||||
mLauncherConfig->beginGroup("Profiles");
|
||||
|
||||
// Open the profile-name subgroup
|
||||
mLauncherConfig->beginGroup(profile);
|
||||
mLauncherConfig->remove(""); // Clear the subgroup
|
||||
mLauncherConfig->endGroup();
|
||||
mLauncherConfig->endGroup();
|
||||
|
||||
// Remove the profile from the combobox
|
||||
mProfilesComboBox->removeItem(mProfilesComboBox->findText(profile));
|
||||
}
|
||||
}
|
||||
|
||||
void DataFilesPage::masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
||||
{
|
||||
if (mMastersWidget->selectionModel()->hasSelection()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user