summaryrefslogtreecommitdiff
path: root/src/tabbar.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-03-29 00:13:01 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-03-29 00:13:01 +0100
commit08deb6b161ef0cdda7ed8e49870b16f41d78eb4e (patch)
tree14a9dec045a2f01db4d41f57a0c85ae9182af7ca /src/tabbar.cpp
parentMerge branch 'prova2' (diff)
downloadrekonq-08deb6b161ef0cdda7ed8e49870b16f41d78eb4e.tar.xz
Revert "Revert "pedantic""
Reapplied previous changes. Sorry for confusion. Time to bed.. This reverts commit 98f53721514116b876d18bf0a2da89d2a53cc97d.
Diffstat (limited to 'src/tabbar.cpp')
-rw-r--r--src/tabbar.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index 43940f7d..cf3a1988 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -50,6 +50,14 @@ TabBar::TabBar(QWidget *parent)
setAcceptDrops(true);
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
+ // we count to 9 because Ctrl+0 is already taken by Normal Font
+ for (int i = 1; i < 10; ++i)
+ {
+ QShortcut *tabShortCut = new QShortcut(QString("Ctrl+%1").arg(i), this);
+ connect(tabShortCut, SIGNAL(activated()), this, SLOT(selectTabAction()));
+ m_tabShortcuts.append(tabShortCut);
+ }
+
QFont standardFont = KGlobalSettings::generalFont();
QString fontFamily = standardFont.family();
int dim = standardFont.pointSize();
@@ -64,16 +72,25 @@ TabBar::~TabBar()
QSize TabBar::tabSizeHint(int index) const
{
- Q_UNUSED(index);
QSize s = m_parent->sizeHint();
int w;
- if (count() > 3)
+
+ int n = count();
+
+ if(n > 6)
{
- w = s.width() / 4;
+ w = s.width() / 5;
}
else
{
- w = s.width() / 3;
+ if (n > 3)
+ {
+ w = s.width() / 4;
+ }
+ else
+ {
+ w = s.width() / 3;
+ }
}
int h = KTabBar::tabSizeHint(index).height();
@@ -81,22 +98,22 @@ QSize TabBar::tabSizeHint(int index) const
return ts;
}
-
+
void TabBar::selectTabAction()
{
if (QShortcut *shortCut = qobject_cast<QShortcut*>(sender()))
{
int index = m_tabShortcuts.indexOf(shortCut);
- if (index == 0)
- index = 10;
- setCurrentIndex(index);
+ if (index != 0)
+ {
+ setCurrentIndex(index);
+ }
}
}
void TabBar::contextMenuRequested(const QPoint &position)
{
- // FIXME: use right actions
KMenu menu;
menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab);
int index = tabAt(position);