void NPlayer::on_jumpAction_triggered() { NAction *action = reinterpret_cast<NAction *>(QObject::sender()); QRegExp regex("(\\w+\\d)(\\w+)Action"); regex.indexIn(action->objectName()); m_playbackEngine->jump((regex.cap(2) == "Forward" ? 1 : -1) * NSettings::instance()->value(regex.cap(1)).toDouble() * 1000); }
void NShortcutEditorWidget::init(const QList<NAction *> &actionList) { if (m_init) return; m_init = true; m_actionList = actionList; setRowCount(m_actionList.size()); for (int i = 0; i < m_actionList.size(); ++i) { NAction *action = m_actionList.at(i); QTableWidgetItem *nameItem = new QTableWidgetItem(action->text()); nameItem->setFlags(Qt::NoItemFlags); nameItem->setData(Qt::UserRole, action->objectName()); setItem(i, Name, nameItem); QTableWidgetItem *descriptionItem = new QTableWidgetItem(action->statusTip()); descriptionItem->setFlags(Qt::NoItemFlags); setItem(i, Description, descriptionItem); QList<QKeySequence> shortcut = action->shortcuts(); QStringList shortcutStr; foreach (QKeySequence seq, shortcut) shortcutStr << seq.toString(); QTableWidgetItem *shortcutItem = new QTableWidgetItem(shortcutStr.join(", ")); setItem(i, Shortcut, shortcutItem); QList<QKeySequence> globalShortcut = action->globalShortcuts(); QStringList globalShortcutStr; foreach (QKeySequence seq, globalShortcut) globalShortcutStr << seq.toString(); QTableWidgetItem *globalShortcutItem = new QTableWidgetItem(globalShortcutStr.join(", ")); setItem(i, GlobalShortcut, globalShortcutItem); } resizeColumnToContents(Name); resizeColumnToContents(Description); horizontalHeader()->setResizeMode(Name, QHeaderView::Fixed); horizontalHeader()->setResizeMode(Description, QHeaderView::Fixed); horizontalHeader()->setResizeMode(Shortcut, QHeaderView::Stretch); horizontalHeader()->setResizeMode(GlobalShortcut, QHeaderView::Stretch); horizontalHeader()->setStretchLastSection(true); }