def __init__(self, userStyle):
     self.windowList = []
     globalref.treeControl = self
     self.serverSocket = None
     mainVersion = '.'.join(__version__.split('.')[:2])
     globalref.options = option.Option(u'treeline-%s' % mainVersion, 21)
     globalref.options.loadAll(optiondefaults.defaultOutput())
     iconPathList = [iconPath, os.path.join(globalref.modPath, u'icons/'),
                     os.path.join(globalref.modPath, u'../icons/')]
     if not iconPath:
         del iconPathList[0]
     globalref.treeIcons = icondict.IconDict()
     globalref.treeIcons.addIconPath([os.path.join(path, u'tree') for path
                                      in iconPathList])
     globalref.treeIcons.addIconPath([globalref.options.iconPath])
     treemainwin.TreeMainWin.toolIcons = icondict.IconDict()
     treemainwin.TreeMainWin.toolIcons.\
                 addIconPath([os.path.join(path, u'toolbar')
                              for path in iconPathList],
                             [u'', u'32x32', u'16x16'])
     treemainwin.TreeMainWin.toolIcons.loadAllIcons()
     windowIcon = globalref.treeIcons.getIcon(u'treeline')
     if windowIcon:
         QtGui.QApplication.setWindowIcon(windowIcon)
     if not userStyle:
         if sys.platform.startswith('dar'):
             QtGui.QApplication.setStyle('macintosh')
         elif not sys.platform.startswith('win'):
             QtGui.QApplication.setStyle('plastique')
     self.recentFiles = recentfiles.RecentFileList()
     qApp = QtGui.QApplication.instance()
     qApp.connect(qApp, QtCore.SIGNAL('focusChanged(QWidget*, QWidget*)'),
                  self.updateFocus)
Beispiel #2
0
 def __init__(self, userStyle):
     self.windowList = []
     globalref.treeControl = self
     self.serverSocket = None
     mainVersion = '.'.join(__version__.split('.')[:2])
     globalref.options = option.Option(u'treeline-%s' % mainVersion, 21)
     globalref.options.loadAll(optiondefaults.defaultOutput())
     iconPathList = [iconPath, os.path.join(globalref.modPath, u'icons/'),
                     os.path.join(globalref.modPath, u'../icons/')]
     if not iconPath:
         del iconPathList[0]
     globalref.treeIcons = icondict.IconDict()
     globalref.treeIcons.addIconPath([os.path.join(path, u'tree') for path
                                      in iconPathList])
     globalref.treeIcons.addIconPath([globalref.options.iconPath])
     treemainwin.TreeMainWin.toolIcons = icondict.IconDict()
     treemainwin.TreeMainWin.toolIcons.\
                 addIconPath([os.path.join(path, u'toolbar')
                              for path in iconPathList],
                             [u'', u'32x32', u'16x16'])
     treemainwin.TreeMainWin.toolIcons.loadAllIcons()
     windowIcon = globalref.treeIcons.getIcon(u'treeline')
     if windowIcon:
         QtGui.QApplication.setWindowIcon(windowIcon)
     if not userStyle:
         if sys.platform.startswith('dar'):
             QtGui.QApplication.setStyle('macintosh')
         elif not sys.platform.startswith('win'):
             QtGui.QApplication.setStyle('plastique')
     self.recentFiles = recentfiles.RecentFileList()
     qApp = QtGui.QApplication.instance()
     qApp.connect(qApp, QtCore.SIGNAL('focusChanged(QWidget*, QWidget*)'),
                  self.updateFocus)
Beispiel #3
0
    def __init__(self, pathObjects, parent=None):
        """Initialize the main tree controls

        Arguments:
            pathObjects -- a list of file objects to open
            parent -- the parent QObject if given
        """
        super().__init__(parent)
        self.localControls = []
        self.activeControl = None
        self.trayIcon = None
        self.isTrayMinimized = False
        self.configDialog = None
        self.sortDialog = None
        self.numberingDialog = None
        self.findTextDialog = None
        self.findConditionDialog = None
        self.findReplaceDialog = None
        self.filterTextDialog = None
        self.filterConditionDialog = None
        self.basicHelpView = None
        self.passwords = {}
        globalref.mainControl = self
        self.allActions = {}
        try:
            # check for existing TreeLine session
            socket = QLocalSocket()
            socket.connectToServer('treeline3-session', QIODevice.WriteOnly)
            # if found, send files to open and exit TreeLine
            if socket.waitForConnected(1000):
                socket.write(
                    bytes(repr([str(path) for path in pathObjects]), 'utf-8'))
                if socket.waitForBytesWritten(1000):
                    socket.close()
                    sys.exit(0)
            # start local server to listen for attempt to start new session
            self.serverSocket = QLocalServer()
            self.serverSocket.listen('treeline3-session')
            self.serverSocket.newConnection.connect(self.getSocket)
        except AttributeError:
            print(_('Warning:  Could not create local socket'))
        mainVersion = '.'.join(__version__.split('.')[:2])
        globalref.genOptions = options.Options('general', 'TreeLine',
                                               mainVersion, 'bellz')
        optiondefaults.setGenOptionDefaults(globalref.genOptions)
        globalref.miscOptions = options.Options('misc')
        optiondefaults.setMiscOptionDefaults(globalref.miscOptions)
        globalref.histOptions = options.Options('history')
        optiondefaults.setHistOptionDefaults(globalref.histOptions)
        globalref.toolbarOptions = options.Options('toolbar')
        optiondefaults.setToolbarOptionDefaults(globalref.toolbarOptions)
        globalref.keyboardOptions = options.Options('keyboard')
        optiondefaults.setKeyboardOptionDefaults(globalref.keyboardOptions)
        try:
            globalref.genOptions.readFile()
            globalref.miscOptions.readFile()
            globalref.histOptions.readFile()
            globalref.toolbarOptions.readFile()
            globalref.keyboardOptions.readFile()
        except IOError:
            errorDir = options.Options.basePath
            if not errorDir:
                errorDir = _('missing directory')
            QMessageBox.warning(
                None, 'TreeLine',
                _('Error - could not write config file to {}').format(
                    errorDir))
            options.Options.basePath = None
        iconPathList = self.findResourcePaths('icons', iconPath)
        globalref.toolIcons = icondict.IconDict(
            [path / 'toolbar' for path in iconPathList],
            ['', '32x32', '16x16'])
        globalref.toolIcons.loadAllIcons()
        windowIcon = globalref.toolIcons.getIcon('treelogo')
        if windowIcon:
            QApplication.setWindowIcon(windowIcon)
        globalref.treeIcons = icondict.IconDict(iconPathList, ['', 'tree'])
        icon = globalref.treeIcons.getIcon('default')
        qApp.setStyle(QStyleFactory.create('Fusion'))
        setThemeColors()
        self.recentFiles = recentfiles.RecentFileList()
        if globalref.genOptions['AutoFileOpen'] and not pathObjects:
            recentPath = self.recentFiles.firstPath()
            if recentPath:
                pathObjects = [recentPath]
        self.setupActions()
        self.systemFont = QApplication.font()
        self.updateAppFont()
        if globalref.genOptions['MinToSysTray']:
            self.createTrayIcon()
        qApp.focusChanged.connect(self.updateActionsAvail)
        if pathObjects:
            for pathObj in pathObjects:
                self.openFile(pathObj, True)
        else:
            self.createLocalControl()
Beispiel #4
0
    def __init__(self, filePaths, parent=None):
        """Initialize the main tree controls

        Arguments:
            filePaths -- a list of files to open
            parent -- the parent QObject if given
        """
        super().__init__(parent)
        self.localControls = []
        self.activeControl = None
        self.pluginInterface = None
        self.pluginInstances = []
        self.pluginDescriptions = []
        self.configDialog = None
        self.sortDialog = None
        self.numberingDialog = None
        self.findTextDialog = None
        self.findConditionDialog = None
        self.findReplaceDialog = None
        self.filterTextDialog = None
        self.filterConditionDialog = None
        self.basicHelpView = None
        self.serverSocket = None
        self.passwords = {}
        globalref.mainControl = self
        try:
            # check for existing TreeLine session
            socket = QtNetwork.QLocalSocket()
            socket.connectToServer('treeline2-session',
                                   QtCore.QIODevice.WriteOnly)
            # if found, send files to open and exit TreeLine
            if socket.waitForConnected(1000):
                socket.write(bytes(repr(filePaths), 'utf-8'))
                if socket.waitForBytesWritten(1000):
                    socket.close()
                    sys.exit(0)
            # start local server to listen for attempt to start new session
            self.serverSocket = QtNetwork.QLocalServer()
            self.serverSocket.listen('treeline2-session')
            self.serverSocket.newConnection.connect(self.getSocket)
        except AttributeError:
            print(_('Warning:  Could not create local socket'))
        mainVersion = '.'.join(__version__.split('.')[:2])
        globalref.genOptions = options.Options('general', 'GmEdit',
                                               mainVersion, 'gmedit')
        optiondefaults.setGenOptionDefaults(globalref.genOptions)
        globalref.miscOptions = options.Options('misc')
        optiondefaults.setMiscOptionDefaults(globalref.miscOptions)
        globalref.histOptions = options.Options('history')
        optiondefaults.setHistOptionDefaults(globalref.histOptions)
        globalref.toolbarOptions = options.Options('toolbar')
        optiondefaults.setToolbarOptionDefaults(globalref.toolbarOptions)
        globalref.keyboardOptions = options.Options('keyboard')
        optiondefaults.setKeyboardOptionDefaults(globalref.keyboardOptions)
        try:
            globalref.genOptions.readFile()
            globalref.miscOptions.readFile()
            recentfiles.setRecentOptionDefaults()
            globalref.histOptions.readFile()
            globalref.toolbarOptions.readFile()
            globalref.keyboardOptions.readFile()
        except IOError:
            QtGui.QMessageBox.warning(
                QtGui.QApplication.activeWindow(), 'GmEdit',
                _('Error - could not write config file to {}').format(
                    options.Options.basePath))
        iconPathList = self.findResourcePaths('icons', iconPath)
        globalref.toolIcons = icondict.IconDict(
            [os.path.join(path, 'toolbar') for path in iconPathList],
            ['', '32x32', '16x16'])
        globalref.toolIcons.loadAllIcons()
        windowIcon = globalref.toolIcons.getIcon('gm_logo')
        if windowIcon:
            QtGui.QApplication.setWindowIcon(windowIcon)
        globalref.treeIcons = icondict.IconDict(iconPathList, ['', 'tree'])
        self.recentFiles = recentfiles.RecentFileList()
        if globalref.genOptions.getValue('AutoFileOpen') and not filePaths:
            recentPath = self.recentFiles.firstPath()
            if recentPath:
                filePaths = [recentPath]
        self.allActions = {}
        self.setupActions()
        QtGui.qApp.focusChanged.connect(self.updateActionsAvail)
        if filePaths:
            for path in filePaths:
                self.openFile(path)
        else:
            self.createLocalControl()
        self.setupPlugins()
Beispiel #5
0
    def __init__(self, filePaths, parent=None):
        """Initialize the main tree controls

        Arguments:
            filePaths -- a list of files to open
            parent -- the parent QObject if given
        """
        super().__init__(parent)
        self.localControls = []
        self.activeControl = None
        self.pluginInterface = None
        self.pluginInstances = []
        self.pluginDescriptions = []
        self.configDialog = None
        self.sortDialog = None
        self.numberingDialog = None
        self.findTextDialog = None
        self.findConditionDialog = None
        self.findReplaceDialog = None
        self.filterTextDialog = None
        self.filterConditionDialog = None
        self.basicHelpView = None
        self.serverSocket = None
        self.passwords = {}
        globalref.mainControl = self
        try:
            # check for existing TreeLine session
            socket = QtNetwork.QLocalSocket()
            socket.connectToServer('treeline2-session',
                                   QtCore.QIODevice.WriteOnly)
            # if found, send files to open and exit TreeLine
            if socket.waitForConnected(1000):
                socket.write(bytes(repr(filePaths), 'utf-8'))
                if socket.waitForBytesWritten(1000):
                    socket.close()
                    sys.exit(0)
            # start local server to listen for attempt to start new session
            self.serverSocket = QtNetwork.QLocalServer()
            self.serverSocket.listen('treeline2-session')
            self.serverSocket.newConnection.connect(self.getSocket)
        except AttributeError:
            print(_('Warning:  Could not create local socket'))
        mainVersion = '.'.join(__version__.split('.')[:2])
        globalref.genOptions = options.Options('general', 'GmEdit',
                                               mainVersion, 'gmedit')
        optiondefaults.setGenOptionDefaults(globalref.genOptions)
        globalref.miscOptions  = options.Options('misc')
        optiondefaults.setMiscOptionDefaults(globalref.miscOptions)
        globalref.histOptions = options.Options('history')
        optiondefaults.setHistOptionDefaults(globalref.histOptions)
        globalref.toolbarOptions = options.Options('toolbar')
        optiondefaults.setToolbarOptionDefaults(globalref.toolbarOptions)
        globalref.keyboardOptions = options.Options('keyboard')
        optiondefaults.setKeyboardOptionDefaults(globalref.keyboardOptions)
        try:
            globalref.genOptions.readFile()
            globalref.miscOptions.readFile()
            recentfiles.setRecentOptionDefaults()
            globalref.histOptions.readFile()
            globalref.toolbarOptions.readFile()
            globalref.keyboardOptions.readFile()
        except IOError:
            QtGui.QMessageBox.warning(QtGui.QApplication.activeWindow(),
                                'GmEdit',
                                _('Error - could not write config file to {}').
                                format(options.Options.basePath))
        iconPathList = self.findResourcePaths('icons', iconPath)
        globalref.toolIcons = icondict.IconDict([os.path.join(path, 'toolbar')
                                                 for path in iconPathList],
                                                ['', '32x32', '16x16'])
        globalref.toolIcons.loadAllIcons()
        windowIcon = globalref.toolIcons.getIcon('gm_logo')
        if windowIcon:
            QtGui.QApplication.setWindowIcon(windowIcon)
        globalref.treeIcons = icondict.IconDict(iconPathList, ['', 'tree'])
        self.recentFiles = recentfiles.RecentFileList()
        if globalref.genOptions.getValue('AutoFileOpen') and not filePaths:
            recentPath = self.recentFiles.firstPath()
            if recentPath:
                filePaths = [recentPath]
        self.allActions = {}
        self.setupActions()
        QtGui.qApp.focusChanged.connect(self.updateActionsAvail)
        if filePaths:
            for path in filePaths:
                self.openFile(path)
        else:
            self.createLocalControl()
        self.setupPlugins()