26 #include <QStringList>
50 bool succeeded =
true;
51 if (!names.empty() && !paths.empty() && params.empty()) {
52 for (
int i = 0; i < paths.length(); i++)
57 if (names.empty() && paths.empty() && params.empty()) {
60 if (QFileInfo(
"/usr/bin/gedit").isExecutable()) {
71 if (QFileInfo(
"/usr/bin/kate").isExecutable()) {
80 if (findDefaultWindowsEditor()) {
84 }
else if (names.size() == paths.size()) {
85 for (
int i = 0; i < names.size(); i++) {
86 const Application app(names[i], paths[i], params[i]);
93 else if (defapp < names.size())
188 if (QFileInfo::exists(appPath) && QFileInfo(appPath).isExecutable()) {
191 app.
setPath(
"\"" + appPath +
"\"");
200 bool ApplicationList::findDefaultWindowsEditor()
202 bool foundOne =
false;
204 const QString appPathx86(getenv(
"ProgramFiles(x86)"));
206 const QString appPathx86(getenv(
"ProgramFiles"));
208 const QString appPathx64(getenv(
"ProgramW6432"));
209 const QString windowsPath(getenv(
"windir"));
213 else if (
checkAndAddApplication(appPathx64 +
"\\Notepad++\\notepad++.exe",
"Notepad++",
"-n(line) (file)"))
224 QString regPath =
"HKEY_CLASSES_ROOT\\Applications\\QtProject.QtCreator.pro\\shell\\Open\\command";
225 QSettings registry(regPath, QSettings::NativeFormat);
226 QString qtCreatorRegistry = registry.value(
"Default", QString()).toString();
227 QString qtCreatorPath = qtCreatorRegistry.left(qtCreatorRegistry.indexOf(
".exe") + 4);
228 if (!qtCreatorRegistry.isEmpty() &&
checkAndAddApplication(qtCreatorPath,
"Qt Creator",
"-client (file):(line)")) {
232 const QString regPathUEdit32 =
"HKEY_CLASSES_ROOT\\Applications\\Uedit32.exe\\shell\\open\\Command";
233 const QSettings registryUEdit32(regPathUEdit32, QSettings::NativeFormat);
234 const QString uedit32Registry = registryUEdit32.value(
"Default", QString()).toString();
235 if (!uedit32Registry.isEmpty()) {
237 const QString uedit32Path = uedit32Registry.left(uedit32Registry.indexOf(
".exe") + 4).replace(
"\"",
"");
243 const QString regPathUEdit64 =
"HKEY_CLASSES_ROOT\\Applications\\uedit64.exe\\shell\\open\\Command";
244 const QSettings registryUEdit64(regPathUEdit64, QSettings::NativeFormat);
245 const QString uedit64Registry = registryUEdit64.value(
"Default", QString()).toString();
246 if (!uedit64Registry.isEmpty()) {
248 const QString uedit64Path = uedit64Registry.left(uedit64Registry.indexOf(
".exe") + 4).replace(
"\"",
"");
254 const QString regPathMSVSCode =
"HKEY_CLASSES_ROOT\\Applications\\Code.exe\\shell\\open\\command";
255 const QSettings registryMSVSCode(regPathMSVSCode, QSettings::NativeFormat);
256 const QString msvscodeRegistry = registryMSVSCode.value(
"Default", QString()).toString();
257 if (!msvscodeRegistry.isEmpty()) {
258 const QString msvscodePath = msvscodeRegistry.left(msvscodeRegistry.indexOf(
".exe") + 4).replace(
"\"",
"");
List of applications user has specified to open errors with.
int mDefaultApplicationIndex
Index of the default application.
QList< Application > mApplications
List of applications.
bool loadSettings()
Load all applications.
void copy(const ApplicationList *list)
Remove all applications from this list and copy all applications from list given as a parameter.
void setDefault(const int index)
Set application as default application.
void clear()
Clear the list.
void saveSettings() const
Save all applications.
ApplicationList(QObject *parent=nullptr)
int getApplicationCount() const
Get the amount of applications in the list.
const Application & getApplication(const int index) const
Get specific application's name.
void removeApplication(const int index)
Remove an application from the list.
~ApplicationList() override
void addApplication(const Application &app)
Add a new application.
int getDefaultApplication() const
Return the default application.
bool checkAndAddApplication(const QString &appPath, const QString &name, const QString ¶meters)
A class containing information of the application to execute.
const QString & getParameters() const
Get application command line parameters.
void setPath(const QString &path)
Set application path.
void setName(const QString &name)
Set application name.
void setParameters(const QString ¶meters)
Set application command line parameters.
const QString & getPath() const
Get application path.
const QString & getName() const
Get application name.
#define SETTINGS_APPLICATION_DEFAULT
#define SETTINGS_APPLICATION_PATHS
#define SETTINGS_APPLICATION_NAMES
#define SETTINGS_APPLICATION_PARAMS