Commit 81d69641 authored by Friedemann Kleint's avatar Friedemann Kleint

Added ParameterAction class for QActions acting on files.

Reduce inconsistencies in tr()-Strings provided for
QActions that act on a current <something> (mostly files) by
introducing a ParameterAction class that takes the tr()-Strings
at construction time and provides a setParameter(QString) slot,
allows for setting that parameter or an empty string, which
will cause the displayed text to be updated.
parent 9106c721
#include "parameteraction.h"
namespace Core {
namespace Utils {
ParameterAction::ParameterAction(const QString &emptyText,
const QString &parameterText,
EnablingMode mode,
QObject* parent) :
QAction(emptyText, parent),
m_emptyText(emptyText),
m_parameterText(parameterText),
m_enablingMode(mode)
{
}
QString ParameterAction::emptyText() const
{
return m_emptyText;
}
void ParameterAction::setEmptyText(const QString &t)
{
m_emptyText = t;
}
QString ParameterAction::parameterText() const
{
return m_parameterText;
}
void ParameterAction::setParameterText(const QString &t)
{
m_parameterText = t;
}
ParameterAction::EnablingMode ParameterAction::enablingMode() const
{
return m_enablingMode;
}
void ParameterAction::setEnablingMode(EnablingMode m)
{
m_enablingMode = m;
}
void ParameterAction::setParameter(const QString &p)
{
const bool enabled = !p.isEmpty();
if (enabled) {
setText(m_parameterText.arg(p));
} else {
setText(m_emptyText);
}
if (m_enablingMode == EnabledWithParameter)
setEnabled(enabled);
}
}
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef PARAMETERACTION_H
#define PARAMETERACTION_H
#include "utils_global.h"
#include <QtGui/QAction>
namespace Core {
namespace Utils {
/* ParameterAction: Intended for actions that act on a 'current',
* string-type parameter (typically file name) and have 2 states:
* 1) <no current parameter> displaying "Do XX" (empty text)
* 2) <parameter present> displaying "Do XX with %1".
* Provides a slot to set the parameter, changing display
* and enabled state accordingly.
* The text passed in should already be translated; parameterText
* should contain a %1 where the parameter is to be inserted. */
class QTCREATOR_UTILS_EXPORT ParameterAction : public QAction
{
Q_ENUMS(EnablingMode)
Q_PROPERTY(QString emptyText READ emptyText WRITE setEmptyText)
Q_PROPERTY(QString parameterText READ parameterText WRITE setParameterText)
Q_PROPERTY(EnablingMode enablingMode READ enablingMode WRITE setEnablingMode)
Q_OBJECT
public:
enum EnablingMode { AlwaysEnabled, EnabledWithParameter };
explicit ParameterAction(const QString &emptyText,
const QString &parameterText,
EnablingMode em = AlwaysEnabled,
QObject* parent = 0);
QString emptyText() const;
void setEmptyText(const QString &);
QString parameterText() const;
void setParameterText(const QString &);
EnablingMode enablingMode() const;
void setEnablingMode(EnablingMode m);
public slots:
void setParameter(const QString &);
private:
QString m_emptyText;
QString m_parameterText;
EnablingMode m_enablingMode;
};
}
}
#endif // PARAMETERACTION_H
...@@ -29,7 +29,8 @@ SOURCES += \ ...@@ -29,7 +29,8 @@ SOURCES += \
synchronousprocess.cpp \ synchronousprocess.cpp \
submitfieldwidget.cpp \ submitfieldwidget.cpp \
consoleprocess.cpp \ consoleprocess.cpp \
uncommentselection.cpp uncommentselection.cpp \
parameteraction.cpp
win32 { win32 {
SOURCES += abstractprocess_win.cpp \ SOURCES += abstractprocess_win.cpp \
...@@ -66,7 +67,8 @@ HEADERS += \ ...@@ -66,7 +67,8 @@ HEADERS += \
consoleprocess.h \ consoleprocess.h \
synchronousprocess.h \ synchronousprocess.h \
submitfieldwidget.h \ submitfieldwidget.h \
uncommentselection.h uncommentselection.h \
parameteraction.h
FORMS += filewizardpage.ui \ FORMS += filewizardpage.ui \
projectintropage.ui \ projectintropage.ui \
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/parameteraction.h>
#include <vcsbase/basevcseditorfactory.h> #include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/vcsbaseeditor.h> #include <vcsbase/vcsbaseeditor.h>
...@@ -275,7 +276,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) ...@@ -275,7 +276,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
Core::Command *command; Core::Command *command;
m_diffAction = new QAction(tr("Diff Current File"), this); m_diffAction = new Core::Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_diffAction, "Git.Diff", globalcontext); command = actionManager->registerAction(m_diffAction, "Git.Diff", globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
...@@ -284,7 +285,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) ...@@ -284,7 +285,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_diffAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); connect(m_diffAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
gitContainer->addAction(command); gitContainer->addAction(command);
m_statusAction = new QAction(tr("File Status"), this); m_statusAction = new Core::Utils::ParameterAction(tr("File Status"), tr("Status Related to \"%1\""), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_statusAction, "Git.Status", globalcontext); command = actionManager->registerAction(m_statusAction, "Git.Status", globalcontext);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+S"))); command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+S")));
...@@ -293,7 +294,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) ...@@ -293,7 +294,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_statusAction, SIGNAL(triggered()), this, SLOT(statusFile())); connect(m_statusAction, SIGNAL(triggered()), this, SLOT(statusFile()));
gitContainer->addAction(command); gitContainer->addAction(command);
m_logAction = new QAction(tr("Log File"), this); m_logAction = new Core::Utils::ParameterAction(tr("Log File"), tr("Log of \"%1\""), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_logAction, "Git.Log", globalcontext); command = actionManager->registerAction(m_logAction, "Git.Log", globalcontext);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+L"))); command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+L")));
...@@ -302,7 +303,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) ...@@ -302,7 +303,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_logAction, SIGNAL(triggered()), this, SLOT(logFile())); connect(m_logAction, SIGNAL(triggered()), this, SLOT(logFile()));
gitContainer->addAction(command); gitContainer->addAction(command);
m_blameAction = new QAction(tr("Blame"), this); m_blameAction = new Core::Utils::ParameterAction(tr("Blame"), tr("Blame for \"%1\""), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_blameAction, "Git.Blame", globalcontext); command = actionManager->registerAction(m_blameAction, "Git.Blame", globalcontext);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+B"))); command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+B")));
...@@ -311,7 +312,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) ...@@ -311,7 +312,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_blameAction, SIGNAL(triggered()), this, SLOT(blameFile())); connect(m_blameAction, SIGNAL(triggered()), this, SLOT(blameFile()));
gitContainer->addAction(command); gitContainer->addAction(command);
m_undoFileAction = new QAction(tr("Undo Changes"), this); m_undoFileAction = new Core::Utils::ParameterAction(tr("Undo Changes"), tr("Undo Changes for \"%1\""), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_undoFileAction, "Git.Undo", globalcontext); command = actionManager->registerAction(m_undoFileAction, "Git.Undo", globalcontext);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+U"))); command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+U")));
...@@ -320,7 +321,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) ...@@ -320,7 +321,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_undoFileAction, SIGNAL(triggered()), this, SLOT(undoFileChanges())); connect(m_undoFileAction, SIGNAL(triggered()), this, SLOT(undoFileChanges()));
gitContainer->addAction(command); gitContainer->addAction(command);
m_stageAction = new QAction(tr("Stage File for Commit"), this); m_stageAction = new Core::Utils::ParameterAction(tr("Stage File for Commit"), tr("Stage \"%1\" for Commit"), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_stageAction, "Git.Stage", globalcontext); command = actionManager->registerAction(m_stageAction, "Git.Stage", globalcontext);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+A"))); command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+A")));
...@@ -329,13 +330,13 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) ...@@ -329,13 +330,13 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_stageAction, SIGNAL(triggered()), this, SLOT(stageFile())); connect(m_stageAction, SIGNAL(triggered()), this, SLOT(stageFile()));
gitContainer->addAction(command); gitContainer->addAction(command);
m_unstageAction = new QAction(tr("Unstage File from Commit"), this); m_unstageAction = new Core::Utils::ParameterAction(tr("Unstage File from Commit"), tr("Unstage \"%1\" from Commit"), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_unstageAction, "Git.Unstage", globalcontext); command = actionManager->registerAction(m_unstageAction, "Git.Unstage", globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
connect(m_unstageAction, SIGNAL(triggered()), this, SLOT(unstageFile())); connect(m_unstageAction, SIGNAL(triggered()), this, SLOT(unstageFile()));
gitContainer->addAction(command); gitContainer->addAction(command);
m_revertAction = new QAction(tr("Revert..."), this); m_revertAction = new Core::Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_revertAction, "Git.Revert", globalcontext); command = actionManager->registerAction(m_revertAction, "Git.Revert", globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertFile())); connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertFile()));
...@@ -343,7 +344,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) ...@@ -343,7 +344,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Project"), this)); gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Project"), this));
m_diffProjectAction = new QAction(tr("Diff Current Project"), this); m_diffProjectAction = new Core::Utils::ParameterAction(tr("Diff Current Project"), tr("Diff Project \"%1\""), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_diffProjectAction, "Git.DiffProject", globalcontext); command = actionManager->registerAction(m_diffProjectAction, "Git.DiffProject", globalcontext);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
command->setDefaultKeySequence(QKeySequence("Alt+G,Alt+Shift+D")); command->setDefaultKeySequence(QKeySequence("Alt+G,Alt+Shift+D"));
...@@ -352,13 +353,13 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) ...@@ -352,13 +353,13 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffCurrentProject())); connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffCurrentProject()));
gitContainer->addAction(command); gitContainer->addAction(command);
m_statusProjectAction = new QAction(tr("Project Status"), this); m_statusProjectAction = new Core::Utils::ParameterAction(tr("Project Status"), tr("Status Project \"%1\""), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_statusProjectAction, "Git.StatusProject", globalcontext); command = actionManager->registerAction(m_statusProjectAction, "Git.StatusProject", globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(statusProject())); connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(statusProject()));
gitContainer->addAction(command); gitContainer->addAction(command);
m_logProjectAction = new QAction(tr("Log Project"), this); m_logProjectAction = new Core::Utils::ParameterAction(tr("Log Project"), tr("Log Project \"%1\""), Core::Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_logProjectAction, "Git.LogProject", globalcontext); command = actionManager->registerAction(m_logProjectAction, "Git.LogProject", globalcontext);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+K"))); command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+K")));
...@@ -785,15 +786,14 @@ void GitPlugin::updateActions() ...@@ -785,15 +786,14 @@ void GitPlugin::updateActions()
const QString repository = m_gitClient->findRepositoryForFile(current.absoluteFilePath()); const QString repository = m_gitClient->findRepositoryForFile(current.absoluteFilePath());
// First check for file commands and if the current file is inside // First check for file commands and if the current file is inside
// a Git-repository // a Git-repository
const QString file = fileName.isEmpty() ? tr("File") : "\"" + fileName + '"'; m_diffAction->setParameter(fileName);
m_diffAction->setText(tr("Diff %1").arg(file)); m_statusAction->setParameter(fileName);
m_statusAction->setText(tr("Status Related to %1").arg(file)); m_logAction->setParameter(fileName);
m_logAction->setText(tr("Log of %1").arg(file)); m_blameAction->setParameter(fileName);
m_blameAction->setText(tr("Blame for %1").arg(file)); m_undoFileAction->setParameter(fileName);
m_undoFileAction->setText(tr("Undo Changes for %1").arg(file)); m_stageAction->setParameter(fileName);
m_stageAction->setText(tr("Stage %1 for Commit").arg(file)); m_unstageAction->setParameter(fileName);
m_unstageAction->setText(tr("Unstage %1 from Commit").arg(file)); m_revertAction->setParameter(fileName);
m_revertAction->setText(tr("Revert %1...").arg(file));
bool enabled = !fileName.isEmpty() && !repository.isEmpty(); bool enabled = !fileName.isEmpty() && !repository.isEmpty();
m_diffAction->setEnabled(enabled); m_diffAction->setEnabled(enabled);
...@@ -809,10 +809,10 @@ void GitPlugin::updateActions() ...@@ -809,10 +809,10 @@ void GitPlugin::updateActions()
// If the file is not in a repository, the corresponding project will // If the file is not in a repository, the corresponding project will
// be neither and we can disable everything and return // be neither and we can disable everything and return
m_diffProjectAction->setEnabled(false); m_diffProjectAction->setEnabled(false);
m_diffProjectAction->setText(tr("Diff Project")); m_diffProjectAction->setParameter(repository);
m_statusProjectAction->setText(tr("Status Project")); m_statusProjectAction->setParameter(repository);
m_statusProjectAction->setEnabled(false); m_statusProjectAction->setEnabled(false);
m_logProjectAction->setText(tr("Log Project")); m_logProjectAction->setParameter(repository);
m_logProjectAction->setEnabled(false); m_logProjectAction->setEnabled(false);
return; return;
} }
...@@ -822,18 +822,18 @@ void GitPlugin::updateActions() ...@@ -822,18 +822,18 @@ void GitPlugin::updateActions()
using namespace ProjectExplorer; using namespace ProjectExplorer;
QString project; QString project;
if (m_projectExplorer) { if (m_projectExplorer) {
if (Node *node = m_projectExplorer->currentNode()) if (const Node *node = m_projectExplorer->currentNode())
if (Node *projectNode = node->projectNode()) if (const Node *projectNode = node->projectNode())
project = '"' + QFileInfo(projectNode->path()).completeBaseName() + '"'; project = QFileInfo(projectNode->path()).completeBaseName();
} }
enabled = !project.isEmpty(); enabled = !project.isEmpty();
m_diffProjectAction->setEnabled(enabled); m_diffProjectAction->setEnabled(enabled);
m_diffProjectAction->setText(tr("Diff Project %1").arg(project)); m_diffProjectAction->setParameter(project);
m_statusProjectAction->setEnabled(enabled); m_statusProjectAction->setEnabled(enabled);
m_statusProjectAction->setText(tr("Status Project %1").arg(project)); m_statusProjectAction->setParameter(project);
m_logProjectAction->setEnabled(enabled); m_logProjectAction->setEnabled(enabled);
m_logProjectAction->setText(tr("Log Project %1").arg(project)); m_logProjectAction->setParameter(project);
} }
void GitPlugin::showCommit() void GitPlugin::showCommit()
......
...@@ -52,6 +52,9 @@ namespace Core { ...@@ -52,6 +52,9 @@ namespace Core {
class IEditorFactory; class IEditorFactory;
class ICore; class ICore;
class IVersionControl; class IVersionControl;
namespace Utils {
class ParameterAction;
}
} // namespace Core } // namespace Core
namespace Git { namespace Git {
...@@ -133,19 +136,19 @@ private: ...@@ -133,19 +136,19 @@ private:
static GitPlugin *m_instance; static GitPlugin *m_instance;
Core::ICore *m_core; Core::ICore *m_core;
QAction *m_diffAction; Core::Utils::ParameterAction *m_diffAction;
QAction *m_diffProjectAction; Core::Utils::ParameterAction *m_diffProjectAction;
QAction *m_statusAction; Core::Utils::ParameterAction *m_statusAction;
QAction *m_statusProjectAction; Core::Utils::ParameterAction *m_statusProjectAction;
QAction *m_logAction; Core::Utils::ParameterAction *m_logAction;
QAction *m_blameAction; Core::Utils::ParameterAction *m_blameAction;
QAction *m_logProjectAction; Core::Utils::ParameterAction *m_logProjectAction;
QAction *m_undoFileAction; Core::Utils::ParameterAction *m_undoFileAction;
QAction *m_undoProjectAction; QAction *m_undoProjectAction;
QAction *m_showAction; QAction *m_showAction;
QAction *m_stageAction; Core::Utils::ParameterAction *m_stageAction;
QAction *m_unstageAction; Core::Utils::ParameterAction *m_unstageAction;
QAction *m_revertAction; Core::Utils::ParameterAction *m_revertAction;
QAction *m_commitAction; QAction *m_commitAction;
QAction *m_pullAction; QAction *m_pullAction;
QAction *m_pushAction; QAction *m_pushAction;
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <coreplugin/uniqueidmanager.h> #include <coreplugin/uniqueidmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
#include <utils/parameteraction.h>
#include <vcsbase/basevcseditorfactory.h> #include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/basevcssubmiteditorfactory.h> #include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseeditor.h> #include <vcsbase/vcsbaseeditor.h>
...@@ -263,7 +264,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -263,7 +264,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
Core::Command *command; Core::Command *command;
QAction *tmpaction; QAction *tmpaction;
m_editAction = new QAction(tr("Edit"), this); m_editAction = new Core::Utils::ParameterAction(tr("Edit"), tr("Edit \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_editAction, PerforcePlugin::EDIT, globalcontext); command = am->registerAction(m_editAction, PerforcePlugin::EDIT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+E"))); command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+E")));
...@@ -271,7 +272,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -271,7 +272,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
connect(m_editAction, SIGNAL(triggered()), this, SLOT(openCurrentFile())); connect(m_editAction, SIGNAL(triggered()), this, SLOT(openCurrentFile()));
mperforce->addAction(command); mperforce->addAction(command);
m_addAction = new QAction(tr("Add"), this); m_addAction = new Core::Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_addAction, PerforcePlugin::ADD, globalcontext); command = am->registerAction(m_addAction, PerforcePlugin::ADD, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+A"))); command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+A")));
...@@ -279,14 +280,14 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -279,14 +280,14 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile())); connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
mperforce->addAction(command); mperforce->addAction(command);
m_deleteAction = new QAction(tr("Delete"), this); m_deleteAction = new Core::Utils::ParameterAction(tr("Delete"), tr("Delete \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_deleteAction, PerforcePlugin::DELETE_FILE, globalcontext); command = am->registerAction(m_deleteAction, PerforcePlugin::DELETE_FILE, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultText(tr("Delete File")); command->setDefaultText(tr("Delete File"));
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deleteCurrentFile())); connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deleteCurrentFile()));
mperforce->addAction(command); mperforce->addAction(command);
m_revertAction = new QAction(tr("Revert"), this); m_revertAction = new Core::Utils::ParameterAction(tr("Revert"), tr("Revert \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_revertAction, PerforcePlugin::REVERT, globalcontext); command = am->registerAction(m_revertAction, PerforcePlugin::REVERT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+R"))); command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+R")));
...@@ -299,14 +300,14 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -299,14 +300,14 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
command = am->registerAction(tmpaction, QLatin1String("Perforce.Sep.Edit"), globalcontext); command = am->registerAction(tmpaction, QLatin1String("Perforce.Sep.Edit"), globalcontext);
mperforce->addAction(command); mperforce->addAction(command);
m_diffCurrentAction = new QAction(tr("Diff Current File"), this); m_diffCurrentAction = new Core::Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_diffCurrentAction, PerforcePlugin::DIFF_CURRENT, globalcontext); command = am->registerAction(m_diffCurrentAction, PerforcePlugin::DIFF_CURRENT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultText(tr("Diff Current File")); command->setDefaultText(tr("Diff Current File"));
connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
mperforce->addAction(command); mperforce->addAction(command);
m_diffProjectAction = new QAction(tr("Diff Current Project/Session"), this); m_diffProjectAction = new Core::Utils::ParameterAction(tr("Diff Current Project/Session"), tr("Diff Project \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_diffProjectAction, PerforcePlugin::DIFF_PROJECT, globalcontext); command = am->registerAction(m_diffProjectAction, PerforcePlugin::DIFF_PROJECT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+D"))); command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+D")));
...@@ -351,7 +352,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -351,7 +352,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
connect(m_describeAction, SIGNAL(triggered()), this, SLOT(describeChange())); connect(m_describeAction, SIGNAL(triggered()), this, SLOT(describeChange()));
mperforce->addAction(command); mperforce->addAction(command);
m_annotateCurrentAction = new QAction(tr("Annotate Current File"), this); m_annotateCurrentAction = new Core::Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_annotateCurrentAction, PerforcePlugin::ANNOTATE_CURRENT, globalcontext); command = am->registerAction(m_annotateCurrentAction, PerforcePlugin::ANNOTATE_CURRENT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultText(tr("Annotate Current File")); command->setDefaultText(tr("Annotate Current File"));
...@@ -363,7 +364,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -363,7 +364,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
connect(m_annotateAction, SIGNAL(triggered()), this, SLOT(annotate())); connect(m_annotateAction, SIGNAL(triggered()), this, SLOT(annotate()));
mperforce->addAction(command); mperforce->addAction(command);
m_filelogCurrentAction = new QAction(tr("Filelog Current File"), this); m_filelogCurrentAction = new Core::Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_filelogCurrentAction, PerforcePlugin::FILELOG_CURRENT, globalcontext); command = am->registerAction(m_filelogCurrentAction, PerforcePlugin::FILELOG_CURRENT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+F")));