diff --git a/manifest b/manifest index 581f3f5..502d9cb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Support\sfor\smultiple\scustom\sactions\n -D 2015-07-09T18:55:33.249 +C Added\ssupport\sfor\s$FILE\s$FOLDER\sand\s$WORKSPACE\smacros\sin\scustom\saction\scommands +D 2015-07-10T15:36:47.096 F .travis.yml 77966888a81c4ceee1fcc79bce842c9667ad8a35 F debian/changelog eb4304dfcb6bb66850ec740838090eb50ce1249b F debian/compat b6abd567fa79cbe0196d093a067271361dc6ca8b @@ -224,8 +224,8 @@ F src/FslSettingsDialog.cpp 2531d3709f0eab66651671e3edead2ca720d07d5 F src/FslSettingsDialog.h dfe2a61884a55a74cbb9206b6f6b482b979725e7 F src/LoggedProcess.cpp 2a1e5c94bc1e57c8984563e66c210e43a14dc60c F src/LoggedProcess.h 85df7c635c807a5a0e8c4763f17a0752aaff7261 -F src/MainWindow.cpp 272e8424e81eb81b1c7a996ded26a217f9ec45e5 -F src/MainWindow.h b03f3d99985dd6d2bfe406239ca54e69f571db6a +F src/MainWindow.cpp ab8aa79742a0da21ce1d4ddbe894d523f5c7b7a5 +F src/MainWindow.h 573ffe960044afb446505949da50e0fb5ec2f75f F src/RemoteDialog.cpp 8540cc5e2e41c4127ed8a028d84691604fa6ecac F src/RemoteDialog.h 5e0438c2bd7c79b1bb44bfbd58c2181b544a9e5d F src/RevisionDialog.cpp e58c4f8a704f00addebb15d521b76620fdafda79 @@ -252,7 +252,7 @@ F ui/MainWindow.ui 10181826a25056ed5aba2b23a7d110159be7c043 F ui/RemoteDialog.ui 95a4750d972ed8c49bb10b95db91ff16cfe2dd0b F ui/RevisionDialog.ui 27c3b98c665fec014a50cbf3352c0627f75e68cd F ui/SettingsDialog.ui b5858067cdb16c3f132af4cf8332e4ad255c915c -P c1562dbda3ad33559227bb0d2fd177e35cae6681 -R 084d6ff50c0d7d634da28bd5e41e98ef +P 172938d454db50a53cd0e0435991a7fccea59ae7 +R f0292424de125969e84f6add7e808390 U kostas -Z 5e0824e216c8fc6ae7795004bb7a7ace +Z 655910e224b8a744950ce119d86fd60d diff --git a/manifest.uuid b/manifest.uuid index 0885c2c..c2ccd9a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -172938d454db50a53cd0e0435991a7fccea59ae7 \ No newline at end of file +381aa49e9b6b5d5424ee6dbd69d0890634d5bf08 \ No newline at end of file diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 1f73b13..b98f866 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -215,7 +215,6 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP } // Custom Actions - //ui->fileTableView->addAction(separator); for(int i = 0; i < settings.GetCustomActions().size(); ++i) { customActions[i] = new QAction(this); @@ -1103,7 +1102,7 @@ void MainWindow::applySettings() } store->endArray(); - applyUserActions(); + updateCustomActions(); } //------------------------------------------------------------------------------ @@ -1211,7 +1210,7 @@ void MainWindow::getSelectionPaths(stringset_t &paths) Q_ASSERT(data.isValid()); WorkspaceItem tv = data.value(); - if(tv.Type != WorkspaceItem::TYPE_FOLDER) + if(tv.Type != WorkspaceItem::TYPE_FOLDER && tv.Type != WorkspaceItem::TYPE_WORKSPACE) continue; paths.insert(tv.Value); @@ -1722,7 +1721,7 @@ void MainWindow::on_actionSettings_triggered() if(!SettingsDialog::run(this, settings)) return; - applyUserActions(); + updateCustomActions(); } //------------------------------------------------------------------------------ @@ -2731,7 +2730,7 @@ void MainWindow::on_actionDeleteRemote_triggered() } //------------------------------------------------------------------------------ -void MainWindow::applyUserActions() +void MainWindow::updateCustomActions() { Settings::custom_actions_t custom_actions = settings.GetCustomActions(); Q_ASSERT(MAX_CUSTOM_ACTIONS == custom_actions.size()); @@ -2803,9 +2802,9 @@ void MainWindow::on_actionCustomAction_triggered() // Command ends after first space QChar cmd_char_end = ' '; - int start = 0 ; + int start = 0; - // Unless it is a quoted command + // ...unless it is a quoted command if(cmd[0]=='"') { cmd_char_end = '"'; @@ -2821,29 +2820,73 @@ void MainWindow::on_actionCustomAction_triggered() cmd = cmd.trimmed(); extra_params = extra_params.trimmed(); - QStringList extra_param_list = extra_params.split(' '); - foreach(const QString &p, extra_param_list) - params.push_back(p); - // Extract selection + // Push all additional params, except those containing macros + QStringList extra_param_list = extra_params.split(' '); + QString macro_file; + QString macro_folder; + + const QString &wkdir = fossil().getCurrentWorkspace(); + + foreach(const QString &p, extra_param_list) + { + if(p.indexOf("$FILE")!=-1) + { + macro_file = p; + continue; + } + else if(p.indexOf("$FOLDER")!=-1) + { + macro_folder = p; + continue; + } + else if(p.indexOf("$WORKSPACE")!=-1) + { + // Add in-place + QString n = p; + n.replace("$WORKSPACE", wkdir, Qt::CaseInsensitive); + params.push_back(n); + continue; + } + + params.push_back(p); + } + + // Build file params if(cust_action.IsActive(ACTION_CONTEXT_FILES)) { QStringList file_selection; getSelectionFilenames(file_selection, WorkspaceFile::TYPE_ALL); foreach(const QString &f, file_selection) { - QString path = QFileInfo(fossil().getCurrentWorkspace() + "/" + f).absoluteFilePath(); + QString path = QFileInfo(wkdir + PATH_SEPARATOR + f).absoluteFilePath(); + + // Apply macro + if(!macro_file.isEmpty()) + { + QString macro = macro_file; + path = macro.replace("$FILE", path, Qt::CaseInsensitive); + } + params.append(path); } } + // Build folder params if(cust_action.IsActive(ACTION_CONTEXT_FOLDERS)) { stringset_t path_selection; getSelectionPaths(path_selection); foreach(const QString &f, path_selection) { - QString path = QFileInfo(fossil().getCurrentWorkspace() + "/" + f).absoluteFilePath(); + QString path = QFileInfo(wkdir + PATH_SEPARATOR + f).absoluteFilePath(); + + // Apply macro + if(!macro_folder.isEmpty()) + { + QString macro = macro_folder; + path = macro.replace("$FOLDER", path, Qt::CaseInsensitive); + } params.append(path); } } @@ -2852,9 +2895,8 @@ void MainWindow::on_actionCustomAction_triggered() if(params.empty()) return; - log(""+cmd + " "+params.join(" ")+"
", true); QProcess proc(this); proc.startDetached(cmd, params); -} \ No newline at end of file +} diff --git a/src/MainWindow.h b/src/MainWindow.h index 49f7de5..d40eb7c 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -53,7 +53,7 @@ private: void updateFileView(); void selectRootDir(); void mergeRevision(const QString& defaultRevision); - void applyUserActions(); + void updateCustomActions(); void fossilBrowse(const QString &fossilUrl);