forked from qt-creator/qt-creator
Fixes: Make QtCreator fly even in face of perforce misconfiguration.
Details: If p4 is in path, but the server isn't configured correctly we were pretty slow, this fixes that by running p4 client -o after the settings have changed, if that doesn't return after 2 seconds, then we cache that as a invalid configuration.
This commit is contained in:
@@ -71,14 +71,14 @@ class CMakeRunner
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMakeRunner();
|
CMakeRunner();
|
||||||
void run(QFutureInterface<void> &fi);
|
|
||||||
void setExecutable(const QString &executable);
|
void setExecutable(const QString &executable);
|
||||||
QString executable() const;
|
QString executable() const;
|
||||||
QString version() const;
|
QString version() const;
|
||||||
bool supportsQtCreator() const;
|
bool supportsQtCreator() const;
|
||||||
void waitForUpToDate() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void run(QFutureInterface<void> &fi);
|
||||||
|
void waitForUpToDate() const;
|
||||||
QString m_executable;
|
QString m_executable;
|
||||||
QString m_version;
|
QString m_version;
|
||||||
bool m_supportsQtCreator;
|
bool m_supportsQtCreator;
|
||||||
|
@@ -221,7 +221,6 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
m_coreListener = new CoreListener(this);
|
m_coreListener = new CoreListener(this);
|
||||||
addObject(m_coreListener);
|
addObject(m_coreListener);
|
||||||
|
|
||||||
|
|
||||||
//register actions
|
//register actions
|
||||||
Core::ActionManager *am = Core::ICore::instance()->actionManager();
|
Core::ActionManager *am = Core::ICore::instance()->actionManager();
|
||||||
|
|
||||||
@@ -682,6 +681,8 @@ void PerforcePlugin::updateActions()
|
|||||||
|
|
||||||
bool PerforcePlugin::managesDirectory(const QString &directory) const
|
bool PerforcePlugin::managesDirectory(const QString &directory) const
|
||||||
{
|
{
|
||||||
|
if (!checkP4Command())
|
||||||
|
return false;
|
||||||
const QString p4Path = directory + QLatin1String("/...");
|
const QString p4Path = directory + QLatin1String("/...");
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("fstat") << QLatin1String("-m1") << p4Path;
|
args << QLatin1String("fstat") << QLatin1String("-m1") << p4Path;
|
||||||
@@ -758,7 +759,7 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
|
|||||||
tempfile.setAutoRemove(true);
|
tempfile.setAutoRemove(true);
|
||||||
const QChar newLine = QLatin1Char('\n');
|
const QChar newLine = QLatin1Char('\n');
|
||||||
const QChar blank = QLatin1Char(' ');
|
const QChar blank = QLatin1Char(' ');
|
||||||
QStringList actualArgs = basicP4Args();
|
QStringList actualArgs = m_settings.basicP4Args();
|
||||||
if (!extraArgs.isEmpty()) {
|
if (!extraArgs.isEmpty()) {
|
||||||
if (tempfile.open()) {
|
if (tempfile.open()) {
|
||||||
QTextStream stream(&tempfile);
|
QTextStream stream(&tempfile);
|
||||||
@@ -773,7 +774,7 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
|
|||||||
actualArgs << args;
|
actualArgs << args;
|
||||||
|
|
||||||
if (logFlags & CommandToWindow) {
|
if (logFlags & CommandToWindow) {
|
||||||
QString command = m_settings.p4Command;
|
QString command = m_settings.p4Command();
|
||||||
command += blank;
|
command += blank;
|
||||||
command += actualArgs.join(QString(blank));
|
command += actualArgs.join(QString(blank));
|
||||||
const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm"));
|
const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm"));
|
||||||
@@ -799,7 +800,7 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
|
|||||||
connect(&process, SIGNAL(stdOutBuffered(QString,bool)), m_perforceOutputWindow, SLOT(append(QString,bool)));
|
connect(&process, SIGNAL(stdOutBuffered(QString,bool)), m_perforceOutputWindow, SLOT(append(QString,bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const Core::Utils::SynchronousProcessResponse sp_resp = process.run(m_settings.p4Command, actualArgs);
|
const Core::Utils::SynchronousProcessResponse sp_resp = process.run(m_settings.p4Command(), actualArgs);
|
||||||
if (Perforce::Constants::debug)
|
if (Perforce::Constants::debug)
|
||||||
qDebug() << sp_resp;
|
qDebug() << sp_resp;
|
||||||
|
|
||||||
@@ -817,7 +818,7 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
|
|||||||
response.message = tr("The process terminated abnormally.");
|
response.message = tr("The process terminated abnormally.");
|
||||||
break;
|
break;
|
||||||
case Core::Utils::SynchronousProcessResponse::StartFailed:
|
case Core::Utils::SynchronousProcessResponse::StartFailed:
|
||||||
response.message = tr("Could not start perforce '%1'. Please check your settings in the preferences.").arg(m_settings.p4Command);
|
response.message = tr("Could not start perforce '%1'. Please check your settings in the preferences.").arg(m_settings.p4Command());
|
||||||
break;
|
break;
|
||||||
case Core::Utils::SynchronousProcessResponse::Hang:
|
case Core::Utils::SynchronousProcessResponse::Hang:
|
||||||
response.message = tr("Perforce did not respond within timeout limit (%1 ms).").arg(p4Timeout );
|
response.message = tr("Perforce did not respond within timeout limit (%1 ms).").arg(p4Timeout );
|
||||||
@@ -969,8 +970,8 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor)
|
|||||||
proc.setEnvironment(environment());
|
proc.setEnvironment(environment());
|
||||||
|
|
||||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||||
proc.start(m_settings.p4Command,
|
proc.start(m_settings.p4Command(),
|
||||||
basicP4Args() << QLatin1String("submit") << QLatin1String("-i"));
|
m_settings.basicP4Args() << QLatin1String("submit") << QLatin1String("-i"));
|
||||||
if (!proc.waitForStarted(p4Timeout)) {
|
if (!proc.waitForStarted(p4Timeout)) {
|
||||||
showOutput(tr("Cannot execute p4 submit."), true);
|
showOutput(tr("Cannot execute p4 submit."), true);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
@@ -1018,8 +1019,8 @@ QString PerforcePlugin::clientFilePath(const QString &serverFilePath)
|
|||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.setEnvironment(environment());
|
proc.setEnvironment(environment());
|
||||||
proc.start(m_settings.p4Command,
|
proc.start(m_settings.p4Command(),
|
||||||
basicP4Args() << QLatin1String("fstat") << serverFilePath);
|
m_settings.basicP4Args() << QLatin1String("fstat") << serverFilePath);
|
||||||
|
|
||||||
QString path;
|
QString path;
|
||||||
if (proc.waitForFinished(3000)) {
|
if (proc.waitForFinished(3000)) {
|
||||||
@@ -1047,22 +1048,9 @@ QString PerforcePlugin::currentFileName()
|
|||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList PerforcePlugin::basicP4Args() const
|
|
||||||
{
|
|
||||||
QStringList lst;
|
|
||||||
if (!m_settings.defaultEnv) {
|
|
||||||
lst << QLatin1String("-c") << m_settings.p4Client;
|
|
||||||
lst << QLatin1String("-p") << m_settings.p4Port;
|
|
||||||
lst << QLatin1String("-u") << m_settings.p4User;
|
|
||||||
}
|
|
||||||
return lst;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PerforcePlugin::checkP4Command() const
|
bool PerforcePlugin::checkP4Command() const
|
||||||
{
|
{
|
||||||
if (m_settings.p4Command.isEmpty())
|
return m_settings.isValid();
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PerforcePlugin::pendingChangesData()
|
QString PerforcePlugin::pendingChangesData()
|
||||||
@@ -1074,8 +1062,8 @@ QString PerforcePlugin::pendingChangesData()
|
|||||||
QString user;
|
QString user;
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.setEnvironment(environment());
|
proc.setEnvironment(environment());
|
||||||
proc.start(m_settings.p4Command,
|
proc.start(m_settings.p4Command(),
|
||||||
basicP4Args() << QLatin1String("info"));
|
m_settings.basicP4Args() << QLatin1String("info"));
|
||||||
if (proc.waitForFinished(3000)) {
|
if (proc.waitForFinished(3000)) {
|
||||||
QString output = QString::fromUtf8(proc.readAllStandardOutput());
|
QString output = QString::fromUtf8(proc.readAllStandardOutput());
|
||||||
if (!output.isEmpty()) {
|
if (!output.isEmpty()) {
|
||||||
@@ -1087,8 +1075,8 @@ QString PerforcePlugin::pendingChangesData()
|
|||||||
}
|
}
|
||||||
if (user.isEmpty())
|
if (user.isEmpty())
|
||||||
return data;
|
return data;
|
||||||
proc.start(m_settings.p4Command,
|
proc.start(m_settings.p4Command(),
|
||||||
basicP4Args() << QLatin1String("changes") << QLatin1String("-s") << QLatin1String("pending") << QLatin1String("-u") << user);
|
m_settings.basicP4Args() << QLatin1String("changes") << QLatin1String("-s") << QLatin1String("pending") << QLatin1String("-u") << user);
|
||||||
if (proc.waitForFinished(3000))
|
if (proc.waitForFinished(3000))
|
||||||
data = QString::fromUtf8(proc.readAllStandardOutput());
|
data = QString::fromUtf8(proc.readAllStandardOutput());
|
||||||
return data;
|
return data;
|
||||||
@@ -1139,17 +1127,24 @@ PerforcePlugin::~PerforcePlugin()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PerforceSettings PerforcePlugin::settings() const
|
const PerforceSettings& PerforcePlugin::settings() const
|
||||||
{
|
{
|
||||||
return m_settings;
|
return m_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerforcePlugin::setSettings(const PerforceSettings &s)
|
void PerforcePlugin::setSettings(const QString &p4Command, const QString &p4Port, const QString &p4Client, const QString p4User, bool defaultEnv)
|
||||||
{
|
{
|
||||||
if (s != m_settings) {
|
|
||||||
m_settings = s;
|
if (m_settings.p4Command() == p4Command
|
||||||
if (QSettings *settings = Core::ICore::instance()->settings())
|
&& m_settings.p4Port() == p4Port
|
||||||
m_settings.toSettings(settings);
|
&& m_settings.p4Client() == p4Client
|
||||||
|
&& m_settings.p4User() == p4User
|
||||||
|
&& m_settings.defaultEnv() == defaultEnv)
|
||||||
|
{
|
||||||
|
// Nothing to do
|
||||||
|
} else {
|
||||||
|
m_settings.setSettings(p4Command, p4Port, p4Client, p4User, defaultEnv);
|
||||||
|
m_settings.toSettings(Core::ICore::instance()->settings());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1162,9 +1157,9 @@ QString PerforcePlugin::fileNameFromPerforceName(const QString& perforceName,
|
|||||||
return perforceName;
|
return perforceName;
|
||||||
// "where" remaps the file to client file tree
|
// "where" remaps the file to client file tree
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
QStringList args(basicP4Args());
|
QStringList args(m_settings.basicP4Args());
|
||||||
args << QLatin1String("where") << perforceName;
|
args << QLatin1String("where") << perforceName;
|
||||||
proc.start(m_settings.p4Command, args);
|
proc.start(m_settings.p4Command(), args);
|
||||||
if (!proc.waitForFinished()) {
|
if (!proc.waitForFinished()) {
|
||||||
*errorMessage = tr("Timeout waiting for \"where\" (%1).").arg(perforceName);
|
*errorMessage = tr("Timeout waiting for \"where\" (%1).").arg(perforceName);
|
||||||
return QString();
|
return QString();
|
||||||
|
@@ -93,7 +93,6 @@ public:
|
|||||||
PerforcePlugin();
|
PerforcePlugin();
|
||||||
~PerforcePlugin();
|
~PerforcePlugin();
|
||||||
|
|
||||||
QStringList basicP4Args() const;
|
|
||||||
SettingsPage *settingsPage() const { return m_settingsPage; }
|
SettingsPage *settingsPage() const { return m_settingsPage; }
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *error_message);
|
bool initialize(const QStringList &arguments, QString *error_message);
|
||||||
@@ -113,8 +112,8 @@ public:
|
|||||||
|
|
||||||
static PerforcePlugin *perforcePluginInstance();
|
static PerforcePlugin *perforcePluginInstance();
|
||||||
|
|
||||||
PerforceSettings settings() const;
|
const PerforceSettings& settings() const;
|
||||||
void setSettings(const PerforceSettings &s);
|
void setSettings(const QString &p4Command, const QString &p4Port, const QString &p4Client, const QString p4User, bool defaultEnv);
|
||||||
|
|
||||||
// Map a perforce name "//xx" to its real name in the file system
|
// Map a perforce name "//xx" to its real name in the file system
|
||||||
QString fileNameFromPerforceName(const QString& perforceName, QString *errorMessage) const;
|
QString fileNameFromPerforceName(const QString& perforceName, QString *errorMessage) const;
|
||||||
|
@@ -33,7 +33,11 @@
|
|||||||
|
|
||||||
#include "perforcesettings.h"
|
#include "perforcesettings.h"
|
||||||
|
|
||||||
|
#include <qtconcurrent/QtConcurrentTools>
|
||||||
|
#include <QtCore/QtConcurrentRun>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QProcess>
|
||||||
|
|
||||||
static const char *groupC = "Perforce";
|
static const char *groupC = "Perforce";
|
||||||
static const char *commandKeyC = "Command";
|
static const char *commandKeyC = "Command";
|
||||||
@@ -55,41 +59,134 @@ static QString defaultCommand()
|
|||||||
namespace Perforce {
|
namespace Perforce {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
PerforceSettings::PerforceSettings() :
|
PerforceSettings::PerforceSettings()
|
||||||
p4Command(defaultCommand()),
|
: m_valid(false)
|
||||||
defaultEnv(true)
|
|
||||||
{
|
{
|
||||||
|
// We do all the initialization in fromSettings
|
||||||
|
}
|
||||||
|
|
||||||
|
PerforceSettings::~PerforceSettings()
|
||||||
|
{
|
||||||
|
// ensure that we are not still running
|
||||||
|
m_future.waitForFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PerforceSettings::isValid() const
|
||||||
|
{
|
||||||
|
m_future.waitForFinished();
|
||||||
|
m_mutex.lock();
|
||||||
|
bool valid = m_valid;
|
||||||
|
m_mutex.unlock();
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PerforceSettings::run(QFutureInterface<void> &fi)
|
||||||
|
{
|
||||||
|
m_mutex.lock();
|
||||||
|
QString executable = m_p4Command;
|
||||||
|
QStringList arguments = basicP4Args();
|
||||||
|
m_mutex.unlock();
|
||||||
|
|
||||||
|
// TODO actually check
|
||||||
|
bool valid = true;
|
||||||
|
|
||||||
|
QProcess p4;
|
||||||
|
p4.start(m_p4Command, QStringList() << "client"<<"-o");
|
||||||
|
p4.waitForFinished(2000);
|
||||||
|
if (p4.state() != QProcess::NotRunning) {
|
||||||
|
p4.kill();
|
||||||
|
p4.waitForFinished();
|
||||||
|
valid = false;
|
||||||
|
} else {
|
||||||
|
QString response = p4.readAllStandardOutput();
|
||||||
|
if (!response.contains("View:"))
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mutex.lock();
|
||||||
|
if (executable == m_p4Command && arguments == basicP4Args()) // Check that those settings weren't changed in between
|
||||||
|
m_valid = valid;
|
||||||
|
m_mutex.unlock();
|
||||||
|
fi.reportFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerforceSettings::fromSettings(QSettings *settings)
|
void PerforceSettings::fromSettings(QSettings *settings)
|
||||||
{
|
{
|
||||||
|
m_mutex.lock();
|
||||||
settings->beginGroup(QLatin1String(groupC));
|
settings->beginGroup(QLatin1String(groupC));
|
||||||
p4Command = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
|
m_p4Command = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
|
||||||
defaultEnv = settings->value(QLatin1String(defaultKeyC), true).toBool();
|
m_defaultEnv = settings->value(QLatin1String(defaultKeyC), true).toBool();
|
||||||
p4Port = settings->value(QLatin1String(portKeyC), QString()).toString();
|
m_p4Port = settings->value(QLatin1String(portKeyC), QString()).toString();
|
||||||
p4Client = settings->value(QLatin1String(clientKeyC), QString()).toString();
|
m_p4Client = settings->value(QLatin1String(clientKeyC), QString()).toString();
|
||||||
p4User = settings->value(QLatin1String(userKeyC), QString()).toString();
|
m_p4User = settings->value(QLatin1String(userKeyC), QString()).toString();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
m_mutex.unlock();
|
||||||
|
|
||||||
|
m_future = QtConcurrent::run(&PerforceSettings::run, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerforceSettings::toSettings(QSettings *settings) const
|
void PerforceSettings::toSettings(QSettings *settings) const
|
||||||
{
|
{
|
||||||
|
m_mutex.lock();
|
||||||
settings->beginGroup(QLatin1String(groupC));
|
settings->beginGroup(QLatin1String(groupC));
|
||||||
settings->setValue(commandKeyC, p4Command);
|
settings->setValue(commandKeyC, m_p4Command);
|
||||||
settings->setValue(defaultKeyC, defaultEnv);
|
settings->setValue(defaultKeyC, m_defaultEnv);
|
||||||
settings->setValue(portKeyC, p4Port);
|
settings->setValue(portKeyC, m_p4Port);
|
||||||
settings->setValue(clientKeyC, p4Client);
|
settings->setValue(clientKeyC, m_p4Client);
|
||||||
settings->setValue(userKeyC, p4User);
|
settings->setValue(userKeyC, m_p4User);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
m_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PerforceSettings::equals(const PerforceSettings &s) const
|
void PerforceSettings::setSettings(const QString &p4Command, const QString &p4Port, const QString &p4Client, const QString p4User, bool defaultEnv)
|
||||||
{
|
{
|
||||||
return p4Command == s.p4Command && p4Port == s.p4Port
|
m_mutex.lock();
|
||||||
&& p4Client == s.p4Client && p4User == s.p4User
|
m_p4Command = p4Command;
|
||||||
&& defaultEnv == s.defaultEnv;
|
m_p4Port = p4Port;
|
||||||
|
m_p4Client = p4Client;
|
||||||
|
m_p4User = p4User;
|
||||||
|
m_defaultEnv = defaultEnv;
|
||||||
|
m_valid = false;
|
||||||
|
m_mutex.unlock();
|
||||||
|
m_future = QtConcurrent::run(&PerforceSettings::run, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PerforceSettings::p4Command() const
|
||||||
|
{
|
||||||
|
return m_p4Command;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PerforceSettings::p4Port() const
|
||||||
|
{
|
||||||
|
return m_p4Port;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PerforceSettings::p4Client() const
|
||||||
|
{
|
||||||
|
return m_p4Client;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PerforceSettings::p4User() const
|
||||||
|
{
|
||||||
|
return m_p4User;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PerforceSettings::defaultEnv() const
|
||||||
|
{
|
||||||
|
return m_defaultEnv;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList PerforceSettings::basicP4Args() const
|
||||||
|
{
|
||||||
|
QStringList lst;
|
||||||
|
if (!m_defaultEnv) {
|
||||||
|
lst << QLatin1String("-c") << m_p4Client;
|
||||||
|
lst << QLatin1String("-p") << m_p4Port;
|
||||||
|
lst << QLatin1String("-u") << m_p4User;
|
||||||
|
}
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
} // Perforce
|
} // Perforce
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#define PERFOCESETTINGS_H
|
#define PERFOCESETTINGS_H
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QFuture>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSettings;
|
class QSettings;
|
||||||
@@ -43,24 +44,35 @@ QT_END_NAMESPACE
|
|||||||
namespace Perforce {
|
namespace Perforce {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
struct PerforceSettings {
|
class PerforceSettings {
|
||||||
|
public:
|
||||||
PerforceSettings();
|
PerforceSettings();
|
||||||
void fromSettings(QSettings *);
|
~PerforceSettings();
|
||||||
|
void fromSettings(QSettings *settings);
|
||||||
void toSettings(QSettings *) const;
|
void toSettings(QSettings *) const;
|
||||||
bool equals(const PerforceSettings &s) const;
|
void setSettings(const QString &p4Command, const QString &p4Port, const QString &p4Client, const QString p4User, bool defaultEnv);
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
QString p4Command;
|
QString p4Command() const;
|
||||||
QString p4Port;
|
QString p4Port() const;
|
||||||
QString p4Client;
|
QString p4Client() const;
|
||||||
QString p4User;
|
QString p4User() const;
|
||||||
bool defaultEnv;
|
bool defaultEnv() const;
|
||||||
|
QStringList basicP4Args() const;
|
||||||
|
private:
|
||||||
|
void run(QFutureInterface<void> &fi);
|
||||||
|
mutable QFuture<void> m_future;
|
||||||
|
mutable QMutex m_mutex;
|
||||||
|
|
||||||
|
QString m_p4Command;
|
||||||
|
QString m_p4Port;
|
||||||
|
QString m_p4Client;
|
||||||
|
QString m_p4User;
|
||||||
|
bool m_defaultEnv;
|
||||||
|
bool m_valid;
|
||||||
|
Q_DISABLE_COPY(PerforceSettings);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const PerforceSettings &p1, const PerforceSettings &p2)
|
|
||||||
{ return p1.equals(p2); }
|
|
||||||
inline bool operator!=(const PerforceSettings &p1, const PerforceSettings &p2)
|
|
||||||
{ return !p1.equals(p2); }
|
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
} // Perforce
|
} // Perforce
|
||||||
|
|
||||||
|
@@ -49,24 +49,38 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
|
|||||||
m_ui.pathChooser->setExpectedKind(PathChooser::Command);
|
m_ui.pathChooser->setExpectedKind(PathChooser::Command);
|
||||||
}
|
}
|
||||||
|
|
||||||
PerforceSettings SettingsPageWidget::settings() const
|
QString SettingsPageWidget::p4Command() const
|
||||||
{
|
{
|
||||||
PerforceSettings rc;
|
return m_ui.pathChooser->path();
|
||||||
rc.p4Command = m_ui.pathChooser->path();
|
}
|
||||||
rc.defaultEnv = m_ui.defaultCheckBox->isChecked();
|
|
||||||
rc.p4Port = m_ui.portLineEdit->text();
|
bool SettingsPageWidget::defaultEnv() const
|
||||||
rc.p4Client = m_ui.clientLineEdit->text();
|
{
|
||||||
rc.p4User = m_ui.userLineEdit->text();
|
return m_ui.defaultCheckBox->isChecked();
|
||||||
return rc;
|
}
|
||||||
|
|
||||||
|
QString SettingsPageWidget::p4Port() const
|
||||||
|
{
|
||||||
|
return m_ui.portLineEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SettingsPageWidget::p4User() const
|
||||||
|
{
|
||||||
|
return m_ui.userLineEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SettingsPageWidget::p4Client() const
|
||||||
|
{
|
||||||
|
return m_ui.clientLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPageWidget::setSettings(const PerforceSettings &s)
|
void SettingsPageWidget::setSettings(const PerforceSettings &s)
|
||||||
{
|
{
|
||||||
m_ui.pathChooser->setPath(s.p4Command);
|
m_ui.pathChooser->setPath(s.p4Command());
|
||||||
m_ui.defaultCheckBox->setChecked(s.defaultEnv);
|
m_ui.defaultCheckBox->setChecked(s.defaultEnv());
|
||||||
m_ui.portLineEdit->setText(s.p4Port);
|
m_ui.portLineEdit->setText(s.p4Port());
|
||||||
m_ui.clientLineEdit->setText(s.p4Client);
|
m_ui.clientLineEdit->setText(s.p4Client());
|
||||||
m_ui.userLineEdit->setText(s.p4User);
|
m_ui.userLineEdit->setText(s.p4User());
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsPage::SettingsPage()
|
SettingsPage::SettingsPage()
|
||||||
@@ -101,5 +115,5 @@ void SettingsPage::apply()
|
|||||||
if (!m_widget)
|
if (!m_widget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PerforcePlugin::perforcePluginInstance()->setSettings(m_widget->settings());
|
PerforcePlugin::perforcePluginInstance()->setSettings(m_widget->p4Command(), m_widget->p4Port(), m_widget->p4Client(), m_widget->p4User(), m_widget->defaultEnv());
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,12 @@ class SettingsPageWidget : public QWidget {
|
|||||||
public:
|
public:
|
||||||
explicit SettingsPageWidget(QWidget *parent);
|
explicit SettingsPageWidget(QWidget *parent);
|
||||||
|
|
||||||
PerforceSettings settings() const;
|
QString p4Command() const;
|
||||||
|
bool defaultEnv() const;
|
||||||
|
QString p4Port() const;
|
||||||
|
QString p4User() const;
|
||||||
|
QString p4Client() const;
|
||||||
|
|
||||||
void setSettings(const PerforceSettings &);
|
void setSettings(const PerforceSettings &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user