Commit 26c1d20f authored by Andrius Štikonas's avatar Andrius Štikonas

Port from KDialog to QDialog

RestoreDefaults button was non-fuctional in the current version, so remove it.
parent ff802a23
......@@ -23,10 +23,13 @@
#define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API
#include <libkdegamesprivate/kchatbase.h>
#include <KConfigGroup>
#include <KLocalizedString>
#include <QDialogButtonBox>
#include <QFontDialog>
#include <QFrame>
#include <QGridLayout>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
......@@ -60,25 +63,20 @@ class KChatDialogPrivate
};
KChatDialog::KChatDialog(KChatBase* chat, QWidget* parent, bool modal)
: KDialog(parent),
: QDialog(parent),
d( new KChatDialogPrivate )
{
setCaption(i18n("Configure Chat"));
setButtons(Ok|Default|Apply|Cancel);
setModal(modal);
init();
plugChatWidget(chat);
}
KChatDialog::KChatDialog(QWidget* parent, bool modal)
: KDialog(parent),
: QDialog(parent),
d( new KChatDialogPrivate )
{
setCaption(i18n("Configure Chat"));
setButtons(Ok|Default|Apply|Cancel);
setModal(modal);
init();
// init();
}
KChatDialog::~KChatDialog()
......@@ -89,9 +87,19 @@ KChatDialog::~KChatDialog()
void KChatDialog::init()
{
d->mTextPage = new QFrame( this );
setMainWidget( d->mTextPage );
QGridLayout* layout = new QGridLayout(d->mTextPage);
setWindowTitle(i18n("Configure Chat"));
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Apply);
QWidget *mainWidget = new QWidget(this);
setLayout(layout);
layout->addWidget(mainWidget);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &KChatDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &KChatDialog::reject);
// General fonts
QPushButton* nameFont = new QPushButton(i18n("Name Font..."), d->mTextPage);
connect(nameFont, &QPushButton::pressed, this, &KChatDialog::slotGetNameFont);
......@@ -138,8 +146,10 @@ void KChatDialog::init()
d->mMaxMessages = new QLineEdit(d->mTextPage);
d->mMaxMessages->setText(QString::number(-1));
layout->addWidget(d->mMaxMessages, 6, 1);
connect(this, &KChatDialog::applyClicked, this, &KChatDialog::slotApply);
connect(this, &KChatDialog::okClicked, this, &KChatDialog::slotOk);
layout->addWidget(buttonBox, 7, 0, 1, 2);
connect(buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KChatDialog::slotApply);
connect(okButton, &QPushButton::clicked, this, &KChatDialog::slotOk);
}
void KChatDialog::slotGetNameFont()
......@@ -229,7 +239,7 @@ void KChatDialog::configureChatWidget(KChatBase* widget)
void KChatDialog::slotOk()
{
slotApply();
KDialog::accept();
QDialog::accept();
}
void KChatDialog::slotApply()
......
......@@ -20,16 +20,18 @@
#ifndef __KCHATDIALOG_H__
#define __KCHATDIALOG_H__
#include <kdialog.h>
#include <QDialog>
class KChatBase;
class QDialogButtonBox;
class QVBoxLayout;
class KChatBase;
class KChatDialogPrivate;
/**
* \class KChatDialog kchatdialog.h <KChatDialog>
* */
class KChatDialog : public KDialog
class KChatDialog : public QDialog
{
Q_OBJECT
public:
......@@ -116,6 +118,8 @@ private:
private:
KChatDialogPrivate* const d;
QVBoxLayout* mainLayout;
QDialogButtonBox* buttonBox;
};
#endif
......@@ -89,7 +89,7 @@ public:
* @param g The KGame object of this game
* @param owner The KPlayer object who is responsible for this
* dialog, aka "the local player"
* @param title The title of the dialog - see KDialog::setCaption
* @param title The title of the dialog - see QDialog::setWindowTitle
* @param parent The parent of the dialog
* @param modal Whether the dialog is modal or not
* @param initConfigs whether the default KGameDialogConfig widgets
......
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