GUI: Use Notepad in Windows as default editor if Notepad++ not found.

This commit is contained in:
Kimmo Varis 2010-10-28 23:21:05 +03:00
parent 16fe2f8802
commit 3b4770e5a3
2 changed files with 27 additions and 5 deletions

View File

@ -56,12 +56,8 @@ void ApplicationList::LoadSettings(QSettings *programSettings)
break;
}
// use as default for windows environments
const QString appPath(getenv("ProgramFiles"));
if (!appPath.isNull() && QFileInfo(appPath + "\\Notepad++\\notepad++.exe").isExecutable())
{
AddApplicationType("Notepad++", "\"" + QString(appPath) + "\\Notepad++\\notepad++.exe\" -n(line) (file)");
if (FindDefaultWindowsEditor())
break;
}
}
while (0);
}
@ -176,3 +172,22 @@ void ApplicationList::Clear()
mApplications.clear();
}
bool ApplicationList::FindDefaultWindowsEditor()
{
const QString appPath(getenv("ProgramFiles"));
const QString notepadppPath = appPath + "\\Notepad++\\notepad++.exe";
if (QFileInfo(notepadppPath).isExecutable())
{
AddApplicationType("Notepad++", "\"" + notepadppPath + "\" -n(line) (file)");
return true;
}
const QString windowsPath(getenv("windir"));
const QString notepadPath = windowsPath + "\\system32\\notepad.exe";
if (QFileInfo(notepadPath).isExecutable())
{
AddApplicationType("Notepad", notepadPath + " (file)");
return true;
}
return false;
}

View File

@ -155,6 +155,13 @@ protected:
*
*/
void Clear();
/**
* @brief Find editor used by default in Windows.
* Check if Notepad++ is installed and use it. If not, use Notepad.
*/
bool FindDefaultWindowsEditor();
/**
* @brief List of applications
*