Fixed #1931 (GUI should try to detect the best possible editor)

This commit is contained in:
Erik Lax 2010-08-15 07:58:14 +02:00 committed by Daniel Marjamäki
parent 54b7f972c9
commit 6423288d2e
1 changed files with 25 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include "applicationlist.h" #include "applicationlist.h"
#include <QStringList> #include <QStringList>
#include <QFileInfo>
#include "common.h" #include "common.h"
ApplicationList::ApplicationList(QObject *parent) : ApplicationList::ApplicationList(QObject *parent) :
@ -37,6 +38,30 @@ void ApplicationList::LoadSettings(QSettings *programSettings)
QStringList names = programSettings->value(SETTINGS_APPLICATION_NAMES, QStringList()).toStringList(); QStringList names = programSettings->value(SETTINGS_APPLICATION_NAMES, QStringList()).toStringList();
QStringList paths = programSettings->value(SETTINGS_APPLICATION_PATHS, QStringList()).toStringList(); QStringList paths = programSettings->value(SETTINGS_APPLICATION_PATHS, QStringList()).toStringList();
if (names.empty() && paths.empty())
{
do {
// use as default for gnome environments
if (QFileInfo("/usr/bin/gedit").isExecutable())
{
AddApplicationType("gedit", "/usr/bin/gedit +(line) (file)");
break;
}
// use as default for kde environments
if (QFileInfo("/usr/bin/kate").isExecutable())
{
AddApplicationType("kate", "/usr/bin/kate -l(line) (file)");
break;
}
// use as default for windows environments
if (QFileInfo("%PROGRAMFILES%\\Notepad++\\notepad++.exe").isExecutable())
{
AddApplicationType("notepad++", "%PROGRAMFILES%\\Notepad++\\notepad++.exe -n(line) (file)");
break;
}
} while ( 0 );
}
if (names.size() == paths.size()) if (names.size() == paths.size())
{ {
for (int i = 0; i < names.size(); i++) for (int i = 0; i < names.size(); i++)