traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src/traverso Interface.cpp Interface.h...


From: Nicola Doebelin
Subject: [Traverso-commit] traverso/src/traverso Interface.cpp Interface.h...
Date: Mon, 12 May 2008 20:44:46 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Nicola Doebelin <n_doebelin>    08/05/12 20:44:46

Modified files:
        src/traverso   : Interface.cpp Interface.h 
        src/traverso/widgets: InfoWidgets.cpp InfoWidgets.h 

Log message:
        * More actions moved from the InfoToolBar to the menu bar

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/Interface.cpp?cvsroot=traverso&r1=1.135&r2=1.136
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/Interface.h?cvsroot=traverso&r1=1.54&r2=1.55
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/widgets/InfoWidgets.cpp?cvsroot=traverso&r1=1.60&r2=1.61
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/widgets/InfoWidgets.h?cvsroot=traverso&r1=1.23&r2=1.24

Patches:
Index: Interface.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/Interface.cpp,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -b -r1.135 -r1.136
--- Interface.cpp       12 May 2008 16:47:50 -0000      1.135
+++ Interface.cpp       12 May 2008 20:44:45 -0000      1.136
@@ -201,6 +201,7 @@
        cpointer().add_contextitem(this);
 
        connect(&config(), SIGNAL(configChanged()), this, 
SLOT(config_changed()));
+       connect(&config(), SIGNAL(configChanged()), this, 
SLOT(update_follow_state()));
        update_follow_state();
 }
 
@@ -227,6 +228,9 @@
 
        if ( project ) {
                connect(project, SIGNAL(currentSheetChanged(Sheet*)), this, 
SLOT(show_sheet(Sheet*)));
+               connect(project, SIGNAL(projectLoadFinished()), this, 
SLOT(sheet_selector_update_sheets()));
+               connect(m_project, SIGNAL(sheetAdded(Sheet*)), this, 
SLOT(sheet_selector_sheet_added(Sheet*)));
+               connect(m_project, SIGNAL(sheetRemoved(Sheet*)), this, 
SLOT(sheet_selector_sheet_removed(Sheet*)));
                setWindowTitle(project->get_title() + " - Traverso");
                m_projectSaveAction->setEnabled(true);
                m_projectSheetManagerAction->setEnabled(true);
@@ -1443,3 +1447,86 @@
        }
 }
 
+void Interface::sheet_selector_update_sheets()
+{
+       // empty the list, make sure everything is deleted
+       while(!m_currentSheetActions.isEmpty())
+       {
+               QAction *action = m_currentSheetActions.takeFirst();
+               delete action;
+       }
+
+       if (!m_project)
+       {
+               return;
+       }
+
+       if (!m_project->get_current_sheet())
+       {
+               return;
+       }
+
+       qint64 id = m_project->get_current_sheet()->get_id();
+
+       QActionGroup* actiongroup = new QActionGroup(this);
+       actiongroup->setExclusive(true);
+
+       // create the new actions
+       foreach(Sheet* sheet, m_project->get_sheets())
+       {
+               QString string = 
QString::number(m_project->get_sheet_index(sheet->get_id())) +
+               ": " + sheet->get_title();
+               QAction* action = m_sheetMenu->addAction(string);
+               actiongroup->addAction(action);
+               action->setData(sheet->get_id());
+               action->setCheckable(true);
+
+               if (sheet->get_id() == id)
+               {
+                       action->setChecked(true);
+               } else {
+                       action->setChecked(false);
+               }
+
+               connect(action, SIGNAL(triggered()), this, 
SLOT(sheet_selected()));
+               m_currentSheetActions.append(action);
+       }
+}
+
+void Interface::sheet_selected()
+{
+       // identify the action that was activated
+       QAction *orig = qobject_cast<QAction *>(sender());
+
+       if (!orig)
+       {
+               return;
+       }
+
+       qint64 id = orig->data().toLongLong();
+
+       // uncheck all other actions
+       foreach(QAction* action, m_currentSheetActions)
+       {
+               if (action->data().toLongLong() != id)
+               {
+                       action->setChecked(false);
+               }
+       }
+
+       m_project->set_current_sheet(id);
+}
+
+void Interface::sheet_selector_sheet_added(Sheet* sheet)
+{
+       connect(sheet, SIGNAL(propertyChanged()), this, 
SLOT(sheet_selector_update_sheets()));
+       sheet_selector_update_sheets();
+}
+
+void Interface::sheet_selector_sheet_removed(Sheet* sheet)
+{
+       disconnect(sheet, SIGNAL(propertyChanged()), this, 
SLOT(sheet_selector_update_sheets()));
+       sheet_selector_update_sheets();
+}
+
+

Index: Interface.h
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/Interface.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- Interface.h 12 May 2008 16:47:50 -0000      1.54
+++ Interface.h 12 May 2008 20:44:45 -0000      1.55
@@ -151,6 +151,7 @@
        QMenu*                  m_viewMenu;
        QMenu*                  m_settingsMenu;
        QMenu*                  m_helpMenu;
+       QList<QAction*>         m_currentSheetActions;
        
        ResourcesInfoWidget*    resourcesInfo;
        DriverInfoWidget*       driverInfo;
@@ -215,6 +216,10 @@
        void follow_state_changed(bool state);
        void update_follow_state();
        void update_temp_follow_state(bool state);
+       void sheet_selector_update_sheets();
+       void sheet_selected();
+       void sheet_selector_sheet_added(Sheet*);
+       void sheet_selector_sheet_removed(Sheet*);
 };
 
 

Index: widgets/InfoWidgets.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/widgets/InfoWidgets.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- widgets/InfoWidgets.cpp     12 May 2008 17:47:33 -0000      1.60
+++ widgets/InfoWidgets.cpp     12 May 2008 20:44:46 -0000      1.61
@@ -550,12 +550,6 @@
        setObjectName(tr("Main Toolbar"));
        
        connect(&pm(), SIGNAL(projectLoaded(Project*)), this, 
SLOT(set_project(Project*)));
-       connect(&config(), SIGNAL(configChanged()), this, 
SLOT(update_follow_state()));
-
-       m_sheetselectbox = new QComboBox(this);
-       m_sheetselectbox->setMinimumWidth(140);
-       m_sheetselectbox->setToolTip(tr("Select Sheet to be displayed"));
-       connect(m_sheetselectbox, SIGNAL(activated(int)), this, 
SLOT(sheet_selector_index_changed(int)));
 
        m_playhead = new PlayHeadInfo(this);
 
@@ -566,32 +560,12 @@
        // the order in which the actions are added determines the order of 
appearance in the toolbar
        addAction(m_recAct);
        addWidget(m_playhead);
-       addWidget(m_sheetselectbox);
 }
 
 
 void InfoToolBar::set_project(Project * project)
 {
        m_project = project;
-       
-       if (!project) {
-               m_sheetselectbox->clear();
-               set_sheet(0);
-               return;
-       }
-       
-       connect(m_project, SIGNAL(sheetAdded(Sheet*)), this, 
SLOT(sheet_selector_sheet_added(Sheet*)));
-       connect(m_project, SIGNAL(sheetRemoved(Sheet*)), this, 
SLOT(sheet_selector_sheet_removed(Sheet*)));
-       connect(m_project, SIGNAL(currentSheetChanged(Sheet*)), this, 
SLOT(sheet_selector_change_index_to(Sheet*)));
-       connect(m_project, SIGNAL(currentSheetChanged(Sheet*)), this, 
SLOT(set_sheet(Sheet*)));
-       connect(m_project, SIGNAL(projectLoadFinished()), this, 
SLOT(project_load_finished()));
-       
-       sheet_selector_update_sheets();
-}
-
-void InfoToolBar::project_load_finished()
-{
-       sheet_selector_change_index_to(m_project->get_current_sheet());
 }
 
 void InfoToolBar::set_sheet(Sheet* sheet)
@@ -631,54 +605,6 @@
 }
 
 
-void InfoToolBar::sheet_selector_update_sheets()
-{
-       m_sheetselectbox->clear();
-       foreach(Sheet* sheet, m_project->get_sheets()) {
-               m_sheetselectbox->addItem("Sheet " +
-               QString::number(m_project->get_sheet_index(sheet->get_id())) +
-               ": " + sheet->get_title(),
-               sheet->get_id());
-       }
-
-       if (m_project->get_current_sheet()) {
-               int i = 
m_project->get_sheet_index((m_project->get_current_sheet())->get_id()) - 1;
-               m_sheetselectbox->setCurrentIndex(i);
-       }
-}
-
-void InfoToolBar::sheet_selector_sheet_added(Sheet * sheet)
-{
-       connect(sheet, SIGNAL(propertyChanged()), this, 
SLOT(sheet_selector_update_sheets()));
-       sheet_selector_update_sheets();
-}
-
-void InfoToolBar::sheet_selector_sheet_removed(Sheet * sheet)
-{
-       disconnect(sheet, SIGNAL(propertyChanged()), this, 
SLOT(sheet_selector_update_sheets()));
-       sheet_selector_update_sheets();
-}
-
-void InfoToolBar::sheet_selector_index_changed(int index)
-{
-       qint64 id = m_sheetselectbox->itemData(index).toLongLong();
-       
-       m_project->set_current_sheet(id);
-}
-
-void InfoToolBar::sheet_selector_change_index_to(Sheet* sheet)
-{
-       if (!sheet) {
-               return;
-       }
-       
-       int index = m_sheetselectbox->findData(sheet->get_id());
-       if (index >= 0) {
-               m_sheetselectbox->setCurrentIndex(index);
-       }
-}
-
-
 
 SysInfoToolBar::SysInfoToolBar(QWidget * parent)
        : QToolBar(parent)

Index: widgets/InfoWidgets.h
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/widgets/InfoWidgets.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- widgets/InfoWidgets.h       12 May 2008 16:47:51 -0000      1.23
+++ widgets/InfoWidgets.h       12 May 2008 20:44:46 -0000      1.24
@@ -182,7 +182,6 @@
        Project*        m_project;
 
 private:
-       QComboBox*      m_sheetselectbox;
        PlayHeadInfo*   m_playhead;
        QAction*        m_recAct;
 
@@ -191,14 +190,8 @@
        void set_sheet(Sheet* );
 
 private slots:
-       void sheet_selector_index_changed(int index);
-       void sheet_selector_change_index_to(Sheet* sheet);
-       void sheet_selector_sheet_added(Sheet* sheet);
-       void sheet_selector_sheet_removed(Sheet* sheet);
-       void sheet_selector_update_sheets();
        void recording_action_clicked();
        void update_recording_state();
-       void project_load_finished();
 };
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]