1
0
mirror of https://gitlab.com/pholy/OSCAR-code.git synced 2025-04-17 03:00:46 +00:00

Tell user to create a new profile if none there

This commit is contained in:
Phil Olynyk 2019-03-25 17:49:24 -04:00
parent 6213819fa5
commit f9919036de

View File

@ -58,8 +58,10 @@ ProfileSelector::ProfileSelector(QWidget *parent) :
ui->diskSpaceInfo->setVisible(false); ui->diskSpaceInfo->setVisible(false);
QItemSelectionModel * sm = ui->profileView->selectionModel(); QItemSelectionModel * sm = ui->profileView->selectionModel();
if (sm) connect(sm, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(on_selectionChanged(QModelIndex,QModelIndex))); if (sm)
connect(sm, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(on_selectionChanged(QModelIndex,QModelIndex)));
ui->buttonEditProfile->setEnabled(false); ui->buttonEditProfile->setEnabled(false);
ui->buttonOpenProfile->setEnabled(false);
} }
ProfileSelector::~ProfileSelector() ProfileSelector::~ProfileSelector()
@ -162,6 +164,9 @@ void ProfileSelector::updateProfileList()
w+=20; w+=20;
// ui->profileView->setMinimumWidth(w); // ui->profileView->setMinimumWidth(w);
if ( row == 0 ) {
ui->profileInfoLabel->setText("You must create a profile");
}
proxy = new MySortFilterProxyModel2(this); proxy = new MySortFilterProxyModel2(this);
proxy->setSourceModel(model); proxy->setSourceModel(model);
proxy->setSortCaseSensitivity(Qt::CaseInsensitive); proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
@ -202,13 +207,11 @@ void ProfileSelector::updateProfileHighlight(QString name)
for (int i=0; i<proxy->columnCount(); i++) { for (int i=0; i<proxy->columnCount(); i++) {
idx = proxy->index(row, i, QModelIndex()); idx = proxy->index(row, i, QModelIndex());
proxy->setData(idx, bg, Qt::ForegroundRole); proxy->setData(idx, bg, Qt::ForegroundRole);
proxy->setData(idx, font, Qt::FontRole); proxy->setData(idx, font, Qt::FontRole);
} }
break; break;
} }
} }
} }
@ -232,14 +235,10 @@ Profile *ProfileSelector::SelectProfile(QString profname, bool skippassword=fals
lay->addWidget(e); lay->addWidget(e);
int tries = 0; int tries = 0;
bool succeeded = false; bool succeeded = false;
do { do {
e->setText(""); e->setText("");
if (dialog.exec() != QDialog::Accepted) { break; } if (dialog.exec() != QDialog::Accepted) { break; }
tries++; tries++;
if (prof->user->checkPassword(e->text())) { if (prof->user->checkPassword(e->text())) {
succeeded = true; succeeded = true;
break; break;
@ -248,16 +247,14 @@ Profile *ProfileSelector::SelectProfile(QString profname, bool skippassword=fals
QMessageBox::warning(this, STR_MessageBox_Error, tr("You entered an incorrect password"), QMessageBox::Ok); QMessageBox::warning(this, STR_MessageBox_Error, tr("You entered an incorrect password"), QMessageBox::Ok);
} else { } else {
QMessageBox::warning(this, STR_MessageBox_Error, QMessageBox::warning(this, STR_MessageBox_Error,
tr("Forgot your password?")+"\n"+tr("Ask on the forums how to reset it, it's actually pretty easy."), tr("Forgot your password?")+"\n"+tr("Ask on the forums how to reset it, it's actually pretty easy."),
QMessageBox::Ok); QMessageBox::Ok);
} }
} }
} while (tries < 3); } while (tries < 3);
if (!succeeded) return nullptr; if (!succeeded) return nullptr;
} }
// Unselect everything in ProfileView // Unselect everything in ProfileView
updateProfileHighlight(profname); updateProfileHighlight(profname);
} }
@ -377,8 +374,8 @@ void ProfileSelector::on_buttonDestroyProfile_clicked()
QMessageBox::warning(this, STR_MessageBox_Error, tr("You entered an incorrect password"), QMessageBox::Ok); QMessageBox::warning(this, STR_MessageBox_Error, tr("You entered an incorrect password"), QMessageBox::Ok);
} else { } else {
QMessageBox::warning(this, STR_MessageBox_Error, QMessageBox::warning(this, STR_MessageBox_Error,
tr("If you're trying to delete because you forgot the password, you need to either reset it or delete the profile folder manually."), tr("If you're trying to delete because you forgot the password, you need to either reset it or delete the profile folder manually."),
QMessageBox::Ok); QMessageBox::Ok);
} }
} }
} while (tries < 3); } while (tries < 3);
@ -513,5 +510,6 @@ void ProfileSelector::on_selectionChanged(const QModelIndex &index, const QModel
ui->diskSpaceInfo->setText("Something went wrong"); ui->diskSpaceInfo->setText("Something went wrong");
} }
} }
ui->buttonOpenProfile->setEnabled(enabled);
ui->buttonEditProfile->setEnabled(enabled); ui->buttonEditProfile->setEnabled(enabled);
} }