Merge branch 'master' into fix-call-bar
4 files changed, 85 insertions, 1 deletions
diff --git a/src/ui/NhekoDropArea.cpp b/src/ui/NhekoDropArea.cpp
new file mode 100644
index 00000000..14b71524
--- /dev/null
+++ b/src/ui/NhekoDropArea.cpp
@@ -0,0 +1,39 @@
+#include "NhekoDropArea.h"
+
+#include <QMimeData>
+
+#include "ChatPage.h"
+#include "timeline/InputBar.h"
+#include "timeline/TimelineModel.h"
+#include "timeline/TimelineViewManager.h"
+
+#include "Logging.h"
+
+NhekoDropArea::NhekoDropArea(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+ setFlags(ItemAcceptsDrops);
+}
+
+void
+NhekoDropArea::dragEnterEvent(QDragEnterEvent *event)
+{
+ event->acceptProposedAction();
+}
+
+void
+NhekoDropArea::dragMoveEvent(QDragMoveEvent *event)
+{
+ event->acceptProposedAction();
+}
+
+void
+NhekoDropArea::dropEvent(QDropEvent *event)
+{
+ if (event) {
+ auto model = ChatPage::instance()->timelineManager()->getHistoryView(roomid_);
+ if (model) {
+ model->input()->insertMimeData(event->mimeData());
+ }
+ }
+}
diff --git a/src/ui/NhekoDropArea.h b/src/ui/NhekoDropArea.h
new file mode 100644
index 00000000..b03620f2
--- /dev/null
+++ b/src/ui/NhekoDropArea.h
@@ -0,0 +1,30 @@
+#include <QQuickItem>
+
+class NhekoDropArea : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString roomid READ roomid WRITE setRoomid NOTIFY roomidChanged)
+public:
+ NhekoDropArea(QQuickItem *parent = nullptr);
+
+signals:
+ void roomidChanged(QString roomid);
+
+public slots:
+ void setRoomid(QString roomid)
+ {
+ if (roomid_ != roomid) {
+ roomid_ = roomid;
+ emit roomidChanged(roomid);
+ }
+ }
+ QString roomid() const { return roomid_; }
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event) override;
+ void dragMoveEvent(QDragMoveEvent *event) override;
+ void dropEvent(QDropEvent *event) override;
+
+private:
+ QString roomid_;
+};
diff --git a/src/ui/TextField.cpp b/src/ui/TextField.cpp
index 27584693..f717bcba 100644
--- a/src/ui/TextField.cpp
+++ b/src/ui/TextField.cpp
@@ -69,6 +69,18 @@ TextField::hasLabel() const
return show_label_;
}
+bool
+TextField::isValid() const
+{
+ return is_valid_;
+}
+
+void
+TextField::setValid(bool valid)
+{
+ is_valid_ = valid;
+}
+
void
TextField::setLabelFontSize(qreal size)
{
@@ -147,7 +159,7 @@ QColor
TextField::underlineColor() const
{
if (!underline_color_.isValid()) {
- if (hasAcceptableInput() || !isModified())
+ if ((hasAcceptableInput() && isValid()) || !isModified())
return QPalette().color(QPalette::Highlight);
else
return Qt::red;
diff --git a/src/ui/TextField.h b/src/ui/TextField.h
index 85d5036d..966155f4 100644
--- a/src/ui/TextField.h
+++ b/src/ui/TextField.h
@@ -30,6 +30,7 @@ public:
void setLabelFontSize(qreal size);
void setShowLabel(bool value);
void setUnderlineColor(const QColor &color);
+ void setValid(bool valid);
QColor inkColor() const;
QColor labelColor() const;
@@ -37,6 +38,7 @@ public:
QColor backgroundColor() const;
QString label() const;
bool hasLabel() const;
+ bool isValid() const;
qreal labelFontSize() const;
protected:
@@ -54,6 +56,7 @@ private:
TextFieldLabel *label_;
TextFieldStateMachine *state_machine_;
bool show_label_;
+ bool is_valid_;
qreal label_font_size_;
};
|