Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 817075f6 authored by Vijay Krishnavanshi's avatar Vijay Krishnavanshi Committed by Pali Rohár

Ported contact notes plugin to KF5 and adapted slot and signal to Qt5

parent d41679c9
......@@ -22,25 +22,35 @@
#include <KLocalizedString>
#include <QVBoxLayout>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
#include "kopetemetacontact.h"
#include "contactnotesplugin.h"
ContactNotesEdit::ContactNotesEdit(Kopete::MetaContact *m, ContactNotesPlugin *p)
: KDialog()
: QDialog()
{
setCaption(i18n("Contact Notes"));
setButtons(KDialog::Ok | KDialog::Cancel);
setDefaultButton(KDialog::Ok);
setWindowTitle(i18n("Contact Notes"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &ContactNotesEdit::slotOkButtonClicked);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
m_plugin = p;
m_metaContact = m;
QWidget *w = new QWidget(this);
QVBoxLayout *wVBoxLayout = new QVBoxLayout(w);
wVBoxLayout->setMargin(0);
wVBoxLayout->setSpacing(KDialog::spacingHint());
m_label = new QLabel(i18n("Notes about %1:", m->displayName()), w);
wVBoxLayout->addWidget(m_label);
m_label->setObjectName(QStringLiteral("m_label"));
......@@ -49,18 +59,15 @@ ContactNotesEdit::ContactNotesEdit(Kopete::MetaContact *m, ContactNotesPlugin *p
m_linesEdit->setText(p->notes(m));
showButtonSeparator(true);
setMainWidget(w);
mainLayout->addWidget(w);
mainLayout->addWidget(buttonBox);
}
ContactNotesEdit::~ContactNotesEdit()
{
}
void ContactNotesEdit::slotButtonClicked(int buttonCode)
void ContactNotesEdit::slotOkButtonClicked()
{
KDialog::slotButtonClicked(buttonCode);
if (buttonCode == KDialog::Ok) {
emit notesChanged(m_linesEdit->toPlainText(), m_metaContact);
}
emit notesChanged(m_linesEdit->toPlainText(), m_metaContact);
}
......@@ -21,7 +21,7 @@
#include <qwidget.h>
#include <qstring.h>
#include <QLabel>
#include <kdialog.h>
#include <QDialog>
class QLabel;
class QTextEdit;
......@@ -34,11 +34,11 @@ class ContactNotesPlugin;
*@author Olivier Goffart
*/
class ContactNotesEdit : public KDialog
class ContactNotesEdit : public QDialog
{
Q_OBJECT
public:
explicit ContactNotesEdit(Kopete::MetaContact *m, ContactNotesPlugin *p = 0);
explicit ContactNotesEdit(Kopete::MetaContact *m, ContactNotesPlugin *p = nullptr);
~ContactNotesEdit();
private:
......@@ -49,7 +49,7 @@ private:
QTextEdit *m_linesEdit;
protected Q_SLOTS: // Protected slots
void slotButtonClicked(int buttonCode) Q_DECL_OVERRIDE;
void slotOkButtonClicked();
Q_SIGNALS: // Signals
void notesChanged(const QString &, Kopete::MetaContact *);
};
......
......@@ -44,9 +44,9 @@ ContactNotesPlugin::ContactNotesPlugin(QObject *parent, const QVariantList & /*
setComponentName(QStringLiteral("contactnotes"), i18n("Kopete"));
QAction *m_actionEdit = new QAction(QIcon::fromTheme(QStringLiteral("user-identity")), i18n("&Notes"), this);
actionCollection()->addAction(QStringLiteral("editContactNotes"), m_actionEdit);
connect(m_actionEdit, SIGNAL(triggered(bool)), this, SLOT(slotEditInfo()));
connect(m_actionEdit, &QAction::triggered, this, &ContactNotesPlugin::slotEditInfo);
connect(Kopete::ContactList::self(), SIGNAL(metaContactSelected(bool)), m_actionEdit, SLOT(setEnabled(bool)));
connect(Kopete::ContactList::self(), &Kopete::ContactList::metaContactSelected, m_actionEdit, &QAction::setEnabled);
m_actionEdit->setEnabled(Kopete::ContactList::self()->selectedMetaContacts().count() == 1);
setXMLFile(QStringLiteral("contactnotesui.rc"));
......@@ -71,8 +71,7 @@ void ContactNotesPlugin::slotEditInfo()
return;
}
ContactNotesEdit *e = new ContactNotesEdit(m, this);
connect(e, SIGNAL(notesChanged(QString,Kopete::MetaContact *)), this,
SLOT(setNotes(QString,Kopete::MetaContact *)));
connect(e, &ContactNotesEdit::notesChanged, this, &ContactNotesPlugin::setNotes);
e->show();
}
......
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