- Reorganized settings management
- Added localisation UI - Added Greek localisation - Message text refactoring FossilOrigin-Name: 05f2cac387c4a3863197f794c68421f7e04fb28e
This commit is contained in:
@ -198,7 +198,7 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
|
||||
|
||||
viewMode = VIEWMODE_TREE;
|
||||
|
||||
loadSettings();
|
||||
applySettings();
|
||||
|
||||
// Apply any explicit workspace path if available
|
||||
if(workspacePath && !workspacePath->isEmpty())
|
||||
@ -217,7 +217,7 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
stopUI();
|
||||
saveSettings();
|
||||
updateSettings();
|
||||
|
||||
// Dispose RepoFiles
|
||||
for(filemap_t::iterator it = workspaceFiles.begin(); it!=workspaceFiles.end(); ++it)
|
||||
@ -246,7 +246,7 @@ void MainWindow::setCurrentWorkspace(const QString &workspace)
|
||||
addWorkspace(new_workspace);
|
||||
|
||||
if(!QDir::setCurrent(new_workspace))
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not change current diectory to '%0'").arg(new_workspace), QMessageBox::Ok );
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not change current directory to '%0'").arg(new_workspace), QMessageBox::Ok );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -288,7 +288,7 @@ bool MainWindow::openWorkspace(const QString &path)
|
||||
|
||||
if(!(QFileInfo(checkout_file1).exists() || QFileInfo(checkout_file2).exists()) )
|
||||
{
|
||||
if(QMessageBox::Yes !=DialogQuery(this, tr("Open Fossil"), tr("A workspace does not exist in this folder.\nWould you like to create one here?")))
|
||||
if(QMessageBox::Yes !=DialogQuery(this, tr("Open Workspace"), tr("A workspace does not exist in this folder.\nWould you like to create one here?")))
|
||||
{
|
||||
wkspace = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
@ -366,7 +366,7 @@ void MainWindow::on_actionOpenRepository_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionNewRepository_triggered()
|
||||
{
|
||||
QString filter(tr("Repositories (*.fossil)"));
|
||||
QString filter(tr("Fossil Repositories (*.fossil)"));
|
||||
|
||||
// Get Repository file
|
||||
QString repo_path = QFileDialog::getSaveFileName(
|
||||
@ -591,7 +591,7 @@ bool MainWindow::refresh()
|
||||
}
|
||||
else if(st==REPO_OLD_SCHEMA)
|
||||
{
|
||||
setStatus(tr("Old fossil schema detected. Consider running 'fossil rebuild'"));
|
||||
setStatus(tr("Old repository schema detected. Consider running 'fossil rebuild'"));
|
||||
enableActions(false);
|
||||
repoFileModel.removeRows(0, repoFileModel.rowCount());
|
||||
repoDirModel.clear();
|
||||
@ -648,7 +648,7 @@ void MainWindow::scanWorkspace()
|
||||
if(!ui->actionViewIgnored->isChecked())
|
||||
{
|
||||
// QDir expects multiple specs being separated by a semicolon
|
||||
ignore = settings.Mappings[FUEL_SETTING_IGNORE_GLOB].Value.toString().replace(',',';');
|
||||
ignore = settings.GetFossilValue(FOSSIL_SETTING_IGNORE_GLOB).toString().replace(',',';');
|
||||
}
|
||||
|
||||
scanDirectory(all_files, wkdir, wkdir, ignore);
|
||||
@ -1093,7 +1093,7 @@ bool MainWindow::runFossilRaw(const QStringList &args, QStringList *output, int
|
||||
process.start(fossil, args);
|
||||
if(!process.waitForStarted())
|
||||
{
|
||||
log(tr("Could not start Fossil executable '%s'\n").arg(fossil));
|
||||
log(tr("Could not start Fossil executable '%s'").arg(fossil)+"\n");
|
||||
return false;
|
||||
}
|
||||
const QChar EOL_MARK('\n');
|
||||
@ -1264,7 +1264,7 @@ bool MainWindow::runFossilRaw(const QStringList &args, QStringList *output, int
|
||||
QString MainWindow::getFossilPath()
|
||||
{
|
||||
// Use the user-specified fossil if available
|
||||
QString fossil_path = settings.Mappings[FUEL_SETTING_FOSSIL_PATH].Value.toString();
|
||||
QString fossil_path = settings.GetValue(FUEL_SETTING_FOSSIL_PATH).toString();
|
||||
if(!fossil_path.isEmpty())
|
||||
return QDir::toNativeSeparators(fossil_path);
|
||||
|
||||
@ -1282,22 +1282,15 @@ QString MainWindow::getFossilPath()
|
||||
return fossil_exe;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::loadSettings()
|
||||
void MainWindow::applySettings()
|
||||
{
|
||||
if(settings.store->contains(FUEL_SETTING_FOSSIL_PATH))
|
||||
settings.Mappings[FUEL_SETTING_FOSSIL_PATH].Value = settings.store->value(FUEL_SETTING_FOSSIL_PATH);
|
||||
QSettings *store = settings.GetStore();
|
||||
|
||||
if(settings.store->contains(FUEL_SETTING_COMMIT_MSG))
|
||||
settings.Mappings[FUEL_SETTING_COMMIT_MSG].Value = settings.store->value(FUEL_SETTING_COMMIT_MSG);
|
||||
|
||||
if(settings.store->contains(FUEL_SETTING_FILE_DBLCLICK))
|
||||
settings.Mappings[FUEL_SETTING_FILE_DBLCLICK].Value = settings.store->value(FUEL_SETTING_FILE_DBLCLICK);
|
||||
|
||||
int num_wks = settings.store->beginReadArray("Workspaces");
|
||||
int num_wks = store->beginReadArray("Workspaces");
|
||||
for(int i=0; i<num_wks; ++i)
|
||||
{
|
||||
settings.store->setArrayIndex(i);
|
||||
QString wk = settings.store->value("Path").toString();
|
||||
store->setArrayIndex(i);
|
||||
QString wk = store->value("Path").toString();
|
||||
|
||||
// Skip invalid workspaces
|
||||
if(wk.isEmpty() || !QDir(wk).exists())
|
||||
@ -1305,80 +1298,75 @@ void MainWindow::loadSettings()
|
||||
|
||||
addWorkspace(wk);
|
||||
|
||||
if(settings.store->contains("Active") && settings.store->value("Active").toBool())
|
||||
if(store->contains("Active") && store->value("Active").toBool())
|
||||
setCurrentWorkspace(wk);
|
||||
}
|
||||
settings.store->endArray();
|
||||
store->endArray();
|
||||
|
||||
|
||||
if(settings.store->contains("WindowX") && settings.store->contains("WindowY"))
|
||||
if(store->contains("WindowX") && store->contains("WindowY"))
|
||||
{
|
||||
QPoint _pos;
|
||||
_pos.setX(settings.store->value("WindowX").toInt());
|
||||
_pos.setY(settings.store->value("WindowY").toInt());
|
||||
_pos.setX(store->value("WindowX").toInt());
|
||||
_pos.setY(store->value("WindowY").toInt());
|
||||
move(_pos);
|
||||
}
|
||||
|
||||
if(settings.store->contains("WindowWidth") && settings.store->contains("WindowHeight"))
|
||||
if(store->contains("WindowWidth") && store->contains("WindowHeight"))
|
||||
{
|
||||
QSize _size;
|
||||
_size.setWidth(settings.store->value("WindowWidth").toInt());
|
||||
_size.setHeight(settings.store->value("WindowHeight").toInt());
|
||||
_size.setWidth(store->value("WindowWidth").toInt());
|
||||
_size.setHeight(store->value("WindowHeight").toInt());
|
||||
resize(_size);
|
||||
}
|
||||
|
||||
if(settings.store->contains("ViewUnknown"))
|
||||
ui->actionViewUnknown->setChecked(settings.store->value("ViewUnknown").toBool());
|
||||
if(settings.store->contains("ViewModified"))
|
||||
ui->actionViewModified->setChecked(settings.store->value("ViewModified").toBool());
|
||||
if(settings.store->contains("ViewUnchanged"))
|
||||
ui->actionViewUnchanged->setChecked(settings.store->value("ViewUnchanged").toBool());
|
||||
if(settings.store->contains("ViewIgnored"))
|
||||
ui->actionViewIgnored->setChecked(settings.store->value("ViewIgnored").toBool());
|
||||
if(settings.store->contains("ViewAsList"))
|
||||
if(store->contains("ViewUnknown"))
|
||||
ui->actionViewUnknown->setChecked(store->value("ViewUnknown").toBool());
|
||||
if(store->contains("ViewModified"))
|
||||
ui->actionViewModified->setChecked(store->value("ViewModified").toBool());
|
||||
if(store->contains("ViewUnchanged"))
|
||||
ui->actionViewUnchanged->setChecked(store->value("ViewUnchanged").toBool());
|
||||
if(store->contains("ViewIgnored"))
|
||||
ui->actionViewIgnored->setChecked(store->value("ViewIgnored").toBool());
|
||||
if(store->contains("ViewAsList"))
|
||||
{
|
||||
ui->actionViewAsList->setChecked(settings.store->value("ViewAsList").toBool());
|
||||
viewMode = settings.store->value("ViewAsList").toBool()? VIEWMODE_LIST : VIEWMODE_TREE;
|
||||
ui->actionViewAsList->setChecked(store->value("ViewAsList").toBool());
|
||||
viewMode = store->value("ViewAsList").toBool()? VIEWMODE_LIST : VIEWMODE_TREE;
|
||||
}
|
||||
ui->treeView->setVisible(viewMode == VIEWMODE_TREE);
|
||||
|
||||
if(settings.store->contains("ViewStash"))
|
||||
ui->actionViewStash->setChecked(settings.store->value("ViewStash").toBool());
|
||||
if(store->contains("ViewStash"))
|
||||
ui->actionViewStash->setChecked(store->value("ViewStash").toBool());
|
||||
ui->tableViewStash->setVisible(ui->actionViewStash->isChecked());
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::saveSettings()
|
||||
void MainWindow::updateSettings()
|
||||
{
|
||||
// If we have a customize fossil path, save it
|
||||
QString fossil_path = settings.Mappings[FUEL_SETTING_FOSSIL_PATH].Value.toString();
|
||||
settings.store->setValue(FUEL_SETTING_FOSSIL_PATH, fossil_path);
|
||||
settings.store->setValue(FUEL_SETTING_COMMIT_MSG, settings.Mappings[FUEL_SETTING_COMMIT_MSG].Value);
|
||||
settings.store->setValue(FUEL_SETTING_FILE_DBLCLICK, settings.Mappings[FUEL_SETTING_FILE_DBLCLICK].Value);
|
||||
QSettings *store = settings.GetStore();
|
||||
|
||||
settings.store->beginWriteArray("Workspaces", workspaceHistory.size());
|
||||
store->beginWriteArray("Workspaces", workspaceHistory.size());
|
||||
for(int i=0; i<workspaceHistory.size(); ++i)
|
||||
{
|
||||
settings.store->setArrayIndex(i);
|
||||
settings.store->setValue("Path", workspaceHistory[i]);
|
||||
store->setArrayIndex(i);
|
||||
store->setValue("Path", workspaceHistory[i]);
|
||||
if(getCurrentWorkspace() == workspaceHistory[i])
|
||||
settings.store->setValue("Active", true);
|
||||
store->setValue("Active", true);
|
||||
else
|
||||
settings.store->remove("Active");
|
||||
store->remove("Active");
|
||||
}
|
||||
settings.store->endArray();
|
||||
store->endArray();
|
||||
|
||||
settings.store->setValue("WindowX", x());
|
||||
settings.store->setValue("WindowY", y());
|
||||
settings.store->setValue("WindowWidth", width());
|
||||
settings.store->setValue("WindowHeight", height());
|
||||
settings.store->setValue("ViewUnknown", ui->actionViewUnknown->isChecked());
|
||||
settings.store->setValue("ViewModified", ui->actionViewModified->isChecked());
|
||||
settings.store->setValue("ViewUnchanged", ui->actionViewUnchanged->isChecked());
|
||||
settings.store->setValue("ViewIgnored", ui->actionViewIgnored->isChecked());
|
||||
settings.store->setValue("ViewAsList", ui->actionViewAsList->isChecked());
|
||||
settings.store->setValue("ViewStash", ui->actionViewStash->isChecked());
|
||||
store->setValue("WindowX", x());
|
||||
store->setValue("WindowY", y());
|
||||
store->setValue("WindowWidth", width());
|
||||
store->setValue("WindowHeight", height());
|
||||
store->setValue("ViewUnknown", ui->actionViewUnknown->isChecked());
|
||||
store->setValue("ViewModified", ui->actionViewModified->isChecked());
|
||||
store->setValue("ViewUnchanged", ui->actionViewUnchanged->isChecked());
|
||||
store->setValue("ViewIgnored", ui->actionViewIgnored->isChecked());
|
||||
store->setValue("ViewAsList", ui->actionViewAsList->isChecked());
|
||||
store->setValue("ViewStash", ui->actionViewStash->isChecked());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -1551,7 +1539,7 @@ bool MainWindow::startUI()
|
||||
{
|
||||
if(uiRunning())
|
||||
{
|
||||
log(tr("Fossil UI is already running\n"));
|
||||
log(tr("Fossil UI is already running")+"\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1560,13 +1548,13 @@ bool MainWindow::startUI()
|
||||
fossilUI.setWorkingDirectory(getCurrentWorkspace());
|
||||
|
||||
log("<b>> fossil ui</b><br>", true);
|
||||
log(tr("Starting Fossil browser UI. Please wait.\n"));
|
||||
log(tr("Starting Fossil browser UI. Please wait.")+"\n");
|
||||
QString fossil = getFossilPath();
|
||||
|
||||
fossilUI.start(fossil, QStringList() << "ui");
|
||||
if(!fossilUI.waitForStarted() || fossilUI.state()!=QProcess::Running)
|
||||
{
|
||||
log(tr("Could not start Fossil executable '%s'\n").arg(fossil));
|
||||
log(tr("Could not start Fossil executable '%s'").arg(fossil)+"\n");
|
||||
ui->actionFossilUI->setChecked(false);
|
||||
return false;
|
||||
}
|
||||
@ -1659,7 +1647,7 @@ void MainWindow::on_actionHistory_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_tableView_doubleClicked(const QModelIndex &/*index*/)
|
||||
{
|
||||
int action = settings.Mappings[FUEL_SETTING_FILE_DBLCLICK].Value.toInt();
|
||||
int action = settings.GetValue(FUEL_SETTING_FILE_DBLCLICK).toInt();
|
||||
if(action==FILE_DLBCLICK_ACTION_DIFF)
|
||||
on_actionDiff_triggered();
|
||||
else if(action==FILE_DLBCLICK_ACTION_OPEN)
|
||||
@ -1683,7 +1671,7 @@ void MainWindow::on_actionOpenFile_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionPush_triggered()
|
||||
{
|
||||
QString remote_url = settings.Mappings[FUEL_SETTING_REMOTE_URL].Value.toString();
|
||||
QString remote_url = settings.GetFossilValue(FOSSIL_SETTING_REMOTE_URL).toString();
|
||||
|
||||
if(remote_url.isEmpty() || remote_url == "off")
|
||||
{
|
||||
@ -1697,7 +1685,7 @@ void MainWindow::on_actionPush_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionPull_triggered()
|
||||
{
|
||||
QString remote_url = settings.Mappings[FUEL_SETTING_REMOTE_URL].Value.toString();
|
||||
QString remote_url = settings.GetFossilValue(FOSSIL_SETTING_REMOTE_URL).toString();
|
||||
|
||||
if(remote_url.isEmpty() || remote_url == "off")
|
||||
{
|
||||
@ -1717,7 +1705,7 @@ void MainWindow::on_actionCommit_triggered()
|
||||
if(commit_files.empty())
|
||||
return;
|
||||
|
||||
QStringList commit_msgs = settings.Mappings[FUEL_SETTING_COMMIT_MSG].Value.toStringList();
|
||||
QStringList commit_msgs = settings.GetValue(FUEL_SETTING_COMMIT_MSG).toStringList();
|
||||
|
||||
QString msg;
|
||||
bool aborted = !CommitDialog::run(this, tr("Commit Changes"), commit_files, msg, &commit_msgs);
|
||||
@ -1727,7 +1715,7 @@ void MainWindow::on_actionCommit_triggered()
|
||||
if(commit_msgs.indexOf(msg)==-1)
|
||||
{
|
||||
commit_msgs.push_front(msg);
|
||||
settings.Mappings[FUEL_SETTING_COMMIT_MSG].Value = commit_msgs;
|
||||
settings.SetValue(FUEL_SETTING_COMMIT_MSG, commit_msgs);
|
||||
}
|
||||
|
||||
if(aborted)
|
||||
@ -1867,7 +1855,7 @@ void MainWindow::on_actionRename_triggered()
|
||||
QFileInfo fi_before(repo_files[0]);
|
||||
|
||||
bool ok = false;
|
||||
QString new_name = QInputDialog::getText(this, tr("Rename"), tr("Enter new name"), QLineEdit::Normal, fi_before.filePath(), &ok, Qt::Sheet );
|
||||
QString new_name = QInputDialog::getText(this, tr("Rename"), tr("New name"), QLineEdit::Normal, fi_before.filePath(), &ok, Qt::Sheet );
|
||||
if(!ok)
|
||||
return;
|
||||
|
||||
@ -1948,7 +1936,7 @@ void MainWindow::on_actionAbout_triggered()
|
||||
QCoreApplication::applicationName() + " "+ QCoreApplication::applicationVersion() + " " +
|
||||
tr("a GUI frontend to the Fossil SCM\n"
|
||||
"by Kostas Karanikolas\n"
|
||||
"Released under the GNU GPL\n\n")
|
||||
"Released under the GNU GPL")+"\n\n"
|
||||
+ fossil_ver +
|
||||
tr("Icon-set by Deleket - Jojo Mendoza\n"
|
||||
"Available under the CC Attribution Noncommercial No Derivate 3.0 License"));
|
||||
@ -1984,15 +1972,11 @@ void MainWindow::loadFossilSettings()
|
||||
|
||||
QStringMap kv = MakeKeyValues(out);
|
||||
|
||||
for(Settings::mappings_t::iterator it=settings.Mappings.begin(); it!=settings.Mappings.end(); ++it)
|
||||
for(Settings::mappings_t::iterator it=settings.GetMappings().begin(); it!=settings.GetMappings().end(); ++it)
|
||||
{
|
||||
const QString &name = it.key();
|
||||
Settings::Setting::SettingType type = it->Type;
|
||||
|
||||
// Internal types are handled explicitly
|
||||
if(type == Settings::Setting::TYPE_INTERNAL)
|
||||
continue;
|
||||
|
||||
// Command types we issue directly on fossil
|
||||
if(type == Settings::Setting::TYPE_FOSSIL_COMMAND)
|
||||
{
|
||||
@ -2034,15 +2018,11 @@ void MainWindow::on_actionSettings_triggered()
|
||||
return;
|
||||
|
||||
// Apply settings
|
||||
for(Settings::mappings_t::iterator it=settings.Mappings.begin(); it!=settings.Mappings.end(); ++it)
|
||||
for(Settings::mappings_t::iterator it=settings.GetMappings().begin(); it!=settings.GetMappings().end(); ++it)
|
||||
{
|
||||
const QString &name = it.key();
|
||||
Settings::Setting::SettingType type = it.value().Type;
|
||||
|
||||
// Internal types are handled explicitly
|
||||
if(type == Settings::Setting::TYPE_INTERNAL)
|
||||
continue;
|
||||
|
||||
// Command types we issue directly on fossil
|
||||
if(type == Settings::Setting::TYPE_FOSSIL_COMMAND)
|
||||
{
|
||||
@ -2178,7 +2158,7 @@ void MainWindow::on_actionRenameFolder_triggered()
|
||||
QString old_name = old_path.mid(dir_start);
|
||||
|
||||
bool ok = false;
|
||||
QString new_name = QInputDialog::getText(this, tr("Rename Folder"), tr("Enter new name"), QLineEdit::Normal, old_name, &ok, Qt::Sheet);
|
||||
QString new_name = QInputDialog::getText(this, tr("Rename Folder"), tr("New name"), QLineEdit::Normal, old_name, &ok, Qt::Sheet);
|
||||
if(!ok || old_name==new_name)
|
||||
return;
|
||||
|
||||
@ -2190,7 +2170,7 @@ void MainWindow::on_actionRenameFolder_triggered()
|
||||
{
|
||||
if(new_name.indexOf(invalid_tokens[i])!=-1)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Cannot rename folder.\nFolder name contains invalid characters."));
|
||||
QMessageBox::critical(this, tr("Error"), tr("Cannot rename folder.")+"\n" +tr("Folder name contains invalid characters."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2199,7 +2179,7 @@ void MainWindow::on_actionRenameFolder_triggered()
|
||||
|
||||
if(pathSet.contains(new_path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Cannot rename folder.\nThis folder exists already."));
|
||||
QMessageBox::critical(this, tr("Error"), tr("Cannot rename folder.")+"\n" +tr("This folder exists already."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2239,7 +2219,7 @@ void MainWindow::on_actionRenameFolder_triggered()
|
||||
|
||||
if(!runFossil(QStringList() << "mv" << QuotePath(r->getFilePath()) << QuotePath(new_file_path)))
|
||||
{
|
||||
log(tr("Move aborted due to errors\n"));
|
||||
log(tr("Move aborted due to errors")+"\n");
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
@ -2259,10 +2239,10 @@ void MainWindow::on_actionRenameFolder_triggered()
|
||||
QDir wkdir(getCurrentWorkspace());
|
||||
Q_ASSERT(wkdir.exists());
|
||||
|
||||
log(tr("Creating folder '%0'\n").arg(target_path));
|
||||
log(tr("Creating folder '%0'").arg(target_path)+"\n");
|
||||
if(!wkdir.mkpath(new_paths[i] + PATH_SEP + "."))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Cannot make target folder '%0'\n").arg(target_path));
|
||||
QMessageBox::critical(this, tr("Error"), tr("Cannot make target folder '%0'").arg(target_path));
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
@ -2279,7 +2259,7 @@ void MainWindow::on_actionRenameFolder_triggered()
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
log(tr("Copying file '%0' to '%1'\n").arg(r->getFilePath(), new_file_path));
|
||||
log(tr("Copying file '%0' to '%1'").arg(r->getFilePath(), new_file_path)+"\n");
|
||||
|
||||
if(!QFile::copy(r->getFilePath(), new_file_path))
|
||||
{
|
||||
@ -2293,7 +2273,7 @@ void MainWindow::on_actionRenameFolder_triggered()
|
||||
{
|
||||
RepoFile *r = files_to_move[i];
|
||||
|
||||
log(tr("Removing old file '%0'\n").arg(r->getFilePath()));
|
||||
log(tr("Removing old file '%0'").arg(r->getFilePath())+"\n");
|
||||
|
||||
if(!QFile::exists(r->getFilePath()))
|
||||
{
|
||||
@ -2308,7 +2288,7 @@ void MainWindow::on_actionRenameFolder_triggered()
|
||||
}
|
||||
}
|
||||
|
||||
log(tr("Folder renamed completed. Don't forget to commit!\n"));
|
||||
log(tr("Folder renamed completed. Don't forget to commit!")+"\n");
|
||||
|
||||
_exit:
|
||||
refresh();
|
||||
@ -2386,7 +2366,7 @@ void MainWindow::on_actionApplyStash_triggered()
|
||||
|
||||
if(!runFossil(QStringList() << "stash" << "apply" << *id_it))
|
||||
{
|
||||
log(tr("Stash application aborted due to errors\n"));
|
||||
log(tr("Stash application aborted due to errors")+"\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2399,7 +2379,7 @@ void MainWindow::on_actionApplyStash_triggered()
|
||||
|
||||
if(!runFossil(QStringList() << "stash" << "drop" << *id_it))
|
||||
{
|
||||
log(tr("Stash deletion aborted due to errors\n"));
|
||||
log(tr("Stash deletion aborted due to errors")+"\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2427,7 +2407,7 @@ void MainWindow::on_actionDeleteStash_triggered()
|
||||
|
||||
if(!runFossil(QStringList() << "stash" << "drop" << *id_it))
|
||||
{
|
||||
log(tr("Stash deletion aborted due to errors\n"));
|
||||
log(tr("Stash deletion aborted due to errors")+"\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -136,8 +136,8 @@ private:
|
||||
void scanWorkspace();
|
||||
bool runFossil(const QStringList &args, QStringList *output=0, int runFlags=RUNFLAGS_NONE);
|
||||
bool runFossilRaw(const QStringList &args, QStringList *output=0, int *exitCode=0, int runFlags=RUNFLAGS_NONE);
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
void applySettings();
|
||||
void updateSettings();
|
||||
const QString &getCurrentWorkspace();
|
||||
void setCurrentWorkspace(const QString &workspace);
|
||||
void log(const QString &text, bool isHTML=false);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QResource>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
QString SettingsDialog::SelectExe(QWidget *parent, const QString &description)
|
||||
{
|
||||
QString filter(tr("Applications"));
|
||||
@ -39,20 +40,31 @@ SettingsDialog::SettingsDialog(QWidget *parent, Settings &_settings) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
CreateLangMap();
|
||||
|
||||
ui->cmbDoubleClickAction->addItem(tr("Diff File"));
|
||||
ui->cmbDoubleClickAction->addItem(tr("Open File"));
|
||||
ui->cmbDoubleClickAction->addItem(tr("Open Containing Folder"));
|
||||
|
||||
// App Settings
|
||||
ui->lineFossilPath->setText(QDir::toNativeSeparators(settings->Mappings[FUEL_SETTING_FOSSIL_PATH].Value.toString()));
|
||||
ui->lineGDiffCommand->setText(QDir::toNativeSeparators(settings->Mappings[FUEL_SETTING_GDIFF_CMD].Value.toString()));
|
||||
ui->lineGMergeCommand->setText(QDir::toNativeSeparators(settings->Mappings[FUEL_SETTING_GMERGE_CMD].Value.toString()));
|
||||
ui->cmbDoubleClickAction->setCurrentIndex(settings->Mappings[FUEL_SETTING_FILE_DBLCLICK].Value.toInt());
|
||||
ui->lineFossilPath->setText(QDir::toNativeSeparators(settings->GetValue(FUEL_SETTING_FOSSIL_PATH).toString()));
|
||||
ui->cmbDoubleClickAction->setCurrentIndex(settings->GetValue(FUEL_SETTING_FILE_DBLCLICK).toInt());
|
||||
|
||||
// Initialize language combo
|
||||
foreach(const LangMap &m, langMap)
|
||||
ui->cmbActiveLanguage->addItem(m.name);
|
||||
|
||||
// Select current language
|
||||
ui->cmbActiveLanguage->setCurrentIndex(
|
||||
ui->cmbActiveLanguage->findText(
|
||||
LangIdToName(settings->GetValue(FUEL_SETTING_LANGUAGE).toString())));
|
||||
|
||||
// Repo Settings
|
||||
ui->lineRemoteURL->setText(settings->Mappings[FUEL_SETTING_REMOTE_URL].Value.toString());
|
||||
ui->lineIgnore->setText(settings->Mappings[FUEL_SETTING_IGNORE_GLOB].Value.toString());
|
||||
ui->lineIgnoreCRNL->setText(settings->Mappings[FUEL_SETTING_CRNL_GLOB].Value.toString());
|
||||
ui->lineGDiffCommand->setText(QDir::toNativeSeparators(settings->GetFossilValue(FOSSIL_SETTING_GDIFF_CMD).toString()));
|
||||
ui->lineGMergeCommand->setText(QDir::toNativeSeparators(settings->GetFossilValue(FOSSIL_SETTING_GMERGE_CMD).toString()));
|
||||
ui->lineRemoteURL->setText(settings->GetFossilValue(FOSSIL_SETTING_REMOTE_URL).toString());
|
||||
ui->lineIgnore->setText(settings->GetFossilValue(FOSSIL_SETTING_IGNORE_GLOB).toString());
|
||||
ui->lineIgnoreCRNL->setText(settings->GetFossilValue(FOSSIL_SETTING_CRNL_GLOB).toString());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -71,16 +83,28 @@ bool SettingsDialog::run(QWidget *parent, Settings &settings)
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
settings->Mappings[FUEL_SETTING_FOSSIL_PATH].Value = QDir::fromNativeSeparators(ui->lineFossilPath->text());
|
||||
settings->Mappings[FUEL_SETTING_GDIFF_CMD].Value = QDir::fromNativeSeparators(ui->lineGDiffCommand->text());
|
||||
settings->Mappings[FUEL_SETTING_GMERGE_CMD].Value = QDir::fromNativeSeparators(ui->lineGMergeCommand->text());
|
||||
settings->SetValue(FUEL_SETTING_FOSSIL_PATH, QDir::fromNativeSeparators(ui->lineFossilPath->text()));
|
||||
Q_ASSERT(ui->cmbDoubleClickAction->currentIndex()>=FILE_DLBCLICK_ACTION_DIFF && ui->cmbDoubleClickAction->currentIndex()<FILE_DLBCLICK_ACTION_MAX);
|
||||
settings->Mappings[FUEL_SETTING_FILE_DBLCLICK].Value = ui->cmbDoubleClickAction->currentIndex();
|
||||
settings->SetValue(FUEL_SETTING_FILE_DBLCLICK, ui->cmbDoubleClickAction->currentIndex());
|
||||
|
||||
settings->Mappings[FUEL_SETTING_REMOTE_URL].Value = ui->lineRemoteURL->text();
|
||||
settings->Mappings[FUEL_SETTING_IGNORE_GLOB].Value = ui->lineIgnore->text();
|
||||
settings->Mappings[FUEL_SETTING_CRNL_GLOB].Value = ui->lineIgnoreCRNL->text();
|
||||
Q_ASSERT(settings->HasValue(FUEL_SETTING_LANGUAGE));
|
||||
QString curr_langid = settings->GetValue(FUEL_SETTING_LANGUAGE).toString();
|
||||
QString new_langid = LangNameToId(ui->cmbActiveLanguage->currentText());
|
||||
Q_ASSERT(!new_langid.isEmpty());
|
||||
settings->SetValue(FUEL_SETTING_LANGUAGE, new_langid);
|
||||
|
||||
if(curr_langid != new_langid)
|
||||
QMessageBox::information(this, tr("Restart required"), tr("The language change will take effect after restarting the application"), QMessageBox::Ok);
|
||||
|
||||
settings->SetFossilValue(FOSSIL_SETTING_GDIFF_CMD, QDir::fromNativeSeparators(ui->lineGDiffCommand->text()));
|
||||
settings->SetFossilValue(FOSSIL_SETTING_GMERGE_CMD, QDir::fromNativeSeparators(ui->lineGMergeCommand->text()));
|
||||
settings->SetFossilValue(FOSSIL_SETTING_REMOTE_URL, ui->lineRemoteURL->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_IGNORE_GLOB, ui->lineIgnore->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_CRNL_GLOB, ui->lineIgnoreCRNL->text());
|
||||
|
||||
settings->ApplyEnvironment();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::on_btnSelectFossil_clicked()
|
||||
{
|
||||
@ -109,21 +133,49 @@ void SettingsDialog::on_btnSelectGMerge_clicked()
|
||||
void SettingsDialog::on_btnClearMessageHistory_clicked()
|
||||
{
|
||||
if(DialogQuery(this, tr("Clear Commit Message History"), tr("Are you sure want to clear the commit message history?"))==QMessageBox::Yes)
|
||||
settings->Mappings[FUEL_SETTING_COMMIT_MSG].Value = QStringList();
|
||||
settings->SetValue(FUEL_SETTING_COMMIT_MSG, QStringList());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::CreateLangMap()
|
||||
{
|
||||
langMap.append(LangMap("en_US", tr("English (US)")));
|
||||
langMap.append(LangMap("ja_JP", tr("Japanese")));
|
||||
langMap.append(LangMap("el_GR", tr("Greek")));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString SettingsDialog::LangIdToName(const QString &id)
|
||||
{
|
||||
foreach(const LangMap &m, langMap)
|
||||
{
|
||||
if(m.id == id)
|
||||
return m.name;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString SettingsDialog::LangNameToId(const QString &name)
|
||||
{
|
||||
foreach(const LangMap &m, langMap)
|
||||
{
|
||||
if(m.name == name)
|
||||
return m.id;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
Settings::Settings(bool portableMode) : store(0)
|
||||
{
|
||||
Mappings[FUEL_SETTING_FOSSIL_PATH] = Setting();
|
||||
Mappings[FUEL_SETTING_COMMIT_MSG] = Setting();
|
||||
Mappings[FUEL_SETTING_FILE_DBLCLICK] = Setting(0); // Maps to FileDblClickAction
|
||||
Mappings[FUEL_SETTING_GDIFF_CMD] = Setting("", Setting::TYPE_FOSSIL_GLOBAL);
|
||||
Mappings[FUEL_SETTING_GMERGE_CMD] = Setting("", Setting::TYPE_FOSSIL_GLOBAL);
|
||||
Mappings[FUEL_SETTING_IGNORE_GLOB] = Setting("", Setting::TYPE_FOSSIL_LOCAL);
|
||||
Mappings[FUEL_SETTING_CRNL_GLOB] = Setting("", Setting::TYPE_FOSSIL_LOCAL);
|
||||
Mappings[FUEL_SETTING_REMOTE_URL] = Setting("off", Setting::TYPE_FOSSIL_COMMAND);
|
||||
|
||||
Mappings.insert(FOSSIL_SETTING_GDIFF_CMD, Setting("", Setting::TYPE_FOSSIL_GLOBAL));
|
||||
Mappings.insert(FOSSIL_SETTING_GMERGE_CMD, Setting("", Setting::TYPE_FOSSIL_GLOBAL));
|
||||
Mappings.insert(FOSSIL_SETTING_IGNORE_GLOB, Setting("", Setting::TYPE_FOSSIL_LOCAL));
|
||||
Mappings.insert(FOSSIL_SETTING_CRNL_GLOB, Setting("", Setting::TYPE_FOSSIL_LOCAL));
|
||||
Mappings.insert(FOSSIL_SETTING_REMOTE_URL, Setting("off", Setting::TYPE_FOSSIL_COMMAND));
|
||||
|
||||
// Go into portable mode when explicitly requested or if a config file exists next to the executable
|
||||
QString ini_path = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QDir::separator() + QCoreApplication::applicationName() + ".ini");
|
||||
@ -135,6 +187,12 @@ Settings::Settings(bool portableMode) : store(0)
|
||||
// Windows: HKEY_CURRENT_USER\Software\organizationName\Fuel
|
||||
store = new QSettings(QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
}
|
||||
Q_ASSERT(store);
|
||||
|
||||
if(!HasValue(FUEL_SETTING_FILE_DBLCLICK))
|
||||
SetValue(FUEL_SETTING_FILE_DBLCLICK, 0);
|
||||
if(!HasValue(FUEL_SETTING_LANGUAGE))
|
||||
SetValue(FUEL_SETTING_LANGUAGE, QLocale::system().name());
|
||||
|
||||
ApplyEnvironment();
|
||||
}
|
||||
@ -142,17 +200,54 @@ Settings::Settings(bool portableMode) : store(0)
|
||||
//-----------------------------------------------------------------------------
|
||||
Settings::~Settings()
|
||||
{
|
||||
Q_ASSERT(store);
|
||||
delete store;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Settings::ApplyEnvironment()
|
||||
{
|
||||
QString locale_name = QLocale::system().name();
|
||||
//locale_name = "el_GR";
|
||||
QString lang_id = GetValue(FUEL_SETTING_LANGUAGE).toString();
|
||||
|
||||
QString locale_path = QString(":intl/intl/%0.qm").arg(locale_name);
|
||||
QString locale_path = QString(":intl/intl/%0.qm").arg(lang_id);
|
||||
QResource res(locale_path);
|
||||
if(res.isValid() && translator.load(res.data(), res.size()))
|
||||
QCoreApplication::instance()->installTranslator(&translator);
|
||||
else
|
||||
SetValue(FUEL_SETTING_LANGUAGE, "en_US");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Settings::HasValue(const QString &name) const
|
||||
{
|
||||
return store->contains(name);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const QVariant Settings::GetValue(const QString &name)
|
||||
{
|
||||
Q_ASSERT(HasValue(name));
|
||||
return store->value(name);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Settings::SetValue(const QString &name, const QVariant &value)
|
||||
{
|
||||
store->setValue(name, value);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QVariant &Settings::GetFossilValue(const QString &name)
|
||||
{
|
||||
mappings_t::iterator it=Mappings.find(name);
|
||||
Q_ASSERT(it!=Mappings.end());
|
||||
return it.value().Value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Settings::SetFossilValue(const QString &name, const QVariant &value)
|
||||
{
|
||||
mappings_t::iterator it=Mappings.find(name);
|
||||
Q_ASSERT(it!=Mappings.end());
|
||||
it->Value = value;
|
||||
}
|
||||
|
@ -14,11 +14,14 @@ namespace Ui {
|
||||
#define FUEL_SETTING_FOSSIL_PATH "FossilPath"
|
||||
#define FUEL_SETTING_COMMIT_MSG "CommitMsgHistory"
|
||||
#define FUEL_SETTING_FILE_DBLCLICK "FileDblClickAction"
|
||||
#define FUEL_SETTING_GDIFF_CMD "gdiff-command"
|
||||
#define FUEL_SETTING_GMERGE_CMD "gmerge-command"
|
||||
#define FUEL_SETTING_IGNORE_GLOB "ignore-glob"
|
||||
#define FUEL_SETTING_CRNL_GLOB "crnl-glob"
|
||||
#define FUEL_SETTING_REMOTE_URL "remote-url"
|
||||
#define FUEL_SETTING_LANGUAGE "Language"
|
||||
|
||||
#define FOSSIL_SETTING_GDIFF_CMD "gdiff-command"
|
||||
#define FOSSIL_SETTING_GMERGE_CMD "gmerge-command"
|
||||
#define FOSSIL_SETTING_IGNORE_GLOB "ignore-glob"
|
||||
#define FOSSIL_SETTING_CRNL_GLOB "crnl-glob"
|
||||
#define FOSSIL_SETTING_REMOTE_URL "remote-url"
|
||||
|
||||
|
||||
enum FileDblClickAction
|
||||
{
|
||||
@ -34,27 +37,38 @@ struct Settings
|
||||
{
|
||||
enum SettingType
|
||||
{
|
||||
TYPE_INTERNAL,
|
||||
TYPE_FOSSIL_GLOBAL,
|
||||
TYPE_FOSSIL_LOCAL,
|
||||
TYPE_FOSSIL_COMMAND
|
||||
};
|
||||
|
||||
Setting(QVariant value=QVariant(), SettingType type=TYPE_INTERNAL) : Value(value), Type(type)
|
||||
Setting(QVariant value, SettingType type) : Value(value), Type(type)
|
||||
{}
|
||||
QVariant Value;
|
||||
SettingType Type;
|
||||
};
|
||||
typedef QMap<QString, Setting> mappings_t;
|
||||
|
||||
|
||||
Settings(bool portableMode = false);
|
||||
~Settings();
|
||||
void ApplyEnvironment();
|
||||
|
||||
typedef QMap<QString, Setting> mappings_t;
|
||||
// App configuration access
|
||||
class QSettings * GetStore() { return store; }
|
||||
bool HasValue(const QString &name) const; // store->contains(FUEL_SETTING_FOSSIL_PATH)
|
||||
const QVariant GetValue(const QString &name); // settings.store->value
|
||||
void SetValue(const QString &name, const QVariant &value); // settings.store->value
|
||||
|
||||
// Fossil configuration access
|
||||
QVariant & GetFossilValue(const QString &name);
|
||||
void SetFossilValue(const QString &name, const QVariant &value);
|
||||
mappings_t & GetMappings() { return Mappings; }
|
||||
|
||||
private:
|
||||
mappings_t Mappings;
|
||||
class QSettings *store;
|
||||
QTranslator translator;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -78,7 +92,22 @@ private slots:
|
||||
|
||||
private:
|
||||
static QString SelectExe(QWidget *parent, const QString &description);
|
||||
QString LangIdToName(const QString &id);
|
||||
QString LangNameToId(const QString &name);
|
||||
void CreateLangMap();
|
||||
|
||||
struct LangMap
|
||||
{
|
||||
LangMap(const QString &_id, const QString &_name)
|
||||
: id(_id), name(_name)
|
||||
{
|
||||
}
|
||||
|
||||
QString id;
|
||||
QString name;
|
||||
};
|
||||
|
||||
QList<LangMap> langMap;
|
||||
Ui::SettingsDialog *ui;
|
||||
Settings *settings;
|
||||
};
|
||||
|
Reference in New Issue
Block a user