Exemplo n.º 1
0
def add_more_tool_bar():
    """
    Add a tool bar at the bottom.

    This provieds colorful command buttons for the functions usually
    hidden in the "More" button at the bottom.
    """
    try:
        mw.reviewer.more_tool_bar = QToolBar()
    except AttributeError:
        return
    # mw.reviewer.more_tool_bar.setAccessibleName('secondary tool bar')
    mw.reviewer.more_tool_bar.setObjectName('more options tool bar')
    mw.reviewer.more_tool_bar.setIconSize(QSize(24, 24))
    if netbook_version:
        mw.reviewer.more_tool_bar.setFloatable(True)
        mw.reviewer.more_tool_bar.setMovable(True)
        mw.addToolBar(Qt.RightToolBarArea, mw.reviewer.more_tool_bar)
    else:
        mw.reviewer.more_tool_bar.setFloatable(False)
        mw.reviewer.more_tool_bar.setMovable(False)
        mw.mainLayout.insertWidget(2, mw.reviewer.more_tool_bar)
    if do_gradient:
        palette = mw.reviewer.more_tool_bar.palette()
        fg = palette.color(QPalette.ButtonText)
        bg = palette.color(QPalette.Button)
        if bg.lightnessF() > fg.lightnessF():
            bgg = bg.darker(108)
            bgl = bg.darker()
        else:
            bgg = bg.lighter(105)
            bgl = bg.lighter()
        mw.reviewer.more_tool_bar.setStyleSheet(
            toolbar_gradient_form.format(bg=bg.name(),
                                         bgg=bgg.name(),
                                         bgl=bgl.name()))
    # Add the actions here
    mw.reviewer.more_tool_bar.addAction(edit_current_action)
    mw.reviewer.more_tool_bar.addAction(toggle_mark_action)
    if show_toggle_last:
        mw.reviewer.more_tool_bar.addAction(toggle_last_card_action)
    if show_mute_button:
        mw.reviewer.more_tool_bar.addAction(mute_action)
    mw.reviewer.more_tool_bar.addAction(bury_action)
    if show_suspend_card:
        mw.reviewer.more_tool_bar.addAction(suspend_card_action)
    if show_suspend_note:
        mw.reviewer.more_tool_bar.addAction(suspend_note_action)
    mw.reviewer.more_tool_bar.addAction(delete_action)
    mw.reviewer.more_tool_bar.addSeparator()
    mw.reviewer.more_tool_bar.addAction(options_action)
    mw.reviewer.more_tool_bar.addSeparator()
    mw.reviewer.more_tool_bar.addAction(replay_action)
    mw.reviewer.more_tool_bar.addAction(record_own_action)
    mw.reviewer.more_tool_bar.addAction(replay_own_action)
    more_tool_bar_off()
Exemplo n.º 2
0
def add_more_tool_bar():
    """
    Add a tool bar at the bottom.

    This provieds colorful command buttons for the functions usually
    hidden in the "More" button at the bottom.
    """
    try:
        mw.reviewer.more_tool_bar = QToolBar()
    except AttributeError:
        return
    # mw.reviewer.more_tool_bar.setAccessibleName('secondary tool bar')
    mw.reviewer.more_tool_bar.setObjectName('more options tool bar')
    mw.reviewer.more_tool_bar.setIconSize(QSize(24, 24))
    if netbook_version:
        mw.reviewer.more_tool_bar.setFloatable(True)
        mw.reviewer.more_tool_bar.setMovable(True)
        mw.addToolBar(Qt.RightToolBarArea, mw.reviewer.more_tool_bar)
    else:
        mw.reviewer.more_tool_bar.setFloatable(False)
        mw.reviewer.more_tool_bar.setMovable(False)
        mw.mainLayout.insertWidget(2, mw.reviewer.more_tool_bar)
    if do_gradient:
        palette = mw.reviewer.more_tool_bar.palette()
        fg = palette.color(QPalette.ButtonText)
        bg = palette.color(QPalette.Button)
        if bg.lightnessF() > fg.lightnessF():
            bgg = bg.darker(108)
            bgl = bg.darker()
        else:
            bgg = bg.lighter(105)
            bgl = bg.lighter()
        mw.reviewer.more_tool_bar.setStyleSheet(
            toolbar_gradient_form.format(
                bg=bg.name(), bgg=bgg.name(), bgl=bgl.name()))
    # Add the actions here
    mw.reviewer.more_tool_bar.addAction(edit_current_action)
    mw.reviewer.more_tool_bar.addAction(toggle_mark_action)
    if show_toggle_last:
        mw.reviewer.more_tool_bar.addAction(toggle_last_card_action)
    if show_mute_button:
        mw.reviewer.more_tool_bar.addAction(mute_action)
    mw.reviewer.more_tool_bar.addAction(bury_action)
    if show_suspend_card:
        mw.reviewer.more_tool_bar.addAction(suspend_card_action)
    if show_suspend_note:
        mw.reviewer.more_tool_bar.addAction(suspend_note_action)
    mw.reviewer.more_tool_bar.addAction(delete_action)
    mw.reviewer.more_tool_bar.addSeparator()
    mw.reviewer.more_tool_bar.addAction(options_action)
    mw.reviewer.more_tool_bar.addSeparator()
    mw.reviewer.more_tool_bar.addAction(replay_action)
    mw.reviewer.more_tool_bar.addAction(record_own_action)
    mw.reviewer.more_tool_bar.addAction(replay_own_action)
    more_tool_bar_off()
Exemplo n.º 3
0
def add_tool_bar():
    """
    Add a Qt tool bar to Anki2.

    This is a more Anki-1-ish Qt tool bar with a number of rather big,
    colorful icons to replace the Anki 2 DSAB toolbar.
    """
    mw.qt_tool_bar = QToolBar()
    # mw.qt_tool_bar.setAccessibleName('secondary tool bar')
    mw.qt_tool_bar.setObjectName('qt tool bar')
    if netbook_version:
        mw.qt_tool_bar.setIconSize(QSize(24, 24))
    else:
        mw.qt_tool_bar.setIconSize(QSize(32, 32))
    # Conditional setup
    if netbook_version or qt_toolbar_movable:
        mw.qt_tool_bar.setFloatable(True)
        mw.qt_tool_bar.setMovable(True)
        if netbook_version:
            mw.addToolBar(Qt.LeftToolBarArea, mw.qt_tool_bar)
        else:
            mw.addToolBar(Qt.TopToolBarArea, mw.qt_tool_bar)
    else:
        mw.qt_tool_bar.setFloatable(False)
        mw.qt_tool_bar.setMovable(False)
        mw.mainLayout.insertWidget(1, mw.qt_tool_bar)
    if do_gradient:
        palette = mw.qt_tool_bar.palette()
        fg = palette.color(QPalette.ButtonText)
        bg = palette.color(QPalette.Button)
        if bg.lightnessF() > fg.lightnessF():
            bgg = bg.darker(108)
            bgl = bg.darker()
        else:
            bgg = bg.lighter(120)
            bgl = bg.lighter()
        mw.qt_tool_bar.setStyleSheet(
            toolbar_gradient_form.format(bg=bg.name(),
                                         bgg=bgg.name(),
                                         bgl=bgl.name()))
    # Add the actions here
    mw.qt_tool_bar.addAction(sync_action)
    # Put this in the more tool bar, closer to the old edit button
    #    mw.qt_tool_bar.addAction(edit_current_action)
    mw.qt_tool_bar.addAction(decks_action)
    mw.qt_tool_bar.addAction(overview_action)
    # Keep in line with the old tool bar. Don't show in standard version.
    # mw.qt_tool_bar.addAction(study_action)
    mw.qt_tool_bar.addAction(add_notes_action)
    mw.qt_tool_bar.addAction(browse_cards_action)
    mw.qt_tool_bar.addAction(statistics_action)
Exemplo n.º 4
0
def add_tool_bar():
    """
    Add a Qt tool bar to Anki2.

    This is a more Anki-1-ish Qt tool bar with a number of rather big,
    colorful icons to replace the Anki 2 DSAB toolbar.
    """
    mw.qt_tool_bar = QToolBar()
    # mw.qt_tool_bar.setAccessibleName('secondary tool bar')
    mw.qt_tool_bar.setObjectName('qt tool bar')
    if netbook_version:
        mw.qt_tool_bar.setIconSize(QSize(24, 24))
    else:
        mw.qt_tool_bar.setIconSize(QSize(32, 32))
    # Conditional setup
    if netbook_version or qt_toolbar_movable:
        mw.qt_tool_bar.setFloatable(True)
        mw.qt_tool_bar.setMovable(True)
        if netbook_version:
            mw.addToolBar(Qt.LeftToolBarArea, mw.qt_tool_bar)
        else:
            mw.addToolBar(Qt.TopToolBarArea, mw.qt_tool_bar)
    else:
        mw.qt_tool_bar.setFloatable(False)
        mw.qt_tool_bar.setMovable(False)
        mw.mainLayout.insertWidget(1, mw.qt_tool_bar)
    if do_gradient:
        palette = mw.qt_tool_bar.palette()
        fg = palette.color(QPalette.ButtonText)
        bg = palette.color(QPalette.Button)
        if bg.lightnessF() > fg.lightnessF():
            bgg = bg.darker(108)
            bgl = bg.darker()
        else:
            bgg = bg.lighter(120)
            bgl = bg.lighter()
        mw.qt_tool_bar.setStyleSheet(
            toolbar_gradient_form.format(
                bg=bg.name(), bgg=bgg.name(), bgl=bgl.name()))
    # Add the actions here
    mw.qt_tool_bar.addAction(sync_action)
    # Put this in the more tool bar, closer to the old edit button
    #    mw.qt_tool_bar.addAction(edit_current_action)
    mw.qt_tool_bar.addAction(decks_action)
    mw.qt_tool_bar.addAction(overview_action)
    # Keep in line with the old tool bar. Don't show in standard version.
    # mw.qt_tool_bar.addAction(study_action)
    mw.qt_tool_bar.addAction(add_notes_action)
    mw.qt_tool_bar.addAction(browse_cards_action)
    mw.qt_tool_bar.addAction(statistics_action)
Exemplo n.º 5
0
def add_tool_bar():
    """
    Add a Qt tool bar to Anki2.

    This is a more Anki-1-ish Qt tool bar with a number of rather big,
    colorful icons to replace the Anki 2 DSAB toolbar.
    """
    mw.qt_tool_bar = QToolBar()
    # mw.qt_tool_bar.setAccessibleName('secondary tool bar')
    mw.qt_tool_bar.setObjectName('qt tool bar')
    mw.qt_tool_bar.setIconSize(QSize(32, 32))
    mw.qt_tool_bar.setStyleSheet(
        '''QToolBar{
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #fff, stop:1 #ddd);
border: none;
border-bottom: 1px solid #aaa;
}
''')
    # Conditional setup
    if qt_toolbar_movable:
        mw.qt_tool_bar.setFloatable(True)
        mw.qt_tool_bar.setMovable(True)
        mw.addToolBar(mw.qt_tool_bar)
    else:
        mw.qt_tool_bar.setFloatable(False)
        mw.qt_tool_bar.setMovable(False)
        mw.mainLayout.insertWidget(1, mw.qt_tool_bar)
    # Add the actions here
    mw.qt_tool_bar.addAction(sync_action)
    # Put this in the more tool bar, closer to the old edit button
    #    mw.qt_tool_bar.addAction(edit_current_action)
    mw.qt_tool_bar.addAction(decks_action)
    mw.qt_tool_bar.addAction(overview_action)
    # Keep in line with the old tool bar. Don't show in standard version.
    # mw.qt_tool_bar.addAction(study_action)
    mw.qt_tool_bar.addAction(add_notes_action)
    mw.qt_tool_bar.addAction(browse_cards_action)
    mw.qt_tool_bar.addAction(statistics_action)
Exemplo n.º 6
0
def add_tool_bar():
    """
    Add a Qt tool bar to Anki2.

    This is a more Anki-1-ish Qt tool bar with a number of rather big,
    colorful icons to replace the Anki 2 DSAB toolbar.
    """
    mw.qt_tool_bar = QToolBar()
    # mw.qt_tool_bar.setAccessibleName('secondary tool bar')
    mw.qt_tool_bar.setObjectName('qt tool bar')
    mw.qt_tool_bar.setIconSize(QSize(32, 32))
    mw.qt_tool_bar.setStyleSheet(
        '''QToolBar{
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #fff, stop:1 #ddd);
border: none;
border-bottom: 1px solid #aaa;
}
''')
    # Conditional setup
    if qt_toolbar_movable:
        mw.qt_tool_bar.setFloatable(True)
        mw.qt_tool_bar.setMovable(True)
        mw.addToolBar(mw.qt_tool_bar)
    else:
        mw.qt_tool_bar.setFloatable(False)
        mw.qt_tool_bar.setMovable(False)
        mw.mainLayout.insertWidget(1, mw.qt_tool_bar)
    # Add the actions here
    mw.qt_tool_bar.addAction(sync_action)
    # Put this in the more tool bar, closer to the old edit button
    #    mw.qt_tool_bar.addAction(edit_current_action)
    mw.qt_tool_bar.addAction(decks_action)
    mw.qt_tool_bar.addAction(overview_action)
    # Keep in line with the old tool bar. Don't show in standard version.
    # mw.qt_tool_bar.addAction(study_action)
    mw.qt_tool_bar.addAction(add_notes_action)
    mw.qt_tool_bar.addAction(browse_cards_action)
    mw.qt_tool_bar.addAction(statistics_action)

    F3_action = QAction(mw)
    F3_action.setText(_(u"Front"))
    F3_action.setIcon(QIcon(os.path.join(icons_dir, 'F3.png')))
    F3_action.setToolTip(_(u"Front"))
    mw.connect(F3_action, SIGNAL("triggered()"), actionF3)
    mw.qt_tool_bar.addAction(F3_action)

    F4_action = QAction(mw)
    F4_action.setText(_(u"Definition"))
    F4_action.setIcon(QIcon(os.path.join(icons_dir, 'F4.png')))
    F4_action.setToolTip(_(u"Definition"))
    mw.connect(F4_action, SIGNAL("triggered()"), actionF4)
    mw.qt_tool_bar.addAction(F4_action)	
	
    F5_action = QAction(mw)
    F5_action.setText(_(u"Example"))
    F5_action.setIcon(QIcon(os.path.join(icons_dir, 'F5.png')))
    F5_action.setToolTip(_(u"Example"))
    mw.connect(F5_action, SIGNAL("triggered()"), actionF5)
    mw.qt_tool_bar.addAction(F5_action)		

    
    stop_action.setText(_(u"Stop"))
    stop_action.setIcon(QIcon(os.path.join(icons_dir, 'stop.png')))
    stop_action.setShortcut(QKeySequence(Qt.Key_Escape))	
    stop_action.setToolTip(_(u"Stop  Esc"))
    mw.connect(stop_action, SIGNAL("triggered()"), stopProccess)
    mw.qt_tool_bar.addAction(stop_action)


#    Say_action = QAction(mw)
    Say_action.setText(_(u"Say Example"))
    Say_action.setIcon(QIcon(os.path.join(icons_dir, 'Say.png')))
    Say_action.setToolTip(_(u"Say Example  R"))
    Say_action.setShortcut(QKeySequence(Qt.Key_R))
    mw.connect(Say_action, SIGNAL("triggered()"), actionExample)
    mw.qt_tool_bar.addAction(Say_action)			
	
    Def_action = QAction(mw)
    #Def_action.setText(_(u"Definition"))
    #Def_action.setIcon(QIcon(os.path.join(icons_dir, 'dictionary.png')))
    Def_action.setToolTip(_(u"Definition"))
    #mw.connect(Def_action, SIGNAL("triggered()"), actionDef)
    mw.qt_tool_bar.addAction(Def_action)		
	
    Rep_action = QAction(mw)
    Rep_action.setText(_(u"Repeat"))
    Rep_action.setIcon(QIcon(os.path.join(icons_dir, 'Rep.png')))
    Rep_action.setToolTip(_(u"Repeat"))
    mw.connect(Rep_action, SIGNAL("triggered()"), actionRepeat)
    mw.qt_tool_bar.addAction(Rep_action)	   

    
    Show_action.setText(_(u"Show"))
    Show_action.setIconText(_(u"Show"))
    Show_action.setShortcut(QKeySequence(Qt.Key_U))
    Show_action.setIcon(QIcon(os.path.join(icons_dir, 'lightbulb.png')))
    Show_action.setToolTip(_(u"Show  U"))
    mw.connect(Show_action, SIGNAL("triggered()"), showHidden)
    mw.qt_tool_bar.addAction(Show_action)	

    Ru_action = QAction(mw)
    Ru_action.setText(_(u"Russian"))
    Ru_action.setShortcut(QKeySequence(Qt.Key_T))
    Ru_action.setIcon(QIcon(os.path.join(icons_dir, 'Ru.png')))
    Ru_action.setToolTip(_(u"Russian  T"))
    mw.connect(Ru_action, SIGNAL("triggered()"), actionRu)
    mw.qt_tool_bar.addAction(Ru_action)		

    count_action = QAction(mw)
    #count_action.setText(_(u"Count"))
    #count_action.setIcon(QIcon(os.path.join(icons_dir, 'calculator.png')))
    #count_action.setToolTip(_(u"Count"))
    #mw.connect(count_action, SIGNAL("triggered()"), actionCount)
    mw.qt_tool_bar.addAction(count_action)

    
    hint_action.setText(_(u"Hint"))
    hint_action.setShortcut(QKeySequence(Qt.Key_H))
    hint_action.setIcon(QIcon(os.path.join(icons_dir, 'hint.png')))
    hint_action.setToolTip(_(u"Hint  U"))
    hint_action.setObjectName("Hint")
    mw.connect(hint_action, SIGNAL("triggered()"), actionHint)
    mw.qt_tool_bar.addAction(hint_action)
    
    defer_action = QAction(mw)
    defer_action.setText(_(u"Defer"))
#    defer_action.setShortcut(QKeySequence(Qt.Key_H))
    defer_action.setIcon(QIcon(os.path.join(icons_dir, 'warning.png')))
    defer_action.setToolTip(_(u"Defer"))
    defer_action.setCheckable(True)
    mw.connect(defer_action, SIGNAL("triggered()"), actionDefer)
    mw.qt_tool_bar.addAction(defer_action)

    
    letter_action.setText(_(u"Letter"))
    letter_action.setShortcut(QKeySequence(Qt.Key_L))
    letter_action.setIcon(QIcon(os.path.join(icons_dir, 'question_mark.png')))
    letter_action.setToolTip(_(u"First Letter Hint L"))
    mw.connect(letter_action, SIGNAL("triggered()"), actionLetter)
    mw.qt_tool_bar.addAction(letter_action)

    exHint_action.setText(_(u"Ex. Hint"))
    exHint_action.setShortcut(QKeySequence(Qt.Key_E))
    exHint_action.setIcon(QIcon(os.path.join(icons_dir, 'file-help-icon.png')))
    exHint_action.setToolTip(_(u"Example Hint E"))
    mw.connect(exHint_action, SIGNAL("triggered()"), actionExampleHint)
    mw.qt_tool_bar.addAction(exHint_action)

    spacerWidget3 =  QWidget(mw)
    spacerWidget3.setMinimumWidth(128)
    spacerWidget3.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
    spacerWidget3.setVisible(True)
    mw.qt_tool_bar.addWidget(spacerWidget3)

    cardStats_action.setText("Card Stats")
    cardStats_action.setCheckable(True)
#    cardStats_action.setShortcut(QKeySequence(Qt.Key_L))
    cardStats_action.setIcon(QIcon(os.path.join(icons_dir, 'calculator.png')))
#    cardStats_action.setToolTip(_(u"First Letter Hint L"))
    mw.connect(cardStats_action, SIGNAL("toggled(bool)"), cardStats)
    mw.qt_tool_bar.addAction(cardStats_action)