Commit 666b4542 authored by Marco Bubke's avatar Marco Bubke
Browse files

Add "Select All" menu item to the design mode

parent b4c6ecee
......@@ -663,6 +663,20 @@ void DesignDocumentController::paste()
}
}
void DesignDocumentController::selectAll()
{
if (!m_d->model)
return;
DesignDocumentControllerView view;
m_d->model->attachView(&view);
QList<ModelNode> allNodesExceptRootNode(view.allModelNodes());
allNodesExceptRootNode.removeOne(view.rootModelNode());
view.setSelectedModelNodes(allNodesExceptRootNode);
}
void DesignDocumentController::showError(const QString &message, QWidget *parent) const
{
if (!parent)
......
......@@ -110,6 +110,7 @@ public slots:
void copySelected();
void cutSelected();
void paste();
void selectAll();
void togglePreview(bool visible);
void toggleWithDebugPreview(bool visible);
......
......@@ -147,6 +147,11 @@ DesignMode::DesignMode() :
command->setDefaultKeySequence(QKeySequence::Paste);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
command = actionManager->registerAction(m_mainWidget->selectAllAction(),
Core::Constants::SELECTALL, context());
command->setDefaultKeySequence(QKeySequence::SelectAll);
editMenu->addAction(command, Core::Constants::G_EDIT_SELECTALL);
// add second shortcut to trigger delete
QAction *deleteAction = new QAction(m_mainWidget);
deleteAction->setShortcut(QKeySequence(QLatin1String("Backspace")));
......
......@@ -497,6 +497,8 @@ DesignModeWidget::DesignModeWidget(DesignMode *designMode, QWidget *parent) :
connect(m_copyAction, SIGNAL(triggered()), this, SLOT(copySelected()));
m_pasteAction = new Utils::ParameterAction(tr("&Paste"), tr("Paste \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
connect(m_pasteAction, SIGNAL(triggered()), this, SLOT(paste()));
m_selectAllAction = new Utils::ParameterAction(tr("Select &All"), tr("Select All \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
connect(m_selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll()));
QLabel *defaultBackground = new QLabel(tr("Open/Create a qml file first."));
defaultBackground->setAlignment(Qt::AlignCenter);
......@@ -598,6 +600,11 @@ QAction *DesignModeWidget::pasteAction() const
return m_pasteAction;
}
QAction *DesignModeWidget::selectAllAction() const
{
return m_selectAllAction;
}
DesignMode *DesignModeWidget::designMode() const
{
return m_designMode;
......@@ -639,6 +646,12 @@ void DesignModeWidget::paste()
m_currentDocumentWidget->document()->paste();
}
void DesignModeWidget::selectAll()
{
if (m_currentDocumentWidget)
m_currentDocumentWidget->document()->selectAll();
}
void DesignModeWidget::undoAvailable(bool isAvailable)
{
DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender());
......
......@@ -172,6 +172,7 @@ public:
QAction *cutAction() const;
QAction *copyAction() const;
QAction *pasteAction() const;
QAction *selectAllAction() const;
DesignMode *designMode() const;
......@@ -182,6 +183,7 @@ private slots:
void cutSelected();
void copySelected();
void paste();
void selectAll();
void undoAvailable(bool isAvailable);
void redoAvailable(bool isAvailable);
......@@ -202,6 +204,7 @@ private:
QAction *m_cutAction;
QAction *m_copyAction;
QAction *m_pasteAction;
QAction *m_selectAllAction;
bool m_syncWithTextEdit;
};
......
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