I would like for the combo boxes to be mouse wheel sensitive.
The patch works for me on my laptop (which has an up-down-clicky-thing acting
as a mouse wheel), but I haven't tested it with an actual *mouse* wheel.
- Jakob Lund.
Index: gui/src/widgets/LCDCombo.h
===================================================================
--- gui/src/widgets/LCDCombo.h (revision 220)
+++ gui/src/widgets/LCDCombo.h (working copy)
@@ -70,8 +70,12 @@
Button *button;
QMenu *pop;
int size;
+ int active;
+ static const QString SEPARATOR;
virtual void mousePressEvent(QMouseEvent *ev);
+ virtual void wheelEvent( QWheelEvent * ev );
};
+
#endif
Index: gui/src/widgets/LCDCombo.cpp
===================================================================
--- gui/src/widgets/LCDCombo.cpp (revision 220)
+++ gui/src/widgets/LCDCombo.cpp (working copy)
@@ -33,10 +33,11 @@
#include <hydrogen/globals.h>
+const QString LCDCombo::SEPARATOR("--sep--");
LCDCombo::LCDCombo(QWidget *pParent, int digits)
: QWidget(pParent)
- , Object( "LCDCombo")
+ , Object( "LCDCombo") //, SEPARATOR("--sep--")
{
INFOLOG( "INIT" );
@@ -50,6 +51,7 @@
);
pop = new QMenu( this );
size = digits;
+ active = 0;
button->move( ( digits * 8 ) + 5 , 1 );
setFixedSize( ( digits * 8 ) + 17, display->height() );
@@ -64,6 +66,7 @@
+
LCDCombo::~LCDCombo()
{
}
@@ -73,8 +76,9 @@
void LCDCombo::changeText(QAction* pAction)
{
//_WARNINGLOG("triggered");
- display->setText(pAction->text());
- emit valueChanged( pAction->text() );
+// display->setText(pAction->text());
+// emit valueChanged( pAction->text() );
+ set_text( pAction->text() );
}
@@ -99,7 +103,7 @@
pop->clear();
for( int i = 0; i < items.size(); i++ ) {
- if(items.at(i)!=QString("--sep--")){
+ if ( items.at(i) != SEPARATOR ){
pop->addAction( items.at(i) );
}else{
pop->addSeparator();
@@ -117,7 +121,7 @@
-bool LCDCombo::addItem(const QString &text )
+bool LCDCombo::addItem( const QString &text )
{
//INFOLOG( "add item" );
@@ -133,7 +137,7 @@
void LCDCombo::addSeparator()
{
- items.append( QString("--sep--") );
+ items.append( SEPARATOR );
}
@@ -154,8 +158,19 @@
pop->popup( display->mapToGlobal( QPoint( 1, display->height() + 2 ) ) );
}
+void LCDCombo::wheelEvent( QWheelEvent * ev )
+{
+ ev->ignore();
+ const int n = items.size();
+ const int d = ( ev->delta() > 0 ) ? -1: 1;
+ active = ( n + active + d ) % n;
+ if ( items.at( active ) == SEPARATOR )
+ active = ( n + active + d ) % n;
+ set_text( items.at( active ) );
+}
+
void LCDCombo::set_text( const QString &text)
{
if (display->getText() == text) {
@@ -163,6 +178,10 @@
}
//INFOLOG( text );
display->setText( text );
+ for ( int i = 0; i < items.size(); i++ ) {
+ if ( items.at(i) == text )
+ active = i;
+ }
emit valueChanged( text );
}
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel