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 ...@@ -19,6 +19,7 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#include "../src/individualmaildialog.h" #include "../src/individualmaildialog.h"
#include <KGuiItem>
#include <QObject> #include <QObject>
#include <qtest.h> #include <qtest.h>
......
...@@ -224,7 +224,7 @@ void IndividualMailITIPHandlerDialogDelegate::openDialogIncidenceDeleted(Recipie ...@@ -224,7 +224,7 @@ void IndividualMailITIPHandlerDialogDelegate::openDialogIncidenceDeleted(Recipie
void IndividualMailITIPHandlerDialogDelegate::onDialogClosed(int result) void IndividualMailITIPHandlerDialogDelegate::onDialogClosed(int result)
{ {
if (result == KDialog::Yes) { if (result == QDialogButtonBox::Yes) {
Q_EMIT setEdit(mIncidence, mDialog->editAttendees()); Q_EMIT setEdit(mIncidence, mDialog->editAttendees());
Q_EMIT setUpdate(mIncidence, mDialog->updateAttendees()); Q_EMIT setUpdate(mIncidence, mDialog->updateAttendees());
Q_EMIT dialogClosed(KMessageBox::Yes, mMethod, mIncidence); Q_EMIT dialogClosed(KMessageBox::Yes, mMethod, mIncidence);
......
...@@ -22,26 +22,24 @@ ...@@ -22,26 +22,24 @@
#include "individualmaildialog.h" #include "individualmaildialog.h"
#include <KGuiItem>
#include <KLocalizedString> #include <KLocalizedString>
#include <QDialogButtonBox>
#include <QGridLayout> #include <QGridLayout>
#include <QComboBox> #include <QComboBox>
#include <QLabel> #include <QLabel>
#include <QPushButton>
using namespace IncidenceEditorNG; using namespace IncidenceEditorNG;
IndividualMailDialog::IndividualMailDialog(const QString &question, const KCalCore::Attendee::List &attendees, IndividualMailDialog::IndividualMailDialog(const QString &question, const KCalCore::Attendee::List &attendees,
const KGuiItem &buttonYes, const KGuiItem &buttonNo, QWidget *parent) const KGuiItem &buttonYes, const KGuiItem &buttonNo, QWidget *parent)
: KDialog(parent) : QDialog(parent)
{ {
setCaption(i18nc("@title:window", "Group Scheduling Email")); setWindowTitle(i18nc("@title:window", "Group Scheduling Email"));
setButtons(KDialog::Yes | KDialog::No | KDialog::Details); m_detailsWidget = new QWidget();
setButtonText(KDialog::Details, i18nc("@action:button show list of attendees", "Individual mailsettings")); QGridLayout *layout = new QGridLayout(m_detailsWidget);
setButtonGuiItem(KDialog::Yes, buttonYes);
setButtonGuiItem(KDialog::No, buttonNo);
QWidget *widget = new QWidget();
QGridLayout *layout = new QGridLayout(widget);
int row = 0; int row = 0;
for (const KCalCore::Attendee::Ptr &attendee : attendees) { for (const KCalCore::Attendee::Ptr &attendee : attendees) {
QComboBox *options = new QComboBox(); QComboBox *options = new QComboBox();
...@@ -54,15 +52,37 @@ IndividualMailDialog::IndividualMailDialog(const QString &question, const KCalCo ...@@ -54,15 +52,37 @@ IndividualMailDialog::IndividualMailDialog(const QString &question, const KCalCo
layout->addWidget(options, row, 1); layout->addWidget(options, row, 1);
++row; ++row;
} }
QSizePolicy sizePolicy = widget->sizePolicy(); QSizePolicy sizePolicy = m_detailsWidget->sizePolicy();
sizePolicy.setHorizontalStretch(1); sizePolicy.setHorizontalStretch(1);
sizePolicy.setVerticalStretch(1); sizePolicy.setVerticalStretch(1);
widget->setSizePolicy(sizePolicy); m_detailsWidget->setSizePolicy(sizePolicy);
QWidget *mW = new QLabel(question); QWidget *mW = new QLabel(question);
setMainWidget(mW); auto topLayout = new QVBoxLayout(this);
setDetailsWidget(widget); 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() IndividualMailDialog::~IndividualMailDialog()
...@@ -93,3 +113,12 @@ KCalCore::Attendee::List IndividualMailDialog::updateAttendees() const ...@@ -93,3 +113,12 @@ KCalCore::Attendee::List IndividualMailDialog::updateAttendees() const
} }
return update; 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 @@ ...@@ -24,9 +24,12 @@
#define INCIDENCEEDITOR_INDIVIDUALMAILDIALOG_H #define INCIDENCEEDITOR_INDIVIDUALMAILDIALOG_H
#include <KCalCore/Attendee> #include <KCalCore/Attendee>
#include <KDialog> #include <QDialog>
#include <QComboBox> #include <QComboBox>
#include <QDialogButtonBox>
class KGuiItem;
class TestIndividualMailDialog; class TestIndividualMailDialog;
...@@ -35,7 +38,7 @@ namespace IncidenceEditorNG ...@@ -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. // 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. // Used to get individual mails for attendees of an event.
class IndividualMailDialog : public KDialog class IndividualMailDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
friend class ::TestIndividualMailDialog; friend class ::TestIndividualMailDialog;
...@@ -53,7 +56,11 @@ public: ...@@ -53,7 +56,11 @@ public:
KCalCore::Attendee::List updateAttendees() const; KCalCore::Attendee::List updateAttendees() const;
private: private:
void updateButtonState();
QHash<KCalCore::Attendee::Ptr, QComboBox *> mAttendeeDecision; 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