summaryrefslogtreecommitdiff
path: root/libopie/ofontmenu.cc
authorzecke <zecke>2003-04-13 16:57:28 (UTC)
committer zecke <zecke>2003-04-13 16:57:28 (UTC)
commit0b311079ff19798866291034663757103c6ba935 (patch) (unidiff)
tree70ddccf3a3147475050fa06cc2d807a71ab1d5ee /libopie/ofontmenu.cc
parent1537ccb435ca725c793db6e94e0b9e83484b57e7 (diff)
downloadopie-0b311079ff19798866291034663757103c6ba935.zip
opie-0b311079ff19798866291034663757103c6ba935.tar.gz
opie-0b311079ff19798866291034663757103c6ba935.tar.bz2
Jumbo API documentation update
and some API fixed ColorDialog is now OColorDialog!!! keep the namespace tidy! ColorPopupMenu is now OColorPopupMenu!!! keep the namespace tidy ColorDialog TT couldn't break bc we can so make it const QColor& OTimePicker add some convience methods more I might have forgot
Diffstat (limited to 'libopie/ofontmenu.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofontmenu.cc46
1 files changed, 45 insertions, 1 deletions
diff --git a/libopie/ofontmenu.cc b/libopie/ofontmenu.cc
index 52ff3ee..d16c5e5 100644
--- a/libopie/ofontmenu.cc
+++ b/libopie/ofontmenu.cc
@@ -1,112 +1,156 @@
1 1
2 2
3#include <qpe/config.h> 3#include <qpe/config.h>
4#include "ofontmenu.h" 4#include "ofontmenu.h"
5 5
6 6
7 7/**
8 * Constructs the FontMenu.
9 *
10 * @param parent The parent widget
11 * @param name A name for this widget
12 * @param list The list of widgets to be controlled
13 */
8OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list ) 14OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list )
9 : QPopupMenu( parent, name ) 15 : QPopupMenu( parent, name )
10{ 16{
11 m_list = list; 17 m_list = list;
12 m_wids.setAutoDelete( TRUE ); 18 m_wids.setAutoDelete( TRUE );
13 19
14 insertItem(tr("Large"), this, SLOT(slotLarge() ), 20 insertItem(tr("Large"), this, SLOT(slotLarge() ),
15 0, 10); 21 0, 10);
16 insertItem(tr("Medium"), this, SLOT(slotMedium() ), 22 insertItem(tr("Medium"), this, SLOT(slotMedium() ),
17 0, 11 ); 23 0, 11 );
18 insertItem(tr("Small"), this, SLOT(slotSmall() ), 24 insertItem(tr("Small"), this, SLOT(slotSmall() ),
19 0, 12 ); 25 0, 12 );
20 setCheckable( true ); 26 setCheckable( true );
21 m_size=10; 27 m_size=10;
22} 28}
29
30/**
31 * This method saves the font size
32 * into a Config object
33 * OFontMenu will be used as group and size as key
34 * @param cfg The Config object to be used
35 */
23void OFontMenu::save(Config *cfg ) 36void OFontMenu::save(Config *cfg )
24{ 37{
25 cfg->setGroup("OFontMenu" ); 38 cfg->setGroup("OFontMenu" );
26 cfg->writeEntry("size", m_size ); 39 cfg->writeEntry("size", m_size );
27} 40}
41
42/**
43 * This method restores the font size from a Config object
44 * it'll apply the sizes to the widgets and will also set the
45 * menu appropriate
46 */
28void OFontMenu::restore(Config *cfg ) 47void OFontMenu::restore(Config *cfg )
29{ 48{
30 cfg->setGroup("OFontMeny" ); 49 cfg->setGroup("OFontMeny" );
31 m_size = cfg->readNumEntry("size" ); 50 m_size = cfg->readNumEntry("size" );
32 setItemChecked(10, false ); 51 setItemChecked(10, false );
33 setItemChecked(11, false ); 52 setItemChecked(11, false );
34 setItemChecked(12, false ); 53 setItemChecked(12, false );
35 switch( m_size ){ 54 switch( m_size ){
36 case 8: 55 case 8:
37 setItemChecked(12, true ); 56 setItemChecked(12, true );
38 break; 57 break;
39 case 14: 58 case 14:
40 setItemChecked(10, true ); 59 setItemChecked(10, true );
41 break; 60 break;
42 case 10:// fall through 61 case 10:// fall through
43 default: 62 default:
44 setItemChecked(11, true ); 63 setItemChecked(11, true );
45 m_size = 10; 64 m_size = 10;
46 break; 65 break;
47 } 66 }
48 setFontSize( m_size ); 67 setFontSize( m_size );
49} 68}
69
70/**
71 * set the list of widgets
72 * @param list the widget list
73 */
50void OFontMenu::setWidgets(const QList<QWidget> &list ) 74void OFontMenu::setWidgets(const QList<QWidget> &list )
51{ 75{
52 m_list = list; 76 m_list = list;
53} 77}
78
79/**
80 * add a widget to the list
81 * @param wid The widget to be added
82 */
54void OFontMenu::addWidget( QWidget *wid ) 83void OFontMenu::addWidget( QWidget *wid )
55{ 84{
56 m_list.append(wid ); 85 m_list.append(wid );
57} 86}
87
88/**
89 * removes the widget from the list of controlled objects
90 * @param wid the to be removed widget
91 */
58void OFontMenu::removeWidget( QWidget *wid ) 92void OFontMenu::removeWidget( QWidget *wid )
59{ 93{
60 m_list.remove( wid ); 94 m_list.remove( wid );
61} 95}
96
97/**
98 * The list of controlled widgets
99 */
62const QList<QWidget> &OFontMenu::widgets()const 100const QList<QWidget> &OFontMenu::widgets()const
63{ 101{
64 return m_list; 102 return m_list;
65} 103}
104
105/**
106 * Forces a size on a widget
107 * @param wid The widget
108 * @param size The font size forced onto the widget
109 */
66void OFontMenu::forceSize(QWidget *wid, int size ) 110void OFontMenu::forceSize(QWidget *wid, int size )
67{ 111{
68 WidSize *widz = new WidSize; 112 WidSize *widz = new WidSize;
69 widz->wid = wid; 113 widz->wid = wid;
70 widz->size = size; 114 widz->size = size;
71 m_wids.append( widz ); 115 m_wids.append( widz );
72} 116}
73void OFontMenu::slotSmall() 117void OFontMenu::slotSmall()
74{ 118{
75 setItemChecked(10, false ); 119 setItemChecked(10, false );
76 setItemChecked(11, false ); 120 setItemChecked(11, false );
77 setItemChecked(12, true ); 121 setItemChecked(12, true );
78 setFontSize( 8 ); 122 setFontSize( 8 );
79} 123}
80void OFontMenu::slotMedium() 124void OFontMenu::slotMedium()
81{ 125{
82 setItemChecked(10, false ); 126 setItemChecked(10, false );
83 setItemChecked(11, true ); 127 setItemChecked(11, true );
84 setItemChecked(12, false ); 128 setItemChecked(12, false );
85 setFontSize(10 ); 129 setFontSize(10 );
86} 130}
87void OFontMenu::slotLarge() 131void OFontMenu::slotLarge()
88{ 132{
89 setItemChecked(10, true ); 133 setItemChecked(10, true );
90 setItemChecked(11, false ); 134 setItemChecked(11, false );
91 setItemChecked(12, false ); 135 setItemChecked(12, false );
92 setFontSize(14 ); 136 setFontSize(14 );
93} 137}
94void OFontMenu::setFontSize(int size ) 138void OFontMenu::setFontSize(int size )
95{ 139{
96 m_size = size; 140 m_size = size;
97 QWidget *wid; 141 QWidget *wid;
98 for(wid = m_list.first(); wid !=0; wid = m_list.next() ){ 142 for(wid = m_list.first(); wid !=0; wid = m_list.next() ){
99 QFont font = wid->font(); 143 QFont font = wid->font();
100 font.setPointSize( size ); 144 font.setPointSize( size );
101 wid->setFont( font ); 145 wid->setFont( font );
102 } 146 }
103 if(!m_wids.isEmpty() ){ 147 if(!m_wids.isEmpty() ){
104 WidSize *wids; 148 WidSize *wids;
105 for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){ 149 for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){
106 QFont font = wids->wid->font(); 150 QFont font = wids->wid->font();
107 font.setPointSize( wids->size ); 151 font.setPointSize( wids->size );
108 wids->wid->setFont( font ); 152 wids->wid->setFont( font );
109 } 153 }
110 } 154 }
111 emit fontChanged(size ); 155 emit fontChanged(size );
112} 156}