-rw-r--r-- | libopie/ofontmenu.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libopie/ofontmenu.cc b/libopie/ofontmenu.cc index 2acae1c..52ff3ee 100644 --- a/libopie/ofontmenu.cc +++ b/libopie/ofontmenu.cc | |||
@@ -1,78 +1,112 @@ | |||
1 | 1 | ||
2 | |||
3 | #include <qpe/config.h> | ||
2 | #include "ofontmenu.h" | 4 | #include "ofontmenu.h" |
3 | 5 | ||
4 | 6 | ||
5 | 7 | ||
6 | OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list ) | 8 | OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list ) |
7 | : QPopupMenu( parent, name ) | 9 | : QPopupMenu( parent, name ) |
8 | { | 10 | { |
9 | m_list = list; | 11 | m_list = list; |
12 | m_wids.setAutoDelete( TRUE ); | ||
13 | |||
10 | insertItem(tr("Large"), this, SLOT(slotLarge() ), | 14 | insertItem(tr("Large"), this, SLOT(slotLarge() ), |
11 | 0, 10); | 15 | 0, 10); |
12 | insertItem(tr("Medium"), this, SLOT(slotMedium() ), | 16 | insertItem(tr("Medium"), this, SLOT(slotMedium() ), |
13 | 0, 11 ); | 17 | 0, 11 ); |
14 | insertItem(tr("Small"), this, SLOT(slotSmall() ), | 18 | insertItem(tr("Small"), this, SLOT(slotSmall() ), |
15 | 0, 12 ); | 19 | 0, 12 ); |
16 | setCheckable( true ); | 20 | setCheckable( true ); |
21 | m_size=10; | ||
22 | } | ||
23 | void OFontMenu::save(Config *cfg ) | ||
24 | { | ||
25 | cfg->setGroup("OFontMenu" ); | ||
26 | cfg->writeEntry("size", m_size ); | ||
27 | } | ||
28 | void OFontMenu::restore(Config *cfg ) | ||
29 | { | ||
30 | cfg->setGroup("OFontMeny" ); | ||
31 | m_size = cfg->readNumEntry("size" ); | ||
32 | setItemChecked(10, false ); | ||
33 | setItemChecked(11, false ); | ||
34 | setItemChecked(12, false ); | ||
35 | switch( m_size ){ | ||
36 | case 8: | ||
37 | setItemChecked(12, true ); | ||
38 | break; | ||
39 | case 14: | ||
40 | setItemChecked(10, true ); | ||
41 | break; | ||
42 | case 10:// fall through | ||
43 | default: | ||
44 | setItemChecked(11, true ); | ||
45 | m_size = 10; | ||
46 | break; | ||
47 | } | ||
48 | setFontSize( m_size ); | ||
17 | } | 49 | } |
18 | void OFontMenu::setWidgets(const QList<QWidget> &list ) | 50 | void OFontMenu::setWidgets(const QList<QWidget> &list ) |
19 | { | 51 | { |
20 | m_list = list; | 52 | m_list = list; |
21 | } | 53 | } |
22 | void OFontMenu::addWidget( QWidget *wid ) | 54 | void OFontMenu::addWidget( QWidget *wid ) |
23 | { | 55 | { |
24 | m_list.append(wid ); | 56 | m_list.append(wid ); |
25 | } | 57 | } |
26 | void OFontMenu::removeWidget( QWidget *wid ) | 58 | void OFontMenu::removeWidget( QWidget *wid ) |
27 | { | 59 | { |
28 | m_list.remove( wid ); | 60 | m_list.remove( wid ); |
29 | } | 61 | } |
30 | const QList<QWidget> &OFontMenu::widgets()const | 62 | const QList<QWidget> &OFontMenu::widgets()const |
31 | { | 63 | { |
32 | return m_list; | 64 | return m_list; |
33 | } | 65 | } |
34 | void OFontMenu::forceSize(QWidget *wid, int size ) | 66 | void OFontMenu::forceSize(QWidget *wid, int size ) |
35 | { | 67 | { |
36 | WidSize *widz = new WidSize; | 68 | WidSize *widz = new WidSize; |
37 | widz->wid = wid; | 69 | widz->wid = wid; |
38 | widz->size = size; | 70 | widz->size = size; |
39 | m_wids.append( widz ); | 71 | m_wids.append( widz ); |
40 | } | 72 | } |
41 | void OFontMenu::slotSmall() | 73 | void OFontMenu::slotSmall() |
42 | { | 74 | { |
43 | setItemChecked(10, false ); | 75 | setItemChecked(10, false ); |
44 | setItemChecked(11, false ); | 76 | setItemChecked(11, false ); |
45 | setItemChecked(12, true ); | 77 | setItemChecked(12, true ); |
46 | setFontSize( 8 ); | 78 | setFontSize( 8 ); |
47 | } | 79 | } |
48 | void OFontMenu::slotMedium() | 80 | void OFontMenu::slotMedium() |
49 | { | 81 | { |
50 | setItemChecked(10, false ); | 82 | setItemChecked(10, false ); |
51 | setItemChecked(11, true ); | 83 | setItemChecked(11, true ); |
52 | setItemChecked(12, false ); | 84 | setItemChecked(12, false ); |
53 | setFontSize(10 ); | 85 | setFontSize(10 ); |
54 | } | 86 | } |
55 | void OFontMenu::slotLarge() | 87 | void OFontMenu::slotLarge() |
56 | { | 88 | { |
57 | setItemChecked(10, true ); | 89 | setItemChecked(10, true ); |
58 | setItemChecked(11, false ); | 90 | setItemChecked(11, false ); |
59 | setItemChecked(12, false ); | 91 | setItemChecked(12, false ); |
60 | setFontSize(14 ); | 92 | setFontSize(14 ); |
61 | } | 93 | } |
62 | void OFontMenu::setFontSize(int size ) | 94 | void OFontMenu::setFontSize(int size ) |
63 | { | 95 | { |
96 | m_size = size; | ||
64 | QWidget *wid; | 97 | QWidget *wid; |
65 | for(wid = m_list.first(); wid !=0; wid = m_list.next() ){ | 98 | for(wid = m_list.first(); wid !=0; wid = m_list.next() ){ |
66 | QFont font = wid->font(); | 99 | QFont font = wid->font(); |
67 | font.setPointSize( size ); | 100 | font.setPointSize( size ); |
68 | wid->setFont( font ); | 101 | wid->setFont( font ); |
69 | } | 102 | } |
70 | if(!m_wids.isEmpty() ){ | 103 | if(!m_wids.isEmpty() ){ |
71 | WidSize *wids; | 104 | WidSize *wids; |
72 | for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){ | 105 | for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){ |
73 | QFont font = wids->wid->font(); | 106 | QFont font = wids->wid->font(); |
74 | font.setPointSize( wids->size ); | 107 | font.setPointSize( wids->size ); |
75 | wids->wid->setFont( font ); | 108 | wids->wid->setFont( font ); |
76 | } | 109 | } |
77 | } | 110 | } |
111 | emit fontChanged(size ); | ||
78 | } | 112 | } |