Initial work on user defined file actions
FossilOrigin-Name: c1562dbda3ad33559227bb0d2fd177e35cae6681
This commit is contained in:
@@ -106,11 +106,14 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
|
||||
ui->fileTableView->addAction(ui->actionHistory);
|
||||
ui->fileTableView->addAction(ui->actionOpenFile);
|
||||
ui->fileTableView->addAction(ui->actionOpenContaining);
|
||||
ui->actionCustomFileAction->setVisible(false);
|
||||
ui->fileTableView->addAction(ui->actionCustomFileAction);
|
||||
ui->fileTableView->addAction(separator);
|
||||
ui->fileTableView->addAction(ui->actionAdd);
|
||||
ui->fileTableView->addAction(ui->actionRevert);
|
||||
ui->fileTableView->addAction(ui->actionRename);
|
||||
ui->fileTableView->addAction(ui->actionDelete);
|
||||
|
||||
connect( ui->fileTableView,
|
||||
SIGNAL( dragOutEvent() ),
|
||||
SLOT( onFileViewDragOut() ),
|
||||
@@ -604,7 +607,8 @@ void MainWindow::enableActions(bool on)
|
||||
ui->actionDeleteTag,
|
||||
ui->actionCreateBranch,
|
||||
ui->actionMergeBranch,
|
||||
ui->actionFossilSettings
|
||||
ui->actionFossilSettings,
|
||||
ui->actionCustomFileAction
|
||||
};
|
||||
|
||||
for(size_t i=0; i<COUNTOF(actions); ++i)
|
||||
@@ -1055,6 +1059,8 @@ void MainWindow::applySettings()
|
||||
// Set the workspace after loading the settings, since it may trigger a remote info storage
|
||||
if(!active_workspace.isEmpty())
|
||||
setCurrentWorkspace(active_workspace);
|
||||
|
||||
applyUserActions();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -1654,6 +1660,8 @@ void MainWindow::on_actionSettings_triggered()
|
||||
// Run the dialog
|
||||
if(!SettingsDialog::run(this, settings))
|
||||
return;
|
||||
|
||||
applyUserActions();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -2440,7 +2448,7 @@ void MainWindow::on_actionCreateBranch_triggered()
|
||||
updateRevision(branch_name);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::MergeRevision(const QString &defaultRevision)
|
||||
void MainWindow::mergeRevision(const QString &defaultRevision)
|
||||
{
|
||||
QStringList res;
|
||||
QString revision = defaultRevision;
|
||||
@@ -2474,7 +2482,7 @@ void MainWindow::on_actionMergeBranch_triggered()
|
||||
|
||||
if(!selectedBranches.isEmpty())
|
||||
revision = selectedBranches.first();
|
||||
MergeRevision(revision);
|
||||
mergeRevision(revision);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -2661,3 +2669,45 @@ void MainWindow::on_actionDeleteRemote_triggered()
|
||||
updateWorkspaceView();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::applyUserActions()
|
||||
{
|
||||
QString fileaction_name;
|
||||
QString fileaction_cmd;
|
||||
|
||||
if(settings.HasValue(FUEL_SETTING_FILEACTION_NAME) && settings.HasValue(FUEL_SETTING_FILEACTION_COMMAND))
|
||||
{
|
||||
fileaction_name = settings.GetValue(FUEL_SETTING_FILEACTION_NAME).toString();
|
||||
fileaction_cmd = settings.GetValue(FUEL_SETTING_FILEACTION_COMMAND).toString();
|
||||
}
|
||||
|
||||
if(!fileaction_name.isEmpty() && !fileaction_cmd.isEmpty())
|
||||
{
|
||||
ui->actionCustomFileAction->setVisible(true);
|
||||
ui->actionCustomFileAction->setText(fileaction_name);
|
||||
}
|
||||
else
|
||||
ui->actionCustomFileAction->setVisible(false);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionCustomFileAction_triggered()
|
||||
{
|
||||
if(!settings.HasValue(FUEL_SETTING_FILEACTION_NAME) || !settings.HasValue(FUEL_SETTING_FILEACTION_COMMAND))
|
||||
return;
|
||||
|
||||
QStringList selection;
|
||||
getSelectionFilenames(selection, WorkspaceFile::TYPE_ALL);
|
||||
|
||||
QProcess proc(this);
|
||||
|
||||
QStringList params;
|
||||
foreach(const QString &f, selection)
|
||||
{
|
||||
QString path = QFileInfo(fossil().getCurrentWorkspace() + "/" + f).absoluteFilePath();
|
||||
params.append(path);
|
||||
}
|
||||
|
||||
const QString &cmd = settings.GetValue(FUEL_SETTING_FILEACTION_COMMAND).toString();
|
||||
proc.startDetached(cmd, params);
|
||||
}
|
||||
|
@@ -52,7 +52,9 @@ private:
|
||||
void updateWorkspaceView();
|
||||
void updateFileView();
|
||||
void selectRootDir();
|
||||
void MergeRevision(const QString& defaultRevision);
|
||||
void mergeRevision(const QString& defaultRevision);
|
||||
void applyUserActions();
|
||||
|
||||
|
||||
void fossilBrowse(const QString &fossilUrl);
|
||||
void dragEnterEvent(class QDragEnterEvent *event);
|
||||
@@ -132,6 +134,7 @@ private slots:
|
||||
void on_actionSetDefaultRemote_triggered();
|
||||
void on_actionAddRemote_triggered();
|
||||
void on_actionDeleteRemote_triggered();
|
||||
void on_actionCustomFileAction_triggered();
|
||||
|
||||
private:
|
||||
class MainWinUICallback : public UICallback
|
||||
|
@@ -37,6 +37,11 @@ Settings::Settings(bool portableMode) : store(0)
|
||||
if(!HasValue(FUEL_SETTING_WEB_BROWSER))
|
||||
SetValue(FUEL_SETTING_WEB_BROWSER, 0);
|
||||
|
||||
if(!HasValue(FUEL_SETTING_FILEACTION_NAME))
|
||||
SetValue(FUEL_SETTING_FILEACTION_NAME, "");
|
||||
if(!HasValue(FUEL_SETTING_FILEACTION_COMMAND))
|
||||
SetValue(FUEL_SETTING_FILEACTION_COMMAND, "");
|
||||
|
||||
ApplyEnvironment();
|
||||
}
|
||||
|
||||
|
@@ -10,6 +10,8 @@
|
||||
#define FUEL_SETTING_FILE_DBLCLICK "FileDblClickAction"
|
||||
#define FUEL_SETTING_LANGUAGE "Language"
|
||||
#define FUEL_SETTING_WEB_BROWSER "WebBrowser"
|
||||
#define FUEL_SETTING_FILEACTION_NAME "FileActionName"
|
||||
#define FUEL_SETTING_FILEACTION_COMMAND "FileActionCommand"
|
||||
|
||||
#define FOSSIL_SETTING_GDIFF_CMD "gdiff-command"
|
||||
#define FOSSIL_SETTING_GMERGE_CMD "gmerge-command"
|
||||
|
@@ -26,6 +26,9 @@ SettingsDialog::SettingsDialog(QWidget *parent, Settings &_settings) :
|
||||
ui->cmbDoubleClickAction->setCurrentIndex(settings->GetValue(FUEL_SETTING_FILE_DBLCLICK).toInt());
|
||||
ui->cmbFossilBrowser->setCurrentIndex(settings->GetValue(FUEL_SETTING_WEB_BROWSER).toInt());
|
||||
|
||||
ui->lineCustomFileActionName->setText(settings->GetValue(FUEL_SETTING_FILEACTION_NAME).toString());
|
||||
ui->lineCustomFileActionCommand->setText(settings->GetValue(FUEL_SETTING_FILEACTION_COMMAND).toString());
|
||||
|
||||
// Initialize language combo
|
||||
foreach(const LangMap &m, langMap)
|
||||
ui->cmbActiveLanguage->addItem(m.name);
|
||||
@@ -68,6 +71,12 @@ void SettingsDialog::on_buttonBox_accepted()
|
||||
if(curr_langid != new_langid)
|
||||
QMessageBox::information(this, tr("Restart required"), tr("The language change will take effect after restarting the application"), QMessageBox::Ok);
|
||||
|
||||
|
||||
Q_ASSERT(settings->HasValue(FUEL_SETTING_FILEACTION_NAME));
|
||||
settings->SetValue(FUEL_SETTING_FILEACTION_NAME, ui->lineCustomFileActionName->text().trimmed());
|
||||
Q_ASSERT(settings->HasValue(FUEL_SETTING_FILEACTION_COMMAND));
|
||||
settings->SetValue(FUEL_SETTING_FILEACTION_COMMAND, QDir::fromNativeSeparators(ui->lineCustomFileActionCommand->text().trimmed()));
|
||||
|
||||
settings->ApplyEnvironment();
|
||||
}
|
||||
|
||||
@@ -121,3 +130,11 @@ QString SettingsDialog::LangNameToId(const QString &name)
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::on_btnSelectCustomFileActionCommand_clicked()
|
||||
{
|
||||
QString path = SelectExe(this, tr("Select executable"));
|
||||
if(!path.isEmpty())
|
||||
ui->lineCustomFileActionCommand->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ private slots:
|
||||
void on_btnSelectFossil_clicked();
|
||||
void on_buttonBox_accepted();
|
||||
void on_btnClearMessageHistory_clicked();
|
||||
void on_btnSelectCustomFileActionCommand_clicked();
|
||||
|
||||
private:
|
||||
QString LangIdToName(const QString &id);
|
||||
|
Reference in New Issue
Block a user