summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-04-15 00:36:18 (UTC)
committer llornkcor <llornkcor>2003-04-15 00:36:18 (UTC)
commit02f76303f1b134c26b13c30f97295e78ffca051b (patch) (unidiff)
tree8f64d4caa99229fa7d93258656c318667e8d6d6f
parent0b785144fe1700423b8a57e51638d444f1725283 (diff)
downloadopie-02f76303f1b134c26b13c30f97295e78ffca051b.zip
opie-02f76303f1b134c26b13c30f97295e78ffca051b.tar.gz
opie-02f76303f1b134c26b13c30f97295e78ffca051b.tar.bz2
hack for bug 840. remembers typed in messages.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/button/remapdlg.cpp218
1 files changed, 112 insertions, 106 deletions
diff --git a/core/settings/button/remapdlg.cpp b/core/settings/button/remapdlg.cpp
index b6ee60b..939a6bf 100644
--- a/core/settings/button/remapdlg.cpp
+++ b/core/settings/button/remapdlg.cpp
@@ -1,150 +1,156 @@
1#include <qlistview.h> 1#include <qlistview.h>
2#include <qlabel.h> 2#include <qlabel.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qtimer.h> 4#include <qtimer.h>
5 5
6#include "remapdlg.h" 6#include "remapdlg.h"
7#include "buttonutils.h" 7#include "buttonutils.h"
8 8
9using namespace Opie; 9using namespace Opie;
10 10
11class NoSortItem : public QListViewItem { 11class NoSortItem : public QListViewItem {
12public: 12public:
13 NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 ) 13 NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 )
14 : QListViewItem ( lv, str, s1, s2 ) 14 : QListViewItem ( lv, str, s1, s2 )
15 { 15 {
16 m_key = QString ( QChar ( 'a' + pos )); 16 m_key = QString ( QChar ( 'a' + pos ));
17 m_def = false; 17 m_def = false;
18 } 18 }
19 19
20 void setDefault ( bool b ) 20 void setDefault ( bool b )
21 { 21 {
22 m_def = b; 22 m_def = b;
23 } 23 }
24 24
25 virtual QString key ( int /*column*/, bool /*ascending*/ ) const 25 virtual QString key ( int /*column*/, bool /*ascending*/ ) const
26 { 26 {
27 return m_key; 27 return m_key;
28 } 28 }
29 29
30 virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ) 30 virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align )
31 { 31 {
32 if ( m_def ) { 32 if ( m_def ) {
33 QFont f ( listView ( )-> font ( )); 33 QFont f ( listView ( )-> font ( ));
34 f. setBold ( true ); 34 f. setBold ( true );
35 p-> setFont ( f ); 35 p-> setFont ( f );
36 } 36 }
37 QListViewItem::paintCell ( p, cg, column, width, align ); 37 QListViewItem::paintCell ( p, cg, column, width, align );
38 } 38 }
39 39
40private: 40private:
41 QString m_key; 41 QString m_key;
42 bool m_def; 42 bool m_def;
43}; 43};
44 44
45 45
46RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name ) 46RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name )
47 : RemapDlgBase ( parent, name, true, WStyle_ContextHelp ) 47 : RemapDlgBase ( parent, name, true, WStyle_ContextHelp )
48{ 48{
49 setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( ))); 49 setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( )));
50 50
51 m_current = 0; 51 m_current = 0;
52 52
53 static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 }; 53 static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 };
54 w_channel-> insertStrList ((const char **) def_channels ); 54 w_channel-> insertStrList ((const char **) def_channels );
55 55
56 m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( ); 56 m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( );
57 m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( ); 57 m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( );
58 58
59 m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" )); 59 m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" ));
60 m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); 60 m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
61 ((NoSortItem *) m_map_preset )-> setDefault ( true ); 61 ((NoSortItem *) m_map_preset )-> setDefault ( true );
62 62
63 if (m_msg. channel ( ) == "ignore") 63 if (m_msg. channel ( ) == "ignore")
64 { 64 {
65 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); 65 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
66 66
67 m_current = m_map_none; 67 m_current = m_map_none;
68 } 68 }
69 else 69 else
70 { 70 {
71 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); 71 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( ));
72 m_current = m_map_custom; 72 m_current = m_map_custom;
73 } 73 }
74 74
75 QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); 75 QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" ));
76 ButtonUtils::inst ( )-> insertActions ( it ); 76 ButtonUtils::inst ( )-> insertActions ( it );
77 it-> setOpen ( true ); 77 it-> setOpen ( true );
78 78
79 m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); 79 m_map_show = new NoSortItem ( w_list, 4, tr( "Show" ));
80 80
81 w_list-> setCurrentItem ( m_current ); 81 w_list-> setCurrentItem ( m_current );
82 82
83 QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); 83 QTimer::singleShot ( 0, this, SLOT( delayedInit ( )));
84} 84}
85 85
86RemapDlg::~RemapDlg ( ) 86RemapDlg::~RemapDlg ( )
87{ 87{
88} 88}
89 89
90void RemapDlg::delayedInit ( ) 90void RemapDlg::delayedInit ( )
91{ 91{
92 bool b = w_list-> viewport ( )-> isUpdatesEnabled ( ); 92 bool b = w_list-> viewport ( )-> isUpdatesEnabled ( );
93 w_list-> viewport ( )-> setUpdatesEnabled ( false ); 93 w_list-> viewport ( )-> setUpdatesEnabled ( false );
94 94
95 ButtonUtils::inst ( )-> insertAppLnks ( m_map_show ); 95 ButtonUtils::inst ( )-> insertAppLnks ( m_map_show );
96 96
97 w_list-> viewport ( )-> setUpdatesEnabled ( b ); 97 w_list-> viewport ( )-> setUpdatesEnabled ( b );
98 98
99 m_map_show-> repaint ( ); 99 m_map_show-> repaint ( );
100} 100}
101 101
102void RemapDlg::itemChanged ( QListViewItem *it ) 102void RemapDlg::itemChanged ( QListViewItem *it )
103{ 103{
104 bool enabled = false; 104 bool enabled = false;
105 OQCopMessage m; 105 OQCopMessage m;
106 106
107 m_current = it; 107 m_current = it;
108 108
109 if ( it == m_map_none ) 109 if ( it == m_map_none )
110 { 110 {
111 m_msg = m = OQCopMessage ( "ignore", 0 ); 111 m_msg = m = OQCopMessage ( "ignore", 0 );
112 qDebug ("***ignoring"); 112 qDebug ("***ignoring");
113 } 113 }
114 else if ( it == m_map_preset ) 114 else if ( it == m_map_preset )
115 { 115 {
116 m_msg = m = m_msg_preset; 116 m_msg = m = m_msg_preset;
117 qDebug ("***Preset"); 117 qDebug ("***Preset");
118 } 118 }
119 else if ( it && !it-> childCount ( )) 119 else if ( it && !it-> childCount ( ) )
120 { 120 {
121 qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); 121 qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
122 enabled = ( it == m_map_custom ); 122 enabled = ( it == m_map_custom );
123 m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); 123 m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
124 } 124 }
125 125
126 w_channel-> setEnabled ( enabled ); 126 w_channel-> setEnabled ( enabled );
127 w_message-> setEnabled ( enabled ); 127 w_message-> setEnabled ( enabled );
128 128
129 w_channel-> setEditText ( m. channel ( )); 129 w_channel-> setEditText ( m. channel ( ));
130 w_message-> setEditText ( m. message ( )); 130//hack for if user has typed in a message, such as 'suspend()'
131//so raise() is always present
132 if(m. message ( ) != "raise()")
133 w_message->insertItem("raise()");
134 w_message-> setEditText ( m. message ( ));
131} 135}
132 136
133void RemapDlg::textChanged ( const QString &str ) 137void RemapDlg::textChanged ( const QString &str )
134{ 138{
135 if ( !m_current ) 139 if ( !m_current )
136 return; 140 return;
137 141
138 QComboBox *which = (QComboBox *) sender ( ); 142 QComboBox *which = (QComboBox *) sender ( );
139 143
140 if ( which == w_channel ) 144 if ( which == w_channel )
141 m_current-> setText ( 1, str ); 145 m_current-> setText ( 1, str );
142 else if ( which == w_message ) 146 else if ( which == w_message )
143 m_current-> setText ( 2, str ); 147 m_current-> setText ( 2, str );
144} 148}
145 149
146OQCopMessage RemapDlg::message ( ) 150OQCopMessage RemapDlg::message ( )
147{ 151{
148 return m_msg; 152//make sure to update message if typed in
153 itemChanged(w_list->currentItem());
154 return m_msg;
149} 155}
150 156