Commit 85d10ae0 authored by Volker Krause's avatar Volker Krause

Port away from KDialog

parent 89a4545a
......@@ -19,6 +19,7 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#include "../src/individualmaildialog.h"
#include <KGuiItem>
#include <QObject>
#include <qtest.h>
......
......@@ -224,7 +224,7 @@ void IndividualMailITIPHandlerDialogDelegate::openDialogIncidenceDeleted(Recipie
void IndividualMailITIPHandlerDialogDelegate::onDialogClosed(int result)
{
if (result == KDialog::Yes) {
if (result == QDialogButtonBox::Yes) {
Q_EMIT setEdit(mIncidence, mDialog->editAttendees());
Q_EMIT setUpdate(mIncidence, mDialog->updateAttendees());
Q_EMIT dialogClosed(KMessageBox::Yes, mMethod, mIncidence);
......
......@@ -22,26 +22,24 @@
#include "individualmaildialog.h"
#include <KGuiItem>
#include <KLocalizedString>
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QComboBox>
#include <QLabel>
#include <QPushButton>
using namespace IncidenceEditorNG;
IndividualMailDialog::IndividualMailDialog(const QString &question, const KCalCore::Attendee::List &attendees,
const KGuiItem &buttonYes, const KGuiItem &buttonNo, QWidget *parent)
: KDialog(parent)
: QDialog(parent)
{
setCaption(i18nc("@title:window", "Group Scheduling Email"));
setButtons(KDialog::Yes | KDialog::No | KDialog::Details);
setButtonText(KDialog::Details, i18nc("@action:button show list of attendees", "Individual mailsettings"));
setButtonGuiItem(KDialog::Yes, buttonYes);
setButtonGuiItem(KDialog::No, buttonNo);
QWidget *widget = new QWidget();
QGridLayout *layout = new QGridLayout(widget);
setWindowTitle(i18nc("@title:window", "Group Scheduling Email"));
m_detailsWidget = new QWidget();
QGridLayout *layout = new QGridLayout(m_detailsWidget);
int row = 0;
for (const KCalCore::Attendee::Ptr &attendee : attendees) {
QComboBox *options = new QComboBox();
......@@ -54,15 +52,37 @@ IndividualMailDialog::IndividualMailDialog(const QString &question, const KCalCo
layout->addWidget(options, row, 1);
++row;
}
QSizePolicy sizePolicy = widget->sizePolicy();
QSizePolicy sizePolicy = m_detailsWidget->sizePolicy();
sizePolicy.setHorizontalStretch(1);
sizePolicy.setVerticalStretch(1);
widget->setSizePolicy(sizePolicy);
m_detailsWidget->setSizePolicy(sizePolicy);
QWidget *mW = new QLabel(question);
setMainWidget(mW);
setDetailsWidget(widget);
auto topLayout = new QVBoxLayout(this);
topLayout->addWidget(mW);
topLayout->addWidget(m_detailsWidget);
m_buttons = new QDialogButtonBox;
m_buttons->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Help);
auto yesButton = m_buttons->button(QDialogButtonBox::Yes);
yesButton->setText(buttonYes.text());
connect(yesButton, &QPushButton::clicked, this, [this]() { done(QDialogButtonBox::Yes); });
auto noButton = m_buttons->button(QDialogButtonBox::No);
noButton->setText(buttonNo.text());
connect(noButton, &QPushButton::clicked, this, [this]() { done(QDialogButtonBox::No); });
auto detailsButton = m_buttons->button(QDialogButtonBox::Help);
detailsButton->setIcon(QIcon::fromTheme(QLatin1String("help-about")));
connect(detailsButton, &QPushButton::clicked, this, [this]() {
m_detailsWidget->setVisible(!m_detailsWidget->isVisible());
updateButtonState();
adjustSize();
});
m_detailsWidget->setVisible(false);
updateButtonState();
topLayout->addWidget(m_buttons);
setLayout(topLayout);
}
IndividualMailDialog::~IndividualMailDialog()
......@@ -93,3 +113,12 @@ KCalCore::Attendee::List IndividualMailDialog::updateAttendees() const
}
return update;
}
void IndividualMailDialog::updateButtonState()
{
auto detailsButton = m_buttons->button(QDialogButtonBox::Help);
if (m_detailsWidget->isVisible())
detailsButton->setText(i18nc("@action:button show list of attendees", "Individual mailsettings <<"));
else
detailsButton->setText(i18nc("@action:button show list of attendees", "Individual mailsettings >>"));
}
......@@ -24,9 +24,12 @@
#define INCIDENCEEDITOR_INDIVIDUALMAILDIALOG_H
#include <KCalCore/Attendee>
#include <KDialog>
#include <QDialog>
#include <QComboBox>
#include <QDialogButtonBox>
class KGuiItem;
class TestIndividualMailDialog;
......@@ -35,7 +38,7 @@ namespace IncidenceEditorNG
// Shows a dialog with a question and the option to select which attendee should get the mail or to open a composer for him.
// Used to get individual mails for attendees of an event.
class IndividualMailDialog : public KDialog
class IndividualMailDialog : public QDialog
{
Q_OBJECT
friend class ::TestIndividualMailDialog;
......@@ -53,7 +56,11 @@ public:
KCalCore::Attendee::List updateAttendees() const;
private:
void updateButtonState();
QHash<KCalCore::Attendee::Ptr, QComboBox *> mAttendeeDecision;
QDialogButtonBox *m_buttons;
QWidget *m_detailsWidget;
};
}
......
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