| ︙ | | | ︙ | |
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
recentWorkspaceActs[i] = new QAction(this);
recentWorkspaceActs[i]->setVisible(false);
connect(recentWorkspaceActs[i], SIGNAL(triggered()), this, SLOT(onOpenRecent()));
ui->menuFile->insertAction(recent_sep, recentWorkspaceActs[i]);
}
// Custom Actions
//ui->fileTableView->addAction(separator);
for(int i = 0; i < settings.GetCustomActions().size(); ++i)
{
customActions[i] = new QAction(this);
customActions[i]->setVisible(false);
connect(customActions[i], SIGNAL(triggered()), this, SLOT(on_actionCustomAction_triggered()));
customActions[i]->setData(i);
customActions[i]->setShortcut(QKeySequence(QString("Ctrl+%0").arg(i+1)));
|
<
|
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
recentWorkspaceActs[i] = new QAction(this);
recentWorkspaceActs[i]->setVisible(false);
connect(recentWorkspaceActs[i], SIGNAL(triggered()), this, SLOT(onOpenRecent()));
ui->menuFile->insertAction(recent_sep, recentWorkspaceActs[i]);
}
// Custom Actions
for(int i = 0; i < settings.GetCustomActions().size(); ++i)
{
customActions[i] = new QAction(this);
customActions[i]->setVisible(false);
connect(customActions[i], SIGNAL(triggered()), this, SLOT(on_actionCustomAction_triggered()));
customActions[i]->setData(i);
customActions[i]->setShortcut(QKeySequence(QString("Ctrl+%0").arg(i+1)));
|
| ︙ | | | ︙ | |
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
|
if(store->contains("Context"))
action.Context = static_cast<CustomActionContext>(store->value("Context").toInt());
++last_action;
}
store->endArray();
applyUserActions();
}
//------------------------------------------------------------------------------
void MainWindow::updateSettings()
{
QSettings *store = settings.GetStore();
|
|
|
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
|
if(store->contains("Context"))
action.Context = static_cast<CustomActionContext>(store->value("Context").toInt());
++last_action;
}
store->endArray();
updateCustomActions();
}
//------------------------------------------------------------------------------
void MainWindow::updateSettings()
{
QSettings *store = settings.GetStore();
|
| ︙ | | | ︙ | |
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
|
QModelIndexList selection = ui->workspaceTreeView->selectionModel()->selectedIndexes();
foreach(const QModelIndex &mi, selection)
{
QVariant data = mi.model()->data(mi, ROLE_WORKSPACE_ITEM);
Q_ASSERT(data.isValid());
WorkspaceItem tv = data.value<WorkspaceItem>();
if(tv.Type != WorkspaceItem::TYPE_FOLDER)
continue;
paths.insert(tv.Value);
}
}
//------------------------------------------------------------------------------
// Select all workspace files that match the includeMask
|
|
|
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
|
QModelIndexList selection = ui->workspaceTreeView->selectionModel()->selectedIndexes();
foreach(const QModelIndex &mi, selection)
{
QVariant data = mi.model()->data(mi, ROLE_WORKSPACE_ITEM);
Q_ASSERT(data.isValid());
WorkspaceItem tv = data.value<WorkspaceItem>();
if(tv.Type != WorkspaceItem::TYPE_FOLDER && tv.Type != WorkspaceItem::TYPE_WORKSPACE)
continue;
paths.insert(tv.Value);
}
}
//------------------------------------------------------------------------------
// Select all workspace files that match the includeMask
|
| ︙ | | | ︙ | |
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
|
//------------------------------------------------------------------------------
void MainWindow::on_actionSettings_triggered()
{
// Run the dialog
if(!SettingsDialog::run(this, settings))
return;
applyUserActions();
}
//------------------------------------------------------------------------------
void MainWindow::on_actionFossilSettings_triggered()
{
loadFossilSettings();
|
|
|
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
|
//------------------------------------------------------------------------------
void MainWindow::on_actionSettings_triggered()
{
// Run the dialog
if(!SettingsDialog::run(this, settings))
return;
updateCustomActions();
}
//------------------------------------------------------------------------------
void MainWindow::on_actionFossilSettings_triggered()
{
loadFossilSettings();
|
| ︙ | | | ︙ | |
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
|
return;
getWorkspace().removeRemote(url);
updateWorkspaceView();
}
//------------------------------------------------------------------------------
void MainWindow::applyUserActions()
{
Settings::custom_actions_t custom_actions = settings.GetCustomActions();
Q_ASSERT(MAX_CUSTOM_ACTIONS == custom_actions.size());
// Remove All Actions
for(int i = 0; i < custom_actions.size(); ++i)
{
|
|
|
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
|
return;
getWorkspace().removeRemote(url);
updateWorkspaceView();
}
//------------------------------------------------------------------------------
void MainWindow::updateCustomActions()
{
Settings::custom_actions_t custom_actions = settings.GetCustomActions();
Q_ASSERT(MAX_CUSTOM_ACTIONS == custom_actions.size());
// Remove All Actions
for(int i = 0; i < custom_actions.size(); ++i)
{
|
| ︙ | | | ︙ | |
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
|
Q_ASSERT(!cmd.isEmpty());
// Split command from embedded params
QString extra_params;
// Command ends after first space
QChar cmd_char_end = ' ';
int start = 0 ;
// Unless it is a quoted command
if(cmd[0]=='"')
{
cmd_char_end = '"';
start = 1;
}
int cmd_end = cmd.indexOf(cmd_char_end, start);
if(cmd_end != -1)
{
extra_params = cmd.mid(cmd_end+1);
cmd = cmd.left(cmd_end);
}
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
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();
params.append(path);
}
}
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();
params.append(path);
}
}
// Skip action if nothing is available
if(params.empty())
return;
log("<b>"+cmd + " "+params.join(" ")+"</b><br>", true);
QProcess proc(this);
proc.startDetached(cmd, params);
}
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
|
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
<
|
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
|
Q_ASSERT(!cmd.isEmpty());
// Split command from embedded params
QString extra_params;
// Command ends after first space
QChar cmd_char_end = ' ';
int start = 0;
// ...unless it is a quoted command
if(cmd[0]=='"')
{
cmd_char_end = '"';
start = 1;
}
int cmd_end = cmd.indexOf(cmd_char_end, start);
if(cmd_end != -1)
{
extra_params = cmd.mid(cmd_end+1);
cmd = cmd.left(cmd_end);
}
cmd = cmd.trimmed();
extra_params = extra_params.trimmed();
// 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(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(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);
}
}
// Skip action if nothing is available
if(params.empty())
return;
log("<b>"+cmd + " "+params.join(" ")+"</b><br>", true);
QProcess proc(this);
proc.startDetached(cmd, params);
}
|