traverso-commit
[Top][All Lists]
Advanced

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

[Traverso-commit] traverso/src commands/Zoom.cpp core/Command.cpp...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src commands/Zoom.cpp core/Command.cpp...
Date: Tue, 17 Apr 2007 11:51:21 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/04/17 11:51:20

Modified files:
        src/commands   : Zoom.cpp 
        src/core       : Command.cpp ContextPointer.cpp core.pro 
        src/traverso/songcanvas: AudioClipView.cpp AudioClipView.h 
                                 FadeView.cpp PluginView.cpp 
                                 PluginView.h TrackPanelView.cpp 
                                 TrackView.cpp ViewItem.cpp ViewItem.h 
        src/traverso   : traverso.pro 
Added files:
        src/core       : Themer.cpp Themer.h 
Removed files:
        src/traverso   : Themer.cpp Themer.h 

Log message:
        * Get QCursors from themer, creating one for each canvas item
        was a huge performance regression!
        * Moved Themer class to core for convenience (it's used in almost all 
libs...)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/Zoom.cpp?cvsroot=traverso&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Command.cpp?cvsroot=traverso&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ContextPointer.cpp?cvsroot=traverso&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/core.pro?cvsroot=traverso&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Themer.cpp?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Themer.h?cvsroot=traverso&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.cpp?cvsroot=traverso&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.h?cvsroot=traverso&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/FadeView.cpp?cvsroot=traverso&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/PluginView.cpp?cvsroot=traverso&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/PluginView.h?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/TrackPanelView.cpp?cvsroot=traverso&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/TrackView.cpp?cvsroot=traverso&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/ViewItem.cpp?cvsroot=traverso&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/ViewItem.h?cvsroot=traverso&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/traverso.pro?cvsroot=traverso&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/Themer.cpp?cvsroot=traverso&r1=1.6&r2=0
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/Themer.h?cvsroot=traverso&r1=1.4&r2=0

Patches:
Index: commands/Zoom.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/commands/Zoom.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- commands/Zoom.cpp   11 Apr 2007 21:19:17 -0000      1.11
+++ commands/Zoom.cpp   17 Apr 2007 11:51:20 -0000      1.12
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
  
-    $Id: Zoom.cpp,v 1.11 2007/04/11 21:19:17 r_sijrier Exp $
+    $Id: Zoom.cpp,v 1.12 2007/04/17 11:51:20 r_sijrier Exp $
 */
 
 #include <libtraversocore.h>
@@ -70,7 +70,7 @@
        Q_UNUSED(useY);
        
        ViewPort* view = cpointer().get_viewport();
-       view->viewport()->setCursor(QCursor(find_pixmap(":/cursorZoom")));
+       view->viewport()->setCursor(themer()->get_cursor("Zoom"));
        mousePos = QCursor::pos();      
 }
 

Index: core/Command.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Command.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- core/Command.cpp    13 Apr 2007 09:57:35 -0000      1.17
+++ core/Command.cpp    17 Apr 2007 11:51:20 -0000      1.18
@@ -17,13 +17,14 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: Command.cpp,v 1.17 2007/04/13 09:57:35 r_sijrier Exp $
+$Id: Command.cpp,v 1.18 2007/04/17 11:51:20 r_sijrier Exp $
 */
 
 #include "Command.h"
 #include "ContextPointer.h"
 #include <ViewPort.h>
 #include <Utils.h>
+#include <Themer.h>
 #include "ContextItem.h"
 
 // Always put me below _all_ includes, this is needed
@@ -258,11 +259,11 @@
        ViewPort* view = cpointer().get_viewport();
        
        if (useX && useY) {
-                
view->viewport()->setCursor(QCursor(find_pixmap(":/cursorHoldLrud")));
+                view->viewport()->setCursor(themer()->get_cursor("LRUD"));
        } else if (useX) {
-                
view->viewport()->setCursor(QCursor(find_pixmap(":/cursorHoldLr")));
+               view->viewport()->setCursor(themer()->get_cursor("LR"));
        } else if (useY) {
-                
view->viewport()->setCursor(QCursor(find_pixmap(":/cursorHoldUd")));
+               view->viewport()->setCursor(themer()->get_cursor("UD"));
        } else{
                view->reset_cursor();
        }

Index: core/ContextPointer.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ContextPointer.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- core/ContextPointer.cpp     16 Apr 2007 09:08:31 -0000      1.13
+++ core/ContextPointer.cpp     17 Apr 2007 11:51:20 -0000      1.14
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: ContextPointer.cpp,v 1.13 2007/04/16 09:08:31 r_sijrier Exp $
+$Id: ContextPointer.cpp,v 1.14 2007/04/17 11:51:20 r_sijrier Exp $
 */
 
 #include "ContextPointer.h"
@@ -25,6 +25,7 @@
 #include "Config.h"
 #include "InputEngine.h"
 #include "Utils.h"
+#include "Themer.h"
 
 
 // Always put me below _all_ includes, this is needed
@@ -159,7 +160,7 @@
 {
        if (currentViewPort) {
                currentViewPort->viewport()->releaseMouse();
-               
currentViewPort->setCursor(QCursor(find_pixmap(":/cursorFloat")));
+               currentViewPort->setCursor(themer()->get_cursor("Default"));
 
        }
        m_jogTimer.stop();

Index: core/core.pro
===================================================================
RCS file: /sources/traverso/traverso/src/core/core.pro,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- core/core.pro       2 Apr 2007 09:52:31 -0000       1.26
+++ core/core.pro       17 Apr 2007 11:51:20 -0000      1.27
@@ -48,7 +48,8 @@
        SnapList.cpp \
        Snappable.cpp \
        TimeLine.cpp \
-       Marker.cpp
+       Marker.cpp \
+       Themer.cpp
 HEADERS = precompile.h \
        AudioClip.h \
        AudioClipList.h \
@@ -91,7 +92,8 @@
        Snappable.h \
        CommandPlugin.h \
        TimeLine.h \
-       Marker.h
+       Marker.h \
+       Themer.h
 macx{
     QMAKE_LIBDIR += /usr/local/qt/lib
 }

Index: traverso/songcanvas/AudioClipView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- traverso/songcanvas/AudioClipView.cpp       16 Apr 2007 09:08:31 -0000      
1.41
+++ traverso/songcanvas/AudioClipView.cpp       17 Apr 2007 11:51:20 -0000      
1.42
@@ -42,7 +42,6 @@
 // in case we run with memory leak detection enabled!
 #include "Debugger.h"
 
-
 AudioClipView::AudioClipView(SongView* sv, TrackView* parent, AudioClip* clip )
        : ViewItem(parent, clip)
        , m_tv(parent)
@@ -91,7 +90,7 @@
        
 //     setFlags(ItemIsSelectable | ItemIsMovable);
        setAcceptsHoverEvents(true);
-       setCursor(QCursor(find_pixmap(":/cursorFloatOverClip")));
+       setCursor(themer()->get_cursor("AudioClip"));
 }
 
 AudioClipView::~ AudioClipView()
@@ -703,6 +702,7 @@
        m_recordingTimer.stop();
        prepareGeometryChange();
        m_boundingRect = QRectF(0, 0, (m_clip->get_length() / 
m_sv->scalefactor), m_height);
+       curveView->calculate_bounding_rect();
        update();
 }
 
@@ -718,7 +718,6 @@
        
        QRect updaterect = QRect(m_oldRecordingPos, 0, newPos, 
(int)m_boundingRect.height());
        update(updaterect);
-       
        m_oldRecordingPos = newPos;
 }
 
@@ -741,5 +740,5 @@
        m_dragging = dragging;
 }
 
-
 //eof
+

Index: traverso/songcanvas/AudioClipView.h
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- traverso/songcanvas/AudioClipView.h 11 Apr 2007 23:07:32 -0000      1.19
+++ traverso/songcanvas/AudioClipView.h 17 Apr 2007 11:51:20 -0000      1.20
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: AudioClipView.h,v 1.19 2007/04/11 23:07:32 r_sijrier Exp $
+$Id: AudioClipView.h,v 1.20 2007/04/17 11:51:20 r_sijrier Exp $
 */
 
 #ifndef AUDIO_CLIP_VIEW_H
@@ -107,7 +107,6 @@
        void draw_peaks(QPainter* painter, int xstart, int pixelcount);
        void start_peak_data_loading();
 
-       
        friend class FadeView;
 
 public slots:

Index: traverso/songcanvas/FadeView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/FadeView.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- traverso/songcanvas/FadeView.cpp    11 Apr 2007 15:56:35 -0000      1.13
+++ traverso/songcanvas/FadeView.cpp    17 Apr 2007 11:51:20 -0000      1.14
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: FadeView.cpp,v 1.13 2007/04/11 15:56:35 r_sijrier Exp $
+$Id: FadeView.cpp,v 1.14 2007/04/17 11:51:20 r_sijrier Exp $
 */
 
 #include "FadeView.h"
@@ -41,7 +41,6 @@
 static const int DOT_SIZE              = 6;
 static const QString DOT_COLOR         = "#78817B";
 
-
 FadeView::FadeView(SongView* sv, AudioClipView* parent, FadeCurve * fadeCurve )
        : ViewItem(parent, fadeCurve)
        , m_fadeCurve(fadeCurve)
@@ -62,7 +61,7 @@
        
        load_theme_data();
        setAcceptsHoverEvents(true);
-       setCursor(QCursor(find_pixmap(":/cursorFloatOverFade")));
+       setCursor(themer()->get_cursor("Fade"));
        
        connect(m_fadeCurve, SIGNAL(stateChanged()), this, 
SLOT(state_changed()));
        connect(m_fadeCurve, SIGNAL(rangeChanged()), this, 
SLOT(state_changed()));

Index: traverso/songcanvas/PluginView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/PluginView.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- traverso/songcanvas/PluginView.cpp  11 Apr 2007 15:58:46 -0000      1.12
+++ traverso/songcanvas/PluginView.cpp  17 Apr 2007 11:51:20 -0000      1.13
@@ -38,7 +38,6 @@
 // in case we run with memory leak detection enabled!
 #include "Debugger.h"
 
-
 PluginView::PluginView(TrackView* parent, Plugin* plugin, int index)
        : ViewItem(parent, plugin)
        , m_trackView(parent)
@@ -58,7 +57,7 @@
        m_boundingRect = QRectF(0, 0, 100, 25);
        
        setAcceptsHoverEvents(true);
-       setCursor(QCursor(find_pixmap(":/cursorFloatOverPlugin")));
+       setCursor(themer()->get_cursor("Plugin"));
 }
 
 PluginView::~PluginView( )
@@ -134,4 +133,5 @@
 {
        update();
 }
+
 //eof

Index: traverso/songcanvas/PluginView.h
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/PluginView.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- traverso/songcanvas/PluginView.h    31 Jan 2007 12:00:55 -0000      1.6
+++ traverso/songcanvas/PluginView.h    17 Apr 2007 11:51:20 -0000      1.7
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-    $Id: PluginView.h,v 1.6 2007/01/31 12:00:55 r_sijrier Exp $
+    $Id: PluginView.h,v 1.7 2007/04/17 11:51:20 r_sijrier Exp $
 */
 
 #ifndef PLUGIN_VIEW_H

Index: traverso/songcanvas/TrackPanelView.cpp
===================================================================
RCS file: 
/sources/traverso/traverso/src/traverso/songcanvas/TrackPanelView.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- traverso/songcanvas/TrackPanelView.cpp      11 Apr 2007 22:46:36 -0000      
1.20
+++ traverso/songcanvas/TrackPanelView.cpp      17 Apr 2007 11:51:20 -0000      
1.21
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: TrackPanelView.cpp,v 1.20 2007/04/11 22:46:36 r_sijrier Exp $
+$Id: TrackPanelView.cpp,v 1.21 2007/04/17 11:51:20 r_sijrier Exp $
 */
 
 #include <QGraphicsScene>
@@ -101,7 +101,7 @@
        
 //     setFlags(ItemIsSelectable | ItemIsMovable);
 //     setAcceptsHoverEvents(true);
-       setCursor(QCursor(find_pixmap(":/cursorFloatOverTrack")));
+       setCursor(themer()->get_cursor("Track"));
 }
 
 TrackPanelView::~TrackPanelView( )

Index: traverso/songcanvas/TrackView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/TrackView.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- traverso/songcanvas/TrackView.cpp   11 Apr 2007 15:56:35 -0000      1.26
+++ traverso/songcanvas/TrackView.cpp   17 Apr 2007 11:51:20 -0000      1.27
@@ -41,7 +41,6 @@
 
 #include <Debugger.h>
 
-
 TrackView::TrackView(SongView* sv, Track * track)
        : ViewItem(0, track)
 {
@@ -56,7 +55,7 @@
 
        m_track = track;
        setFlags(ItemIsSelectable | ItemIsMovable);
-       setCursor(QCursor(find_pixmap(":/cursorFloatOverTrack")));
+       setCursor(themer()->get_cursor("Track"));
 
        m_panel = new TrackPanelView(this);
        calculate_bounding_rect();
@@ -205,5 +204,5 @@
        return 0; 
 }
 
-
 //eof
+

Index: traverso/songcanvas/ViewItem.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/ViewItem.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- traverso/songcanvas/ViewItem.cpp    2 Feb 2007 09:47:21 -0000       1.3
+++ traverso/songcanvas/ViewItem.cpp    17 Apr 2007 11:51:20 -0000      1.4
@@ -17,15 +17,10 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: ViewItem.cpp,v 1.3 2007/02/02 09:47:21 r_sijrier Exp $
+$Id: ViewItem.cpp,v 1.4 2007/04/17 11:51:20 r_sijrier Exp $
 */
 
 
 #include "ViewItem.h"
 
-// Always put me below _all_ includes, this is needed
-// in case we run with memory leak detection enabled!
-#include "Debugger.h"
-
-
 //eof

Index: traverso/songcanvas/ViewItem.h
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/ViewItem.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- traverso/songcanvas/ViewItem.h      16 Apr 2007 09:08:31 -0000      1.15
+++ traverso/songcanvas/ViewItem.h      17 Apr 2007 11:51:20 -0000      1.16
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: ViewItem.h,v 1.15 2007/04/16 09:08:31 r_sijrier Exp $
+$Id: ViewItem.h,v 1.16 2007/04/17 11:51:20 r_sijrier Exp $
 */
 
 #ifndef VIEW_ITEM_H
@@ -29,7 +29,9 @@
 #include <QGraphicsItem>
 #include <QGraphicsSceneMouseEvent>
 #include <QStyleOptionGraphicsItem>
+#include <QCursor>
 #include <Utils.h>
+#include <Themer.h>
 
 class SongView;
                
@@ -44,6 +46,7 @@
 #define MAX_CANVAS_HEIGHT 107374182
 #endif
 
+
 class ViewItem : public ContextItem, public QGraphicsItem
 {
        Q_OBJECT
@@ -56,7 +59,7 @@
        {
                set_context_item(parentContext);
                m_parentViewItem = parentViewItem;
-               setCursor(QCursor(find_pixmap(":/cursorFloat")));
+               setCursor(themer()->get_cursor("Default"));
        }
        
        ~ViewItem() {};
@@ -87,7 +90,6 @@
        SongView*       m_sv;
        ViewItem*       m_parentViewItem;
        QRectF          m_boundingRect;
-       
 };
 
 inline QRectF ViewItem::boundingRect() const {return m_boundingRect;}

Index: traverso/traverso.pro
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/traverso.pro,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- traverso/traverso.pro       16 Apr 2007 18:44:26 -0000      1.43
+++ traverso/traverso.pro       17 Apr 2007 11:51:20 -0000      1.44
@@ -28,7 +28,6 @@
        AudioSourcesTreeWidget.h \
        BusMonitor.h \
        BusSelector.h \
-       Themer.h \
        ContextDialog.h \
        FadeContextDialog.h \
        Help.h \
@@ -62,7 +61,6 @@
        AudioSourcesTreeWidget.cpp \
        BusMonitor.cpp \
        BusSelector.cpp \
-       Themer.cpp \
        ContextDialog.cpp \
        FadeContextDialog.cpp \
        Help.cpp \

Index: core/Themer.cpp
===================================================================
RCS file: core/Themer.cpp
diff -N core/Themer.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ core/Themer.cpp     17 Apr 2007 11:51:20 -0000      1.1
@@ -0,0 +1,291 @@
+/*
+Copyright (C) 2005-2006 Remon Sijrier 
+
+This file is part of Traverso
+
+Traverso 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 St, Fifth Floor, Boston, MA  02110-1301  USA.
+
+$Id: Themer.cpp,v 1.1 2007/04/17 11:51:20 r_sijrier Exp $
+*/
+
+#include "Themer.h"
+
+#include <Utils.h>
+#include <Config.h>
+#include <QDir>
+#include <QTextStream>
+#include <QDomDocument>
+#include <QApplication>
+#include <QStyle>
+
+
+// Always put me below _all_ includes, this is needed
+// in case we run with memory leak detection enabled!
+#include "Debugger.h"
+
+Themer* Themer::m_instance = 0;
+
+Themer* themer()
+{
+       return Themer::instance();
+}
+
+Themer* Themer::instance()
+{
+       if (m_instance == 0) {
+               m_instance = new Themer();
+       }
+
+       return m_instance;
+}
+
+Themer::Themer()
+{
+       m_watcher = new QFileSystemWatcher(this);
+       QString themepath = config().get_property("Themer", "themepath", 
"").toString();
+       if (themepath.isEmpty()) {
+               themepath = ":/themes";
+       }
+       m_currentTheme = config().get_property("Themer", "currenttheme", 
"TraversoLight").toString();
+       
+       if (get_builtin_themes().contains(m_currentTheme)) {
+               themepath = ":/themes";
+       }
+
+       m_themefile =  themepath + "/" + m_currentTheme + "/traversotheme.xml";
+       m_coloradjust = -1;
+       
+       m_systempallete = QApplication::palette();
+       
+       QString style = config().get_property("Themer", "style", "").toString();
+       QString currentStyle = 
QString(QApplication::style()->metaObject()->className()).remove("Q").remove("Style");
+       if (style != currentStyle) {
+               QApplication::setStyle(style);
+       }
+       bool usestylepallete = config().get_property("Themer", 
"usestylepallet", "").toBool();
+       if (usestylepallete) {
+               
QApplication::setPalette(QApplication::style()->standardPalette());
+       }
+       
+       connect(m_watcher, SIGNAL(fileChanged(const QString&)), this, 
SLOT(reload_on_themefile_change(const QString&)));
+}
+
+
+void Themer::save( )
+{
+       QDomDocument doc("TraversoTheming");
+       QString fileName = QDir::homePath();
+       fileName +=  "/.traverso/themes/default.xml";
+       QFile data( fileName );
+
+       if (data.open( QIODevice::WriteOnly ) ) {
+               QDomElement colorManagerNode = doc.createElement("Themer");
+               doc.appendChild(colorManagerNode);
+
+               QHash<QString, QColor>::ConstIterator it = m_colors.begin();
+               while (it != m_colors.end()) {
+                       QColor color = it.value();
+                       QDomElement colorProperty = doc.createElement("color");
+                       colorProperty.setAttribute("red", color.red());
+                       colorProperty.setAttribute("green", color.green());
+                       colorProperty.setAttribute("blue", color.blue());
+                       colorProperty.setAttribute("alpha", color.alpha() );
+                       colorProperty.setAttribute("name", it.key() );
+                       QVariant v;
+                       v = color;
+                       colorProperty.setAttribute("color", color.name());
+                       ++it;
+                       colorManagerNode.appendChild(colorProperty);
+               }
+
+               QTextStream stream(&data);
+               doc.save(stream, 4);
+               data.close();
+       } else {
+               PWARN("Could not open Themer properties file for writing! 
(%s)", QS_C(fileName));
+       }
+}
+
+void Themer::load( )
+{
+       QDomDocument doc("TraversoTheming");
+       
+       QFile file(m_themefile);
+       
+       if ( ! file.exists() ) {
+               printf("File %s doesn't exit, falling back to default 
(TraversoLight) theme\n", QS_C(m_themefile));
+               file.setFileName(":/themes/TraversoLight/traversotheme.xml");
+       } else {
+               m_watcher->addPath(m_themefile);
+               printf("Using themefile: %s\n", QS_C(m_themefile));
+       }
+
+       if (!file.open(QIODevice::ReadOnly)) {
+               PWARN("Cannot open Themer properties file");
+       }
+
+       QString errorMsg;
+       if (!doc.setContent(&file, &errorMsg)) {
+               file.close();
+               PWARN("Cannot set Content of XML file (%s)", QS_C(errorMsg));
+       }
+
+       file.close();
+
+       QDomElement docElem = doc.documentElement();
+
+       QDomNode colorsNode = docElem.firstChildElement("colors");
+       QDomNode colorNode = colorsNode.firstChild();
+       
+       int coloradjust = config().get_property("Themer", "coloradjust", 
100).toInt();
+       
+       // If the m_coloradjust value is set, use that one instead!
+       if (m_coloradjust != -1) {
+               coloradjust = m_coloradjust;
+       }
+
+       while(!colorNode.isNull()) {
+               
+               QDomElement e = colorNode.toElement();
+               
+               QColor color(
+                       e.attribute("red").toUInt(),
+                       e.attribute("green").toUInt(), 
+                       e.attribute("blue").toUInt(), 
+                       e.attribute("alpha").toInt()
+                       );
+               QString name = e.attribute("name", "");
+               
+               if (coloradjust != 100) {
+                       int adjust = coloradjust - 100;
+                       if (adjust < 0) {
+                               color = color.dark(-1 * adjust + 100);
+                       } else {
+                               color = color.light(adjust + 100);
+                       }
+               }
+               m_colors.insert(name, color);
+               colorNode = colorNode.nextSibling();
+       }
+               
+               
+       QDomNode fontsNode = docElem.firstChildElement("fonts");
+       QDomNode fontNode = fontsNode.firstChild();
+       
+       while (!fontNode.isNull()) {
+               
+               QDomElement e = fontNode.toElement();
+               
+               QString family = e.attribute("family", "");
+               int size = e.attribute("size", "").toInt();
+               QString name = e.attribute("name", "");
+               QFont font(family, size);
+               
+               m_fonts.insert(name, font);
+               fontNode = fontNode.nextSibling();
+       }
+               
+       
+       QDomNode propertiesNode = docElem.firstChildElement("properties");
+       QDomNode propertyNode = propertiesNode.firstChild();
+       
+       while (!propertyNode.isNull()) {
+               
+               QDomElement e = propertyNode.toElement();
+               
+               QString name = e.attribute("name", "");
+               QVariant value = e.attribute("value", "");
+               
+               m_properties.insert(name, value);
+               propertyNode = propertyNode.nextSibling();
+       }
+       
+       m_cursors.clear();
+       m_cursors.insert("AudioClip", 
QCursor(find_pixmap(":/cursorFloatOverClip")));
+       m_cursors.insert("Track", 
QCursor(find_pixmap(":/cursorFloatOverTrack")));
+       m_cursors.insert("Plugin", 
QCursor(find_pixmap(":/cursorFloatOverPlugin")));
+       m_cursors.insert("Fade", QCursor(find_pixmap(":/cursorFloatOverFade")));
+       m_cursors.insert("Default", QCursor(find_pixmap(":/cursorFloat")));
+       m_cursors.insert("Zoom", QCursor(find_pixmap(":/cursorZoom")));
+       
+       m_cursors.insert("LRUD", QCursor(find_pixmap(":/cursorHoldLrud")));
+       m_cursors.insert("LR", QCursor(find_pixmap(":/cursorHoldLr")));
+       m_cursors.insert("UD", QCursor(find_pixmap(":/cursorHoldUd")));
+       emit themeLoaded();
+}
+
+QColor Themer::get_color(const QString& name) const
+{
+       return m_colors.value(name);
+}
+
+QFont Themer::get_font(const QString& fontname) const
+{
+       return m_fonts.value(fontname);
+}
+
+QVariant Themer::get_property(const QString& propertyname, const QVariant& 
defaultValue) const
+{
+       return m_properties.value(propertyname, defaultValue);
+}
+
+QCursor Themer::get_cursor(const QString & name) const
+{
+       return m_cursors.value(name);
+}
+
+void Themer::reload_on_themefile_change(const QString&)
+{
+       m_colors.clear();
+       m_fonts.clear();
+       m_properties.clear();
+       load();
+}
+
+void Themer::set_path_and_theme(const QString& path, const QString& theme)
+{
+       if (m_currentTheme == theme) {
+               return;
+       }
+       m_currentTheme = theme;
+       m_themefile = path + "/" + theme + "/traversotheme.xml";
+       reload_on_themefile_change("");
+}
+
+void Themer::set_color_adjust_value(int value)
+{
+       m_coloradjust = value;
+       reload_on_themefile_change("");
+}
+
+QStringList Themer::get_builtin_themes()
+{
+       QStringList list;
+       list << "TraversoLight";
+       return list;
+}
+
+void Themer::use_builtin_theme(const QString & theme)
+{
+       if (m_currentTheme == theme) {
+               return;
+       }
+       
+       m_currentTheme = theme;
+       m_themefile = QString(":/themes/") + theme + "/traversotheme.xml";;
+       reload_on_themefile_change("");
+}
+
+//eof

Index: core/Themer.h
===================================================================
RCS file: core/Themer.h
diff -N core/Themer.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ core/Themer.h       17 Apr 2007 11:51:20 -0000      1.1
@@ -0,0 +1,83 @@
+/*
+    Copyright (C) 2005-2006 Remon Sijrier 
+ 
+    This file is part of Traverso
+ 
+    Traverso 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 St, Fifth Floor, Boston, MA  02110-1301  USA.
+ 
+    $Id: Themer.h,v 1.1 2007/04/17 11:51:20 r_sijrier Exp $
+*/
+
+#ifndef COLORMANAGER_H
+#define COLORMANAGER_H
+
+#include <QObject>
+#include <QColor>
+#include <QFont>
+#include <QHash>
+#include <QCursor>
+#include <QString>
+#include <QFileSystemWatcher>
+#include <QVariant>
+#include <QPalette>
+
+class Themer : public QObject
+{
+       Q_OBJECT
+public:
+        void save();
+        void load();
+        
+        void set_path_and_theme(const QString& path, const QString& theme);
+       void use_builtin_theme(const QString& theme);
+       void set_color_adjust_value(int value);
+        
+       QColor get_color(const QString& name) const;
+        QFont get_font(const QString& fontname) const;
+        QVariant get_property(const QString& propertyname, const QVariant& 
defaultValue=0) const;
+       QPalette system_palette() const {return m_systempallete;}
+       QStringList get_builtin_themes();
+       QCursor get_cursor(const QString& name) const;
+
+       static Themer* instance();
+       
+private:
+        Themer();
+
+        QHash<QString, QColor>  m_colors;
+       QHash<QString, QVariant> m_properties;
+       QHash<QString, QFont>   m_fonts;
+       QHash<QString, QCursor> m_cursors;
+       QFileSystemWatcher*     m_watcher;
+        QString                        m_themefile;
+       int                     m_coloradjust;
+       QPalette                m_systempallete;
+       QString                 m_currentTheme;
+
+       static Themer* m_instance;
+        
+       
+private slots:
+       void reload_on_themefile_change(const QString&);
+       
+signals:
+       void themeLoaded();
+};
+
+// use this function to get the Colormanager object
+Themer* themer();
+
+#endif
+

Index: traverso/Themer.cpp
===================================================================
RCS file: traverso/Themer.cpp
diff -N traverso/Themer.cpp
--- traverso/Themer.cpp 16 Mar 2007 00:10:26 -0000      1.6
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,280 +0,0 @@
-/*
-Copyright (C) 2005-2006 Remon Sijrier 
-
-This file is part of Traverso
-
-Traverso 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 St, Fifth Floor, Boston, MA  02110-1301  USA.
-
-$Id: Themer.cpp,v 1.6 2007/03/16 00:10:26 r_sijrier Exp $
-*/
-
-#include "Themer.h"
-
-#include <Utils.h>
-#include <Config.h>
-#include <QDir>
-#include <QTextStream>
-#include <QDomDocument>
-#include <QApplication>
-#include <QStyle>
-
-
-// Always put me below _all_ includes, this is needed
-// in case we run with memory leak detection enabled!
-#include "Debugger.h"
-
-Themer* Themer::m_instance = 0;
-
-Themer* themer()
-{
-       return Themer::instance();
-}
-
-Themer* Themer::instance()
-{
-       if (m_instance == 0) {
-               m_instance = new Themer();
-       }
-
-       return m_instance;
-}
-
-Themer::Themer()
-{
-       m_watcher = new QFileSystemWatcher(this);
-       QString themepath = config().get_property("Themer", "themepath", 
"").toString();
-       if (themepath.isEmpty()) {
-               themepath = ":/themes";
-       }
-       m_currentTheme = config().get_property("Themer", "currenttheme", 
"TraversoLight").toString();
-       
-       if (get_builtin_themes().contains(m_currentTheme)) {
-               themepath = ":/themes";
-       }
-
-       m_themefile =  themepath + "/" + m_currentTheme + "/traversotheme.xml";
-       m_coloradjust = -1;
-       
-       m_systempallete = QApplication::palette();
-       
-       QString style = config().get_property("Themer", "style", "").toString();
-       QString currentStyle = 
QString(QApplication::style()->metaObject()->className()).remove("Q").remove("Style");
-       if (style != currentStyle) {
-               QApplication::setStyle(style);
-       }
-       bool usestylepallete = config().get_property("Themer", 
"usestylepallet", "").toBool();
-       if (usestylepallete) {
-               
QApplication::setPalette(QApplication::style()->standardPalette());
-       }
-       
-       connect(m_watcher, SIGNAL(fileChanged(const QString&)), this, 
SLOT(reload_on_themefile_change(const QString&)));
-}
-
-
-void Themer::save( )
-{
-       QDomDocument doc("TraversoTheming");
-       QString fileName = QDir::homePath();
-       fileName +=  "/.traverso/themes/default.xml";
-       QFile data( fileName );
-
-       if (data.open( QIODevice::WriteOnly ) ) {
-               QDomElement colorManagerNode = doc.createElement("Themer");
-               doc.appendChild(colorManagerNode);
-
-               QHash<QString, QColor>::ConstIterator it = m_colors.begin();
-               while (it != m_colors.end()) {
-                       QColor color = it.value();
-                       QDomElement colorProperty = doc.createElement("color");
-                       colorProperty.setAttribute("red", color.red());
-                       colorProperty.setAttribute("green", color.green());
-                       colorProperty.setAttribute("blue", color.blue());
-                       colorProperty.setAttribute("alpha", color.alpha() );
-                       colorProperty.setAttribute("name", it.key() );
-                       QVariant v;
-                       v = color;
-                       colorProperty.setAttribute("color", color.name());
-                       ++it;
-                       colorManagerNode.appendChild(colorProperty);
-               }
-
-               QTextStream stream(&data);
-               doc.save(stream, 4);
-               data.close();
-       } else {
-               PWARN("Could not open Themer properties file for writing! 
(%s)", QS_C(fileName));
-       }
-}
-
-void Themer::load( )
-{
-       QDomDocument doc("TraversoTheming");
-       
-       QFile file(m_themefile);
-       
-       if ( ! file.exists() ) {
-               printf("File %s doesn't exit, falling back to default 
(TraversoLight) theme\n", QS_C(m_themefile));
-               file.setFileName(":/themes/TraversoLight/traversotheme.xml");
-       } else {
-               m_watcher->addPath(m_themefile);
-               printf("Using themefile: %s\n", QS_C(m_themefile));
-       }
-
-       if (!file.open(QIODevice::ReadOnly)) {
-               PWARN("Cannot open Themer properties file");
-       }
-
-       QString errorMsg;
-       if (!doc.setContent(&file, &errorMsg)) {
-               file.close();
-               PWARN("Cannot set Content of XML file (%s)", QS_C(errorMsg));
-       }
-
-       file.close();
-
-       QDomElement docElem = doc.documentElement();
-
-       QDomNode colorsNode = docElem.firstChildElement("colors");
-       QDomNode colorNode = colorsNode.firstChild();
-       
-       int coloradjust = config().get_property("Themer", "coloradjust", 
100).toInt();
-       
-       // If the m_coloradjust value is set, use that one instead!
-       if (m_coloradjust != -1) {
-               coloradjust = m_coloradjust;
-       }
-
-       while(!colorNode.isNull()) {
-               
-               QDomElement e = colorNode.toElement();
-               
-               QColor color(
-                       e.attribute("red").toUInt(),
-                       e.attribute("green").toUInt(), 
-                       e.attribute("blue").toUInt(), 
-                       e.attribute("alpha").toInt()
-                       );
-               QString name = e.attribute("name", "");
-               
-               if (coloradjust != 100) {
-                       int adjust = coloradjust - 100;
-                       if (adjust < 0) {
-                               color = color.dark(-1 * adjust + 100);
-                       } else {
-                               color = color.light(adjust + 100);
-                       }
-               }
-               m_colors.insert(name, color);
-               colorNode = colorNode.nextSibling();
-       }
-               
-               
-       QDomNode fontsNode = docElem.firstChildElement("fonts");
-       QDomNode fontNode = fontsNode.firstChild();
-       
-       while (!fontNode.isNull()) {
-               
-               QDomElement e = fontNode.toElement();
-               
-               QString family = e.attribute("family", "");
-               int size = e.attribute("size", "").toInt();
-               QString name = e.attribute("name", "");
-               QFont font(family, size);
-               
-               m_fonts.insert(name, font);
-               fontNode = fontNode.nextSibling();
-       }
-               
-       
-       QDomNode propertiesNode = docElem.firstChildElement("properties");
-       QDomNode propertyNode = propertiesNode.firstChild();
-       
-       while (!propertyNode.isNull()) {
-               
-               QDomElement e = propertyNode.toElement();
-               
-               QString name = e.attribute("name", "");
-               QVariant value = e.attribute("value", "");
-               
-               m_properties.insert(name, value);
-               propertyNode = propertyNode.nextSibling();
-       }
-       
-       
-       emit themeLoaded();
-}
-
-
-QColor Themer::get_color(const QString& name) const
-{
-       return m_colors.value(name);
-}
-
-
-QFont Themer::get_font(const QString& fontname) const
-{
-       return m_fonts.value(fontname);
-}
-
-
-QVariant Themer::get_property(const QString& propertyname, const QVariant& 
defaultValue) const
-{
-       return m_properties.value(propertyname, defaultValue);
-}
-
-
-void Themer::reload_on_themefile_change(const QString&)
-{
-       m_colors.clear();
-       m_fonts.clear();
-       m_properties.clear();
-       load();
-}
-
-
-void Themer::set_path_and_theme(const QString& path, const QString& theme)
-{
-       if (m_currentTheme == theme) {
-               return;
-       }
-       m_currentTheme = theme;
-       m_themefile = path + "/" + theme + "/traversotheme.xml";
-       reload_on_themefile_change("");
-}
-
-void Themer::set_color_adjust_value(int value)
-{
-       m_coloradjust = value;
-       reload_on_themefile_change("");
-}
-
-QStringList Themer::get_builtin_themes()
-{
-       QStringList list;
-       list << "TraversoLight";
-       return list;
-}
-
-void Themer::use_builtin_theme(const QString & theme)
-{
-       if (m_currentTheme == theme) {
-               return;
-       }
-       
-       m_currentTheme = theme;
-       m_themefile = QString(":/themes/") + theme + "/traversotheme.xml";;
-       reload_on_themefile_change("");
-}
-

Index: traverso/Themer.h
===================================================================
RCS file: traverso/Themer.h
diff -N traverso/Themer.h
--- traverso/Themer.h   16 Mar 2007 00:10:26 -0000      1.4
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,80 +0,0 @@
-/*
-    Copyright (C) 2005-2006 Remon Sijrier 
- 
-    This file is part of Traverso
- 
-    Traverso 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 St, Fifth Floor, Boston, MA  02110-1301  USA.
- 
-    $Id: Themer.h,v 1.4 2007/03/16 00:10:26 r_sijrier Exp $
-*/
-
-#ifndef COLORMANAGER_H
-#define COLORMANAGER_H
-
-#include <QObject>
-#include <QColor>
-#include <QFont>
-#include <QHash>
-#include <QString>
-#include <QFileSystemWatcher>
-#include <QVariant>
-#include <QPalette>
-
-class Themer : public QObject
-{
-       Q_OBJECT
-public:
-        void save();
-        void load();
-        
-        void set_path_and_theme(const QString& path, const QString& theme);
-       void use_builtin_theme(const QString& theme);
-       void set_color_adjust_value(int value);
-        
-       QColor get_color(const QString& name) const;
-        QFont get_font(const QString& fontname) const;
-        QVariant get_property(const QString& propertyname, const QVariant& 
defaultValue=0) const;
-       QPalette system_palette() const {return m_systempallete;}
-       QStringList get_builtin_themes();
-
-       static Themer* instance();
-       
-private:
-        Themer();
-
-        QHash<QString , QColor>         m_colors;
-       QHash<QString, QVariant> m_properties;
-       QHash<QString, QFont>   m_fonts;
-       QFileSystemWatcher*     m_watcher;
-        QString                        m_themefile;
-       int                     m_coloradjust;
-       QPalette                m_systempallete;
-       QString                 m_currentTheme;
-
-       static Themer* m_instance;
-        
-       
-private slots:
-       void reload_on_themefile_change(const QString&);
-       
-signals:
-       void themeLoaded();
-};
-
-// use this function to get the Colormanager object
-Themer* themer();
-
-#endif
-




reply via email to

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