Custom actions now support explicit single selections
FossilOrigin-Name: e422f84c485ada3ae538712434ae64ea80021f8b
This commit is contained in:
@@ -1097,6 +1097,8 @@ void MainWindow::applySettings()
|
||||
action.Command = store->value("Command").toString();
|
||||
if(store->contains("Context"))
|
||||
action.Context = static_cast<CustomActionContext>(store->value("Context").toInt());
|
||||
if(store->contains("MultipleSelection"))
|
||||
action.MultipleSelection = store->value("MultipleSelection").toBool();
|
||||
|
||||
++last_action;
|
||||
}
|
||||
@@ -1156,6 +1158,7 @@ void MainWindow::updateSettings()
|
||||
store->setValue("Description", action.Description);
|
||||
store->setValue("Command", action.Command);
|
||||
store->setValue("Context", static_cast<int>(action.Context));
|
||||
store->setValue("MultipleSelection", action.MultipleSelection);
|
||||
++active_actions;
|
||||
}
|
||||
store->endArray();
|
||||
@@ -2801,6 +2804,24 @@ void MainWindow::on_actionCustomAction_triggered()
|
||||
if(cust_action.IsActive(ACTION_CONTEXT_FOLDERS))
|
||||
getSelectionPaths(path_selection);
|
||||
|
||||
// Trim excess items for single selection
|
||||
if(!cust_action.MultipleSelection)
|
||||
{
|
||||
if(!file_selection.empty())
|
||||
{
|
||||
QString item = *file_selection.begin();
|
||||
file_selection.clear();
|
||||
file_selection.push_back(item);
|
||||
path_selection.clear();
|
||||
}
|
||||
else if(!path_selection.empty())
|
||||
{
|
||||
QString item = *path_selection.begin();
|
||||
path_selection.clear();
|
||||
path_selection.insert(item);
|
||||
}
|
||||
}
|
||||
|
||||
const QString &wkdir = fossil().getCurrentWorkspace();
|
||||
|
||||
SpawnExternalProcess(this, cust_action.Command, file_selection, path_selection, wkdir, uiCallback);
|
||||
|
@@ -39,7 +39,7 @@ enum CustomActionContext
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_CUSTOM_ACTIONS = 5
|
||||
MAX_CUSTOM_ACTIONS = 9
|
||||
};
|
||||
|
||||
struct CustomAction
|
||||
@@ -48,6 +48,7 @@ struct CustomAction
|
||||
QString Description;
|
||||
QString Command;
|
||||
CustomActionContext Context;
|
||||
bool MultipleSelection;
|
||||
|
||||
CustomAction()
|
||||
{
|
||||
@@ -69,6 +70,7 @@ struct CustomAction
|
||||
Description.clear();
|
||||
Command.clear();
|
||||
Context = ACTION_CONTEXT_FILES;
|
||||
MultipleSelection = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -165,6 +165,7 @@ void SettingsDialog::GetCustomAction(int index)
|
||||
ui->lineCustomActionDescription->setText(action.Description);
|
||||
ui->lineCustomActionCommand->setText(action.Command);
|
||||
ui->cmbCustomActionContext->setCurrentIndex(action.Context-1);
|
||||
ui->chkCustomActionMultipleSelection->setChecked(action.MultipleSelection);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -175,6 +176,7 @@ void SettingsDialog::PutCustomAction(int index)
|
||||
action.Description = ui->lineCustomActionDescription->text().trimmed();
|
||||
action.Command = QDir::fromNativeSeparators(ui->lineCustomActionCommand->text().trimmed());
|
||||
action.Context = static_cast<CustomActionContext>(ui->cmbCustomActionContext->currentIndex()+1);
|
||||
action.MultipleSelection = ui->chkCustomActionMultipleSelection->isChecked();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user