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

blogilo

  • sources
  • kde-4.14
  • kdepim
  • blogilo
  • src
poststabwidget.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013-2015 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 
27 PostsTabWidget::PostsTabWidget(QWidget *parent)
28  : KTabWidget(parent)
29 {
30  setElideMode( Qt::ElideRight );
31  setTabsClosable( true );
32  tabBar()->setSelectionBehaviorOnRemove( QTabBar::SelectPreviousTab );
33  setDocumentMode(true);
34 
35  setMovable( true );
36 
37  mNewTabButton = new QToolButton( this );
38  mNewTabButton->setIcon( KIcon( QLatin1String( "tab-new" ) ) );
39  mNewTabButton->adjustSize();
40  mNewTabButton->setToolTip( i18nc("@info:tooltip", "Open a new tab"));
41 #ifndef QT_NO_ACCESSIBILITY
42  mNewTabButton->setAccessibleName( i18n( "New tab" ) );
43 #endif
44  setCornerWidget( mNewTabButton, Qt::TopLeftCorner );
45  connect( mNewTabButton, SIGNAL(clicked()), this, SIGNAL(createNewPost()) );
46 
47  mCloseTabButton = new QToolButton( this );
48  mCloseTabButton->setIcon( KIcon( QLatin1String( "tab-close" ) ) );
49  mCloseTabButton->adjustSize();
50  mCloseTabButton->setToolTip( i18nc("@info:tooltip", "Close the current tab"));
51 #ifndef QT_NO_ACCESSIBILITY
52  mCloseTabButton->setAccessibleName( i18n( "Close tab" ) );
53 #endif
54  setCornerWidget( mCloseTabButton, Qt::TopRightCorner );
55  connect( mCloseTabButton, SIGNAL(clicked()), this, SIGNAL(closeTabClicked()) );
56 
57  setContextMenuPolicy( Qt::CustomContextMenu );
58  connect( this, SIGNAL(customContextMenuRequested(QPoint)),
59  this, SLOT(slotTabContextMenuRequest(QPoint)) );
60 }
61 
62 PostsTabWidget::~PostsTabWidget()
63 {
64 }
65 
66 void PostsTabWidget::slotTabContextMenuRequest( const QPoint &pos )
67 {
68  QTabBar *bar = tabBar();
69  if ( count() < 1 ) return;
70 
71  const int indexBar = bar->tabAt( bar->mapFrom( this, pos ) );
72  if ( indexBar == -1 )
73  return;
74 
75  KMenu menu( this );
76  QAction *closeTab = menu.addAction( i18nc( "@action:inmenu", "Close Tab" ) );
77  closeTab->setIcon( KIcon( QLatin1String( "tab-close" ) ) );
78 
79  QAction *allOther = menu.addAction( i18nc("@action:inmenu", "Close All Other Tabs" ) );
80  allOther->setEnabled( count() > 1 );
81  allOther->setIcon( KIcon( QLatin1String( "tab-close-other" ) ) );
82 
83  QAction *action = menu.exec( mapToGlobal( pos ) );
84 
85  if ( action == allOther ) { // Close all other tabs
86  Q_EMIT tabRemoveAllExclude(indexBar);
87  } else if (action == closeTab) {
88  Q_EMIT tabCloseRequested(indexBar);
89  }
90 }
91 
92 
QWidget
PostsTabWidget::closeTabClicked
void closeTabClicked()
QAction::setIcon
void setIcon(const QIcon &icon)
QPoint
QWidget::adjustSize
void adjustSize()
QAbstractButton::setIcon
void setIcon(const QIcon &icon)
QWidget::setAccessibleName
void setAccessibleName(const QString &name)
PostsTabWidget::PostsTabWidget
PostsTabWidget(QWidget *parent)
Definition: poststabwidget.cpp:27
PostsTabWidget::~PostsTabWidget
~PostsTabWidget()
Definition: poststabwidget.cpp:62
QTabBar
QToolButton
PostsTabWidget::tabRemoveAllExclude
void tabRemoveAllExclude(int)
QLatin1String
PostsTabWidget::createNewPost
void createNewPost()
QAction
poststabwidget.h
QTabBar::tabAt
int tabAt(const QPoint &position) const
QWidget::setToolTip
void setToolTip(const QString &)
QAction::setEnabled
void setEnabled(bool)
QWidget::mapFrom
QPoint mapFrom(QWidget *parent, const QPoint &pos) const
KTabWidget
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:16 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
  • pimprint

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