GUI: Use Notepad in Windows as default editor if Notepad++ not found.
This commit is contained in:
parent
16fe2f8802
commit
3b4770e5a3
|
@ -56,13 +56,9 @@ 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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue