diff options
| -rw-r--r-- | src/mainwindow.cpp | 34 | ||||
| -rw-r--r-- | src/mainwindow.h | 3 | 
2 files changed, 37 insertions, 0 deletions
| diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index be534432..4159d451 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -404,6 +404,17 @@ void MainWindow::setupActions()      // set zoom bar actions      m_zoomBar->setupActions(this); +     +    // tab list +    m_tabListMenu = new KMenu(); +    m_tabListMenu->addAction("hack"); // necessary to show the menu on the right side the first time +    connect(m_tabListMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowTabListMenu())); +    connect(m_tabListMenu, SIGNAL(triggered(QAction*)), this, SLOT(openActionTab(QAction*))); +    KActionMenu *tabAction = new KActionMenu(i18n("Tab List"), this); +    tabAction->setMenu(m_tabListMenu); +    tabAction->setIcon(KIcon("document-multiple")); +    tabAction->setDelayed(false); +    actionCollection()->addAction(QL1S("tab_list"), tabAction);      // =============================== Tools Actions =================================      a = new KAction(i18n("View Page S&ource"), this); @@ -1243,6 +1254,18 @@ void MainWindow::aboutToShowBackMenu()      }  } +void MainWindow::aboutToShowTabListMenu() +{ +    m_tabListMenu->clear(); +    for( int i = 0; i < m_view->count(); ++i ){ +        KAction *action = new KAction(m_view->tabText(i), this); +        action->setIcon(Application::iconManager()->iconForUrl(m_view->webTab(i)->url()).pixmap(16, 16)); +        action->setData(i); +        m_tabListMenu->addAction(action); +    } +    m_tabListMenu->adjustSize(); +} +  void MainWindow::openActionUrl(QAction *action)  { @@ -1258,6 +1281,17 @@ void MainWindow::openActionUrl(QAction *action)      history->goToItem(history->itemAt(index));  } +void MainWindow::openActionTab(QAction* action) +{ +    int index = action->data().toInt(); +    if(index < 0 || index >= m_view->count()) +    { +        kDebug() << "Invalid Index!: " << index; +        return; +    } +    m_view->setCurrentIndex(index); +} +  void MainWindow::setEncoding(QAction *qa)  { diff --git a/src/mainwindow.h b/src/mainwindow.h index 33fd2021..7dfc186b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -157,7 +157,9 @@ private Q_SLOTS:      void clearPrivateData();      void aboutToShowBackMenu(); +    void aboutToShowTabListMenu();      void openActionUrl(QAction *action); +    void openActionTab(QAction *action);      // encodings      void setEncoding(QAction *); @@ -181,6 +183,7 @@ private:      KAction *m_stopReloadAction;      KMenu *m_historyBackMenu;      KMenu *m_encodingMenu; +    KMenu *m_tabListMenu;      BookmarkToolBar *m_bookmarksBar; | 
