summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-02 05:19:47 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-02 05:19:47 (GMT)
commita5009e6c0a261a7d1107a9c4db658a94854da14d (patch)
treea5b89e5bf3c4cceb8803e751707061d2a7cd0a76
parent22f64930ed7190a3f3f08e11668a6f9e3eb64a43 (diff)
Don"t show action when not necessary
-rw-r--r--src/texteditor/plaintexteditor/plaintexteditor.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/texteditor/plaintexteditor/plaintexteditor.cpp b/src/texteditor/plaintexteditor/plaintexteditor.cpp
index 3b3d6d1..1ab4421 100644
--- a/src/texteditor/plaintexteditor/plaintexteditor.cpp
+++ b/src/texteditor/plaintexteditor/plaintexteditor.cpp
@@ -136,11 +136,10 @@ void PlainTextEditor::contextMenuEvent(QContextMenuEvent *event)
separatorAction = actionList.at(idx);
}
if (separatorAction) {
- QAction *clearAllAction = KStandardAction::clear(this, &PlainTextEditor::slotUndoableClear, popup);
- if (emptyDocument) {
- clearAllAction->setEnabled(false);
+ if (!emptyDocument) {
+ QAction *clearAllAction = KStandardAction::clear(this, &PlainTextEditor::slotUndoableClear, popup);
+ popup->insertAction(separatorAction, clearAllAction);
}
- popup->insertAction(separatorAction, clearAllAction);
}
}
KIconTheme::assignIconsToContextMenu(isReadOnly() ? KIconTheme::ReadOnlyText
@@ -148,17 +147,15 @@ void PlainTextEditor::contextMenuEvent(QContextMenuEvent *event)
popup->actions());
if (d->supportFeatures & Search) {
popup->addSeparator();
- QAction *findAct = popup->addAction(KStandardGuiItem::find().icon(), KStandardGuiItem::find().text(), this, SIGNAL(findText()), Qt::Key_F + Qt::CTRL);
- if (emptyDocument) {
- findAct->setEnabled(false);
+ if (!emptyDocument) {
+ popup->addAction(KStandardGuiItem::find().icon(), KStandardGuiItem::find().text(), this, SIGNAL(findText()), Qt::Key_F + Qt::CTRL);
+ popup->addSeparator();
}
- popup->addSeparator();
if (!isReadOnly()) {
- QAction *act = popup->addAction(i18n("Replace..."), this, SIGNAL(replaceText()), Qt::Key_R + Qt::CTRL);
- if (emptyDocument) {
- act->setEnabled(false);
+ if (!emptyDocument) {
+ popup->addAction(i18n("Replace..."), this, SIGNAL(replaceText()), Qt::Key_R + Qt::CTRL);
+ popup->addSeparator();
}
- popup->addSeparator();
}
} else {
popup->addSeparator();
@@ -169,11 +166,10 @@ void PlainTextEditor::contextMenuEvent(QContextMenuEvent *event)
d->speller = new Sonnet::Speller();
}
if (!d->speller->availableBackends().isEmpty()) {
- QAction *spellCheckAction = popup->addAction(QIcon::fromTheme(QStringLiteral("tools-check-spelling")), i18n("Check Spelling..."), this, SLOT(slotCheckSpelling()));
- if (emptyDocument) {
- spellCheckAction->setEnabled(false);
+ if (!emptyDocument) {
+ popup->addAction(QIcon::fromTheme(QStringLiteral("tools-check-spelling")), i18n("Check Spelling..."), this, SLOT(slotCheckSpelling()));
+ popup->addSeparator();
}
- popup->addSeparator();
QAction *autoSpellCheckAction = popup->addAction(i18n("Auto Spell Check"), this, SLOT(slotToggleAutoSpellCheck()));
autoSpellCheckAction->setCheckable(true);
autoSpellCheckAction->setChecked(checkSpellingEnabled());