diff --git a/locale-gen.sh b/locale-gen.sh index 4ac7de8..723b776 100755 --- a/locale-gen.sh +++ b/locale-gen.sh @@ -24,4 +24,5 @@ pylupdate5 -noobsolete \ ui_about.py \ ui_mainwindow.py \ ui_selectlayout.py \ - -ts "$langs"/"lang_$lang.ts" \ No newline at end of file + ui_error_message.py \ + -ts "$langs"/"lang_$lang.ts" diff --git a/sway_input_config/langs/lang_ru_RU.qm b/sway_input_config/langs/lang_ru_RU.qm index f1795cc..4e265b8 100644 Binary files a/sway_input_config/langs/lang_ru_RU.qm and b/sway_input_config/langs/lang_ru_RU.qm differ diff --git a/sway_input_config/langs/lang_ru_RU.ts b/sway_input_config/langs/lang_ru_RU.ts index 028601d..bfb80f2 100644 --- a/sway_input_config/langs/lang_ru_RU.ts +++ b/sway_input_config/langs/lang_ru_RU.ts @@ -2,11 +2,16 @@ - AboutDialog + ErrorMessage - - Version: - Версия: + + Sway socket not found! + + + + + <html><head/><body><p><span style=" font-size:10pt;">Sway Input Configurator only supports Sway. You are probably using an unsupported window manager or there are problems with your Sway configuration.</span></p></body></html> + @@ -408,14 +413,6 @@ Метод клика (только для кликпадов): - - SelectKeyboardLayout - - - A user defined custom layout - Пользовательская раскладка - - SelectKeyboardLayoutDialog diff --git a/sway_input_config/main.py b/sway_input_config/main.py index 71d393b..8e3ad14 100644 --- a/sway_input_config/main.py +++ b/sway_input_config/main.py @@ -18,13 +18,16 @@ from sway_input_config.ui_mainwindow import Ui_MainWindow from sway_input_config.ui_about import Ui_about from sway_input_config.ui_selectlayout import Ui_SelectKeyboardLayoutDialog +from sway_input_config.ui_error_message import Ui_ErrorMessage app_version = "1.3.0" -sway_version = get_sway_version() data_dir = "" -config_home = get_config_home() -sway_config = os.path.join(config_home, "sway", "config") +if os.getenv("SWAYSOCK"): + sway_version = get_sway_version() + config_home = get_config_home() + sway_config = os.path.join(config_home, "sway", "config") + dir_name = os.path.dirname(__file__) shortcut_list = os.path.join(dir_name, "data/shortcuts.json") kbd_model_list = os.path.join(dir_name, "data/kbd_model.json") @@ -33,6 +36,19 @@ default_settings = os.path.join(dir_name, "data/defaults.json") +class ErrorMessage(QDialog): + def __init__(self): + super(ErrorMessage, self).__init__() + self.ui = Ui_ErrorMessage() + self.ui.setupUi(self) + + self.btnOk = self.ui.buttonBox.button(QDialogButtonBox.Ok) + self.btnOk.clicked.connect(self.on_clicked_ok) + + def on_clicked_ok(self): + self.close() + + class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() @@ -943,11 +959,15 @@ def main(): copy2(os.path.join(dir_name, "data/defaults.json"), os.path.join(data_dir, "settings")) sys.exit(0) - load_settings() - - win = MainWindow() - win.show() - sys.exit(app.exec_()) + if os.getenv("SWAYSOCK"): + load_settings() + win = MainWindow() + win.show() + sys.exit(app.exec_()) + else: + win = ErrorMessage() + win.show() + sys.exit(app.exec_()) if __name__ == "__main__": diff --git a/sway_input_config/ui/error_message.ui b/sway_input_config/ui/error_message.ui new file mode 100644 index 0000000..d3ca83a --- /dev/null +++ b/sway_input_config/ui/error_message.ui @@ -0,0 +1,96 @@ + + + ErrorMessage + + + Qt::WindowModal + + + + 0 + 0 + 670 + 115 + + + + + 0 + 0 + + + + + 670 + 115 + + + + + 670 + 115 + + + + Sway socket not found! + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + <html><head/><body><p><span style=" font-size:10pt;">Sway Input Configurator only supports Sway. You are probably using an unsupported window manager or there are problems with your Sway configuration.</span></p></body></html> + + + Qt::AutoText + + + true + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + QDialogButtonBox::Ok + + + + + + + + + + diff --git a/sway_input_config/ui_error_message.py b/sway_input_config/ui_error_message.py new file mode 100644 index 0000000..5333841 --- /dev/null +++ b/sway_input_config/ui_error_message.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- + +################################################################################ +## Form generated from reading UI file 'error_message.ui' +## +## Created by: Qt User Interface Compiler version 5.15.8 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ + +from PySide2.QtCore import * # type: ignore +from PySide2.QtGui import * # type: ignore +from PySide2.QtWidgets import * # type: ignore + + +class Ui_ErrorMessage(object): + def setupUi(self, ErrorMessage): + if not ErrorMessage.objectName(): + ErrorMessage.setObjectName(u"ErrorMessage") + ErrorMessage.setWindowModality(Qt.WindowModal) + ErrorMessage.resize(670, 115) + sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(ErrorMessage.sizePolicy().hasHeightForWidth()) + ErrorMessage.setSizePolicy(sizePolicy) + ErrorMessage.setMinimumSize(QSize(670, 115)) + ErrorMessage.setMaximumSize(QSize(670, 115)) + self.verticalLayout = QVBoxLayout(ErrorMessage) + self.verticalLayout.setObjectName(u"verticalLayout") + self.verticalSpacer_2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) + + self.verticalLayout.addItem(self.verticalSpacer_2) + + self.horizontalLayout = QHBoxLayout() + self.horizontalLayout.setObjectName(u"horizontalLayout") + self.label = QLabel(ErrorMessage) + self.label.setObjectName(u"label") + self.label.setTextFormat(Qt.AutoText) + self.label.setWordWrap(True) + + self.horizontalLayout.addWidget(self.label) + + + self.verticalLayout.addLayout(self.horizontalLayout) + + self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) + + self.verticalLayout.addItem(self.verticalSpacer) + + self.horizontalLayout_3 = QHBoxLayout() + self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") + self.buttonBox = QDialogButtonBox(ErrorMessage) + self.buttonBox.setObjectName(u"buttonBox") + self.buttonBox.setStandardButtons(QDialogButtonBox.Ok) + + self.horizontalLayout_3.addWidget(self.buttonBox) + + + self.verticalLayout.addLayout(self.horizontalLayout_3) + + + self.retranslateUi(ErrorMessage) + + QMetaObject.connectSlotsByName(ErrorMessage) + # setupUi + + def retranslateUi(self, ErrorMessage): + ErrorMessage.setWindowTitle(QCoreApplication.translate("ErrorMessage", u"Sway socket not found!", None)) + self.label.setText(QCoreApplication.translate("ErrorMessage", u"

Sway Input Configurator only supports Sway. You are probably using an unsupported window manager or there are problems with your Sway configuration.

", None)) + # retranslateUi +