forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#include "parameteraction.h"
|
||||
|
||||
namespace Core {
|
||||
namespace Utils {
|
||||
|
||||
ParameterAction::ParameterAction(const QString &emptyText,
|
||||
const QString ¶meterText,
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** 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 ¶meterText,
|
||||
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 += \
|
||||
synchronousprocess.cpp \
|
||||
submitfieldwidget.cpp \
|
||||
consoleprocess.cpp \
|
||||
uncommentselection.cpp
|
||||
uncommentselection.cpp \
|
||||
parameteraction.cpp
|
||||
|
||||
win32 {
|
||||
SOURCES += abstractprocess_win.cpp \
|
||||
@@ -66,7 +67,8 @@ HEADERS += \
|
||||
consoleprocess.h \
|
||||
synchronousprocess.h \
|
||||
submitfieldwidget.h \
|
||||
uncommentselection.h
|
||||
uncommentselection.h \
|
||||
parameteraction.h
|
||||
|
||||
FORMS += filewizardpage.ui \
|
||||
projectintropage.ui \
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/parameteraction.h>
|
||||
|
||||
#include <vcsbase/basevcseditorfactory.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
@@ -275,7 +276,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
#ifndef Q_OS_MAC
|
||||
@@ -284,7 +285,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
connect(m_diffAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
||||
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);
|
||||
#ifndef Q_OS_MAC
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+S")));
|
||||
@@ -293,7 +294,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
connect(m_statusAction, SIGNAL(triggered()), this, SLOT(statusFile()));
|
||||
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);
|
||||
#ifndef Q_OS_MAC
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+L")));
|
||||
@@ -302,7 +303,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
connect(m_logAction, SIGNAL(triggered()), this, SLOT(logFile()));
|
||||
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);
|
||||
#ifndef Q_OS_MAC
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+B")));
|
||||
@@ -311,7 +312,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
connect(m_blameAction, SIGNAL(triggered()), this, SLOT(blameFile()));
|
||||
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);
|
||||
#ifndef Q_OS_MAC
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+U")));
|
||||
@@ -320,7 +321,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
connect(m_undoFileAction, SIGNAL(triggered()), this, SLOT(undoFileChanges()));
|
||||
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);
|
||||
#ifndef Q_OS_MAC
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+A")));
|
||||
@@ -329,13 +330,13 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
connect(m_stageAction, SIGNAL(triggered()), this, SLOT(stageFile()));
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_unstageAction, SIGNAL(triggered()), this, SLOT(unstageFile()));
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertFile()));
|
||||
@@ -343,7 +344,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
|
||||
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);
|
||||
#ifndef Q_OS_MAC
|
||||
command->setDefaultKeySequence(QKeySequence("Alt+G,Alt+Shift+D"));
|
||||
@@ -352,13 +353,13 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffCurrentProject()));
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(statusProject()));
|
||||
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);
|
||||
#ifndef Q_OS_MAC
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+K")));
|
||||
@@ -785,15 +786,14 @@ void GitPlugin::updateActions()
|
||||
const QString repository = m_gitClient->findRepositoryForFile(current.absoluteFilePath());
|
||||
// First check for file commands and if the current file is inside
|
||||
// a Git-repository
|
||||
const QString file = fileName.isEmpty() ? tr("File") : "\"" + fileName + '"';
|
||||
m_diffAction->setText(tr("Diff %1").arg(file));
|
||||
m_statusAction->setText(tr("Status Related to %1").arg(file));
|
||||
m_logAction->setText(tr("Log of %1").arg(file));
|
||||
m_blameAction->setText(tr("Blame for %1").arg(file));
|
||||
m_undoFileAction->setText(tr("Undo Changes for %1").arg(file));
|
||||
m_stageAction->setText(tr("Stage %1 for Commit").arg(file));
|
||||
m_unstageAction->setText(tr("Unstage %1 from Commit").arg(file));
|
||||
m_revertAction->setText(tr("Revert %1...").arg(file));
|
||||
m_diffAction->setParameter(fileName);
|
||||
m_statusAction->setParameter(fileName);
|
||||
m_logAction->setParameter(fileName);
|
||||
m_blameAction->setParameter(fileName);
|
||||
m_undoFileAction->setParameter(fileName);
|
||||
m_stageAction->setParameter(fileName);
|
||||
m_unstageAction->setParameter(fileName);
|
||||
m_revertAction->setParameter(fileName);
|
||||
|
||||
bool enabled = !fileName.isEmpty() && !repository.isEmpty();
|
||||
m_diffAction->setEnabled(enabled);
|
||||
@@ -809,10 +809,10 @@ void GitPlugin::updateActions()
|
||||
// If the file is not in a repository, the corresponding project will
|
||||
// be neither and we can disable everything and return
|
||||
m_diffProjectAction->setEnabled(false);
|
||||
m_diffProjectAction->setText(tr("Diff Project"));
|
||||
m_statusProjectAction->setText(tr("Status Project"));
|
||||
m_diffProjectAction->setParameter(repository);
|
||||
m_statusProjectAction->setParameter(repository);
|
||||
m_statusProjectAction->setEnabled(false);
|
||||
m_logProjectAction->setText(tr("Log Project"));
|
||||
m_logProjectAction->setParameter(repository);
|
||||
m_logProjectAction->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
@@ -822,18 +822,18 @@ void GitPlugin::updateActions()
|
||||
using namespace ProjectExplorer;
|
||||
QString project;
|
||||
if (m_projectExplorer) {
|
||||
if (Node *node = m_projectExplorer->currentNode())
|
||||
if (Node *projectNode = node->projectNode())
|
||||
project = '"' + QFileInfo(projectNode->path()).completeBaseName() + '"';
|
||||
if (const Node *node = m_projectExplorer->currentNode())
|
||||
if (const Node *projectNode = node->projectNode())
|
||||
project = QFileInfo(projectNode->path()).completeBaseName();
|
||||
}
|
||||
|
||||
enabled = !project.isEmpty();
|
||||
m_diffProjectAction->setEnabled(enabled);
|
||||
m_diffProjectAction->setText(tr("Diff Project %1").arg(project));
|
||||
m_diffProjectAction->setParameter(project);
|
||||
m_statusProjectAction->setEnabled(enabled);
|
||||
m_statusProjectAction->setText(tr("Status Project %1").arg(project));
|
||||
m_statusProjectAction->setParameter(project);
|
||||
m_logProjectAction->setEnabled(enabled);
|
||||
m_logProjectAction->setText(tr("Log Project %1").arg(project));
|
||||
m_logProjectAction->setParameter(project);
|
||||
}
|
||||
|
||||
void GitPlugin::showCommit()
|
||||
|
||||
+14
-11
@@ -52,6 +52,9 @@ namespace Core {
|
||||
class IEditorFactory;
|
||||
class ICore;
|
||||
class IVersionControl;
|
||||
namespace Utils {
|
||||
class ParameterAction;
|
||||
}
|
||||
} // namespace Core
|
||||
|
||||
namespace Git {
|
||||
@@ -133,19 +136,19 @@ private:
|
||||
|
||||
static GitPlugin *m_instance;
|
||||
Core::ICore *m_core;
|
||||
QAction *m_diffAction;
|
||||
QAction *m_diffProjectAction;
|
||||
QAction *m_statusAction;
|
||||
QAction *m_statusProjectAction;
|
||||
QAction *m_logAction;
|
||||
QAction *m_blameAction;
|
||||
QAction *m_logProjectAction;
|
||||
QAction *m_undoFileAction;
|
||||
Core::Utils::ParameterAction *m_diffAction;
|
||||
Core::Utils::ParameterAction *m_diffProjectAction;
|
||||
Core::Utils::ParameterAction *m_statusAction;
|
||||
Core::Utils::ParameterAction *m_statusProjectAction;
|
||||
Core::Utils::ParameterAction *m_logAction;
|
||||
Core::Utils::ParameterAction *m_blameAction;
|
||||
Core::Utils::ParameterAction *m_logProjectAction;
|
||||
Core::Utils::ParameterAction *m_undoFileAction;
|
||||
QAction *m_undoProjectAction;
|
||||
QAction *m_showAction;
|
||||
QAction *m_stageAction;
|
||||
QAction *m_unstageAction;
|
||||
QAction *m_revertAction;
|
||||
Core::Utils::ParameterAction *m_stageAction;
|
||||
Core::Utils::ParameterAction *m_unstageAction;
|
||||
Core::Utils::ParameterAction *m_revertAction;
|
||||
QAction *m_commitAction;
|
||||
QAction *m_pullAction;
|
||||
QAction *m_pushAction;
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/parameteraction.h>
|
||||
#include <vcsbase/basevcseditorfactory.h>
|
||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
@@ -263,7 +264,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
Core::Command *command;
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+E")));
|
||||
@@ -271,7 +272,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
connect(m_editAction, SIGNAL(triggered()), this, SLOT(openCurrentFile()));
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+A")));
|
||||
@@ -279,14 +280,14 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
command->setDefaultText(tr("Delete File"));
|
||||
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deleteCurrentFile()));
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+R")));
|
||||
@@ -299,14 +300,14 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
command = am->registerAction(tmpaction, QLatin1String("Perforce.Sep.Edit"), globalcontext);
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
command->setDefaultText(tr("Diff Current File"));
|
||||
connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+D")));
|
||||
@@ -351,7 +352,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
connect(m_describeAction, SIGNAL(triggered()), this, SLOT(describeChange()));
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
command->setDefaultText(tr("Annotate Current File"));
|
||||
@@ -363,7 +364,7 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
connect(m_annotateAction, SIGNAL(triggered()), this, SLOT(annotate()));
|
||||
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->setAttribute(Core::Command::CA_UpdateText);
|
||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+F")));
|
||||
@@ -628,40 +629,22 @@ void PerforcePlugin::filelog(const QString &fileName)
|
||||
|
||||
void PerforcePlugin::updateActions()
|
||||
{
|
||||
QString fileName = currentFileName();
|
||||
QString baseName = QFileInfo(fileName).fileName();
|
||||
const bool hasFile = !currentFileName().isEmpty();
|
||||
m_editAction->setEnabled(hasFile);
|
||||
m_addAction->setEnabled(hasFile);
|
||||
m_deleteAction->setEnabled(hasFile);
|
||||
m_revertAction->setEnabled(hasFile);
|
||||
m_diffCurrentAction->setEnabled(hasFile);
|
||||
m_annotateCurrentAction->setEnabled(hasFile);
|
||||
m_filelogCurrentAction->setEnabled(hasFile);
|
||||
if (hasFile) {
|
||||
m_editAction->setText(tr("Edit %1").arg(baseName));
|
||||
m_addAction->setText(tr("Add %1").arg(baseName));
|
||||
m_deleteAction->setText(tr("Delete %1").arg(baseName));
|
||||
m_revertAction->setText(tr("Revert %1").arg(baseName));
|
||||
m_diffCurrentAction->setText(tr("Diff %1").arg(baseName));
|
||||
m_annotateCurrentAction->setText(tr("Annotate %1").arg(baseName));
|
||||
m_filelogCurrentAction->setText(tr("Filelog %1").arg(baseName));
|
||||
} else {
|
||||
m_editAction->setText(tr("Edit"));
|
||||
m_addAction->setText(tr("Add"));
|
||||
m_deleteAction->setText(tr("Delete"));
|
||||
m_revertAction->setText(tr("Revert"));
|
||||
m_diffCurrentAction->setText(tr("Diff"));
|
||||
m_annotateCurrentAction->setText(tr("Annotate Current File"));
|
||||
m_filelogCurrentAction->setText(tr("Filelog Current File"));
|
||||
}
|
||||
const QString fileName = currentFileName();
|
||||
const QString baseName = fileName.isEmpty() ? fileName : QFileInfo(fileName).fileName();
|
||||
|
||||
m_editAction->setParameter(baseName);
|
||||
m_addAction->setParameter(baseName);
|
||||
m_deleteAction->setParameter(baseName);
|
||||
m_revertAction->setParameter(baseName);
|
||||
m_diffCurrentAction->setParameter(baseName);
|
||||
m_annotateCurrentAction->setParameter(baseName);
|
||||
m_filelogCurrentAction->setParameter(baseName);
|
||||
|
||||
if (m_projectExplorer && m_projectExplorer->currentProject()) {
|
||||
m_diffProjectAction->setEnabled(true);
|
||||
m_diffProjectAction->setText(tr("Diff Project %1").arg(m_projectExplorer->currentProject()->name()));
|
||||
m_diffProjectAction->setParameter(m_projectExplorer->currentProject()->name());
|
||||
m_submitAction->setEnabled(true);
|
||||
} else {
|
||||
m_diffProjectAction->setEnabled(false);
|
||||
m_diffProjectAction->setText(tr("Diff Current Project/Solution"));
|
||||
m_diffProjectAction->setParameter(QString());
|
||||
m_submitAction->setEnabled(false);
|
||||
}
|
||||
m_diffAllAction->setEnabled(true);
|
||||
|
||||
@@ -51,6 +51,9 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
class IEditorFactory;
|
||||
namespace Utils {
|
||||
class ParameterAction;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Perforce {
|
||||
@@ -170,21 +173,21 @@ private:
|
||||
SettingsPage *m_settingsPage;
|
||||
QList<Core::IEditorFactory*> m_editorFactories;
|
||||
|
||||
QAction *m_editAction;
|
||||
QAction *m_addAction;
|
||||
QAction *m_deleteAction;
|
||||
Core::Utils::ParameterAction *m_editAction;
|
||||
Core::Utils::ParameterAction *m_addAction;
|
||||
Core::Utils::ParameterAction *m_deleteAction;
|
||||
QAction *m_openedAction;
|
||||
QAction *m_revertAction;
|
||||
QAction *m_diffCurrentAction;
|
||||
QAction *m_diffProjectAction;
|
||||
Core::Utils::ParameterAction *m_revertAction;
|
||||
Core::Utils::ParameterAction *m_diffCurrentAction;
|
||||
Core::Utils::ParameterAction *m_diffProjectAction;
|
||||
QAction *m_diffAllAction;
|
||||
QAction *m_resolveAction;
|
||||
QAction *m_submitAction;
|
||||
QAction *m_pendingAction;
|
||||
QAction *m_describeAction;
|
||||
QAction *m_annotateCurrentAction;
|
||||
Core::Utils::ParameterAction *m_annotateCurrentAction;
|
||||
QAction *m_annotateAction;
|
||||
QAction *m_filelogCurrentAction;
|
||||
Core::Utils::ParameterAction *m_filelogCurrentAction;
|
||||
QAction *m_filelogAction;
|
||||
QAction *m_submitCurrentLogAction;
|
||||
bool m_submitActionTriggered;
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/parameteraction.h>
|
||||
|
||||
#include <QtCore/QtPlugin>
|
||||
#include <QtCore/QDateTime>
|
||||
@@ -438,7 +439,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
this, SLOT(updateRecentProjectMenu()));
|
||||
|
||||
// unload action
|
||||
m_unloadAction = new QAction(tr("Close Project"), this);
|
||||
m_unloadAction = new Core::Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
|
||||
cmd = am->registerAction(m_unloadAction, Constants::UNLOAD, globalcontext);
|
||||
cmd->setAttribute(Core::Command::CA_UpdateText);
|
||||
cmd->setDefaultText(m_unloadAction->text());
|
||||
@@ -1273,12 +1274,11 @@ void ProjectExplorerPlugin::updateActions()
|
||||
if (debug)
|
||||
qDebug()<<"BuildManager::isBuilding()"<<building;
|
||||
|
||||
m_unloadAction->setEnabled(m_currentProject != 0);
|
||||
if (m_currentProject == 0) {
|
||||
m_unloadAction->setText(tr("Close Project"));
|
||||
m_unloadAction->setParameter(QString());
|
||||
m_buildProjectOnlyMenu->setTitle(tr("Current Project"));
|
||||
} else {
|
||||
m_unloadAction->setText(tr("Close Project \"%1\"").arg(m_currentProject->name()));
|
||||
m_unloadAction->setParameter(m_currentProject->name());
|
||||
m_buildProjectOnlyMenu->setTitle(tr("Project \"%1\"").arg(m_currentProject->name()));
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,9 @@ class IFileFactory;
|
||||
namespace Internal {
|
||||
class WelcomeMode;
|
||||
}
|
||||
namespace Utils {
|
||||
class ParameterAction;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -225,7 +228,7 @@ private:
|
||||
#if 0
|
||||
QAction *m_loadAction;
|
||||
#endif
|
||||
QAction *m_unloadAction;
|
||||
Core::Utils::ParameterAction *m_unloadAction;
|
||||
QAction *m_clearSession;
|
||||
QAction *m_buildProjectOnlyAction;
|
||||
QAction *m_buildAction;
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/parameteraction.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
@@ -320,7 +321,7 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
globalcontext << core->uniqueIDManager()->uniqueIdentifier(C_GLOBAL);
|
||||
|
||||
Core::Command *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 = ami->registerAction(m_addAction, SubversionPlugin::ADD,
|
||||
globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
@@ -330,14 +331,14 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
||||
subversionMenu->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 = ami->registerAction(m_deleteAction, SubversionPlugin::DELETE_FILE,
|
||||
globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deleteCurrentFile()));
|
||||
subversionMenu->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 = ami->registerAction(m_revertAction, SubversionPlugin::REVERT,
|
||||
globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
@@ -352,7 +353,7 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject()));
|
||||
subversionMenu->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 = ami->registerAction(m_diffCurrentAction,
|
||||
SubversionPlugin::DIFF_CURRENT, globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
@@ -370,7 +371,7 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll()));
|
||||
subversionMenu->addAction(command);
|
||||
|
||||
m_commitCurrentAction = new QAction(tr("Commit Current File"), this);
|
||||
m_commitCurrentAction = new Core::Utils::ParameterAction(tr("Commit Current File"), tr("Commit \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
|
||||
command = ami->registerAction(m_commitCurrentAction,
|
||||
SubversionPlugin::COMMIT_CURRENT, globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
@@ -382,7 +383,7 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
|
||||
subversionMenu->addAction(createSeparator(this, ami, SubversionPlugin::SEPARATOR2, globalcontext));
|
||||
|
||||
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 = ami->registerAction(m_filelogCurrentAction,
|
||||
SubversionPlugin::FILELOG_CURRENT, globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
@@ -390,7 +391,7 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
SLOT(filelogCurrentFile()));
|
||||
subversionMenu->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 = ami->registerAction(m_annotateCurrentAction,
|
||||
SubversionPlugin::ANNOTATE_CURRENT, globalcontext);
|
||||
command->setAttribute(Core::Command::CA_UpdateText);
|
||||
@@ -549,32 +550,21 @@ SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QStri
|
||||
|
||||
void SubversionPlugin::updateActions()
|
||||
{
|
||||
const QString fileName = currentFileName();
|
||||
const bool hasFile = !fileName.isEmpty();
|
||||
|
||||
m_addAction->setEnabled(hasFile);
|
||||
m_deleteAction->setEnabled(hasFile);
|
||||
m_revertAction->setEnabled(hasFile);
|
||||
m_diffProjectAction->setEnabled(true);
|
||||
m_diffCurrentAction->setEnabled(hasFile);
|
||||
m_commitAllAction->setEnabled(true);
|
||||
m_commitCurrentAction->setEnabled(hasFile);
|
||||
m_filelogCurrentAction->setEnabled(hasFile);
|
||||
m_annotateCurrentAction->setEnabled(hasFile);
|
||||
m_statusAction->setEnabled(true);
|
||||
m_describeAction->setEnabled(true);
|
||||
|
||||
QString baseName;
|
||||
if (hasFile)
|
||||
baseName = QFileInfo(fileName).fileName();
|
||||
const QString fileName = currentFileName();
|
||||
const QString baseName = fileName.isEmpty() ? fileName : QFileInfo(fileName).fileName();
|
||||
|
||||
m_addAction->setText(tr("Add %1").arg(baseName));
|
||||
m_deleteAction->setText(tr("Delete %1").arg(baseName));
|
||||
m_revertAction->setText(tr("Revert %1").arg(baseName));
|
||||
m_diffCurrentAction->setText(tr("Diff %1").arg(baseName));
|
||||
m_commitCurrentAction->setText(tr("Commit %1").arg(baseName));
|
||||
m_filelogCurrentAction->setText(tr("Filelog %1").arg(baseName));
|
||||
m_annotateCurrentAction->setText(tr("Annotate %1").arg(baseName));
|
||||
m_addAction->setParameter(baseName);
|
||||
m_deleteAction->setParameter(baseName);
|
||||
m_revertAction->setParameter(baseName);
|
||||
m_diffCurrentAction->setParameter(baseName);
|
||||
m_commitCurrentAction->setParameter(baseName);
|
||||
m_filelogCurrentAction->setParameter(baseName);
|
||||
m_annotateCurrentAction->setParameter(baseName);
|
||||
}
|
||||
|
||||
void SubversionPlugin::addCurrentFile()
|
||||
|
||||
@@ -52,6 +52,9 @@ QT_END_NAMESPACE
|
||||
namespace Core {
|
||||
class IEditorFactory;
|
||||
class IVersionControl;
|
||||
namespace Utils {
|
||||
class ParameterAction;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -151,15 +154,15 @@ private:
|
||||
SubversionOutputWindow *m_subversionOutputWindow;
|
||||
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
|
||||
|
||||
QAction *m_addAction;
|
||||
QAction *m_deleteAction;
|
||||
QAction *m_revertAction;
|
||||
Core::Utils::ParameterAction *m_addAction;
|
||||
Core::Utils::ParameterAction *m_deleteAction;
|
||||
Core::Utils::ParameterAction *m_revertAction;
|
||||
QAction *m_diffProjectAction;
|
||||
QAction *m_diffCurrentAction;
|
||||
Core::Utils::ParameterAction *m_diffCurrentAction;
|
||||
QAction *m_commitAllAction;
|
||||
QAction *m_commitCurrentAction;
|
||||
QAction *m_filelogCurrentAction;
|
||||
QAction *m_annotateCurrentAction;
|
||||
Core::Utils::ParameterAction *m_commitCurrentAction;
|
||||
Core::Utils::ParameterAction *m_filelogCurrentAction;
|
||||
Core::Utils::ParameterAction *m_annotateCurrentAction;
|
||||
QAction *m_statusAction;
|
||||
QAction *m_updateProjectAction;
|
||||
QAction *m_describeAction;
|
||||
|
||||
Reference in New Issue
Block a user