radioapp/radioapplication/src/testwindow_win32.cpp
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 19 afea38384506
parent 33 11b6825f0862
equal deleted inserted replaced
26:6bcf277166c1 37:451b2e1545b2
    35 #include "radioapplication.h"
    35 #include "radioapplication.h"
    36 #include "radiologger.h"
    36 #include "radiologger.h"
    37 #include "radio_global.h"
    37 #include "radio_global.h"
    38 #include "radioenginewrapper_win32_p.h"
    38 #include "radioenginewrapper_win32_p.h"
    39 
    39 
    40 const int KWindowWidth = 360;
    40 const int WINDOW_WIDTH = 360;
    41 const int KWindowHeight = 640;
    41 const int WINDOW_HEIGHT = 640;
    42 const int KToolbarHeight = 140;
    42 const int TOOLBAR_HEIGHT = 120;
       
    43 const int WINDOW_EXTRA_WIDTH = 5;
    43 
    44 
    44 const QString KBtnDisconnectHeadset = "Disconnect Headset";
    45 const QString KBtnDisconnectHeadset = "Disconnect Headset";
    45 const QString KBtnConnectHeadset = "Connect Headset";
    46 const QString KBtnConnectHeadset = "Connect Headset";
    46 
    47 
    47 const QString KBtnGoOffline = "Go Offline";
    48 const QString KBtnGoOffline = "Go Offline";
    85     mSongIndex( 0 )
    86     mSongIndex( 0 )
    86 {
    87 {
    87     mThemeBox->setEditable( false );
    88     mThemeBox->setEditable( false );
    88     initThemes();    
    89     initThemes();    
    89 
    90 
    90     connectAndTest( mOrientationButton, SIGNAL(clicked()), this, SLOT(changeOrientation()) );
    91     Radio::connect( mOrientationButton, SIGNAL(clicked()), this, SLOT(changeOrientation()) );
    91     connectAndTest( mVolUpButton, SIGNAL(clicked()), this, SLOT(volumeUp()) );
    92     Radio::connect( mVolUpButton, SIGNAL(clicked()), this, SLOT(volumeUp()) );
    92     connectAndTest( mVolDownButton, SIGNAL(clicked()), this, SLOT(volumeDown()) );
    93     Radio::connect( mVolDownButton, SIGNAL(clicked()), this, SLOT(volumeDown()) );
    93     connectAndTest( mHeadsetButton, SIGNAL(clicked()), this, SLOT(toggleHeadsetStatus()) );
    94     Radio::connect( mHeadsetButton, SIGNAL(clicked()), this, SLOT(toggleHeadsetStatus()) );
    94     connectAndTest( mAddSongButton, SIGNAL(clicked()), this, SLOT(addSong()) );
    95     Radio::connect( mAddSongButton, SIGNAL(clicked()), this, SLOT(addSong()) );
    95     connectAndTest( mClearSongButton, SIGNAL(clicked()), this, SLOT(clearSong()) );
    96     Radio::connect( mClearSongButton, SIGNAL(clicked()), this, SLOT(clearSong()) );
    96     connectAndTest( mOfflineButton, SIGNAL(clicked()), this, SLOT(toggleOffline()) );
    97     Radio::connect( mOfflineButton, SIGNAL(clicked()), this, SLOT(toggleOffline()) );
    97     connectAndTest( mThemeBox, SIGNAL(activated(QString)), this, SLOT(changeTheme(QString)) );
    98     Radio::connect( mThemeBox, SIGNAL(activated(QString)), this, SLOT(changeTheme(QString)) );
    98 
    99 
    99     QTimer::singleShot( 0, this, SLOT(updateWindowSize()) );
   100     QTimer::singleShot( 0, this, SLOT(updateWindowSize()) );
   100 }
   101 }
   101 
   102 
   102 /*!
   103 /*!
   184 /*!
   185 /*!
   185  * Private slot
   186  * Private slot
   186  */
   187  */
   187 void Win32Window::volumeUp()
   188 void Win32Window::volumeUp()
   188 {
   189 {
   189     if ( ++mVolume > KMaximumVolumeLevel ) {
   190     if ( ++mVolume > MAXIMUM_VOLUME_LEVEL ) {
   190         mVolume = KMaximumVolumeLevel;
   191         mVolume = MAXIMUM_VOLUME_LEVEL;
   191     }
   192     }
   192     RadioEngineWrapperPrivate::instance()->setVolume( mVolume );
   193     RadioEngineWrapperPrivate::instance()->setVolume( mVolume );
   193 }
   194 }
   194 
   195 
   195 /*!
   196 /*!
   221  * Private slot
   222  * Private slot
   222  */
   223  */
   223 void Win32Window::updateWindowSize()
   224 void Win32Window::updateWindowSize()
   224 {
   225 {
   225     if ( mOrientation == Qt::Horizontal ) {
   226     if ( mOrientation == Qt::Horizontal ) {
   226         resize( KWindowHeight, KWindowWidth + KToolbarHeight );
   227         resize( WINDOW_HEIGHT + WINDOW_EXTRA_WIDTH, WINDOW_WIDTH + TOOLBAR_HEIGHT );
   227     } else {
   228     } else {
   228         resize( KWindowWidth, KWindowHeight + KToolbarHeight );
   229         resize( WINDOW_WIDTH + WINDOW_EXTRA_WIDTH, WINDOW_HEIGHT + TOOLBAR_HEIGHT );
   229     }
   230     }
   230 }
   231 }
   231 
   232 
   232 /*!
   233 /*!
   233  * Private slot
   234  * Private slot
   265 /*!
   266 /*!
   266  * Private slot
   267  * Private slot
   267  */
   268  */
   268 void Win32Window::changeTheme( const QString& theme )
   269 void Win32Window::changeTheme( const QString& theme )
   269 {
   270 {
       
   271     LOG_FORMAT( "Changing to theme %s", GETSTRING( theme ) );
   270     QLocalSocket socket;
   272     QLocalSocket socket;
   271     socket.connectToServer( "hbthemeserver" );
   273     socket.connectToServer( "hbthemeserver" );
   272     if ( socket.waitForConnected( 3000 ) ) {
   274     if ( socket.waitForConnected( 3000 ) ) {
   273         QByteArray outputByteArray;
   275         QByteArray outputByteArray;
   274         QDataStream outputDataStream( &outputByteArray, QIODevice::WriteOnly );
   276         QDataStream outputDataStream( &outputByteArray, QIODevice::WriteOnly );
   339     QString envDir = qgetenv( "HB_THEMES_DIR" );
   341     QString envDir = qgetenv( "HB_THEMES_DIR" );
   340     if ( !envDir.isEmpty() ) {
   342     if ( !envDir.isEmpty() ) {
   341         rootDirs << envDir;
   343         rootDirs << envDir;
   342     }
   344     }
   343 
   345 
   344     rootDirs << HB_RESOURCES_DIR;
   346     QString resourcesDir = HB_RESOURCES_DIR;
       
   347     if ( resourcesDir.isEmpty() ) {
       
   348         resourcesDir = "/hb_dev/src/hbcore/resources";
       
   349     }
       
   350     rootDirs << resourcesDir;
   345 
   351 
   346     return rootDirs;
   352     return rootDirs;
   347 }
   353 }