From: Valerio Valerio Date: Sun, 28 Feb 2010 17:02:27 +0000 (+0000) Subject: Auto-select new added files X-Git-Url: http://git.maemo.org/git/?p=bootcreen;a=commitdiff_plain;h=3ec4cdf81a3d1bef3206718b710096fbf7036175 Auto-select new added files --- diff --git a/Makefile b/Makefile index fbd8afe..1315396 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: bootscreen -# Generated by qmake (2.01a) (Qt 4.6.2) on: Mon Feb 22 01:04:53 2010 +# Generated by qmake (2.01a) (Qt 4.6.2) on: Sun Feb 28 16:52:17 2010 # Project: bootscreen.pro # Template: app # Command: /opt/qt4-maemo5/bin/qmake-qt4 -unix -o Makefile bootscreen.pro diff --git a/bootscreen.cpp b/bootscreen.cpp index fca329f..ae1a04b 100644 --- a/bootscreen.cpp +++ b/bootscreen.cpp @@ -7,6 +7,7 @@ BootScreen::BootScreen(QWidget *parent) { hildonWelcome = "/etc/hildon-welcome.d/"; videosDir = "/opt/bootscreen/media/"; + settingsDir = "/opt/bootscreen/data/"; checkSettings(); filterGroup = new QActionGroup(this); @@ -36,23 +37,15 @@ BootScreen::BootScreen(QWidget *parent) void BootScreen::checkSettings() { - QDir dir("/home/user"); - if (!dir.cd(".bootscreen")) { - qWarning("Cannot find the \".bootscreen/\" directory"); - dir.mkdir(".bootscreen"); - if (!dir.cd(".bootscreen")) { - qWarning("Cannot create the \".bootscreen/\" directory"); - - //terminar applicacao - } - } - settingsFile.setFileName(dir.filePath("settings.ini")); - if (!settingsFile.exists()) + QDir dir(settingsDir); + settingsFile.setFileName(dir.filePath("bootscrenn.conf")); + + if (!settingsFile.exists()) restoreSettings(); - else{ + else{ QSettings tempSettings(settingsFile.fileName(),QSettings::IniFormat); random = tempSettings.value("random").toBool(); - } + } } void BootScreen::createList() @@ -174,16 +167,19 @@ void BootScreen::addVideo() QMaemo5InformationBox::DefaultTimeout); else{ bool result = fileCopy.copy(newFilePath); - // tamanho - if(result) + if(result){ list->addItem(QString("%1").arg(fileInfo.fileName())); + //autoselect item, if not in random mode + if(!random){ + QListWidgetItem *currentItem = list->item(list->count()-1); + currentItem->setSelected(true); + } + } else QMaemo5InformationBox::information(this, "Error copying file", QMaemo5InformationBox::DefaultTimeout); } } - - //add somewhere } } @@ -281,8 +277,11 @@ void BootScreen::restoreSettings() { qDebug() << settingsFile.fileName() << endl; - if (!settingsFile.open(QIODevice::ReadWrite | QIODevice::Text)) + if (!settingsFile.open(QIODevice::ReadWrite | QIODevice::Text)){ qWarning("Cannot create the settings file"); //abord + QMaemo5InformationBox::information(this, "Error: Cannot create the settings file", + QMaemo5InformationBox::DefaultTimeout); + } QTextStream out(&settingsFile); out << "random=false" << endl; diff --git a/bootscreen.h b/bootscreen.h index 4637fe2..20215c0 100644 --- a/bootscreen.h +++ b/bootscreen.h @@ -32,6 +32,7 @@ private: QString hildonWelcome; QString settingsPath; QString videosDir; + QString settingsDir; QFile settingsFile; QActionGroup *filterGroup; QAction *mRandom; diff --git a/bootscreen.pro b/bootscreen.pro index 9a7573b..7369bac 100644 --- a/bootscreen.pro +++ b/bootscreen.pro @@ -9,6 +9,7 @@ QT += maemo5 install_app.commands = $(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)/opt/bootscreen/$(QMAKE_TARGET) +install_cfg.commands = $(INSTALL_FILE) data/$(QMAKE_TARGET).conf $(DESTDIR)/opt/bootscreen/$(QMAKE_TARGET).conf install_dsk.commands = $(INSTALL_FILE) data/$(QMAKE_TARGET).desktop $(DESTDIR)/usr/share/applications/hildon/$(QMAKE_TARGET).desktop install_sd.commands = $(INSTALL_FILE) data/$(QMAKE_TARGET).sudoers $(DESTDIR)/etc/sudoers.d/$(QMAKE_TARGET).sudoers install_evd.commands = $(INSTALL_FILE) data/$(QMAKE_TARGET) $(DESTDIR)/etc/event.d/$(QMAKE_TARGET) diff --git a/bootscreenR.cpp b/bootscreenR.cpp index a00b3e4..2b1e019 100644 --- a/bootscreenR.cpp +++ b/bootscreenR.cpp @@ -7,28 +7,25 @@ BootScreenR::BootScreenR() { - logFile.setFileName("/home/user/.bootscreen/log.txt"); + settingsDir = "/opt/bootscreen/data/"; + logFile.setFileName("/opt/bootscreen/data/log.txt"); if (!logFile.open(QIODevice::ReadWrite | QIODevice::Text)) qDebug() << "Can't write log" << endl; QTextStream out(&logFile); - out << "log" << endl; + //out << "log" << endl; QDir dir("/home/user/"); - if (dir.cd(".bootscreen")) { - settingsFile.setFileName(dir.filePath("settings.ini")); - if (settingsFile.exists()){ - QSettings tempSettings(settingsFile.fileName(),QSettings::IniFormat); - bool random = tempSettings.value("random").toBool(); - if(random) - selectRandomFile(); - } - else - out << "Can't read settings file1111" << endl; - } - else - out << "Can't read settings file2222" << endl; + settingsFile.setFileName(dir.filePath("settings.ini")); + if (settingsFile.exists()){ + QSettings tempSettings(settingsFile.fileName(),QSettings::IniFormat); + bool random = tempSettings.value("random").toBool(); + if(random) + selectRandomFile(); + } + else + out << "Can't read settings file" << endl; } void BootScreenR::selectRandomFile() diff --git a/bootscreenR.h b/bootscreenR.h index 9fa47d3..b5b2cfd 100644 --- a/bootscreenR.h +++ b/bootscreenR.h @@ -13,6 +13,7 @@ public: private: void selectRandomFile(); + QString settingsDir; QFile settingsFile; QFile logFile; QList files; diff --git a/debian/dirs b/debian/dirs index 8806e73..c9a50f7 100644 --- a/debian/dirs +++ b/debian/dirs @@ -3,6 +3,7 @@ etc/sudoers.d/ etc/event.d/ opt/bootscreen/ opt/bootscreen/media/ +opt/bootscreen/data/ usr/share/applications/hildon/ usr/share/icons/hicolor/48x48/apps/ usr/share/icons/hicolor/64x64/apps/ diff --git a/welcome b/welcome deleted file mode 100644 index e69de29..0000000