From c538a814ccc76812db743a528c15d119df04a539 Mon Sep 17 00:00:00 2001
From: mae <qt-info@nokia.com>
Date: Mon, 20 Jul 2009 17:29:24 +0200
Subject: [PATCH] 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.

---
 .../coreplugin/editormanager/editorview.cpp   | 47 +++++++++++++++++++
 .../coreplugin/editormanager/editorview.h     |  8 ++++
 2 files changed, 55 insertions(+)

diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp
index 9e31dc2ec0c..8aaafc61e6e 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 35ddcb6ad82..5f97701d7cf 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; }
 
-- 
GitLab