Exemple #1
0
def addDockAction(actionName, actionText, iconPath, append=False):
    """
    Get a dock action in the right-hand action toolbar. If it does not exist, it will be created

    :param actionName: The name of the action, the objectName field of the QAction
    :param actionText: The text shown on mouseover of the action and also when viewing the right-click menu
    :param iconPath: The path to the icon to display for this action
    :param append: If true, put this action at the bottom of the toolbar rather than at the top
    :return: The QAction added to the dock, or the existing action if it was already there
    """

    action = getToolBarActions().get(actionName)

    if action is None:
        assert os.path.isfile(iconPath)

        action = QtGui.QAction(QtGui.QIcon(iconPath), actionText, None)
        action.objectName = actionName
        action.checkable = True

        toolbar = getMainWindow().panelToolBar()

        if append:
            toolbar.addAction(action)
        else:
            toolbar.insertAction(toolbar.actions()[0], action)

    return action
Exemple #2
0
    def __init__(self, mainWindowApp):

        self.app = mainWindowApp
        self.rootFolderName = "data files"

        self.openAction = QtGui.QAction("&Open Data...", self.app.fileMenu)
        self.app.fileMenu.insertAction(self.app.quitAction, self.openAction)
        self.app.fileMenu.insertSeparator(self.app.quitAction)
        self.openAction.setShortcut(QtGui.QKeySequence("Ctrl+O"))
        self.openAction.connect("triggered()", self.onOpenDataFile)
    def __init__(self):
        super(dlg_exportFontsInFolder, self).__init__()
        self.export = ExportFontsInFolder()

        menu = QtGui.QMenu('MyMenu')
        myact = QtGui.QAction('MyAction', self)
        menu.addAction(myact)

        menubar = main.menuBar()
        menubar.addAction(myact)

        layoutV = QtGui.QVBoxLayout()

        # Source folder
        self.lay_src = QtGui.QHBoxLayout()
        self.lbl_src = QtGui.QLabel('Source folder:')
        self.lbl_src.setFixedWidth(120)
        self.lay_src.addWidget(self.lbl_src)
        self.edt_srcFolder = QtGui.QLineEdit()
        self.edt_srcFolder.setText(self.export.srcFolder)
        self.edt_srcFolder.setToolTip(
            '<p>Finds fonts to be converted in this <b>Source folder</b>. Defaults to the same folder as the currently active font. Click ... to choose a different folder.</p>'
        )
        self.lay_src.addWidget(self.edt_srcFolder)
        self.btn_pickSrcFolder = QtGui.QPushButton('...')
        self.btn_pickSrcFolder.setToolTip(
            '<p>Click to choose a different <b>Source folder</b></p>')
        self.btn_pickSrcFolder.clicked.connect(self.pickSrcFolder)
        self.lay_src.addWidget(self.btn_pickSrcFolder)
        layoutV.addLayout(self.lay_src)

        # Filtering
        self.lay_types = QtGui.QHBoxLayout()
        self.lbl_types = QtGui.QLabel('File types:')
        self.lbl_types.setFixedWidth(120)
        self.lay_types.addWidget(self.lbl_types)
        self.edt_types = QtGui.QLineEdit()
        self.edt_types.setText(" ".join(self.export.fontTypes))
        self.edt_types.setToolTip(
            '<p>Finds fonts to be converted that match these space-separated <b>patterns</b> (case-insensitive).</p>'
        )
        self.lay_types.addWidget(self.edt_types)
        self.chk_subfolders = QtGui.QCheckBox('Subfolders')
        self.chk_subfolders.setCheckState(QtCore.Qt.Unchecked)
        self.chk_subfolders.setToolTip(
            '<p>If <b>on</b>, finds fonts to be converted in the Source folder <b>recursively</b> (including subfolders).</p>'
        )
        self.lay_types.addWidget(self.chk_subfolders)
        layoutV.addLayout(self.lay_types)

        # Destination folder
        self.lay_dest = QtGui.QHBoxLayout()
        self.lbl_dest = QtGui.QLabel('Destination folder:')
        self.lbl_dest.setFixedWidth(120)
        self.lay_dest.addWidget(self.lbl_dest)
        self.edt_destFolder = QtGui.QLineEdit()
        self.edt_destFolder.setText(self.export.destFolder)
        self.edt_destFolder.setToolTip(
            '<p>Exports fonts into this folder. Recreates the Source folder <b>structure</b>. If a font exports as a single file, uses the original filename as the new filename. If a font exports as multiple files, uses the original filename as a subfolder name. Click ... to choose a different folder.</p>'
        )
        self.lay_dest.addWidget(self.edt_destFolder)
        self.btn_pickDestFolder = QtGui.QPushButton('...')
        self.btn_pickDestFolder.setToolTip(
            '<p>Click to choose a different <b>Destination folder</b></p>')
        self.btn_pickDestFolder.clicked.connect(self.pickDestFolder)
        self.lay_dest.addWidget(self.btn_pickDestFolder)
        layoutV.addLayout(self.lay_dest)

        # Run layout
        self.lay_run = QtGui.QHBoxLayout()
        self.lbl_format = QtGui.QLabel(
            '<small>Hold your pointer over the UI items for instructions</small>'
        )
        self.lbl_format.setStyleSheet('color:darkGray;')
        self.lay_run.addWidget(self.lbl_format)
        self.lay_run.addStretch()
        self.btn_cancel = QtGui.QPushButton('&Cancel')
        self.btn_cancel.clicked.connect(self.cancel)
        self.lay_run.addWidget(self.btn_cancel)
        self.btn_run = QtGui.QPushButton('&Export Fonts As')
        self.btn_run.setDefault(True)
        self.btn_run.setFocus()
        self.btn_run.clicked.connect(self.run)
        self.btn_run.setToolTip(
            '<p>Click this button. In the <i>Export Font</i> dialog, choose <b>Content</b>, choose/customize the <b>Profile</b>, but <b>do not change</b> the <b>Destination</b> settings there. Then click <b>Export</b> to start the conversion.</p>'
        )
        self.lay_run.addWidget(self.btn_run)
        layoutV.addLayout(self.lay_run)

        # - Set Widget
        self.setLayout(layoutV)
        self.setWindowTitle('%s %s' % (app_name, __version__))
        self.setGeometry(300, 300, 640, 200)
        self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)  # Always on top!!
        self.show()