author | mickeyl <mickeyl> | 2005-01-04 23:03:23 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-04 23:03:23 (UTC) |
commit | 49683b3396a2e93cf49ac1726eafca6e8798be81 (patch) (side-by-side diff) | |
tree | 6aaa08205dbf55a214655c275c11cd7ef8a27bdd | |
parent | b41e4499d41fc92cc1ed4ed487e57d0a002c1a02 (diff) | |
download | opie-49683b3396a2e93cf49ac1726eafca6e8798be81.zip opie-49683b3396a2e93cf49ac1726eafca6e8798be81.tar.gz opie-49683b3396a2e93cf49ac1726eafca6e8798be81.tar.bz2 |
catch up with proper inclusion of OLedBox into libopieui
-rw-r--r-- | core/applets/volumeapplet/config.in | 2 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 7 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.h | 8 | ||||
-rw-r--r-- | core/applets/volumeapplet/volumeapplet.pro | 7 | ||||
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/Opietooth.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/Opietooth.h | 4 |
6 files changed, 17 insertions, 13 deletions
diff --git a/core/applets/volumeapplet/config.in b/core/applets/volumeapplet/config.in index b18cd54..7ab1a27 100644 --- a/core/applets/volumeapplet/config.in +++ b/core/applets/volumeapplet/config.in @@ -1,4 +1,4 @@ config VOLUMEAPPLET boolean "opie-volumeapplet (set volume for microphone and speaker)" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 45c106a..23c847d 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp @@ -1,780 +1,783 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "volume.h" +/* OPIE */ #include <opie2/oledbox.h> #include <opie2/odevice.h> #include <opie2/otaskbarapplet.h> #include <qpe/resource.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> +using namespace Opie::Core; +using namespace Opie::Ui; +/* QT */ #include <qpainter.h> #include <qcheckbox.h> #include <qslider.h> #include <qlayout.h> #include <qvbox.h> #include <qlabel.h> #include <qpushbutton.h> #include <qtimer.h> +/* STD */ #include <stdio.h> -using namespace Opie::Core; - #define RATE_TIMER_INTERVAL 100 // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. /* XPM */ using namespace Opie::Ui; static const char * vol_xpm[] = { "20 20 3 1", " c None", ". c #0000FF", "+ c #000000", " ", " . ", " . . . . ", " . . . . . . ", " . . . . . . . ", " . . ..... . . ", " . ... ..... ... ", " ........... .... ", " ................. ", "++++++++++++++++++++", " .................. ", " . ............. . ", " . ..... ....... ", " . ... ..... . ", " . ... ..... . ", " . ... ..... ", " . . . . . ", " . . . ", " . . . ", " "}; /* XPM */ static const char * mic_xpm[] = { "20 20 21 1", " c None", ". c #000000", "+ c #EEEEEE", "@ c #B4B6B4", "# c #8B8D8B", "$ c #D5D6D5", "% c #E6E6E6", "& c #9C9D9C", "* c #6A696A", "= c #E6E2E6", "- c #F6F2F6", "; c #CDC6CD", "> c #737573", ", c #4A484A", "' c #DEDEDE", ") c #F6EEF6", "! c #414041", "~ c #202020", "{ c #ACAEAC", "] c #838583", "^ c #6A656A", " ", " .... ", " .+@+#. ", " ..$%&%*. ", " .=-.;=>=,. ", " .'+).&+!+. ", " .+;+;.~+~. ", " ..%{%,.... ", " ..&=>=~.. ", " .+..]^,.. ", " .+....... ", " .%... ", " .=... ", " .+... ", " .+... ", " .... ", " .... ", " .. ", " . ", ". "}; static const char * bass_xpm[] = { "20 20 3 1", " c None", ". c #000000", "+ c #0000FF", " ", " ", " ", "..... +++ ......", " +++++++ ", " ++ ++ ", "... ++ ... ++ ++ .", " +++ ++ ++ ", " ++++ ++ ", "... ++++ .. ++ .....", " ++ ++ ", " ++ ++ ", "..........++ ++ .", " ++ ", " ++ ", "...... ++ .........", " + ", " ", " ", " "}; static const char * treble_xpm[] = { "20 20 3 1", " c None", ". c #0000FF", "+ c #000000", " .. ", " . .. ", " . .. ", "++++++++ . .. ++++++", " . . ", " ... ", "++++++++ . +++++++", " .. ", " .. . ", "+++ .. ... +++++++", " .. .. .. ", " .. . . .. ", "+++ .. . . + . +++++", " .. . .. ", " .. . .. ", "++++ ...... +++++++", " . ", " .. . ", " .. . ", " .. "}; /* XPM */ static const char * alarm_xpm[] = { "20 20 33 1", " c None", ". c #080602", "+ c #AAA602", "@ c #252002", "# c #434202", "$ c #795602", "% c #C3C20D", "& c #DADAC2", "* c #826002", "= c #740502", "- c #D6D602", "; c #322E02", "> c #826A02", ", c #F1F195", "' c #959215", ") c #423602", "! c #4B0302", "~ c #844315", "{ c #AAAA2A", "] c #E2DE42", "^ c #BA7E04", "/ c #7F7502", "( c #828276", "_ c #FEFE4E", ": c #7D1902", "< c #989656", "[ c #260B02", "} c #F7F7D8", "| c #DCDA5A", "1 c #823102", "2 c #B1AC6B", "3 c #F7F710", "4 c #838204", " ", " ", " 4'4/ ", " /-^= ", " 42{4>4 ", " '2|+*$44 ", " +2&3+$1*44 ", " (%_}_+/$:>/4 ", " 4%_}3+#;>:*4 ", " 4%_}&+#[1$/4 ", " 4%_,2')[~~>4 ", " 4%33'4#@~1>4 ", " 4%3344#[:>/4 ", " 42&_3'4#@>:*44 ", " 42|}}3'4#[;$)$44 ", "444{]]2^~~:!!#.@##/ ", "4444-%*:==!!=...../ ", " /:[.. ", " /@. ", " "}; VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) { m_icon = icon; bool has_wav_alarm = true; bool has_bass = true; bool has_treble = true; switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually case Model_Zaurus_SL5000: has_wav_alarm = false; //poor guys probably feeling left out... break; default: break; } if ( !ODevice::inst()->modelString().contains( "Model_iPAQ" )) { has_bass = false; has_treble = false; } setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); grid-> setSpacing ( 4 ); grid-> setMargin ( 6 ); QVBoxLayout *vbox; QLabel *l; vbox = new QVBoxLayout ( ); vbox-> setSpacing ( 4 ); grid-> addLayout ( vbox, 1, 0 ); upButton = new QPushButton ( this ); upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); upButton-> setPixmap ( Resource::loadPixmap ( "up" )); upButton-> setFocusPolicy ( QWidget::NoFocus ); vbox-> addWidget ( upButton ); downButton = new QPushButton ( this ); downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); downButton-> setPixmap ( Resource::loadPixmap ( "down" )); downButton-> setFocusPolicy ( QWidget::NoFocus ); vbox-> addWidget ( downButton ); volSlider = new QSlider ( this ); volSlider-> setRange ( 0, 100 ); volSlider-> setTickmarks ( QSlider::Both ); volSlider-> setTickInterval ( 20 ); volSlider-> setFocusPolicy ( QWidget::NoFocus ); l = new QLabel ( this ); l-> setPixmap ( QPixmap ( vol_xpm )); grid-> addWidget ( l, 0, 1, AlignCenter ); grid-> addWidget ( volSlider, 1, 1, AlignCenter ); volLed = new OLedBox ( green, this ); volLed-> setFocusPolicy ( QWidget::NoFocus ); volLed-> setFixedSize ( 16, 16 ); grid-> addWidget ( volLed, 2, 1, AlignCenter ); QVBox *basstrebleBox = new QVBox( this ); trebleSlider = new QSlider ( basstrebleBox ); trebleSlider-> setRange ( 0, 100 ); trebleSlider-> setTickmarks ( QSlider::Both ); trebleSlider-> setTickInterval ( 20 ); trebleSlider->setMaximumHeight( 40 ); trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); bassSlider = new QSlider ( basstrebleBox ); bassSlider-> setRange ( 0, 100 ); bassSlider-> setTickmarks ( QSlider::Both ); bassSlider-> setTickInterval ( 20 ); bassSlider->setMaximumHeight( 40 ); bassSlider-> setFocusPolicy ( QWidget::NoFocus ); QLabel *bassLabel = new QLabel ( this ); bassLabel-> setPixmap ( QPixmap ( bass_xpm )); QLabel *trebleLabel = new QLabel( this ); trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); grid->addWidget( trebleLabel, 0, 4, AlignCenter ); grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); if ( !has_bass ) { bassSlider->hide(); bassLabel->hide(); } if ( !has_treble ) { trebleSlider->hide(); trebleLabel->hide(); } micSlider = new QSlider ( this ); micSlider-> setRange ( 0, 100 ); micSlider-> setTickmarks ( QSlider::Both ); micSlider-> setTickInterval ( 20 ); micSlider-> setFocusPolicy ( QWidget::NoFocus ); l = new QLabel ( this ); l-> setPixmap ( QPixmap ( mic_xpm )); grid-> addWidget ( l, 0, 2, AlignCenter ); grid-> addWidget ( micSlider, 1, 2, AlignCenter ); micLed = new OLedBox ( red, this ); micLed-> setFocusPolicy ( QWidget::NoFocus ); micLed-> setFixedSize ( 16, 16 ); grid-> addWidget ( micLed, 2, 2, AlignCenter ); alarmSlider = new QSlider ( this ); alarmSlider-> setRange ( 0, 100 ); alarmSlider-> setTickmarks ( QSlider::Both ); alarmSlider-> setTickInterval ( 20 ); alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); QLabel *alarmLabel = new QLabel ( this ); alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); alarmLed = new OLedBox ( yellow, this ); alarmLed-> setFocusPolicy ( QWidget::NoFocus ); alarmLed-> setFixedSize ( 16, 16 ); grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); if ( !has_wav_alarm ) { alarmSlider-> hide ( ); alarmLabel-> hide ( ); alarmLed-> hide ( ); } grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); vbox = new QVBoxLayout ( ); vbox-> setSpacing ( 4 ); grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); tapBox-> setFocusPolicy ( QWidget::NoFocus ); vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); keyBox-> setFocusPolicy ( QWidget::NoFocus ); vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); alarmBox-> setFocusPolicy ( QWidget::NoFocus ); vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); if ( has_wav_alarm ) { alarmBox-> hide ( ); } vbox-> addStretch ( 100 ); setFixedSize ( sizeHint ( )); setFocusPolicy ( QWidget::NoFocus ); rateTimer = new QTimer( this ); connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); // initialize variables readConfig ( true ); // initialize the config file, in case some entries are missing writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); } bool VolumeControl::volMuted ( ) const { return m_vol_muted; } int VolumeControl::volPercent ( ) const { return m_vol_percent; } void VolumeControl::keyPressEvent ( QKeyEvent *e ) { switch ( e-> key ( )) { case Key_Up: volSlider-> subtractStep ( ); break; case Key_Down: volSlider-> addStep ( ); break; case Key_Space: volLed-> toggle ( ); break; case Key_Escape: hide ( ); break; } } void VolumeControl::buttonChanged ( ) { if ( upButton-> isDown ( ) || downButton->isDown ( )) { rateTimerDone ( ); // Call it one time manually, otherwise it wont get // called at all when a button is pressed for a time // shorter than RATE_TIMER_INTERVAL. rateTimer-> start ( RATE_TIMER_INTERVAL, false ); } else rateTimer-> stop ( ); } void VolumeControl::rateTimerDone ( ) { if ( upButton-> isDown ( )) volSlider-> setValue ( volSlider-> value ( ) - 2 ); else // if ( downButton-> isDown ( )) volSlider-> setValue ( volSlider-> value ( ) + 2 ); } void VolumeControl::show ( bool /*showMic*/ ) { readConfig ( ); QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); int w = sizeHint ( ). width ( ); int x = curPos.x ( ) - ( w / 2 ); if (( x + w ) > QPEApplication::desktop ( )-> width ( )) x = QPEApplication::desktop ( )-> width ( ) - w; move ( x, curPos. y ( ) - sizeHint ( ). height ( )); QFrame::show ( ); } void VolumeControl::readConfig ( bool force ) { Config cfg ( "qpe" ); cfg. setGroup ( "Volume" ); int old_vp = m_vol_percent; int old_mp = m_mic_percent; int old_bass = m_bass_percent; int old_treble = m_treble_percent; bool old_vm = m_vol_muted; bool old_mm = m_mic_muted; bool old_sk = m_snd_key; bool old_st = m_snd_touch; bool old_sa = m_snd_alarm; int old_ap = m_alarm_percent; m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); if ( force || ( m_vol_percent != old_vp )) volSlider-> setValue ( 100 - m_vol_percent ); if ( force || ( m_mic_percent != old_mp )) micSlider-> setValue ( 100 - m_mic_percent ); if ( force || ( m_alarm_percent != old_ap )) alarmSlider-> setValue ( 100 - m_alarm_percent ); if ( force || ( m_bass_percent != old_bass )) bassSlider-> setValue ( 100 - m_bass_percent ); if ( force || ( m_treble_percent != old_treble )) trebleSlider-> setValue ( 100 - m_treble_percent ); if ( force || ( m_vol_muted != old_vm )) volLed-> setOn ( !m_vol_muted ); if ( force || ( m_mic_muted != old_mm )) micLed-> setOn ( !m_mic_muted ); if ( force || ( m_snd_alarm != old_sa )) alarmLed-> setOn ( m_snd_alarm ); if ( force || ( m_snd_key != old_sk )) keyBox-> setChecked ( m_snd_key ); if ( force || ( m_snd_touch != old_st )) tapBox-> setChecked ( m_snd_touch ); if ( force || ( m_snd_alarm != old_sa )) alarmBox-> setChecked ( m_snd_alarm ); } void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) { int prevVol = m_vol_percent; bool prevMute = m_vol_muted; readConfig ( ); // Handle case where muting it toggled if ( m_vol_muted != prevMute ) m_icon-> redraw ( true ); else if ( prevVol != m_vol_percent ) // Avoid over repainting m_icon-> redraw ( false ); } void VolumeControl::micChanged ( bool nowMuted ) { if ( !nowMuted ) readConfig ( ); m_mic_muted = nowMuted; } void VolumeControl::screenTapToggled ( bool b ) { m_snd_touch = b; writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); } void VolumeControl::keyClickToggled ( bool b ) { m_snd_key = b; writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); } void VolumeControl::alarmSoundToggled ( bool b ) { m_snd_alarm = b; writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); } void VolumeControl::volMuteToggled ( bool b ) { m_vol_muted = !b; m_icon-> redraw ( true ); writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); } void VolumeControl::micMuteToggled ( bool b ) { m_mic_muted = !b; writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); } void VolumeControl::volMoved ( int percent ) { m_vol_percent = 100 - percent; // clamp volume percent to be between 0 and 100 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); // repaint just the little volume rectangle m_icon-> redraw ( false ); writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); } void VolumeControl::micMoved ( int percent ) { m_mic_percent = 100 - percent; // clamp volume percent to be between 0 and 100 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); } void VolumeControl::alarmMoved ( int percent ) { m_alarm_percent = 100 - percent; // clamp volume percent to be between 0 and 100 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); } void VolumeControl::bassMoved ( int percent ) { m_bass_percent = 100 - percent; // clamp bass percent to be between 0 and 100 m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); } void VolumeControl::trebleMoved ( int percent ) { m_treble_percent = 100 - percent; // clamp treble percent to be between 0 and 100 m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); } void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) { Config cfg ( "qpe" ); cfg. setGroup ( "Volume" ); cfg. writeEntry ( entry, val ); // cfg. write ( ); #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) switch ( upd ) { case UPD_Vol: { QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; break; } case UPD_Mic: { QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; break; } case UPD_Bass: { QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; break; } case UPD_Treble: { QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; break; } case UPD_None: break; } #endif } //=========================================================================== VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { setFixedWidth ( AppLnk::smallIconSize() ); setFixedHeight ( AppLnk::smallIconSize()+4 ); m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); } VolumeApplet::~VolumeApplet() { delete m_pixmap; } int VolumeApplet::position() { return 6; } void VolumeApplet::mousePressEvent ( QMouseEvent * ) { if ( m_dialog-> isVisible ( )) m_dialog-> hide ( ); else m_dialog-> show ( true ); } void VolumeApplet::redraw ( bool all ) { if ( all ) repaint ( true ); else repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); } void VolumeApplet::paintEvent ( QPaintEvent * ) { QPainter p ( this ); p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); p. setPen ( darkGray ); p. drawRect ( 1, height() - 4, width() - 2, 4 ); int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); if ( m_dialog-> volMuted ( )) { p. setPen ( red ); p. drawLine ( 1, 2, width() - 2, height() - 5 ); p. drawLine ( 1, 3, width() - 2, height() - 4 ); p. drawLine ( width() - 2, 2, 1, height() - 5 ); p. drawLine ( width() - 2, 3, 1, height() - 4 ); } } EXPORT_OPIE_APPLET_v1( VolumeApplet ) diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h index 454a688..958395f 100644 --- a/core/applets/volumeapplet/volume.h +++ b/core/applets/volumeapplet/volume.h @@ -1,135 +1,135 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef __VOLUME_APPLET_H__ #define __VOLUME_APPLET_H__ #include <qframe.h> class QPixmap; class QTimer; class QSlider; class QCheckBox; class QButton; -class OLedBox; +namespace Opie { namespace Ui { class OLedBox; }; }; class VolumeApplet; class VolumeControl : public QFrame { Q_OBJECT public: VolumeControl ( VolumeApplet *icon, bool showMic = false, QWidget *parent=0, const char *name=0 ); bool volMuted ( ) const; int volPercent ( ) const; virtual void show ( bool showmic ); protected: virtual void keyPressEvent ( QKeyEvent * e ); protected slots: void volumeChanged ( bool muted ); void micChanged ( bool muted ); private slots: void volMoved ( int percent ); void micMoved ( int percent ); void alarmMoved ( int percent ); void bassMoved( int percent ); void trebleMoved( int percent ); void volMuteToggled ( bool ); void micMuteToggled ( bool ); void alarmSoundToggled ( bool ); void keyClickToggled ( bool ); void screenTapToggled ( bool ); void buttonChanged ( ); void rateTimerDone ( ); private: void readConfig ( bool force = false ); enum eUpdate { UPD_None, UPD_Vol, UPD_Mic, UPD_Bass, UPD_Treble }; void writeConfigEntry ( const char *entry, int val, eUpdate upd ); private: QSlider *volSlider; QSlider *bassSlider; QSlider *trebleSlider; QSlider *micSlider; QSlider *alarmSlider; - OLedBox *volLed; - OLedBox *micLed; - OLedBox *alarmLed; + Opie::Ui::OLedBox *volLed; + Opie::Ui::OLedBox *micLed; + Opie::Ui::OLedBox *alarmLed; QCheckBox *alarmBox; QCheckBox *tapBox; QCheckBox *keyBox; QPushButton *upButton; QPushButton *downButton; QTimer *rateTimer; int m_vol_percent; int m_mic_percent; int m_alarm_percent; int m_bass_percent; int m_treble_percent; bool m_vol_muted; bool m_mic_muted; bool m_snd_alarm; bool m_snd_touch; bool m_snd_key; VolumeApplet *m_icon; }; class VolumeApplet : public QWidget { Q_OBJECT public: VolumeApplet ( QWidget *parent = 0, const char *name=0 ); ~VolumeApplet ( ); static int position(); void redraw ( bool all = true ); protected: virtual void mousePressEvent ( QMouseEvent * ); virtual void paintEvent ( QPaintEvent* ); private: QPixmap * m_pixmap; VolumeControl *m_dialog; }; #endif // __VOLUME_APPLET_H__ diff --git a/core/applets/volumeapplet/volumeapplet.pro b/core/applets/volumeapplet/volumeapplet.pro index e118dbd..3067a0f 100644 --- a/core/applets/volumeapplet/volumeapplet.pro +++ b/core/applets/volumeapplet/volumeapplet.pro @@ -1,14 +1,13 @@ TEMPLATE = lib CONFIG += qt plugin warn_on -HEADERS = volume.h oledbox.h -#SOURCES = volume.cpp oledbox.cpp +HEADERS = volume.h SOURCES = volume.cpp TARGET = volumeapplet DESTDIR = $(OPIEDIR)/plugins/applets -INCLUDEPATH += $(OPIEDIR)/include +INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += -LIBS += -lqpe -lopiecore2 +LIBS += -lqpe -lopiecore2 -lopieui2 VERSION = 1.0.0 include( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp index 8d71f32..8ea3a48 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp @@ -1,1003 +1,1005 @@ #include <opie2/odebug.h> #include <opie2/oledbox.h> +using namespace Opie::Core; +using namespace Opie::Ui; #include <qpe/resource.h> #include <qcheckbox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qprogressbar.h> #include <qheader.h> #include <qmessagebox.h> #include <qapplication.h> #include <qlistbox.h> #include <qdialog.h> #include <qlayout.h> #include <qcombobox.h> #include <qlabel.h> #include <qlistview.h> #include <qpushbutton.h> #include <Opietooth.h> #include <OTDriver.h> #include <OTPeer.h> #include <OTGateway.h> #include <OTSDPAttribute.h> #include <OTSDPService.h> #include <OTInquiry.h> using namespace Opietooth2; namespace Opietooth2 { class PeerLVI : public QListViewItem { public : PeerLVI( OTPeer * P, QListView * it ) : QListViewItem (it) { Peer = P; } ~PeerLVI( void ) { } inline OTPeer * peer( void ) { return Peer; } private : OTPeer * Peer; }; class ChannelLVI : public QListViewItem { public : ChannelLVI( int Ch, QListViewItem * it ) : QListViewItem (it) { Channel = Ch; } ~ChannelLVI( void ) { } inline int channel( void ) { return Channel; } private : int Channel; }; class DriverLVI : public QListViewItem { public : DriverLVI( OTDriver * P, QListView * it ) : QListViewItem (it) { Driver = P; } ~DriverLVI( void ) { } inline OTDriver * driver( void ) { return Driver; } private : OTDriver * Driver; }; class LinkKeyLVI : public QListViewItem { public : LinkKeyLVI( int Ch, QListView * it ) : QListViewItem (it) { LinkKey = Ch; } ~LinkKeyLVI( void ) { } inline int index( void ) { return LinkKey; } private : int LinkKey; }; }; // // // // // OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : OTPairingGUI( parent ) { OT = OTGateway::getOTGateway(); Icons = (_IC ) ? _IC : new OTIcons(); MyIcons = (_IC == 0 ); // unpairing can only be done if bluetooth is disabled Unpair_But->setEnabled( ! OT->isEnabled() ); if( ! OT->isEnabled() ) { Unpair_LBL->hide(); } else { Unpair_LBL->show(); } // open linkkey file and load pairs LinkKeyArray Keys = OT->getLinkKeys(); LinkKeyLVI * it; OTPeer * P; OTDriver * D; for( unsigned int i = 0 ; i < Keys.count(); i ++ ) { it = new LinkKeyLVI( i, Pairs_LV ); P = 0; D = OT->findDriver( Keys[i].from() ); if( D ) { it->setText( 0, D->devname() ); // we are source P = OT->findPeer( Keys[i].to() ); if( P ) { // put name it->setText( 1, P->name() ); } else { // unknown it->setText( 1, Keys[i].to().toString() ); } // and put address as sub QListViewItem * Sub = new QListViewItem( it ); Sub->setText( 0, D->address().toString() ); Sub->setText( 1, Keys[i].to().toString() ); } else { // perhaps we are destination D = OT->findDriver( Keys[i].to() ); if( D ) { it->setText( 1, D->devname() ); // we are source P = OT->findPeer( Keys[i].from() ); if( P ) { // put name it->setText( 0, P->name() ); } else { // unknown it->setText( 0, Keys[i].from().toString() ); } // and put address as sub QListViewItem * Sub = new QListViewItem( it ); Sub->setText( 0, Keys[i].from().toString() ); Sub->setText( 1, D->address().toString() ); } else { // nor source nor destination -> unknown it->setText( 0, Keys[i].from().toString() ); it->setText( 1, Keys[i].to().toString() ); } } } } OTPairing::~OTPairing() { if( MyIcons ) delete Icons; OTGateway::releaseOTGateway(); } void OTPairing::SLOT_Unpair( ) { // find selected pair QListViewItem * it = Pairs_LV->firstChild(); while( it ) { if( it->isSelected() ) { // confirm ? if( QMessageBox::warning(0, tr("Break pairing"), tr("Sure ?"), tr("Yes, break"), tr("No, don't break") ) == 0 ) { LinkKeyLVI * KPIt = (LinkKeyLVI *)it; // break OT->removeLinkKey( KPIt->index() ); delete KPIt; } return; } it= it->nextSibling(); } } // // // // // OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : OTScanGUI( parent ), Filter() { OT = OTGateway::getOTGateway(); Icons = (_IC ) ? _IC : new OTIcons(); MyIcons = (_IC == 0 ); DetectedPeers_LV->header()->hide(); Current = 0; SelectedPeer = 0; SelectedChannel = 0; StrengthTimer = new QTimer( this ); connect( StrengthTimer, SIGNAL( timeout()), this, SLOT( SLOT_UpdateStrength()) ); connect( OT, SIGNAL( detectedPeer( OTPeer *, bool )), this, SLOT( SLOT_NewPeer( OTPeer *, bool )) ); connect( OT, SIGNAL( finishedDetecting()), this, SLOT( SLOT_FinishedDetecting()) ); // populate with peers we already know about const PeerVector & P = OT->peers(); for( unsigned int i = 0; i < P.count(); i ++ ) { SLOT_NewPeer( P[i], TRUE ); } // populate State fram { QHBoxLayout * H =new QHBoxLayout( State_Frm ); Paired_Led = new OLedBox( green, State_Frm ); QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); H->addWidget( Paired_Led ); H->addWidget( L1 ); H->addStretch( 1 ); } } OTScan::~OTScan() { if( MyIcons ) delete Icons; OTGateway::releaseOTGateway(); // send all peers that we do not care about states QListViewItem * Lit = DetectedPeers_LV->firstChild(); while( Lit ) { ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); Lit = Lit->nextSibling(); } } // static scan dialog function int OTScan::getDevice( OTPeer *& Peer, int & Channel, OTGateway * OT, const UUIDVector & Filter, QWidget* Parent ) { bool IsUp = 0; unsigned int i; // check if bluetooth is up OTDriverList & DL = OT->getDriverList(); for( i = 0; i < DL.count(); i ++ ) { if( DL[i]->isUp() ) { // one device that is up found IsUp = 1; break; } } // use this driver OT->setScanWith( OT->driver(i) ); // create dialog QDialog * Dlg = new QDialog( Parent, 0, TRUE ); QVBoxLayout * V = new QVBoxLayout( Dlg ); OTScan * Scn = new OTScan( Dlg ); connect( Scn, SIGNAL( selected() ), Dlg, SLOT( accept() ) ); if( Filter ) { Scn->setScanFilter( Filter ); } V->addWidget( Scn ); Dlg->setCaption( tr("Scan Neighbourhood" ) ); Dlg->showMaximized(); int rv = Dlg->exec(); if( rv == QDialog::Accepted ) { // get peer Peer = Scn->selectedPeer(); if( Peer == 0 ) { // no peer selected rv = QDialog::Rejected; } else { Channel = Scn->selectedChannel(); } } delete Dlg; return rv; } void OTScan::setScanFilter( const UUIDVector & V ) { Filter = V; } void OTScan::resetScanFilter( void ) { Filter.truncate(0); } void OTScan::SLOT_DoScan( bool DoIt ) { if( DoIt ) { OT->scanNeighbourhood(); } else { OT->stopScanOfNeighbourhood(); } scanMode( DoIt ); } // double clicked on a device void OTScan::SLOT_Selected( QListViewItem * it ) { if( ! it ) return; if( Filter.count() > 0 ) { // filter on service if( it->depth() == 0 ) { // select a service and not a device return; } // store result SelectedPeer = ((PeerLVI *)it->parent())->peer(); SelectedChannel = ((ChannelLVI *)it)->channel(); } else { // click on device if( it->depth() != 0 ) { return; } SelectedPeer = ((PeerLVI *)it)->peer(); SelectedChannel = 0; } owarn << "Selected " << SelectedPeer->address().toString() << " Channel " << SelectedChannel << oendl; emit selected(); } void OTScan::SLOT_FinishedDetecting( ) { scanMode( false ); } void OTScan::SLOT_CleanupOld( ) { // iterate over all peers and find those that // are down and have no pairing info OTPeer * TheP; const LinkKeyArray & Keys = OT->getLinkKeys(); QListViewItem * Lit = DetectedPeers_LV->firstChild(); while( Lit ) { TheP = ((PeerLVI *)Lit)->peer(); if( TheP->state() == OTPeer::Peer_Down ) { unsigned int k; // what about linkkeys ? for( k = 0; k < Keys.count(); k ++ ) { if( TheP->address() == Keys[k].to() || TheP->address() == Keys[k].from() ) { // part of linkkey owarn << "LINKKEY " << TheP->address().toString() << oendl; break; } } if( k == Keys.count() ) { owarn << "RM LINKKEY " << TheP->address().toString() << oendl; // not found -> remember to remove this peer QListViewItem * Nit; OT->removePeer( TheP ); Nit = Lit->nextSibling(); delete Lit; Lit = Nit; continue; } } else { owarn << "NODOWN " << TheP->address().toString() << oendl; } Lit = Lit->nextSibling(); } } void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ PeerLVI * it = 0; if( IsNew ) { it = new PeerLVI( P, DetectedPeers_LV ); } else { // find peer in table QListViewItem * Lit = DetectedPeers_LV->firstChild(); while( Lit ) { if( ((PeerLVI *)Lit)->peer() == P ) { // this item it = (PeerLVI *)Lit; break; } Lit = Lit->nextSibling(); } if( ! it ) { owarn << "Should not occur" << oendl; return; } } // update/show info it->setText( 0, P->name() ); it->setPixmap(0, Icons->deviceIcon( OT->deviceTypeToName( P->deviceClass() ) ) ); // tell peer to report its state async connect( P, SIGNAL( peerStateReport( OTPeer *)), this, SLOT( SLOT_PeerState( OTPeer *)) ); if( IsNew ) { // find state refreshState( (PeerLVI *)it, 1 ); } else { // update staet SLOT_PeerState( P ); } } void OTScan::SLOT_PeerState( OTPeer * P ) { PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild(); while( it ) { if( it->peer() == P ) { break; } it = (PeerLVI * )it->nextSibling(); } if( ! it ) return; switch( P->state() ) { case OTPeer::Peer_Unknown : case OTPeer::Peer_Down : it->setPixmap( 1, 0 ); break; case OTPeer::Peer_Up : it->setPixmap( 1, Icons->loadPixmap( ( P->connectedTo() ) ? "connected" : "notconnected" ) ); if( it == Current && ! StrengthTimer->isActive() ) { // start showing strength StrengthTimer->start( 1000, FALSE ); SLOT_UpdateStrength(); } break; } } void OTScan::SLOT_RefreshState( void ) { QListViewItem * it = DetectedPeers_LV->firstChild(); while( it ) { if( it->isSelected() ) { break; } it = it->nextSibling(); } if( ! it ) return; refreshState( (PeerLVI *)it, 1 ); } void OTScan::refreshState( PeerLVI * it, bool Force ) { it->setPixmap( 1, Icons->loadPixmap( "find" ) ); it->peer()->findOutState( 30, Force ); } void OTScan::SLOT_Show( QListViewItem * it ) { if( ! it || it->depth() > 0 ) return; QString S; Current = (PeerLVI *)it; Strength_PB->setProgress( 0 ); // reset Address_LBL->setText( Current->peer()->address().toString() ); Peer_GB->setTitle( Current->peer()->name() ); const LinkKeyArray & Keys = OT->getLinkKeys(); Paired_Led->setOn( FALSE ); for( unsigned int i = 0; i < Keys.count(); i ++ ) { if( Current->peer()->address() == Keys[i].to() ) { Paired_Led->setOn( TRUE ); break; } } if( Current->peer()->state() == OTPeer::Peer_Up ) { RefreshServices_But->setEnabled( TRUE ); StrengthTimer->start( 1000, FALSE ); SLOT_UpdateStrength(); } else { RefreshServices_But->setEnabled( FALSE ); } } void OTScan::SLOT_UpdateStrength( void ) { OTDriver * D = Current->peer()->connectedTo(); if( D ) { long Q = D->getLinkQuality( Current->peer()->address() ); Strength_PB->setProgress( Q ); if( ! Q ) { // no quality Strength_PB->setEnabled( TRUE ); StrengthTimer->stop(); } } else { Strength_PB->setEnabled( FALSE ); Strength_PB->setProgress( 0 ); // no point in continuing StrengthTimer->stop(); } } void OTScan::SLOT_RefreshServices( void ) { QListViewItem * it = DetectedPeers_LV->firstChild(); while( it ) { if( it->isSelected() ) { break; } it = it->nextSibling(); } if( ! it ) return; QString S; PeerLVI * PI = (PeerLVI *)it; scanMode( true ); qApp->processEvents(0); ServiceVector & V = PI->peer()->services(); while( PI->firstChild() ) { // remove children delete PI->firstChild(); } for( unsigned int i = 0 ; i < V.count(); i ++ ) { QString S; S = V[i]->name(); if( S.isEmpty() ) { continue; } { QListViewItem * SIt; UUIDVector UIDV; QPixmap Pm; bool Done = 0; bool R; short ID; SIt = 0; UIDV = V[i]->classIDList(); // first all UUID ! 1200 12ff (Genericprofiles) for( unsigned int j = 0; j < UIDV.count(); j ++ ) { if( Filter.count() ) { bool FilterOut = 1; // filter out if not in list for( unsigned int ff = 0; ff < Filter.count(); ff ++ ) { if( UIDV[j] == Filter[ff] ) { FilterOut = 0; break; } } if( FilterOut ) { // not in filter list continue; } } // else show ID = UIDV[j].toShort(); if( ID < 0x1200 || ID > 0x12ff ) { // use this profile if( R ) { unsigned int ch; bool has; has = V[i]->rfcommChannel( ch ); SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); SIt->setText(0, V[i]->name() ); Pm = Icons->serviceIcon( ID, R ); SIt->setPixmap(0, Pm ); Done = 1; break; } } } if( ! Done ) { // check other range too for( unsigned int j = 0; j < UIDV.count(); j ++ ) { if( Filter.count() ) { bool FilterOut = 1; // filter out if not in list for( unsigned int ff = 0; ff < Filter.count(); ff ++ ) { if( UIDV[j] == Filter[ff] ) { FilterOut = 0; break; } } if( FilterOut ) { // not in filter list continue; } } // else show ID = UIDV[j].toShort(); if( ID >= 0x1200 && ID <= 0x12ff ) { // use this profile unsigned int ch; bool has; has = V[i]->rfcommChannel( ch ); SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); SIt->setText(0, V[i]->name() ); Pm = Icons->serviceIcon( ID, R ); SIt->setPixmap(0, Pm ); break; } } } } } scanMode( false ); } void OTScan::scanMode( bool M ) { // avoid infinite loop because it triggers DoScan Detect_But->blockSignals( TRUE ); Detect_But->setOn( M ); Detect_But->setText( (M) ? tr("Scanning") : tr("Scan") ); Detect_But->blockSignals( FALSE ); } // // // // // OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : OTManageGUI( parent ) { OT = OTGateway::getOTGateway(); Icons = (_IC ) ? _IC : new OTIcons(); MyIcons = (_IC == 0 ); AllDrivers_LV->setSorting(-1); connect( OT, SIGNAL( driverListChanged() ), this, SLOT( SLOT_DriverListChanged() ) ); connect( OT, SIGNAL( stateChange( OTDriver *, bool ) ), this, SLOT( SLOT_StateChange( OTDriver *, bool ) ) ); SLOT_DriverListChanged(); AllDrivers_LV->header()->hide(); } OTManage::~OTManage() { if( MyIcons ) delete Icons; OTGateway::releaseOTGateway(); } void OTManage::SLOT_ShowDriver( QListViewItem * It ) { if( It == 0 || It->depth() > 0 ) // not toplevel return; DriverLVI * it = (DriverLVI *) It; DriverIsUp_CB->setChecked( it->driver()->isUp() ); } void OTManage::SLOT_UpDriver( bool Up ) { QListViewItem * it = AllDrivers_LV->firstChild(); while( it ) { if( it->isSelected() ) { OTDriver * D = ((DriverLVI *)it)->driver(); owarn << "UP driver " << D->devname() << oendl; // this D->setUp( Up ); return; } it = it->nextSibling(); } } void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { QListViewItem * it = AllDrivers_LV->firstChild(); while( it ) { if( ((DriverLVI *)it)->driver() == D ) { it->setPixmap( 0, Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) ); return; } it = it->nextSibling(); } } void OTManage::SLOT_DriverListChanged( ) { DriverLVI * It; QListViewItem * Sub; QListViewItem * First = 0; OTDriver* D; OTDriverList & DL = OT->getDriverList(); AllDrivers_LV->clear(); for( unsigned int i = 0; i < DL.count(); i ++ ) { D = DL[i]; It = new DriverLVI( D, AllDrivers_LV ); if( ! First ) First = It; It->setText( 0, D->devname() ); It->setPixmap( 0, Icons->loadPixmap( (D->isUp()) ? "bluezon" : "bluezoff" ) ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Name" ) ); Sub->setText( 1, D->name() ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Address" ) ); Sub->setText( 1, D->address().toString() ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Revision" ) ); Sub->setText( 1, D->revision() ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Manufacturer" ) ); Sub->setText( 1, D->manufacturer() ); QString Service, Device; D->getClass( Service, Device ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Service classes" ) ); Sub->setText( 1, Service ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Device class" ) ); Sub->setText( 1, Device ); } if( DL.count() ) { AllDrivers_LV->setCurrentItem( First ); DriverIsUp_CB->setEnabled( TRUE ); } else { DriverIsUp_CB->setChecked( FALSE ); DriverIsUp_CB->setEnabled( FALSE ); } } void OTManage::SLOT_SetRefreshTimer( int v ) { OT->setRefreshTimer( v * 1000 ); } // // // // // OTMain::OTMain( QWidget * parent ) : OTMainGUI( parent ) { Icons = new OTIcons(); OT = OTGateway::getOTGateway(); connect( OT, SIGNAL( deviceEnabled( bool ) ), this, SLOT( SLOT_DeviceIsEnabled( bool ) ) ); connect( OT, SIGNAL( driverListChanged() ), this, SLOT( SLOT_DriverListChanged() ) ); connect( OT, SIGNAL( stateChange( OTDriver *, bool ) ), this, SLOT( SLOT_StateChange( OTDriver *, bool ) ) ); if( ! OT->needsEnabling() ) { MustBeEnabled_CB->hide(); } else { // detect current state MustBeEnabled_CB->setChecked( OT->isEnabled() ); } SLOT_DriverListChanged(); } OTMain::~OTMain() { OTGateway::releaseOTGateway(); delete Icons; } void OTMain::SLOT_DriverListChanged() { OTDriver * D; OTDriverList & DL = OT->getDriverList(); DeviceList_CB->clear(); for( unsigned int i = 0; i < DL.count(); i ++ ) { D = DL[i]; DeviceList_CB->insertItem( Icons->loadPixmap( (D->isUp()) ? "bluezon" : "bluezoff" ), D->devname() ); if( D == OT->scanWith() ) { DeviceList_CB->setCurrentItem( i ); } } Scan_But->setEnabled( OT->getDriverList().count() > 0 ); DeviceList_CB->setEnabled( OT->getDriverList().count() > 0 ); } void OTMain::SLOT_EnableBluetooth( bool Up ) { OT->SLOT_SetEnabled( Up ); } void OTMain::SLOT_DeviceIsEnabled( bool Up ) { MustBeEnabled_CB->blockSignals( TRUE ); MustBeEnabled_CB->setChecked( Up ); MustBeEnabled_CB->blockSignals( FALSE ); } void OTMain::SLOT_Manage( void ) { QDialog * Dlg = new QDialog( this, 0, TRUE ); QVBoxLayout * V = new QVBoxLayout( Dlg ); OTManage * Mng = new OTManage( Dlg, Icons ); V->addWidget( Mng ); Dlg->setCaption( tr("Manage local devices" ) ); Dlg->showMaximized(); Dlg->exec(); delete Dlg; } void OTMain::SLOT_Scan( void ) { OTDriverList & DL = OT->getDriverList(); for( unsigned int i = 0; i < DL.count(); i ++ ) { if( DL[i]->isUp() && DL[i]->devname() == DeviceList_CB->currentText() ) { QDialog * Dlg = new QDialog( this, 0, TRUE ); QVBoxLayout * V = new QVBoxLayout( Dlg ); OTScan * Scn = new OTScan( Dlg, Icons ); OT->setScanWith( OT->driver(i) ); V->addWidget( Scn ); Dlg->setCaption( tr("Scan Neighbourhood" ) ); Dlg->showMaximized(); Dlg->exec(); delete Dlg; return; } } } void OTMain::SLOT_StateChange( OTDriver * D, bool Up ) { for( int i = 0; i < DeviceList_CB->count(); i ++ ) { if( DeviceList_CB->text(i) == D->devname() ) { DeviceList_CB->changeItem( Icons->loadPixmap( (Up) ? "bluezon" : "bluezoff" ), D->devname(), i ); return; } } } void OTMain::SLOT_Pairing( void ) { QDialog * Dlg = new QDialog( this, 0, TRUE ); QVBoxLayout * V = new QVBoxLayout( Dlg ); OTPairing * Pair = new OTPairing( Dlg, Icons ); V->addWidget( Pair ); Dlg->showMaximized(); Dlg->setCaption( tr("Manage pairing" ) ); Dlg->exec(); delete Dlg; } diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.h b/noncore/settings/networksettings2/opietooth2/Opietooth.h index 9e53fcb..16a22d6 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.h +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.h @@ -1,194 +1,194 @@ #ifndef OPIETOOTH_H #define OPIETOOTH_H #include <OTIcons.h> #include <OTPairingGUI.h> -class OLedBox; +namespace Opie { namespace Ui { class OLedBox; }; }; namespace Opietooth2 { class OTGateway; class OTDriver; class OTInquiry; class OTPeer; class PeerLVI; class OTPairing : public OTPairingGUI { Q_OBJECT public : OTPairing( QWidget * parent, OTIcons * _Ic = 0 ); ~OTPairing(); private slots : void SLOT_Unpair( void ); signals : protected : private : bool MyIcons; OTIcons * Icons; OTGateway * OT; }; }; #include <OTScanGUI.h> namespace Opietooth2 { class OTGateway; class OTDriver; class OTInquiry; class OTPeer; class OTScan : public OTScanGUI { Q_OBJECT public : OTScan( QWidget * parent, OTIcons * _Ic = 0 ); ~OTScan(); // static function to return a device and a channel static int getDevice( OTPeer *& Peer, int & Channel, OTGateway * OT, const UUIDVector & Filter = 0, QWidget* Parent = 0); // show only services that match any of the filter void setScanFilter( const UUIDVector & Filter ); void resetScanFilter( void ); inline OTPeer * selectedPeer( void ) { return SelectedPeer; } inline int selectedChannel( void ) { return SelectedChannel; } public slots : private slots : void SLOT_DoScan( bool ); void SLOT_NewPeer( OTPeer *, bool ); void SLOT_FinishedDetecting(); void SLOT_Show( QListViewItem *); void SLOT_RefreshServices( void ); void SLOT_RefreshState( void ); void SLOT_CleanupOld( void ); void SLOT_UpdateStrength( void ); void SLOT_PeerState( OTPeer * ); void SLOT_Selected( QListViewItem * ); signals : void selected( void ); protected : private : void refreshState( PeerLVI *, bool ); void scanMode( bool ); // load scanned devices bool MyIcons; OTIcons * Icons; OTGateway * OT; OTInquiry * Scanning; UUIDVector Filter; - OLedBox * Paired_Led; + Opie::Ui::OLedBox * Paired_Led; QTimer * StrengthTimer; PeerLVI * Current; OTPeer * SelectedPeer; int SelectedChannel; }; }; #include <OTManageGUI.h> namespace Opietooth2 { class OTManage : public OTManageGUI { Q_OBJECT public : OTManage( QWidget * parent, OTIcons * _IC = 0 ); ~OTManage(); public slots : private slots : void SLOT_ShowDriver( QListViewItem * ); void SLOT_UpDriver( bool ); void SLOT_StateChange( OTDriver * , bool ); void SLOT_DriverListChanged(); void SLOT_SetRefreshTimer( int ); signals : protected : private : // load scanned devices bool MyIcons; OTIcons * Icons; OTGateway * OT; OTInquiry * Scanning; }; }; #include <OTMainGUI.h> namespace Opietooth2 { class OTMain : public OTMainGUI { Q_OBJECT public : OTMain( QWidget * parent ); ~OTMain(); public slots : private slots : void SLOT_Pairing( void ); void SLOT_Manage( void ); void SLOT_Scan( void ); void SLOT_EnableBluetooth( bool ); void SLOT_DriverListChanged(); void SLOT_DeviceIsEnabled( bool ); void SLOT_StateChange( OTDriver * , bool ); signals : protected : private : // load scanned devices OTIcons * Icons; OTGateway * OT; }; }; #endif |