From 97e4197dbc794db76bd84d3b01284c24e71464f8 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 13 Jan 2008 15:21:28 +0000 Subject: [PATCH] add context menu svn path=/branches/KDE4/; revision=1800 --- src/CMakeLists.txt | 1 + src/kdenliveui.rc | 6 ++--- src/main.cpp | 2 +- src/mainwindow.cpp | 9 +++----- src/projectitem.cpp | 6 ++--- src/projectlist.cpp | 43 ++++++++++++++++++++++++++++++----- src/projectlist.h | 12 +++++++++- src/projectlistview.cpp | 39 ++++++++++++++++++++++++++++++++ src/projectlistview.h | 50 +++++++++++++++++++++++++++++++++++++++++ 9 files changed, 148 insertions(+), 20 deletions(-) create mode 100644 src/projectlistview.cpp create mode 100644 src/projectlistview.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ec0f9d65..988f4f82 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,6 +38,7 @@ set(kdenlive_SRCS gentime.cpp renderer.cpp kdenlivedoc.cpp + projectlistview.cpp trackview.cpp docclipbase.cpp timecode.cpp diff --git a/src/kdenliveui.rc b/src/kdenliveui.rc index 1d3967b2..4021c438 100644 --- a/src/kdenliveui.rc +++ b/src/kdenliveui.rc @@ -1,8 +1,8 @@ - - - Main Toolbar + + + Extra Toolbar diff --git a/src/main.cpp b/src/main.cpp index 52db06a4..f6a8888d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,7 @@ int main (int argc, char *argv[]) KCmdLineArgs::addCmdLineOptions(options); //new KApplication app; - + MainWindow* window = new MainWindow(); window->show(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 98a9d04e..39fa17f8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -51,7 +51,6 @@ MainWindow::MainWindow(QWidget *parent) m_timelineArea->setHoverCloseButton(true); m_timelineArea->setTabReorderingEnabled(true); connect(m_timelineArea, SIGNAL(currentChanged (int)), this, SLOT(activateDocument())); - setCentralWidget(m_timelineArea); m_monitorManager = new MonitorManager(); @@ -108,6 +107,8 @@ MainWindow::MainWindow(QWidget *parent) projectListDock->raise(); tabifyDockWidget (clipMonitorDock, projectMonitorDock); + setCentralWidget(m_timelineArea); + setupGUI(Default, "kdenliveui.rc"); connect(projectMonitorDock, SIGNAL(visibilityChanged (bool)), m_projectMonitor, SLOT(refreshMonitor(bool))); connect(clipMonitorDock, SIGNAL(visibilityChanged (bool)), m_clipMonitor, SLOT(refreshMonitor(bool))); @@ -115,10 +116,10 @@ MainWindow::MainWindow(QWidget *parent) connect(m_monitorManager, SIGNAL(raiseClipMonitor (bool)), this, SLOT(slotRaiseMonitor(bool))); m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor); + setAutoSaveSettings(); newFile(); } - void MainWindow::slotRaiseMonitor(bool clipMonitor) { if (clipMonitor) clipMonitorDock->raise(); @@ -176,10 +177,6 @@ void MainWindow::setupActions() /*m_redo = m_commandStack->createRedoAction(actionCollection()); m_undo = m_commandStack->createUndoAction(actionCollection());*/ - - setupGUI(); - - } void MainWindow::newFile() diff --git a/src/projectitem.cpp b/src/projectitem.cpp index 4a46eb3b..bcdac14a 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -41,7 +41,7 @@ ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDom { m_element = xml.cloneNode().toElement(); setSizeHint(0, QSize(65, 45)); - setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); + setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); if (!m_element.isNull()) { m_element.setAttribute("id", clipId); QString cType = m_element.attribute("type", QString::null); @@ -57,7 +57,7 @@ ProjectItem::ProjectItem(QTreeWidgetItem * parent, const QStringList & strings, { m_element = xml.cloneNode().toElement(); setSizeHint(0, QSize(65, 45)); - setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); + setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); if (!m_element.isNull()) { m_element.setAttribute("id", clipId); QString cType = m_element.attribute("type", QString::null); @@ -72,7 +72,7 @@ ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings) : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(DocClipBase::NONE), m_clipId(-1), m_isGroup(true) { setSizeHint(0, QSize(65, 45)); - setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); + setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); setIcon(0, KIcon("folder")); } diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 369370d0..9bec68fb 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -93,7 +93,7 @@ ProjectList::ProjectList(QWidget *parent) { QWidget *vbox = new QWidget; - listView = new QTreeWidget(this);; + listView = new ProjectListView(this);; QVBoxLayout *layout = new QVBoxLayout; m_clipIdCounter = 0; @@ -114,11 +114,11 @@ ProjectList::ProjectList(QWidget *parent) QAction *addColorClip = addMenu->addAction (KIcon("document-new"), i18n("Add Color Clip")); connect(addColorClip, SIGNAL(triggered()), this, SLOT(slotAddColorClip())); - QAction *deleteClip = m_toolbar->addAction (KIcon("edit-delete"), i18n("Delete Clip")); - connect(deleteClip, SIGNAL(triggered()), this, SLOT(slotRemoveClip())); + m_deleteAction = m_toolbar->addAction (KIcon("edit-delete"), i18n("Delete Clip")); + connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(slotRemoveClip())); - QAction *editClip = m_toolbar->addAction (KIcon("document-properties"), i18n("Edit Clip")); - connect(editClip, SIGNAL(triggered()), this, SLOT(slotEditClip())); + m_editAction = m_toolbar->addAction (KIcon("document-properties"), i18n("Edit Clip")); + connect(m_editAction, SIGNAL(triggered()), this, SLOT(slotEditClip())); addButton->setDefaultAction( addClipButton ); @@ -136,8 +136,15 @@ ProjectList::ProjectList(QWidget *parent) listView->setHeaderLabels(headers); listView->sortByColumn(1, Qt::AscendingOrder); + m_menu = new QMenu(); + m_menu->addAction(addClipButton); + m_menu->addAction(addColorClip); + m_menu->addAction(m_editAction); + m_menu->addAction(m_deleteAction); + m_menu->insertSeparator(m_deleteAction); + connect(listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected())); - //connect(listView, SIGNAL(itemDoubleClicked ( QTreeWidgetItem *, int )), this, SLOT(slotEditClip(QTreeWidgetItem *, int))); + connect(listView, SIGNAL(requestMenu ( const QPoint &, QTreeWidgetItem * )), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *))); listView->setItemDelegate(new ItemDelegate(listView)); @@ -146,6 +153,12 @@ ProjectList::ProjectList(QWidget *parent) } +ProjectList::~ProjectList() +{ + delete m_menu; + delete m_toolbar; +} + void ProjectList::setRenderer(Render *projectRender) { m_render = projectRender; @@ -159,7 +172,25 @@ void ProjectList::slotClipSelected() void ProjectList::slotEditClip() { + kDebug()<<"//////////////////////////////////////// DBL CLK"; +} + + +void ProjectList::slotEditClip(QTreeWidgetItem *item, int column) +{ + kDebug()<<"//////////////////////////////////////// DBL CLK"; +} + +void ProjectList::slotContextMenu( const QPoint &pos, QTreeWidgetItem *item ) +{ + bool enable = false; + if (item) { + enable = true; + } + m_editAction->setEnabled(enable); + m_deleteAction->setEnabled(enable); + m_menu->popup(pos); } void ProjectList::slotRemoveClip() diff --git a/src/projectlist.h b/src/projectlist.h index 95cd4d6c..8e555fb9 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -32,6 +32,7 @@ #include "kdenlivedoc.h" #include "renderer.h" #include "timecode.h" +#include "projectlistview.h" class ProjectItem; @@ -41,6 +42,7 @@ class ProjectList : public QWidget public: ProjectList(QWidget *parent=0); + virtual ~ProjectList(); QDomElement producersList(); void setRenderer(Render *projectRender); @@ -56,16 +58,19 @@ class ProjectList : public QWidget private: - QTreeWidget *listView; + ProjectListView *listView; KTreeWidgetSearchLine *searchView; Render *m_render; Timecode m_timecode; double m_fps; QToolBar *m_toolbar; + QMenu *m_menu; KUndoStack *m_commandStack; int m_clipIdCounter; void selectItemById(const int clipId); ProjectItem *getItemById(int id); + QAction *m_editAction; + QAction *m_deleteAction; private slots: void slotAddClip(); @@ -73,6 +78,11 @@ class ProjectList : public QWidget void slotEditClip(); void slotClipSelected(); void slotAddColorClip(); + void slotEditClip(QTreeWidgetItem *, int); + void slotContextMenu( const QPoint &pos, QTreeWidgetItem * ); + //void slotShowMenu(const QPoint &pos); + + signals: void clipSelected(const QDomElement &); diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp new file mode 100644 index 00000000..f8d67e4d --- /dev/null +++ b/src/projectlistview.cpp @@ -0,0 +1,39 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "projectlistview.h" + + +ProjectListView::ProjectListView(QWidget *parent) + : QTreeWidget(parent) +{ + +} + +ProjectListView::~ProjectListView() +{ +} + +void ProjectListView::contextMenuEvent ( QContextMenuEvent * event ) +{ + emit requestMenu(event->globalPos(), itemAt(event->pos())); +} + + +#include "projectlistview.moc" diff --git a/src/projectlistview.h b/src/projectlistview.h new file mode 100644 index 00000000..07f22ca6 --- /dev/null +++ b/src/projectlistview.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef PRJECTLISTVIEW_H +#define PRJECTLISTVIEW_H + +#include +#include + +class ProjectListView : public QTreeWidget +{ + Q_OBJECT + + public: + ProjectListView(QWidget *parent=0); + virtual ~ProjectListView(); + + protected: + virtual void contextMenuEvent ( QContextMenuEvent * event ); + + public slots: + + + private: + + + private slots: + + signals: + void requestMenu(const QPoint &, QTreeWidgetItem *); +}; + +#endif -- 2.39.2