feat(ipc): Handle missing keyboard layouts with IPC

This commit is contained in:
Nick Bolton 2026-03-30 19:38:03 +01:00
parent 59a4747113
commit 682966fec0
14 changed files with 113 additions and 14 deletions

View file

@ -18,6 +18,7 @@
#include "deskflow/ProtocolTypes.h"
#include "deskflow/ProtocolUtil.h"
#include "deskflow/StreamChunker.h"
#include "deskflow/ipc/CoreIpc.h"
#include "io/IStream.h"
#include <cstring>
@ -139,7 +140,12 @@ ServerProxy::ConnectionResult ServerProxy::parseHandshakeMessage(const uint8_t *
// handshake is complete
m_parser = &ServerProxy::parseMessage;
checkMissedLanguages();
if (const auto missedKeyboardLayouts = m_languageManager.getMissedLanguages(); !missedKeyboardLayouts.empty()) {
LOG_WARN("server layouts missing on this computer: %s", missedKeyboardLayouts.c_str());
ipcSendToClient("missingKeyboardLayouts", QString::fromStdString(missedKeyboardLayouts));
}
m_client->handshakeComplete();
}
@ -844,15 +850,3 @@ void ServerProxy::setActiveServerLanguage(const std::string_view &language)
LOG_DEBUG1("active server language is empty");
}
}
void ServerProxy::checkMissedLanguages() const
{
auto missedLanguages = m_languageManager.getMissedLanguages();
if (!missedLanguages.empty()) {
LOG(
(CLOG_WARN "You need to install these languages on this computer and restart "
"Deskflow to enable support for multiple languages: %s",
missedLanguages.c_str())
);
}
}

View file

@ -98,7 +98,6 @@ private:
void secureInputNotification();
void setServerLanguages();
void setActiveServerLanguage(const std::string_view &language);
void checkMissedLanguages() const;
private:
using MessageParser = ConnectionResult (ServerProxy::*)(const uint8_t *);

View file

@ -85,6 +85,7 @@ public:
inline static const auto ShownFirstConnectedMessage = QStringLiteral("gui/shownFirstConnectedMessage");
inline static const auto ShownServerFirstStartMessage = QStringLiteral("gui/shownServerFirstStartMessage");
inline static const auto ShowVersionInTitle = QStringLiteral("gui/showVersionInTitle");
inline static const auto IgnoreMissingKeyboardLayouts = QStringLiteral("gui/ignoreMissingKeyboardLayouts");
};
struct Log
{
@ -243,6 +244,7 @@ private:
, Settings::Gui::ShownFirstConnectedMessage
, Settings::Gui::ShownServerFirstStartMessage
, Settings::Gui::ShowVersionInTitle
, Settings::Gui::IgnoreMissingKeyboardLayouts
, Settings::Security::Certificate
, Settings::Security::CheckPeers
, Settings::Security::KeySize
@ -258,6 +260,7 @@ private:
, Settings::Gui::ShownFirstConnectedMessage
, Settings::Gui::ShownServerFirstStartMessage
, Settings::Gui::ShowVersionInTitle
, Settings::Gui::IgnoreMissingKeyboardLayouts
, Settings::Core::PreventSleep
, Settings::Core::UseWlClipboard
, Settings::Core::EnableEnterCommand

View file

@ -11,6 +11,8 @@
namespace deskflow::languages {
// TODO: rename class and namespace; "languages" is a misnomer. These are keyboard
// _layouts_ (Windows/X11) or input sources (macOS), not spoken "languages".
class LanguageManager
{
std::vector<std::string> m_remoteLanguages;

View file

@ -31,6 +31,7 @@
#include "net/FingerprintDatabase.h"
#include "widgets/StatusBar.h"
#include <QCheckBox>
#include <QCloseEvent>
#include <QDesktopServices>
#include <QFileDialog>
@ -272,6 +273,7 @@ void MainWindow::connectSlots()
connect(&m_coreProcess, &CoreProcess::connectionRefused, this, &MainWindow::handleConnectionRefused);
connect(&m_coreProcess, &CoreProcess::retryIn, this, &MainWindow::updateTimeoutDelay);
connect(&m_coreProcess, &CoreProcess::peerFingerprint, this, &MainWindow::handlePeerFingerprint);
connect(&m_coreProcess, &CoreProcess::missingKeyboardLayouts, this, &MainWindow::handleMissingKeyboardLayouts);
if (Settings::value(Settings::Gui::AutoStartCore).toBool()) {
connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStopCore, &QAction::trigger, Qt::UniqueConnection);
@ -802,6 +804,29 @@ void MainWindow::handleConnectionRefused(deskflow::core::ConnectionRefusal reaso
m_clientErrorVisible = false;
}
void MainWindow::handleMissingKeyboardLayouts(const QString &layouts)
{
if (Settings::value(Settings::Gui::IgnoreMissingKeyboardLayouts).toBool())
return;
QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("Missing Keyboard Layouts"));
msgBox.setText(tr("<p>Keyboard layout support requires matching layouts on all computers. "
"The following layouts from the other computer are not installed on this computer:</p>"
"<p><b>%1</b></p>"
"<p>Please install them to enable support for these layouts.</p>")
.arg(layouts));
auto *checkBox = new QCheckBox(tr("Don't show this again"), &msgBox);
msgBox.setCheckBox(checkBox);
msgBox.exec();
if (checkBox->isChecked()) {
Settings::setValue(Settings::Gui::IgnoreMissingKeyboardLayouts, true);
}
}
void MainWindow::handlePeerFingerprint(const QString &fingerprint)
{
const auto sha256Text = QString(fingerprint).remove(':');

View file

@ -119,6 +119,7 @@ private:
void handleUnrecognisedClient(const QString &clientName);
void handleConnectionRefused(deskflow::core::ConnectionRefusal reason);
void handlePeerFingerprint(const QString &fingerprint);
void handleMissingKeyboardLayouts(const QString &layouts);
void closeEvent(QCloseEvent *event) override;
void secureSocket(bool secureSocket);
void connectSlots();

View file

@ -564,6 +564,8 @@ void CoreProcess::onCoreIpcMessageReceived(const QString &command, const QString
Q_EMIT retryIn(args.toInt());
} else if (command == "peerFingerprint") {
Q_EMIT peerFingerprint(args);
} else if (command == "missingKeyboardLayouts") {
Q_EMIT missingKeyboardLayouts(args);
}
}

View file

@ -93,6 +93,7 @@ Q_SIGNALS:
void connectionRefused(deskflow::core::ConnectionRefusal reason);
void retryIn(int seconds);
void peerFingerprint(const QString &fingerprint);
void missingKeyboardLayouts(const QString &layouts);
private Q_SLOTS:
void onProcessFinished(int exitCode, QProcess::ExitStatus);

View file

@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
<translation type="unfinished">
Además, verifique que puede %1 el archivo de configuración del servidor: %2</translation>
</message>
<message>
<source>Don&apos;t show this again</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Missing Keyboard Layouts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:&lt;/p&gt;&lt;p&gt;&lt;b&gt;%1&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Please install them to enable support for these layouts.&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NewScreenWidget</name>

View file

@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
<translation type="unfinished">
Inoltre, verifica di poter %1 il file di configurazione del server: %2</translation>
</message>
<message>
<source>Don&apos;t show this again</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Missing Keyboard Layouts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:&lt;/p&gt;&lt;p&gt;&lt;b&gt;%1&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Please install them to enable support for these layouts.&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NewScreenWidget</name>

View file

@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
<translation type="unfinished">
また、サーバー設定ファイルを%1できることを確認してください: %2</translation>
</message>
<message>
<source>Don&apos;t show this again</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Missing Keyboard Layouts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:&lt;/p&gt;&lt;p&gt;&lt;b&gt;%1&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Please install them to enable support for these layouts.&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NewScreenWidget</name>

View file

@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
<translation type="unfinished">
또한 서버 구성 파일을 %1할 수 있는지 확인하세요: %2</translation>
</message>
<message>
<source>Don&apos;t show this again</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Missing Keyboard Layouts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:&lt;/p&gt;&lt;p&gt;&lt;b&gt;%1&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Please install them to enable support for these layouts.&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NewScreenWidget</name>

View file

@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
<translation type="unfinished">
Также убедитесь, что вы можете %1 файл конфигурации сервера: %2</translation>
</message>
<message>
<source>Don&apos;t show this again</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Missing Keyboard Layouts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:&lt;/p&gt;&lt;p&gt;&lt;b&gt;%1&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Please install them to enable support for these layouts.&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NewScreenWidget</name>

View file

@ -559,6 +559,18 @@ Additionally, check you are able to %1 the server config file: %2</source>
<translation type="unfinished">
另外,请检查您是否能够%1服务器配置文件:%2</translation>
</message>
<message>
<source>Don&apos;t show this again</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Missing Keyboard Layouts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;p&gt;Keyboard layout support requires matching layouts on all computers. The following layouts from the other computer are not installed on this computer:&lt;/p&gt;&lt;p&gt;&lt;b&gt;%1&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Please install them to enable support for these layouts.&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NewScreenWidget</name>