Custom actions now expect macros for file and folder expansion
Custom actions now trigger even without a selection Use native path separators in custom actions FossilOrigin-Name: e017a9126cf63ed060dd88accfcabbd9726e9aa7
This commit is contained in:
@@ -89,7 +89,7 @@ void SettingsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
CustomAction &a = currentCustomActions[i];
|
||||
a.Description = a.Description.trimmed();
|
||||
a.Command = QDir::fromNativeSeparators(a.Command.trimmed());
|
||||
a.Command = a.Command.trimmed();
|
||||
}
|
||||
|
||||
PutCustomAction(ui->cmbCustomAction->currentIndex());
|
||||
@@ -157,8 +157,14 @@ QString SettingsDialog::LangNameToId(const QString &name)
|
||||
void SettingsDialog::on_btnSelectCustomFileActionCommand_clicked()
|
||||
{
|
||||
QString path = SelectExe(this, tr("Select command"));
|
||||
if(!path.isEmpty())
|
||||
ui->lineCustomActionCommand->setText(QDir::toNativeSeparators(path));
|
||||
if(path.isEmpty())
|
||||
return;
|
||||
|
||||
// Quote path if it contains spaces
|
||||
if(path.indexOf(' ')!=-1)
|
||||
path = '"' + path + '"';
|
||||
|
||||
ui->lineCustomActionCommand->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -178,7 +184,7 @@ void SettingsDialog::PutCustomAction(int index)
|
||||
Q_ASSERT(index>=0 && index < currentCustomActions.size());
|
||||
CustomAction &action = currentCustomActions[index];
|
||||
action.Description = ui->lineCustomActionDescription->text().trimmed();
|
||||
action.Command = QDir::fromNativeSeparators(ui->lineCustomActionCommand->text().trimmed());
|
||||
action.Command = ui->lineCustomActionCommand->text().trimmed();
|
||||
action.Context = static_cast<CustomActionContext>(ui->cmbCustomActionContext->currentIndex()+1);
|
||||
action.MultipleSelection = ui->chkCustomActionMultipleSelection->isChecked();
|
||||
}
|
||||
|
@@ -581,7 +581,7 @@ bool SpawnExternalProcess(QObject *processParent, const QString& command, const
|
||||
{
|
||||
// Add in-place
|
||||
QString n = p;
|
||||
n.replace(MACRO_WORKSPACE, workspaceDir, Qt::CaseInsensitive);
|
||||
n.replace(MACRO_WORKSPACE, QDir::toNativeSeparators(workspaceDir), Qt::CaseInsensitive);
|
||||
params.push_back(n);
|
||||
continue;
|
||||
}
|
||||
@@ -591,39 +591,31 @@ bool SpawnExternalProcess(QObject *processParent, const QString& command, const
|
||||
}
|
||||
|
||||
// Build file params
|
||||
foreach(const QString &f, fileList)
|
||||
if(!macro_file.isEmpty())
|
||||
{
|
||||
QString path = QFileInfo(workspaceDir + PATH_SEPARATOR + f).absoluteFilePath();
|
||||
|
||||
// Apply macro
|
||||
if(!macro_file.isEmpty())
|
||||
foreach(const QString &f, fileList)
|
||||
{
|
||||
QString path = QDir::toNativeSeparators(QFileInfo(workspaceDir + PATH_SEPARATOR + f).absoluteFilePath());
|
||||
|
||||
QString macro = macro_file;
|
||||
path = macro.replace(MACRO_FILE, path, Qt::CaseInsensitive);
|
||||
params.append(path);
|
||||
}
|
||||
|
||||
params.append(path);
|
||||
}
|
||||
|
||||
|
||||
// Build folder params
|
||||
foreach(const QString &f, pathSet)
|
||||
if(!macro_folder.isEmpty())
|
||||
{
|
||||
QString path = QFileInfo(workspaceDir + PATH_SEPARATOR + f).absoluteFilePath();
|
||||
|
||||
// Apply macro
|
||||
if(!macro_folder.isEmpty())
|
||||
foreach(const QString &f, pathSet)
|
||||
{
|
||||
QString path = QDir::toNativeSeparators(QFileInfo(workspaceDir + PATH_SEPARATOR + f).absoluteFilePath());
|
||||
|
||||
QString macro = macro_folder;
|
||||
path = macro.replace(MACRO_FOLDER, path, Qt::CaseInsensitive);
|
||||
params.append(path);
|
||||
}
|
||||
params.append(path);
|
||||
}
|
||||
|
||||
// Skip action if nothing is available
|
||||
if(params.empty())
|
||||
return false;
|
||||
|
||||
uiCallback.logText("<b>"+cmd + " "+params.join(" ")+"</b><br>", true);
|
||||
|
||||
QProcess proc(processParent);
|
||||
|
Reference in New Issue
Block a user