kdevtabwidget.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <qpopupmenu.h>
00013
00014 #include <kglobal.h>
00015 #include <klocale.h>
00016 #include <kicontheme.h>
00017 #include <kiconloader.h>
00018
00019 #include "kdevtabwidget.h"
00020
00021 KDevTabWidget::KDevTabWidget(QWidget *parent, const char *name) : QTabWidget(parent,name)
00022 {
00023 m_pTabBar = new KTabBar(this, "tabbar");
00024 setTabBar(m_pTabBar);
00025 connect(m_pTabBar, SIGNAL(closeWindow(const QWidget*)), this, SIGNAL(closeWindow(const QWidget*)));
00026 connect(m_pTabBar, SIGNAL(closeOthers(QWidget*)), this, SIGNAL(closeOthers(QWidget*)));
00027 }
00028
00029 KTabBar::KTabBar(QWidget *parent, const char *name) : QTabBar(parent,name)
00030 {
00031 m_pPopupMenu = new QPopupMenu(this);
00032
00033 QPixmap closePixmap = KGlobal::instance()->iconLoader()->loadIcon( "tab_remove", KIcon::Small, 0, KIcon::DefaultState, 0, true );
00034 if (closePixmap.isNull())
00035 closePixmap = SmallIcon("fileclose");
00036
00037 m_pPopupMenu->insertItem(closePixmap, i18n("&Close"), this, SLOT(closeWindowSlot()));
00038 m_pPopupMenu->insertItem(i18n("Close &Others"), this, SLOT(closeOthersSlot()));
00039 }
00040
00041 void KTabBar::closeWindowSlot()
00042 {
00043 emit closeWindow(m_pPage);
00044 }
00045
00046 void KTabBar::closeOthersSlot()
00047 {
00048 emit closeOthers(m_pPage);
00049 }
00050
00051 void KTabBar::mousePressEvent(QMouseEvent *e)
00052 {
00053 if(e->button() == Qt::RightButton) {
00054
00055 QTab *tab = selectTab(e->pos() );
00056 if( tab == 0L ) return;
00057
00058 m_pPage = ((KDevTabWidget*)parent())->page(indexOf(tab->identifier() ) );
00059 if(m_pPage == 0L) return;
00060
00061 m_pPopupMenu->exec(mapToGlobal(e->pos()));
00062 }
00063 QTabBar::mousePressEvent(e);
00064 }
00065
00066 #include "kdevtabwidget.moc"
This file is part of the documentation for KDevelop Version 3.1.2.