Commit 738d1cce authored by con's avatar con

Remove the special 'external text editor' setting.

It's done via a external tool description now.
parent 845e9d51
......@@ -200,7 +200,6 @@ struct EditorManagerPrivate {
QAction *m_gotoPreviousDocHistoryAction;
QAction *m_goBackAction;
QAction *m_goForwardAction;
QAction *m_openInExternalEditorAction;
QAction *m_splitAction;
QAction *m_splitSideBySideAction;
QAction *m_removeCurrentSplitAction;
......@@ -214,7 +213,6 @@ struct EditorManagerPrivate {
Internal::OpenEditorsViewFactory *m_openEditorsFactory;
OpenEditorsModel *m_editorModel;
QString m_externalEditor;
IFile::ReloadSetting m_reloadSetting;
IFile::Utf8BomSetting m_utf8BomSetting;
......@@ -237,7 +235,6 @@ EditorManagerPrivate::EditorManagerPrivate(ICore *core, QWidget *parent) :
m_gotoPreviousDocHistoryAction(new QAction(EditorManager::tr("Previous Open Document in History"), parent)),
m_goBackAction(new QAction(QIcon(QLatin1String(Constants::ICON_PREV)), EditorManager::tr("Go Back"), parent)),
m_goForwardAction(new QAction(QIcon(QLatin1String(Constants::ICON_NEXT)), EditorManager::tr("Go Forward"), parent)),
m_openInExternalEditorAction(new QAction(EditorManager::tr("Open in External Editor"), parent)),
m_windowPopup(0),
m_coreListener(0),
m_reloadSetting(IFile::AlwaysAsk),
......@@ -435,11 +432,6 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Editor"), editManagerContext);
advancedMenu->addAction(cmd, Constants::G_EDIT_EDITOR);
cmd = am->registerAction(m_d->m_openInExternalEditorAction, Constants::OPEN_IN_EXTERNAL_EDITOR, editManagerContext);
cmd->setDefaultKeySequence(QKeySequence(tr("Alt+V,Alt+I")));
advancedMenu->addAction(cmd, Constants::G_EDIT_EDITOR);
connect(m_d->m_openInExternalEditorAction, SIGNAL(triggered()), this, SLOT(openInExternalEditor()));
// other setup
m_d->m_splitter = new SplitterOrView(m_d->m_editorModel);
m_d->m_view = m_d->m_splitter->view();
......@@ -488,19 +480,6 @@ EditorToolBar *EditorManager::createToolBar(QWidget *parent)
return new EditorToolBar(parent);
}
QString EditorManager::defaultExternalEditor() const
{
#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 QLatin1String("notepad %f");
#endif
}
void EditorManager::removeEditor(IEditor *editor)
{
bool isDuplicate = m_d->m_editorModel->isDuplicate(editor);
......@@ -1628,8 +1607,6 @@ void EditorManager::updateActions()
m_d->m_removeCurrentSplitAction->setEnabled(hasSplitter);
m_d->m_removeAllSplitsAction->setEnabled(hasSplitter);
m_d->m_gotoOtherSplitAction->setEnabled(hasSplitter);
m_d->m_openInExternalEditorAction->setEnabled(curEditor != 0);
}
bool EditorManager::hasSplitter() const
......@@ -1811,7 +1788,6 @@ bool EditorManager::restoreState(const QByteArray &state)
}
static const char * const documentStatesKey = "EditorManager/DocumentStates";
static const char * const externalEditorKey = "EditorManager/ExternalEditorCommand";
static const char * const reloadBehaviorKey = "EditorManager/ReloadBehavior";
static const char * const utf8BomBehaviorKey = "EditorManager/Utf8BomBehavior";
......@@ -1819,7 +1795,6 @@ void EditorManager::saveSettings()
{
SettingsDatabase *settings = m_d->m_core->settingsDatabase();
settings->setValue(QLatin1String(documentStatesKey), m_d->m_editorStates);
settings->setValue(QLatin1String(externalEditorKey), m_d->m_externalEditor);
settings->setValue(QLatin1String(reloadBehaviorKey), m_d->m_reloadSetting);
settings->setValue(QLatin1String(utf8BomBehaviorKey), m_d->m_utf8BomSetting);
}
......@@ -1833,17 +1808,11 @@ void EditorManager::readSettings()
.value<QMap<QString, QVariant> >();
qs->remove(QLatin1String(documentStatesKey));
}
if (qs->contains(QLatin1String(externalEditorKey))) {
m_d->m_externalEditor = qs->value(QLatin1String(externalEditorKey)).toString();
qs->remove(QLatin1String(externalEditorKey));
}
SettingsDatabase *settings = m_d->m_core->settingsDatabase();
if (settings->contains(QLatin1String(documentStatesKey)))
m_d->m_editorStates = settings->value(QLatin1String(documentStatesKey))
.value<QMap<QString, QVariant> >();
if (settings->contains(QLatin1String(externalEditorKey)))
m_d->m_externalEditor = settings->value(QLatin1String(externalEditorKey)).toString();
if (settings->contains(QLatin1String(reloadBehaviorKey)))
m_d->m_reloadSetting = (IFile::ReloadSetting)settings->value(QLatin1String(reloadBehaviorKey)).toInt();
......@@ -1907,106 +1876,6 @@ void EditorManager::hideEditorStatusBar(const QString &id)
currentEditorView()->hideEditorStatusBar(id);
}
QString EditorManager::externalEditorHelpText() const
{
QString help = tr(
"<table border=1 cellspacing=0 cellpadding=3>"
"<tr><th>Variable</th><th>Expands to</th></tr>"
"<tr><td>%f</td><td>file name</td></tr>"
"<tr><td>%l</td><td>current line number</td></tr>"
"<tr><td>%c</td><td>current column number</td></tr>"
"<tr><td>%x</td><td>editor's x position on screen</td></tr>"
"<tr><td>%y</td><td>editor's y position on screen</td></tr>"
"<tr><td>%w</td><td>editor's width in pixels</td></tr>"
"<tr><td>%h</td><td>editor's height in pixels</td></tr>"
"<tr><td>%W</td><td>editor's width in characters</td></tr>"
"<tr><td>%H</td><td>editor's height in characters</td></tr>"
"<tr><td>%%</td><td>%</td></tr>"
"</table>");
return help;
}
void EditorManager::openInExternalEditor()
{
QString command = m_d->m_externalEditor;
if (command.isEmpty())
command = defaultExternalEditor();
if (command.isEmpty())
return;
IEditor *editor = currentEditor();
if (!editor)
return;
if (editor->file()->isModified()) {
bool cancelled = false;
QList<IFile*> list = m_d->m_core->fileManager()->
saveModifiedFiles(QList<IFile*>() << editor->file(), &cancelled);
if (cancelled)
return;
}
QRect rect = editor->widget()->rect();
QFont font = editor->widget()->font();
QFontMetrics fm(font);
rect.moveTo(editor->widget()->mapToGlobal(QPoint(0,0)));
QString pre = command;
QString cmd;
for (int i = 0; i < pre.size(); ++i) {
QChar c = pre.at(i);
if (c == QLatin1Char('%') && i < pre.size()-1) {
c = pre.at(++i);
QString s;
if (c == QLatin1Char('f'))
s = editor->file()->fileName();
else if (c == QLatin1Char('l'))
s = QString::number(editor->currentLine());
else if (c == QLatin1Char('c'))
s = QString::number(editor->currentColumn());
else if (c == QLatin1Char('x'))
s = QString::number(rect.x());
else if (c == QLatin1Char('y'))
s = QString::number(rect.y());
else if (c == QLatin1Char('w'))
s = QString::number(rect.width());
else if (c == QLatin1Char('h'))
s = QString::number(rect.height());
else if (c == QLatin1Char('W'))
s = QString::number(rect.width() / fm.width(QLatin1Char('x')));
else if (c == QLatin1Char('H'))
s = QString::number(rect.height() / fm.lineSpacing());
else if (c == QLatin1Char('%'))
s = c;
else {
s = QLatin1Char('%');
s += c;
}
cmd += s;
continue;
}
cmd += c;
}
QProcess::startDetached(cmd);
}
void EditorManager::setExternalEditor(const QString &editor)
{
if (editor.isEmpty() || editor == defaultExternalEditor())
m_d->m_externalEditor = defaultExternalEditor();
else
m_d->m_externalEditor = editor;
}
QString EditorManager::externalEditor() const
{
if (m_d->m_externalEditor.isEmpty())
return defaultExternalEditor();
return m_d->m_externalEditor;
}
void EditorManager::setReloadSetting(IFile::ReloadSetting behavior)
{
m_d->m_reloadSetting = behavior;
......
......@@ -184,11 +184,6 @@ public:
EditorFactoryList editorFactories(const MimeType &mimeType, bool bestMatchOnly = true) const;
ExternalEditorList externalEditors(const MimeType &mimeType, bool bestMatchOnly = true) const;
void setExternalEditor(const QString &);
QString externalEditor() const;
QString defaultExternalEditor() const;
QString externalEditorHelpText() const;
void setReloadSetting(IFile::ReloadSetting behavior);
IFile::ReloadSetting reloadSetting() const;
......@@ -212,7 +207,6 @@ signals:
public slots:
bool closeAllEditors(bool askAboutModifiedEditors = true);
void openInExternalEditor();
bool saveFile(Core::IFile *file = 0);
bool saveFileAs(Core::IFile *file = 0);
......
......@@ -125,8 +125,8 @@ void GeneralSettings::fillLanguageBox() const
QWidget *GeneralSettings::createPage(QWidget *parent)
{
m_page = new Ui::GeneralSettings();
QWidget *w = new QWidget(parent);
m_page->setupUi(w);
m_widget = new QWidget(parent);
m_page->setupUi(m_widget);
QSettings* settings = Core::ICore::instance()->settings();
Q_UNUSED(settings) // Windows
......@@ -134,7 +134,6 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
fillLanguageBox();
m_page->colorButton->setColor(StyleHelper::requestedBaseColor());
m_page->externalEditorEdit->setText(EditorManager::instance()->externalEditor());
m_page->reloadBehavior->setCurrentIndex(EditorManager::instance()->reloadSetting());
#ifdef Q_OS_UNIX
m_page->terminalEdit->setText(ConsoleProcess::terminalEmulator(settings));
......@@ -155,10 +154,6 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
connect(m_page->resetButton, SIGNAL(clicked()),
this, SLOT(resetInterfaceColor()));
connect(m_page->resetEditorButton, SIGNAL(clicked()),
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()));
......@@ -178,11 +173,10 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
<< m_page->languageLabel->text() << sep
<< m_page->systemBox->title() << sep
<< m_page->terminalLabel->text() << sep
<< m_page->editorLabel->text() << sep
<< m_page->modifiedLabel->text();
m_searchKeywords.remove(QLatin1Char('&'));
}
return w;
return m_widget;
}
bool GeneralSettings::matches(const QString &s) const
......@@ -198,7 +192,6 @@ void GeneralSettings::apply()
setLanguage(m_page->languageBox->itemData(currentIndex, Qt::UserRole).toString());
// Apply the new base color if accepted
StyleHelper::setBaseColor(m_page->colorButton->color());
EditorManager::instance()->setExternalEditor(m_page->externalEditorEdit->text());
EditorManager::instance()->setReloadSetting(IFile::ReloadSetting(m_page->reloadBehavior->currentIndex()));
#ifdef Q_OS_UNIX
ConsoleProcess::setTerminalEmulator(Core::ICore::instance()->settings(),
......@@ -222,11 +215,6 @@ void GeneralSettings::resetInterfaceColor()
m_page->colorButton->setColor(StyleHelper::DEFAULT_BASE_COLOR);
}
void GeneralSettings::resetExternalEditor()
{
m_page->externalEditorEdit->setText(EditorManager::instance()->defaultExternalEditor());
}
#ifdef Q_OS_UNIX
void GeneralSettings::resetTerminal()
{
......@@ -257,18 +245,13 @@ void GeneralSettings::variableHelpDialogCreator(const QString &helpText)
tr("Variables"),
helpText,
QMessageBox::Close,
m_page->helpExternalEditorButton);
m_widget);
mb->setWindowModality(Qt::NonModal);
m_dialog = mb;
mb->show();
}
void GeneralSettings::showHelpForExternalEditor()
{
variableHelpDialogCreator(EditorManager::instance()->externalEditorHelpText());
}
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
void GeneralSettings::showHelpForFileBrowser()
{
......
......@@ -67,9 +67,7 @@ public:
private slots:
void resetInterfaceColor();
void resetExternalEditor();
void resetLanguage();
void showHelpForExternalEditor();
#ifdef Q_OS_UNIX
# ifndef Q_OS_MAC
void showHelpForFileBrowser();
......@@ -86,6 +84,7 @@ private:
Ui::GeneralSettings *m_page;
QString m_searchKeywords;
QPointer<QMessageBox> m_dialog;
QPointer<QWidget> m_widget;
};
} // namespace Internal
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>527</width>
<height>323</height>
<height>295</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
......@@ -145,51 +145,16 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="editorLabel">
<property name="text">
<string>External editor:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="externalEditorEdit"/>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="resetEditorButton">
<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>
<item row="1" column="3">
<widget class="QToolButton" name="helpExternalEditorButton">
<property name="text">
<string>?</string>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/core/images/help.png</normaloff>:/core/images/help.png</iconset>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="externalFileBrowserLabel">
<property name="text">
<string>External file browser:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QLineEdit" name="externalFileBrowserEdit"/>
</item>
<item row="2" column="2">
<item row="1" column="2">
<widget class="QToolButton" name="resetFileBrowserButton">
<property name="toolTip">
<string>Reset to default</string>
......@@ -203,7 +168,7 @@
</property>
</widget>
</item>
<item row="2" column="3">
<item row="1" column="3">
<widget class="QToolButton" name="helpExternalFileBrowserButton">
<property name="text">
<string>?</string>
......@@ -214,7 +179,7 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<item row="2" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="modifiedLabel">
......@@ -291,9 +256,6 @@
<tabstop>languageBox</tabstop>
<tabstop>terminalEdit</tabstop>
<tabstop>resetTerminalButton</tabstop>
<tabstop>externalEditorEdit</tabstop>
<tabstop>resetEditorButton</tabstop>
<tabstop>helpExternalEditorButton</tabstop>
<tabstop>externalFileBrowserEdit</tabstop>
<tabstop>resetFileBrowserButton</tabstop>
<tabstop>helpExternalFileBrowserButton</tabstop>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment