forked from qt-creator/qt-creator
Make the "prompt to submit" setting a per-plugin one.
Provide a checkable message box to be able to turn prompting off when asked.
This commit is contained in:
@@ -690,12 +690,14 @@ bool GitPlugin::editorAboutToClose(Core::IEditor *iEditor)
|
||||
return true;
|
||||
// Prompt user. Force a prompt unless submit was actually invoked (that
|
||||
// is, the editor was closed or shutdown).
|
||||
GitSettings settings = m_gitClient->settings();
|
||||
const bool wantedPrompt = settings.promptToSubmit;
|
||||
const VCSBase::VCSBaseSubmitEditor::PromptSubmitResult answer =
|
||||
editor->promptSubmit(tr("Closing git editor"),
|
||||
tr("Do you want to commit the change?"),
|
||||
tr("The commit message check failed. Do you want to commit the change?"),
|
||||
!m_submitActionTriggered);
|
||||
m_submitActionTriggered = false;
|
||||
&settings.promptToSubmit, !m_submitActionTriggered);
|
||||
m_submitActionTriggered = false;
|
||||
switch (answer) {
|
||||
case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
|
||||
return false; // Keep editing and change file
|
||||
@@ -705,6 +707,8 @@ bool GitPlugin::editorAboutToClose(Core::IEditor *iEditor)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (wantedPrompt != settings.promptToSubmit)
|
||||
m_gitClient->setSettings(settings);
|
||||
// Go ahead!
|
||||
const QStringList fileList = editor->checkedFiles();
|
||||
if (Git::Constants::debug)
|
||||
|
||||
@@ -41,6 +41,7 @@ static const char *sysEnvKeyC = "SysEnv";
|
||||
static const char *pathKeyC = "Path";
|
||||
static const char *logCountKeyC = "LogCount";
|
||||
static const char *timeoutKeyC = "TimeOut";
|
||||
static const char *promptToSubmitKeyC = "PromptForSubmit";
|
||||
|
||||
enum { defaultLogCount = 10 , defaultTimeOut = 30};
|
||||
|
||||
@@ -50,7 +51,8 @@ namespace Internal {
|
||||
GitSettings::GitSettings() :
|
||||
adoptPath(false),
|
||||
logCount(defaultLogCount),
|
||||
timeout(defaultTimeOut)
|
||||
timeout(defaultTimeOut),
|
||||
promptToSubmit(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -61,6 +63,7 @@ void GitSettings::fromSettings(QSettings *settings)
|
||||
path = settings->value(QLatin1String(pathKeyC), QString()).toString();
|
||||
logCount = settings->value(QLatin1String(logCountKeyC), defaultLogCount).toInt();
|
||||
timeout = settings->value(QLatin1String(timeoutKeyC), defaultTimeOut).toInt();
|
||||
promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@@ -71,12 +74,14 @@ void GitSettings::toSettings(QSettings *settings) const
|
||||
settings->setValue(QLatin1String(pathKeyC), path);
|
||||
settings->setValue(QLatin1String(logCountKeyC), logCount);
|
||||
settings->setValue(QLatin1String(timeoutKeyC), timeout);
|
||||
settings->setValue(QLatin1String(promptToSubmitKeyC), promptToSubmit);
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
bool GitSettings::equals(const GitSettings &s) const
|
||||
{
|
||||
return adoptPath == s.adoptPath && path == s.path && logCount == s.logCount && timeout == s.timeout;
|
||||
return adoptPath == s.adoptPath && path == s.path && logCount == s.logCount
|
||||
&& timeout == s.timeout && promptToSubmit == s.promptToSubmit;
|
||||
}
|
||||
|
||||
QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
|
||||
|
||||
@@ -55,6 +55,7 @@ struct GitSettings
|
||||
QString path;
|
||||
int logCount;
|
||||
int timeout;
|
||||
bool promptToSubmit;
|
||||
};
|
||||
|
||||
inline bool operator==(const GitSettings &p1, const GitSettings &p2)
|
||||
|
||||
@@ -54,6 +54,7 @@ GitSettings SettingsPageWidget::settings() const
|
||||
rc.adoptPath = m_ui.environmentGroupBox->isChecked() && !rc.path.isEmpty();
|
||||
rc.logCount = m_ui.logCountSpinBox->value();
|
||||
rc.timeout = m_ui.timeoutSpinBox->value();
|
||||
rc.promptToSubmit = m_ui.promptToSubmitCheckBox->isChecked();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -63,6 +64,7 @@ void SettingsPageWidget::setSettings(const GitSettings &s)
|
||||
m_ui.pathLineEdit->setText(s.path);
|
||||
m_ui.logCountSpinBox->setValue(s.logCount);
|
||||
m_ui.timeoutSpinBox->setValue(s.timeout);
|
||||
m_ui.promptToSubmitCheckBox->setChecked(s.promptToSubmit);
|
||||
}
|
||||
|
||||
void SettingsPageWidget::setSystemPath()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>403</width>
|
||||
<width>409</width>
|
||||
<height>251</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -104,6 +104,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="promptToSubmitCheckBox">
|
||||
<property name="text">
|
||||
<string>Prompt to submit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user