Diffstat (limited to 'core/settings/button/remapdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/button/remapdlg.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/core/settings/button/remapdlg.cpp b/core/settings/button/remapdlg.cpp index a251bd4..b6ee60b 100644 --- a/core/settings/button/remapdlg.cpp +++ b/core/settings/button/remapdlg.cpp | |||
@@ -38,90 +38,108 @@ public: | |||
38 | } | 38 | } |
39 | 39 | ||
40 | private: | 40 | private: |
41 | QString m_key; | 41 | QString m_key; |
42 | bool m_def; | 42 | bool m_def; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | 45 | ||
46 | RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name ) | 46 | RemapDlg::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 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); | 62 | |
63 | if (m_msg. channel ( ) == "ignore") | ||
64 | { | ||
65 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); | ||
66 | |||
67 | m_current = m_map_none; | ||
68 | } | ||
69 | else | ||
70 | { | ||
71 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); | ||
72 | m_current = m_map_custom; | ||
73 | } | ||
63 | 74 | ||
64 | QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); | 75 | QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); |
65 | ButtonUtils::inst ( )-> insertActions ( it ); | 76 | ButtonUtils::inst ( )-> insertActions ( it ); |
66 | it-> setOpen ( true ); | 77 | it-> setOpen ( true ); |
67 | 78 | ||
68 | m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); | 79 | m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); |
69 | 80 | ||
70 | m_current = m_map_custom; | ||
71 | w_list-> setCurrentItem ( m_current ); | 81 | w_list-> setCurrentItem ( m_current ); |
72 | 82 | ||
73 | QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); | 83 | QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); |
74 | } | 84 | } |
75 | 85 | ||
76 | RemapDlg::~RemapDlg ( ) | 86 | RemapDlg::~RemapDlg ( ) |
77 | { | 87 | { |
78 | } | 88 | } |
79 | 89 | ||
80 | void RemapDlg::delayedInit ( ) | 90 | void RemapDlg::delayedInit ( ) |
81 | { | 91 | { |
82 | bool b = w_list-> viewport ( )-> isUpdatesEnabled ( ); | 92 | bool b = w_list-> viewport ( )-> isUpdatesEnabled ( ); |
83 | w_list-> viewport ( )-> setUpdatesEnabled ( false ); | 93 | w_list-> viewport ( )-> setUpdatesEnabled ( false ); |
84 | 94 | ||
85 | ButtonUtils::inst ( )-> insertAppLnks ( m_map_show ); | 95 | ButtonUtils::inst ( )-> insertAppLnks ( m_map_show ); |
86 | 96 | ||
87 | w_list-> viewport ( )-> setUpdatesEnabled ( b ); | 97 | w_list-> viewport ( )-> setUpdatesEnabled ( b ); |
88 | 98 | ||
89 | m_map_show-> repaint ( ); | 99 | m_map_show-> repaint ( ); |
90 | } | 100 | } |
91 | 101 | ||
92 | void RemapDlg::itemChanged ( QListViewItem *it ) | 102 | void RemapDlg::itemChanged ( QListViewItem *it ) |
93 | { | 103 | { |
94 | bool enabled = false; | 104 | bool enabled = false; |
95 | OQCopMessage m; | 105 | OQCopMessage m; |
96 | 106 | ||
97 | m_current = it; | 107 | m_current = it; |
98 | 108 | ||
99 | if ( it == m_map_none ) | 109 | if ( it == m_map_none ) |
100 | m_msg = m = OQCopMessage ( 0, 0 ); | 110 | { |
111 | m_msg = m = OQCopMessage ( "ignore", 0 ); | ||
112 | qDebug ("***ignoring"); | ||
113 | } | ||
101 | else if ( it == m_map_preset ) | 114 | else if ( it == m_map_preset ) |
115 | { | ||
102 | m_msg = m = m_msg_preset; | 116 | m_msg = m = m_msg_preset; |
103 | else if ( it && !it-> childCount ( )) { | 117 | qDebug ("***Preset"); |
118 | } | ||
119 | else if ( it && !it-> childCount ( )) | ||
120 | { | ||
121 | qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); | ||
104 | enabled = ( it == m_map_custom ); | 122 | enabled = ( it == m_map_custom ); |
105 | 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 ( )); |
106 | } | 124 | } |
107 | 125 | ||
108 | w_channel-> setEnabled ( enabled ); | 126 | w_channel-> setEnabled ( enabled ); |
109 | w_message-> setEnabled ( enabled ); | 127 | w_message-> setEnabled ( enabled ); |
110 | 128 | ||
111 | w_channel-> setEditText ( m. channel ( )); | 129 | w_channel-> setEditText ( m. channel ( )); |
112 | w_message-> setEditText ( m. message ( )); | 130 | w_message-> setEditText ( m. message ( )); |
113 | } | 131 | } |
114 | 132 | ||
115 | void RemapDlg::textChanged ( const QString &str ) | 133 | void RemapDlg::textChanged ( const QString &str ) |
116 | { | 134 | { |
117 | if ( !m_current ) | 135 | if ( !m_current ) |
118 | return; | 136 | return; |
119 | 137 | ||
120 | QComboBox *which = (QComboBox *) sender ( ); | 138 | QComboBox *which = (QComboBox *) sender ( ); |
121 | 139 | ||
122 | if ( which == w_channel ) | 140 | if ( which == w_channel ) |
123 | m_current-> setText ( 1, str ); | 141 | m_current-> setText ( 1, str ); |
124 | else if ( which == w_message ) | 142 | else if ( which == w_message ) |
125 | m_current-> setText ( 2, str ); | 143 | m_current-> setText ( 2, str ); |
126 | } | 144 | } |
127 | 145 | ||