summaryrefslogtreecommitdiff
path: root/core/settings
Side-by-side diff
Diffstat (limited to 'core/settings') (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/button/buttonsettings.cpp8
-rw-r--r--core/settings/button/buttonsettings.h1
-rw-r--r--core/settings/button/buttonutils.cpp22
-rw-r--r--core/settings/button/remapdlg.cpp27
-rw-r--r--core/settings/button/remapdlg.h4
5 files changed, 48 insertions, 14 deletions
diff --git a/core/settings/button/buttonsettings.cpp b/core/settings/button/buttonsettings.cpp
index c71514c..8b0b0a8 100644
--- a/core/settings/button/buttonsettings.cpp
+++ b/core/settings/button/buttonsettings.cpp
@@ -51,24 +51,25 @@ struct buttoninfo {
QLabel *m_hicon;
QLabel *m_hlabel;
bool m_pdirty : 1;
bool m_hdirty : 1;
};
ButtonSettings::ButtonSettings ( )
: QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp )
{
const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( );
+ (void) ButtonUtils::inst ( ); // initialise
setCaption ( tr( "Button Settings" ));
QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 );
QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this );
toplay-> addWidget ( l );
QGridLayout *lay = new QGridLayout ( toplay );
lay-> setMargin ( 0 );
lay-> setColStretch ( 0, 0 );
lay-> setColStretch ( 1, 0 );
@@ -124,24 +125,25 @@ ButtonSettings::ButtonSettings ( )
l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine );
lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop );
bi-> m_hlabel = l;
i += 2;
m_infos. append ( bi );
}
toplay-> addStretch ( 10 );
m_last_button = 0;
+ m_lock = false;
m_timer = new QTimer ( this );
connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( keyTimeout ( )));
updateLabels ( );
QPEApplication::grabKeyboard ( );
}
ButtonSettings::~ButtonSettings ( )
{
QPEApplication::ungrabKeyboard ( );
@@ -199,43 +201,49 @@ void ButtonSettings::keyReleaseEvent ( QKeyEvent *e )
void ButtonSettings::keyTimeout ( )
{
if ( m_last_button ) {
edit ( m_last_button, true );
m_last_button = false;
}
}
void ButtonSettings::edit ( buttoninfo *bi, bool hold )
{
qDebug ( "remap %s for %s", hold ? "hold" : "press", bi-> m_button-> userText ( ). latin1 ( ));
+ if ( m_lock )
+ return;
+ m_lock = true;
+
RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this );
d-> showMaximized ( );
if ( d-> exec ( ) == QDialog::Accepted ) {
qDebug ( " -> %s %s", d-> message ( ). channel ( ). data ( ), d-> message ( ). message ( ). data ( ));
if ( hold ) {
bi-> m_hmsg = d-> message ( );
bi-> m_hdirty = true;
}
else {
bi-> m_pmsg = d-> message ( );
bi-> m_pdirty = true;
}
updateLabels ( );
}
delete d;
+
+ m_lock = false;
}
void ButtonSettings::accept ( )
{
for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) {
buttoninfo *bi = *it;
if ( bi-> m_pdirty )
ODevice::inst ( )-> remapPressedAction ( bi-> m_index, bi-> m_pmsg );
if ( bi-> m_hdirty )
ODevice::inst ( )-> remapHeldAction ( bi-> m_index, bi-> m_hmsg );
}
diff --git a/core/settings/button/buttonsettings.h b/core/settings/button/buttonsettings.h
index f571825..d41a209 100644
--- a/core/settings/button/buttonsettings.h
+++ b/core/settings/button/buttonsettings.h
@@ -58,17 +58,18 @@ protected:
private:
buttoninfo *buttonInfoForKeycode ( ushort key );
void edit ( buttoninfo *bi, bool hold );
QString qcopToString ( const OQCopMessage &c );
private:
QTimer *m_timer;
buttoninfo *m_last_button;
QList <buttoninfo> m_infos;
+ bool m_lock;
};
#endif
diff --git a/core/settings/button/buttonutils.cpp b/core/settings/button/buttonutils.cpp
index bb70047..91d2af3 100644
--- a/core/settings/button/buttonutils.cpp
+++ b/core/settings/button/buttonutils.cpp
@@ -92,28 +92,36 @@ qCopInfo ButtonUtils::messageToInfo ( const OQCopMessage &c )
void ButtonUtils::insertActions ( QListViewItem *here )
{
for ( const predef_qcop *p = predef; p-> m_text; p++ ) {
QListViewItem *item = new QListViewItem ( here, qApp-> translate ( "ButtonSettings", p-> m_text ), p-> m_channel, p-> m_function );
item-> setPixmap ( 0, Resource::loadPixmap ( p-> m_pixmap ));
}
}
void ButtonUtils::insertAppLnks ( QListViewItem *here )
{
- QStringList types = m_apps-> types ( );
+ QStringList types = m_apps-> types ( );
+ QListViewItem *typeitem [types. count ( )];
+ int i = 0;
for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) {
QListViewItem *item = new QListViewItem ( here, m_apps-> typeName ( *it ));
item-> setPixmap ( 0, m_apps-> typePixmap ( *it ));
-
- for ( QListIterator <AppLnk> appit ( m_apps-> children ( )); *appit; ++appit ) {
- AppLnk *l = *appit;
-
+
+ typeitem [i++] = item;
+ }
+
+ for ( QListIterator <AppLnk> appit ( m_apps-> children ( )); *appit; ++appit ) {
+ AppLnk *l = *appit;
+
+ int i = 0;
+ for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) {
if ( l-> type ( ) == *it ) {
- QListViewItem *sub = new QListViewItem ( item, l-> name ( ), QString ( "QPE/Application/" ) + l-> exec ( ), "raise()" );
+ QListViewItem *sub = new QListViewItem ( typeitem [i], l-> name ( ), QString ( "QPE/Application/" ) + l-> exec ( ), "raise()" );
sub-> setPixmap ( 0, l-> pixmap ( ));
}
- }
+ i++;
+ }
}
}
diff --git a/core/settings/button/remapdlg.cpp b/core/settings/button/remapdlg.cpp
index 511d0e7..a251bd4 100644
--- a/core/settings/button/remapdlg.cpp
+++ b/core/settings/button/remapdlg.cpp
@@ -1,15 +1,16 @@
#include <qlistview.h>
#include <qlabel.h>
#include <qcombobox.h>
+#include <qtimer.h>
#include "remapdlg.h"
#include "buttonutils.h"
using namespace Opie;
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 ));
@@ -37,54 +38,66 @@ public:
}
private:
QString m_key;
bool m_def;
};
RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name )
: RemapDlgBase ( parent, name, true, WStyle_ContextHelp )
{
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 );
m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( ));
QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" ));
ButtonUtils::inst ( )-> insertActions ( it );
it-> setOpen ( true );
- it = new NoSortItem ( w_list, 4, tr( "Show" ));
- ButtonUtils::inst ( )-> insertAppLnks ( it );
+ m_map_show = new NoSortItem ( w_list, 4, tr( "Show" ));
m_current = m_map_custom;
w_list-> setCurrentItem ( m_current );
- static const char * const def_channels [] = {
- "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0
- };
-
- w_channel-> insertStrList ((const char **) def_channels );
+ QTimer::singleShot ( 0, this, SLOT( delayedInit ( )));
}
RemapDlg::~RemapDlg ( )
{
}
+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 ( );
+}
+
void RemapDlg::itemChanged ( QListViewItem *it )
{
bool enabled = false;
OQCopMessage m;
m_current = it;
if ( it == m_map_none )
m_msg = m = OQCopMessage ( 0, 0 );
else if ( it == m_map_preset )
m_msg = m = m_msg_preset;
else if ( it && !it-> childCount ( )) {
diff --git a/core/settings/button/remapdlg.h b/core/settings/button/remapdlg.h
index 8c9cc02..046a22f 100644
--- a/core/settings/button/remapdlg.h
+++ b/core/settings/button/remapdlg.h
@@ -11,25 +11,29 @@ class QListViewItem;
class RemapDlg : public RemapDlgBase {
Q_OBJECT
public:
RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget* parent = 0, const char* name = 0 );
~RemapDlg ( );
Opie::OQCopMessage message ( );
public slots:
virtual void itemChanged ( QListViewItem * );
virtual void textChanged ( const QString & );
+
+private slots:
+ void delayedInit ( );
private:
Opie::OQCopMessage m_msg;
Opie::OQCopMessage m_msg_preset;
QListViewItem *m_current;
QListViewItem *m_map_none;
QListViewItem *m_map_preset;
QListViewItem *m_map_custom;
+ QListViewItem *m_map_show;
};
#endif