]> git.sesse.net Git - kdenlive/commitdiff
add context menu
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 13 Jan 2008 15:21:28 +0000 (15:21 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 13 Jan 2008 15:21:28 +0000 (15:21 +0000)
svn path=/branches/KDE4/; revision=1800

src/CMakeLists.txt
src/kdenliveui.rc
src/main.cpp
src/mainwindow.cpp
src/projectitem.cpp
src/projectlist.cpp
src/projectlist.h
src/projectlistview.cpp [new file with mode: 0644]
src/projectlistview.h [new file with mode: 0644]

index ec0f9d65606384beda7bcebb2ccf5cb90adb5d0b..988f4f82b21833057206e14ad5ee1059332056ff 100644 (file)
@@ -38,6 +38,7 @@ set(kdenlive_SRCS
   gentime.cpp
   renderer.cpp
   kdenlivedoc.cpp
+  projectlistview.cpp
   trackview.cpp
   docclipbase.cpp
   timecode.cpp
index 1d3967b235953f9a7fef4c810bf7b05b4289885f..4021c4388bc51a70b8edfe6887f2d7b6ef48c238 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<gui name="kdenlive" version="4">
-  <ToolBar name="mainToolBar" >
-    <text>Main Toolbar</text>
+<gui name="kdenlive" version="5">
+  <ToolBar name="extraToolBar" >
+    <text>Extra Toolbar</text>
     <Action name="clear" />
   </ToolBar>
 
index 52db06a4514d3821f56d24a3ba9696a063894368..f6a8888d0ccb0ed0a555581d312022241a0213d3 100644 (file)
@@ -19,7 +19,7 @@ int main (int argc, char *argv[])
   KCmdLineArgs::addCmdLineOptions(options); //new
  
   KApplication app;
+
   MainWindow* window = new MainWindow();
   window->show();
  
index 98a9d04eca5e713d0bddb006fd3a278da8721ea7..39fa17f8b5a46263702c90fc94cde84c0aa88f9a 100644 (file)
@@ -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()
index 4a46eb3b00194936174895a476a1fdf2daee442c..bcdac14a94dc2fdc6af92f96700dc890c4b93d2d 100644 (file)
@@ -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"));
 }
 
index 369370d06b92009d735dd4a9819af7eb53b09de9..9bec68fbdb39bbb28558d567e11671bf88edb6f7 100644 (file)
@@ -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()
index 95cd4d6c2303c15625ee0339e965373f53c9bfda..8e555fb99dbf6c6588e2cf7d3e5144f20aa53433 100644 (file)
@@ -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 (file)
index 0000000..f8d67e4
--- /dev/null
@@ -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 (file)
index 0000000..07f22ca
--- /dev/null
@@ -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 <QTreeWidget>
+#include <QContextMenuEvent>
+
+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