X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fchoosecolorwidget.cpp;h=f8b8d3024b7050e30d4883316808a8948ae64a9b;hb=c3302003093710ee247ad84c0fe2ef3c579d417f;hp=26c18743e649ab9455c58669647ca5da7a496738;hpb=ce68de86827a11cd0dc96465fba021b2f7ceea55;p=kdenlive diff --git a/src/choosecolorwidget.cpp b/src/choosecolorwidget.cpp index 26c18743..f8b8d302 100644 --- a/src/choosecolorwidget.cpp +++ b/src/choosecolorwidget.cpp @@ -27,6 +27,7 @@ #include #include #include +#include static QColor stringToColor(QString strColor) { @@ -67,7 +68,7 @@ static QColor stringToColor(QString strColor) return color; } -static QString colorToString(QColor color, bool alpha) +static QString colorToString(const QColor &color, bool alpha) { QString colorStr; QTextStream stream(&colorStr); @@ -77,14 +78,16 @@ static QString colorToString(QColor color, bool alpha) stream.setFieldAlignment(QTextStream::AlignRight); stream.setPadChar('0'); stream << color.red() << color.green() << color.blue(); - if(alpha) - { + if (alpha) { stream << color.alpha(); + } else { + // MLT always wants 0xRRGGBBAA format + stream << "ff"; } return colorStr; } -ChooseColorWidget::ChooseColorWidget(QString text, QString color, QWidget *parent) : +ChooseColorWidget::ChooseColorWidget(const QString &text, const QString &color, bool alphaEnabled, QWidget *parent) : QWidget(parent) { QHBoxLayout *layout = new QHBoxLayout(this); @@ -99,6 +102,9 @@ ChooseColorWidget::ChooseColorWidget(QString text, QString color, QWidget *paren rightSideLayout->setSpacing(0); m_button = new KColorButton(stringToColor(color), rightSide); +#if KDE_IS_VERSION(4,5,0) + if (alphaEnabled) m_button->setAlphaChannelEnabled(alphaEnabled); +#endif // m_button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); ColorPickerWidget *picker = new ColorPickerWidget(rightSide); @@ -108,11 +114,12 @@ ChooseColorWidget::ChooseColorWidget(QString text, QString color, QWidget *paren rightSideLayout->addWidget(picker, 0, Qt::AlignRight); connect(picker, SIGNAL(colorPicked(QColor)), this, SLOT(setColor(QColor))); - connect(picker, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int))); + connect(picker, SIGNAL(displayMessage(QString,int)), this, SIGNAL(displayMessage(QString,int))); + connect(picker, SIGNAL(disableCurrentFilter(bool)), this, SIGNAL(disableCurrentFilter(bool))); connect(m_button, SIGNAL(changed(QColor)), this, SIGNAL(modified())); } -QString ChooseColorWidget::getColor() +QString ChooseColorWidget::getColor() const { bool alphaChannel = false; #if KDE_IS_VERSION(4,5,0) @@ -121,14 +128,7 @@ QString ChooseColorWidget::getColor() return colorToString(m_button->color(), alphaChannel); } -void ChooseColorWidget::setAlphaChannelEnabled(bool enabled) -{ -#if KDE_IS_VERSION(4,5,0) - m_button->setAlphaChannelEnabled(enabled); -#endif -} - -void ChooseColorWidget::setColor(QColor color) +void ChooseColorWidget::setColor(const QColor& color) { m_button->setColor(color); }