예제 #1
0
    def __init__(self, parent_widget):
        QDialog.__init__(self, parent_widget)
        self.setupUi(self)

        desc = "\n".join(
            (
                "%(PROTOCOL_TAG)s: Database protocol. Double-click and hold to see the available options.",
                "%(HOST_NAME_TAG)s: Host name (and database name for Postgres).",
                '    * Postgres: Use the format "host_name/database_name" (without quotes).',
                "          - Leave host_name empty to connect to localhost.",
                "          - Leave database_name empty (but retain the slash) to connect",
                "            to the default database for the database user.",
                "    * Other protocols: Enter the host name only.",
                "%(USER_NAME_TAG)s: Database user name",
                "%(PASSWORD_TAG)s: Database password",
                "",
                "To add a new database configuration, please edit",
                "%(conf_file_path)s",
            )
        )
        desc = QtGui.QApplication.translate("DatabaseSettingsEditGui", desc, None, QtGui.QApplication.UnicodeUTF8)
        desc = unicode(desc) % dict(
            [
                (n, eval("DatabaseServerConfiguration.%s" % n))
                for n in dir(DatabaseServerConfiguration)
                if re.match(".*_TAG$", n)
            ]
            + [("conf_file_path", DatabaseServerConfiguration.get_default_configuration_file_path())]
        )
        desc = QtCore.QString(desc)

        self.description.setText(desc)

        self._config_filename = DatabaseServerConfiguration.get_default_configuration_file_path()

        try:
            self.xml_root = ElementTree(file=self._config_filename).getroot()
            self.base_widget = self.variableBox
            self.xml_controller = XmlController_DatabaseConfig(self)
            # Turns out that Qt Garbage collects the model (and delegate) if we don't explicitly
            # bind it to a Python object in addition to using the PyQt .setModel() method.

            self.tree_view = self.xml_controller.view
            return

        except IOError, ex:
            MessageBox.error(mainwindow=self, text="Could not initialize Database Settings", detailed_text=str(ex))
            self.xml_root = None
            self._config_filename = ""
            self.configFile = None
예제 #2
0
    def __init__(self, parent_widget):
        QDialog.__init__(self, parent_widget)
        self.setupUi(self)

        desc = '\n'.join((
            '%(PROTOCOL_TAG)s: Database protocol. Double-click and hold to see the available options.',
            '%(HOST_NAME_TAG)s: Host name (and database name for Postgres).',
            '    * Postgres: Use the format "host_name/database_name" (without quotes).',
            '          - Leave host_name empty to connect to localhost.',
            '          - Leave database_name empty (but retain the slash) to connect',
            '            to the default database for the database user.',
            '    * Other protocols: Enter the host name only.',
            '%(USER_NAME_TAG)s: Database user name',
            '%(PASSWORD_TAG)s: Database password', '',
            'To add a new database configuration, please edit',
            '%(conf_file_path)s'))
        desc = QtGui.QApplication.translate("DatabaseSettingsEditGui", desc,
                                            None,
                                            QtGui.QApplication.UnicodeUTF8)
        desc = unicode(desc) % dict(
            [(n, eval('DatabaseServerConfiguration.%s' % n))
             for n in dir(DatabaseServerConfiguration)
             if re.match('.*_TAG$', n)] +
            [('conf_file_path',
              DatabaseServerConfiguration.get_default_configuration_file_path(
              ))])
        desc = QtCore.QString(desc)

        self.description.setText(desc)

        self._config_filename = DatabaseServerConfiguration.get_default_configuration_file_path(
        )

        try:
            self.xml_root = ElementTree(file=self._config_filename).getroot()
            self.base_widget = self.variableBox
            self.xml_controller = XmlController_DatabaseConfig(self)
            # Turns out that Qt Garbage collects the model (and delegate) if we don't explicitly
            # bind it to a Python object in addition to using the PyQt .setModel() method.

            self.tree_view = self.xml_controller.view
            return

        except IOError, ex:
            MessageBox.error(mainwindow=self,
                             text='Could not initialize Database Settings',
                             detailed_text=str(ex))
            self.xml_root = None
            self._config_filename = ''
            self.configFile = None
예제 #3
0
    def __init__(self, gui_configuration = None):
        QMainWindow.__init__(self)
        self.setupUi(self)

        # Bind the application global instance for to this window
        set_opusgui_instance(self)

        self.thread().setPriority(QThread.HighestPriority)

        self.tabWidget = QTabWidget(self.splitter)
        self.splitter.setSizes([400, 500])

        # Create a log window
        self.log_tab = LogWidget(self.tabWidget)
        self.log_tab.start_stdout_capture()

        # Initialize empty project
        self.project = OpusProject()
        self.shows_hidden = False

        # Read database connection names
        db_con_file = DatabaseServerConfiguration.get_default_configuration_file_path()
        db_config_node = ElementTree(file=db_con_file).getroot()
        self.db_connection_names = [node.tag for node in db_config_node if
                                     node.tag != Comment and node.get('hidden') != "True" and node.tag != 'xml_version']
  
        # Application default configuration
        self.gui_config = gui_configuration

        # Bind actions
        self._setup_actions()

        # Manager collection -- initialized by openProject()
        self.managers = {}

#        # Delay before hiding the splash screen
#        time.sleep(1)
#        self.gui_config.splash_screen.hide()

        # Restoring application geometry from last shut down
        settings = QSettings()
        self.restoreGeometry(settings.value("Geometry").toByteArray())
        self.updateFontSize()
        self.setFocus()

        # Variable library
        self.variable_library = None

        # Load the latest project file if that flag is set in GUI configuration
        if self.gui_config.load_latest_on_start:
            try:
                self.openProject(self.gui_config.latest_project_filename or '')
            except:
                self.closeProject()
            if self.gui_config.load_latest_tab_on_start:
                try:
                    self.toolBox.setCurrentIndex(int(self.gui_config.latest_tab_index))
                except:
                    pass
        ###T: removing these until they serve a purpose
        self.menuUtilities.removeAction(self.actPythonView)
        #self.menuUtilities.removeAction(self.actionLog_View)
        self.menuUtilities.removeAction(self.actEditorView)

        self.connect(self, SIGNAL('variables_updated'), self.update_saved_state)
        self.update_saved_state()
예제 #4
0
    def __init__(self, gui_configuration=None):
        QMainWindow.__init__(self)
        self.setupUi(self)

        # Bind the application global instance for to this window
        set_opusgui_instance(self)

        self.thread().setPriority(QThread.HighestPriority)

        self.tabWidget = QTabWidget(self.splitter)
        self.splitter.setSizes([400, 500])

        # Create a log window
        self.log_tab = LogWidget(self.tabWidget)
        self.log_tab.start_stdout_capture()

        # Initialize empty project
        self.project = OpusProject()
        self.shows_hidden = False

        # Read database connection names
        db_con_file = DatabaseServerConfiguration.get_default_configuration_file_path(
        )
        db_config_node = ElementTree(file=db_con_file).getroot()
        self.db_connection_names = [
            node.tag for node in db_config_node if node.tag != Comment
            and node.get('hidden') != "True" and node.tag != 'xml_version'
        ]

        # Application default configuration
        self.gui_config = gui_configuration

        # Bind actions
        self._setup_actions()

        # Manager collection -- initialized by openProject()
        self.managers = {}

        #        # Delay before hiding the splash screen
        #        time.sleep(1)
        #        self.gui_config.splash_screen.hide()

        # Restoring application geometry from last shut down
        settings = QSettings()
        self.restoreGeometry(settings.value("Geometry").toByteArray())
        self.updateFontSize()
        self.setFocus()

        # Variable library
        self.variable_library = None

        # Load the latest project file if that flag is set in GUI configuration
        if self.gui_config.load_latest_on_start:
            try:
                self.openProject(self.gui_config.latest_project_filename or '')
            except:
                self.closeProject()
            if self.gui_config.load_latest_tab_on_start:
                try:
                    self.toolBox.setCurrentIndex(
                        int(self.gui_config.latest_tab_index))
                except:
                    pass
        ###T: removing these until they serve a purpose
        self.menuUtilities.removeAction(self.actPythonView)
        #self.menuUtilities.removeAction(self.actionLog_View)
        self.menuUtilities.removeAction(self.actEditorView)

        self.connect(self, SIGNAL('variables_updated'),
                     self.update_saved_state)
        self.update_saved_state()