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