summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-04-15 00:36:18 (UTC)
committer llornkcor <llornkcor>2003-04-15 00:36:18 (UTC)
commit02f76303f1b134c26b13c30f97295e78ffca051b (patch) (side-by-side diff)
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
@@ -12,32 +12,32 @@ class NoSortItem : public QListViewItem {
public:
- NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 )
- : QListViewItem ( lv, str, s1, s2 )
- {
- m_key = QString ( QChar ( 'a' + pos ));
- m_def = false;
- }
-
- void setDefault ( bool b )
- {
- m_def = b;
- }
-
- virtual QString key ( int /*column*/, bool /*ascending*/ ) const
- {
- return m_key;
- }
-
- virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align )
- {
- if ( m_def ) {
- QFont f ( listView ( )-> font ( ));
- f. setBold ( true );
- p-> setFont ( f );
- }
- QListViewItem::paintCell ( p, cg, column, width, align );
- }
-
+ NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 )
+ : QListViewItem ( lv, str, s1, s2 )
+ {
+ m_key = QString ( QChar ( 'a' + pos ));
+ m_def = false;
+ }
+
+ void setDefault ( bool b )
+ {
+ m_def = b;
+ }
+
+ virtual QString key ( int /*column*/, bool /*ascending*/ ) const
+ {
+ return m_key;
+ }
+
+ virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align )
+ {
+ if ( m_def ) {
+ QFont f ( listView ( )-> font ( ));
+ f. setBold ( true );
+ p-> setFont ( f );
+ }
+ QListViewItem::paintCell ( p, cg, column, width, align );
+ }
+
private:
- QString m_key;
- bool m_def;
+ QString m_key;
+ bool m_def;
};
@@ -46,39 +46,39 @@ private:
RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name )
- : RemapDlgBase ( parent, name, true, WStyle_ContextHelp )
+ : RemapDlgBase ( parent, name, true, WStyle_ContextHelp )
{
- setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( )));
+ setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( )));
- m_current = 0;
-
- static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 };
- w_channel-> insertStrList ((const char **) def_channels );
-
- m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( );
- m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( );
-
- m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" ));
- m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
- ((NoSortItem *) m_map_preset )-> setDefault ( true );
-
- if (m_msg. channel ( ) == "ignore")
- {
- m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
-
- m_current = m_map_none;
- }
- else
- {
- m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( ));
- m_current = m_map_custom;
- }
-
- QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" ));
- ButtonUtils::inst ( )-> insertActions ( it );
- it-> setOpen ( true );
-
- m_map_show = new NoSortItem ( w_list, 4, tr( "Show" ));
-
- w_list-> setCurrentItem ( m_current );
-
- QTimer::singleShot ( 0, this, SLOT( delayedInit ( )));
+ m_current = 0;
+
+ static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 };
+ w_channel-> insertStrList ((const char **) def_channels );
+
+ m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( );
+ m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( );
+
+ m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" ));
+ m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
+ ((NoSortItem *) m_map_preset )-> setDefault ( true );
+
+ if (m_msg. channel ( ) == "ignore")
+ {
+ m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
+
+ m_current = m_map_none;
+ }
+ else
+ {
+ m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( ));
+ m_current = m_map_custom;
+ }
+
+ QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" ));
+ ButtonUtils::inst ( )-> insertActions ( it );
+ it-> setOpen ( true );
+
+ m_map_show = new NoSortItem ( w_list, 4, tr( "Show" ));
+
+ w_list-> setCurrentItem ( m_current );
+
+ QTimer::singleShot ( 0, this, SLOT( delayedInit ( )));
}
@@ -91,10 +91,10 @@ void RemapDlg::delayedInit ( )
{
- bool b = w_list-> viewport ( )-> isUpdatesEnabled ( );
- w_list-> viewport ( )-> setUpdatesEnabled ( false );
-
- ButtonUtils::inst ( )-> insertAppLnks ( m_map_show );
-
- w_list-> viewport ( )-> setUpdatesEnabled ( b );
-
- m_map_show-> repaint ( );
+ bool b = w_list-> viewport ( )-> isUpdatesEnabled ( );
+ w_list-> viewport ( )-> setUpdatesEnabled ( false );
+
+ ButtonUtils::inst ( )-> insertAppLnks ( m_map_show );
+
+ w_list-> viewport ( )-> setUpdatesEnabled ( b );
+
+ m_map_show-> repaint ( );
}
@@ -103,29 +103,33 @@ void RemapDlg::itemChanged ( QListViewItem *it )
{
- bool enabled = false;
- OQCopMessage m;
-
- m_current = it;
+ bool enabled = false;
+ OQCopMessage m;
+
+ m_current = it;
- if ( it == m_map_none )
- {
- m_msg = m = OQCopMessage ( "ignore", 0 );
- qDebug ("***ignoring");
- }
- else if ( it == m_map_preset )
- {
- m_msg = m = m_msg_preset;
- qDebug ("***Preset");
- }
- else if ( it && !it-> childCount ( ))
- {
- qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
- enabled = ( it == m_map_custom );
- m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
- }
-
- w_channel-> setEnabled ( enabled );
- w_message-> setEnabled ( enabled );
-
- w_channel-> setEditText ( m. channel ( ));
- w_message-> setEditText ( m. message ( ));
+ if ( it == m_map_none )
+ {
+ m_msg = m = OQCopMessage ( "ignore", 0 );
+ qDebug ("***ignoring");
+ }
+ else if ( it == m_map_preset )
+ {
+ m_msg = m = m_msg_preset;
+ qDebug ("***Preset");
+ }
+ else if ( it && !it-> childCount ( ) )
+ {
+ qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
+ enabled = ( it == m_map_custom );
+ m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
+ }
+
+ w_channel-> setEnabled ( enabled );
+ w_message-> setEnabled ( enabled );
+
+ w_channel-> setEditText ( m. channel ( ));
+//hack for if user has typed in a message, such as 'suspend()'
+//so raise() is always present
+ if(m. message ( ) != "raise()")
+ w_message->insertItem("raise()");
+ w_message-> setEditText ( m. message ( ));
}
@@ -134,11 +138,11 @@ void RemapDlg::textChanged ( const QString &str )
{
- if ( !m_current )
- return;
+ if ( !m_current )
+ return;
- QComboBox *which = (QComboBox *) sender ( );
+ QComboBox *which = (QComboBox *) sender ( );
- if ( which == w_channel )
- m_current-> setText ( 1, str );
- else if ( which == w_message )
- m_current-> setText ( 2, str );
+ if ( which == w_channel )
+ m_current-> setText ( 1, str );
+ else if ( which == w_message )
+ m_current-> setText ( 2, str );
}
@@ -147,3 +151,5 @@ OQCopMessage RemapDlg::message ( )
{
- return m_msg;
+//make sure to update message if typed in
+ itemChanged(w_list->currentItem());
+ return m_msg;
}