Commit 32781ff3 authored by Laurent Montel's avatar Laurent Montel 😁

Fix enable/disable undo/redo action

parent da52d197
......@@ -96,6 +96,8 @@ void SieveEditorMainWidget::slotCreateScriptPage(const KUrl &url, const QStringL
connect(editor, SIGNAL(refreshList()), this, SIGNAL(updateScriptList()));
connect(editor, SIGNAL(scriptModified(bool,SieveEditorPageWidget*)), this, SLOT(slotScriptModified(bool,SieveEditorPageWidget*)));
connect(editor, SIGNAL(modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode)), SIGNAL(modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode)));
connect(editor, SIGNAL(undoAvailable(bool)), SIGNAL(undoAvailable(bool)));
connect(editor, SIGNAL(redoAvailable(bool)), SIGNAL(redoAvailable(bool)));
editor->setIsNewScript(isNewScript);
editor->loadScript(url, capabilities);
mTabWidget->addTab(editor, url.fileName());
......
......@@ -60,6 +60,9 @@ Q_SIGNALS:
void updateScriptList();
void modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode);
void serverSieveFound(bool);
void undoAvailable(bool);
void redoAvailable(bool);
private slots:
void slotCreateScriptPage(const KUrl &url, const QStringList &capabilities, bool isNewScript);
......
......@@ -58,6 +58,8 @@ SieveEditorMainWindow::SieveEditorMainWindow()
this, SLOT(slotSystemNetworkStatusChanged(Solid::Networking::Status)) );
connect(mMainWidget->sieveEditorMainWidget()->tabWidget(), SIGNAL(currentChanged(int)), SLOT(slotUpdateActions()));
connect(mMainWidget->sieveEditorMainWidget(), SIGNAL(modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode)), SLOT(slotUpdateActions()));
connect(mMainWidget->sieveEditorMainWidget(), SIGNAL(undoAvailable(bool)), SLOT(slotUndoAvailable(bool)));
connect(mMainWidget->sieveEditorMainWidget(), SIGNAL(redoAvailable(bool)), SLOT(slotRedoAvailable(bool)));
const Solid::Networking::Status status = Solid::Networking::status();
slotSystemNetworkStatusChanged(status);
slotRefreshList();
......@@ -227,10 +229,24 @@ void SieveEditorMainWindow::slotUpdateActions()
mGoToLine->setEnabled(editActionEnabled);
mFindAction->setEnabled(editActionEnabled);
mReplaceAction->setEnabled(editActionEnabled);
mUndoAction->setEnabled(editActionEnabled /*&& mMainWidget->sieveEditorMainWidget()->isUndoAvailable()*/);
mRedoAction->setEnabled(editActionEnabled /*&& mMainWidget->sieveEditorMainWidget()->isRedoAvailable()*/);
mUndoAction->setEnabled(editActionEnabled && mMainWidget->sieveEditorMainWidget()->isUndoAvailable());
mRedoAction->setEnabled(editActionEnabled && mMainWidget->sieveEditorMainWidget()->isRedoAvailable());
mSaveScript->setEnabled(hasPage && !mNetworkIsDown);
mRefreshList->setEnabled(!mNetworkIsDown);
}
void SieveEditorMainWindow::slotUndoAvailable(bool b)
{
const bool hasPage = (mMainWidget->sieveEditorMainWidget()->tabWidget()->count()>0);
const bool editActionEnabled = (hasPage && mMainWidget->sieveEditorMainWidget()->pageMode() == KSieveUi::SieveEditorWidget::TextMode);
mUndoAction->setEnabled(editActionEnabled && b);
}
void SieveEditorMainWindow::slotRedoAvailable(bool b)
{
const bool hasPage = (mMainWidget->sieveEditorMainWidget()->tabWidget()->count()>0);
const bool editActionEnabled = (hasPage && mMainWidget->sieveEditorMainWidget()->pageMode() == KSieveUi::SieveEditorWidget::TextMode);
mRedoAction->setEnabled(editActionEnabled && b);
}
......@@ -49,6 +49,9 @@ private slots:
void slotSaveScript();
void slotSystemNetworkStatusChanged(Solid::Networking::Status status);
void slotUpdateActions();
void slotUndoAvailable(bool);
void slotRedoAvailable(bool);
private:
void initStatusBar();
void readConfig();
......
......@@ -41,6 +41,8 @@ SieveEditorPageWidget::SieveEditorPageWidget(QWidget *parent)
vbox->addWidget(mSieveEditorWidget);
connect(mSieveEditorWidget, SIGNAL(checkSyntax()), this, SLOT(slotCheckSyntaxClicked()));
connect(mSieveEditorWidget, SIGNAL(modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode)), SIGNAL(modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode)));
connect(mSieveEditorWidget, SIGNAL(undoAvailable(bool)), SIGNAL(undoAvailable(bool)));
connect(mSieveEditorWidget, SIGNAL(redoAvailable(bool)), SIGNAL(redoAvailable(bool)));
//qDebug()<<"SieveEditorPageWidget::SieveEditorPageWidget "<<this;
}
......
......@@ -57,6 +57,8 @@ Q_SIGNALS:
void refreshList();
void scriptModified(bool, SieveEditorPageWidget *);
void modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode);
void undoAvailable(bool);
void redoAvailable(bool);
private slots:
void slotGetResult(KManageSieve::SieveJob *, bool success, const QString &script, bool isActive);
......
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