diff --git a/src/plugins/bineditor/bineditor.pro b/src/plugins/bineditor/bineditor.pro index 06724a155ffc32d4e4e4de27b0598b3422d07838..6ee822f9658a159a3be2a2d0547668dbf681c0c0 100644 --- a/src/plugins/bineditor/bineditor.pro +++ b/src/plugins/bineditor/bineditor.pro @@ -14,5 +14,5 @@ SOURCES += bineditorplugin.cpp \ RESOURCES += bineditor.qrc -OTHER_FILES += BinEditor.pluginspec BinEditor.mimetypes.xml \ +OTHER_FILES += BinEditor.pluginspec \ ImageViewer.mimetypes.xml diff --git a/src/plugins/bineditor/bineditor.qrc b/src/plugins/bineditor/bineditor.qrc index fd8e171d3f7373e2dc22b316d0c3dcca59e73376..1bc50d279e2839871c666d86982fe20583a7b23f 100644 --- a/src/plugins/bineditor/bineditor.qrc +++ b/src/plugins/bineditor/bineditor.qrc @@ -1,6 +1,5 @@ <RCC> <qresource prefix="/bineditor"> - <file>BinEditor.mimetypes.xml</file> <file>ImageViewer.mimetypes.xml</file> </qresource> </RCC> diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 03dd19c65e3c5abefe6b355bfa71cfd2aba9a55d..afb2605ea7e0196acfa126923e0ed7650a250d48 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -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 *))); diff --git a/src/plugins/coreplugin/core.qrc b/src/plugins/coreplugin/core.qrc index 806ece30e80bfd15253aa90d050c2cab8e3a7da5..ce3e1988823a7df1839164181bee0c5e891ebf6e 100644 --- a/src/plugins/coreplugin/core.qrc +++ b/src/plugins/coreplugin/core.qrc @@ -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> diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index f54108e8d05698151ca962ee93670f3d5ca51de5..8374249f26f97a5b1f93ae03a9a4fbe879b8d2d7 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -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 diff --git a/src/plugins/bineditor/BinEditor.mimetypes.xml b/src/plugins/coreplugin/editormanager/BinFiles.mimetypes.xml similarity index 100% rename from src/plugins/bineditor/BinEditor.mimetypes.xml rename to src/plugins/coreplugin/editormanager/BinFiles.mimetypes.xml diff --git a/src/plugins/coreplugin/editormanager/systemeditor.cpp b/src/plugins/coreplugin/editormanager/systemeditor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fc2e20e3f49cf80e438a653ddea20722b6d5b03e --- /dev/null +++ b/src/plugins/coreplugin/editormanager/systemeditor.cpp @@ -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; +} diff --git a/src/plugins/coreplugin/editormanager/systemeditor.h b/src/plugins/coreplugin/editormanager/systemeditor.h new file mode 100644 index 0000000000000000000000000000000000000000..cbcec7fb7f23db8018ed46b67b14002853c7e4cb --- /dev/null +++ b/src/plugins/coreplugin/editormanager/systemeditor.h @@ -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 diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 82a076e81e0d94178e65f1e1ccfc74ff43b74652..2dd2429772ce26ae76f5579784f4a1d8795602de 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -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 diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h index 273d1bc1d31babca076a35bfd3d44b393177f8ce..17ea9dfa1937f87be50b8fad99e585585e80058d 100644 --- a/src/plugins/coreplugin/mainwindow.h +++ b/src/plugins/coreplugin/mainwindow.h @@ -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;