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

kopete/kopete

  • sources
  • kde-4.12
  • kdenetwork
  • kopete
  • kopete
  • config
  • appearance
contactlisttoken.cpp
Go to the documentation of this file.
1 /*
2  Kopete ContactList Token
3 
4  Copyright (c) 2009 by Roman Jarosz <kedgedev@gmail.com>
5 
6  Kopete (c) 2009 by the Kopete developers <kopete-devel@kde.org>
7 
8  *************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  *************************************************************************
16 */
17 
18 #include "contactlisttoken.h"
19 
20 #include <QFont>
21 #include <QMenu>
22 
23 #include <KAction>
24 #include <KLocale>
25 
26 #include "kopeteitemdelegate.h"
27 
28 const QString ActionSmallName = QLatin1String( "ActionSmall" );
29 const QString ActionOptimalSizeName = QLatin1String( "ActionOptimalSize" );
30 
31 Token * ContactListTokenFactory::createToken(const QString &text, const QString &iconName, int value, QWidget *parent)
32 {
33  return new ContactListToken( text, iconName, value, parent );
34 }
35 
36 ContactListToken::ContactListToken( const QString &text, const QString &iconName, int value, QWidget *parent )
37 : TokenWithLayout( text, iconName, value, parent ), m_small( false ), m_optimalSize( false )
38 {
39 }
40 
41 void ContactListToken::fillMenu( QMenu * menu )
42 {
43  KAction *optimalSizeAction = new KAction( i18n( "Optimal width" ), menu );
44  optimalSizeAction->setObjectName( ActionOptimalSizeName );
45  optimalSizeAction->setCheckable( true );
46  optimalSizeAction->setChecked( m_optimalSize );
47  menu->addAction( optimalSizeAction );
48 
49  menu->addSeparator();
50 
51  KAction *smallAction = new KAction( KIcon( "format-font-size-less"), i18n( "Small" ), menu );
52  smallAction->setObjectName( ActionSmallName );
53  smallAction->setCheckable( true );
54  smallAction->setChecked( m_small );
55  menu->addAction( smallAction );
56 
57  TokenWithLayout::fillMenu( menu );
58 }
59 
60 void ContactListToken::menuExecuted( const QAction* action )
61 {
62  TokenWithLayout::menuExecuted( action );
63  if( action->objectName() == ActionSmallName )
64  setSmall( action->isChecked() );
65  else if( action->objectName() == ActionOptimalSizeName )
66  setOptimalSize( action->isChecked() );
67 }
68 
69 bool ContactListToken::small() const
70 {
71  return m_small;
72 }
73 
74 void ContactListToken::setSmall( bool small )
75 {
76  if ( m_small == small )
77  return;
78 
79  m_small = small;
80  QFont font( ( small ) ? KopeteItemDelegate::smallFont( this->font() ) : KopeteItemDelegate::normalFont( this->font() ) );
81  font.setBold( bold() );
82  font.setItalic( italic() );
83  m_label->setFont( font );
84  emit changed();
85 }
86 
87 bool ContactListToken::optimalSize() const
88 {
89  return m_optimalSize;
90 }
91 
92 void ContactListToken::setOptimalSize( bool optimalSize )
93 {
94  if ( m_optimalSize == optimalSize )
95  return;
96 
97  m_optimalSize = optimalSize;
98  emit changed();
99 }
100 
101 #include "contactlisttoken.moc"
KopeteItemDelegate::normalFont
static QFont normalFont(const QFont &naturalFont)
Definition: kopeteitemdelegate.cpp:54
TokenWithLayout
An extended Token with controls for layouting the token and getting layout values for use outside the...
Definition: TokenWithLayout.h:38
ContactListToken::setSmall
void setSmall(bool small)
Definition: contactlisttoken.cpp:74
Token::changed
void changed()
QWidget
Token::m_label
QLabel * m_label
Definition: Token.h:65
ContactListToken::ContactListToken
ContactListToken(const QString &text, const QString &iconName, int value, QWidget *parent=0)
Definition: contactlisttoken.cpp:36
TokenWithLayout::bold
bool bold() const
Definition: TokenWithLayout.cpp:214
ContactListToken::optimalSize
bool optimalSize() const
Definition: contactlisttoken.cpp:87
TokenWithLayout::fillMenu
virtual void fillMenu(QMenu *menu)
Definition: TokenWithLayout.cpp:63
ContactListToken
Definition: contactlisttoken.h:29
ContactListToken::setOptimalSize
void setOptimalSize(bool optimalSize)
Definition: contactlisttoken.cpp:92
ContactListToken::menuExecuted
virtual void menuExecuted(const QAction *action)
Definition: contactlisttoken.cpp:60
ContactListTokenFactory::createToken
virtual Token * createToken(const QString &text, const QString &iconName, int value, QWidget *parent=0)
Definition: contactlisttoken.cpp:31
ContactListToken::small
bool small() const
Definition: contactlisttoken.cpp:69
TokenWithLayout::italic
bool italic() const
Definition: TokenWithLayout.cpp:268
KAction
TokenWithLayout::menuExecuted
virtual void menuExecuted(const QAction *action)
Definition: TokenWithLayout.cpp:152
Token
Definition: Token.h:38
ActionOptimalSizeName
const QString ActionOptimalSizeName
Definition: contactlisttoken.cpp:29
ActionSmallName
const QString ActionSmallName
Definition: contactlisttoken.cpp:28
contactlisttoken.h
ContactListToken::fillMenu
virtual void fillMenu(QMenu *menu)
Definition: contactlisttoken.cpp:41
KopeteItemDelegate::smallFont
static QFont smallFont(const QFont &naturalFont)
Definition: kopeteitemdelegate.cpp:62
kopeteitemdelegate.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/kopete

Skip menu "kopete/kopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

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