Exemplo n.º 1
0
    def addDocumentTree(self, docid, name, parent, meta={}):
        if parent:
            # TODO: find parent in tree
            parent = self.treeFindDocument(parent)
        else:
            parent = self.tree.invisibleRootItem()

        tags = meta.get('tags') or ""
        tags = [t.strip() for t in tags.split(",") if t]

        columns = [None] * TREE_COLUMN_COUNT
        columns[TREE_COLUMN_NAME] = name
        columns[TREE_COLUMN_UID] = docid

        item = Qt.QTreeWidgetItem(parent, columns)
        # item.setFirstColumnSpanned(True)
        item.setText(TREE_COLUMN_NAME, name)
        item.setText(TREE_COLUMN_UID, docid)
        item.setText(TREE_COLUMN_TAGS, "")
        item.setIcon(TREE_COLUMN_NAME, getIcon("icon-document-default"))
        item.setExpanded(True)
        item.setFlags(TREE_ITEM_FLAGS)

        self.tagDocuemntTree(treeitem=item, addtags=tags)

        self.tree.resizeColumnToContents(TREE_COLUMN_NAME)
        self.tree.resizeColumnToContents(TREE_COLUMN_ICON)
        return item
Exemplo n.º 2
0
    def buildToolbar(self):

        # TODO: remove static code, move to dynamic build of toolbars and menus
        self.toolbar.add(
            [dict(name='Save', icon=getIcon('document-save'), shortcut='CTRL+S', callback=self.on_toolbar_save),
             dict(name='Save all', icon=getIcon('document-save-all'), shortcut=None,
                  callback=self.on_toolbar_saveall),
             dict(name='Add new Project', icon='project-add', shortcut=None, callback=self.on_toolbar_project_add),
             dict(name='Add document', icon='document-add', shortcut='CTRL+SHIFT++',
                  callback=self.on_toolbar_document_add),
             ])

        for p in self.plugins:
            try:
                p.buildToolbarApplication(self.toolbar)
            except Exception as e:
                self.log.error("buildToolbar(): %s: %s", e.__class__.__name__, e)
Exemplo n.º 3
0
    def buildToolbarLocal(self):
        self.fontselection = Qt.QFontComboBox(self.toolbar)
        self.fontselection.currentFontChanged.connect(self.on_fontselection_change)

        self.fontsizeselection = Qt.QSpinBox(self.toolbar)
        self.fontsizeselection.setMinimum(4)
        self.fontsizeselection.setMaximum(32)
        self.fontsizeselection.setValue(14)
        self.fontsizeselection.valueChanged.connect(self.on_fontsizeselection_change)

        self.toolbar.addWidget(self.fontselection)
        self.toolbar.addWidget(self.fontsizeselection)
        self.toolbar.addButtonObjectAction(self, "format-justify-left", getIcon('format-justify-left'))
        self.toolbar.addButtonObjectAction(self, "format-justify-center", getIcon('format-justify-center'))
        self.toolbar.addButtonObjectAction(self, "format-justify-right", getIcon('format-justify-right'))

        self.toolbar.addSeparator()
        self.toolbar.addButtonObjectAction(self, 'insert-image', getIcon('image-insert'), desc='Insert image',
                                           shortcut='CTRL+SHIFT+I')
Exemplo n.º 4
0
    def _add(self, name, icon, shortcut, callback):
        if icon.__class__.__name__ != "QIcon":
            _icon = getIcon(icon)
        else:
            _icon = icon

        a = Qt.QAction(_icon, name, self.win())
        a.triggered.connect(callback)
        if shortcut:
            a.setShortcut(shortcut)
        self.addAction(a)
Exemplo n.º 5
0
    def _addElement(self, _type, name):
        if not _type:
            return None

        parent = self._findElement(_type) or self.elementsroot
        if not parent:
            return None

        item = Qt.QTreeWidgetItem(parent, [
            name,
            "something",
        ])
        item.setIcon(0, getIcon("attachment"))
Exemplo n.º 6
0
    def buildToolbar(self):
        self.toolbar = Toolbar(self)

        self.toolbar.addButtonObjectAction(self,
                                           "save",
                                           getIcon('document-save'),
                                           desc="Save")
        self.toolbar.addButtonObjectAction(
            self,
            "drop-draft",
            getIcon('document-drop-draft'),
            desc="Drop draft, restore saved document")
        if self.can_print:
            self.toolbar.addButtonObjectAction(self,
                                               "export-to-pdf",
                                               getIcon('pdf'),
                                               desc="Export to pdf")
        self.buildToolbarLocal()

        win = self.win()
        if not win:
            return

        win.buildToolbarEditor(self, self.toolbar)
Exemplo n.º 7
0
    def __init__(self):
        super(AppleTreeMainWindow, self).__init__()
        self.setWindowIcon(getIcon('app'))
        self.log = logging.getLogger("at")
        self.projects = Projects()
        self.setWindowTitle("AppleTree (Qt " + Qt.QT_VERSION_STR + ")")

        self.menubar = Qt.QMenuBar()
        self.toolbar = Toolbar(self)

        self.menuprojects = self.menubar.addMenu("Projects")
        self.menuproject = self.menubar.addMenu("Project")
        self.menuplugins = self.menubar.addMenu("Plugins")

        self.plugins = ATPlugins(self)
        self.plugins.discovery()

        self.projects = Projects()
        self.projectsViews = dict()

        self.buildMenuProject()
        self.buildToolbar()

        self.setGeometry(50, 50, 1440, 800)
        box = Qt.QVBoxLayout()
        centralwidget = Qt.QWidget()
        centralwidget.setLayout(box)

        self.tabs = Qt.QTabWidget()
        self.tabs.setTabsClosable(True)
        self.tabs.tabCloseRequested.connect(self.on_tab_close_req)
        # tabs.currentChanged.connect(self.on_tab_current_changed)

        box.addWidget(self.toolbar)
        box.addWidget(self.tabs)

        self.setCentralWidget(centralwidget)
        self.setMenuBar(self.menubar)

        self.plugins.initialize()
        self.ready = True
        self.treeready = False

        self.load()
Exemplo n.º 8
0
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.
#
# __author__ = 'Jakub Kolasa <*****@*****.**'>
#

import logging
import signal
import sys

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)

    print("Loading appletree.qui.qt")
    from appletree.gui.qt import initFonts, initQtApplication
    APP = initQtApplication()
    print("Loading appletree.helpers")
    from appletree.helpers import getIcon
    print("Loading appletree.application")
    from appletree.application import App

    APP.setApplicationName("AppleTree")
    APP.setWindowIcon(getIcon('app'))
    initFonts()
    app = App()
    app.show()
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    sys.exit(APP.exec_())