def show_shortcuts(main_window):
    """Shows a modal QDialog of shortcuts
    """
    dialog = QDialog(main_window)
    dialog.setWindowTitle('Inselect')

    hlayout = QHBoxLayout()
    hlayout.addWidget(_column1(main_window), alignment=Qt.AlignTop)
    hlayout.addWidget(VerticalLine())
    hlayout.addWidget(_column2(main_window), alignment=Qt.AlignTop)

    vlayout = QVBoxLayout()
    vlayout.addWidget(
        HeaderLabel('Shortcuts and controls'),
        alignment=Qt.AlignHCenter | Qt.AlignTop
    )
    vlayout.addWidget(HorizontalLine())
    vlayout.addLayout(hlayout)

    show_at_startup = QCheckBox('Show this help the next time Inselect starts')
    show_at_startup.setChecked(_show_shortcuts_at_startup())
    vlayout.addWidget(show_at_startup, alignment=Qt.AlignLeft)

    prompt = ("Show this help at any time by pressing '{0}' or by selecting "
              "'{1}' from the Help menu.")
    vlayout.addWidget(QLabel(prompt.format(
        format_action_shortcuts(main_window.show_shortcuts_action),
        main_window.show_shortcuts_action.iconText()
    )))

    close = QPushButton('Close')
    close.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
    close.setDefault(True)
    close.clicked.connect(dialog.close)
    vlayout.addWidget(close, alignment=Qt.AlignHCenter)

    dialog.setLayout(vlayout)

    # TODO This belongs in the app's stylesheet but it wasn't respected
    # when I tried it
    dialog.setStyleSheet("""
    HeaderLabel {
        font-weight: bold;
        font-size: 16px;
    }
    """)
    dialog.exec_()

    QSettings().setValue(_KEY, 1 if show_at_startup.isChecked() else 0)
def show_shortcuts(main_window):
    """Shows a modal QDialog of shortcuts
    """
    dialog = QDialog(main_window)
    dialog.setWindowTitle('Inselect')

    hlayout = QHBoxLayout()
    hlayout.addWidget(_column1(main_window), alignment=Qt.AlignTop)
    hlayout.addWidget(VerticalLine())
    hlayout.addWidget(_column2(main_window), alignment=Qt.AlignTop)

    vlayout = QVBoxLayout()
    vlayout.addWidget(HeaderLabel('Shortcuts and controls'),
                      alignment=Qt.AlignHCenter | Qt.AlignTop)
    vlayout.addWidget(HorizontalLine())
    vlayout.addLayout(hlayout)

    show_at_startup = QCheckBox('Show this help the next time Inselect starts')
    show_at_startup.setChecked(_show_shortcuts_at_startup())
    vlayout.addWidget(show_at_startup, alignment=Qt.AlignLeft)

    prompt = ("Show this help at any time by pressing '{0}' or by selecting "
              "'{1}' from the Help menu.")
    vlayout.addWidget(
        QLabel(
            prompt.format(
                format_action_shortcuts(main_window.show_shortcuts_action),
                main_window.show_shortcuts_action.iconText())))

    close = QPushButton('Close')
    close.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
    close.setDefault(True)
    close.clicked.connect(dialog.close)
    vlayout.addWidget(close, alignment=Qt.AlignHCenter)

    dialog.setLayout(vlayout)

    # TODO This belongs in the app's stylesheet but it wasn't respected
    # when I tried it
    dialog.setStyleSheet("""
    HeaderLabel {
        font-weight: bold;
        font-size: 16px;
    }
    """)
    dialog.exec_()

    QSettings().setValue(_KEY, 1 if show_at_startup.isChecked() else 0)
def _add_row(layout, action):
    """Adds to layout the text and shortcuts for action
    """
    row = layout.rowCount()
    layout.addWidget(QLabel(format_action_shortcuts(action)), row, 0)
    layout.addWidget(QLabel(action.iconText()), row, 1)
def _add_row(layout, action):
    """Adds to layout the text and shortcuts for action
    """
    row = layout.rowCount()
    layout.addWidget(QLabel(format_action_shortcuts(action)), row, 0)
    layout.addWidget(QLabel(action.iconText()), row, 1)