60 const char *last_lang_key = "lastlang"; |
60 const char *last_lang_key = "lastlang"; |
61 const char *last_file_count_key = "lastfilecount"; |
61 const char *last_file_count_key = "lastfilecount"; |
62 const char *last_output_dir_key = "lastoutdir"; |
62 const char *last_output_dir_key = "lastoutdir"; |
63 |
63 |
64 HbSplashGenerator::HbSplashGenerator() |
64 HbSplashGenerator::HbSplashGenerator() |
65 : mBusy(false), mForceRegen(false), mMainWindow(0), mFirstRegenerate(true) |
65 : mMainWindowLocked(false), |
|
66 mProcessQueuePending(false), |
|
67 mForceRegen(false), |
|
68 mMainWindow(0), |
|
69 mFirstRegenerate(true) |
66 { |
70 { |
67 #if defined(Q_OS_SYMBIAN) |
71 #if defined(Q_OS_SYMBIAN) |
68 CCoeEnv::Static()->FsSession().CreatePrivatePath(EDriveC); |
72 CCoeEnv::Static()->FsSession().CreatePrivatePath(EDriveC); |
69 QString iniFileName = QString("c:/private/%1/hbsplashgen.ini") |
73 QString iniFileName = QString("c:/private/%1/hbsplashgen.ini") |
70 .arg(QString::number(hbsplash_server_uid3.iUid, 16)); |
74 .arg(QString::number(hbsplash_server_uid3.iUid, 16)); |
71 mSettings = new QSettings(iniFileName, QSettings::IniFormat, this); |
75 mSettings = new QSettings(iniFileName, QSettings::IniFormat, this); |
72 #else |
76 #else |
73 mSettings = new QSettings("Nokia", "HbSplash", this); |
77 mSettings = new QSettings("Nokia", "HbSplash", this); |
74 #endif |
78 #endif |
75 // Effects on decorators (started when they are shown) would ruin |
79 // Effects on decorators (started when they are shown) would ruin |
129 connect(theme, SIGNAL(changeFinished()), SLOT(regenerate())); |
133 connect(theme, SIGNAL(changeFinished()), SLOT(regenerate())); |
130 |
134 |
131 // Watch also the directories containing splashml files. Files may |
135 // Watch also the directories containing splashml files. Files may |
132 // be added/updated at any time. |
136 // be added/updated at any time. |
133 connect(&mFsWatcher, SIGNAL(directoryChanged(QString)), SLOT(onDirectoryChanged(QString))); |
137 connect(&mFsWatcher, SIGNAL(directoryChanged(QString)), SLOT(onDirectoryChanged(QString))); |
134 foreach (const QString &dir, hbsplash_splashml_dirs()) { |
138 foreach(const QString & dir, hbsplash_splashml_dirs()) { |
135 // Check for directory existence before calling addPath() to |
139 // Check for directory existence before calling addPath() to |
136 // avoid printing warnings. |
140 // avoid printing warnings. |
137 if (QDir(dir).exists()) { |
141 if (QDir(dir).exists()) { |
138 mFsWatcher.addPath(dir); |
142 mFsWatcher.addPath(dir); |
139 } |
143 } |
152 QString currentOutputDir = hbsplash_output_dir(); |
156 QString currentOutputDir = hbsplash_output_dir(); |
153 int currentFileCount = updateOutputDirContents(currentOutputDir); |
157 int currentFileCount = updateOutputDirContents(currentOutputDir); |
154 qDebug() << PRE << "last regen:" << lastTheme << lastLang << lastFileCount << lastOutputDir |
158 qDebug() << PRE << "last regen:" << lastTheme << lastLang << lastFileCount << lastOutputDir |
155 << "current:" << currentTheme << currentLang << currentFileCount << currentOutputDir; |
159 << "current:" << currentTheme << currentLang << currentFileCount << currentOutputDir; |
156 if (mForceRegen |
160 if (mForceRegen |
157 || currentTheme != lastTheme |
161 || currentTheme != lastTheme |
158 || currentLang != lastLang |
162 || currentLang != lastLang |
159 || currentFileCount != lastFileCount |
163 || currentFileCount != lastFileCount |
160 || currentOutputDir != lastOutputDir) |
164 || currentOutputDir != lastOutputDir) { |
161 { |
|
162 QMetaObject::invokeMethod(this, "regenerate", Qt::QueuedConnection); |
165 QMetaObject::invokeMethod(this, "regenerate", Qt::QueuedConnection); |
163 } |
166 } |
164 } |
167 } |
165 |
168 |
166 void HbSplashGenerator::uncachedRegenerate() |
169 void HbSplashGenerator::uncachedRegenerate() |
186 // empty view) has not finished when a new app is started then it is |
189 // empty view) has not finished when a new app is started then it is |
187 // better to show no splash screen at all. |
190 // better to show no splash screen at all. |
188 QDir outDir(hbsplash_output_dir()); |
191 QDir outDir(hbsplash_output_dir()); |
189 if (outDir.exists()) { |
192 if (outDir.exists()) { |
190 QStringList names = outDir.entryList(QStringList() << "*", QDir::Files); |
193 QStringList names = outDir.entryList(QStringList() << "*", QDir::Files); |
191 foreach (const QString &name, names) { |
194 foreach(const QString & name, names) { |
192 outDir.remove(name); |
195 outDir.remove(name); |
193 } |
196 } |
194 } |
197 } |
195 // Clear the queue, generating screens with a non-current theme is |
198 // Clear the queue, generating screens with a non-current theme is |
196 // not possible anyway. |
199 // not possible anyway. |
271 mSettings->setValue(last_output_dir_key, outDir); |
274 mSettings->setValue(last_output_dir_key, outDir); |
272 emit finished(); |
275 emit finished(); |
273 qDebug() << PRE << "processQueue() over"; |
276 qDebug() << PRE << "processQueue() over"; |
274 return; |
277 return; |
275 } |
278 } |
276 // If a previous splash generation is still in progress then do nothing. |
279 // If a previous splash generation is still in progress or a compositor is |
277 if (mBusy) { |
280 // working then do nothing. |
|
281 if (!lockMainWindow()) { |
|
282 mProcessQueuePending = true; |
278 qDebug() << PRE << "still busy processQueue() over"; |
283 qDebug() << PRE << "still busy processQueue() over"; |
279 return; |
284 return; |
280 } |
285 } |
281 try { |
286 try { |
282 mBusy = true; |
287 mProcessQueuePending = false; |
283 mItem = mQueue.dequeue(); |
288 mItem = mQueue.dequeue(); |
284 mItemTime.start(); |
289 mItemTime.start(); |
285 log("generating splash screen", mItem.mThemeName, mItem.mOrientation); |
290 log("generating splash screen", mItem.mThemeName, mItem.mOrientation); |
286 |
291 |
287 ensureMainWindow(); |
292 ensureMainWindow(); |
300 cleanup(); |
305 cleanup(); |
301 } |
306 } |
302 qDebug() << PRE << "processQueue() over"; |
307 qDebug() << PRE << "processQueue() over"; |
303 } |
308 } |
304 |
309 |
305 void HbSplashGenerator::ensureMainWindow() |
310 HbMainWindow *HbSplashGenerator::ensureMainWindow() |
306 { |
311 { |
307 if (!mMainWindow) { |
312 if (!mMainWindow) { |
308 // The FixedVertical flag is used just to disable the sensor-based |
313 // The FixedVertical flag is used just to disable the sensor-based |
309 // orientation switching. |
314 // orientation switching. |
310 mMainWindow = new HbMainWindow(0, Hb::WindowFlagFixedVertical); |
315 mMainWindow = new HbMainWindow(0, Hb::WindowFlagFixedVertical); |
311 // Make sure that at least the 1st phase of the delayed |
316 // Make sure that at least the 1st phase of the delayed |
312 // construction is done right now. |
317 // construction is done right now. |
313 HbMainWindowPrivate::d_ptr(mMainWindow)->_q_delayedConstruction(); |
318 HbMainWindowPrivate::d_ptr(mMainWindow)->_q_delayedConstruction(); |
314 } |
319 } |
|
320 return mMainWindow; |
315 } |
321 } |
316 |
322 |
317 void HbSplashGenerator::processWindow() |
323 void HbSplashGenerator::processWindow() |
318 { |
324 { |
319 // Take the screenshot, remove content, and move on to the next request in the queue. |
325 // Take the screenshot, remove content, and move on to the next request in the queue. |
320 log("processWindow() rendering splash screen", mItem.mThemeName, mItem.mOrientation); |
326 log("processWindow() rendering splash screen", mItem.mThemeName, mItem.mOrientation); |
321 takeScreenshot(); |
327 takeScreenshot(); |
322 qDebug() << PRE << "total time for screen (ms):" << mItemTime.elapsed(); |
328 qDebug() << PRE << "total time for screen (ms):" << mItemTime.elapsed(); |
323 |
329 |
324 QList<HbView *> views = mMainWindow->views(); |
330 QList<HbView *> views = mMainWindow->views(); |
325 foreach (HbView *view, views) { |
331 foreach(HbView * view, views) { |
326 mMainWindow->removeView(view); |
332 mMainWindow->removeView(view); |
327 delete view; |
333 delete view; |
328 } |
334 } |
329 clearTranslators(); |
335 clearTranslators(); |
330 |
336 |
331 mBusy = false; |
337 unlockMainWindowInternal(); |
332 QMetaObject::invokeMethod(this, "processQueue", Qt::QueuedConnection); |
338 QMetaObject::invokeMethod(this, "processQueue", Qt::QueuedConnection); |
333 log("processWindow() over", mItem.mThemeName, mItem.mOrientation); |
339 log("processWindow() over", mItem.mThemeName, mItem.mOrientation); |
334 } |
340 } |
335 |
341 |
336 void HbSplashGenerator::takeScreenshot() |
342 void HbSplashGenerator::takeScreenshot() |
405 f.write((char *) &w, sizeof(quint32)); |
405 f.write((char *) &w, sizeof(quint32)); |
406 f.write((char *) &h, sizeof(quint32)); |
406 f.write((char *) &h, sizeof(quint32)); |
407 f.write((char *) &bpl, sizeof(quint32)); |
407 f.write((char *) &bpl, sizeof(quint32)); |
408 f.write((char *) &fmt, sizeof(qint32)); |
408 f.write((char *) &fmt, sizeof(qint32)); |
409 f.write((char *) &extra, sizeof(quint32)); |
409 f.write((char *) &extra, sizeof(quint32)); |
410 f.write((const char *) imageBits(image), bpl * h); |
410 f.write((const char *) image.bits(), bpl * h); |
411 f.close(); |
411 f.close(); |
412 return true; |
412 return true; |
413 } |
413 } |
414 return false; |
414 return false; |
415 } |
415 } |
467 |
468 |
468 void HbSplashGenerator::queueAppSpecificItems(const QString &themeName, Qt::Orientation orientation) |
469 void HbSplashGenerator::queueAppSpecificItems(const QString &themeName, Qt::Orientation orientation) |
469 { |
470 { |
470 QSet<QString> processedFileNames; |
471 QSet<QString> processedFileNames; |
471 QStringList dirNames(hbsplash_splashml_dirs()); |
472 QStringList dirNames(hbsplash_splashml_dirs()); |
472 foreach (const QString &dirName, dirNames) { |
473 foreach(const QString & dirName, dirNames) { |
473 QDir dir(dirName); |
474 QDir dir(dirName); |
474 if (!dir.exists()) { |
475 if (!dir.exists()) { |
475 continue; |
476 continue; |
476 } |
477 } |
477 QStringList entries = dir.entryList(QStringList() << "*.splashml", QDir::Files); |
478 QStringList entries = dir.entryList(QStringList() << "*.splashml", QDir::Files); |
478 foreach (const QString &entry, entries) { |
479 foreach(const QString & entry, entries) { |
479 // Skip if a file with the same name has already been processed from |
480 // Skip if a file with the same name has already been processed from |
480 // a different location. |
481 // a different location. |
481 if (processedFileNames.contains(entry)) { |
482 if (processedFileNames.contains(entry)) { |
482 qDebug() << PRE << "skipping splashml (already found at other location)" << dir.filePath(entry); |
483 qDebug() << PRE << "skipping splashml (already found at other location)" << dir.filePath(entry); |
483 continue; |
484 continue; |
494 continue; |
495 continue; |
495 } |
496 } |
496 QueueItem item(themeName, orientation); |
497 QueueItem item(themeName, orientation); |
497 bool ok = parseSplashml(fullName, item); |
498 bool ok = parseSplashml(fullName, item); |
498 if (ok |
499 if (ok |
499 && !item.mAppId.isEmpty() |
500 && !item.mAppId.isEmpty() |
500 && !item.mDocmlWidgetName.isEmpty() |
501 && !item.mDocmlWidgetName.isEmpty() |
501 && !item.mDocmlFileName.isEmpty()) |
502 && !item.mDocmlFileName.isEmpty()) { |
502 { |
|
503 // Add the full path to the filename. The docml is supposed to |
503 // Add the full path to the filename. The docml is supposed to |
504 // be in the same directory as the splashml. |
504 // be in the same directory as the splashml. |
505 item.mDocmlFileName = dir.filePath(item.mDocmlFileName); |
505 item.mDocmlFileName = dir.filePath(item.mDocmlFileName); |
506 qDebug() << PRE << "queuing request" << item; |
506 qDebug() << PRE << "queuing request" << item; |
507 addSplashmlItemToQueue(item); |
507 addSplashmlItemToQueue(item); |
531 if (token == QXmlStreamReader::Invalid) { |
531 if (token == QXmlStreamReader::Invalid) { |
532 reportSplashmlError(fullFileName, xml.lineNumber(), xml.errorString()); |
532 reportSplashmlError(fullFileName, xml.lineNumber(), xml.errorString()); |
533 ok = false; |
533 ok = false; |
534 break; |
534 break; |
535 } else if (token == QXmlStreamReader::StartElement |
535 } else if (token == QXmlStreamReader::StartElement |
536 && xml.name() == QLatin1String("hbsplash")) |
536 && xml.name() == QLatin1String("hbsplash")) { |
537 { |
|
538 docOk = true; |
537 docOk = true; |
539 } else if (docOk) { |
538 } else if (docOk) { |
540 parseSplashmlElements(xml, item, fullFileName); |
539 parseSplashmlElements(xml, item, fullFileName); |
541 } |
540 } |
542 } |
541 } |
550 QString text = xml.readElementText().trimmed(); |
549 QString text = xml.readElementText().trimmed(); |
551 return text == QLatin1String("true") || text == QLatin1String("1"); |
550 return text == QLatin1String("true") || text == QLatin1String("1"); |
552 } |
551 } |
553 |
552 |
554 void HbSplashGenerator::parseSplashmlElements(QXmlStreamReader &xml, |
553 void HbSplashGenerator::parseSplashmlElements(QXmlStreamReader &xml, |
555 QueueItem &item, |
554 QueueItem &item, |
556 const QString &fullFileName) |
555 const QString &fullFileName) |
557 { |
556 { |
558 if (xml.isStartElement()) { |
557 if (xml.isStartElement()) { |
559 QStringRef name = xml.name(); |
558 QStringRef name = xml.name(); |
560 if (name == QLatin1String("docml")) { |
559 if (name == QLatin1String("docml")) { |
561 item.mDocmlFileName = xml.readElementText().trimmed(); |
560 item.mDocmlFileName = xml.readElementText().trimmed(); |
562 } else if (name == QLatin1String("widget")) { |
561 } else if (name == QLatin1String("widget")) { |
563 item.mDocmlWidgetName = xml.readElementText().trimmed(); |
562 item.mDocmlWidgetName = xml.readElementText().trimmed(); |
564 } else if (name == QLatin1String("appid") || name == QLatin1String("appuid")) { |
563 } else if (name == QLatin1String("appid") || name == QLatin1String("appuid")) { |
565 item.mAppId = xml.readElementText().trimmed(); |
564 item.mAppId = xml.readElementText().trimmed(); |
566 if (item.mAppId.startsWith("0x")) { |
565 if (item.mAppId.startsWith(QLatin1String("0x"))) { |
567 item.mAppId.remove(0, 2); |
566 item.mAppId.remove(0, 2); |
568 } |
567 } |
569 } else if (name == QLatin1String("screenid")) { |
568 } else if (name == QLatin1String("screenid")) { |
570 item.mScreenId = xml.readElementText().trimmed(); |
569 item.mScreenId = xml.readElementText().trimmed(); |
571 } else if (name == QLatin1String("tsappname")) { |
570 } else if (name == QLatin1String("tsappname")) { |
572 item.mTsAppName = xml.readElementText().trimmed(); |
571 item.mTsAppName = xml.readElementText().trimmed(); |
573 } else if (name == QLatin1String("view-flags")) { |
572 } else if (name == QLatin1String("view-flags")) { |
574 item.mViewFlags = xml.readElementText().split(",", QString::SkipEmptyParts); |
573 item.mViewFlags = xml.readElementText().split(',', QString::SkipEmptyParts); |
575 for (int i = 0, ie = item.mViewFlags.count(); i != ie; ++i) { |
574 for (int i = 0, ie = item.mViewFlags.count(); i != ie; ++i) { |
576 item.mViewFlags[i] = item.mViewFlags[i].trimmed().toLower(); |
575 item.mViewFlags[i] = item.mViewFlags[i].trimmed().toLower(); |
577 } |
576 } |
578 } else if (name == QLatin1String("background-item-visible")) { |
577 } else if (name == QLatin1String("background-item-visible")) { |
579 item.mHideBackground = !readBool(xml); |
578 item.mHideBackground = !readBool(xml); |
615 req.mFrameGraphicsType = HbFrameDrawer::ThreePiecesHorizontal; |
614 req.mFrameGraphicsType = HbFrameDrawer::ThreePiecesHorizontal; |
616 } else if (type == QLatin1String("3v")) { |
615 } else if (type == QLatin1String("3v")) { |
617 req.mFrameGraphicsType = HbFrameDrawer::ThreePiecesVertical; |
616 req.mFrameGraphicsType = HbFrameDrawer::ThreePiecesVertical; |
618 } else if (type == QLatin1String("9")) { |
617 } else if (type == QLatin1String("9")) { |
619 req.mFrameGraphicsType = HbFrameDrawer::NinePieces; |
618 req.mFrameGraphicsType = HbFrameDrawer::NinePieces; |
620 } |
619 } |
621 QString z = xml.attributes().value("z").toString().trimmed(); |
620 QString z = xml.attributes().value("z").toString().trimmed(); |
622 if (z.isEmpty()) { |
621 if (z.isEmpty()) { |
623 req.mZValue = -1; |
622 req.mZValue = -1; |
624 } else { |
623 } else { |
625 req.mZValue = z.toFloat(); |
624 req.mZValue = z.toFloat(); |
688 |
687 |
689 // Parse the docml file and add the specified widget as a view. |
688 // Parse the docml file and add the specified widget as a view. |
690 CustomDocumentLoader loader(mMainWindow, mItem); |
689 CustomDocumentLoader loader(mMainWindow, mItem); |
691 QStringList sections; |
690 QStringList sections; |
692 if (!mItem.mCondSections.isEmpty()) { |
691 if (!mItem.mCondSections.isEmpty()) { |
693 if (mItem.mCondSections.contains("portrait") && mItem.mOrientation == Qt::Vertical) { |
692 QLatin1String prtKey("portrait"); |
694 sections << mItem.mCondSections.value("portrait"); |
693 QLatin1String lscKey("landscape"); |
695 } else if (mItem.mCondSections.contains("landscape") && mItem.mOrientation == Qt::Horizontal) { |
694 if (mItem.mCondSections.contains(prtKey) && mItem.mOrientation == Qt::Vertical) { |
696 sections << mItem.mCondSections.value("landscape"); |
695 sections << mItem.mCondSections.value(prtKey); |
|
696 } else if (mItem.mCondSections.contains(lscKey) && mItem.mOrientation == Qt::Horizontal) { |
|
697 sections << mItem.mCondSections.value(lscKey); |
697 } |
698 } |
698 } |
699 } |
699 sections << mItem.mForcedSections; |
700 sections << mItem.mForcedSections; |
700 qDebug() << PRE << "loading" << mItem.mDocmlFileName << "common section"; |
701 qDebug() << PRE << "loading" << mItem.mDocmlFileName << "common section"; |
701 bool ok; |
702 bool ok; |
702 loader.load(mItem.mDocmlFileName, &ok); |
703 loader.load(mItem.mDocmlFileName, &ok); |
703 if (ok && !sections.isEmpty()) { |
704 if (ok && !sections.isEmpty()) { |
704 foreach (const QString §ion, sections) { |
705 foreach(const QString & section, sections) { |
705 qDebug() << PRE << "loading" << mItem.mDocmlFileName << "section" << section; |
706 qDebug() << PRE << "loading" << mItem.mDocmlFileName << "section" << section; |
706 loader.load(mItem.mDocmlFileName, section, &ok); |
707 loader.load(mItem.mDocmlFileName, section, &ok); |
707 } |
708 } |
708 } |
709 } |
709 if (ok) { |
710 if (ok) { |
726 { |
727 { |
727 // item-bg-graphics |
728 // item-bg-graphics |
728 for (int i = 0, ie = mItem.mItemBgGraphics.count(); i != ie; ++i) { |
729 for (int i = 0, ie = mItem.mItemBgGraphics.count(); i != ie; ++i) { |
729 QueueItem::ItemBgGraphicsRequest req = mItem.mItemBgGraphics.at(i); |
730 QueueItem::ItemBgGraphicsRequest req = mItem.mItemBgGraphics.at(i); |
730 if ((req.mOrientation == QLatin1String("portrait") && mItem.mOrientation != Qt::Vertical) |
731 if ((req.mOrientation == QLatin1String("portrait") && mItem.mOrientation != Qt::Vertical) |
731 || (req.mOrientation == QLatin1String("landscape") && mItem.mOrientation != Qt::Horizontal)) |
732 || (req.mOrientation == QLatin1String("landscape") && mItem.mOrientation != Qt::Horizontal)) { |
732 { |
|
733 continue; |
733 continue; |
734 } |
734 } |
735 HbWidget *widget = qobject_cast<HbWidget *>(loader.findWidget(req.mTargetWidgetName)); |
735 HbWidget *widget = qobject_cast<HbWidget *>(loader.findWidget(req.mTargetWidgetName)); |
736 if (widget) { |
736 if (widget) { |
737 qDebug() << PRE << "setting background item" << req.mFrameGraphicsName |
737 qDebug() << PRE << "setting background item" << req.mFrameGraphicsName |
754 if (!views.isEmpty()) { |
754 if (!views.isEmpty()) { |
755 HbView *view = views.at(0); |
755 HbView *view = views.at(0); |
756 |
756 |
757 // view-flags |
757 // view-flags |
758 HbView::HbViewFlags viewFlags = view->viewFlags(); |
758 HbView::HbViewFlags viewFlags = view->viewFlags(); |
759 if (mItem.mViewFlags.contains("tb-minimizable")) { |
759 if (mItem.mViewFlags.contains(QLatin1String("tb-minimizable"))) { |
760 viewFlags |= HbView::ViewTitleBarMinimizable; |
760 viewFlags |= HbView::ViewTitleBarMinimizable; |
761 } |
761 } |
762 if (mItem.mViewFlags.contains("tb-minimized")) { |
762 if (mItem.mViewFlags.contains(QLatin1String("tb-minimized"))) { |
763 viewFlags |= HbView::ViewTitleBarMinimized; |
763 viewFlags |= HbView::ViewTitleBarMinimized; |
764 } |
764 } |
765 if (mItem.mViewFlags.contains("tb-hidden")) { |
765 if (mItem.mViewFlags.contains(QLatin1String("tb-hidden"))) { |
766 viewFlags |= HbView::ViewTitleBarHidden; |
766 viewFlags |= HbView::ViewTitleBarHidden; |
767 } |
767 } |
768 if (mItem.mViewFlags.contains("tb-transparent")) { |
768 if (mItem.mViewFlags.contains(QLatin1String("tb-transparent"))) { |
769 viewFlags |= HbView::ViewTitleBarTransparent; |
769 viewFlags |= HbView::ViewTitleBarTransparent; |
770 } |
770 } |
771 if (mItem.mViewFlags.contains("tb-floating")) { |
771 if (mItem.mViewFlags.contains(QLatin1String("tb-floating"))) { |
772 viewFlags |= HbView::ViewTitleBarFloating; |
772 viewFlags |= HbView::ViewTitleBarFloating; |
773 } |
773 } |
774 if (mItem.mViewFlags.contains("sb-hidden")) { |
774 if (mItem.mViewFlags.contains(QLatin1String("sb-hidden"))) { |
775 viewFlags |= HbView::ViewStatusBarHidden; |
775 viewFlags |= HbView::ViewStatusBarHidden; |
776 } |
776 } |
777 if (mItem.mViewFlags.contains("sb-transparent")) { |
777 if (mItem.mViewFlags.contains(QLatin1String("sb-transparent"))) { |
778 viewFlags |= HbView::ViewStatusBarTransparent; |
778 viewFlags |= HbView::ViewStatusBarTransparent; |
779 } |
779 } |
780 if (mItem.mViewFlags.contains("sb-floating")) { |
780 if (mItem.mViewFlags.contains(QLatin1String("sb-floating"))) { |
781 viewFlags |= HbView::ViewStatusBarFloating; |
781 viewFlags |= HbView::ViewStatusBarFloating; |
782 } |
782 } |
783 view->setViewFlags(viewFlags); |
783 view->setViewFlags(viewFlags); |
784 if (viewFlags.testFlag(HbView::ViewStatusBarHidden) |
784 if (viewFlags.testFlag(HbView::ViewStatusBarHidden) |
785 || viewFlags.testFlag(HbView::ViewStatusBarTransparent)) |
785 || viewFlags.testFlag(HbView::ViewStatusBarTransparent)) { |
786 { |
786 mItem.mFlagsToStore |= HbSplashNonStandardStatusBar; |
787 mItem.mFlagsToStore |= 1; |
|
788 } |
787 } |
789 |
788 |
790 // navi-action-icon |
789 // navi-action-icon |
791 if (!mItem.mNaviActionIcon.isEmpty()) { |
790 if (!mItem.mNaviActionIcon.isEmpty()) { |
792 view->setNavigationAction(new HbAction(HbIcon(mItem.mNaviActionIcon), QString(), view)); |
791 view->setNavigationAction(new HbAction(HbIcon(mItem.mNaviActionIcon), QString(), view)); |
810 mMainWindow->scene()->setBackgroundBrush(Qt::NoBrush); |
809 mMainWindow->scene()->setBackgroundBrush(Qt::NoBrush); |
811 // background-image-name |
810 // background-image-name |
812 HbBackgroundItem *bgItem = mwd->mBgItem; |
811 HbBackgroundItem *bgItem = mwd->mBgItem; |
813 if (bgItem) { |
812 if (bgItem) { |
814 QString backgroundImageName = mItem.mBackgroundImageName.value( |
813 QString backgroundImageName = mItem.mBackgroundImageName.value( |
815 mItem.mOrientation == Qt::Vertical ? "portrait" : "landscape"); |
814 mItem.mOrientation == Qt::Vertical ? "portrait" : "landscape"); |
816 if (backgroundImageName.isEmpty()) { |
815 if (backgroundImageName.isEmpty()) { |
817 backgroundImageName = mItem.mBackgroundImageName.value("always"); |
816 backgroundImageName = mItem.mBackgroundImageName.value("always"); |
818 if (backgroundImageName.isEmpty()) { |
817 if (backgroundImageName.isEmpty()) { |
819 backgroundImageName = bgItem->defaultImageName(mItem.mOrientation); |
818 backgroundImageName = bgItem->defaultImageName(mItem.mOrientation); |
820 } |
819 } |
822 mMainWindow->setBackgroundImageName(mItem.mOrientation, backgroundImageName); |
821 mMainWindow->setBackgroundImageName(mItem.mOrientation, backgroundImageName); |
823 } |
822 } |
824 } |
823 } |
825 |
824 |
826 // Hide dynamic content from status bar (clock, indicators). |
825 // Hide dynamic content from status bar (clock, indicators). |
827 setStatusBarElementsVisible(false); |
826 setStatusBarElementsVisible(mMainWindow, false); |
828 } |
827 } |
829 |
828 |
830 void HbSplashGenerator::setStatusBarElementsVisible(bool visible) |
829 void HbSplashGenerator::setStatusBarElementsVisible(HbMainWindow *mw, bool visible) |
831 { |
830 { |
832 HbMainWindowPrivate *mwd = HbMainWindowPrivate::d_ptr(mMainWindow); |
831 HbMainWindowPrivate *mwd = HbMainWindowPrivate::d_ptr(mw); |
833 HbStatusBar *statusBar = mwd->mStatusBar; |
832 HbStatusBar *statusBar = mwd->mStatusBar; |
834 if (statusBar) { |
833 if (statusBar) { |
835 foreach (QGraphicsItem *item, statusBar->childItems()) { |
834 foreach(QGraphicsItem * item, statusBar->childItems()) { |
836 QString name = HbStyle::itemName(item); |
835 QString name = HbStyle::itemName(item); |
837 bool knownItem = |
836 bool knownItem = |
838 name == QLatin1String("signal") |
837 name == QLatin1String("signal") |
839 || name == QLatin1String("battery") |
838 || name == QLatin1String("battery") |
840 || name == QLatin1String("notificationindicators") |
839 || name == QLatin1String("notificationindicators") |
852 QString lang = QLocale::system().name(); |
851 QString lang = QLocale::system().name(); |
853 QTranslator *translator = new QTranslator; |
852 QTranslator *translator = new QTranslator; |
854 bool ok = false; |
853 bool ok = false; |
855 QStringList dirNames(hbsplash_translation_dirs()); |
854 QStringList dirNames(hbsplash_translation_dirs()); |
856 dirNames.append(mItem.mCustomTrDirs); |
855 dirNames.append(mItem.mCustomTrDirs); |
857 foreach (const QString &dirName, dirNames) { |
856 foreach(const QString & dirName, dirNames) { |
858 QDir dir(dirName); |
857 QDir dir(dirName); |
859 QString fullName = dir.filePath(name + '_' + lang); |
858 QString fullName = dir.filePath(name + '_' + lang); |
860 // fullName is not necessarily an existing file, however the translator |
859 // fullName is not necessarily an existing file, however the translator |
861 // may still pick up another suitable file based on this name. |
860 // may still pick up another suitable file based on this name. |
862 if (translator->load(fullName)) { |
861 if (translator->load(fullName)) { |
889 mParsedSplashmls.clear(); |
888 mParsedSplashmls.clear(); |
890 // Have some delay to avoid heavy system load in case of multiple |
889 // Have some delay to avoid heavy system load in case of multiple |
891 // directory-changed notifications. |
890 // directory-changed notifications. |
892 QTimer::singleShot(1000, this, SLOT(regenerate())); |
891 QTimer::singleShot(1000, this, SLOT(regenerate())); |
893 } |
892 } |
|
893 |
|
894 bool HbSplashGenerator::lockMainWindow() |
|
895 { |
|
896 if (!mMainWindowLocked) { |
|
897 mMainWindowLocked = true; |
|
898 return true; |
|
899 } |
|
900 return false; |
|
901 } |
|
902 |
|
903 void HbSplashGenerator::unlockMainWindowInternal() |
|
904 { |
|
905 mMainWindowLocked = false; |
|
906 } |
|
907 |
|
908 void HbSplashGenerator::unlockMainWindow() |
|
909 { |
|
910 // This version is used by the compositors. Besides resetting the flag it |
|
911 // also queues a call to processQueue() if needed. |
|
912 unlockMainWindowInternal(); |
|
913 if (mProcessQueuePending) { |
|
914 QMetaObject::invokeMethod(this, "processQueue", Qt::QueuedConnection); |
|
915 } |
|
916 } |