Пример #1
0
 def __init__(self, app):
     QDialog.__init__(self)
     self.app = app
     self.app_path = os.getenv("APPDATA") + "\\" + qApp.applicationName()
     self.registrySettings = QSettings("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", QSettings.NativeFormat)
     self.table_path = self.app_path + "\\tables"
     self.engine = Engine()
     self.minimize_action = QAction("Minimize", self)
     self.maximize_action = QAction("Maximize", self)
     self.settings_action = QAction("Settings", self)
     self.about_action = QAction("About", self)
     self.quit_action = QAction("Quit", self)
     self.tray_icon_menu = QMenu(self)
     self.tray_icon = QSystemTrayIcon(self)
     self.setupUi(self)
     self.icon = QIcon(QPixmap(":icon/off_logo"))
     self.construct_tray_icon()
     self.signal_connectors()
     self.database = DatabaseManager()
     self.shortcut_key = self.database.get_shortcut_key()
     self.populate_modifier_cbox()
     if self.database.get_current_state() == "True":
         self.engine.conv_state = False
     else:
         self.engine.conv_state = True
     self.icon_activated(QSystemTrayIcon.Trigger)
     self.file_path_tview.setEnabled(False)
     self.check_app_path()
     self.update_table(True)
     self.init_combobox()
     if self.registrySettings.contains(qApp.applicationName()):
         self.start_windows_check.setChecked(True)
     else:
         self.start_windows_check.setChecked(False)
Пример #2
0
 def __init__(self):
     QDialog.__init__(self)
     self.app_path = os.getenv("APPDATA") + "\\" + qApp.applicationName()
     self.registrySettings = QSettings("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", QSettings.NativeFormat)
     self.table_path = self.app_path + "\\tables"
     self.engine = Engine()
     self.minimize_action = QAction("Minimize", self)
     self.maximize_action = QAction("Maximize", self)
     self.settings_action = QAction("Settings", self)
     self.about_action = QAction("About", self)
     self.quit_action = QAction("Quit", self)
     self.tray_icon_menu = QMenu(self)
     self.tray_icon = QSystemTrayIcon(self)
     self.setupUi(self)
     self.icon = QIcon(QPixmap(":icon/off_logo"))
     self.construct_tray_icon()
     self.signal_connectors()
     self.database = DatabaseManager()
     self.shortcut_key = self.database.get_shortcut_key()
     self.populate_modifier_cbox()
     if self.database.get_current_state() == "True":
         self.engine.conv_state = False
     else:
         self.engine.conv_state = True
     self.icon_activated(QSystemTrayIcon.Trigger)
     self.file_path_tview.setEnabled(False)
     self.check_app_path()
     self.update_table(True)
     self.init_combobox()
     if self.registrySettings.contains(qApp.applicationName()):
         self.start_windows_check.setChecked(True)
     else:
         self.start_windows_check.setChecked(False)
Пример #3
0
 def checkbox_start_with_windows_ticked(self):
     """
         Function to add or disable registry entry to auto start ekalappai with windows for the current users
     """
     if self.checkboxStartWithWindows.isChecked():
         self.registrySettings.setValue(qApp.applicationName(), qApp.applicationFilePath())
     else:
         self.registrySettings.remove(qApp.applicationName())
Пример #4
0
 def show_tray_message(self, index):
     """
         Tray message generator when there is change in keyboard state
     """
     icon = QSystemTrayIcon.MessageIcon(0)
     message = self.iconComboBox.itemText(int(index)) + " set"
     self.trayIcon.showMessage(qApp.applicationName() + " " + qApp.applicationVersion(), message, icon, 100)
Пример #5
0
 def show_tray_message(self):
     if self.engine.conv_state:
         message = "Ekalappai is Switched ON"
     else:
         message = "Ekalappai is Switched OFF"
     self.tray_icon.showMessage(
         qApp.applicationName() + " " + qApp.applicationVersion(),
         message,
         QSystemTrayIcon.MessageIcon(0),
         100
     )
Пример #6
0
 def show_tray_message(self):
     if self.engine.conv_state:
         message = "Ekalappai is Switched ON"
     else:
         message = "Ekalappai is Switched OFF"
     self.tray_icon.showMessage(
         qApp.applicationName() + " " + qApp.applicationVersion(),
         message,
         QSystemTrayIcon.MessageIcon(0),
         100
     )
Пример #7
0
 def init_settings(self):
     """
         Function to check whether the settings file is there or not. If there is no file, then it will create with
         default settings.
     """
     if not os.path.exists(self.settingsFilePath):
         settings_dir = os.getenv("APPDATA") + "\\" + qApp.applicationName()
         if not os.path.exists(settings_dir):
             os.makedirs(settings_dir)
         setting_path = ""
         if getattr(sys, 'frozen', False):
             setting_path = os.path.dirname(sys.executable)
         elif __file__:
             setting_path = os.path.dirname(__file__)
         shutil.copyfile(os.path.join(setting_path, "resources\eksettings.ini"), self.settingsFilePath)
     return
Пример #8
0
    def __init__(self):
        """
            Constructor for this class
        """
        super(EKWindow, self).__init__()
        self.engine = Engine("tables/Tamil-bamini.txt.in")

        # Settings file initialization
        self.settingsFilePath = os.getenv("APPDATA") + "\\" + qApp.applicationName() + "\eksettings.ini"
        self.init_settings()    # Function to check whether the settings file is or not.
        self.iniSettings = QSettings(self.settingsFilePath, QSettings.IniFormat)

        # Variable Initialization
        self.registrySettings = QSettings("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", QSettings.NativeFormat)
        self.shortcutModifierKey = self.iniSettings.value("shortcut_modifier")
        self.shortcutKey = self.iniSettings.value("shortcut")
        self.selectedKeyboard = self.iniSettings.value("selected_keyboard")
        self.keyboardStatus = False
        self.fileName = ""

        # Ui variable Initialization
        self.iconGroupBox = QGroupBox("Keyboards")
        self.iconLabel = QLabel("Keyboard:")
        self.iconComboBox = QComboBox(self)
        self.shortcutGroupBox = QGroupBox("Shortcut Setting")
        self.shortcutComboBox1 = QComboBox(self)
        self.shortcutComboBox2 = QComboBox(self)
        self.otherSettingsGroupBox = QGroupBox("Other Settings")
        self.checkboxStartWithWindows = QCheckBox()
        self.minimizeAction = QAction("Minimize", self)
        self.maximizeAction = QAction("Maximize", self)
        self.settingsAction = QAction("Settings", self)
        self.aboutAction = QAction("About", self)
        self.quitAction = QAction("Quit", self)
        self.trayIconMenu = QMenu(self)
        self.trayIcon = QSystemTrayIcon(self)
        self.mainLayout = QVBoxLayout()
        self.mainLayout.addWidget(self.iconGroupBox)
        self.mainLayout.addWidget(self.shortcutGroupBox)
        self.mainLayout.addWidget(self.otherSettingsGroupBox)
        self.setLayout(self.mainLayout)

        # UI constructor and connectors
        self.create_settings_group_boxes()
        self.create_actions()
        self.create_tray_icon()

        # Signal connectors
        self.iconComboBox.currentIndexChanged.connect(self.change_keyboard)
        self.shortcutComboBox1.currentIndexChanged.connect(self.set_shortcut_modifier)
        self.shortcutComboBox2.currentIndexChanged.connect(self.set_shortcut_key)
        self.trayIcon.activated.connect(self.icon_activated)
        self.checkboxStartWithWindows.stateChanged.connect(self.checkbox_start_with_windows_ticked)

        if self.keyboardStatus:
            self.iconComboBox.setCurrentIndex(self.selectedKeyBoard)
        else:
            self.change_keyboard(0)
            self.iconComboBox.setCurrentIndex(0)

        self.trayIcon.show()
        self.set_shortcut_key()
        self.setWindowTitle(qApp.applicationName() + " " + qApp.applicationVersion())
Пример #9
0
    def create_settings_group_boxes(self):
        """
            UI generator function.
        """
        self.iconComboBox.addItem("No Keyboard")
        self.iconComboBox.addItem("Tamil99")
        self.iconComboBox.addItem("Phonetic")
        self.iconComboBox.addItem("Typewriter")
        self.iconComboBox.addItem("Bamini")
        self.iconComboBox.addItem("Inscript")
        icon_layout = QHBoxLayout(self)
        icon_layout.addWidget(self.iconLabel)
        icon_layout.addWidget(self.iconComboBox)
        icon_layout.addStretch()
        self.iconGroupBox.setLayout(icon_layout)

        shortcut_label_1 = QLabel("Modifier Key:")
        shortcut_label_2 = QLabel("Shortcut Key:")

        self.shortcutComboBox1.addItem("NONE")
        self.shortcutComboBox1.addItem("CTRL")
        self.shortcutComboBox1.addItem("ALT")

        modifier_index = self.shortcutComboBox1.findText(self.shortcutModifierKey)
        self.shortcutComboBox1.setCurrentIndex(modifier_index)

        self.shortcutComboBox2.setMinimumContentsLength(3)

        if modifier_index == 0:
            self.shortcutComboBox2.addItem("F1")
            self.shortcutComboBox2.addItem("ESC")
            self.shortcutComboBox2.addItem("F2")
            self.shortcutComboBox2.addItem("F3")
            self.shortcutComboBox2.addItem("F4")
            self.shortcutComboBox2.addItem("F5")
            self.shortcutComboBox2.addItem("F6")
            self.shortcutComboBox2.addItem("F7")
            self.shortcutComboBox2.addItem("F8")
            self.shortcutComboBox2.addItem("F9")
            self.shortcutComboBox2.addItem("F10")
        else:
            self.shortcutComboBox2.addItem("1")
            self.shortcutComboBox2.addItem("2")
            self.shortcutComboBox2.addItem("3")
            self.shortcutComboBox2.addItem("4")
            self.shortcutComboBox2.addItem("5")
            self.shortcutComboBox2.addItem("6")
            self.shortcutComboBox2.addItem("7")
            self.shortcutComboBox2.addItem("8")
            self.shortcutComboBox2.addItem("9")
            self.shortcutComboBox2.addItem("0")

        key_index = self.shortcutComboBox2.findText(self.shortcutKey)
        self.shortcutComboBox2.setCurrentIndex(key_index)

        shortcut_layout = QHBoxLayout(self)
        shortcut_layout.addWidget(shortcut_label_1)
        shortcut_layout.addWidget(self.shortcutComboBox1)
        shortcut_layout.addWidget(shortcut_label_2)
        shortcut_layout.addWidget(self.shortcutComboBox2)
        shortcut_layout.addStretch()
        self.shortcutGroupBox.setLayout(shortcut_layout)

        checkbox_start_with_windows_label = QLabel("Start eKalappai whenever windows starts")

        # if registry entry for auto start with windows for the current user exists, then check the checkbox
        if self.registrySettings.contains(qApp.applicationName()):
            self.checkboxStartWithWindows.setChecked(True)
        else:
            self.checkboxStartWithWindows.setChecked(False)

        other_settings_layout = QHBoxLayout(self)
        other_settings_layout.addWidget(checkbox_start_with_windows_label)
        other_settings_layout.addWidget(self.checkboxStartWithWindows)
        other_settings_layout.addStretch()
        self.otherSettingsGroupBox.setLayout(other_settings_layout)
Пример #10
0
 def change_start_windows(self):
     if self.start_windows_check.isChecked():
         self.registrySettings.setValue(qApp.applicationName(), qApp.applicationFilePath())
     else:
         self.registrySettings.remove(qApp.applicationName())
Пример #11
0
 def change_start_windows(self):
     if self.start_windows_check.isChecked():
         self.registrySettings.setValue(qApp.applicationName(), qApp.applicationFilePath())
     else:
         self.registrySettings.remove(qApp.applicationName())