From 987eca7269ebac1d820914919b3ed93f1c6e9b84 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 20 Mar 2009 01:56:32 +0100 Subject: Fixed tabs dimension && reduced tabbar font --- src/tabbar.cpp | 32 ++++++++++++++++++-------------- src/tabbar.h | 3 +++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 8f648f28..ac18d7e8 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -35,33 +35,25 @@ #include #include #include +#include // Qt Includes #include -#include TabBar::TabBar(QWidget *parent) : KTabBar(parent) + , m_parent(parent) { setElideMode(Qt::ElideRight); setContextMenuPolicy(Qt::CustomContextMenu); setAcceptDrops(true); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); -// FIXME: not sure we need this.. -// QString alt = QLatin1String("Alt+%1"); -// for (int i = 1; i <= 10; ++i) -// { -// int key = i; -// if (key == 10) -// { -// key = 0; -// } -// QShortcut *shortCut = new QShortcut(alt.arg(key), this); -// m_tabShortcuts.append(shortCut); -// connect(shortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); -// } + QFont standardFont = KGlobalSettings::generalFont(); + QString fontFamily = standardFont.family(); + int dim = standardFont.pointSize(); + setFont( QFont(fontFamily, dim-2) ); } @@ -70,6 +62,18 @@ TabBar::~TabBar() } +QSize TabBar::tabSizeHint (int index) const +{ + Q_UNUSED(index); + QSize s = m_parent->sizeHint(); + int w = s.width() / 5; + int h = s.height() / 20; + + QSize ts = QSize(w,h); + return ts; +} + + void TabBar::selectTabAction() { if (QShortcut *shortCut = qobject_cast(sender())) diff --git a/src/tabbar.h b/src/tabbar.h index 0dbdd004..8b670def 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -56,6 +56,8 @@ protected: void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); + virtual QSize tabSizeHint (int index) const; + private slots: void selectTabAction(); void cloneTab(); @@ -68,6 +70,7 @@ 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 -- cgit v1.2.1