]> git.sesse.net Git - kdenlive/blobdiff - src/dvdwizardmenu.cpp
Fix a couple of compile warnings because of unused and uninitialized variables.
[kdenlive] / src / dvdwizardmenu.cpp
index 4a90c50aa4fa6c9e45bc2fe97721069926712d53..625754c6b24bef9aced3391d5b6a314d9a9edfe0 100644 (file)
  ***************************************************************************/
 
 #include "dvdwizardmenu.h"
+#include "kdenlivesettings.h"
 
 #include <KDebug>
 #include <KColorScheme>
+#include "kthumb.h"
 
 DvdWizardMenu::DvdWizardMenu(const QString &profile, QWidget *parent) :
         QWizardPage(parent),
@@ -48,7 +50,6 @@ DvdWizardMenu::DvdWizardMenu(const QString &profile, QWidget *parent) :
     } else changeProfile(true);
 
 
-
     // Create color background
     m_color = new QGraphicsRectItem(0, 0, m_width, m_height);
     m_color->setBrush(m_view.background_color->color());
@@ -111,7 +112,7 @@ DvdWizardMenu::DvdWizardMenu(const QString &profile, QWidget *parent) :
     connect(m_scene, SIGNAL(changed(const QList<QRectF> &)), this, SIGNAL(completeChanged()));
 
     // red background for error message
-    KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window);
+    KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
     QPalette p = m_view.error_message->palette();
     p.setColor(QPalette::Background, scheme.background(KColorScheme::NegativeBackground).color());
     m_view.error_message->setAutoFillBackground(true);
@@ -157,7 +158,7 @@ bool DvdWizardMenu::isComplete() const
         }
     }
     if (buttonCount == 0) {
-        // We need at least one button
+        //We need at least one button
         m_view.error_message->setText(i18n("No button in menu"));
         m_view.error_message->setHidden(false);
         return false;
@@ -276,14 +277,11 @@ void DvdWizardMenu::changeProfile(bool isPal)
     if (isPal == false) {
         m_width = 720;
         m_height = 480;
-        m_isPal = false;
-        updatePreview();
     } else {
         m_width = 720;
         m_height = 576;
-        m_isPal = true;
-        updatePreview();
     }
+    updatePreview();
 }
 
 void DvdWizardMenu::updatePreview()
@@ -304,7 +302,7 @@ void DvdWizardMenu::updatePreview()
 void DvdWizardMenu::setTargets(QStringList list, QStringList targetlist)
 {
     m_view.target_list->clear();
-    m_view.target_list->addItem(i18n("Play All"), "title 1");
+    m_view.target_list->addItem(i18n("Play All"), "jump title 1");
     int movieCount = 0;
     for (int i = 0; i < list.count(); i++) {
         if (targetlist.at(i).contains("chapter"))
@@ -322,16 +320,21 @@ void DvdWizardMenu::checkBackgroundType(int ix)
     if (ix == 0) {
         m_view.background_color->setVisible(true);
         m_view.background_image->setVisible(false);
+        m_view.loop_movie->setVisible(false);
         if (m_background->scene() != 0) m_scene->removeItem(m_background);
     } else {
         m_view.background_color->setVisible(false);
         m_view.background_image->setVisible(true);
         if (ix == 1) {
+            m_view.background_image->clear();
             m_view.background_image->setFilter("*");
-            m_scene->addItem(m_background);
+            if (m_background->scene() != 0) m_scene->removeItem(m_background);
+            m_view.loop_movie->setVisible(false);
         } else {
             if (m_background->scene() != 0) m_scene->removeItem(m_background);
+            m_view.background_image->clear();
             m_view.background_image->setFilter("video/mpeg");
+            m_view.loop_movie->setVisible(true);
         }
     }
 }
@@ -349,13 +352,24 @@ void DvdWizardMenu::buildImage()
         return;
     }
     QPixmap pix;
-    if (!pix.load(m_view.background_image->url().path())) {
-        if (m_background->scene() != 0) m_scene->removeItem(m_background);
-        return;
+
+    if (m_view.background_list->currentIndex() == 1) {
+        // image background
+        if (!pix.load(m_view.background_image->url().path())) {
+            if (m_background->scene() != 0) m_scene->removeItem(m_background);
+            return;
+        }
+        pix = pix.scaled(m_width, m_height);
+    } else if (m_view.background_list->currentIndex() == 2) {
+        // video background
+        int w;
+        if (m_isPal) w = 768;
+        else w = 640;
+        pix = KThumb::getImage(m_view.background_image->url(), 0, w, m_height);
+        pix = pix.scaled(m_width, m_height);
     }
-    pix = pix.scaled(m_width, m_height);
     m_background->setPixmap(pix);
-    if (m_view.background_list->currentIndex() == 1) m_scene->addItem(m_background);
+    m_scene->addItem(m_background);
 }
 
 void DvdWizardMenu::checkBackground()
@@ -409,70 +423,59 @@ void DvdWizardMenu::createButtonImages(const QString &img1, const QString &img2,
 {
     if (m_view.create_menu->isChecked()) {
         m_scene->clearSelection();
-        QImage img(m_width, m_height, QImage::Format_ARGB8555_Premultiplied);
-        QPainter p(&img);
-        p.setRenderHints(QPainter::Antialiasing, false);
-        p.setRenderHints(QPainter::TextAntialiasing, false);
         if (m_safeRect->scene() != 0) m_scene->removeItem(m_safeRect);
         if (m_color->scene() != 0) m_scene->removeItem(m_color);
         if (m_background->scene() != 0) m_scene->removeItem(m_background);
+        
+        QImage img(m_width, m_height, QImage::Format_Mono);
+        img.fill(Qt::white);
+        updateColor(Qt::black);
+        QPainter p(&img);
+        p.setRenderHints(QPainter::Antialiasing, false);
+        p.setRenderHints(QPainter::TextAntialiasing, false);
         m_scene->render(&p, QRectF(0, 0, m_width, m_height));
         p.end();
 #if QT_VERSION >= 0x040600
-        img.setColorCount(4);
+        img.setColor(0, m_view.text_color->color().rgb());
+        img.setColor(1, qRgba(0,0,0,0));
 #else
         img.setNumColors(4);
 #endif
         img.save(img1);
-        /*QImage saved;
-        if (m_view.menu_profile->currentIndex() < 2)
-            saved = img.scaled(720, 576);
-        else saved = img.scaled(720, 480);
-        saved.setNumColors(4);
-        saved.save(img1);*/
-
-        updateColor(m_view.selected_color->color());
+
+        img.fill(Qt::white);
         p.begin(&img);
         p.setRenderHints(QPainter::Antialiasing, false);
         p.setRenderHints(QPainter::TextAntialiasing, false);
         m_scene->render(&p, QRectF(0, 0, m_width, m_height));
         p.end();
-        /*        if (m_view.menu_profile->currentIndex() < 2)
-                    saved = img.scaled(720, 576);
-                else saved = img.scaled(720, 480);
-                saved.setNumColors(4);
-                saved.save(img2);*/
 #if QT_VERSION >= 0x040600
-        img.setColorCount(4);
+        img.setColor(0, m_view.highlighted_color->color().rgb());
+        img.setColor(1, qRgba(0,0,0,0));
 #else
         img.setNumColors(4);
 #endif
-        img.save(img2);
-
+        img.save(img3);        
 
-        updateColor(m_view.highlighted_color->color());
+        img.fill(Qt::white);
         p.begin(&img);
         p.setRenderHints(QPainter::Antialiasing, false);
         p.setRenderHints(QPainter::TextAntialiasing, false);
         m_scene->render(&p, QRectF(0, 0, m_width, m_height));
         p.end();
-        /*if (m_view.menu_profile->currentIndex() < 2)
-            saved = img.scaled(720, 576);
-        else saved = img.scaled(720, 480);
-        saved.setNumColors(4);
-        saved.save(img3);*/
+
 #if QT_VERSION >= 0x040600
-        img.setColorCount(4);
+        img.setColor(0, m_view.selected_color->color().rgb());
+        img.setColor(1, qRgba(0,0,0,0));
 #else
         img.setNumColors(4);
 #endif
-        img.save(img3);
-
+        img.save(img2);
         updateColor();
 
         m_scene->addItem(m_safeRect);
         m_scene->addItem(m_color);
-        if (m_view.background_list->currentIndex() == 1) m_scene->addItem(m_background);
+        if (m_view.background_list->currentIndex() > 0) m_scene->addItem(m_background);
     }
 }
 
@@ -505,6 +508,11 @@ bool DvdWizardMenu::createMenu() const
     return m_view.create_menu->isChecked();
 }
 
+bool DvdWizardMenu::loopMovie() const
+{
+    return m_view.loop_movie->isChecked();
+}
+
 bool DvdWizardMenu::menuMovie() const
 {
     return m_view.background_list->currentIndex() == 2;
@@ -632,7 +640,6 @@ void DvdWizardMenu::loadXml(QDomElement xml)
         button->setBackMenu(e.attribute("backtomenu").toInt());
         button->setDefaultTextColor(m_view.text_color->color());
         button->setZValue(4);
-        QRectF r = button->sceneBoundingRect();
         m_scene->addItem(button);
         button->setPos(e.attribute("posx").toDouble(), e.attribute("posy").toDouble());