def initMenu(self):
        # ugh, we gotta get a KActionCollection instance somehow
        action_collection = kate.sip.cast(kate.mainWidget().topLevelWidget(), KMainWindow).actionCollection()

        # because our KPopupMenu has no parent, we have to keep it from going out of scope
        self.menu = KPopupMenu()

        # Open
        action = KAction("&Open...", "fileopen", KShortcut("Ctrl+Shift+O"), self.menuOpen, action_collection)
        action.plug(self.menu)

        # Close
        action = KAction("&Close", "fileclose", KShortcut.null(), self.menuClose, action_collection)
        action.plug(self.menu)

        # Reload
        action = KAction("&Reload", "reload", KShortcut("Shift+F5"), self.menuReload, action_collection)
        action.plug(self.menu)

        self.menu.insertSeparator()

        # Find Files
        action = KAction("&Find Files...", "find", KShortcut("Ctrl+H"), self.menuFindFiles, action_collection)
        action.plug(self.menu)

        self.menu.insertSeparator()

        # Settings
        action = KAction("&Settings...", "configure", KShortcut.null(), self.menuSettings, action_collection)
        action.plug(self.menu)

        # insert the menu into the menu bar
        menu_bar = kate.mainWidget().topLevelWidget().menuBar()
        menu_bar.insertItem("&Project", self.menu, -1, 4)
    def accept(self):

        # get the old filter and ignore settings
        old_filter = str(QString(self.dp.get_option("filter")).simplifyWhiteSpace())
        old_ignore = ",".join([x.strip() for x in self.dp.get_option("ignore").split(",")])

        # dialog size
        self.dp.config.set("general", "config_size", "%dx%d" % (self.width(), self.height()))

        # search type
        self.dp.config.set("general", "search_type", DPSettings.SEARCH_TYPES[self.w_search_type.currentItem()])

        # filters
        new_filter = str(self.w_filters.text().simplifyWhiteSpace())
        self.dp.set_option("filter", new_filter)

        # ignore
        new_ignore = ",".join([str(s).strip() for s in self.w_ignore.items()])
        self.dp.set_option("ignore", new_ignore)

        # save the config
        self.dp.saveConfig()

        # this should close the settings dialog
        QDialog.accept(self)

        # if they changed any settings offer to reload the project
        if old_ignore != new_ignore or old_filter != new_filter:
            result = KMessageBox.questionYesNo(
                kate.mainWidget(),
                "Project settings have changed, would you like to reload the project?",
                "Reload Project?",
            )
            if result == KMessageBox.Yes:
                self.dp.reload()
    def __init__(self, parent=None):
        KDialog.__init__(self, kate.mainWidget())

        self.dp = parent

        FindFilesDlgLayout = QVBoxLayout(self, 11, 6, "FindFilesDlgLayout")

        self.list_view = KListView(self)
        self.list_view.addColumn(QString.null)
        self.list_view.header().hide()

        self.lv_search = ListViewSearchLineWidget(self.list_view, self)

        FindFilesDlgLayout.addWidget(self.lv_search)
        FindFilesDlgLayout.addWidget(self.list_view)

        self.setSizeGripEnabled(True)
Esempio n. 4
0
 def undock(self):
     """
     Undocks the widget and place it in a QDialog
     """
     if not self.dialog:
         parent = None
         if config("preferences")["keep undocked on top"] != '0':
             parent = kate.mainWidget()
         d = DockDialog(self, parent)
         d.setCaption("%s - %s" % (self.title, PROGRAMNAME))
         if self.dialogSize:
             d.resize(*self.dialogSize)
         if self.dialogPos:
             d.move(*self.dialogPos)
         QVBoxLayout(d).setAutoAdd(True)
         self.widget.reparent(d, QPoint(0, 0))
         if not self.focus:
             self.widget.setFocusPolicy(QWidget.WheelFocus)
         self.dialog = d
         if self.tool:
             sip.delete(self.tool.widget)
             self.tool = None
         self.show()
    def __init__(self, dp):
        DPSettingsBase.__init__(self, kate.mainWidget(), None, 1, 0)

        # save an instance of our DirectoryProject
        self.dp = dp
 def menuReload(self):
     kate.debug("menuReload()")
     if self.open_project:
         self.reload()
     else:
         KMessageBox.information(kate.mainWidget(), "There is no project open to reload.", "No Project Open")
 def menuFindFiles(self):
     kate.debug("menuFindFiles()")
     if not self.open_project:
         KMessageBox.information(kate.mainWidget(), "Open a project first.", "No Project Open")
     else:
         self.finder.show()
Esempio n. 8
0
def focus():
    """Give keyboard focus to the text editor widget."""
    kate.mainWidget().setFocus()
Esempio n. 9
0
def mainWidget():
    """The main text editing widget."""
    return kate.mainWidget()
Esempio n. 10
0
def topLevelWidget():
    """The toplevel window of the editing widget."""
    return kate.mainWidget().topLevelWidget()
Esempio n. 11
0
 def warncontinue(message):
     return KMessageBox.warningContinueCancel(
         kate.mainWidget(), message) == KMessageBox.Continue
Esempio n. 12
0
 def _popup(message, timeout=5, **a):
     a.setdefault('parent', kate.mainWidget().topLevelWidget())
     kate.gui.showPassivePopup(message, timeout, **a)