From 78aef384a57bca278bdd4484e9b31bbd7b88c98e Mon Sep 17 00:00:00 2001 From: Alexandr Domrachev Date: Mon, 27 Apr 2009 18:01:41 +0000 Subject: TabBar code clean. Icons added to context menu --- src/mainview.cpp | 1 - src/tabbar.cpp | 22 +++++++--------------- src/tabbar.h | 6 ------ 3 files changed, 7 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/mainview.cpp b/src/mainview.cpp index 9449a9c5..8cf09e2a 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -65,7 +65,6 @@ MainView::MainView(QWidget *parent) m_loadingGitPath = KStandardDirs::locate("appdata" , "pics/loading.gif"); - connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newWebView())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(slotCloseTab(int))); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(slotCloneTab(int))); connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(slotCloseOtherTabs(int))); diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 75a06e23..6914ef77 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -96,18 +96,20 @@ QSize TabBar::tabSizeHint(int index) const void TabBar::contextMenuRequested(const QPoint &position) { KMenu menu; - menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab())); + MainWindow *mainWindow = Application::instance()->mainWindow(); + + menu.addAction(mainWindow->actionByName(QLatin1String("new_tab"))); int index = tabAt(position); if (-1 != index) { m_actualIndex = index; - KAction *action = (KAction *) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); + menu.addAction(KIcon("tab-duplicate"), i18n("Clone Tab"), this, SLOT(cloneTab())); menu.addSeparator(); - action = (KAction *) menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab())); - action = (KAction *) menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); + menu.addAction(KIcon("tab-close"), i18n("&Close Tab"), this, SLOT(closeTab())); + menu.addAction(KIcon("tab-close-other"), i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); menu.addSeparator(); - action = (KAction *) menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab())); + menu.addAction(KIcon("view-refresh"), i18n("Reload Tab"), this, SLOT(reloadTab())); } else { @@ -136,16 +138,6 @@ void TabBar::closeOtherTabs() } -void TabBar::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - { - m_dragStartPos = event->pos(); - } - KTabBar::mousePressEvent(event); -} - - void TabBar::reloadTab() { emit reloadTab(m_actualIndex); diff --git a/src/tabbar.h b/src/tabbar.h index 2281f997..8563793f 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -45,7 +45,6 @@ public: ~TabBar(); signals: - void newTab(); void cloneTab(int index); void closeTab(int index); void closeOtherTabs(int index); @@ -53,8 +52,6 @@ signals: void reloadAllTabs(); protected: - void mousePressEvent(QMouseEvent* event); - /** * Added to fix tab dimension */ @@ -68,12 +65,9 @@ private slots: void contextMenuRequested(const QPoint &position); private: - friend class MainView; QWidget *m_parent; - QPoint m_dragStartPos; - int m_dragCurrentIndex; /** * the index in which we are seeing a Context menu -- cgit v1.2.1