62 Win32Window::Win32Window() : |
69 Win32Window::Win32Window() : |
63 QWidget( 0 ), |
70 QWidget( 0 ), |
64 mOrientationButton( new QPushButton( "Change Orientation", this ) ), |
71 mOrientationButton( new QPushButton( "Change Orientation", this ) ), |
65 mVolUpButton( new QPushButton( "Volume Up", this ) ), |
72 mVolUpButton( new QPushButton( "Volume Up", this ) ), |
66 mVolDownButton( new QPushButton( "Volume Down", this ) ), |
73 mVolDownButton( new QPushButton( "Volume Down", this ) ), |
67 mHeadsetButton( new QPushButton( KBtnDisconnectHeadset, this ) ), |
|
68 mAddSongButton( new QPushButton( "Add Song", this ) ), |
74 mAddSongButton( new QPushButton( "Add Song", this ) ), |
69 mClearSongButton( new QPushButton( "Clear Song", this ) ), |
75 mClearSongButton( new QPushButton( "Clear Song", this ) ), |
|
76 mHeadsetButton( new QPushButton( KBtnDisconnectHeadset, this ) ), |
|
77 mHeadsetConnected( true ), |
70 mOfflineButton( new QPushButton( KBtnGoOffline, this ) ), |
78 mOfflineButton( new QPushButton( KBtnGoOffline, this ) ), |
71 mUpdateButton( new QPushButton( "Update", this ) ), |
79 mThemeBox( new QComboBox( this ) ), |
72 mHeadsetConnected( true ), |
80 mToolbarLayout( 0 ), |
73 mVolume( 5 ), |
81 mVolume( 5 ), |
74 mRadioWindow( 0 ), |
82 mRadioWindow( 0 ), |
|
83 mOrientation( Qt::Vertical ), |
75 mSongIndex( 0 ) |
84 mSongIndex( 0 ) |
76 { |
85 { |
|
86 mThemeBox->setEditable( false ); |
|
87 initThemes(); |
|
88 |
77 connectAndTest( mOrientationButton, SIGNAL(clicked()), this, SLOT(changeOrientation()) ); |
89 connectAndTest( mOrientationButton, SIGNAL(clicked()), this, SLOT(changeOrientation()) ); |
78 connectAndTest( mVolUpButton, SIGNAL(clicked()), this, SLOT(volumeUp()) ); |
90 connectAndTest( mVolUpButton, SIGNAL(clicked()), this, SLOT(volumeUp()) ); |
79 connectAndTest( mVolDownButton, SIGNAL(clicked()), this, SLOT(volumeDown()) ); |
91 connectAndTest( mVolDownButton, SIGNAL(clicked()), this, SLOT(volumeDown()) ); |
80 connectAndTest( mHeadsetButton, SIGNAL(clicked()), this, SLOT(toggleHeadsetStatus()) ); |
92 connectAndTest( mHeadsetButton, SIGNAL(clicked()), this, SLOT(toggleHeadsetStatus()) ); |
81 connectAndTest( mAddSongButton, SIGNAL(clicked()), this, SLOT(addSong()) ); |
93 connectAndTest( mAddSongButton, SIGNAL(clicked()), this, SLOT(addSong()) ); |
82 connectAndTest( mClearSongButton, SIGNAL(clicked()), this, SLOT(clearSong()) ); |
94 connectAndTest( mClearSongButton, SIGNAL(clicked()), this, SLOT(clearSong()) ); |
83 connectAndTest( mOfflineButton, SIGNAL(clicked()), this, SLOT(toggleOffline()) ); |
95 connectAndTest( mOfflineButton, SIGNAL(clicked()), this, SLOT(toggleOffline()) ); |
84 connectAndTest( mUpdateButton, SIGNAL(clicked()), this, SLOT(updateWindow()) ); |
96 connectAndTest( mThemeBox, SIGNAL(activated(QString)), this, SLOT(changeTheme(QString)) ); |
85 |
97 |
86 QTimer::singleShot( 0, this, SLOT(updateWindowSize()) ); |
98 QTimer::singleShot( 0, this, SLOT(updateWindowSize()) ); |
87 } |
99 } |
88 |
100 |
89 /*! |
101 /*! |
115 mToolbarLayout->addWidget( mVolDownButton, 1, 1 ); |
127 mToolbarLayout->addWidget( mVolDownButton, 1, 1 ); |
116 mToolbarLayout->addWidget( mHeadsetButton, 1, 0 ); |
128 mToolbarLayout->addWidget( mHeadsetButton, 1, 0 ); |
117 mToolbarLayout->addWidget( mAddSongButton, 2, 0 ); |
129 mToolbarLayout->addWidget( mAddSongButton, 2, 0 ); |
118 mToolbarLayout->addWidget( mClearSongButton, 2, 1 ); |
130 mToolbarLayout->addWidget( mClearSongButton, 2, 1 ); |
119 mToolbarLayout->addWidget( mOfflineButton, 3, 0 ); |
131 mToolbarLayout->addWidget( mOfflineButton, 3, 0 ); |
120 mToolbarLayout->addWidget( mUpdateButton, 3, 1 ); |
132 |
|
133 QGridLayout* themeLayout = new QGridLayout( this ); |
|
134 themeLayout->addWidget( new QLabel( "Theme:", this ), 0, 0 ); |
|
135 themeLayout->addWidget( mThemeBox, 0, 1 ); |
|
136 themeLayout->setColumnStretch( 1, 2 ); |
|
137 |
|
138 mToolbarLayout->addLayout( themeLayout, 3, 1 ); |
|
139 mToolbarLayout->setColumnStretch( 0, 1 ); |
|
140 mToolbarLayout->setColumnStretch( 1, 1 ); |
121 |
141 |
122 layout->addItem( mToolbarLayout ); |
142 layout->addItem( mToolbarLayout ); |
123 layout->addWidget( radioWindow ); |
143 layout->addWidget( radioWindow ); |
124 |
144 |
125 setLayout( layout ); |
145 setLayout( layout ); |
242 } |
262 } |
243 |
263 |
244 /*! |
264 /*! |
245 * Private slot |
265 * Private slot |
246 */ |
266 */ |
247 void Win32Window::updateWindow() |
267 void Win32Window::changeTheme( const QString& theme ) |
248 { |
268 { |
249 update(); |
269 QLocalSocket socket; |
250 } |
270 socket.connectToServer( "hbthemeserver" ); |
|
271 if ( socket.waitForConnected( 3000 ) ) { |
|
272 QByteArray outputByteArray; |
|
273 QDataStream outputDataStream( &outputByteArray, QIODevice::WriteOnly ); |
|
274 outputDataStream << 4; // EThemeSelection from HbThemeServerRequest in hbthemecommon_p.h |
|
275 outputDataStream << theme; |
|
276 socket.write( outputByteArray ); |
|
277 socket.flush(); |
|
278 } |
|
279 } |
|
280 |
|
281 /*! |
|
282 * |
|
283 */ |
|
284 void Win32Window::initThemes() |
|
285 { |
|
286 QStringList themeList; |
|
287 foreach ( const QString& themeRootPath, themeRootPaths() ) { |
|
288 QDir dir( themeRootPath ) ; |
|
289 QStringList list = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name ); |
|
290 |
|
291 if ( list.contains( "themes", Qt::CaseSensitive ) ) { |
|
292 QDir root = themeRootPath; |
|
293 dir.setPath( root.path() + "/themes/icons/" ); |
|
294 QStringList iconthemeslist = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name ); |
|
295 foreach ( QString themefolder, iconthemeslist ) { |
|
296 QDir iconThemePath( root.path() + "/themes/icons/" + themefolder ); |
|
297 if ( iconThemePath.exists( "index.theme" ) ) { |
|
298 QSettings iniSetting( iconThemePath.path() + "/index.theme", QSettings::IniFormat ); |
|
299 iniSetting.beginGroup( "Icon Theme" ); |
|
300 QString hidden = iniSetting.value( "Hidden" ).toString(); |
|
301 QString name = iniSetting.value( "Name" ).toString(); |
|
302 iniSetting.endGroup(); |
|
303 if ( (hidden == "true") || ( hidden == "" ) || ( name != themefolder ) ) { |
|
304 iconthemeslist.removeOne( themefolder ); |
|
305 } |
|
306 } |
|
307 else { |
|
308 iconthemeslist.removeOne( themefolder ); |
|
309 } |
|
310 |
|
311 } |
|
312 |
|
313 themeList.append( iconthemeslist ); |
|
314 } |
|
315 } |
|
316 |
|
317 if ( themeList.count() == 0 ) { |
|
318 themeList.insert( 0, "hbdefault" ); //adding one default entry |
|
319 mThemeBox->setEnabled( false ); |
|
320 } |
|
321 |
|
322 mThemeBox->setModel( new QStringListModel( themeList, mThemeBox ) ); |
|
323 |
|
324 for ( int i = 0; i < themeList.count(); ++i ) { |
|
325 QString theme = themeList.at( i ); |
|
326 if ( theme == HbInstance::instance()->theme()->name() ) { |
|
327 mThemeBox->setCurrentIndex( i ); |
|
328 } |
|
329 } |
|
330 } |
|
331 |
|
332 /*! |
|
333 * |
|
334 */ |
|
335 QStringList Win32Window::themeRootPaths() |
|
336 { |
|
337 QStringList rootDirs; |
|
338 QString envDir = qgetenv( "HB_THEMES_DIR" ); |
|
339 if ( !envDir.isEmpty() ) { |
|
340 rootDirs << envDir; |
|
341 } |
|
342 |
|
343 rootDirs << HB_RESOURCES_DIR; |
|
344 |
|
345 return rootDirs; |
|
346 } |