forked from qt-creator/qt-creator
Editors: Extract class for external windows
It will take over more responsibility in a later patch. Change-Id: I89ef61791ccbba3e42de2862d5d887099634bce4 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -31,6 +31,7 @@ SOURCES += mainwindow.cpp \
|
||||
editormanager/editorarea.cpp \
|
||||
editormanager/editormanager.cpp \
|
||||
editormanager/editorview.cpp \
|
||||
editormanager/editorwindow.cpp \
|
||||
editormanager/documentmodel.cpp \
|
||||
editormanager/openeditorsview.cpp \
|
||||
editormanager/openeditorswindow.cpp \
|
||||
@@ -122,6 +123,7 @@ HEADERS += mainwindow.h \
|
||||
editormanager/editormanager.h \
|
||||
editormanager/editormanager_p.h \
|
||||
editormanager/editorview.h \
|
||||
editormanager/editorwindow.h \
|
||||
editormanager/documentmodel.h \
|
||||
editormanager/openeditorsview.h \
|
||||
editormanager/openeditorswindow.h \
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "editormanager.h"
|
||||
#include "editormanager_p.h"
|
||||
#include "editorwindow.h"
|
||||
|
||||
#include "editorview.h"
|
||||
#include "openeditorswindow.h"
|
||||
@@ -1169,19 +1170,9 @@ void EditorManagerPrivate::splitNewWindow(EditorView *view)
|
||||
newEditor = EditorManagerPrivate::duplicateEditor(editor);
|
||||
else
|
||||
newEditor = editor; // move to the new view
|
||||
auto area = new EditorArea;
|
||||
QWidget *win = new QWidget;
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
win->setLayout(layout);
|
||||
layout->addWidget(area);
|
||||
win->setFocusProxy(area);
|
||||
win->setAttribute(Qt::WA_DeleteOnClose);
|
||||
win->setAttribute(Qt::WA_QuitOnClose, false); // don't prevent Qt Creator from closing
|
||||
win->resize(QSize(800, 600));
|
||||
static int windowId = 0;
|
||||
ICore::registerWindow(win, Context(Id("EditorManager.ExternalWindow.").withSuffix(++windowId)));
|
||||
|
||||
auto win = new EditorWindow;
|
||||
EditorArea *area = win->editorArea();
|
||||
d->m_editorAreas.append(area);
|
||||
connect(area, SIGNAL(destroyed(QObject*)), d, SLOT(editorAreaDestroyed(QObject*)));
|
||||
win->show();
|
||||
|
||||
66
src/plugins/coreplugin/editormanager/editorwindow.cpp
Normal file
66
src/plugins/coreplugin/editormanager/editorwindow.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "editorwindow.h"
|
||||
|
||||
#include "editorarea.h"
|
||||
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
EditorWindow::EditorWindow(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
m_area = new EditorArea;
|
||||
auto layout = new QVBoxLayout;
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
setLayout(layout);
|
||||
layout->addWidget(m_area);
|
||||
setFocusProxy(m_area);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setAttribute(Qt::WA_QuitOnClose, false); // don't prevent Qt Creator from closing
|
||||
resize(QSize(800, 600));
|
||||
|
||||
static int windowId = 0;
|
||||
ICore::registerWindow(this, Context(Id("EditorManager.ExternalWindow.").withSuffix(++windowId)));
|
||||
}
|
||||
|
||||
EditorArea *EditorWindow::editorArea() const
|
||||
{
|
||||
return m_area;
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // Core
|
||||
55
src/plugins/coreplugin/editormanager/editorwindow.h
Normal file
55
src/plugins/coreplugin/editormanager/editorwindow.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef EDITORWINDOW_H
|
||||
#define EDITORWINDOW_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class EditorArea;
|
||||
|
||||
class EditorWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditorWindow(QWidget *parent = 0);
|
||||
|
||||
EditorArea *editorArea() const;
|
||||
|
||||
private:
|
||||
EditorArea *m_area;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
} // Core
|
||||
|
||||
#endif // EDITORWINDOW_H
|
||||
Reference in New Issue
Block a user