+QDomElement DvdWizardMenu::toXml() const
+{
+ QDomDocument doc;
+ QDomElement xml = doc.createElement("menu");
+ doc.appendChild(xml);
+ xml.setAttribute("enabled", m_view.create_menu->isChecked());
+ if (m_view.background_list->currentIndex() == 0) {
+ // Color bg
+ xml.setAttribute("background_color", m_view.background_color->color().name());
+ } else if (m_view.background_list->currentIndex() == 1) {
+ // Image bg
+ xml.setAttribute("background_image", m_view.background_image->url().path());
+ } else {
+ // Video bg
+ xml.setAttribute("background_video", m_view.background_image->url().path());
+ }
+ xml.setAttribute("text_color", m_view.text_color->color().name());
+ xml.setAttribute("selected_color", m_view.selected_color->color().name());
+ xml.setAttribute("highlighted_color", m_view.highlighted_color->color().name());
+ xml.setAttribute("text_shadow", (int) m_view.use_shadow->isChecked());
+
+ QList<QGraphicsItem *> list = m_scene->items();
+ int buttonCount = 0;
+
+ for (int i = 0; i < list.count(); ++i) {
+ if (list.at(i)->type() == DvdButtonItem) {
+ buttonCount++;
+ DvdButton *button = static_cast < DvdButton* >(list.at(i));
+ QDomElement xmlbutton = doc.createElement("button");
+ xmlbutton.setAttribute("target", button->target());
+ xmlbutton.setAttribute("command", button->command());
+ xmlbutton.setAttribute("backtomenu", button->backMenu());
+ xmlbutton.setAttribute("posx", (int) button->pos().x());
+ xmlbutton.setAttribute("posy", (int) button->pos().y());
+ xmlbutton.setAttribute("text", button->toPlainText());
+ QFont font = button->font();
+ xmlbutton.setAttribute("font_size", font.pixelSize());
+ xmlbutton.setAttribute("font_family", font.family());
+ xml.appendChild(xmlbutton);
+ }
+ }
+ return doc.documentElement();
+}
+
+
+void DvdWizardMenu::loadXml(DVDFORMAT format, const QDomElement &xml)
+{
+ kDebug() << "// LOADING MENU";
+ if (xml.isNull()) return;
+ kDebug() << "// LOADING MENU 1";
+ changeProfile(format);
+ m_view.create_menu->setChecked(xml.attribute("enabled").toInt());
+ if (xml.hasAttribute("background_color")) {
+ m_view.background_list->setCurrentIndex(0);
+ m_view.background_color->setColor(xml.attribute("background_color"));
+ } else if (xml.hasAttribute("background_image")) {
+ m_view.background_list->setCurrentIndex(1);
+ m_view.background_image->setUrl(KUrl(xml.attribute("background_image")));
+ } else if (xml.hasAttribute("background_video")) {
+ m_view.background_list->setCurrentIndex(2);
+ m_view.background_image->setUrl(KUrl(xml.attribute("background_video")));
+ }
+
+ m_view.text_color->setColor(xml.attribute("text_color"));
+ m_view.selected_color->setColor(xml.attribute("selected_color"));
+ m_view.highlighted_color->setColor(xml.attribute("highlighted_color"));
+
+ m_view.use_shadow->setChecked(xml.attribute("text_shadow").toInt());
+
+ QDomNodeList buttons = xml.elementsByTagName("button");
+ kDebug() << "// LOADING MENU 2" << buttons.count();
+
+ if (buttons.count() > 0) {
+ // Clear existing buttons
+ QList<QGraphicsItem *> list = m_scene->items();
+
+ for (int i = 0; i < list.count(); ++i) {
+ if (list.at(i)->type() == DvdButtonItem) {
+ delete list.at(i);
+ --i;
+ }
+ }
+ }
+
+ for (int i = 0; i < buttons.count(); ++i) {
+ QDomElement e = buttons.at(i).toElement();
+ // create menu button
+ DvdButton *button = new DvdButton(e.attribute("text"));
+ QFont font(e.attribute("font_family"));
+ font.setPixelSize(e.attribute("font_size").toInt());
+#if KDE_IS_VERSION(4,6,0)
+ if (m_view.use_shadow->isChecked()) {
+ QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
+ shadow->setBlurRadius(7);
+ shadow->setOffset(4, 4);
+ button->setGraphicsEffect(shadow);
+ }
+#endif
+
+ //font.setStyleStrategy(QFont::NoAntialias);
+ button->setFont(font);
+ button->setTarget(e.attribute("target").toInt(), e.attribute("command"));
+ button->setBackMenu(e.attribute("backtomenu").toInt());
+ button->setDefaultTextColor(m_view.text_color->color());
+ button->setZValue(4);
+ m_scene->addItem(button);
+ button->setPos(e.attribute("posx").toInt(), e.attribute("posy").toInt());
+
+ }
+}
+
+void DvdWizardMenu::slotZoom()
+{
+ m_view.menu_preview->scale(2.0, 2.0);