Commit a6a04985 authored by Lasse Holmstedt's avatar Lasse Holmstedt

Editor toolbar integration

parent 9534f6bc
......@@ -82,7 +82,7 @@ SOURCES += mainwindow.cpp \
imode.cpp \
editormanager/systemeditor.cpp \
designmode.cpp \
faketoolbar.cpp
designmodetoolbar.cpp
HEADERS += mainwindow.h \
editmode.h \
......
......@@ -34,6 +34,8 @@
#include <QWidget>
#include <QtCore/QPointer>
#include <utils/styledbar.h>
QT_BEGIN_NAMESPACE
class QComboBox;
class QToolButton;
......@@ -49,28 +51,56 @@ namespace Core {
* Fakes an IEditor-like toolbar for design mode widgets such as Qt Designer and Bauhaus.
* Creates a combobox for open files and lock and close buttons on the right.
*/
class CORE_EXPORT DesignModeToolBar : public QWidget
class CORE_EXPORT EditorToolBar : public Utils::StyledBar
{
Q_OBJECT
Q_DISABLE_COPY(FakeToolBar)
Q_DISABLE_COPY(EditorToolBar)
public:
explicit DesignModeToolBar(QWidget *parent = 0);
void setEditor(Core::IEditor *editor);
void setCenterToolBar(QWidget *toolBar);
explicit EditorToolBar(QWidget *parent = 0);
enum ToolbarCreationFlags { FlagsNone = 0, FlagsIgnoreIEditorToolBar = 1 };
/**
* Adds an editor to listen to state changes so that the editor can be updated accordingly.
*/
void addEditor(IEditor *editor, ToolbarCreationFlags flags = FlagsNone);
/**
* Sets the editor and adds its custom toolbar to the widget.
*/
void setCurrentEditor(IEditor *editor);
/**
* Adds a toolbar to the widget and sets invisible by default.
*/
void addCenterToolBar(QWidget *toolBar);
void updateActions();
void setNavigationVisible(bool isVisible);
void setCanGoBack(bool canGoBack);
void setCanGoForward(bool canGoForward);
void removeToolbarForEditor(IEditor *editor);
public slots:
void updateEditorStatus(IEditor *editor);
signals:
void closeClicked();
void goBackClicked();
void goForwardClicked();
private slots:
void updateEditorListSelection(Core::IEditor *newSelection);
void listSelectionActivated(int row);
void listContextMenu(QPoint);
void makeEditorWritable();
void updateEditorStatus();
void checkEditorStatus();
void closeView();
void updateActionShortcuts();
private:
void updateToolBar(QWidget *toolBar);
IEditor *currentEditor() const;
Core::OpenEditorsModel *m_editorsListModel;
QComboBox *m_editorList;
QToolBar *m_centerToolBar;
......@@ -79,7 +109,14 @@ private:
QToolButton *m_lockButton;
QAction *m_goBackAction;
QAction *m_goForwardAction;
QPointer<Core::IEditor> m_editor;
QToolButton *m_backButton;
QToolButton *m_forwardButton;
QWidget *m_activeToolBar;
QWidget *m_toolBarPlaceholder;
QWidget *m_defaultToolBar;
bool m_ignoreEditorToolbar;
};
}
......
......@@ -443,9 +443,9 @@ void EditorManager::init()
}
DesignModeToolBar *EditorManager::createFakeToolBar(QWidget *parent)
EditorToolBar *EditorManager::createToolBar(QWidget *parent)
{
return new DesignModeToolBar(parent);
return new EditorToolBar(parent);
}
QString EditorManager::defaultExternalEditor() const
......
......@@ -57,7 +57,7 @@ class IFile;
class IMode;
class IVersionControl;
class DesignModeToolBar;
class EditorToolBar;
enum MakeWritableResult {
OpenedWithVersionControl,
......@@ -107,7 +107,7 @@ public:
void init();
static EditorManager *instance() { return m_instance; }
static DesignModeToolBar *createFakeToolBar(QWidget *parent = 0);
static EditorToolBar *createToolBar(QWidget *parent = 0);
enum OpenEditorFlag {
NoActivate = 1,
......@@ -265,6 +265,7 @@ private:
friend class Core::Internal::SplitterOrView;
friend class Core::Internal::EditorView;
friend class Core::EditorToolBar;
};
} // namespace Core
......
......@@ -56,6 +56,7 @@ namespace Core {
class IEditor;
class OpenEditorsModel;
class EditorToolBar;
namespace Internal {
......@@ -71,7 +72,7 @@ class EditorView : public QWidget
Q_OBJECT
public:
EditorView(OpenEditorsModel *model = 0, QWidget *parent = 0);
EditorView(QWidget *parent = 0);
virtual ~EditorView();
int editorCount() const;
......@@ -95,28 +96,17 @@ public:
QObject *object, const char *member);
void hideEditorStatusBar(const QString &id);
public slots:
void closeView();
private slots:
void updateEditorStatus(Core::IEditor *editor = 0);
void checkEditorStatus();
void makeEditorWritable();
void listSelectionActivated(int index);
void listContextMenu(QPoint);
private:
void updateNavigatorActions();
void updateToolBar(IEditor *editor);
void checkProjectLoaded(IEditor *editor);
OpenEditorsModel *m_model;
QWidget *m_toolBar;
QWidget *m_activeToolBar;
EditorToolBar *m_toolBar;
QStackedWidget *m_container;
QComboBox *m_editorList;
QToolButton *m_closeButton;
QToolButton *m_lockButton;
QWidget *m_defaultToolBar;
QString m_infoWidgetId;
QFrame *m_infoWidget;
QLabel *m_infoWidgetLabel;
......@@ -134,9 +124,6 @@ private:
QList<EditLocation> m_editorHistory;
int m_currentNavigationHistoryPosition;
void updateCurrentPositionInNavigationHistory();
QAction *m_goBackAction;
QAction *m_goForwardAction;
void updateActions();
public:
......@@ -146,7 +133,6 @@ public:
public slots:
void goBackInNavigationHistory();
void goForwardInNavigationHistory();
void updateActionShortcuts();
public:
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
......
......@@ -122,7 +122,7 @@ DocumentWidget::DocumentWidget(TextEditor::ITextEditor *textEditor, QPlainTextEd
m_leftSideBar(0),
m_rightSideBar(0),
m_designToolBar(new QToolBar),
m_fakeToolBar(Core::EditorManager::createFakeToolBar(this)),
m_fakeToolBar(Core::EditorManager::createToolBar(this)),
m_isDisabled(false),
m_warningWidget(0)
{
......@@ -203,11 +203,6 @@ void DocumentWidget::setAutoSynchronization(bool sync)
}
}
void DocumentWidget::closeEditor()
{
Core::ICore::instance()->editorManager()->closeEditors(QList<IEditor*>() << textEditor());
}
void DocumentWidget::enable()
{
if (debug)
......@@ -302,9 +297,9 @@ void DocumentWidget::setup()
m_designToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored);
connect(m_fakeToolBar, SIGNAL(closeClicked()), this, SLOT(closeEditor()));
m_fakeToolBar->setEditor(textEditor());
m_fakeToolBar->setCenterToolBar(m_designToolBar);
m_fakeToolBar->addEditor(textEditor(), Core::EditorToolBar::FlagsIgnoreIEditorToolBar);
m_fakeToolBar->addCenterToolBar(m_designToolBar);
m_fakeToolBar->setNavigationVisible(false);
// right area:
QWidget *centerWidget = new QWidget;
......
......@@ -62,7 +62,7 @@ QT_END_NAMESPACE
namespace Core {
class SideBar;
class OpenEditorsModel;
class DesignModeToolBar;
class EditorToolBar;
}
namespace QmlDesigner {
......@@ -115,7 +115,6 @@ private slots:
void enable();
void disable(const QList<RewriterView::Error> &errors);
void updateErrorStatus(const QList<RewriterView::Error> &errors);
void closeEditor();
private:
void setup();
......@@ -131,7 +130,7 @@ private:
Core::SideBar *m_rightSideBar;
QToolBar *m_designToolBar;
Core::DesignModeToolBar *m_fakeToolBar;
Core::EditorToolBar *m_fakeToolBar;
bool m_isDisabled;
DocumentWarningWidget *m_warningWidget;
......
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