diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index 7cb2c01..b0ccdee 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -45,7 +45,8 @@ SOURCES += main.cpp\ aoevidencebutton.cpp \ charselect.cpp \ aotextarea.cpp \ - aolineedit.cpp + aolineedit.cpp \ + aotextedit.cpp HEADERS += lobby.h \ aoimage.h \ @@ -72,7 +73,8 @@ HEADERS += lobby.h \ aoblipplayer.h \ aoevidencebutton.h \ aotextarea.h \ - aolineedit.h + aolineedit.h \ + aotextedit.h unix:LIBS += -L$$PWD -lbass win32:LIBS += "$$PWD/bass.dll" diff --git a/aotextedit.cpp b/aotextedit.cpp new file mode 100644 index 0000000..580067b --- /dev/null +++ b/aotextedit.cpp @@ -0,0 +1,21 @@ +#include "aotextedit.h" + +AOTextEdit::AOTextEdit(QWidget *parent) : QPlainTextEdit(parent) +{ + this->setReadOnly(true); + + connect(this, SIGNAL(returnPressed()), this, SLOT(on_enter_pressed())); +} + +void AOTextEdit::mouseDoubleClickEvent(QMouseEvent *e) +{ + QPlainTextEdit::mouseDoubleClickEvent(e); + + this->setReadOnly(false); +} + +void AOTextEdit::on_enter_pressed() +{ + this->setReadOnly(true); +} + diff --git a/aotextedit.h b/aotextedit.h new file mode 100644 index 0000000..85909c6 --- /dev/null +++ b/aotextedit.h @@ -0,0 +1,23 @@ +#ifndef AOTEXTEDIT_H +#define AOTEXTEDIT_H + +#include + +class AOTextEdit : public QPlainTextEdit +{ + Q_OBJECT +public: + AOTextEdit(QWidget *parent); + +protected: + void mouseDoubleClickEvent(QMouseEvent *e); + +signals: + void double_clicked(); + +private slots: + void on_enter_pressed(); + +}; + +#endif // AOTEXTEDIT_H diff --git a/courtroom.h b/courtroom.h index e41ae28..ec78f89 100644 --- a/courtroom.h +++ b/courtroom.h @@ -15,6 +15,7 @@ #include "aoevidencebutton.h" #include "aotextarea.h" #include "aolineedit.h" +#include "aotextedit.h" #include "datatypes.h" #include @@ -303,7 +304,7 @@ private: AOButton *ui_evidence_right; AOImage *ui_evidence_overlay; AOButton *ui_evidence_x; - QPlainTextEdit *ui_evidence_description; + AOTextEdit *ui_evidence_description; AOImage *ui_char_select_background; diff --git a/evidence.cpp b/evidence.cpp index e653a34..aeaa2b2 100644 --- a/evidence.cpp +++ b/evidence.cpp @@ -23,8 +23,7 @@ void Courtroom::construct_evidence() ui_evidence_x = new AOButton(ui_evidence_overlay, ao_app); ui_evidence_x->setText("X"); - ui_evidence_description = new QPlainTextEdit(ui_evidence_overlay); - ui_evidence_description->setReadOnly(true); + ui_evidence_description = new AOTextEdit(ui_evidence_overlay); ui_evidence_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" "color: white;");