forked from qt-creator/qt-creator
Add a "System Editor" external editor, for use with Open with...
This commit is contained in:
@@ -14,5 +14,5 @@ SOURCES += bineditorplugin.cpp \
|
||||
|
||||
RESOURCES += bineditor.qrc
|
||||
|
||||
OTHER_FILES += BinEditor.pluginspec BinEditor.mimetypes.xml \
|
||||
OTHER_FILES += BinEditor.pluginspec \
|
||||
ImageViewer.mimetypes.xml
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/bineditor">
|
||||
<file>BinEditor.mimetypes.xml</file>
|
||||
<file>ImageViewer.mimetypes.xml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -483,8 +483,6 @@ bool BinEditorPlugin::initialize(const QStringList &arguments, QString *errorMes
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/bineditor/ImageViewer.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/bineditor/BinEditor.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
|
||||
connect(core, SIGNAL(contextAboutToChange(Core::IContext *)),
|
||||
this, SLOT(updateCurrentEditor(Core::IContext *)));
|
||||
|
||||
@@ -43,5 +43,6 @@
|
||||
<file>images/unlocked.png</file>
|
||||
<file>images/extension.png</file>
|
||||
<file>images/darkclosebutton.png</file>
|
||||
<file>editormanager/BinFiles.mimetypes.xml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -79,7 +79,8 @@ SOURCES += mainwindow.cpp \
|
||||
dialogs/iwizard.cpp \
|
||||
settingsdatabase.cpp \
|
||||
eventfilteringmainwindow.cpp \
|
||||
imode.cpp
|
||||
imode.cpp \
|
||||
editormanager/systemeditor.cpp
|
||||
HEADERS += mainwindow.h \
|
||||
editmode.h \
|
||||
tabpositionindicator.h \
|
||||
@@ -156,7 +157,8 @@ HEADERS += mainwindow.h \
|
||||
fileiconprovider.h \
|
||||
mimedatabase.h \
|
||||
settingsdatabase.h \
|
||||
eventfilteringmainwindow.h
|
||||
eventfilteringmainwindow.h \
|
||||
editormanager/systemeditor.h
|
||||
FORMS += dialogs/newdialog.ui \
|
||||
dialogs/shortcutsettings.ui \
|
||||
dialogs/saveitemsdialog.ui \
|
||||
@@ -181,4 +183,4 @@ else:unix {
|
||||
images.path = /share/pixmaps
|
||||
INSTALLS += images
|
||||
}
|
||||
OTHER_FILES += Core.pluginspec
|
||||
OTHER_FILES += Core.pluginspec editormanager/BinFiles.mimetypes.xml
|
||||
|
||||
74
src/plugins/coreplugin/editormanager/systemeditor.cpp
Normal file
74
src/plugins/coreplugin/editormanager/systemeditor.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "systemeditor.h"
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtGui/QDesktopServices>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
SystemEditor::SystemEditor(QObject *parent) :
|
||||
IExternalEditor(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QStringList SystemEditor::mimeTypes() const
|
||||
{
|
||||
return QStringList() << QLatin1String("application/octet-stream");
|
||||
}
|
||||
|
||||
QString SystemEditor::id() const
|
||||
{
|
||||
return QLatin1String("CorePlugin.OpenWithSystemEditor");
|
||||
}
|
||||
|
||||
QString SystemEditor::displayName() const
|
||||
{
|
||||
return QLatin1String("System Editor");
|
||||
}
|
||||
|
||||
bool SystemEditor::startEditor(const QString &fileName, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
QUrl url;
|
||||
url.setPath(fileName);
|
||||
url.setScheme(QLatin1String("file"));
|
||||
qDebug() << url;
|
||||
if (!QDesktopServices::openUrl(url)) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Could not open url %1.").arg(url.toString());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
54
src/plugins/coreplugin/editormanager/systemeditor.h
Normal file
54
src/plugins/coreplugin/editormanager/systemeditor.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef SYSTEMEDITOR_H
|
||||
#define SYSTEMEDITOR_H
|
||||
|
||||
#include "iexternaleditor.h"
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class SystemEditor : public IExternalEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SystemEditor(QObject *parent = 0);
|
||||
|
||||
QStringList mimeTypes() const;
|
||||
QString id() const;
|
||||
QString displayName() const;
|
||||
|
||||
bool startEditor(const QString &fileName, QString *errorMessage);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SYSTEMEDITOR_H
|
||||
@@ -61,6 +61,7 @@
|
||||
#include "statusbarwidget.h"
|
||||
#include "basefilewizard.h"
|
||||
#include "ioutputpane.h"
|
||||
#include "editormanager/systemeditor.h"
|
||||
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
#include <coreplugin/settingsdatabase.h>
|
||||
@@ -134,6 +135,7 @@ MainWindow::MainWindow() :
|
||||
m_activeContext(0),
|
||||
m_generalSettings(new GeneralSettings),
|
||||
m_shortcutSettings(new ShortcutSettings),
|
||||
m_systemEditor(new SystemEditor),
|
||||
m_focusToEditor(0),
|
||||
m_newAction(0),
|
||||
m_openAction(0),
|
||||
@@ -236,12 +238,15 @@ MainWindow::~MainWindow()
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
pm->removeObject(m_shortcutSettings);
|
||||
pm->removeObject(m_generalSettings);
|
||||
pm->removeObject(m_systemEditor);
|
||||
delete m_messageManager;
|
||||
m_messageManager = 0;
|
||||
delete m_shortcutSettings;
|
||||
m_shortcutSettings = 0;
|
||||
delete m_generalSettings;
|
||||
m_generalSettings = 0;
|
||||
delete m_systemEditor;
|
||||
m_systemEditor = 0;
|
||||
delete m_settings;
|
||||
m_settings = 0;
|
||||
delete m_printer;
|
||||
@@ -286,6 +291,9 @@ bool MainWindow::init(QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
if (!mimeDatabase()->addMimeTypes(QLatin1String(":/core/editormanager/BinFiles.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
pm->addObject(m_coreImpl);
|
||||
m_statusBarManager->init();
|
||||
@@ -294,6 +302,8 @@ bool MainWindow::init(QString *errorMessage)
|
||||
|
||||
pm->addObject(m_generalSettings);
|
||||
pm->addObject(m_shortcutSettings);
|
||||
pm->addObject(m_systemEditor);
|
||||
|
||||
|
||||
// Add widget to the bottom, we create the view here instead of inside the
|
||||
// OutputPaneManager, since the StatusBarManager needs to be initialized before
|
||||
|
||||
@@ -76,6 +76,7 @@ class ProgressManagerPrivate;
|
||||
class ShortcutSettings;
|
||||
class StatusBarManager;
|
||||
class VersionDialog;
|
||||
class SystemEditor;
|
||||
|
||||
class CORE_EXPORT MainWindow : public EventFilteringMainWindow
|
||||
{
|
||||
@@ -204,6 +205,7 @@ private:
|
||||
|
||||
GeneralSettings *m_generalSettings;
|
||||
ShortcutSettings *m_shortcutSettings;
|
||||
SystemEditor *m_systemEditor;
|
||||
|
||||
// actions
|
||||
QShortcut *m_focusToEditor;
|
||||
|
||||
Reference in New Issue
Block a user