forked from qt-creator/qt-creator
make terminal emulator configurable centrally
this includes changing the runInTerminal.command command line. the terminal setting mock from the debugger plugin is gone again.
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
#include "consoleprocess.h"
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QTemporaryFile>
|
||||
|
||||
#include <QtNetwork/QLocalSocket>
|
||||
@@ -48,6 +50,7 @@ ConsoleProcess::ConsoleProcess(QObject *parent)
|
||||
m_debug = false;
|
||||
m_appPid = 0;
|
||||
m_stubSocket = 0;
|
||||
m_settings = 0;
|
||||
|
||||
connect(&m_stubServer, SIGNAL(newConnection()), SLOT(stubConnectionAvailable()));
|
||||
|
||||
@@ -88,8 +91,8 @@ bool ConsoleProcess::start(const QString &program, const QStringList &args)
|
||||
m_tempFile->flush();
|
||||
}
|
||||
|
||||
QStringList xtermArgs;
|
||||
xtermArgs << "-e"
|
||||
QStringList xtermArgs = terminalEmulator(m_settings).split(QLatin1Char(' ')); // FIXME: quoting
|
||||
xtermArgs
|
||||
#ifdef Q_OS_MAC
|
||||
<< (QCoreApplication::applicationDirPath() + "/../Resources/qtcreator_process_stub")
|
||||
#else
|
||||
@@ -102,10 +105,11 @@ bool ConsoleProcess::start(const QString &program, const QStringList &args)
|
||||
<< (m_tempFile ? m_tempFile->fileName() : 0)
|
||||
<< program << args;
|
||||
|
||||
m_process.start(QLatin1String("xterm"), xtermArgs);
|
||||
QString xterm = xtermArgs.takeFirst();
|
||||
m_process.start(xterm, xtermArgs);
|
||||
if (!m_process.waitForStarted()) {
|
||||
stubServerShutdown();
|
||||
emit processError(tr("Cannot start console emulator xterm."));
|
||||
emit processError(tr("Cannot start terminal emulator %1.").arg(xterm));
|
||||
delete m_tempFile;
|
||||
m_tempFile = 0;
|
||||
return false;
|
||||
@@ -232,3 +236,27 @@ void ConsoleProcess::stubExited()
|
||||
}
|
||||
emit wrapperStopped();
|
||||
}
|
||||
|
||||
QString ConsoleProcess::defaultTerminalEmulator()
|
||||
{
|
||||
// FIXME: enable this once runInTerminal works nicely
|
||||
#if 0 //def Q_OS_MAC
|
||||
return QDir::cleanPath(QCoreApplication::applicationDirPath()
|
||||
+ QLatin1String("/../Resources/runInTerminal.command"));
|
||||
#else
|
||||
return QLatin1String("xterm");
|
||||
#endif
|
||||
}
|
||||
|
||||
QString ConsoleProcess::terminalEmulator(const QSettings *settings)
|
||||
{
|
||||
QString dflt = defaultTerminalEmulator() + QLatin1String(" -e");
|
||||
if (!settings)
|
||||
return dflt;
|
||||
return settings->value(QLatin1String("General/TerminalEmulator"), dflt).toString();
|
||||
}
|
||||
|
||||
void ConsoleProcess::setTerminalEmulator(QSettings *settings, const QString &term)
|
||||
{
|
||||
return settings->setValue(QLatin1String("General/TerminalEmulator"), term);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user