• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

blogilo

  • sources
  • kde-4.12
  • kdepim
  • blogilo
  • src
poststabwidget.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "poststabwidget.h"
19 
20 #include <KLocale>
21 #include <KIcon>
22 #include <KMenu>
23 
24 #include <QToolButton>
25 #include <QTabBar>
26 #include <QDebug>
27 
28 PostsTabWidget::PostsTabWidget(QWidget *parent)
29  : KTabWidget(parent)
30 {
31  setElideMode( Qt::ElideRight );
32  setTabsClosable( true );
33  tabBar()->setSelectionBehaviorOnRemove( QTabBar::SelectPreviousTab );
34  setDocumentMode(true);
35 
36  setMovable( true );
37 
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" ) );
44 #endif
45  setCornerWidget( mNewTabButton, Qt::TopLeftCorner );
46  connect( mNewTabButton, SIGNAL(clicked()), this, SIGNAL(createNewPost()) );
47 
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" ) );
54 #endif
55  setCornerWidget( mCloseTabButton, Qt::TopRightCorner );
56  connect( mCloseTabButton, SIGNAL(clicked()), this, SIGNAL(closeTabClicked()) );
57 
58  setContextMenuPolicy( Qt::CustomContextMenu );
59  connect( this, SIGNAL(customContextMenuRequested(QPoint)),
60  this, SLOT(slotTabContextMenuRequest(QPoint)) );
61 }
62 
63 PostsTabWidget::~PostsTabWidget()
64 {
65 }
66 
67 void PostsTabWidget::slotTabContextMenuRequest( const QPoint &pos )
68 {
69  QTabBar *bar = tabBar();
70  if ( count() < 1 ) return;
71 
72  const int indexBar = bar->tabAt( bar->mapFrom( this, pos ) );
73  if ( indexBar == -1 )
74  return;
75 
76  KMenu menu( this );
77  QAction *closeTab = menu.addAction( i18nc( "@action:inmenu", "Close Tab" ) );
78  closeTab->setIcon( KIcon( QLatin1String( "tab-close" ) ) );
79 
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" ) ) );
83 
84  QAction *action = menu.exec( mapToGlobal( pos ) );
85 
86  if ( action == allOther ) { // Close all other tabs
87  Q_EMIT tabRemoveAllExclude(indexBar);
88  } else if (action == closeTab) {
89  Q_EMIT tabCloseRequested(indexBar);
90  }
91 }
92 
93 
94 #include "poststabwidget.moc"
PostsTabWidget::closeTabClicked
void closeTabClicked()
QWidget
PostsTabWidget::PostsTabWidget
PostsTabWidget(QWidget *parent)
Definition: poststabwidget.cpp:28
PostsTabWidget::~PostsTabWidget
~PostsTabWidget()
Definition: poststabwidget.cpp:63
PostsTabWidget::tabRemoveAllExclude
void tabRemoveAllExclude(int)
PostsTabWidget::createNewPost
void createNewPost()
poststabwidget.h
KTabWidget
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:44 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

blogilo

Skip menu "blogilo"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal