24 #include <QToolButton>
31 setElideMode( Qt::ElideRight );
32 setTabsClosable(
true );
33 tabBar()->setSelectionBehaviorOnRemove( QTabBar::SelectPreviousTab );
34 setDocumentMode(
true);
38 mNewTabButton =
new QToolButton(
this );
39 mNewTabButton->setIcon( KIcon( QLatin1String(
"tab-new" ) ) );
40 mNewTabButton->adjustSize();
41 mNewTabButton->setToolTip( i18nc(
"@info:tooltip",
"Open a new tab"));
42 #ifndef QT_NO_ACCESSIBILITY
43 mNewTabButton->setAccessibleName( i18n(
"New tab" ) );
45 setCornerWidget( mNewTabButton, Qt::TopLeftCorner );
46 connect( mNewTabButton, SIGNAL(clicked()),
this, SIGNAL(
createNewPost()) );
48 mCloseTabButton =
new QToolButton(
this );
49 mCloseTabButton->setIcon( KIcon( QLatin1String(
"tab-close" ) ) );
50 mCloseTabButton->adjustSize();
51 mCloseTabButton->setToolTip( i18nc(
"@info:tooltip",
"Close the current tab"));
52 #ifndef QT_NO_ACCESSIBILITY
53 mCloseTabButton->setAccessibleName( i18n(
"Close tab" ) );
55 setCornerWidget( mCloseTabButton, Qt::TopRightCorner );
56 connect( mCloseTabButton, SIGNAL(clicked()),
this, SIGNAL(
closeTabClicked()) );
58 setContextMenuPolicy( Qt::CustomContextMenu );
59 connect(
this, SIGNAL(customContextMenuRequested(QPoint)),
60 this, SLOT(slotTabContextMenuRequest(QPoint)) );
67 void PostsTabWidget::slotTabContextMenuRequest(
const QPoint &pos )
69 QTabBar *bar = tabBar();
70 if ( count() < 1 )
return;
72 const int indexBar = bar->tabAt( bar->mapFrom(
this, pos ) );
77 QAction *closeTab = menu.addAction( i18nc(
"@action:inmenu",
"Close Tab" ) );
78 closeTab->setIcon( KIcon( QLatin1String(
"tab-close" ) ) );
80 QAction *allOther = menu.addAction( i18nc(
"@action:inmenu",
"Close All Other Tabs" ) );
81 allOther->setEnabled( count() > 1 );
82 allOther->setIcon( KIcon( QLatin1String(
"tab-close-other" ) ) );
84 QAction *action = menu.exec( mapToGlobal( pos ) );
86 if ( action == allOther ) {
88 }
else if (action == closeTab) {
89 Q_EMIT tabCloseRequested(indexBar);
94 #include "poststabwidget.moc"
PostsTabWidget(QWidget *parent)
void tabRemoveAllExclude(int)