Commit 39d277b7 authored by Laurent Montel's avatar Laurent Montel 😁

Add cut/paste/copy action too

parent 3446394f
......@@ -98,6 +98,7 @@ void SieveEditorMainWidget::slotCreateScriptPage(const KUrl &url, const QStringL
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)));
connect(editor, SIGNAL(copyAvailable(bool)), SIGNAL(copyAvailable(bool)));
editor->setIsNewScript(isNewScript);
editor->loadScript(url, capabilities);
mTabWidget->addTab(editor, url.fileName());
......@@ -191,6 +192,39 @@ bool SieveEditorMainWidget::isRedoAvailable() const
return false;
}
void SieveEditorMainWidget::slotCopy()
{
QWidget *w = mTabWidget->currentWidget();
if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) {
page->copy();
}
}
}
void SieveEditorMainWidget::slotPaste()
{
QWidget *w = mTabWidget->currentWidget();
if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) {
page->paste();
}
}
}
void SieveEditorMainWidget::slotCut()
{
QWidget *w = mTabWidget->currentWidget();
if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) {
page->cut();
}
}
}
void SieveEditorMainWidget::slotUndo()
{
QWidget *w = mTabWidget->currentWidget();
......
......@@ -55,6 +55,9 @@ public Q_SLOTS:
void slotReplace();
void slotFind();
void slotCopy();
void slotPaste();
void slotCut();
Q_SIGNALS:
void updateButtons(bool newScriptAction, bool editScriptAction, bool deleteScriptAction, bool desactivateScriptAction);
void updateScriptList();
......@@ -62,6 +65,7 @@ Q_SIGNALS:
void serverSieveFound(bool);
void undoAvailable(bool);
void redoAvailable(bool);
void copyAvailable(bool);
private slots:
......
......@@ -60,6 +60,7 @@ SieveEditorMainWindow::SieveEditorMainWindow()
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)));
connect(mMainWidget->sieveEditorMainWidget(), SIGNAL(copyAvailable(bool)), SLOT(slotCopyAvailable(bool)));
const Solid::Networking::Status status = Solid::Networking::status();
slotSystemNetworkStatusChanged(status);
slotRefreshList();
......@@ -157,6 +158,9 @@ void SieveEditorMainWindow::setupActions()
mReplaceAction = KStandardAction::replace(mMainWidget->sieveEditorMainWidget(), SLOT(slotReplace()), ac);
mUndoAction = KStandardAction::undo(mMainWidget->sieveEditorMainWidget(), SLOT(slotUndo()), ac);
mRedoAction = KStandardAction::redo(mMainWidget->sieveEditorMainWidget(), SLOT(slotRedo()), ac);
mCopyAction = KStandardAction::copy(mMainWidget->sieveEditorMainWidget(), SLOT(slotCopy()), ac);
mPasteAction = KStandardAction::paste(mMainWidget->sieveEditorMainWidget(), SLOT(slotPaste()), ac);
mCutAction = KStandardAction::cut(mMainWidget->sieveEditorMainWidget(), SLOT(slotCut()), ac);
}
void SieveEditorMainWindow::slotRefreshList()
......@@ -232,6 +236,10 @@ void SieveEditorMainWindow::slotUpdateActions()
mUndoAction->setEnabled(editActionEnabled && mMainWidget->sieveEditorMainWidget()->isUndoAvailable());
mRedoAction->setEnabled(editActionEnabled && mMainWidget->sieveEditorMainWidget()->isRedoAvailable());
mCopyAction->setEnabled(editActionEnabled);
mPasteAction->setEnabled(editActionEnabled); //FIXME
mCutAction->setEnabled(editActionEnabled);
mSaveScript->setEnabled(hasPage && !mNetworkIsDown);
mRefreshList->setEnabled(!mNetworkIsDown);
}
......@@ -250,3 +258,9 @@ void SieveEditorMainWindow::slotRedoAvailable(bool b)
mRedoAction->setEnabled(editActionEnabled && b);
}
void SieveEditorMainWindow::slotCopyAvailable(bool b)
{
const bool hasPage = (mMainWidget->sieveEditorMainWidget()->tabWidget()->count()>0);
const bool editActionEnabled = (hasPage && mMainWidget->sieveEditorMainWidget()->pageMode() == KSieveUi::SieveEditorWidget::TextMode);
mCopyAction->setEnabled(editActionEnabled && b);
}
......@@ -51,6 +51,7 @@ private slots:
void slotUpdateActions();
void slotUndoAvailable(bool);
void slotRedoAvailable(bool);
void slotCopyAvailable(bool b);
private:
void initStatusBar();
......@@ -68,6 +69,9 @@ private:
KAction *mReplaceAction;
KAction *mUndoAction;
KAction *mRedoAction;
KAction *mCopyAction;
KAction *mPasteAction;
KAction *mCutAction;
QLabel *mStatusBarInfo;
bool mNetworkIsDown;
......
......@@ -43,6 +43,7 @@ SieveEditorPageWidget::SieveEditorPageWidget(QWidget *parent)
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)));
connect(mSieveEditorWidget, SIGNAL(copyAvailable(bool)), SIGNAL(copyAvailable(bool)));
//qDebug()<<"SieveEditorPageWidget::SieveEditorPageWidget "<<this;
}
......@@ -204,3 +205,19 @@ KSieveUi::SieveEditorWidget::EditorMode SieveEditorPageWidget::pageMode() const
{
return mSieveEditorWidget->mode();
}
void SieveEditorPageWidget::paste()
{
mSieveEditorWidget->paste();
}
void SieveEditorPageWidget::cut()
{
mSieveEditorWidget->cut();
}
void SieveEditorPageWidget::copy()
{
mSieveEditorWidget->copy();
}
......@@ -53,12 +53,17 @@ public:
void undo();
bool isUndoAvailable() const;
bool isRedoAvailable() const;
void paste();
void cut();
void copy();
Q_SIGNALS:
void refreshList();
void scriptModified(bool, SieveEditorPageWidget *);
void modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode);
void undoAvailable(bool);
void redoAvailable(bool);
void copyAvailable(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