summaryrefslogtreecommitdiffstats
path: root/lib/widgets/kdevtabwidget.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /lib/widgets/kdevtabwidget.cpp
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lib/widgets/kdevtabwidget.cpp')
-rw-r--r--lib/widgets/kdevtabwidget.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/widgets/kdevtabwidget.cpp b/lib/widgets/kdevtabwidget.cpp
new file mode 100644
index 00000000..49925115
--- /dev/null
+++ b/lib/widgets/kdevtabwidget.cpp
@@ -0,0 +1,66 @@
+/***************************************************************************
+ * Copyright (C) 2001-2003 *
+ * The KDevelop Team *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qpopupmenu.h>
+
+#include <kglobal.h>
+#include <klocale.h>
+#include <kicontheme.h>
+#include <kiconloader.h>
+
+#include "kdevtabwidget.h"
+
+KDevTabWidget::KDevTabWidget(QWidget *parent, const char *name) : QTabWidget(parent,name)
+{
+ m_pTabBar = new KTabBar(this, "tabbar");
+ setTabBar(m_pTabBar);
+ connect(m_pTabBar, SIGNAL(closeWindow(const QWidget*)), this, SIGNAL(closeWindow(const QWidget*)));
+ connect(m_pTabBar, SIGNAL(closeOthers(QWidget*)), this, SIGNAL(closeOthers(QWidget*)));
+}
+
+KTabBar::KTabBar(QWidget *parent, const char *name) : QTabBar(parent,name)
+{
+ m_pPopupMenu = new QPopupMenu(this);
+
+ QPixmap closePixmap = KGlobal::instance()->iconLoader()->loadIcon( "tab_remove", KIcon::Small, 0, KIcon::DefaultState, 0, true );
+ if (closePixmap.isNull())
+ closePixmap = SmallIcon("fileclose");
+
+ m_pPopupMenu->insertItem(closePixmap, i18n("&Close"), this, SLOT(closeWindowSlot()));
+ m_pPopupMenu->insertItem(i18n("Close &Others"), this, SLOT(closeOthersSlot()));
+}
+
+void KTabBar::closeWindowSlot()
+{
+ emit closeWindow(m_pPage);
+}
+
+void KTabBar::closeOthersSlot()
+{
+ emit closeOthers(m_pPage);
+}
+
+void KTabBar::mousePressEvent(QMouseEvent *e)
+{
+ if(e->button() == Qt::RightButton) {
+
+ QTab *tab = selectTab(e->pos() );
+ if( tab == 0L ) return;
+
+ m_pPage = ((KDevTabWidget*)parent())->page(indexOf(tab->identifier() ) );
+ if(m_pPage == 0L) return;
+
+ m_pPopupMenu->exec(mapToGlobal(e->pos()));
+ }
+ QTabBar::mousePressEvent(e);
+}
+
+#include "kdevtabwidget.moc"