forked from qt-creator/qt-creator
VCS: Add reason text when submit validation fails
Change-Id: If4c8d5d1d5dc5386e49b29be59786dc53cfaaaa3 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
3666e3aaeb
commit
96529a27c5
@@ -152,13 +152,24 @@ void GitSubmitEditorWidget::setPanelData(const GitSubmitEditorPanelData &data)
|
||||
authorInformationChanged();
|
||||
}
|
||||
|
||||
bool GitSubmitEditorWidget::canSubmit() const
|
||||
bool GitSubmitEditorWidget::canSubmit(QString *whyNot) const
|
||||
{
|
||||
if (m_gitSubmitPanelUi.invalidAuthorLabel->isVisible()
|
||||
|| m_gitSubmitPanelUi.invalidEmailLabel->isVisible()
|
||||
|| m_hasUnmerged)
|
||||
if (m_gitSubmitPanelUi.invalidAuthorLabel->isVisible()) {
|
||||
if (whyNot)
|
||||
*whyNot = tr("Invalid author");
|
||||
return false;
|
||||
return SubmitEditorWidget::canSubmit();
|
||||
}
|
||||
if (m_gitSubmitPanelUi.invalidEmailLabel->isVisible()) {
|
||||
if (whyNot)
|
||||
*whyNot = tr("Invalid email");
|
||||
return false;
|
||||
}
|
||||
if (m_hasUnmerged) {
|
||||
if (whyNot)
|
||||
*whyNot = tr("Unresolved merge conflicts");
|
||||
return false;
|
||||
}
|
||||
return SubmitEditorWidget::canSubmit(whyNot);
|
||||
}
|
||||
|
||||
QString GitSubmitEditorWidget::cleanupDescription(const QString &input) const
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
void refreshLog(const QString &repository);
|
||||
|
||||
protected:
|
||||
bool canSubmit() const override;
|
||||
bool canSubmit(QString *whyNot) const override;
|
||||
QString cleanupDescription(const QString &) const override;
|
||||
QString commitName() const override;
|
||||
|
||||
|
||||
@@ -532,14 +532,23 @@ void SubmitEditorWidget::descriptionTextChanged()
|
||||
updateSubmitAction();
|
||||
}
|
||||
|
||||
bool SubmitEditorWidget::canSubmit() const
|
||||
bool SubmitEditorWidget::canSubmit(QString *whyNot) const
|
||||
{
|
||||
if (d->m_updateInProgress)
|
||||
if (d->m_updateInProgress) {
|
||||
if (whyNot)
|
||||
*whyNot = tr("Update in progress");
|
||||
return false;
|
||||
if (isDescriptionMandatory() && d->m_description.trimmed().isEmpty())
|
||||
}
|
||||
if (isDescriptionMandatory() && d->m_description.trimmed().isEmpty()) {
|
||||
if (whyNot)
|
||||
*whyNot = tr("Description is empty");
|
||||
return false;
|
||||
}
|
||||
const unsigned checkedCount = checkedFilesCount();
|
||||
return d->m_emptyFileListEnabled || checkedCount > 0;
|
||||
const bool res = d->m_emptyFileListEnabled || checkedCount > 0;
|
||||
if (!res && whyNot)
|
||||
*whyNot = tr("No files checked");
|
||||
return res;
|
||||
}
|
||||
|
||||
void SubmitEditorWidget::setUpdateInProgress(bool value)
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
void addSubmitFieldWidget(SubmitFieldWidget *f);
|
||||
QList<SubmitFieldWidget *> submitFieldWidgets() const;
|
||||
|
||||
virtual bool canSubmit() const;
|
||||
virtual bool canSubmit(QString *whyNot = nullptr) const;
|
||||
void setUpdateInProgress(bool value);
|
||||
bool updateInProgress() const;
|
||||
|
||||
|
||||
@@ -546,7 +546,7 @@ VcsBaseSubmitEditor::PromptSubmitResult
|
||||
QWidget *parent = Core::ICore::mainWindow();
|
||||
// Pop up a message depending on whether the check succeeded and the
|
||||
// user wants to be prompted
|
||||
bool canCommit = checkSubmitMessage(&errorMessage) && submitWidget->canSubmit();
|
||||
bool canCommit = checkSubmitMessage(&errorMessage) && submitWidget->canSubmit(&errorMessage);
|
||||
if (canCommit) {
|
||||
// Check ok, do prompt?
|
||||
if (prompt) {
|
||||
|
||||
Reference in New Issue
Block a user