author | zecke <zecke> | 2002-04-13 23:18:09 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-13 23:18:09 (UTC) |
commit | 707f0d3dd81b8ecec2df4e942c0efd2ee51b7fc5 (patch) (unidiff) | |
tree | d17645bbf5e0318e6e10c3377605c107a110ebd1 /libopie/ofontmenu.cc | |
parent | 0f7ff8056deb70f1c32bdcf46bb2b623063bdc1c (diff) | |
download | opie-707f0d3dd81b8ecec2df4e942c0efd2ee51b7fc5.zip opie-707f0d3dd81b8ecec2df4e942c0efd2ee51b7fc5.tar.gz opie-707f0d3dd81b8ecec2df4e942c0efd2ee51b7fc5.tar.bz2 |
PopupMenu for fontsize handling like on the Zaurus
-rw-r--r-- | libopie/ofontmenu.cc | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/libopie/ofontmenu.cc b/libopie/ofontmenu.cc new file mode 100644 index 0000000..2acae1c --- a/dev/null +++ b/libopie/ofontmenu.cc | |||
@@ -0,0 +1,78 @@ | |||
1 | |||
2 | #include "ofontmenu.h" | ||
3 | |||
4 | |||
5 | |||
6 | OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list ) | ||
7 | : QPopupMenu( parent, name ) | ||
8 | { | ||
9 | m_list = list; | ||
10 | insertItem(tr("Large"), this, SLOT(slotLarge() ), | ||
11 | 0, 10); | ||
12 | insertItem(tr("Medium"), this, SLOT(slotMedium() ), | ||
13 | 0, 11 ); | ||
14 | insertItem(tr("Small"), this, SLOT(slotSmall() ), | ||
15 | 0, 12 ); | ||
16 | setCheckable( true ); | ||
17 | } | ||
18 | void OFontMenu::setWidgets(const QList<QWidget> &list ) | ||
19 | { | ||
20 | m_list = list; | ||
21 | } | ||
22 | void OFontMenu::addWidget( QWidget *wid ) | ||
23 | { | ||
24 | m_list.append(wid ); | ||
25 | } | ||
26 | void OFontMenu::removeWidget( QWidget *wid ) | ||
27 | { | ||
28 | m_list.remove( wid ); | ||
29 | } | ||
30 | const QList<QWidget> &OFontMenu::widgets()const | ||
31 | { | ||
32 | return m_list; | ||
33 | } | ||
34 | void OFontMenu::forceSize(QWidget *wid, int size ) | ||
35 | { | ||
36 | WidSize *widz = new WidSize; | ||
37 | widz->wid = wid; | ||
38 | widz->size = size; | ||
39 | m_wids.append( widz ); | ||
40 | } | ||
41 | void OFontMenu::slotSmall() | ||
42 | { | ||
43 | setItemChecked(10, false ); | ||
44 | setItemChecked(11, false ); | ||
45 | setItemChecked(12, true ); | ||
46 | setFontSize( 8 ); | ||
47 | } | ||
48 | void OFontMenu::slotMedium() | ||
49 | { | ||
50 | setItemChecked(10, false ); | ||
51 | setItemChecked(11, true ); | ||
52 | setItemChecked(12, false ); | ||
53 | setFontSize(10 ); | ||
54 | } | ||
55 | void OFontMenu::slotLarge() | ||
56 | { | ||
57 | setItemChecked(10, true ); | ||
58 | setItemChecked(11, false ); | ||
59 | setItemChecked(12, false ); | ||
60 | setFontSize(14 ); | ||
61 | } | ||
62 | void OFontMenu::setFontSize(int size ) | ||
63 | { | ||
64 | QWidget *wid; | ||
65 | for(wid = m_list.first(); wid !=0; wid = m_list.next() ){ | ||
66 | QFont font = wid->font(); | ||
67 | font.setPointSize( size ); | ||
68 | wid->setFont( font ); | ||
69 | } | ||
70 | if(!m_wids.isEmpty() ){ | ||
71 | WidSize *wids; | ||
72 | for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){ | ||
73 | QFont font = wids->wid->font(); | ||
74 | font.setPointSize( wids->size ); | ||
75 | wids->wid->setFont( font ); | ||
76 | } | ||
77 | } | ||
78 | } | ||