Commit 824eac22 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Improvements on the SendReplyDialog

Use a designer file for it
Make sure the focus is on the reply widget
Disable focus from the original text
raise() the dialog when we show it to make sure it's over the other windows
parent 9e0d4874
......@@ -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
......
......@@ -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)
......
......@@ -27,34 +27,30 @@
#include <KLocalizedString>
#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;
QTextEdit* textView = new QTextEdit(this);
textView->setReadOnly(true);
textView->setText(topicName + ": \n" + originalMessage);
layout->addWidget(textView);
mTextEdit = new QTextEdit(this);
layout->addWidget(mTextEdit);
m_ui->setupUi(this);
m_ui->textView->setText(topicName + ": \n" + originalMessage);
QPushButton* sendButton = new QPushButton(i18n("Send"), this);
connect(sendButton, &QAbstractButton::clicked, this, &SendReplyDialog::sendButtonClicked);
layout->addWidget(sendButton);
auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok);
button->setText(i18n("Send"));
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();
}
......
......@@ -24,9 +24,7 @@
#include <QDialog>
#include <QSize>
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<Ui::SendReplyDialog> m_ui;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SendReplyDialog</class>
<widget class="QDialog" name="SendReplyDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextEdit" name="textView">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="replyEdit"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SendReplyDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>82</x>
<y>274</y>
</hint>
<hint type="destinationlabel">
<x>2</x>
<y>279</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SendReplyDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>149</x>
<y>284</y>
</hint>
<hint type="destinationlabel">
<x>143</x>
<y>298</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment