Implement basic 'Terminal=' support for .desktop files
This commit is contained in:
父節點
bf8f09ec66
當前提交
59ff382856
@ -79,6 +79,10 @@ EntryConfig EntryProvider::readFromDesktopFile(const QString &path)
|
||||
{
|
||||
result.hidden = args == "true";
|
||||
}
|
||||
if(key == "terminal")
|
||||
{
|
||||
result.isTerminalCommand = args == "true";
|
||||
}
|
||||
}
|
||||
result.type = EntryType::SYSTEM;
|
||||
return result;
|
||||
|
@ -27,6 +27,7 @@ class EntryConfig
|
||||
public:
|
||||
EntryType type = SYSTEM;
|
||||
bool hidden = false;
|
||||
bool isTerminalCommand = false;
|
||||
QString entryPath;
|
||||
QString key;
|
||||
QString name;
|
||||
|
@ -28,3 +28,8 @@ bool SettingsProvider::singleInstanceMode() const
|
||||
{
|
||||
return settings->value("singleInstance", true).toBool();
|
||||
}
|
||||
|
||||
QString SettingsProvider::getTerminalCommand() const
|
||||
{
|
||||
return settings->value("terminal", "/usr/bin/x-terminal-emulator -e %c").toString();
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ class SettingsProvider
|
||||
virtual QStringList systemApplicationsEntriesPaths() const;
|
||||
virtual int getMaxCols() const;
|
||||
virtual bool singleInstanceMode() const;
|
||||
QString getTerminalCommand() const;
|
||||
};
|
||||
|
||||
#endif // SETTINGSPROVIDER_H
|
||||
|
11
window.cpp
11
window.cpp
@ -120,7 +120,16 @@ void Window::populateGrid(const QVector<EntryPushButton *> &list)
|
||||
|
||||
void Window::executeConfig(const EntryConfig &config)
|
||||
{
|
||||
QProcess::startDetached(config.command, config.arguments);
|
||||
if(config.isTerminalCommand)
|
||||
{
|
||||
QString cmd = settingsProvider->getTerminalCommand();
|
||||
cmd.replace("%c", config.command);
|
||||
QProcess::startDetached(cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
QProcess::startDetached(config.command, config.arguments);
|
||||
}
|
||||
this->closeWindow();
|
||||
}
|
||||
|
||||
|
載入中…
新增問題並參考
Block a user