QmlDesigner/ShortcutManager: Cleanup

Remove some unneeded 0-parents, use nullptr, and do not use parameter
actions when they are not needed.

Change-Id: Ia556f83f7f1ce296fc08fa76cced7f41102d110f
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Eike Ziller
2018-04-16 14:10:14 +02:00
parent c00c4fc9c2
commit 42386dbdbc
2 changed files with 20 additions and 27 deletions

View File

@@ -63,25 +63,19 @@ namespace QmlDesigner {
ShortCutManager::ShortCutManager()
: QObject(),
m_revertToSavedAction(0),
m_saveAction(0),
m_saveAsAction(0),
m_exportAsImageAction(tr("Export as &Image..."), 0),
m_closeCurrentEditorAction(0),
m_closeAllEditorsAction(0),
m_closeOtherEditorsAction(0),
m_undoAction(tr("&Undo"), 0),
m_redoAction(tr("&Redo"), 0),
m_deleteAction(tr("Delete"), tr("Delete \"%1\""), Utils::ParameterAction::EnabledWithParameter),
m_cutAction(tr("Cu&t"), tr("Cut \"%1\""), Utils::ParameterAction::EnabledWithParameter),
m_copyAction(tr("&Copy"), tr("Copy \"%1\""), Utils::ParameterAction::EnabledWithParameter),
m_pasteAction(tr("&Paste"), tr("Paste \"%1\""), Utils::ParameterAction::EnabledWithParameter),
m_selectAllAction(tr("Select &All"), tr("Select All \"%1\""), Utils::ParameterAction::EnabledWithParameter),
m_collapseExpandStatesAction(tr("Toggle States"), 0),
m_restoreDefaultViewAction(tr("&Restore Default View"), 0),
m_toggleLeftSidebarAction(tr("Toggle &Left Sidebar"), 0),
m_toggleRightSidebarAction(tr("Toggle &Right Sidebar"), 0),
m_switchTextFormAction(tr("Switch Text/Design"), 0),
m_exportAsImageAction(tr("Export as &Image...")),
m_undoAction(tr("&Undo")),
m_redoAction(tr("&Redo")),
m_deleteAction(tr("Delete")),
m_cutAction(tr("Cu&t")),
m_copyAction(tr("&Copy")),
m_pasteAction(tr("&Paste")),
m_selectAllAction(tr("Select &All")),
m_collapseExpandStatesAction(tr("Toggle States")),
m_restoreDefaultViewAction(tr("&Restore Default View")),
m_toggleLeftSidebarAction(tr("Toggle &Left Sidebar")),
m_toggleRightSidebarAction(tr("Toggle &Right Sidebar")),
m_switchTextFormAction(tr("Switch Text/Design")),
m_escapeAction(this)
{
@@ -261,7 +255,7 @@ void ShortCutManager::updateActions(Core::IEditor* currentEditor)
{
int openedCount = Core::DocumentModel::entryCount();
Core::IDocument *document = 0;
Core::IDocument *document = nullptr;
if (currentEditor)
document = currentEditor->document();
m_saveAction.setEnabled(document && document->isModified());
@@ -278,7 +272,7 @@ void ShortCutManager::updateActions(Core::IEditor* currentEditor)
m_saveAction.setText(tr("&Save %1").arg(quotedName));
m_revertToSavedAction.setText(tr("Revert %1 to Saved").arg(quotedName));
m_closeCurrentEditorAction.setEnabled(currentEditor != 0);
m_closeCurrentEditorAction.setEnabled(currentEditor != nullptr);
m_closeCurrentEditorAction.setText(tr("Close %1").arg(quotedName));
m_closeAllEditorsAction.setEnabled(openedCount > 0);
m_closeOtherEditorsAction.setEnabled(openedCount > 1);

View File

@@ -27,7 +27,6 @@
#include <QObject>
#include <QAction>
#include <utils/parameteraction.h>
namespace Core {
class IEditor;
@@ -80,11 +79,11 @@ private:
QAction m_closeOtherEditorsAction;
QAction m_undoAction;
QAction m_redoAction;
Utils::ParameterAction m_deleteAction;
Utils::ParameterAction m_cutAction;
Utils::ParameterAction m_copyAction;
Utils::ParameterAction m_pasteAction;
Utils::ParameterAction m_selectAllAction;
QAction m_deleteAction;
QAction m_cutAction;
QAction m_copyAction;
QAction m_pasteAction;
QAction m_selectAllAction;
QAction m_collapseExpandStatesAction;
QAction m_restoreDefaultViewAction;
QAction m_toggleLeftSidebarAction;