diff options
| -rw-r--r-- | src/mainwindow.cpp | 63 | ||||
| -rw-r--r-- | src/mainwindow.h | 5 | 
2 files changed, 59 insertions, 9 deletions
| diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a93157a6..943f877d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -104,6 +104,7 @@ MainWindow::MainWindow()          , m_webInspectorPanel(0)          , m_analyzerPanel(0)          , m_historyBackMenu(0) +        , m_historyForwardMenu(0)          , m_encodingMenu(new KMenu(this))          , m_userAgentMenu(new KMenu(this))          , m_bookmarksBar(0) @@ -178,6 +179,7 @@ MainWindow::~MainWindow()      delete m_stopReloadAction;      delete m_historyBackMenu; +    delete m_historyForwardMenu;      delete m_encodingMenu;      delete m_bookmarksBar; @@ -454,6 +456,11 @@ void MainWindow::setupActions()      a = actionCollection()->addAction(KStandardAction::Forward);      connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openNext(Qt::MouseButtons, Qt::KeyboardModifiers))); +    m_historyForwardMenu = new KMenu(this); +    a->setMenu(m_historyForwardMenu); +    connect(m_historyForwardMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowForwardMenu())); +    connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction*))); +          // ============================== General Tab Actions ====================================      a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this);      a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_T)); @@ -1263,16 +1270,12 @@ void MainWindow::aboutToShowBackMenu()      QWebHistory *history = currentTab()->view()->history();      int pivot = history->currentItemIndex();      int offset = 0; -    QList<QWebHistoryItem> historyList = history->backItems(8); //no more than 8 elements! +    const int maxItemNumber = 8;  // no more than 8 elements in the Back History Menu! +    QList<QWebHistoryItem> historyList = history->backItems(maxItemNumber);      int listCount = historyList.count(); -    if (pivot >= 8) -        offset = pivot - 8; - -    /* -     * Need a bug report upstream. -     * Seems setHtml() do some garbage in history -     * Here history->currentItem() have backItem url and currentItem (error page) title -     */ +    if (pivot >= maxItemNumber) +        offset = pivot - maxItemNumber; +      if (currentTab()->view()->page()->isOnRekonqPage())      {          QWebHistoryItem item = history->currentItem(); @@ -1296,6 +1299,48 @@ void MainWindow::aboutToShowBackMenu()      }  } + +void MainWindow::aboutToShowForwardMenu() +{ +    m_historyForwardMenu->clear(); + +    if (!currentTab()) +        return; + +    QWebHistory *history = currentTab()->view()->history(); +    const int pivot = history->currentItemIndex(); +    int offset = 0; +    const int maxItemNumber = 8;  // no more than 8 elements in the Forward History Menu! +    QList<QWebHistoryItem> historyList = history->forwardItems(maxItemNumber); +    int listCount = historyList.count(); + +    if (pivot >= maxItemNumber) +        offset = pivot - maxItemNumber; + +    if (currentTab()->view()->page()->isOnRekonqPage()) +    { +        QWebHistoryItem item = history->currentItem(); +        KAction *action = new KAction(this); +        action->setData(listCount + offset++); +        KIcon icon = Application::iconManager()->iconForUrl(item.url()); +        action->setIcon(icon); +        action->setText(item.title()); +        m_historyForwardMenu->addAction(action); +    } + +    for (int i = 1; i <= listCount; i++) +    { +        QWebHistoryItem item = historyList.at(i - 1); +        KAction *action = new KAction(this); +        action->setData(pivot +i + offset); +        KIcon icon = Application::iconManager()->iconForUrl(item.url()); +        action->setIcon(icon); +        action->setText(item.title()); +        m_historyForwardMenu->addAction(action); +    } +} + +  void MainWindow::aboutToShowTabListMenu()  {      m_tabListMenu->clear(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 3a918879..598d66e3 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -158,6 +158,8 @@ private Q_SLOTS:      void clearPrivateData();      void aboutToShowBackMenu(); +    void aboutToShowForwardMenu(); +          void aboutToShowTabListMenu();      void openActionUrl(QAction *action);      void openActionTab(QAction *action); @@ -187,7 +189,10 @@ private:      NetworkAnalyzerPanel *m_analyzerPanel;      KAction *m_stopReloadAction; +          KMenu *m_historyBackMenu; +    KMenu *m_historyForwardMenu; +          KMenu *m_encodingMenu;      KMenu *m_tabListMenu; | 
