diff --git a/plugins/notifications/CMakeLists.txt b/plugins/notifications/CMakeLists.txt index a3932a4ba..86f962c54 100644 --- a/plugins/notifications/CMakeLists.txt +++ b/plugins/notifications/CMakeLists.txt @@ -7,6 +7,8 @@ set(kdeconnect_notifications_SRCS sendreplydialog.cpp ) +ki18n_wrap_ui(kdeconnect_notifications_SRCS sendreplydialog.ui) + kdeconnect_add_plugin(kdeconnect_notifications JSON kdeconnect_notifications.json SOURCES ${kdeconnect_notifications_SRCS}) target_link_libraries(kdeconnect_notifications diff --git a/plugins/notifications/notificationsdbusinterface.cpp b/plugins/notifications/notificationsdbusinterface.cpp index d6cb3cfc5..c64409ae6 100644 --- a/plugins/notifications/notificationsdbusinterface.cpp +++ b/plugins/notifications/notificationsdbusinterface.cpp @@ -160,6 +160,7 @@ void NotificationsDbusInterface::replyRequested(Notification* noti) SendReplyDialog* dialog = new SendReplyDialog(originalMessage, replyId, appName); connect(dialog, &SendReplyDialog::sendReply, this, &NotificationsDbusInterface::sendReply); dialog->show(); + dialog->raise(); } void NotificationsDbusInterface::sendReply(const QString& replyId, const QString& message) diff --git a/plugins/notifications/sendreplydialog.cpp b/plugins/notifications/sendreplydialog.cpp index e40c2170a..3ed59ac47 100644 --- a/plugins/notifications/sendreplydialog.cpp +++ b/plugins/notifications/sendreplydialog.cpp @@ -27,34 +27,30 @@ #include +#include "ui_sendreplydialog.h" + SendReplyDialog::SendReplyDialog(const QString& originalMessage, const QString& replyId, const QString& topicName, QWidget* parent) : QDialog(parent) , mReplyId(replyId) + , m_ui(new Ui::SendReplyDialog) { - QVBoxLayout* layout = new QVBoxLayout; + m_ui->setupUi(this); + m_ui->textView->setText(topicName + ": \n" + originalMessage); - QTextEdit* textView = new QTextEdit(this); - textView->setReadOnly(true); - textView->setText(topicName + ": \n" + originalMessage); - layout->addWidget(textView); + auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok); + button->setText(i18n("Send")); - mTextEdit = new QTextEdit(this); - layout->addWidget(mTextEdit); - - QPushButton* sendButton = new QPushButton(i18n("Send"), this); - connect(sendButton, &QAbstractButton::clicked, this, &SendReplyDialog::sendButtonClicked); - layout->addWidget(sendButton); - - setLayout(layout); + connect(this, &QDialog::accepted, this, &SendReplyDialog::sendButtonClicked); setWindowTitle(topicName); setWindowIcon(QIcon::fromTheme(QStringLiteral("kdeconnect"))); setAttribute(Qt::WA_DeleteOnClose); } +SendReplyDialog::~SendReplyDialog() = default; void SendReplyDialog::sendButtonClicked() { - Q_EMIT sendReply(mReplyId, mTextEdit->toPlainText()); + Q_EMIT sendReply(mReplyId, m_ui->replyEdit->toPlainText()); close(); } diff --git a/plugins/notifications/sendreplydialog.h b/plugins/notifications/sendreplydialog.h index 8540d5a5a..086773c14 100644 --- a/plugins/notifications/sendreplydialog.h +++ b/plugins/notifications/sendreplydialog.h @@ -24,9 +24,7 @@ #include #include -class QTextEdit; -class QLineEdit; -class QPushButton; +namespace Ui { class SendReplyDialog; } class SendReplyDialog : public QDialog { @@ -34,6 +32,7 @@ class SendReplyDialog : public QDialog public: explicit SendReplyDialog(const QString& originalMessage, const QString& replyId, const QString& topicName, QWidget *parent = nullptr); + ~SendReplyDialog() override; QSize sizeHint() const override; private Q_SLOTS: @@ -43,8 +42,8 @@ Q_SIGNALS: void sendReply(const QString& replyId, const QString& messageBody); private: - QString mReplyId; - QTextEdit *mTextEdit; + const QString mReplyId; + const QScopedPointer m_ui; }; #endif diff --git a/plugins/notifications/sendreplydialog.ui b/plugins/notifications/sendreplydialog.ui new file mode 100644 index 000000000..07db50b40 --- /dev/null +++ b/plugins/notifications/sendreplydialog.ui @@ -0,0 +1,74 @@ + + + SendReplyDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + Qt::NoFocus + + + true + + + + + + + + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + SendReplyDialog + accept() + + + 82 + 274 + + + 2 + 279 + + + + + buttonBox + rejected() + SendReplyDialog + reject() + + + 149 + 284 + + + 143 + 298 + + + + +