mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-03-04 06:25:08 +00:00
bored so added a context menu
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@992 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>images/icons/hi16-action-projectm_add_playlist.png</file>
|
||||
<file>images/icons/hi16-action-projectm_edit.png</file>
|
||||
<file>images/icons/hi16-action-projectm_lock.png</file>
|
||||
<file>images/icons/hi16-action-projectm_playlist_clear.png</file>
|
||||
<file>images/icons/hi16-action-projectm_random.png</file>
|
||||
<file>images/icons/hi16-action-projectm_random_no.png</file>
|
||||
<file>images/icons/hi16-action-projectm_remove.png</file>
|
||||
<file>images/icons/hi16-action-projectm_save.png</file>
|
||||
<file>images/icons/hi16-action-projectm_unlock.png</file>
|
||||
<file>images/icons/prjm16-transparent.svg</file>
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QMenu>
|
||||
class QPlaylistTableView : public QTableView
|
||||
{
|
||||
Q_OBJECT // must include this if you use Qt signals/slots
|
||||
@ -37,6 +38,7 @@ class QPlaylistTableView : public QTableView
|
||||
|
||||
|
||||
signals:
|
||||
void mousePressed(QMouseEvent*);
|
||||
void resized(QResizeEvent * event);
|
||||
void deletesRequested(const QModelIndexList & items);
|
||||
void internalDragAndDropRequested(const QModelIndexList & items, const QModelIndex & target = QModelIndex());
|
||||
@ -95,10 +97,17 @@ class QPlaylistTableView : public QTableView
|
||||
emit(resized(event));
|
||||
}
|
||||
|
||||
inline void mousePressEvent(QMouseEvent * event) {
|
||||
QAbstractItemView::mousePressEvent(event);
|
||||
if (event->button() == Qt::RightButton) {
|
||||
emit(mousePressed(event));
|
||||
|
||||
}
|
||||
else
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void keyReleaseEvent(QKeyEvent * event) {
|
||||
inline void keyReleaseEvent(QKeyEvent * event) {
|
||||
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Delete:
|
||||
|
||||
@ -73,7 +73,7 @@ QProjectM_MainWindow::QProjectM_MainWindow ( const std::string & config_file, QM
|
||||
:m_QPresetFileDialog ( new QPresetFileDialog ( this ) ), ui(0), m_QPlaylistFileDialog
|
||||
( new QPlaylistFileDialog ( this )), playlistModel(0),
|
||||
configDialog(0), hHeader(0), vHeader(0), _menuVisible(true), _menuAndStatusBarsVisible(true),
|
||||
activePresetIndex(new Nullable<long>), playlistItemCounter(0), m_QPresetEditorDialog(0)
|
||||
activePresetIndex(new Nullable<long>), playlistItemCounter(0), m_QPresetEditorDialog(0), selectedPlaylistIndex(QModelIndex())
|
||||
{
|
||||
|
||||
|
||||
@ -96,6 +96,8 @@ activePresetIndex(new Nullable<long>), playlistItemCounter(0), m_QPresetEditorDi
|
||||
|
||||
connect(ui->tableView, SIGNAL(resized(QResizeEvent *)), this, SLOT(refreshHeaders(QResizeEvent*)));
|
||||
|
||||
connect(ui->tableView, SIGNAL(mousePressed(QMouseEvent*)), this, SLOT(popupPlaylistContextMenu(QMouseEvent*)));
|
||||
|
||||
connect ( m_QProjectMWidget, SIGNAL ( projectM_Initialized(QProjectM*) ),
|
||||
this, SLOT ( postProjectM_Initialize() ) );
|
||||
|
||||
@ -123,6 +125,21 @@ activePresetIndex(new Nullable<long>), playlistItemCounter(0), m_QPresetEditorDi
|
||||
|
||||
}
|
||||
|
||||
#include <QMouseEvent>
|
||||
void QProjectM_MainWindow::popupPlaylistContextMenu(QMouseEvent * mouseEvent) {
|
||||
|
||||
selectedPlaylistIndex = ui->tableView->indexAt(mouseEvent->globalPos());
|
||||
|
||||
if (mouseEvent->button() == Qt::RightButton) {
|
||||
|
||||
QPoint point = mouseEvent->globalPos();
|
||||
playlistContextMenu->popup(point, ui->actionEdit_this_preset);
|
||||
mouseEvent->accept();
|
||||
} else {
|
||||
mouseEvent->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void QProjectM_MainWindow::readConfig(const std::string & configFile ) {
|
||||
|
||||
QSettings settings ( "projectM", "qprojectM" );
|
||||
@ -815,6 +832,13 @@ void QProjectM_MainWindow::copyPlaylist()
|
||||
qprojectMWidget()->releasePresetLock();
|
||||
}
|
||||
|
||||
void QProjectM_MainWindow::removeSelectedPlaylistItem() {
|
||||
|
||||
QModelIndexList items;
|
||||
items.append(this->selectedPlaylistIndex);
|
||||
removePlaylistItems(items);
|
||||
}
|
||||
|
||||
void QProjectM_MainWindow::removePlaylistItems(const QModelIndexList & items) {
|
||||
|
||||
qprojectMWidget()->seizePresetLock();
|
||||
@ -945,6 +969,13 @@ void QProjectM_MainWindow::createActions()
|
||||
connect ( ui->actionConfigure_projectM, SIGNAL ( triggered() ), this, SLOT (openSettingsDialog()) );
|
||||
connect ( ui->actionAbout_Qt, SIGNAL(triggered()), this, SLOT(aboutQt()));
|
||||
connect ( ui->actionHotkey_Reference, SIGNAL(triggered()), this, SLOT(hotkeyReference()));
|
||||
|
||||
// connect (ui->actionRemove_selection, SIGNAL(triggered()), this, SLOT(removeSelectedPlaylistItem()));
|
||||
connect (ui->actionEdit_this_preset, SIGNAL(triggered()), this, SLOT(openPresetEditorDialogForSelectedPreset()));
|
||||
}
|
||||
|
||||
void QProjectM_MainWindow::openPresetEditorDialogForSelectedPreset() {
|
||||
openPresetEditorDialog(selectedPlaylistIndex.row());
|
||||
}
|
||||
|
||||
void QProjectM_MainWindow::registerSettingsAction(QAction * action) {
|
||||
@ -957,9 +988,17 @@ void QProjectM_MainWindow::unregisterSettingsAction(QAction * action) {
|
||||
|
||||
void QProjectM_MainWindow::createMenus()
|
||||
{
|
||||
|
||||
playlistContextMenu = new QMenu("Playlist Actions", this);
|
||||
playlistContextMenu->addAction(ui->actionRemove_selection);
|
||||
playlistContextMenu->addAction(ui->actionEdit_this_preset);
|
||||
ui->menuBar->hide();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QProjectM_MainWindow::createToolBars()
|
||||
{
|
||||
|
||||
|
||||
@ -114,11 +114,16 @@ protected:
|
||||
|
||||
private slots:
|
||||
|
||||
void removeSelectedPlaylistItem();
|
||||
|
||||
void openPresetEditorDialogForSelectedPreset();
|
||||
void popupPlaylistContextMenu(QMouseEvent *);
|
||||
void hotkeyReference();
|
||||
void selectPlaylistItem ( int rowIndex);
|
||||
void clearPlaylistModel();
|
||||
void openPresetEditorDialog(int rowIndex);
|
||||
void aboutQt();
|
||||
|
||||
void clearPlaylist();
|
||||
void addPresetsDialog();
|
||||
void openPlaylistDialog();
|
||||
@ -135,7 +140,7 @@ private slots:
|
||||
void removePlaylistItems(const QModelIndexList & items);
|
||||
void dragAndDropPlaylistItems(const QModelIndexList &, const QModelIndex &);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
bool warnIfPlaylistModified();
|
||||
|
||||
@ -153,7 +158,8 @@ private slots:
|
||||
QHeaderView * hHeader;
|
||||
QHeaderView * vHeader;
|
||||
QString m_currentPlaylistUrl;
|
||||
|
||||
QModelIndex selectedPlaylistIndex;
|
||||
|
||||
QPlaylistModel * playlistModel;
|
||||
Ui::QProjectM_MainWindow * ui;
|
||||
QProjectMConfigDialog * configDialog;
|
||||
@ -180,6 +186,7 @@ private slots:
|
||||
|
||||
QMenu *fileMenu;
|
||||
QMenu *helpMenu;
|
||||
QMenu *playlistContextMenu;
|
||||
QToolBar *fileToolBar;
|
||||
|
||||
QAction *openAct;;
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>787</width>
|
||||
<height>26</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile" >
|
||||
@ -213,6 +213,9 @@ p, li { white-space: pre-wrap; }
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy" >
|
||||
<enum>Qt::ActionsContextMenu</enum>
|
||||
</property>
|
||||
<property name="acceptDrops" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -413,6 +416,22 @@ image: url(:/images/icons/hi16-action-projectm_unlock.png);
|
||||
<string>Hotkey reference</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEdit_this_preset" >
|
||||
<property name="icon" >
|
||||
<iconset resource="application.qrc" >:/images/icons/hi16-action-projectm_edit.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Edit this preset</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemove_selection" >
|
||||
<property name="icon" >
|
||||
<iconset resource="application.qrc" >:/images/icons/hi16-action-projectm_remove.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Remove selection</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
Reference in New Issue
Block a user