SVN_SILENT made messages (.desktop file)
[kdepim.git] / sieveeditor / sieveeditortabwidget.cpp
blob9f454790091295a5b1ae48661df4cba41e009b71
1 /*
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
17 02110-1301, USA.
21 #include "sieveeditortabwidget.h"
23 #include <KLocalizedString>
24 #include <KMenu>
25 #include <KIcon>
27 #include <QTabBar>
28 #include <QAction>
30 SieveEditorTabWidget::SieveEditorTabWidget(QWidget *parent)
31 : KTabWidget(parent)
33 setMovable(true);
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();
49 if ( count() < 1 )
50 return;
52 const int indexBar = bar->tabAt( bar->mapFrom( this, pos ) );
53 if ( indexBar == -1 )
54 return;
56 KMenu menu( this );
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);