summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-07-20 17:29:24 +0200
committermae <qt-info@nokia.com>2009-07-20 17:30:25 +0200
commitc538a814ccc76812db743a528c15d119df04a539 (patch)
tree022369c93f47555c8a20e59c6376620c7625ffdb /src/plugins
parentcc6fec2bf8d3de8c6f49e4406235b9a28e65e795 (diff)
downloadqt-creator-c538a814ccc76812db743a528c15d119df04a539.tar.gz
visible next/previous navigation buttons for the editor view.
This commit makes the uglyness of our current default arrow icons visible. The toolbuttons are also too wide.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/coreplugin/editormanager/editorview.cpp47
-rw-r--r--src/plugins/coreplugin/editormanager/editorview.h8
2 files changed, 55 insertions, 0 deletions
diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp
index 9e31dc2ec0..8aaafc61e6 100644
--- a/src/plugins/coreplugin/editormanager/editorview.cpp
+++ b/src/plugins/coreplugin/editormanager/editorview.cpp
@@ -32,6 +32,8 @@
#include "coreimpl.h"
#include "minisplitter.h"
#include "openeditorsmodel.h"
+#include <coreplugin/coreconstants.h>
+#include <coreplugin/actionmanager/actionmanager.h>
#include <utils/qtcassert.h>
#include <utils/styledbar.h>
@@ -81,6 +83,12 @@ EditorView::EditorView(OpenEditorsModel *model, QWidget *parent) :
m_statusWidget(new QFrame(this)),
m_currentNavigationHistoryPosition(0)
{
+
+ m_goBackAction = new QAction(QIcon(QLatin1String(":/help/images/previous.png")), tr("Go Back"), this);
+ connect(m_goBackAction, SIGNAL(triggered()), this, SLOT(goBackInNavigationHistory()));
+ m_goForwardAction = new QAction(QIcon(QLatin1String(":/help/images/next.png")), tr("Go Forward"), this);
+ connect(m_goForwardAction, SIGNAL(triggered()), this, SLOT(goForwardInNavigationHistory()));
+
QVBoxLayout *tl = new QVBoxLayout(this);
tl->setSpacing(0);
tl->setMargin(0);
@@ -89,6 +97,12 @@ EditorView::EditorView(OpenEditorsModel *model, QWidget *parent) :
m_model = CoreImpl::instance()->editorManager()->openedEditorsModel();
}
+ QToolButton *backButton = new QToolButton;
+ backButton->setDefaultAction(m_goBackAction);
+
+ QToolButton *forwardButton= new QToolButton;
+ forwardButton->setDefaultAction(m_goForwardAction);
+
m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_editorList->setMinimumContentsLength(20);
m_editorList->setModel(m_model);
@@ -110,9 +124,12 @@ EditorView::EditorView(OpenEditorsModel *model, QWidget *parent) :
m_closeButton->setAutoRaise(true);
m_closeButton->setIcon(QIcon(":/core/images/closebutton.png"));
+
QHBoxLayout *toplayout = new QHBoxLayout;
toplayout->setSpacing(0);
toplayout->setMargin(0);
+ toplayout->addWidget(backButton);
+ toplayout->addWidget(forwardButton);
toplayout->addWidget(m_editorList);
toplayout->addWidget(m_toolBar, 1); // Custom toolbar stretches
toplayout->addWidget(m_lockButton);
@@ -185,6 +202,18 @@ EditorView::EditorView(OpenEditorsModel *model, QWidget *parent) :
tl->addWidget(m_statusHLine);
tl->addWidget(m_statusWidget);
}
+
+
+ ActionManager *am = ICore::instance()->actionManager();
+ connect(am->command(Constants::CLOSE), SIGNAL(keySequenceChanged()),
+ this, SLOT(updateActionShortcuts()));
+ connect(am->command(Constants::GO_BACK), SIGNAL(keySequenceChanged()),
+ this, SLOT(updateActionShortcuts()));
+ connect(am->command(Constants::GO_FORWARD), SIGNAL(keySequenceChanged()),
+ this, SLOT(updateActionShortcuts()));
+
+ updateActionShortcuts();
+ updateActions();
}
EditorView::~EditorView()
@@ -483,6 +512,21 @@ void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QB
m_navigationHistory.takeLast();
}
}
+ updateActions();
+}
+
+void EditorView::updateActions()
+{
+ m_goBackAction->setEnabled(canGoBack());
+ m_goForwardAction->setEnabled(canGoForward());
+}
+
+void EditorView::updateActionShortcuts()
+{
+ ActionManager *am = ICore::instance()->actionManager();
+ m_closeButton->setToolTip(am->command(Constants::CLOSE)->stringWithAppendedShortcut(EditorManager::tr("Close")));
+ m_goBackAction->setToolTip(am->command(Constants::GO_BACK)->action()->toolTip());
+ m_goForwardAction->setToolTip(am->command(Constants::GO_FORWARD)->action()->toolTip());
}
void EditorView::copyNavigationHistoryFrom(EditorView* other)
@@ -492,6 +536,7 @@ void EditorView::copyNavigationHistoryFrom(EditorView* other)
m_currentNavigationHistoryPosition = other->m_currentNavigationHistoryPosition;
m_navigationHistory = other->m_navigationHistory;
m_editorHistory = other->m_editorHistory;
+ updateActions();
}
void EditorView::updateCurrentPositionInNavigationHistory()
@@ -534,6 +579,7 @@ void EditorView::goBackInNavigationHistory()
editor->restoreState(location.state.toByteArray());
break;
}
+ updateActions();
}
void EditorView::goForwardInNavigationHistory()
@@ -556,6 +602,7 @@ void EditorView::goForwardInNavigationHistory()
}
}
editor->restoreState(location.state.toByteArray());
+ updateActions();
}
diff --git a/src/plugins/coreplugin/editormanager/editorview.h b/src/plugins/coreplugin/editormanager/editorview.h
index 35ddcb6ad8..5f97701d7c 100644
--- a/src/plugins/coreplugin/editormanager/editorview.h
+++ b/src/plugins/coreplugin/editormanager/editorview.h
@@ -135,13 +135,21 @@ private:
QList<EditLocation> m_editorHistory;
int m_currentNavigationHistoryPosition;
void updateCurrentPositionInNavigationHistory();
+ QAction *m_goBackAction;
+ QAction *m_goForwardAction;
+ void updateActions();
public:
inline bool canGoForward() const { return m_currentNavigationHistoryPosition < m_navigationHistory.size()-1; }
inline bool canGoBack() const { return m_currentNavigationHistoryPosition > 0; }
+
+public slots:
void goBackInNavigationHistory();
void goForwardInNavigationHistory();
+ void updateActionShortcuts();
+
+public:
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
inline QList<EditLocation> editorHistory() const { return m_editorHistory; }