Auto-select new added files
authorValerio Valerio <vdv100@gmail.com>
Sun, 28 Feb 2010 17:02:27 +0000 (17:02 +0000)
committerValerio Valerio <vdv100@gmail.com>
Sun, 28 Feb 2010 17:02:27 +0000 (17:02 +0000)
Makefile
bootscreen.cpp
bootscreen.h
bootscreen.pro
bootscreenR.cpp
bootscreenR.h
debian/dirs
welcome [deleted file]

index fbd8afe..1315396 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building: bootscreen
 #############################################################################
 # 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
 # Project:  bootscreen.pro
 # Template: app
 # Command: /opt/qt4-maemo5/bin/qmake-qt4 -unix -o Makefile bootscreen.pro
index fca329f..ae1a04b 100644 (file)
@@ -7,6 +7,7 @@ BootScreen::BootScreen(QWidget *parent)
 {
     hildonWelcome = "/etc/hildon-welcome.d/";
     videosDir = "/opt/bootscreen/media/";
 {
     hildonWelcome = "/etc/hildon-welcome.d/";
     videosDir = "/opt/bootscreen/media/";
+    settingsDir = "/opt/bootscreen/data/";
     checkSettings();
 
     filterGroup = new QActionGroup(this);
     checkSettings();
 
     filterGroup = new QActionGroup(this);
@@ -36,23 +37,15 @@ BootScreen::BootScreen(QWidget *parent)
 
 void BootScreen::checkSettings()
 {
 
 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();
         restoreSettings();
-     else{
+    else{
          QSettings tempSettings(settingsFile.fileName(),QSettings::IniFormat);
          random = tempSettings.value("random").toBool();
          QSettings tempSettings(settingsFile.fileName(),QSettings::IniFormat);
          random = tempSettings.value("random").toBool();
-     }
+    }
 }
 
 void BootScreen::createList()
 }
 
 void BootScreen::createList()
@@ -174,16 +167,19 @@ void BootScreen::addVideo()
                                                             QMaemo5InformationBox::DefaultTimeout);
             else{
                 bool result = fileCopy.copy(newFilePath);
                                                             QMaemo5InformationBox::DefaultTimeout);
             else{
                 bool result = fileCopy.copy(newFilePath);
-            // tamanho
-                if(result)
+                if(result){
                     list->addItem(QString("%1").arg(fileInfo.fileName()));
                     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, "<font color=black>Error copying file</font>",
                                                                 QMaemo5InformationBox::DefaultTimeout);
             }
         }
                 else
                     QMaemo5InformationBox::information(this, "<font color=black>Error copying file</font>",
                                                                 QMaemo5InformationBox::DefaultTimeout);
             }
         }
-
-        //add somewhere
     }
 
 }
     }
 
 }
@@ -281,8 +277,11 @@ void BootScreen::restoreSettings()
 {
      qDebug() << settingsFile.fileName() << endl;
 
 {
      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
         qWarning("Cannot create the settings file"); //abord
+        QMaemo5InformationBox::information(this, "<font color=black><b>Error:</b> Cannot create the settings file</font>",
+                                                    QMaemo5InformationBox::DefaultTimeout);
+     }
 
      QTextStream out(&settingsFile);
      out << "random=false" << endl;
 
      QTextStream out(&settingsFile);
      out << "random=false" << endl;
index 4637fe2..20215c0 100644 (file)
@@ -32,6 +32,7 @@ private:
     QString hildonWelcome;
     QString settingsPath;
     QString videosDir;
     QString hildonWelcome;
     QString settingsPath;
     QString videosDir;
+    QString settingsDir;
     QFile settingsFile;
     QActionGroup *filterGroup;
     QAction *mRandom;
     QFile settingsFile;
     QActionGroup *filterGroup;
     QAction *mRandom;
index 9a7573b..7369bac 100644 (file)
@@ -9,6 +9,7 @@ QT += maemo5
 
 
 install_app.commands = $(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)/opt/bootscreen/$(QMAKE_TARGET)
 
 
 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)
 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)
index a00b3e4..2b1e019 100644 (file)
@@ -7,28 +7,25 @@
 
 BootScreenR::BootScreenR()
 {
 
 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);
 
     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/");
     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()
 }
 
 void BootScreenR::selectRandomFile()
index 9fa47d3..b5b2cfd 100644 (file)
@@ -13,6 +13,7 @@ public:
 
 private:
     void selectRandomFile();
 
 private:
     void selectRandomFile();
+    QString settingsDir;
     QFile settingsFile;
     QFile logFile;
     QList<QString> files;
     QFile settingsFile;
     QFile logFile;
     QList<QString> files;
index 8806e73..c9a50f7 100644 (file)
@@ -3,6 +3,7 @@ etc/sudoers.d/
 etc/event.d/
 opt/bootscreen/
 opt/bootscreen/media/
 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/
 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 (file)
index e69de29..0000000