2 Copyright (c) 2014 Montel Laurent <montel@kde.org>
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "sieveeditortabwidget.h"
23 #include <KLocalizedString>
30 SieveEditorTabWidget::SieveEditorTabWidget(QWidget
*parent
)
34 setTabsClosable(true);
35 connect(this, SIGNAL(tabCloseRequested(int)), SIGNAL(tabCloseRequestedIndex(int)));
36 setContextMenuPolicy( Qt::CustomContextMenu
);
37 connect( this, SIGNAL(customContextMenuRequested(QPoint
)),
38 this, SLOT(slotTabContextMenuRequest(QPoint
)) );
41 SieveEditorTabWidget::~SieveEditorTabWidget()
46 void SieveEditorTabWidget::slotTabContextMenuRequest(const QPoint
&pos
)
48 QTabBar
*bar
= tabBar();
52 const int indexBar
= bar
->tabAt( bar
->mapFrom( this, pos
) );
57 QAction
*closeTab
= menu
.addAction( i18nc( "@action:inmenu", "Close Tab" ) );
58 closeTab
->setIcon( KIcon( QLatin1String( "tab-close" ) ) );
60 QAction
*allOther
= menu
.addAction( i18nc("@action:inmenu", "Close All Other Tabs" ) );
61 allOther
->setEnabled( count() > 1 );
62 allOther
->setIcon( KIcon( QLatin1String( "tab-close-other" ) ) );
64 QAction
*action
= menu
.exec( mapToGlobal( pos
) );
66 if ( action
== allOther
) { // Close all other tabs
67 Q_EMIT
tabRemoveAllExclude(indexBar
);
68 } else if (action
== closeTab
) {
69 Q_EMIT
tabCloseRequestedIndex(indexBar
);