Example #1
0
def start():
    appName = Config.appname
    catalog = Config.catalog
    programName = ki18n(Config.readable_appname)
    version = Config.version
    description = ki18n("A tablet annotation and journaling application.")
    license = KAboutData.License_BSD
    copyright = ki18n("(C) 2009 Dominik Schacht")
    text = ki18n("Whee, greetings.")
    homepage = Config.homepage
    bugemail = "*****@*****.**"

    aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homepage, bugemail)

    KCmdLineArgs.init(sys.argv, aboutData)
    KCmdLineArgs.addCmdLineOptions(Config.get_param_options())

    app = KApplication()

    Config.init_config() # Init after the KApplication has been created.

    mw = MainWindow()
    mw.show()

    result = app.exec_()

    return result
Example #2
0
 def setSizeF(self, sizef):
     BackgroundImage.setSizeF(self, sizef)
     if self.sizeF() is not None:
         group = Config.get_group("backgrounds")
         #TODO: might want to refactor this to a getFloat() of some sort.
         self.cols = int(math.floor(self.sizeF().width() / group.readEntry("checked_size", 17).toDouble()[0])) #TODO: move to config
         self.rows = int(math.floor(self.sizeF().height() / group.readEntry("checked_size", 17).toDouble()[0]))
Example #3
0
    def __init__(self, source_file=None, parent=None):
        """
        Create a new PynalDocument for the given file.

        Parameters:
        source_file -- String path to the pdf that is to be displayed.
        parent      -- the parent widget of this widget.
        """
        QtGui.QGraphicsView.__init__(self, parent)
        self.max_width = -1
        self.setCursor(tools.current_tool.cursor)

        self.configure_scene()

        # Set the default zoom level to 1.0
        self.scale_level = 1

        self.pages = []
        
        self.undoStack = QtGui.QUndoStack(self)


        if Config.get_group("rendering").readEntry("use_opengl", False).toBool():
            self.setViewport(QtOpenGL.QGLWidget())


        if source_file is not None:
            self.document = QtPoppler.Poppler.Document.load(source_file)
            self.document.setRenderHint(QtPoppler.Poppler.Document.Antialiasing and
                                        QtPoppler.Poppler.Document.TextAntialiasing)

            # This might want to be moved into an own thread
            # (when numPages is over a certain threshold?)
            for page_number in range(0, self.document.numPages()):
                self.insert_new_page_at(page_number,
                    Backgrounds.pdf_page(self.document.page(page_number)))

                # Note that the pdf pages are not rendered
                # now. That happens when the page is to be
                # displayed / cached for displaying.

        else:
            self.insert_new_page_at(0) # Add an empty page.

        self.undo_stack = kdeui.KUndoStack(self)

        self.removed_pages = []

        # Toolbar
        toolbar = QtGui.QToolBar()

        # Actions
        self.actionAdd = toolbar.addAction("New", self.refresh_viewport_size)
        self.actionEdit = toolbar.addAction("Edit", self.refresh_viewport_size)
        self.actionDelete = toolbar.addAction("Delete", self.refresh_viewport_size)
        
        self.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
        self.connect(self, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menu)

        # Popup Menu
        self.popMenu = QtGui.QMenu(self)
        self.popMenu.addAction( self.actionEdit )
        self.popMenu.addAction( self.actionDelete )
        self.popMenu.addSeparator()
        self.popMenu.addAction( self.actionAdd )
        
        self.cache = PynalCache()