Commit 82f62923 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move info in a dialog directly

parent 4555f104
......@@ -19,7 +19,6 @@
#include "sieveeditortextmodewidget.h"
#include "templates/sievetemplatewidget.h"
#include "autocreatescripts/autocreatescriptdialog.h"
#include "editor/sieveinfowidget.h"
#include "editor/sievetextedit.h"
#include "editor/warningwidget/sieveeditorwarning.h"
#include "editor/warningwidget/sieveeditorparsingmissingfeaturewarning.h"
......@@ -74,13 +73,11 @@ SieveEditorTextModeWidget::SieveEditorTextModeWidget(QWidget *parent)
//
mSieveTemplateWidget = new SieveTemplateWidget(i18n("Sieve Template:"));
mSieveInfo = new SieveInfoWidget;
mExtraSplitter = new QSplitter;
mExtraSplitter->setOrientation(Qt::Vertical);
mExtraSplitter->addWidget(mSieveTemplateWidget);
mExtraSplitter->addWidget(mSieveInfo);
mExtraSplitter->setChildrenCollapsible(false);
QWidget *textEditWidget = new QWidget;
......@@ -177,6 +174,11 @@ void SieveEditorTextModeWidget::writeConfig()
group.writeEntry("templateSplitter", mTemplateSplitter->sizes());
}
QStringList SieveEditorTextModeWidget::sieveCapabilities() const
{
return mSieveCapabilities;
}
SieveEditorTabWidget *SieveEditorTextModeWidget::tabWidget() const
{
return mTabWidget;
......@@ -488,7 +490,6 @@ void SieveEditorTextModeWidget::setSieveCapabilities(const QStringList &capabili
mSieveCapabilities = capabilities;
mTextEdit->setSieveCapabilities(mSieveCapabilities);
mSieveTemplateWidget->setSieveCapabilities(mSieveCapabilities);
mSieveInfo->setServerInfo(capabilities);
}
void SieveEditorTextModeWidget::showEditorWarning()
......
......@@ -32,7 +32,6 @@ class TextToSpeechWidget;
}
namespace KSieveUi {
class SieveInfoWidget;
class SieveTextEdit;
class SieveEditorWarning;
class SieveEditorParsingMissingFeatureWarning;
......@@ -105,6 +104,8 @@ public:
Q_REQUIRED_RESULT SieveEditorTabWidget *tabWidget() const;
void setListOfIncludeFile(const QStringList &listOfIncludeFile);
Q_REQUIRED_RESULT QStringList sieveCapabilities() const;
Q_SIGNALS:
void enableButtonOk(bool);
void switchToGraphicalMode();
......@@ -131,7 +132,6 @@ private:
KPIMTextEdit::PlainTextEditorWidget *mDebugTextEdit = nullptr;
KPIMTextEdit::PlainTextEditFindBar *mFindBar = nullptr;
KPIMTextEdit::TextToSpeechWidget *mTextToSpeechWidget = nullptr;
SieveInfoWidget *mSieveInfo = nullptr;
QSplitter *mMainSplitter = nullptr;
QSplitter *mExtraSplitter = nullptr;
QSplitter *mTemplateSplitter = nullptr;
......
......@@ -27,6 +27,7 @@
#include "autocreatescripts/sieveeditorgraphicalmodewidget.h"
#include "autocreatescripts/sievescriptparsingerrordialog.h"
#include "sieveeditormenubar.h"
#include "editor/sieveinfodialog.h"
#include <kns3/uploaddialog.h>
#include <KLocalizedString>
......@@ -97,6 +98,11 @@ SieveEditorWidget::SieveEditorWidget(bool useMenuBar, QWidget *parent)
purposeMenu->setEditorWidget(this);
toolbar->addAction(shareAction);
mServerInfo = new QAction(i18n("Server Info"), this);
connect(mServerInfo, &QAction::triggered, this, &SieveEditorWidget::slotServerInfo);
toolbar->addAction(mServerInfo);
SieveEditorMenuBar *menuBar = nullptr;
if (useMenuBar) {
menuBar = new SieveEditorMenuBar;
......@@ -741,3 +747,11 @@ bool SieveEditorWidget::printSupportEnabled() const
}
return false;
}
void SieveEditorWidget::slotServerInfo()
{
QPointer<SieveInfoDialog> dlg = new SieveInfoDialog(this);
dlg->setServerInfo(mTextModeWidget->sieveCapabilities());
dlg->exec();
delete dlg;
}
......@@ -132,6 +132,7 @@ private:
void changeSwitchButtonText();
void changeMode(EditorMode mode);
void addMessageEntry(const QString &errorMsg, const QColor &color);
void slotServerInfo();
QString mOriginalScript;
SieveEditorTextModeWidget *mTextModeWidget = nullptr;
SieveEditorGraphicalModeWidget *mGraphicalModeWidget = nullptr;
......@@ -143,6 +144,7 @@ private:
QAction *mSaveAs = nullptr;
QAction *mShareScript = nullptr;
QAction *mGenerateXml = nullptr;
QAction *mServerInfo = nullptr;
EditorMode mMode = EditorMode::TextMode;
bool mModified = false;
bool mDebug = false;
......
......@@ -39,10 +39,15 @@ SieveInfoDialog::SieveInfoDialog(QWidget *parent)
QDialogButtonBox *button = new QDialogButtonBox(QDialogButtonBox::Close, this);
button->setObjectName(QStringLiteral("button"));
mainLayout->addWidget(button);
connect(button, &QDialogButtonBox::accepted, this, &SieveInfoDialog::accept);
connect(button, &QDialogButtonBox::rejected, this, &SieveInfoDialog::reject);
}
SieveInfoDialog::~SieveInfoDialog()
{
}
void SieveInfoDialog::setServerInfo(const QStringList &serverInfos)
{
mSieveInfoWidget->setServerInfo(serverInfos);
}
......@@ -31,6 +31,7 @@ class KSIEVEUI_EXPORT SieveInfoDialog : public QDialog
public:
explicit SieveInfoDialog(QWidget *parent = nullptr);
~SieveInfoDialog();
void setServerInfo(const QStringList &serverInfos);
private:
SieveInfoWidget *mSieveInfoWidget = nullptr;
};
......
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