diff --git a/src/gui/src/NewScreenWidget.cpp b/src/gui/src/NewScreenWidget.cpp index 18379c0b..0336249e 100644 --- a/src/gui/src/NewScreenWidget.cpp +++ b/src/gui/src/NewScreenWidget.cpp @@ -1,4 +1,4 @@ -/* +/* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) diff --git a/src/gui/src/ScreenSettingsDialog.cpp b/src/gui/src/ScreenSettingsDialog.cpp index 1e95a9c5..4f294e24 100644 --- a/src/gui/src/ScreenSettingsDialog.cpp +++ b/src/gui/src/ScreenSettingsDialog.cpp @@ -23,6 +23,19 @@ #include #include +static const QRegExp ValidScreenName("[a-z0-9\\._-]{,255}", Qt::CaseInsensitive); + +static QString check_name_param(QString name) +{ + // after internationalization happens the default name "Unnamed" might + // be translated with spaces (or other chars). let's replace the spaces + // with dashes and just give up if that doesn't pass the regexp + name.replace(' ', '-'); + if (ValidScreenName.exactMatch(name)) + return name; + return ""; +} + ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), Ui::ScreenSettingsDialogBase(), @@ -30,13 +43,11 @@ ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) : { setupUi(this); - QRegExp validScreenName("[a-z0-9\\._-]{,255}", Qt::CaseInsensitive); - - m_pLineEditName->setText(m_pScreen->name()); - m_pLineEditName->setValidator(new QRegExpValidator(validScreenName, m_pLineEditName)); + m_pLineEditName->setText(check_name_param(m_pScreen->name())); + m_pLineEditName->setValidator(new QRegExpValidator(ValidScreenName, m_pLineEditName)); m_pLineEditName->selectAll(); - m_pLineEditAlias->setValidator(new QRegExpValidator(validScreenName, m_pLineEditName)); + m_pLineEditAlias->setValidator(new QRegExpValidator(ValidScreenName, m_pLineEditName)); for (int i = 0; i < m_pScreen->aliases().count(); i++) new QListWidgetItem(m_pScreen->aliases()[i], m_pListAliases);