From 5a8bb470bc30bf6a360661a87af783fd30588f5f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 21 Mar 2009 12:12:36 +0100 Subject: Always Show Tab Bar. Or not... --- src/mainview.cpp | 32 +++++++ src/mainview.h | 15 +++- src/rekonq.kcfg | 3 + src/settings_general.ui | 234 +++++++++++++++++++++++++++--------------------- src/tabbar.cpp | 2 +- src/tabbar.h | 16 +++- 6 files changed, 194 insertions(+), 108 deletions(-) (limited to 'src') diff --git a/src/mainview.cpp b/src/mainview.cpp index d7e07e14..407db6fe 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -23,6 +23,9 @@ #include "mainview.h" #include "mainview.moc" +// Auto Includes +#include "rekonq.h" + // Local Includes #include "tabbar.h" #include "application.h" @@ -86,6 +89,26 @@ MainView::~MainView() } +void MainView::viewTabBar() +{ + bool always = ReKonfig::alwaysShowTabBar(); + if(always == true) + return; + + if( m_tabBar->count() == 1 ) + { + m_tabBar->hide(); + } + else + { + if( m_tabBar->isHidden() ) + { + m_tabBar->show(); + } + } +} + + KAction *MainView::recentlyClosedTabsAction() const { return m_recentlyClosedTabsAction; @@ -367,6 +390,9 @@ WebView *MainView::newTab(bool makeCurrent) if (count() == 1) currentChanged(currentIndex()); emit tabsChanged(); + + viewTabBar(); + return webView; } @@ -420,6 +446,8 @@ void MainView::closeOtherTabs(int index) closeTab(i); for (int i = index - 1; i >= 0; --i) closeTab(i); + + viewTabBar(); } @@ -432,6 +460,8 @@ void MainView::cloneTab(int index) return; WebView *tab = newTab(false); tab->setUrl( webView(index)->url() ); + + viewTabBar(); } @@ -474,6 +504,8 @@ void MainView::closeTab(int index) currentWebView()->setFocus(); if (count() == 0) emit lastTabClosed(); + + viewTabBar(); } diff --git a/src/mainview.h b/src/mainview.h index 05a9bb16..94b93c37 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -22,11 +22,9 @@ #ifndef TABWIDGET_H #define TABWIDGET_H - // KDE Includes #include - // Forward Declarations class WebView; class TabBar; @@ -41,12 +39,15 @@ class QStackedWidget; class QLineEdit; class QUrl; + /** * TabWidget that contains WebViews and a stack widget of associated line edits. * * Connects up the current tab's signals to this class's signal and uses WebActionMapper * to proxy the actions. + * */ + class MainView : public KTabWidget { Q_OBJECT @@ -126,6 +127,14 @@ private slots: void moveTab(int fromIndex, int toIndex); private: + + /** + * show and hide TabBar if user doesn't choose + * "Always Show TabBar" option + * + */ + void viewTabBar(); + KAction *m_recentlyClosedTabsAction; KMenu *m_recentlyClosedTabsMenu; @@ -137,5 +146,5 @@ private: TabBar *m_tabBar; }; -#endif // TABWIDGET_H +#endif diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index a1b6ca4c..f60d6e86 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -20,6 +20,9 @@ 1 + + true + diff --git a/src/settings_general.ui b/src/settings_general.ui index b155ed56..9b963f89 100644 --- a/src/settings_general.ui +++ b/src/settings_general.ui @@ -1,121 +1,151 @@ - + + general - - + + 0 0 - 500 - 209 + 392 + 269 - + General - - - - - Home: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - + + + + + HomePage + + + + + Home: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + Set to current page + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + - - - - Set to current page + + + + misc + + + + + Remove history items: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + After one day + + + + + After one week + + + + + After two weeks + + + + + After one month + + + + + After one year + + + + + Manually + + + + + + + + Save downloads to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Always show TabBar + + + + - - - - Qt::Horizontal - - - - 233 - 25 - - - - - - - - Remove history items: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - After one day - - - - - After one week - - - - - After two weeks - - - - - After one month - - - - - After one year - - - - - Manually - - - - - - - - Save downloads to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - + + + Qt::Vertical - + 384 36 diff --git a/src/tabbar.cpp b/src/tabbar.cpp index ac18d7e8..0b8bdf63 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -66,7 +66,7 @@ QSize TabBar::tabSizeHint (int index) const { Q_UNUSED(index); QSize s = m_parent->sizeHint(); - int w = s.width() / 5; + int w = s.width() / 4; int h = s.height() / 20; QSize ts = QSize(w,h); diff --git a/src/tabbar.h b/src/tabbar.h index 8b670def..7cdc9afd 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -30,8 +30,11 @@ #include /** - * Tab bar with a few more features such as a context menu and shortcuts + * Tab bar with a few more features such as + * a context menu and shortcuts + * */ + class TabBar : public KTabBar { Q_OBJECT @@ -56,6 +59,10 @@ protected: void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); + /** + * Added to fix tab dimension + * + */ virtual QSize tabSizeHint (int index) const; private slots: @@ -67,13 +74,18 @@ private slots: void contextMenuRequested(const QPoint &position); private: + QList m_tabShortcuts; friend class MainView; QWidget *m_parent; QPoint m_dragStartPos; int m_dragCurrentIndex; - int m_actualIndex; // the index in which we are seeing a Context menu + + /** + * the index in which we are seeing a Context menu + */ + int m_actualIndex; }; #endif -- cgit v1.2.1