diff --git a/share/qtcreator/runInTerminal.command b/share/qtcreator/runInTerminal.command index 372820c1b110491dff57148375d717eb99a5ba98..3cc5baa050df1db2ae4becc90e7d63a0ce9b2c59 100755 --- a/share/qtcreator/runInTerminal.command +++ b/share/qtcreator/runInTerminal.command @@ -1,11 +1,50 @@ -#!/bin/bash -osascript >/dev/null 2>&1 <<EOF +#! /bin/bash + +### FIXME: +# - currentTab and geometry stuff does not work with macX 10.4 (tiger) +# - -async is always in effect, i.e., synchronous execution is not implemented + +geom= +async= +while test -n "$1"; do + case $1 in + -async) + async=1 + shift;; + -geom) + shift + w=${1%%x*} + y=${1#*x} + h=${y%%+*} + y=${y#*+} + x=${y%%+*} + y=${y#*+} + geom="\ + set number of columns of currentTab to $w + set number of rows of currentTab to $h + set position of windows whose tabs contains currentTab to {$x, $y}" + shift;; + -e) + shift + break;; + *) + echo "Invalid call" >&2 + exit 1;; + esac +done +args= +for i in "$@"; do + i=${i//\\/\\\\\\\\} + i=${i//\"/\\\\\\\"} + i=${i//\$/\\\\\\\$} + i=${i//\`/\\\\\\\`} + args="$args \\\"$i\\\"" +done +osascript <<EOF tell application "Terminal" - do script "$1 $2 +$3 +\"normal $4|\"; exit" + do script "$args; exit" set currentTab to the result - set number of columns of currentTab to $5 - set number of rows of currentTab to $6 - set position of windows whose tabs contains currentTab to {$7, $8} +$geom activate end tell EOF diff --git a/src/libs/utils/consoleprocess.h b/src/libs/utils/consoleprocess.h index 821e8cb7c8785c2ddb53e3cdb46d4424c2120950..6da57e375b9f168bc8a0fb9f8e4a964ec3d182bf 100644 --- a/src/libs/utils/consoleprocess.h +++ b/src/libs/utils/consoleprocess.h @@ -47,6 +47,7 @@ QT_END_NAMESPACE #endif QT_BEGIN_NAMESPACE +class QSettings; class QTemporaryFile; QT_END_NAMESPACE @@ -72,6 +73,13 @@ public: int exitCode() const { return m_appCode; } // This will be the signal number if exitStatus == CrashExit QProcess::ExitStatus exitStatus() const { return m_appStatus; } +#ifdef Q_OS_UNIX + void setSettings(QSettings *settings) { m_settings = settings; } + static QString defaultTerminalEmulator(); + static QString terminalEmulator(const QSettings *settings); + static void setTerminalEmulator(QSettings *settings, const QString &term); +#endif + signals: void processError(const QString &error); // These reflect the state of the actual client process @@ -114,6 +122,7 @@ private: #else QProcess m_process; QByteArray m_stubServerDir; + QSettings *m_settings; #endif }; diff --git a/src/libs/utils/consoleprocess_unix.cpp b/src/libs/utils/consoleprocess_unix.cpp index 276d6c77f23f8338551b205ce23e94fbbc7934fd..a43264b59d021f41647fa371fee22522190a6778 100644 --- a/src/libs/utils/consoleprocess_unix.cpp +++ b/src/libs/utils/consoleprocess_unix.cpp @@ -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); +} diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 17d46349d5556b1ed5b465c2065f6ed11ed176ee..49fedc4dcb632048cff858f7bbd408217024dbbf 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -49,6 +49,7 @@ #include <extensionsystem/pluginmanager.h> +#include <utils/consoleprocess.h> #include <utils/qtcassert.h> #include <QtCore/QDebug> @@ -73,6 +74,7 @@ Q_DECLARE_METATYPE(Core::IEditor*) using namespace Core; using namespace Core::Internal; +using namespace Core::Utils; enum { debugEditorManager=0 }; @@ -429,15 +431,14 @@ void EditorManager::init() QString EditorManager::defaultExternalEditor() const { -#ifdef Q_OS_MAC - return m_d->m_core->resourcePath() - +QLatin1String("/runInTerminal.command vi %f %l %c %W %H %x %y"); -#elif defined(Q_OS_UNIX) - return QLatin1String("xterm -geom %Wx%H+%x+%y -e vi %f +%l +\"normal %c|\""); -#elif defined (Q_OS_WIN) - return QLatin1String("notepad %f"); +#ifdef Q_OS_UNIX + return ConsoleProcess::defaultTerminalEmulator() + QLatin1String( +# ifdef Q_OS_MAC + " -async" +# endif + " -geom %Wx%H+%x+%y -e vi %f +%l +\"normal %c|\""); #else - return QString(); + return QLatin1String("notepad %f"); #endif } diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp index 969599b2d8a9140341aed96ec2f3691e7e04596f..ff0f73f330275fc13e35e2a2d292e9e26cf555bc 100644 --- a/src/plugins/coreplugin/generalsettings.cpp +++ b/src/plugins/coreplugin/generalsettings.cpp @@ -31,11 +31,14 @@ #include "stylehelper.h" #include "utils/qtcolorbutton.h" +#include <utils/consoleprocess.h> #include <coreplugin/editormanager/editormanager.h> +#include <coreplugin/icore.h> #include <QtGui/QMessageBox> #include "ui_generalsettings.h" +using namespace Core::Utils; using namespace Core::Internal; GeneralSettings::GeneralSettings(): @@ -71,6 +74,13 @@ QWidget *GeneralSettings::createPage(QWidget *parent) m_page->colorButton->setColor(StyleHelper::baseColor()); m_page->externalEditorEdit->setText(EditorManager::instance()->externalEditor()); +#ifdef Q_OS_UNIX + m_page->terminalEdit->setText(ConsoleProcess::terminalEmulator(Core::ICore::instance()->settings())); +#else + m_page->terminalLabel->hide(); + m_page->terminalEdit->hide(); + m_page->resetTerminalButton->hide(); +#endif connect(m_page->resetButton, SIGNAL(clicked()), this, SLOT(resetInterfaceColor())); @@ -78,6 +88,10 @@ QWidget *GeneralSettings::createPage(QWidget *parent) this, SLOT(resetExternalEditor())); connect(m_page->helpExternalEditorButton, SIGNAL(clicked()), this, SLOT(showHelpForExternalEditor())); +#ifdef Q_OS_UNIX + connect(m_page->resetTerminalButton, SIGNAL(clicked()), + this, SLOT(resetTerminal())); +#endif return w; } @@ -87,6 +101,10 @@ void GeneralSettings::apply() // Apply the new base color if accepted StyleHelper::setBaseColor(m_page->colorButton->color()); EditorManager::instance()->setExternalEditor(m_page->externalEditorEdit->text()); +#ifdef Q_OS_UNIX + ConsoleProcess::setTerminalEmulator(Core::ICore::instance()->settings(), + m_page->terminalEdit->text()); +#endif } void GeneralSettings::finish() @@ -104,6 +122,13 @@ void GeneralSettings::resetExternalEditor() m_page->externalEditorEdit->setText(EditorManager::instance()->defaultExternalEditor()); } +#ifdef Q_OS_UNIX +void GeneralSettings::resetTerminal() +{ + m_page->terminalEdit->setText(ConsoleProcess::defaultTerminalEmulator() + QLatin1String(" -e")); +} +#endif + void GeneralSettings::showHelpForExternalEditor() { if (m_dialog) { diff --git a/src/plugins/coreplugin/generalsettings.h b/src/plugins/coreplugin/generalsettings.h index 9135df7f4a303e5c41a3f54492c2dd3f5fee77e6..d75cd2d8a3938d805044b9ff149e4569d15aed03 100644 --- a/src/plugins/coreplugin/generalsettings.h +++ b/src/plugins/coreplugin/generalsettings.h @@ -59,6 +59,9 @@ private slots: void resetInterfaceColor(); void resetExternalEditor(); void showHelpForExternalEditor(); +#ifdef Q_OS_UNIX + void resetTerminal(); +#endif private: Ui_GeneralSettings *m_page; diff --git a/src/plugins/coreplugin/generalsettings.ui b/src/plugins/coreplugin/generalsettings.ui index c014fae607b8a6585a8b966abeadb117573bff85..826c45ae6bc0d32a0cf05a10d3e9d53abd84761a 100644 --- a/src/plugins/coreplugin/generalsettings.ui +++ b/src/plugins/coreplugin/generalsettings.ui @@ -96,6 +96,34 @@ </item> </layout> </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="terminalLabel"> + <property name="text"> + <string>Terminal:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="terminalEdit"/> + </item> + <item> + <widget class="QToolButton" name="resetTerminalButton"> + <property name="toolTip"> + <string>Reset to default</string> + </property> + <property name="text"> + <string>R</string> + </property> + <property name="icon"> + <iconset resource="core.qrc"> + <normaloff>:/core/images/reset.png</normaloff>:/core/images/reset.png</iconset> + </property> + </widget> + </item> + </layout> + </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_5"> <item> diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index a2e2b6f06146be8cc98db6c69d9aedcaa640b89c..9ca31151232628982ed0e9a8a4b8cf6be5f006e2 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -267,11 +267,6 @@ DebuggerSettings *DebuggerSettings::instance() item->setCheckable(true); instance->insertItem(UseToolTips, item); - item = new SavedAction(instance); - item->setDefaultValue("xterm"); - item->setSettingsKey("DebugMode", "Terminal"); - instance->insertItem(TerminalApplication, item); - item = new SavedAction(instance); item->setSettingsKey("DebugMode", "ListSourceFiles"); item->setText(tr("List source files")); diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 4b0ebd66c86f71b5331b6c720921c3421a482118..7b93ad3c3e43478847eb3b55ee1eaa72a5254d8c 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -70,7 +70,6 @@ enum DebuggerActionCode AdjustColumnWidths, AlwaysAdjustColumnWidths, AutoQuit, - TerminalApplication, LockView, // Gdb diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index ea41b9854eae2b38c0c852d0a49e5b2a199363d9..430141716d9087318a5b072927ec801609c355ba 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -269,8 +269,6 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) m_ui.gdbLocationChooser->setPromptDialogTitle(tr("Choose Gdb Location")); m_ui.scriptFileChooser->setExpectedKind(Core::Utils::PathChooser::File); m_ui.scriptFileChooser->setPromptDialogTitle(tr("Choose Location of Startup Script File")); - m_ui.terminalChooser->setExpectedKind(Core::Utils::PathChooser::Command); - m_ui.terminalChooser->setPromptDialogTitle(tr("Choose Location of Terminal Application")); m_group.clear(); m_group.insert(theDebuggerAction(GdbLocation), @@ -279,8 +277,6 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) m_ui.scriptFileChooser); m_group.insert(theDebuggerAction(GdbEnvironment), m_ui.environmentEdit); - m_group.insert(theDebuggerAction(TerminalApplication), - m_ui.terminalChooser); m_group.insert(theDebuggerAction(AllPluginBreakpoints), m_ui.radioButtonAllPluginBreakpoints); diff --git a/src/plugins/debugger/gdboptionpage.ui b/src/plugins/debugger/gdboptionpage.ui index c3994e7b8e948d08a46a6d3435fd0cbd9da03646..baf91e4667dbf2832e5216b7d4fd6a43e2a54f77 100644 --- a/src/plugins/debugger/gdboptionpage.ui +++ b/src/plugins/debugger/gdboptionpage.ui @@ -39,17 +39,6 @@ </property> </widget> </item> - <item row="3" column="0"> - <widget class="QLabel" name="terminalLocation"> - <property name="toolTip"> - <string>This is either a full abolute path leading to the terminal -you indent to use or the name of a terminal that will be searched in your PATH.</string> - </property> - <property name="text"> - <string>Terminal:</string> - </property> - </widget> - </item> <item row="1" column="0"> <widget class="QLabel" name="labelEnvironment"> <property name="text"> @@ -76,9 +65,6 @@ you indent to use or the name of a terminal that will be searched in your PATH.< <item row="0" column="1"> <widget class="Core::Utils::PathChooser" name="gdbLocationChooser" native="true"/> </item> - <item row="3" column="1"> - <widget class="Core::Utils::PathChooser" name="terminalChooser" native="true"/> - </item> </layout> </widget> </item> diff --git a/src/plugins/projectexplorer/applicationlauncher_x11.cpp b/src/plugins/projectexplorer/applicationlauncher_x11.cpp index b82db98a4168c205705c51759ed8025196d12827..b79c25ff82ccfa3b6a6d246d6b72ef5dbc251ca3 100644 --- a/src/plugins/projectexplorer/applicationlauncher_x11.cpp +++ b/src/plugins/projectexplorer/applicationlauncher_x11.cpp @@ -30,6 +30,8 @@ #include "applicationlauncher.h" #include "consoleprocess.h" +#include <coreplugin/icore.h> + #include <QtCore/QTimer> using namespace ProjectExplorer::Internal; @@ -52,6 +54,7 @@ ApplicationLauncher::ApplicationLauncher(QObject *parent) this, SLOT(bringToForeground())); m_consoleProcess = new ConsoleProcess(this); + m_consoleProcess->setSettings(Core::ICore::instance()->settings()); connect(m_consoleProcess, SIGNAL(processError(const QString&)), this, SIGNAL(applicationError(const QString&))); connect(m_consoleProcess, SIGNAL(processStopped()),