2017-10-01 19:09:42 +00:00
|
|
|
#include "CommentsDialog.h"
|
|
|
|
#include "ui_CommentsDialog.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
CommentsDialog::CommentsDialog(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::CommentsDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2017-03-31 00:51:14 +00:00
|
|
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
2017-12-10 18:13:37 +00:00
|
|
|
|
|
|
|
// Event filter for capturing Ctrl/Cmd+Return
|
|
|
|
ui->textEdit->installEventFilter(this);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-10-02 09:41:28 +00:00
|
|
|
CommentsDialog::~CommentsDialog() {}
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
void CommentsDialog::on_buttonBox_accepted()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CommentsDialog::on_buttonBox_rejected()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
QString CommentsDialog::getComment()
|
|
|
|
{
|
2017-12-10 18:13:37 +00:00
|
|
|
QString ret = ui->textEdit->document()->toPlainText();
|
2017-03-29 10:18:37 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2017-12-01 10:46:13 +00:00
|
|
|
|
|
|
|
void CommentsDialog::setComment(const QString &comment)
|
|
|
|
{
|
2017-12-10 18:13:37 +00:00
|
|
|
ui->textEdit->document()->setPlainText(comment);
|
|
|
|
}
|
|
|
|
|
2017-12-14 19:51:24 +00:00
|
|
|
bool CommentsDialog::eventFilter(QObject */*obj*/, QEvent *event)
|
2017-12-10 18:13:37 +00:00
|
|
|
{
|
|
|
|
if(event -> type() == QEvent::KeyPress)
|
|
|
|
{
|
|
|
|
QKeyEvent *keyEvent = static_cast <QKeyEvent*> (event);
|
|
|
|
|
|
|
|
// Confirm comment by pressing Ctrl/Cmd+Return
|
|
|
|
if((keyEvent -> modifiers() & Qt::ControlModifier) &&
|
|
|
|
((keyEvent -> key() == Qt::Key_Enter) || (keyEvent -> key() == Qt::Key_Return)))
|
|
|
|
{
|
|
|
|
this->accept();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|