diff --git a/app/widget/CMakeLists.txt b/app/widget/CMakeLists.txt index eeb3575e8..da75b0919 100644 --- a/app/widget/CMakeLists.txt +++ b/app/widget/CMakeLists.txt @@ -15,8 +15,10 @@ # along with this program. If not, see . add_subdirectory(audiomonitor) +add_subdirectory(clickablelabel) add_subdirectory(columnedgridlayout) add_subdirectory(flowlayout) +add_subdirectory(focusablelineedit) add_subdirectory(footagecombobox) add_subdirectory(menu) add_subdirectory(nodeview) diff --git a/app/widget/clickablelabel/CMakeLists.txt b/app/widget/clickablelabel/CMakeLists.txt new file mode 100644 index 000000000..95a0c9d19 --- /dev/null +++ b/app/widget/clickablelabel/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2019 Olive Team +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set(OLIVE_SOURCES + ${OLIVE_SOURCES} + widget/clickablelabel/clickablelabel.h + widget/clickablelabel/clickablelabel.cpp + PARENT_SCOPE +) diff --git a/app/widget/clickablelabel/clickablelabel.cpp b/app/widget/clickablelabel/clickablelabel.cpp new file mode 100644 index 000000000..8c0b6258a --- /dev/null +++ b/app/widget/clickablelabel/clickablelabel.cpp @@ -0,0 +1,23 @@ +#include "clickablelabel.h" + +ClickableLabel::ClickableLabel(const QString &text, QWidget *parent) : + QLabel(text, parent) +{ +} + +ClickableLabel::ClickableLabel(QWidget *parent) : + QLabel(parent) +{ +} + +void ClickableLabel::mouseReleaseEvent(QMouseEvent *) +{ + if (underMouse()) { + emit MouseClicked(); + } +} + +void ClickableLabel::mouseDoubleClickEvent(QMouseEvent *) +{ + emit MouseDoubleClicked(); +} diff --git a/app/widget/clickablelabel/clickablelabel.h b/app/widget/clickablelabel/clickablelabel.h new file mode 100644 index 000000000..cc11f11a7 --- /dev/null +++ b/app/widget/clickablelabel/clickablelabel.h @@ -0,0 +1,23 @@ +#ifndef CLICKABLELABEL_H +#define CLICKABLELABEL_H + +#include + +class ClickableLabel : public QLabel +{ + Q_OBJECT +public: + ClickableLabel(const QString& text, QWidget* parent = nullptr); + ClickableLabel(QWidget* parent = nullptr); + +protected: + virtual void mouseReleaseEvent(QMouseEvent* event) override; + virtual void mouseDoubleClickEvent(QMouseEvent* event) override; + +signals: + void MouseClicked(); + void MouseDoubleClicked(); + +}; + +#endif // CLICKABLELABEL_H diff --git a/app/widget/focusablelineedit/CMakeLists.txt b/app/widget/focusablelineedit/CMakeLists.txt new file mode 100644 index 000000000..7ca836d05 --- /dev/null +++ b/app/widget/focusablelineedit/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2019 Olive Team +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set(OLIVE_SOURCES + ${OLIVE_SOURCES} + widget/focusablelineedit/focusablelineedit.h + widget/focusablelineedit/focusablelineedit.cpp + PARENT_SCOPE +) diff --git a/app/widget/slider/sliderlineedit.cpp b/app/widget/focusablelineedit/focusablelineedit.cpp similarity index 84% rename from app/widget/slider/sliderlineedit.cpp rename to app/widget/focusablelineedit/focusablelineedit.cpp index 99ef499da..82ef516f5 100644 --- a/app/widget/slider/sliderlineedit.cpp +++ b/app/widget/focusablelineedit/focusablelineedit.cpp @@ -18,17 +18,17 @@ ***/ -#include "sliderlineedit.h" +#include "focusablelineedit.h" #include -SliderLineEdit::SliderLineEdit(QWidget *parent) : +FocusableLineEdit::FocusableLineEdit(QWidget *parent) : QLineEdit(parent) { } -void SliderLineEdit::keyPressEvent(QKeyEvent *e) +void FocusableLineEdit::keyPressEvent(QKeyEvent *e) { switch (e->key()) { case Qt::Key_Return: @@ -43,7 +43,7 @@ void SliderLineEdit::keyPressEvent(QKeyEvent *e) } } -void SliderLineEdit::focusOutEvent(QFocusEvent *e) +void FocusableLineEdit::focusOutEvent(QFocusEvent *e) { QLineEdit::focusOutEvent(e); diff --git a/app/widget/slider/sliderlineedit.h b/app/widget/focusablelineedit/focusablelineedit.h similarity index 91% rename from app/widget/slider/sliderlineedit.h rename to app/widget/focusablelineedit/focusablelineedit.h index f2c0ed57c..08064d55a 100644 --- a/app/widget/slider/sliderlineedit.h +++ b/app/widget/focusablelineedit/focusablelineedit.h @@ -23,11 +23,11 @@ #include -class SliderLineEdit : public QLineEdit +class FocusableLineEdit : public QLineEdit { Q_OBJECT public: - SliderLineEdit(QWidget* parent); + FocusableLineEdit(QWidget* parent = nullptr); signals: void Confirmed(); diff --git a/app/widget/slider/CMakeLists.txt b/app/widget/slider/CMakeLists.txt index 37bd57931..c1835634b 100644 --- a/app/widget/slider/CMakeLists.txt +++ b/app/widget/slider/CMakeLists.txt @@ -24,8 +24,6 @@ set(OLIVE_SOURCES widget/slider/sliderbase.cpp widget/slider/sliderlabel.h widget/slider/sliderlabel.cpp - widget/slider/sliderlineedit.h - widget/slider/sliderlineedit.cpp widget/slider/stringslider.h widget/slider/stringslider.cpp widget/slider/timeslider.h diff --git a/app/widget/slider/sliderbase.cpp b/app/widget/slider/sliderbase.cpp index 06002b406..700c9d172 100644 --- a/app/widget/slider/sliderbase.cpp +++ b/app/widget/slider/sliderbase.cpp @@ -40,7 +40,7 @@ SliderBase::SliderBase(Mode mode, QWidget *parent) : addWidget(label_); - editor_ = new SliderLineEdit(this); + editor_ = new FocusableLineEdit(this); addWidget(editor_); connect(label_, SIGNAL(drag_start()), this, SLOT(LabelPressed())); diff --git a/app/widget/slider/sliderbase.h b/app/widget/slider/sliderbase.h index 1c50aee4b..25ec8570a 100644 --- a/app/widget/slider/sliderbase.h +++ b/app/widget/slider/sliderbase.h @@ -24,7 +24,7 @@ #include #include "sliderlabel.h" -#include "sliderlineedit.h" +#include "widget/focusablelineedit/focusablelineedit.h" class SliderBase : public QStackedWidget { @@ -73,7 +73,7 @@ private: SliderLabel* label_; - SliderLineEdit* editor_; + FocusableLineEdit* editor_; QVariant value_;