diff --git a/project/effectfields/combofield.cpp b/project/effectfields/combofield.cpp index 46576aa7a..2058e9661 100644 --- a/project/effectfields/combofield.cpp +++ b/project/effectfields/combofield.cpp @@ -1,6 +1,6 @@ #include "combofield.h" -#include +#include "ui/comboboxex.h" ComboField::ComboField(EffectRow* parent, const QString& id) : EffectField(parent, id, EFFECT_FIELD_COMBO) @@ -18,7 +18,9 @@ void ComboField::AddItem(const QString &text, const QVariant &data) QWidget *ComboField::CreateWidget() { - QComboBox* cb = new QComboBox(); + ComboBoxEx* cb = new ComboBoxEx(); + + cb->setScrollingEnabled(false); for (int i=0;iaddItem(items_.at(i).name); diff --git a/project/effectfields/effectfield.cpp b/project/effectfields/effectfield.cpp index b71154022..a3db48cea 100644 --- a/project/effectfields/effectfield.cpp +++ b/project/effectfields/effectfield.cpp @@ -50,7 +50,8 @@ EffectField::EffectField(EffectRow* parent, const QString &i, EffectFieldType t) QObject(parent), type_(t), id_(i), - enabled_(true) + enabled_(true), + colspan_(1) { // EffectField MUST be created with a parent. Q_ASSERT(parent != nullptr); @@ -80,6 +81,7 @@ int EffectField::GetColumnSpan() void EffectField::SetColumnSpan(int i) { + Q_ASSERT(i >= 1); colspan_ = i; } diff --git a/project/effectfields/fontfield.cpp b/project/effectfields/fontfield.cpp index a7b14fc0c..b647dd17e 100644 --- a/project/effectfields/fontfield.cpp +++ b/project/effectfields/fontfield.cpp @@ -1,8 +1,9 @@ #include "fontfield.h" -#include #include +#include "ui/comboboxex.h" + FontField::FontField(EffectRow* parent, const QString &id) : EffectField(parent, id, EFFECT_FIELD_FONT) { @@ -18,7 +19,9 @@ QString FontField::GetFontAt(double timecode) QWidget *FontField::CreateWidget() { - QComboBox* fcb = new QComboBox(); + ComboBoxEx* fcb = new ComboBoxEx(); + + fcb->setScrollingEnabled(false); fcb->addItems(font_list); diff --git a/ui/comboboxex.cpp b/ui/comboboxex.cpp index 254504eab..3306ffbc1 100644 --- a/ui/comboboxex.cpp +++ b/ui/comboboxex.cpp @@ -20,63 +20,23 @@ #include "comboboxex.h" -#include "project/undo.h" -#include "panels/project.h" -#include "mainwindow.h" - -#include #include - -class ComboBoxExCommand : public QUndoCommand { -public: - ComboBoxExCommand(ComboBoxEx* obj, int old_index, int new_index) : - combobox(obj), old_val(old_index), new_val(new_index), done(true), old_project_changed(olive::MainWindow->isWindowModified()) {} - void undo() { - combobox->setCurrentIndex(old_val); - done = false; - olive::MainWindow->setWindowModified(old_project_changed); - } - void redo() { - if (!done) { - combobox->setCurrentIndex(new_val); - } - olive::MainWindow->setWindowModified(true); - } -private: - ComboBoxEx* combobox; - int old_val; - int new_val; - bool done; - bool old_project_changed; -}; - -ComboBoxEx::ComboBoxEx(QWidget *parent) : QComboBox(parent), index(0) { - connect(this, SIGNAL(activated(int)), this, SLOT(index_changed(int))); +ComboBoxEx::ComboBoxEx(QWidget *parent) : + QComboBox(parent) +{ } -void ComboBoxEx::setCurrentIndexEx(int i) { - index = i; - setCurrentIndex(i); +void ComboBoxEx::setScrollingEnabled(bool b) +{ + scrolling_enabled_ = b; } -void ComboBoxEx::setCurrentTextEx(const QString &text) { - setCurrentText(text); - index = currentIndex(); -} - -int ComboBoxEx::getPreviousIndex() { - return previousIndex; -} - -void ComboBoxEx::index_changed(int i) { - if (index != i) { - previousIndex = index; -// undo_stack.push(new ComboBoxExCommand(this, index, i)); - index = i; - } -} - -void ComboBoxEx::wheelEvent(QWheelEvent* e) { +void ComboBoxEx::wheelEvent(QWheelEvent *e) +{ + if (scrolling_enabled_) { + QComboBox::wheelEvent(e); + } else { e->ignore(); + } } diff --git a/ui/comboboxex.h b/ui/comboboxex.h index 5a3d23772..e3b7bb6b3 100644 --- a/ui/comboboxex.h +++ b/ui/comboboxex.h @@ -22,21 +22,16 @@ #define COMBOBOXEX_H #include -#include class ComboBoxEx : public QComboBox { Q_OBJECT public: - ComboBoxEx(QWidget* parent = 0); - void setCurrentIndexEx(int i); - void setCurrentTextEx(const QString &text); - int getPreviousIndex(); -private slots: - void index_changed(int); + ComboBoxEx(QWidget* parent = nullptr); + void setScrollingEnabled(bool b); +protected: + virtual void wheelEvent(QWheelEvent* e) override; private: - int index; - int previousIndex; - void wheelEvent(QWheelEvent* e); + bool scrolling_enabled_; }; #endif // COMBOBOXEX_H diff --git a/ui/effectui.cpp b/ui/effectui.cpp index c88e580dc..cc56e7aff 100644 --- a/ui/effectui.cpp +++ b/ui/effectui.cpp @@ -36,12 +36,15 @@ EffectUI::EffectUI(Effect* e) : layout_->addWidget(row_label, i, 0); + int column = 1; for (int j=0;jFieldCount();j++) { EffectField* field = row->Field(j); QWidget* widget = field->CreateWidget(); - layout_->addWidget(widget, i, j + 1); + layout_->addWidget(widget, i, column, 1, field->GetColumnSpan()); + + column += field->GetColumnSpan(); } // Find maximum column to place keyframe controls