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
This commit is contained in:
parent
9e0d4874c0
commit
824eac228e
5 changed files with 91 additions and 19 deletions
|
@ -7,6 +7,8 @@ set(kdeconnect_notifications_SRCS
|
||||||
sendreplydialog.cpp
|
sendreplydialog.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ki18n_wrap_ui(kdeconnect_notifications_SRCS sendreplydialog.ui)
|
||||||
|
|
||||||
kdeconnect_add_plugin(kdeconnect_notifications JSON kdeconnect_notifications.json SOURCES ${kdeconnect_notifications_SRCS})
|
kdeconnect_add_plugin(kdeconnect_notifications JSON kdeconnect_notifications.json SOURCES ${kdeconnect_notifications_SRCS})
|
||||||
|
|
||||||
target_link_libraries(kdeconnect_notifications
|
target_link_libraries(kdeconnect_notifications
|
||||||
|
|
|
@ -160,6 +160,7 @@ void NotificationsDbusInterface::replyRequested(Notification* noti)
|
||||||
SendReplyDialog* dialog = new SendReplyDialog(originalMessage, replyId, appName);
|
SendReplyDialog* dialog = new SendReplyDialog(originalMessage, replyId, appName);
|
||||||
connect(dialog, &SendReplyDialog::sendReply, this, &NotificationsDbusInterface::sendReply);
|
connect(dialog, &SendReplyDialog::sendReply, this, &NotificationsDbusInterface::sendReply);
|
||||||
dialog->show();
|
dialog->show();
|
||||||
|
dialog->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationsDbusInterface::sendReply(const QString& replyId, const QString& message)
|
void NotificationsDbusInterface::sendReply(const QString& replyId, const QString& message)
|
||||||
|
|
|
@ -27,34 +27,30 @@
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
|
#include "ui_sendreplydialog.h"
|
||||||
|
|
||||||
SendReplyDialog::SendReplyDialog(const QString& originalMessage, const QString& replyId, const QString& topicName, QWidget* parent)
|
SendReplyDialog::SendReplyDialog(const QString& originalMessage, const QString& replyId, const QString& topicName, QWidget* parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, mReplyId(replyId)
|
, 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);
|
auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
textView->setReadOnly(true);
|
button->setText(i18n("Send"));
|
||||||
textView->setText(topicName + ": \n" + originalMessage);
|
|
||||||
layout->addWidget(textView);
|
|
||||||
|
|
||||||
mTextEdit = new QTextEdit(this);
|
connect(this, &QDialog::accepted, this, &SendReplyDialog::sendButtonClicked);
|
||||||
layout->addWidget(mTextEdit);
|
|
||||||
|
|
||||||
QPushButton* sendButton = new QPushButton(i18n("Send"), this);
|
|
||||||
connect(sendButton, &QAbstractButton::clicked, this, &SendReplyDialog::sendButtonClicked);
|
|
||||||
layout->addWidget(sendButton);
|
|
||||||
|
|
||||||
setLayout(layout);
|
|
||||||
setWindowTitle(topicName);
|
setWindowTitle(topicName);
|
||||||
setWindowIcon(QIcon::fromTheme(QStringLiteral("kdeconnect")));
|
setWindowIcon(QIcon::fromTheme(QStringLiteral("kdeconnect")));
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SendReplyDialog::~SendReplyDialog() = default;
|
||||||
|
|
||||||
void SendReplyDialog::sendButtonClicked()
|
void SendReplyDialog::sendButtonClicked()
|
||||||
{
|
{
|
||||||
Q_EMIT sendReply(mReplyId, mTextEdit->toPlainText());
|
Q_EMIT sendReply(mReplyId, m_ui->replyEdit->toPlainText());
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,7 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
|
||||||
class QTextEdit;
|
namespace Ui { class SendReplyDialog; }
|
||||||
class QLineEdit;
|
|
||||||
class QPushButton;
|
|
||||||
|
|
||||||
class SendReplyDialog : public QDialog
|
class SendReplyDialog : public QDialog
|
||||||
{
|
{
|
||||||
|
@ -34,6 +32,7 @@ class SendReplyDialog : public QDialog
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SendReplyDialog(const QString& originalMessage, const QString& replyId, const QString& topicName, QWidget *parent = nullptr);
|
explicit SendReplyDialog(const QString& originalMessage, const QString& replyId, const QString& topicName, QWidget *parent = nullptr);
|
||||||
|
~SendReplyDialog() override;
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
@ -43,8 +42,8 @@ Q_SIGNALS:
|
||||||
void sendReply(const QString& replyId, const QString& messageBody);
|
void sendReply(const QString& replyId, const QString& messageBody);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mReplyId;
|
const QString mReplyId;
|
||||||
QTextEdit *mTextEdit;
|
const QScopedPointer<Ui::SendReplyDialog> m_ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
74
plugins/notifications/sendreplydialog.ui
Normal file
74
plugins/notifications/sendreplydialog.ui
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
<?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>
|
Loading…
Reference in a new issue