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>
|
||||
|
||||
@@ -930,20 +930,26 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor)
|
||||
if (!perforceEditor)
|
||||
return true;
|
||||
QFileInfo editorFile(fileIFace->fileName());
|
||||
QFileInfo changeFile(m_changeTmpFile->fileName());
|
||||
QFileInfo changeFile(m_changeTmpFile->fileName());
|
||||
if (editorFile.absoluteFilePath() == changeFile.absoluteFilePath()) {
|
||||
// Prompt the user. Force a prompt unless submit was actually invoked (that
|
||||
// is, the editor was closed or shutdown).
|
||||
bool wantsPrompt = m_settings.promptToSubmit();
|
||||
const VCSBase::VCSBaseSubmitEditor::PromptSubmitResult answer =
|
||||
perforceEditor->promptSubmit(tr("Closing p4 Editor"),
|
||||
tr("Do you want to submit this change list?"),
|
||||
tr("The commit message check failed. Do you want to submit this change list"),
|
||||
!m_submitActionTriggered);
|
||||
&wantsPrompt, !m_submitActionTriggered);
|
||||
m_submitActionTriggered = false;
|
||||
|
||||
if (answer == VCSBase::VCSBaseSubmitEditor::SubmitCanceled)
|
||||
return false;
|
||||
|
||||
// Set without triggering the checking mechanism
|
||||
if (wantsPrompt != m_settings.promptToSubmit()) {
|
||||
m_settings.setPromptToSubmit(wantsPrompt);
|
||||
m_settings.toSettings(Core::ICore::instance()->settings());
|
||||
}
|
||||
core->fileManager()->blockFileChange(fileIFace);
|
||||
fileIFace->save();
|
||||
core->fileManager()->unblockFileChange(fileIFace);
|
||||
|
||||
@@ -44,6 +44,7 @@ static const char *defaultKeyC = "Default";
|
||||
static const char *portKeyC = "Port";
|
||||
static const char *clientKeyC = "Client";
|
||||
static const char *userKeyC = "User";
|
||||
static const char *promptToSubmitKeyC = "PromptForSubmit";
|
||||
|
||||
static QString defaultCommand()
|
||||
{
|
||||
@@ -59,7 +60,8 @@ namespace Perforce {
|
||||
namespace Internal {
|
||||
|
||||
Settings::Settings() :
|
||||
defaultEnv(true)
|
||||
defaultEnv(true),
|
||||
promptToSubmit(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -67,7 +69,8 @@ bool Settings::equals(const Settings &rhs) const
|
||||
{
|
||||
return defaultEnv == rhs.defaultEnv
|
||||
&& p4Command == rhs.p4Command && p4Port == rhs.p4Port
|
||||
&& p4Client == rhs.p4Client && p4User == rhs.p4User;
|
||||
&& p4Client == rhs.p4Client && p4User == rhs.p4User
|
||||
&& promptToSubmit == rhs.promptToSubmit;
|
||||
};
|
||||
|
||||
QStringList Settings::basicP4Args() const
|
||||
@@ -188,6 +191,7 @@ void PerforceSettings::fromSettings(QSettings *settings)
|
||||
m_settings.p4Port = settings->value(QLatin1String(portKeyC), QString()).toString();
|
||||
m_settings.p4Client = settings->value(QLatin1String(clientKeyC), QString()).toString();
|
||||
m_settings.p4User = settings->value(QLatin1String(userKeyC), QString()).toString();
|
||||
m_settings.promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
|
||||
settings->endGroup();
|
||||
m_mutex.unlock();
|
||||
|
||||
@@ -198,11 +202,12 @@ void PerforceSettings::toSettings(QSettings *settings) const
|
||||
{
|
||||
m_mutex.lock();
|
||||
settings->beginGroup(QLatin1String(groupC));
|
||||
settings->setValue(commandKeyC, m_settings.p4Command);
|
||||
settings->setValue(defaultKeyC, m_settings.defaultEnv);
|
||||
settings->setValue(portKeyC, m_settings.p4Port);
|
||||
settings->setValue(clientKeyC, m_settings.p4Client);
|
||||
settings->setValue(userKeyC, m_settings.p4User);
|
||||
settings->setValue(QLatin1String(commandKeyC), m_settings.p4Command);
|
||||
settings->setValue(QLatin1String(defaultKeyC), m_settings.defaultEnv);
|
||||
settings->setValue(QLatin1String(portKeyC), m_settings.p4Port);
|
||||
settings->setValue(QLatin1String(clientKeyC), m_settings.p4Client);
|
||||
settings->setValue(QLatin1String(userKeyC), m_settings.p4User);
|
||||
settings->setValue(QLatin1String(promptToSubmitKeyC), m_settings.promptToSubmit);
|
||||
settings->endGroup();
|
||||
m_mutex.unlock();
|
||||
}
|
||||
@@ -249,6 +254,16 @@ bool PerforceSettings::defaultEnv() const
|
||||
return m_settings.defaultEnv;
|
||||
}
|
||||
|
||||
bool PerforceSettings::promptToSubmit() const
|
||||
{
|
||||
return m_settings.promptToSubmit;
|
||||
}
|
||||
|
||||
void PerforceSettings::setPromptToSubmit(bool p)
|
||||
{
|
||||
m_settings.promptToSubmit = p;
|
||||
}
|
||||
|
||||
QString PerforceSettings::errorString() const
|
||||
{
|
||||
m_mutex.lock();
|
||||
|
||||
@@ -54,6 +54,7 @@ struct Settings {
|
||||
QString p4User;
|
||||
QString errorString;
|
||||
bool defaultEnv;
|
||||
bool promptToSubmit;
|
||||
};
|
||||
|
||||
inline bool operator==(const Settings &s1, const Settings &s2) { return s1.equals(s2); }
|
||||
@@ -81,6 +82,9 @@ public:
|
||||
QString p4Client() const;
|
||||
QString p4User() const;
|
||||
bool defaultEnv() const;
|
||||
bool promptToSubmit() const;
|
||||
void setPromptToSubmit(bool p);
|
||||
|
||||
QStringList basicP4Args() const;
|
||||
|
||||
// Error code of last check
|
||||
|
||||
@@ -70,6 +70,7 @@ Settings SettingsPageWidget::settings() const
|
||||
settings.p4Port = m_ui.portLineEdit->text();
|
||||
settings.p4User = m_ui.userLineEdit->text();
|
||||
settings.p4Client= m_ui.clientLineEdit->text();
|
||||
settings.promptToSubmit = m_ui.promptToSubmitCheckBox->isChecked();
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -80,6 +81,7 @@ void SettingsPageWidget::setSettings(const PerforceSettings &s)
|
||||
m_ui.portLineEdit->setText(s.p4Port());
|
||||
m_ui.clientLineEdit->setText(s.p4Client());
|
||||
m_ui.userLineEdit->setText(s.p4User());
|
||||
m_ui.promptToSubmitCheckBox->setChecked(s.promptToSubmit());
|
||||
const QString errorString = s.errorString();
|
||||
setStatusText(errorString.isEmpty(), errorString);
|
||||
}
|
||||
|
||||
@@ -6,38 +6,62 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>408</width>
|
||||
<width>423</width>
|
||||
<height>463</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="promptToSubmitCheckBox">
|
||||
<property name="text">
|
||||
<string>Prompt to submit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<item>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="commandLabel">
|
||||
<property name="text">
|
||||
<string>P4 Command:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Core::Utils::PathChooser" name="pathChooser" native="true"/>
|
||||
<item row="0" column="1">
|
||||
<widget class="Core::Utils::PathChooser" name="pathChooser"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="defaultCheckBox">
|
||||
<property name="text">
|
||||
<string>Use default P4 environment variables</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="defaultCheckBox">
|
||||
<property name="text">
|
||||
<string>Use default P4 environment variables</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="enabled">
|
||||
@@ -129,7 +153,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="text">
|
||||
<string extracomment="Placeholder" notr="true">errorLabel: blah blubb</string>
|
||||
<string notr="true" extracomment="Placeholder">errorLabel: blah blubb</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -59,6 +59,7 @@ SubversionSettings SettingsPageWidget::settings() const
|
||||
rc.password = m_ui.passwordLineEdit->text();
|
||||
if (rc.user.isEmpty())
|
||||
rc.useAuthentication = false;
|
||||
rc.promptToSubmit = m_ui.promptToSubmitCheckBox->isChecked();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -68,6 +69,7 @@ void SettingsPageWidget::setSettings(const SubversionSettings &s)
|
||||
m_ui.usernameLineEdit->setText(s.user);
|
||||
m_ui.passwordLineEdit->setText(s.password);
|
||||
m_ui.userGroupBox->setChecked(s.useAuthentication);
|
||||
m_ui.promptToSubmitCheckBox->setChecked(s.promptToSubmit);
|
||||
}
|
||||
|
||||
SettingsPage::SettingsPage()
|
||||
|
||||
@@ -6,30 +6,54 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>427</width>
|
||||
<height>280</height>
|
||||
<width>575</width>
|
||||
<height>437</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="commandHBox">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="promptToSubmitCheckBox">
|
||||
<property name="text">
|
||||
<string>Prompt to submit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="topverticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="commandLabel">
|
||||
<property name="text">
|
||||
<string>Subversion Command:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Core::Utils::PathChooser" name="pathChooser" native="true"/>
|
||||
<item row="0" column="1">
|
||||
<widget class="Core::Utils::PathChooser" name="pathChooser"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
@@ -480,11 +480,12 @@ bool SubversionPlugin::editorAboutToClose(Core::IEditor *iEditor)
|
||||
|
||||
// Prompt user. Force a prompt unless submit was actually invoked (that
|
||||
// is, the editor was closed or shutdown).
|
||||
SubversionSettings newSettings = m_settings;
|
||||
const VCSBase::VCSBaseSubmitEditor::PromptSubmitResult answer =
|
||||
editor->promptSubmit(tr("Closing Subversion Editor"),
|
||||
tr("Do you want to commit the change?"),
|
||||
tr("The commit message check failed. Do you want to commit the change?"),
|
||||
!m_submitActionTriggered);
|
||||
&newSettings.promptToSubmit, !m_submitActionTriggered);
|
||||
m_submitActionTriggered = false;
|
||||
switch (answer) {
|
||||
case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
|
||||
@@ -495,7 +496,7 @@ bool SubversionPlugin::editorAboutToClose(Core::IEditor *iEditor)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
setSettings(newSettings); // in case someone turned prompting off
|
||||
const QStringList fileList = editor->checkedFiles();
|
||||
bool closeEditor = true;
|
||||
if (!fileList.empty()) {
|
||||
|
||||
@@ -40,6 +40,7 @@ static const char *authenticationKeyC = "Authentication";
|
||||
|
||||
static const char *userNameOptionC = "--username";
|
||||
static const char *passwordOptionC = "--password";
|
||||
static const char *promptToSubmitKeyC = "PromptForSubmit";
|
||||
|
||||
static QString defaultCommand()
|
||||
{
|
||||
@@ -55,7 +56,8 @@ using namespace Subversion::Internal;
|
||||
|
||||
SubversionSettings::SubversionSettings() :
|
||||
svnCommand(defaultCommand()),
|
||||
useAuthentication(false)
|
||||
useAuthentication(false),
|
||||
promptToSubmit(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -66,6 +68,7 @@ void SubversionSettings::fromSettings(QSettings *settings)
|
||||
useAuthentication = settings->value(QLatin1String(authenticationKeyC), QVariant(false)).toBool();
|
||||
user = settings->value(QLatin1String(userKeyC), QString()).toString();
|
||||
password = settings->value(QLatin1String(passwordKeyC), QString()).toString();
|
||||
promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@@ -76,6 +79,7 @@ void SubversionSettings::toSettings(QSettings *settings) const
|
||||
settings->setValue(QLatin1String(authenticationKeyC), QVariant(useAuthentication));
|
||||
settings->setValue(QLatin1String(userKeyC), user);
|
||||
settings->setValue(QLatin1String(passwordKeyC), password);
|
||||
settings->setValue(QLatin1String(promptToSubmitKeyC), promptToSubmit);
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@@ -84,7 +88,8 @@ bool SubversionSettings::equals(const SubversionSettings &s) const
|
||||
return svnCommand == s.svnCommand
|
||||
&& useAuthentication == s.useAuthentication
|
||||
&& user == s.user
|
||||
&& password == s.password;
|
||||
&& password == s.password
|
||||
&& promptToSubmit == s.promptToSubmit;
|
||||
}
|
||||
|
||||
QStringList SubversionSettings::addOptions(const QStringList &args) const
|
||||
|
||||
@@ -59,6 +59,7 @@ struct SubversionSettings
|
||||
bool useAuthentication;
|
||||
QString user;
|
||||
QString password;
|
||||
bool promptToSubmit;
|
||||
};
|
||||
|
||||
inline bool operator==(const SubversionSettings &p1, const SubversionSettings &p2)
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
static const char *settingsGroupC = "VCS";
|
||||
static const char *nickNameMailMapKeyC = "NickNameMailMap";
|
||||
static const char *nickNameFieldListFileKeyC = "NickNameFieldListFile";
|
||||
static const char *promptForSubmitKeyC = "PromptForSubmit";
|
||||
static const char *submitMessageCheckScriptKeyC = "SubmitMessageCheckScript";
|
||||
static const char *lineWrapKeyC = "LineWrap";
|
||||
static const char *lineWrapWidthKeyC = "LineWrapWidth";
|
||||
@@ -47,7 +46,6 @@ namespace VCSBase {
|
||||
namespace Internal {
|
||||
|
||||
VCSBaseSettings::VCSBaseSettings() :
|
||||
promptForSubmit(true),
|
||||
lineWrap(lineWrapDefault),
|
||||
lineWrapWidth(lineWrapWidthDefault)
|
||||
{
|
||||
@@ -59,7 +57,6 @@ void VCSBaseSettings::toSettings(QSettings *s) const
|
||||
s->setValue(QLatin1String(nickNameMailMapKeyC), nickNameMailMap);
|
||||
s->setValue(QLatin1String(nickNameFieldListFileKeyC), nickNameFieldListFile);
|
||||
s->setValue(QLatin1String(submitMessageCheckScriptKeyC), submitMessageCheckScript);
|
||||
s->setValue(QLatin1String(promptForSubmitKeyC), promptForSubmit);
|
||||
s->setValue(QLatin1String(lineWrapKeyC), lineWrap);
|
||||
s->setValue(QLatin1String(lineWrapWidthKeyC), lineWrapWidth);
|
||||
s->endGroup();
|
||||
@@ -71,7 +68,6 @@ void VCSBaseSettings::fromSettings(QSettings *s)
|
||||
nickNameMailMap = s->value(QLatin1String(nickNameMailMapKeyC), QString()).toString();
|
||||
nickNameFieldListFile = s->value(QLatin1String(nickNameFieldListFileKeyC), QString()).toString();
|
||||
submitMessageCheckScript = s->value(QLatin1String(submitMessageCheckScriptKeyC), QString()).toString();
|
||||
promptForSubmit = s->value(QLatin1String(promptForSubmitKeyC), QVariant(true)).toBool();
|
||||
lineWrap = s->value(QLatin1String(lineWrapKeyC), lineWrapDefault).toBool();
|
||||
lineWrapWidth = s->value(QLatin1String(lineWrapWidthKeyC), lineWrapWidthDefault).toInt();
|
||||
s->endGroup();
|
||||
@@ -79,8 +75,7 @@ void VCSBaseSettings::fromSettings(QSettings *s)
|
||||
|
||||
bool VCSBaseSettings::equals(const VCSBaseSettings &rhs) const
|
||||
{
|
||||
return promptForSubmit == rhs.promptForSubmit
|
||||
&& lineWrap == rhs.lineWrap
|
||||
return lineWrap == rhs.lineWrap
|
||||
&& lineWrapWidth == rhs.lineWrapWidth
|
||||
&& nickNameMailMap == rhs.nickNameMailMap
|
||||
&& nickNameFieldListFile == rhs.nickNameFieldListFile
|
||||
@@ -89,8 +84,7 @@ bool VCSBaseSettings::equals(const VCSBaseSettings &rhs) const
|
||||
|
||||
QDebug operator<<(QDebug d,const VCSBaseSettings& s)
|
||||
{
|
||||
d.nospace() << "promptForSubmit=" << s.promptForSubmit
|
||||
<< " lineWrap=" << s.lineWrap
|
||||
d.nospace() << " lineWrap=" << s.lineWrap
|
||||
<< " lineWrapWidth=" << s.lineWrapWidth
|
||||
<< " nickNameMailMap='" << s.nickNameMailMap
|
||||
<< "' nickNameFieldListFile='" << s.nickNameFieldListFile
|
||||
|
||||
@@ -45,8 +45,6 @@ namespace Internal {
|
||||
struct VCSBaseSettings {
|
||||
VCSBaseSettings();
|
||||
|
||||
bool promptForSubmit;
|
||||
|
||||
QString nickNameMailMap;
|
||||
QString nickNameFieldListFile;
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ VCSBaseSettings VCSBaseSettingsWidget::settings() const
|
||||
rc.nickNameMailMap = m_ui->nickNameMailMapChooser->path();
|
||||
rc.nickNameFieldListFile = m_ui->nickNameFieldsFileChooser->path();
|
||||
rc.submitMessageCheckScript = m_ui->submitMessageCheckScriptChooser->path();
|
||||
rc.promptForSubmit = m_ui->promptForSubmitCheckBox->isChecked();
|
||||
rc.lineWrap= m_ui->lineWrapCheckBox->isChecked();
|
||||
rc.lineWrapWidth = m_ui->lineWrapSpinBox->value();
|
||||
return rc;
|
||||
@@ -77,7 +76,6 @@ void VCSBaseSettingsWidget::setSettings(const VCSBaseSettings &s)
|
||||
m_ui->nickNameMailMapChooser->setPath(s.nickNameMailMap);
|
||||
m_ui->nickNameFieldsFileChooser->setPath(s.nickNameFieldListFile);
|
||||
m_ui->submitMessageCheckScriptChooser->setPath(s.submitMessageCheckScript);
|
||||
m_ui->promptForSubmitCheckBox->setChecked(s.promptForSubmit);
|
||||
m_ui->lineWrapCheckBox->setChecked(s.lineWrap);
|
||||
m_ui->lineWrapSpinBox->setValue(s.lineWrapWidth);
|
||||
}
|
||||
|
||||
@@ -21,13 +21,6 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="promptForSubmitCheckBox">
|
||||
<property name="text">
|
||||
<string>Prompt to submit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <utils/submiteditorwidget.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/submitfieldwidget.h>
|
||||
#include <find/basetextfind.h>
|
||||
#include <texteditor/fontsettings.h>
|
||||
@@ -433,12 +434,13 @@ VCSBaseSubmitEditor::PromptSubmitResult
|
||||
VCSBaseSubmitEditor::promptSubmit(const QString &title,
|
||||
const QString &question,
|
||||
const QString &checkFailureQuestion,
|
||||
bool *promptSetting,
|
||||
bool forcePrompt) const
|
||||
{
|
||||
QString errorMessage;
|
||||
QMessageBox::StandardButton answer = QMessageBox::Yes;
|
||||
|
||||
const bool prompt = forcePrompt || Internal::VCSBasePlugin::instance()->settings().promptForSubmit;
|
||||
const bool prompt = forcePrompt || *promptSetting;
|
||||
|
||||
QWidget *parent = Core::ICore::instance()->mainWindow();
|
||||
// Pop up a message depending on whether the check succeeded and the
|
||||
@@ -446,9 +448,19 @@ VCSBaseSubmitEditor::PromptSubmitResult
|
||||
if (checkSubmitMessage(&errorMessage)) {
|
||||
// Check ok, do prompt?
|
||||
if (prompt) {
|
||||
answer = QMessageBox::question(parent, title, question,
|
||||
QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel,
|
||||
QMessageBox::Yes);
|
||||
// Provide check box to turn off prompt ONLY if it was not forced
|
||||
if (*promptSetting && !forcePrompt) {
|
||||
const QDialogButtonBox::StandardButton danswer =
|
||||
Core::Utils::CheckableMessageBox::question(parent, title, question,
|
||||
tr("Prompt to submit"), promptSetting,
|
||||
QDialogButtonBox::Yes|QDialogButtonBox::No|QDialogButtonBox::Cancel,
|
||||
QDialogButtonBox::Yes);
|
||||
answer = Core::Utils::CheckableMessageBox::dialogButtonBoxToMessageBoxButton(danswer);
|
||||
} else {
|
||||
answer = QMessageBox::question(parent, title, question,
|
||||
QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel,
|
||||
QMessageBox::Yes);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Check failed.
|
||||
|
||||
@@ -112,9 +112,12 @@ public:
|
||||
// Runs checks on the message and prompts according to configuration.
|
||||
// Force prompt should be true if it is invoked by closing an editor
|
||||
// as opposed to invoking the "Submit" button.
|
||||
// 'promptSetting' points to a bool variable containing the plugin's
|
||||
// prompt setting. The user can uncheck it from the message box.
|
||||
enum PromptSubmitResult { SubmitConfirmed, SubmitCanceled, SubmitDiscarded };
|
||||
PromptSubmitResult promptSubmit(const QString &title, const QString &question,
|
||||
const QString &checkFailureQuestion,
|
||||
bool *promptSetting,
|
||||
bool forcePrompt = false) const;
|
||||
|
||||
int fileNameColumn() const;
|
||||
|
||||
Reference in New Issue
Block a user