enum { DvdButtonItem = QGraphicsItem::UserType + 1, DvdButtonUnderlineItem = QGraphicsItem::UserType + 2 };
DvdWizardMenu::DvdWizardMenu(DVDFORMAT format, QWidget *parent) :
- QWizardPage(parent),
- m_color(NULL),
- m_safeRect(NULL),
- m_finalSize(720, 576),
- m_movieLength(-1)
+ QWizardPage(parent),
+ m_color(NULL),
+ m_safeRect(NULL),
+ m_finalSize(720, 576),
+ m_movieLength(-1)
{
m_view.setupUi(this);
m_view.play_text->setText(i18n("Play"));
//font.setStyleStrategy(QFont::NoAntialias);
#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);
+ QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
+ shadow->setBlurRadius(7);
+ shadow->setOffset(4, 4);
+ button->setGraphicsEffect(shadow);
}
connect(m_view.use_shadow, SIGNAL(stateChanged(int)), this, SLOT(slotEnableShadows(int)));
#elif KDE_IS_VERSION(4,6,0)
//m_view.menu_preview->resizefitInView(0, 0, m_width, m_height);
- connect(m_view.play_text, SIGNAL(textChanged(const QString &)), this, SLOT(buildButton()));
- connect(m_view.text_color, SIGNAL(changed(const QColor &)), this, SLOT(updateColor()));
+ connect(m_view.play_text, SIGNAL(textChanged(QString)), this, SLOT(buildButton()));
+ connect(m_view.text_color, SIGNAL(changed(QColor)), this, SLOT(updateColor()));
connect(m_view.font_size, SIGNAL(valueChanged(int)), this, SLOT(buildButton()));
- connect(m_view.font_family, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(buildButton()));
- connect(m_view.background_image, SIGNAL(textChanged(const QString &)), this, SLOT(buildImage()));
- connect(m_view.background_color, SIGNAL(changed(const QColor &)), this, SLOT(buildColor()));
+ connect(m_view.font_family, SIGNAL(currentFontChanged(QFont)), this, SLOT(buildButton()));
+ connect(m_view.background_image, SIGNAL(textChanged(QString)), this, SLOT(buildImage()));
+ connect(m_view.background_color, SIGNAL(changed(QColor)), this, SLOT(buildColor()));
connect(m_view.background_list, SIGNAL(currentIndexChanged(int)), this, SLOT(checkBackgroundType(int)));
{
#if KDE_IS_VERSION(4,6,0)
QList<QGraphicsItem *> list = m_scene->items();
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
if (enable) {
- QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
- shadow->setBlurRadius(7);
- shadow->setOffset(4, 4);
- list.at(i)->setGraphicsEffect(shadow);
- }
+ QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
+ shadow->setBlurRadius(7);
+ shadow->setOffset(4, 4);
+ list.at(i)->setGraphicsEffect(shadow);
+ }
else list.at(i)->setGraphicsEffect(NULL);
}
}
QList<QGraphicsItem *> list = m_scene->items();
int buttonCount = 0;
// check that the menu buttons don't collide
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
buttonCount++;
DvdButton *button = static_cast < DvdButton* >(list.at(i));
QList<QGraphicsItem *> collisions = button->collidingItems();
if (!collisions.isEmpty()) {
- for (int j = 0; j < collisions.count(); j++) {
+ for (int j = 0; j < collisions.count(); ++j) {
if (collisions.at(j)->type() == button->type()) {
#if KDE_IS_VERSION(4,7,0)
- m_menuMessage->setText(i18n("Buttons overlapping"));
- m_menuMessage->setMessageType(KMessageWidget::Warning);
- m_menuMessage->show();
+ m_menuMessage->setText(i18n("Buttons overlapping"));
+ m_menuMessage->setMessageType(KMessageWidget::Warning);
+ m_menuMessage->show();
#else
m_view.error_message->setText(i18n("Buttons overlapping"));
m_view.error_message->setHidden(false);
}
if (!m_view.background_image->isHidden()) {
- // Make sure user selected a valid image / video file
+ // Make sure user selected a valid image / video file
if (!QFile::exists(m_view.background_image->url().path())) {
#if KDE_IS_VERSION(4,7,0)
m_menuMessage->setText(i18n("Missing background image"));
// check that we have a "Play all" entry
if (targets.contains(0)) return true;
// ... or that each video file has a button
- for (int i = m_view.target_list->count() - 1; i > 0; i--) {
+ for (int i = m_view.target_list->count() - 1; i > 0; --i) {
// If there is a vob file entry and it has no button assigned, don't allow to go further
if (m_view.target_list->itemIcon(i).isNull() == false && !targets.contains(i)) {
#if KDE_IS_VERSION(4,7,0)
void DvdWizardMenu::setButtonTarget(int ix)
{
QList<QGraphicsItem *> list = m_scene->selectedItems();
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
DvdButton *button = static_cast < DvdButton* >(list.at(i));
button->setTarget(ix, m_view.target_list->itemData(ix).toString());
void DvdWizardMenu::setBackToMenu(bool backToMenu)
{
QList<QGraphicsItem *> list = m_scene->selectedItems();
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
DvdButton *button = static_cast < DvdButton* >(list.at(i));
button->setBackMenu(backToMenu);
{
QList<QGraphicsItem *> list = m_scene->selectedItems();
bool foundButton = false;
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
m_view.play_text->blockSignals(true);
m_view.font_size->blockSignals(true);
font.setPixelSize(m_view.font_size->value());
#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);
+ QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
+ shadow->setBlurRadius(7);
+ shadow->setOffset(4, 4);
+ button->setGraphicsEffect(shadow);
}
#endif
//font.setStyleStrategy(QFont::NoAntialias);
void DvdWizardMenu::deleteButton()
{
QList<QGraphicsItem *> list = m_scene->selectedItems();
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
delete list.at(i);
break;
{
m_format = format;
switch (m_format) {
- case PAL_WIDE:
- m_finalSize = QSize(720, 576);
- m_width = 1024;
- m_height = 576;
- break;
- case NTSC_WIDE:
- m_finalSize = QSize(720, 480);
- m_width = 853;
- m_height = 480;
- break;
- case NTSC:
- m_finalSize = QSize(720, 480);
- m_width = 640;
- m_height = 480;
- break;
- default:
- m_finalSize = QSize(720, 576);
- m_width = 768;
- m_height = 576;
+ case PAL_WIDE:
+ m_finalSize = QSize(720, 576);
+ m_width = 1024;
+ m_height = 576;
+ break;
+ case NTSC_WIDE:
+ m_finalSize = QSize(720, 480);
+ m_width = 853;
+ m_height = 480;
+ break;
+ case NTSC:
+ m_finalSize = QSize(720, 480);
+ m_width = 640;
+ m_height = 480;
+ break;
+ default:
+ m_finalSize = QSize(720, 576);
+ m_width = 768;
+ m_height = 576;
}
updatePreview();
}
if (m_safeRect) m_safeRect->setRect(safeW, safeH, m_width - 2 * safeW, m_height - 2 * safeH);
}
-void DvdWizardMenu::setTargets(QStringList list, QStringList targetlist)
+void DvdWizardMenu::setTargets(const QStringList &list, const QStringList &targetlist)
{
m_view.target_list->clear();
m_view.target_list->addItem(i18n("Play All"), "jump title 1");
int movieCount = 0;
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (targetlist.at(i).contains("chapter"))
m_view.target_list->addItem(list.at(i), targetlist.at(i));
else {
} else if (m_view.background_list->currentIndex() == 2) {
// video background
m_movieLength = -1;
- QString profileName = DvdWizardVob::getDvdProfile(m_format);
- Mlt::Profile profile(profileName.toUtf8().constData());
- profile.set_explicit(true);
- Mlt::Producer *producer = new Mlt::Producer(profile, m_view.background_image->url().path().toUtf8().data());
- if (producer && producer->is_valid()) {
- pix = QPixmap::fromImage(KThumb::getFrame(producer, 0, m_finalSize.width(), m_width, m_height));
- m_movieLength = producer->get_length();
- }
- if (producer) delete producer;
+ QString profileName = DvdWizardVob::getDvdProfile(m_format);
+ Mlt::Profile profile(profileName.toUtf8().constData());
+ profile.set_explicit(true);
+ Mlt::Producer *producer = new Mlt::Producer(profile, m_view.background_image->url().path().toUtf8().constData());
+ if (producer && producer->is_valid()) {
+ pix = QPixmap::fromImage(KThumb::getFrame(producer, 0, m_finalSize.width(), m_width, m_height));
+ m_movieLength = producer->get_length();
+ }
+ if (producer) delete producer;
}
m_background->setPixmap(pix);
m_scene->addItem(m_background);
{
DvdButton *button = NULL;
QList<QGraphicsItem *> list = m_scene->selectedItems();
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
button = static_cast < DvdButton* >(list.at(i));
break;
void DvdWizardMenu::prepareUnderLines()
{
QList<QGraphicsItem *> list = m_scene->items();
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
- QRectF r = list.at(i)->sceneBoundingRect();
- int bottom = r.bottom() - 1;
- if (bottom % 2 == 1) bottom = bottom - 1;
- int underlineHeight = r.height() / 10;
- if (underlineHeight % 2 == 1) underlineHeight = underlineHeight - 1;
- underlineHeight = qMin(underlineHeight, 10);
- underlineHeight = qMax(underlineHeight, 2);
- r.setTop(bottom - underlineHeight);
- r.setBottom(bottom);
- r.adjust(2, 0, -2, 0);
- DvdButtonUnderline *underline = new DvdButtonUnderline(r);
- m_scene->addItem(underline);
- list.at(i)->setVisible(false);
- }
+ QRectF r = list.at(i)->sceneBoundingRect();
+ int bottom = r.bottom() - 1;
+ if (bottom % 2 == 1) bottom = bottom - 1;
+ int underlineHeight = r.height() / 10;
+ if (underlineHeight % 2 == 1) underlineHeight = underlineHeight - 1;
+ underlineHeight = qMin(underlineHeight, 10);
+ underlineHeight = qMax(underlineHeight, 2);
+ r.setTop(bottom - underlineHeight);
+ r.setBottom(bottom);
+ r.adjust(2, 0, -2, 0);
+ DvdButtonUnderline *underline = new DvdButtonUnderline(r);
+ m_scene->addItem(underline);
+ list.at(i)->setVisible(false);
+ }
}
}
{
QList<QGraphicsItem *> list = m_scene->items();
QList<QGraphicsItem *> toDelete;
- for (int i = 0; i < list.count(); i++) {
- if (list.at(i)->type() == DvdButtonUnderlineItem) {
- toDelete.append(list.at(i));
- }
+ for (int i = 0; i < list.count(); ++i) {
+ if (list.at(i)->type() == DvdButtonUnderlineItem) {
+ toDelete.append(list.at(i));
+ }
if (list.at(i)->type() == DvdButtonItem) {
- list.at(i)->setVisible(true);
- }
+ list.at(i)->setVisible(true);
+ }
}
while (!toDelete.isEmpty()) {
- QGraphicsItem *item = toDelete.takeFirst();
- delete item;
+ QGraphicsItem *item = toDelete.takeFirst();
+ delete item;
}
}
void DvdWizardMenu::updateUnderlineColor(QColor c)
{
QList<QGraphicsItem *> list = m_scene->items();
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonUnderlineItem) {
DvdButtonUnderline *underline = static_cast < DvdButtonUnderline* >(list.at(i));
- underline->setPen(Qt::NoPen);
- c.setAlpha(150);
- underline->setBrush(c);
+ underline->setPen(Qt::NoPen);
+ c.setAlpha(150);
+ underline->setBrush(c);
}
}
}
-void DvdWizardMenu::updateColor(QColor c)
+void DvdWizardMenu::updateColor(const QColor &c)
{
DvdButton *button = NULL;
QList<QGraphicsItem *> list = m_scene->items();
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
button = static_cast < DvdButton* >(list.at(i));
button->setDefaultTextColor(c);
{
if (m_view.create_menu->isChecked()) {
m_scene->clearSelection();
- QRectF source(0, 0, m_width, m_height);
- QRectF target;
- if (!letterbox) target = QRectF(0, 0, m_finalSize.width(), m_finalSize.height());
- else {
- // Scale the button images to fit a letterbox image
- double factor = (double) m_width / m_finalSize.width();
- int letterboxHeight = m_height / factor;
- target = QRectF(0, (m_finalSize.height() - letterboxHeight) / 2, m_finalSize.width(), letterboxHeight);
- }
+ QRectF source(0, 0, m_width, m_height);
+ QRectF target;
+ if (!letterbox) target = QRectF(0, 0, m_finalSize.width(), m_finalSize.height());
+ else {
+ // Scale the button images to fit a letterbox image
+ double factor = (double) m_width / m_finalSize.width();
+ int letterboxHeight = m_height / factor;
+ target = QRectF(0, (m_finalSize.height() - letterboxHeight) / 2, m_finalSize.width(), letterboxHeight);
+ }
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);
- prepareUnderLines();
+ prepareUnderLines();
#if QT_VERSION >= 0x040800
QImage img(m_finalSize.width(), m_finalSize.height(), QImage::Format_ARGB32);
img.fill(Qt::transparent);
- updateUnderlineColor(m_view.highlighted_color->color());
+ updateUnderlineColor(m_view.highlighted_color->color());
#else
- QImage img(m_finalSize.width(), m_finalSize.height(), QImage::Format_Mono);
+ QImage img(m_finalSize.width(), m_finalSize.height(), QImage::Format_Mono);
img.fill(Qt::white);
- updateUnderlineColor(Qt::black);
+ updateUnderlineColor(Qt::black);
#endif
- QPainter p;
+ QPainter p;
p.begin(&img);
//p.setRenderHints(QPainter::Antialiasing, false);
//p.setRenderHints(QPainter::TextAntialiasing, false);
- m_scene->render(&p, target, source, Qt::IgnoreAspectRatio);
+ m_scene->render(&p, target, source, Qt::IgnoreAspectRatio);
p.end();
#if QT_VERSION >= 0x040800
#elif QT_VERSION >= 0x040600
#if QT_VERSION >= 0x040800
img.fill(Qt::transparent);
- updateUnderlineColor(m_view.selected_color->color());
+ updateUnderlineColor(m_view.selected_color->color());
#else
img.fill(Qt::white);
#endif
- p.begin(&img);
+ p.begin(&img);
//p.setRenderHints(QPainter::Antialiasing, false);
//p.setRenderHints(QPainter::TextAntialiasing, false);
m_scene->render(&p, target, source, Qt::IgnoreAspectRatio);
void DvdWizardMenu::createBackgroundImage(const QString &img1, bool letterbox)
{
+ Q_UNUSED(letterbox)
+
m_scene->clearSelection();
if (m_safeRect->scene() != 0) m_scene->removeItem(m_safeRect);
bool showBg = false;
QRectF target;
if (!letterbox) target = QRectF(0, 0, m_finalSize.width(), m_finalSize.height());
else {
- // Scale the button images to fit a letterbox image
- double factor = (double) m_width / m_finalSize.width();
- int letterboxHeight = m_height / factor;
- target = QRectF(0, (m_finalSize.height() - letterboxHeight) / 2, m_finalSize.width(), letterboxHeight);
+ // Scale the button images to fit a letterbox image
+ double factor = (double) m_width / m_finalSize.width();
+ int letterboxHeight = m_height / factor;
+ target = QRectF(0, (m_finalSize.height() - letterboxHeight) / 2, m_finalSize.width(), letterboxHeight);
}*/
-
+
if (menuMovie()) {
- showBg = true;
- if (m_background->scene() != 0) m_scene->removeItem(m_background);
- if (m_color->scene() != 0) m_scene->removeItem(m_color);
- img.fill(Qt::transparent);
+ showBg = true;
+ if (m_background->scene() != 0) m_scene->removeItem(m_background);
+ if (m_color->scene() != 0) m_scene->removeItem(m_color);
+ img.fill(Qt::transparent);
}
updateColor(m_view.text_color->color());
QPainter p(&img);
img.save(img1);
m_scene->addItem(m_safeRect);
if (showBg) {
- m_scene->addItem(m_background);
- m_scene->addItem(m_color);
+ m_scene->addItem(m_background);
+ m_scene->addItem(m_color);
}
}
int DvdWizardMenu::menuMovieLength() const
{
- return m_movieLength;
+ return m_movieLength;
}
double ratioy = 1;
int offset = 0;
if (letterbox) {
- int letterboxHeight = m_height * ratiox;
- ratioy = (double) letterboxHeight / m_finalSize.height();
- offset = (m_finalSize.height() - letterboxHeight) / 2;
+ int letterboxHeight = m_height * ratiox;
+ ratioy = (double) letterboxHeight / m_finalSize.height();
+ offset = (m_finalSize.height() - letterboxHeight) / 2;
}
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
DvdButton *button = static_cast < DvdButton* >(list.at(i));
- QRectF r = button->sceneBoundingRect();
- QRect adjustedRect(r.x() * ratiox, offset + r.y() * ratioy, r.width() * ratiox, r.height() * ratioy);
- // Make sure y1 is not odd (requested by spumux)
+ QRectF r = button->sceneBoundingRect();
+ QRect adjustedRect(r.x() * ratiox, offset + r.y() * ratioy, r.width() * ratiox, r.height() * ratioy);
+ // Make sure y1 is not odd (requested by spumux)
if (adjustedRect.height() % 2 == 1) adjustedRect.setHeight(adjustedRect.height() + 1);
if (adjustedRect.y() % 2 == 1) adjustedRect.setY(adjustedRect.y() - 1);
QString command = button->command();
QList<QGraphicsItem *> list = m_scene->items();
int buttonCount = 0;
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
buttonCount++;
DvdButton *button = static_cast < DvdButton* >(list.at(i));
}
-void DvdWizardMenu::loadXml(DVDFORMAT format, QDomElement xml)
+void DvdWizardMenu::loadXml(DVDFORMAT format, const QDomElement &xml)
{
kDebug() << "// LOADING MENU";
if (xml.isNull()) return;
// Clear existing buttons
QList<QGraphicsItem *> list = m_scene->items();
- for (int i = 0; i < list.count(); i++) {
+ for (int i = 0; i < list.count(); ++i) {
if (list.at(i)->type() == DvdButtonItem) {
delete list.at(i);
- i--;
+ --i;
}
}
}
- for (int i = 0; i < buttons.count(); 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);
- }
+ 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);
m_view.menu_preview->scale(0.5, 0.5);
}
+
+#include "dvdwizardmenu.moc"