Example #1
0
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);
}
Example #2
0
void NPlayer::on_playlistAction_triggered()
{
	NAction *action = reinterpret_cast<NAction *>(QObject::sender());
	if (action == m_loopPlaylistAction)
		m_settings->setValue("LoopPlaylist", action->isChecked());
	else if (action == m_nextFileEnableAction)
		m_settings->setValue("LoadNext", action->isChecked());
	else if (action == m_nextFileByNameAscdAction)
		m_settings->setValue("LoadNextSort", (int)QDir::Name);
	else if (action == m_nextFileByNameDescAction)
		m_settings->setValue("LoadNextSort", (int)(QDir::Name | QDir::Reversed));
	else if (action == m_nextFileByDateAscd)
		m_settings->setValue("LoadNextSort", (int)QDir::Time | QDir::Reversed);
	else if (action == m_nextFileByDateDesc)
		m_settings->setValue("LoadNextSort", (int)(QDir::Time));
}
Example #3
0
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);
}
Example #4
0
void NPlayer::createActions()
{
	m_showHideAction = new NAction(QIcon::fromTheme("preferences-system-windows", QIcon(":/trolltech/styles/commonstyle/images/dockdock-16.png")), tr("Show / Hide"), this);
	m_showHideAction->setObjectName("ShowHideAction");
	m_showHideAction->setStatusTip(tr("Toggle window visibility"));
	m_showHideAction->setCustomizable(true);

	m_playAction = new NAction(QIcon::fromTheme("media-playback-start", style()->standardIcon(QStyle::SP_MediaPlay)), tr("Play / Pause"), this);
	m_playAction->setObjectName("PlayAction");
	m_playAction->setStatusTip(tr("Toggle playback"));
	m_playAction->setCustomizable(true);

	m_stopAction = new NAction(QIcon::fromTheme("media-playback-stop", style()->standardIcon(QStyle::SP_MediaStop)), tr("Stop"), this);
	m_stopAction->setObjectName("StopAction");
	m_stopAction->setStatusTip(tr("Stop playback"));
	m_stopAction->setCustomizable(true);

	m_prevAction = new NAction(QIcon::fromTheme("media-playback-backward", style()->standardIcon(QStyle::SP_MediaSkipBackward)), tr("Previous"), this);
	m_prevAction->setObjectName("PrevAction");
	m_prevAction->setStatusTip(tr("Play previous track in playlist"));
	m_prevAction->setCustomizable(true);

	m_nextAction = new NAction(QIcon::fromTheme("media-playback-forward", style()->standardIcon(QStyle::SP_MediaSkipForward)), tr("Next"), this);
	m_nextAction->setObjectName("NextAction");
	m_nextAction->setStatusTip(tr("Play next track in playlist"));
	m_nextAction->setCustomizable(true);

	m_preferencesAction = new NAction(QIcon::fromTheme("preferences-desktop", style()->standardIcon(QStyle::SP_MessageBoxInformation)), tr("Preferences..."), this);
	m_preferencesAction->setShortcut(QKeySequence("Ctrl+P"));

	m_exitAction = new NAction(QIcon::fromTheme("exit", style()->standardIcon(QStyle::SP_DialogCloseButton)), tr("Exit"), this);
	m_exitAction->setShortcut(QKeySequence("Ctrl+Q"));

	m_addFilesAction = new NAction(style()->standardIcon(QStyle::SP_DialogOpenButton), tr("Add Files..."), this);
	m_addFilesAction->setShortcut(QKeySequence("Ctrl+O"));

	m_addDirAction = new NAction(style()->standardIcon(QStyle::SP_FileDialogNewFolder), tr("Add Directory..."), this);
	m_addDirAction->setShortcut(QKeySequence("Ctrl+Shift+O"));

	m_savePlaylistAction = new NAction(style()->standardIcon(QStyle::SP_DialogSaveButton), tr("Save Playlist..."), this);
	m_savePlaylistAction->setShortcut(QKeySequence("Ctrl+S"));

	m_showCoverAction = new NAction(tr("Show Cover Art"), this);
	m_showCoverAction->setCheckable(true);
	m_showCoverAction->setObjectName("ShowCoverAction");

	m_aboutAction = new NAction(QIcon::fromTheme("help-about", style()->standardIcon(QStyle::SP_MessageBoxQuestion)), tr("About"), this);

	m_playingOnTopAction = new NAction(tr("On Top During Playback"), this);
	m_playingOnTopAction->setCheckable(true);
	m_playingOnTopAction->setObjectName("PlayingOnTopAction");

	m_alwaysOnTopAction = new NAction(tr("Always On Top"), this);
	m_alwaysOnTopAction->setCheckable(true);
	m_alwaysOnTopAction->setObjectName("AlwaysOnTopAction");

	m_fullScreenAction = new NAction(tr("Fullscreen Mode"), this);
	m_fullScreenAction->setStatusTip(tr("Hide all controll except waveform"));
	m_fullScreenAction->setObjectName("FullScreenAction");
	m_fullScreenAction->setCustomizable(true);

	// playlist actions >>
	m_shufflePlaylistAction = new NAction(tr("Shuffle"), this);
	m_shufflePlaylistAction->setCheckable(true);
	m_shufflePlaylistAction->setObjectName("ShufflePlaylistAction");
	m_shufflePlaylistAction->setStatusTip(tr("Toggle playlist shuffle"));
	m_shufflePlaylistAction->setCustomizable(true);

	m_repeatPlaylistAction = new NAction(tr("Repeat"), this);
	m_repeatPlaylistAction->setCheckable(true);
	m_repeatPlaylistAction->setObjectName("RepeatPlaylistAction");
	m_repeatPlaylistAction->setStatusTip(tr("Toggle current item repeat"));
	m_repeatPlaylistAction->setCustomizable(true);

	m_loopPlaylistAction = new NAction(tr("Loop playlist"), this);
	m_loopPlaylistAction->setCheckable(true);
	m_loopPlaylistAction->setObjectName("LoopPlaylistAction");

	m_nextFileEnableAction = new NAction(tr("Load next file in directory when finished"), this);
	m_nextFileEnableAction->setCheckable(true);
	m_nextFileEnableAction->setObjectName("NextFileEnableAction");

	m_nextFileByNameAscdAction = new NAction(QString::fromUtf8("    ├  %1 ↓").arg(tr("By Name")), this);
	m_nextFileByNameAscdAction->setCheckable(true);
	m_nextFileByNameAscdAction->setObjectName("NextFileByNameAscdAction");

	m_nextFileByNameDescAction = new NAction(QString::fromUtf8("    ├  %1 ↑").arg(tr("By Name")), this);
	m_nextFileByNameDescAction->setCheckable(true);
	m_nextFileByNameDescAction->setObjectName("NextFileByNameDescAction");

	m_nextFileByDateAscd = new NAction(QString::fromUtf8("    ├  %1 ↓").arg(tr("By Date")), this);
	m_nextFileByDateAscd->setCheckable(true);
	m_nextFileByDateAscd->setObjectName("NextFileByDateAscd");

	m_nextFileByDateDesc = new NAction(QString::fromUtf8("    └  %1 ↑").arg(tr("By Date")), this);
	m_nextFileByDateDesc->setCheckable(true);
	m_nextFileByDateDesc->setObjectName("NextFileByDateDesc");

	QActionGroup *group = new QActionGroup(this);
	m_nextFileByNameAscdAction->setActionGroup(group);
	m_nextFileByNameDescAction->setActionGroup(group);
	m_nextFileByDateAscd->setActionGroup(group);
	m_nextFileByDateDesc->setActionGroup(group);
	// << playlist actions

	// jump actions >>
	for (int i = 1; i <= 3; ++i) {
		QString num = QString::number(i);

		NAction *jumpFwAction = new NAction(QString(tr("Jump Forward #%1")).arg(num), this);
		jumpFwAction->setObjectName(QString("Jump%1ForwardAction").arg(num));
		jumpFwAction->setStatusTip(QString(tr("Make a jump forward #%1")).arg(num));
		jumpFwAction->setCustomizable(true);

		NAction *jumpBwAction = new NAction(QString(tr("Jump Backwards #%1")).arg(num), this);
		jumpBwAction->setObjectName(QString("Jump%1BackwardsAction").arg(num));
		jumpBwAction->setStatusTip(QString(tr("Make a jump backwards #%1")).arg(num));
		jumpBwAction->setCustomizable(true);
	}
	// << jump actions

	// keyboard shortcuts
	m_settings->initShortcuts(this);
	m_settings->loadShortcuts();
	foreach (NAction *action, findChildren<NAction *>()) {
		if (!action->shortcuts().isEmpty())
			m_mainWindow->addAction(action);
	}

	createContextMenu();
	createGlobalMenu();
	createTrayIcon();
}