feat: sync setting terminal

This commit is contained in:
kate 2022-01-29 02:44:57 +08:00
parent 0426b57b8d
commit 908cfca920
3 changed files with 24 additions and 1 deletions

View file

@ -448,7 +448,23 @@ void MimeAppManager::launchTerminal(const QString &path)
if (m_terminalApps.isEmpty()) if (m_terminalApps.isEmpty())
return; return;
QString command = m_terminalApps.first().value("Exec").toString(); QSettings settings("cutefishos", "defaultApps");
QString defaultTerminal = settings.value("terminal").toString();
QString command;
if (!defaultTerminal.isEmpty()) {
for (const XdgDesktopFile &f : m_terminalApps) {
if (f.fileName().contains(defaultTerminal)) {
command = f.value("Exec").toString();
break;
}
}
}
if (command.isEmpty()) {
command = m_terminalApps.first().value("Exec").toString();
}
FileLauncher::startDetached(command, path, QStringList()); FileLauncher::startDetached(command, path, QStringList());
} }

View file

@ -123,6 +123,11 @@ QString XdgDesktopFile::prefix() const
return QLatin1String("Desktop Entry"); return QLatin1String("Desktop Entry");
} }
QString XdgDesktopFile::fileName() const
{
return m_fileName;
}
bool XdgDesktopFile::read(const QString &prefix) bool XdgDesktopFile::read(const QString &prefix)
{ {
QFile file(m_fileName); QFile file(m_fileName);

View file

@ -42,6 +42,8 @@ public:
QString localeName() const; QString localeName() const;
QString prefix() const; QString prefix() const;
QString fileName() const;
private: private:
bool read(const QString &prefix); bool read(const QString &prefix);