Exemple #1
0
def show():
    """Browse the tokens in the ID file."""
    # Make all our config is initialised.
    ConfigWidget().apply()
    global idDatabase
    global searchBar
    if searchBar is None:
        idDatabase = Lookup()
        searchBar = SearchBar(kate.mainWindow(), idDatabase)
    global completionModel
    if completionModel is None:
        completionModel = CompletionModel(kate.mainWindow(), idDatabase)
    viewChanged()
    return searchBar.show()
Exemple #2
0
def init():
    # Set default value if not configured yet
    kate.kDebug('Loading...')
    if settings.CMAKE_BINARY not in kate.sessionConfiguration:
        kate.sessionConfiguration[settings.CMAKE_BINARY] = settings.CMAKE_BINARY_DEFAULT
    if settings.PARENT_DIRS_LOOKUP_CNT not in kate.sessionConfiguration:
        kate.sessionConfiguration[settings.PARENT_DIRS_LOOKUP_CNT] = 0
    if settings.AUX_MODULE_DIRS not in kate.sessionConfiguration:
        kate.sessionConfiguration[settings.AUX_MODULE_DIRS] = []
    if settings.PROJECT_DIR not in kate.sessionConfiguration:
        kate.sessionConfiguration[settings.PROJECT_DIR] = ''
    if settings.TOOLVIEW_ADVANCED_MODE not in kate.sessionConfiguration:
        kate.sessionConfiguration[settings.TOOLVIEW_ADVANCED_MODE] = False
    if settings.TOOLVIEW_BEAUTIFY not in kate.sessionConfiguration:
        kate.sessionConfiguration[settings.TOOLVIEW_BEAUTIFY] = True

    # Create completion model
    global _cmake_completion_model
    if _cmake_completion_model is None:
        kate.kDebug('CMake Helper Plugin: Create a completer')
        _cmake_completion_model = CMakeCompletionModel(kate.application)
        _cmake_completion_model.modelReset.connect(_reset)

    # Make an instance of a cmake tool view
    global _cmake_tool_view
    if _cmake_tool_view is None:
        kate.kDebug('CMake Helper Plugin: Create a tool view')
        _cmake_tool_view = CMakeToolView(kate.mainWindow())
Exemple #3
0
def popup(message, timeout, icon=None, maxTextWidth=None, minTextWidth=None, parent=None):
    if parent is None:
        import kate
        parent = kate.mainWindow()
    popup = TimeoutPassivePopup(parent, message, timeout, icon, maxTextWidth, minTextWidth)
    popup.show()
    return popup
def create_mainmenu(name_menu, slug_menu, prefix=PREFIX_MENU):
    window = kate.mainWindow()
    menubar = window.findChildren(QtGui.QMenuBar)[0]
    new_menu = kdeui.KMenu(name_menu, window)
    slug_menu = get_slug_menu(slug_menu, prefix=prefix)
    new_menu.setObjectName(slug_menu)
    menubar.addMenu(new_menu)
    return slug_menu
Exemple #5
0
def popup(caption, text, iconName = None, iconSize = 16):
    ''' Show passive popup using native KDE API
    '''
    parentWidget = kate.mainWindow()
    if iconName:
        icon = KIcon (iconName).pixmap(QSize(iconSize, iconSize))
        KPassivePopup.message(caption, text, icon, parentWidget)
    else:
        KPassivePopup.message(caption, text, parentWidget)
Exemple #6
0
def init():
    '''Iniialize global variables and read config'''
    # Set default value for last used #color if not configured yet
    if _INSERT_COLOR_LCC not in kate.sessionConfiguration:
        kate.sessionConfiguration[_INSERT_COLOR_LCC] = '#ffffff'

    swatcher = ColorSwatcher()

    ## Make an instance of a palette tool view
    global paletteView
    if paletteView is None:
        paletteView = PaletteView(kate.mainWindow())

    # Make an instance of a color chooser widget,
    # connect it to active document updater
    global colorChooserWidget
    if colorChooserWidget is None:
        colorChooserWidget = ColorChooser(kate.mainWindow())
        colorChooserWidget.colorSelected.connect(_insertColorIntoActiveDocument)
Exemple #7
0
def license_accepted(license):
    """asks to accept a license"""
    return KMessageBox.Yes == KMessageBox.warningYesNo(kate.mainWindow(),
        i18nc('@info:status', '''<p>
            Additionally to free software licenses like GPL and MIT,
            this functionality requires you to accept the following conditions:
            </p><p>%1</p><p>
            Do you want to accept and download the functionality?
            </p>''', license),
        i18nc('@title:window', 'Accept license?'))
Exemple #8
0
def hideOldPopUps():
    mainWindow = kate.mainWindow()
    popups = kate.gui.TimeoutPassivePopup.popups.get(mainWindow, []) or []
    for popup in popups:
        popup.timer.stop()
        popup.hide()
        popup.setFixedHeight(0)
        popup.adjustSize()
        popup.originalHeight = popup.height()
        popup.offsetBottom = 0
        popup.move(0, 0)
def get_session():
    main_window = kate.mainWindow()
    title = unicode(main_window.windowTitle())
    session = None
    if title and title != 'Kate' and ":" in title:
        session = title.split(":")[0]
        if session == 'file':
            session = None
    if session:
        return session
    return get_last_session()
Exemple #10
0
def get_session():
    main_window = kate.mainWindow()
    title = str(main_window.windowTitle())
    session = None
    if title and title != 'Kate' and ":" in title:
        session = title.split(":")[0]
        if session == 'file':
            session = None
    if session:
        return session
    return get_last_session()
def hideOldPopUps():
    mainWindow = kate.mainWindow()
    popups = kate.gui.TimeoutPassivePopup.popups.get(mainWindow, []) or []
    for popup in popups:
        popup.timer.stop()
        popup.hide()
        popup.setFixedHeight(0)
        popup.adjustSize()
        popup.originalHeight = popup.height()
        popup.offsetBottom = 0
        popup.move(0, 0)
Exemple #12
0
def init():
    """Iniialize global variables and read config"""
    # Set default value for last used #color if not configured yet
    if _INSERT_COLOR_LCC not in kate.configuration:
        kate.configuration[_INSERT_COLOR_LCC] = 'white'

    swatcher = ColorSwatcher()

    # Make an instance of a palette tool view
    global paletteView
    if paletteView is None:
        paletteView = PaletteView(kate.mainWindow())
Exemple #13
0
 def getSettings(self):
     """Show the settings dialog.
     Establish our configuration. Loop until we have a viable settings, or
     the user cancels.
     """
     fileSet = False
     transformOK = False
     while not fileSet or not transformOK:
         fileSet = False
         transformOK = False
         dialog = ConfigDialog(kate.mainWindow().centralWidget())
         status = dialog.exec_()
         if status == QDialog.Rejected:
             break
         dialog.widget.apply()
         #
         # Check the save file name.
         #
         try:
             #
             # Only re-read the file if it has changed.
             #
             if not searchBar.dataSource.file or (
                     searchBar.dataSource.file.name !=
                     kate.configuration["idFile"]):
                 searchBar.dataSource.setFile(kate.configuration["idFile"])
             fileSet = True
         except IOError as detail:
             KMessageBox.error(self.parent(), str(detail),
                               i18n("ID database error"))
         #
         # Check the transformation settings.
         #
         try:
             transformationKey = kate.configuration["srcIn"]
             percentI = kate.configuration["srcOut"].find("%i")
             if len(transformationKey) and (percentI > -1):
                 #
                 # A transformation of the file name is with the output
                 # using the %i placeholder. Ensure the idFile is usable for
                 # that purpose.
                 #
                 insertLeft, discard = kate.configuration["idFile"].split(
                     transformationKey, 1)
             transformOK = True
         except ValueError as detail:
             KMessageBox.error(
                 self.parent(),
                 i18n("'{}' does not contain '{}'").format(
                     kate.configuration["idFile"], transformationKey),
                 i18n("Cannot use %i"))
     return fileSet and transformOK
Exemple #14
0
def show():
    # Make all our config is initialised.
    ConfigWidget().apply()
    global idDatabase
    global searchBar
    if searchBar is None:
        idDatabase = Lookup()
        searchBar = SearchBar(kate.mainWindow(), idDatabase)
    global completionModel
    #if completionModel is None:
    #    completionModel = CompletionModel(kate.mainWindow(), idDatabase)
    viewChanged()
    return searchBar.show()
Exemple #15
0
    def moveAround(self, position):
        '''Smart positioning self around cursor'''
        self.colors.resizeColumnsToContents()
        self.colors.resizeRowsToContents()
        mwg = kate.mainWindow().geometry()
        wc = mwg.center()
        pos = mwg.topLeft() + position
        pos.setY(pos.y() + 40)
        if wc.y() < pos.y():
            pos.setY(pos.y() - self.height())
        if wc.x() < pos.x():
            pos.setX(pos.x() - self.width())

        self.move(pos)
def create_submenu(name_menu, slug_menu, menu_parent_slug, prefix=PREFIX_MENU):
    menu_parent = findMenu(menu_parent_slug)
    if not menu_parent:
        return ''
    window = kate.mainWindow()
    new_menu = kdeui.KMenu(name_menu, window)
    slug_menu = get_slug_menu(slug_menu, prefix=prefix)
    new_menu.setObjectName(slug_menu)

    action = QtGui.QAction(name_menu, new_menu)
    action.setObjectName(slug_menu)
    action.setMenu(new_menu)
    menu_parent.addAction(action)
    return slug_menu
Exemple #17
0
 def getSettings(self):
     """Show the settings dialog.
     Establish our configuration. Loop until we have a viable settings, or
     the user cancels.
     """
     fileSet = False
     transformOK = False
     while not fileSet or not transformOK:
         fileSet = False
         transformOK = False
         dialog = ConfigDialog(kate.mainWindow().centralWidget())
         status = dialog.exec_()
         if status == QDialog.Rejected:
             break
         dialog.widget.apply()
         #
         # Check the save file name.
         #
         try:
             #
             # Only re-read the file if it has changed.
             #
             if not searchBar.dataSource.file or (searchBar.dataSource.file.name != kate.configuration["idFile"]):
                 searchBar.dataSource.setFile(kate.configuration["idFile"])
             fileSet = True
         except IOError as detail:
             KMessageBox.error(self.parent(), toStr(detail), i18n("ID database error"))
         #
         # Check the transformation settings.
         #
         try:
             transformationKey = kate.configuration["srcIn"]
             percentI = kate.configuration["srcOut"].find("%i")
             if len(transformationKey) and (percentI > -1):
                 #
                 # A transformation of the file name is with the output
                 # using the %i placeholder. Ensure the idFile is usable for
                 # that purpose.
                 #
                 insertLeft, discard = kate.configuration["idFile"].split(transformationKey, 1)
             transformOK = True
         except ValueError as detail:
             # xgettext: no-python-format
             KMessageBox.error(
                 self.parent(),
                 i18n("'%1' does not contain '%2'", kate.configuration["idFile"], transformationKey),
                 i18n("Cannot use %i"),
             )
     return fileSet and transformOK
Exemple #18
0
def findMenu(menu_parent_slug):
    window = kate.mainWindow()
    for menu in window.findChildren(QtGui.QMenu):
        if str(menu.objectName()) == menu_parent_slug:
            return menu
    return None
Exemple #19
0
def showConsole():
    # Make all our config is initialised.
    ConfigWidget().apply()
    parent = kate.mainWindow()
    dialog = KateConsoleDialog(parent)
    dialog.show()
Exemple #20
0
def findMenu(menu_parent_slug):
    window = kate.mainWindow()
    for menu in window.findChildren(QtGui.QMenu):
        if menu.objectName() == menu_parent_slug:
            return menu
    return None
Exemple #21
0
def showConsole():
    # Make all our config is initialised.
    ConfigWidget().apply()
    parent = kate.mainWindow()
    dialog = KateConsoleDialog(parent)
    dialog.show()
def fuzzyOpen():
    global dialog
    if dialog is None:
        dialog = FuzzyOpen(kate.mainWindow())
    dialog.open()
Exemple #23
0
def showConsole():
    parent = kate.mainWindow()
    dialog = KateConsoleDialog(parent)
    dialog.show()