1 #include "bootscreenR.h"
8 BootScreenR::BootScreenR()
10 settingsDir = "/opt/bootscreen/data/";
11 logFile.setFileName("/opt/bootscreen/data/log.txt");
13 if (!logFile.open(QIODevice::ReadWrite | QIODevice::Text))
14 qDebug() << "Can't write log" << endl;
16 QTextStream out(&logFile);
17 //out << "log" << endl;
18 QDir dir(settingsDir);
20 settingsFile.setFileName(dir.filePath("bootscreen.conf"));
21 if (settingsFile.exists()){
22 QSettings tempSettings(settingsFile.fileName(),QSettings::IniFormat);
23 bool random = tempSettings.value("random").toBool();
28 out << "Can't read settings file" << endl;
31 void BootScreenR::selectRandomFile()
33 QTextStream out(&logFile);
35 QSettings settings("/etc/hildon-welcome.d/0.conf",QSettings::IniFormat);
36 if (!settings.isWritable())
37 out << "Can't Write hildon-welcome settings" << endl;
40 settings.beginGroup("hildon-welcome");
41 QString currentFile = settings.value("filename").toString();
43 QDir videosDir("/opt/bootscreen/media");
44 videosDir.setFilter(QDir::Files | QDir::NoSymLinks);
45 videosDir.setSorting(QDir::Name);
46 QFileInfoList ls = videosDir.entryInfoList();
47 for (int i = 0; i < ls.size(); ++i) {
48 QFileInfo fileInfo = ls.at(i);
49 if(fileInfo.absoluteFilePath() != currentFile)
50 files.append(fileInfo.absoluteFilePath());
54 QTime fixTime(0, 0, 0);
55 qsrand(fixTime.secsTo(QTime::currentTime()));
56 int randomNumb = qrand() % files.size();
57 settings.setValue("filename", files.at(randomNumb));
60 out << "Can't randomize: Only one file in the media directory." << endl;
64 BootScreenR::~BootScreenR()