Merge lp:~mixxxdevelopers/mixxx/features_promo into lp:~mixxxdevelopers/mixxx/trunk
- features_promo
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~mixxxdevelopers/mixxx/features_promo |
Merge into: | lp:~mixxxdevelopers/mixxx/trunk |
Diff against target: |
802 lines (+501/-21) 14 files modified
mixxx/build/qt4.py (+1/-0) mixxx/src/SConscript (+8/-2) mixxx/src/library/library.cpp (+32/-7) mixxx/src/library/library.h (+5/-1) mixxx/src/library/promotracksfeature.cpp (+140/-0) mixxx/src/library/promotracksfeature.h (+75/-0) mixxx/src/library/promotrackswebview.cpp (+124/-0) mixxx/src/library/promotrackswebview.h (+62/-0) mixxx/src/library/sidebarmodel.cpp (+9/-4) mixxx/src/library/sidebarmodel.h (+2/-0) mixxx/src/mixxx.cpp (+17/-3) mixxx/src/upgrade.cpp (+14/-2) mixxx/src/upgrade.h (+10/-1) mixxx/src/widget/wlibrary.cpp (+2/-1) |
To merge this branch: | bzr merge lp:~mixxxdevelopers/mixxx/features_promo |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Santoni | Pending | ||
Review via email: mp+18501@code.launchpad.net |
This proposal supersedes a proposal from 2010-02-03.
Commit message
Description of the change
Albert Santoni (gamegod) wrote : Posted in a previous version of this proposal | # |
RJ Skerry-Ryan (rryan) wrote : Posted in a previous version of this proposal | # |
Yea Launchpad is weird like this with regenerating diffs. I think the old merge proposal updated. The feature looks good -- I have a couple comments:
- The local and remote URL strings have 1.8.0~1 written into them. Can you use
defs_version.h and automatically generate that?
- You add getTracksToAuto
PromoTracksFe
constructor. Ideally we would have a static createDefaultLi
something so that the constructor for Library does not add its own features. I
can see that you had to add the PromoTracksFeature into the Library in order
to insert it at the right position. Also, you needed to know the right index
to set the default sidebar model thing.
Ideally, MixxxApp would create the PromoTracksFeature and use it
directly.. also the firstLoad thing is only used in MixxxApp directly
following the library construction. There should be some external way
to set the default feature to load (maybe a default false argument to
addFeature). Someday we should fix that, but for today it seems fine
to add getTracksToAuto
- Can you remove the 'Created by' and 'FORK FORK FORK' messages from the top of
the files? They aren't accurate :).
Albert Santoni (gamegod) wrote : Posted in a previous version of this proposal | # |
On Tue, Feb 2, 2010 at 8:25 PM, RJ Ryan <email address hidden> wrote:
> Review: Approve
> Yea Launchpad is weird like this with regenerating diffs. I think the old merge proposal updated. The feature looks good -- I have a couple comments:
>
> - The local and remote URL strings have 1.8.0~1 written into them. Can you use
> defs_version.h and automatically generate that?
Fixed
>
> - You add getTracksToAuto
> PromoTracksFeature and a 'firstRun' bool parameter to the Library
> constructor. Ideally we would have a static createDefaultLi
> something so that the constructor for Library does not add its own features. I
> can see that you had to add the PromoTracksFeature into the Library in order
> to insert it at the right position. Also, you needed to know the right index
> to set the default sidebar model thing.
>
> Ideally, MixxxApp would create the PromoTracksFeature and use it
> directly.. also the firstLoad thing is only used in MixxxApp directly
> following the library construction. There should be some external way
> to set the default feature to load (maybe a default false argument to
> addFeature). Someday we should fix that, but for today it seems fine
> to add getTracksToAuto
Agreed, we can refactor this at some point.
>
> - Can you remove the 'Created by' and 'FORK FORK FORK' messages from the top of
> the files? They aren't accurate :).
>
>
Updated the copyright headers on those files...
Thanks for the speedy review!
Albert
- 2264. By Albert Santoni
-
* As per RJ's code review:
* Fixed hardcoded version strings in promo URLs
* Added copyright header to promo tracks files - 2265. By Albert Santoni
-
Merge updates from trunk
Preview Diff
1 | === modified file 'mixxx/build/qt4.py' |
2 | --- mixxx/build/qt4.py 2009-08-17 20:28:30 +0000 |
3 | +++ mixxx/build/qt4.py 2010-02-03 05:15:24 +0000 |
4 | @@ -386,6 +386,7 @@ |
5 | 'QtDesigner', |
6 | 'QtDBUS', |
7 | 'QtScript', |
8 | + 'QtWebKit', |
9 | 'QtXmlPatterns' |
10 | ] |
11 | pclessModules = [ |
12 | |
13 | === added directory 'mixxx/res/promo' |
14 | === modified file 'mixxx/src/SConscript' |
15 | --- mixxx/src/SConscript 2010-01-29 19:38:32 +0000 |
16 | +++ mixxx/src/SConscript 2010-02-03 05:15:24 +0000 |
17 | @@ -425,6 +425,8 @@ |
18 | library/dao/settingsdao.cpp |
19 | library/librarymidicontrol.cpp |
20 | library/schemamanager.cpp |
21 | + library/promotracksfeature.cpp |
22 | + library/promotrackswebview.cpp |
23 | |
24 | xmlparse.cpp |
25 | parser.cpp |
26 | @@ -652,7 +654,8 @@ |
27 | 'QtSvg', |
28 | 'QtSql', |
29 | 'QtScript', |
30 | - 'QtXmlPatterns' |
31 | + 'QtXmlPatterns', |
32 | + 'QtWebKit' |
33 | #'QtUiTools', |
34 | #'QtDesigner', |
35 | #'QtWebKit', |
36 | @@ -671,13 +674,14 @@ |
37 | env.Append(LINKFLAGS='-framework OpenGL') |
38 | |
39 | #QT4 |
40 | - env.Append(LINKFLAGS = '-framework QtCore -framework QtOpenGL -framework Qt3Support -framework QtGui -framework QtSql -framework QtXml -framework QtXmlPatterns -framework QtNetwork -framework QtSql -framework QtScript') |
41 | + env.Append(LINKFLAGS = '-framework QtCore -framework QtOpenGL -framework Qt3Support -framework QtGui -framework QtSql -framework QtXml -framework QtXmlPatterns -framework QtNetwork -framework QtSql -framework QtScript -framework QtWebKit') |
42 | env.Append(CPPPATH = ['/Library/Frameworks/QtCore.framework/Headers/', |
43 | '/Library/Frameworks/QtOpenGL.framework/Headers/', |
44 | '/Library/Frameworks/Qt3Support.framework/Headers/', |
45 | '/Library/Frameworks/QtGui.framework/Headers/', |
46 | '/Library/Frameworks/QtXml.framework/Headers/', |
47 | '/Library/Frameworks/QtSql.framework/Headers/', |
48 | + '/Library/Frameworks/QtWebKit.framework/Headers/', |
49 | '/Library/Frameworks/QtScript.framework/Headers/']) |
50 | |
51 | #Non-standard libpaths for fink and darwin ports |
52 | @@ -741,6 +745,7 @@ |
53 | env.Append(LIBS = 'QtGui') |
54 | env.Append(LIBS = 'QtCore') |
55 | env.Append(LIBS = 'QtOpenGL') |
56 | + env.Append(LIBS = 'QtWebKit') |
57 | env.Append(LIBS = 'QtScript') |
58 | env.Append(LIBS = 'sndfile') #? we shouldn't have to do this... |
59 | env.Append(LIBS = 'vorbisfile') #? we shouldn't have to do this... |
60 | @@ -752,6 +757,7 @@ |
61 | env.Append(LIBS = 'QtSql4'); |
62 | env.Append(LIBS = 'QtGui4'); |
63 | env.Append(LIBS = 'QtCore4'); |
64 | + env.Append(LIBS = 'QtWebKit4'); |
65 | env.Append(LIBS = 'QtOpenGL4'); |
66 | env.Append(LIBS = 'WinMM'); #Needed for Midi stuff |
67 | env.Append(LIBS = 'ogg_static') |
68 | |
69 | === modified file 'mixxx/src/library/library.cpp' |
70 | --- mixxx/src/library/library.cpp 2010-01-31 09:15:16 +0000 |
71 | +++ mixxx/src/library/library.cpp 2010-02-03 05:15:24 +0000 |
72 | @@ -18,6 +18,7 @@ |
73 | #include "library/autodjfeature.h" |
74 | #include "library/playlistfeature.h" |
75 | #include "library/preparefeature.h" |
76 | +#include "library/promotracksfeature.h" |
77 | |
78 | #include "wtracktableview.h" |
79 | #include "widget/wlibrary.h" |
80 | @@ -29,15 +30,30 @@ |
81 | // WLibrary |
82 | const QString Library::m_sTrackViewName = QString("WTrackTableView"); |
83 | |
84 | -Library::Library(QObject* parent, ConfigObject<ConfigValue>* pConfig) |
85 | +Library::Library(QObject* parent, ConfigObject<ConfigValue>* pConfig, bool firstRun) |
86 | : m_pConfig(pConfig) { |
87 | m_pTrackCollection = new TrackCollection(pConfig); |
88 | m_pSidebarModel = new SidebarModel(parent); |
89 | m_pLibraryMIDIControl = NULL; //Initialized in bindWidgets |
90 | + |
91 | + //Show the promo tracks view on first run, otherwise show the library |
92 | + if (firstRun) { |
93 | + qDebug() << "First Run, switching to PROMO view!"; |
94 | + m_pSidebarModel->setDefaultSelection(1); |
95 | + //Note the promo tracks item has index=1... hardcoded hack. :/ |
96 | + } |
97 | + |
98 | // TODO(rryan) -- turn this construction / adding of features into a static |
99 | // method or something -- CreateDefaultLibrary |
100 | m_pMixxxLibraryFeature = new MixxxLibraryFeature(this, m_pTrackCollection); |
101 | addFeature(m_pMixxxLibraryFeature); |
102 | + if(PromoTracksFeature::isSupported(m_pConfig)) { |
103 | + m_pPromoTracksFeature = new PromoTracksFeature(this, pConfig, |
104 | + m_pTrackCollection); |
105 | + addFeature(m_pPromoTracksFeature); |
106 | + } |
107 | + else |
108 | + m_pPromoTracksFeature = NULL; |
109 | addFeature(new AutoDJFeature(this, pConfig, m_pTrackCollection)); |
110 | m_pPlaylistFeature = new PlaylistFeature(this, m_pTrackCollection); |
111 | addFeature(m_pPlaylistFeature); |
112 | @@ -81,7 +97,7 @@ |
113 | |
114 | connect(this, SIGNAL(switchToView(const QString&)), |
115 | pLibraryWidget, SLOT(switchToView(const QString&))); |
116 | - |
117 | + |
118 | m_pLibraryMIDIControl = new LibraryMIDIControl(pLibraryWidget, pSidebarWidget); |
119 | |
120 | // Setup the sources view |
121 | @@ -90,6 +106,12 @@ |
122 | m_pSidebarModel, SLOT(clicked(const QModelIndex&))); |
123 | connect(pSidebarWidget, SIGNAL(rightClicked(const QPoint&, const QModelIndex&)), |
124 | m_pSidebarModel, SLOT(rightClicked(const QPoint&, const QModelIndex&))); |
125 | + |
126 | + QListIterator<LibraryFeature*> feature_it(m_features); |
127 | + while(feature_it.hasNext()) { |
128 | + LibraryFeature* feature = feature_it.next(); |
129 | + feature->bindWidget(pSidebarWidget, pLibraryWidget); |
130 | + } |
131 | |
132 | // Enable the default selection |
133 | pSidebarWidget->selectionModel() |
134 | @@ -97,11 +119,6 @@ |
135 | QItemSelectionModel::SelectCurrent); |
136 | m_pSidebarModel->activateDefaultSelection(); |
137 | |
138 | - QListIterator<LibraryFeature*> feature_it(m_features); |
139 | - while(feature_it.hasNext()) { |
140 | - LibraryFeature* feature = feature_it.next(); |
141 | - feature->bindWidget(pSidebarWidget, pLibraryWidget); |
142 | - } |
143 | } |
144 | |
145 | void Library::addFeature(LibraryFeature* feature) { |
146 | @@ -155,3 +172,11 @@ |
147 | { |
148 | m_pPlaylistFeature->slotCreatePlaylist(); |
149 | } |
150 | + |
151 | +QList<TrackInfoObject*> Library::getTracksToAutoLoad() |
152 | +{ |
153 | + if (m_pPromoTracksFeature) |
154 | + return m_pPromoTracksFeature->getTracksToAutoLoad(); |
155 | + else |
156 | + return QList<TrackInfoObject*>(); |
157 | +} |
158 | |
159 | === modified file 'mixxx/src/library/library.h' |
160 | --- mixxx/src/library/library.h 2009-12-30 23:56:16 +0000 |
161 | +++ mixxx/src/library/library.h 2010-02-03 05:15:24 +0000 |
162 | @@ -23,6 +23,7 @@ |
163 | class WLibrary; |
164 | class WSearchLineEdit; |
165 | class MixxxLibraryFeature; |
166 | +class PromoTracksFeature; |
167 | class PlaylistFeature; |
168 | class LibraryMIDIControl; |
169 | |
170 | @@ -30,12 +31,14 @@ |
171 | Q_OBJECT |
172 | public: |
173 | Library(QObject* parent, |
174 | - ConfigObject<ConfigValue>* pConfig); |
175 | + ConfigObject<ConfigValue>* pConfig, |
176 | + bool firstRun); |
177 | virtual ~Library(); |
178 | |
179 | void bindWidget(WLibrarySidebar* sidebarWidget, |
180 | WLibrary* libraryWidget); |
181 | void addFeature(LibraryFeature* feature); |
182 | + QList<TrackInfoObject*> getTracksToAutoLoad(); |
183 | |
184 | // TODO(rryan) Transitionary only -- the only reason this is here is so the |
185 | // waveform widgets can signal to a player to load a track. This can be |
186 | @@ -71,6 +74,7 @@ |
187 | const static QString m_sAutoDJViewName; |
188 | MixxxLibraryFeature* m_pMixxxLibraryFeature; |
189 | PlaylistFeature* m_pPlaylistFeature; |
190 | + PromoTracksFeature* m_pPromoTracksFeature; |
191 | LibraryMIDIControl* m_pLibraryMIDIControl; |
192 | }; |
193 | |
194 | |
195 | === added file 'mixxx/src/library/promotracksfeature.cpp' |
196 | --- mixxx/src/library/promotracksfeature.cpp 1970-01-01 00:00:00 +0000 |
197 | +++ mixxx/src/library/promotracksfeature.cpp 2010-02-03 05:15:24 +0000 |
198 | @@ -0,0 +1,140 @@ |
199 | +/*************************************************************************** |
200 | + promotracksfeature.cpp |
201 | + ------------------- |
202 | + begin : Jan 2010 |
203 | + copyright : (C) 2010 Albert Santoni |
204 | + email : alberts@mixxx.org |
205 | +***************************************************************************/ |
206 | + |
207 | +/*************************************************************************** |
208 | +* * |
209 | +* This program is free software; you can redistribute it and/or modify * |
210 | +* it under the terms of the GNU General Public License as published by * |
211 | +* the Free Software Foundation; either version 2 of the License, or * |
212 | +* (at your option) any later version. * |
213 | +* * |
214 | +***************************************************************************/ |
215 | + |
216 | +#include <QtDebug> |
217 | + |
218 | +#include "library/promotracksfeature.h" |
219 | +#include "library/promotrackswebview.h" |
220 | +#include "library/proxytrackmodel.h" |
221 | +#include "library/trackcollection.h" |
222 | +#include "trackinfoobject.h" |
223 | +#include "defs_version.h" |
224 | +#include "widget/wlibrary.h" |
225 | +#include "widget/wlibrarysidebar.h" |
226 | + |
227 | +const QString PromoTracksFeature::m_sPromoTracksViewName = tr("Featured Artists"); |
228 | +QString PromoTracksFeature::m_sPromoLocalHTMLLocation; |
229 | +QString PromoTracksFeature::m_sPromoRemoteHTMLLocation; |
230 | +#define LOCAL_HTML_LOCATION (config->getConfigPath() + "/promo/" + VERSION + "/index.html") |
231 | + |
232 | +PromoTracksFeature::PromoTracksFeature(QObject* parent, |
233 | + ConfigObject<ConfigValue>* config, |
234 | + TrackCollection* pTrackCollection) |
235 | + : LibraryFeature(parent), |
236 | + m_pConfig(config), |
237 | + m_pPromoTracksView(NULL), |
238 | + m_pTrackCollection(pTrackCollection) { |
239 | + |
240 | + m_sPromoRemoteHTMLLocation = QString("http://promo.mixxx.org/%1/index.html").arg(VERSION); //m_pConfig->getConfigPath() + "/promo/promotracks.html"; |
241 | + m_sPromoLocalHTMLLocation = LOCAL_HTML_LOCATION; |
242 | + m_sPromoAutoloadLocation = m_pConfig->getConfigPath() + "/promo/" + VERSION + "/autoload.dat"; |
243 | + |
244 | + //Load the extra.dat file so we can peek at some extra information, such |
245 | + //as which songs to auto-load into Mixxx's players. |
246 | + QFile file(m_sPromoAutoloadLocation); |
247 | + if (file.open(QIODevice::ReadOnly)) |
248 | + { |
249 | + QTextStream extra(&file); |
250 | + |
251 | + qDebug() << "PROMO: Autoload" << (file.exists() ? "" : "not") << "found"; |
252 | + while (!extra.atEnd()) |
253 | + { |
254 | + QString trackPath = extra.readLine(); |
255 | + qDebug() << "PROMO: Auto-loading track" << trackPath; |
256 | + m_tracksToAutoLoad.append(new TrackInfoObject(trackPath)); |
257 | + } |
258 | + file.close(); |
259 | + } |
260 | +} |
261 | + |
262 | +PromoTracksFeature::~PromoTracksFeature() { |
263 | +} |
264 | + |
265 | +QVariant PromoTracksFeature::title() { |
266 | + return m_sPromoTracksViewName; |
267 | +} |
268 | + |
269 | +QIcon PromoTracksFeature::getIcon() { |
270 | + return QIcon(); |
271 | +} |
272 | + |
273 | +bool PromoTracksFeature::isSupported(ConfigObject<ConfigValue>* config) { |
274 | + m_sPromoLocalHTMLLocation = LOCAL_HTML_LOCATION; |
275 | + qDebug() << "Promo dir:" << m_sPromoLocalHTMLLocation; |
276 | + return (QFile::exists(m_sPromoLocalHTMLLocation)); |
277 | +} |
278 | + |
279 | +QList<TrackInfoObject*> PromoTracksFeature::getTracksToAutoLoad() |
280 | +{ |
281 | + return m_tracksToAutoLoad; |
282 | +} |
283 | + |
284 | +void PromoTracksFeature::bindWidget(WLibrarySidebar* sidebarWidget, |
285 | + WLibrary* libraryWidget) { |
286 | + |
287 | + m_pPromoTracksView = new PromoTracksWebView(libraryWidget, m_pConfig->getConfigPath(), m_sPromoLocalHTMLLocation, m_sPromoRemoteHTMLLocation); |
288 | + |
289 | + libraryWidget->registerView(m_sPromoTracksViewName, m_pPromoTracksView); |
290 | + connect(m_pPromoTracksView, SIGNAL(loadTrack(TrackInfoObject*)), |
291 | + this, SIGNAL(loadTrack(TrackInfoObject*))); |
292 | + connect(m_pPromoTracksView, SIGNAL(loadTrackToPlayer(TrackInfoObject*, int)), |
293 | + this, SIGNAL(loadTrackToPlayer(TrackInfoObject*, int))); |
294 | +} |
295 | + |
296 | +QAbstractItemModel* PromoTracksFeature::getChildModel() { |
297 | + return &m_childModel; |
298 | +} |
299 | + |
300 | +void PromoTracksFeature::activate() { |
301 | + //qDebug() << "PromoTracksFeature::activate()"; |
302 | + //emit(showTrackModel(m_pPromoTracksTableModelProxy)); |
303 | + |
304 | + /* |
305 | + if (m_pPromoTracksView->page()->bytesReceived() == 0) { |
306 | + qDebug() << "PROMO: Loading local page"; |
307 | + m_pPromoTracksView->load(m_sPromoLocalHTMLLocation); |
308 | + }*/ |
309 | + emit(switchToView(m_sPromoTracksViewName)); |
310 | +} |
311 | + |
312 | +void PromoTracksFeature::activateChild(const QModelIndex& index) { |
313 | + |
314 | +} |
315 | + |
316 | +void PromoTracksFeature::onRightClick(const QPoint& globalPos) { |
317 | +} |
318 | + |
319 | +void PromoTracksFeature::onRightClickChild(const QPoint& globalPos, |
320 | + QModelIndex index) { |
321 | +} |
322 | + |
323 | +bool PromoTracksFeature::dropAccept(QUrl url) { |
324 | + return false; |
325 | +} |
326 | + |
327 | +bool PromoTracksFeature::dropAcceptChild(const QModelIndex& index, QUrl url) { |
328 | + return false; |
329 | +} |
330 | + |
331 | +bool PromoTracksFeature::dragMoveAccept(QUrl url) { |
332 | + return false; |
333 | +} |
334 | + |
335 | +bool PromoTracksFeature::dragMoveAcceptChild(const QModelIndex& index, |
336 | + QUrl url) { |
337 | + return false; |
338 | +} |
339 | |
340 | === added file 'mixxx/src/library/promotracksfeature.h' |
341 | --- mixxx/src/library/promotracksfeature.h 1970-01-01 00:00:00 +0000 |
342 | +++ mixxx/src/library/promotracksfeature.h 2010-02-03 05:15:24 +0000 |
343 | @@ -0,0 +1,75 @@ |
344 | +/*************************************************************************** |
345 | + promotracksfeature.cpp |
346 | + ------------------- |
347 | + begin : Jan 2010 |
348 | + copyright : (C) 2010 Albert Santoni |
349 | + email : alberts@mixxx.org |
350 | +***************************************************************************/ |
351 | + |
352 | +/*************************************************************************** |
353 | +* * |
354 | +* This program is free software; you can redistribute it and/or modify * |
355 | +* it under the terms of the GNU General Public License as published by * |
356 | +* the Free Software Foundation; either version 2 of the License, or * |
357 | +* (at your option) any later version. * |
358 | +* * |
359 | +***************************************************************************/ |
360 | + |
361 | +#ifndef PROMOTRACKSFEATURE_H |
362 | +#define PROMOTRACKSFEATURE_H |
363 | + |
364 | +#include <QStringListModel> |
365 | + |
366 | +#include "library/libraryfeature.h" |
367 | +#include "library/dao/playlistdao.h" |
368 | +#include "configobject.h" |
369 | + |
370 | +class PlaylistTableModel; |
371 | +class ProxyTrackModel; |
372 | +class TrackCollection; |
373 | +class TrackInfoObject; |
374 | +class PromoTracksWebView; |
375 | + |
376 | +class PromoTracksFeature : public LibraryFeature { |
377 | + Q_OBJECT |
378 | + public: |
379 | + PromoTracksFeature(QObject* parent, |
380 | + ConfigObject<ConfigValue>* pConfig, |
381 | + TrackCollection* pTrackCollection); |
382 | + virtual ~PromoTracksFeature(); |
383 | + static bool isSupported(ConfigObject<ConfigValue>* config); |
384 | + QList<TrackInfoObject*> getTracksToAutoLoad(); |
385 | + |
386 | + QVariant title(); |
387 | + QIcon getIcon(); |
388 | + |
389 | + bool dropAccept(QUrl url); |
390 | + bool dropAcceptChild(const QModelIndex& index, QUrl url); |
391 | + bool dragMoveAccept(QUrl url); |
392 | + bool dragMoveAcceptChild(const QModelIndex& index, QUrl url); |
393 | + |
394 | + void bindWidget(WLibrarySidebar* sidebarWidget, |
395 | + WLibrary* libraryWidget); |
396 | + |
397 | + QAbstractItemModel* getChildModel(); |
398 | + |
399 | +public slots: |
400 | + void activate(); |
401 | + void activateChild(const QModelIndex& index); |
402 | + void onRightClick(const QPoint& globalPos); |
403 | + void onRightClickChild(const QPoint& globalPos, QModelIndex index); |
404 | + |
405 | +private: |
406 | + ConfigObject<ConfigValue>* m_pConfig; |
407 | + TrackCollection* m_pTrackCollection; |
408 | + PromoTracksWebView* m_pPromoTracksView; |
409 | + const static QString m_sPromoTracksViewName; |
410 | + static QString m_sPromoLocalHTMLLocation; |
411 | + static QString m_sPromoRemoteHTMLLocation; |
412 | + QString m_sPromoAutoloadLocation; |
413 | + QStringListModel m_childModel; |
414 | + QList<TrackInfoObject*> m_tracksToAutoLoad; |
415 | +}; |
416 | + |
417 | + |
418 | +#endif /* PROMOTRACKSFEATURE_H */ |
419 | |
420 | === added file 'mixxx/src/library/promotrackswebview.cpp' |
421 | --- mixxx/src/library/promotrackswebview.cpp 1970-01-01 00:00:00 +0000 |
422 | +++ mixxx/src/library/promotrackswebview.cpp 2010-02-03 05:15:24 +0000 |
423 | @@ -0,0 +1,124 @@ |
424 | +/*************************************************************************** |
425 | + promotrackswebview.cpp |
426 | + ------------------- |
427 | + begin : Jan 2010 |
428 | + copyright : (C) 2010 Albert Santoni |
429 | + email : alberts@mixxx.org |
430 | +***************************************************************************/ |
431 | + |
432 | +/*************************************************************************** |
433 | +* * |
434 | +* This program is free software; you can redistribute it and/or modify * |
435 | +* it under the terms of the GNU General Public License as published by * |
436 | +* the Free Software Foundation; either version 2 of the License, or * |
437 | +* (at your option) any later version. * |
438 | +* * |
439 | +***************************************************************************/ |
440 | + |
441 | +#include <QtXml> |
442 | +#include <QDebug> |
443 | +#include <QDesktopServices> |
444 | +#include "promotrackswebview.h" |
445 | + |
446 | +#define LOAD_TIMEOUT 5000 |
447 | + |
448 | +PromoTracksWebView::PromoTracksWebView(QWidget* parent, QString mixxxPath, QString localURL, QString remoteURL) : QWebView(parent), LibraryView() |
449 | +{ |
450 | + m_sMixxxPath = mixxxPath; |
451 | + m_sLocalURL = localURL; |
452 | + m_sRemoteURL = remoteURL; |
453 | + m_bOfflineMode = false; |
454 | + |
455 | + QWidget::setContextMenuPolicy(Qt::PreventContextMenu); |
456 | + |
457 | + //Allow us to catch if opening the HTML file on promo.mixxx.org |
458 | + //fails, and display a local copy instead. |
459 | + connect(this, SIGNAL(loadFinished(bool)), |
460 | + this, SLOT(handleLoadFinished(bool))); |
461 | + |
462 | + //Load the promo tracks webpage |
463 | + QWebView::load(QUrl(m_sRemoteURL)); |
464 | + |
465 | + //Let us manually handle links that are clicked via the linkClicked() |
466 | + //signal... |
467 | + QWebPage* page = QWebView::page(); |
468 | + page->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); |
469 | + |
470 | + connect(this, SIGNAL(linkClicked(const QUrl&)), |
471 | + this, SLOT(handleClickedLink(const QUrl&))); |
472 | + |
473 | + QTimer* loadingTimer = new QTimer(this); |
474 | + connect(loadingTimer, SIGNAL(timeout()), |
475 | + this, SLOT(checkWebpageLoadingProgress())); |
476 | + loadingTimer->start(LOAD_TIMEOUT); |
477 | +} |
478 | + |
479 | +PromoTracksWebView::~PromoTracksWebView() |
480 | +{ |
481 | + |
482 | +} |
483 | + |
484 | +void PromoTracksWebView::setup(QDomNode node) |
485 | +{ |
486 | + |
487 | +} |
488 | + |
489 | +QString PromoTracksWebView::userAgentForUrl (const QUrl & url) const |
490 | +{ |
491 | + return QCoreApplication::applicationName() + " " + QCoreApplication::applicationVersion(); |
492 | +} |
493 | + |
494 | +void PromoTracksWebView::handleLoadFinished(bool ok) |
495 | +{ |
496 | + //If the remote webpage failed to load, show the |
497 | + //local copy of it. |
498 | + if (!ok) |
499 | + { |
500 | + /* This doesn't work inside this signal handler for some reason: |
501 | + QWebView::stop(); |
502 | + QWebView::load(QUrl(m_sLocalURL)); |
503 | + */ |
504 | + m_bOfflineMode = true; |
505 | + qDebug() << "PROMO: Loading local copy at" << m_sLocalURL; |
506 | + } |
507 | +} |
508 | + |
509 | +void PromoTracksWebView::checkWebpageLoadingProgress() |
510 | +{ |
511 | + if (QWebView::page()->bytesReceived() == 0) { |
512 | + qDebug() << "PROMO: Load timed out, loading local page"; |
513 | + QWebView::stop(); |
514 | + QWebView::load(QUrl(m_sLocalURL)); |
515 | + m_bOfflineMode = true; |
516 | + } |
517 | +} |
518 | + |
519 | +void PromoTracksWebView::handleClickedLink(const QUrl& url) |
520 | +{ |
521 | + qDebug() << "link clicked!" << url; |
522 | + |
523 | + if (url.scheme() == "deck1") |
524 | + { |
525 | + TrackInfoObject* track = new TrackInfoObject(m_sMixxxPath + "/" + url.path()); |
526 | + emit(loadTrackToPlayer(track, 1)); |
527 | + } |
528 | + else if (url.scheme() == "deck2") |
529 | + { |
530 | + TrackInfoObject* track = new TrackInfoObject(m_sMixxxPath + "/" + url.path()); |
531 | + emit(loadTrackToPlayer(track, 2)); |
532 | + } |
533 | + else |
534 | + { |
535 | + QDesktopServices::openUrl(url); |
536 | + } |
537 | + //emit(loadTrack(track)); |
538 | + //int player = 1; |
539 | + //emit(loadTrackToPlayer(track, player)); |
540 | +} |
541 | + |
542 | +//TODO: Implement this for MIDI control |
543 | +void PromoTracksWebView::keyPressEvent(QKeyEvent* event) |
544 | +{ |
545 | + //Look at WTrackTableView::keyPressEvent(...) for some |
546 | + //code to start with... |
547 | +} |
548 | |
549 | === added file 'mixxx/src/library/promotrackswebview.h' |
550 | --- mixxx/src/library/promotrackswebview.h 1970-01-01 00:00:00 +0000 |
551 | +++ mixxx/src/library/promotrackswebview.h 2010-02-03 05:15:24 +0000 |
552 | @@ -0,0 +1,62 @@ |
553 | +/*************************************************************************** |
554 | + promotrackswebview.h |
555 | + ------------------- |
556 | + begin : Jan 2010 |
557 | + copyright : (C) 2010 Albert Santoni |
558 | + email : alberts@mixxx.org |
559 | +***************************************************************************/ |
560 | + |
561 | +/*************************************************************************** |
562 | +* * |
563 | +* This program is free software; you can redistribute it and/or modify * |
564 | +* it under the terms of the GNU General Public License as published by * |
565 | +* the Free Software Foundation; either version 2 of the License, or * |
566 | +* (at your option) any later version. * |
567 | +* * |
568 | +***************************************************************************/ |
569 | + |
570 | +#ifndef __PROMOTRACKSWEBVIEW_H_ |
571 | +#define __PROMOTRACKSWEBVIEW_H_ |
572 | + |
573 | +#include <QWebView> |
574 | +#include <QUrl> |
575 | +#include "trackinfoobject.h" |
576 | +#include "library/libraryview.h" |
577 | + |
578 | +#define MIXXX_PROMO_HTML_LOCATION "promo/promotracks.html" |
579 | + |
580 | +class PromoTracksWebView : public QWebView, public LibraryView |
581 | +{ |
582 | + Q_OBJECT |
583 | + public: |
584 | + PromoTracksWebView(QWidget* parent, QString mixxxPath, |
585 | + QString localURL, QString remoteURL); |
586 | + ~PromoTracksWebView(); |
587 | + virtual void setup(QDomNode node); |
588 | + virtual void onSearchStarting() {}; |
589 | + virtual void onSearchCleared() {}; |
590 | + virtual void onSearch(const QString&) {}; |
591 | + virtual void onShow() {}; |
592 | + virtual QWidget* getWidgetForMIDIControl() { return this; }; |
593 | + virtual void keyPressEvent(QKeyEvent* event); |
594 | + |
595 | + public slots: |
596 | + void handleClickedLink(const QUrl& url); |
597 | + void handleLoadFinished(bool ok); |
598 | + void checkWebpageLoadingProgress(); |
599 | + |
600 | + signals: |
601 | + void loadTrack(TrackInfoObject* pTrack); |
602 | + void loadTrackToPlayer(TrackInfoObject* pTrack, int player); |
603 | + protected: |
604 | + virtual QString userAgentForUrl (const QUrl & url) const; |
605 | + |
606 | + private: |
607 | + QString m_sMixxxPath; /** Top-level path to directory that contains the promo directory. */ |
608 | + QString m_sLocalURL; /** URL to local copy of the promo tracks web page. */ |
609 | + QString m_sRemoteURL; /** URL to remotely hosted (promo.mixxx.org) copy of promo tracks web page.*/ |
610 | + bool m_bOfflineMode; /** Load promo tracks page locally if we're offline */ |
611 | +}; |
612 | + |
613 | + |
614 | +#endif //__PROMOTRACKSWEBVIEW_H_ |
615 | |
616 | === modified file 'mixxx/src/library/sidebarmodel.cpp' |
617 | --- mixxx/src/library/sidebarmodel.cpp 2010-01-31 09:15:16 +0000 |
618 | +++ mixxx/src/library/sidebarmodel.cpp 2010-02-03 05:15:24 +0000 |
619 | @@ -6,8 +6,8 @@ |
620 | #include "library/sidebarmodel.h" |
621 | |
622 | SidebarModel::SidebarModel(QObject* parent) |
623 | - : QAbstractItemModel(parent) { |
624 | - |
625 | + : m_iDefaultSelectedIndex(0), |
626 | + QAbstractItemModel(parent) { |
627 | } |
628 | |
629 | SidebarModel::~SidebarModel() { |
630 | @@ -34,12 +34,17 @@ |
631 | QModelIndex SidebarModel::getDefaultSelection() { |
632 | if (m_sFeatures.size() == 0) |
633 | return QModelIndex(); |
634 | - return createIndex(0, 0, (void*)this); |
635 | + return createIndex(m_iDefaultSelectedIndex, 0, (void*)this); |
636 | +} |
637 | + |
638 | +void SidebarModel::setDefaultSelection(unsigned int index) |
639 | +{ |
640 | + m_iDefaultSelectedIndex = index; |
641 | } |
642 | |
643 | void SidebarModel::activateDefaultSelection() { |
644 | if (m_sFeatures.size() > 0) { |
645 | - m_sFeatures[0]->activate(); |
646 | + m_sFeatures[m_iDefaultSelectedIndex]->activate(); |
647 | } |
648 | } |
649 | |
650 | |
651 | === modified file 'mixxx/src/library/sidebarmodel.h' |
652 | --- mixxx/src/library/sidebarmodel.h 2009-10-24 09:07:58 +0000 |
653 | +++ mixxx/src/library/sidebarmodel.h 2010-02-03 05:15:24 +0000 |
654 | @@ -19,6 +19,7 @@ |
655 | |
656 | void addLibraryFeature(LibraryFeature* feature); |
657 | QModelIndex getDefaultSelection(); |
658 | + void setDefaultSelection(unsigned int index); |
659 | void activateDefaultSelection(); |
660 | |
661 | // Required for QAbstractItemModel |
662 | @@ -56,6 +57,7 @@ |
663 | private: |
664 | QModelIndex translateSourceIndex(const QModelIndex& parent); |
665 | QList<LibraryFeature*> m_sFeatures; |
666 | + unsigned int m_iDefaultSelectedIndex; /** Index of the item in the sidebar model to select at startup. */ |
667 | }; |
668 | |
669 | #endif /* SIDEBARMODEL_H */ |
670 | |
671 | === modified file 'mixxx/src/mixxx.cpp' |
672 | --- mixxx/src/mixxx.cpp 2010-02-03 04:37:15 +0000 |
673 | +++ mixxx/src/mixxx.cpp 2010-02-03 05:15:24 +0000 |
674 | @@ -72,7 +72,7 @@ |
675 | MixxxApp::MixxxApp(QApplication * a, struct CmdlineArgs args) |
676 | { |
677 | app = a; |
678 | - |
679 | + |
680 | QString buildRevision, buildFlags; |
681 | #ifdef BUILD_REV |
682 | buildRevision = BUILD_REV; |
683 | @@ -90,6 +90,8 @@ |
684 | } |
685 | |
686 | qDebug() << "Mixxx" << VERSION << buildRevision << "is starting..."; |
687 | + QCoreApplication::setApplicationName("Mixxx"); |
688 | + QCoreApplication::setApplicationVersion(VERSION); |
689 | setWindowTitle(tr("Mixxx " VERSION)); |
690 | setWindowIcon(QIcon(":/images/icon.svg")); |
691 | |
692 | @@ -99,7 +101,9 @@ |
693 | m_pMidiDeviceManager = 0; |
694 | |
695 | // Check to see if this is the first time this version of Mixxx is run after an upgrade and make any needed changes. |
696 | - config = versionUpgrade(); // This static function is located in upgrade.cpp |
697 | + Upgrade upgrader; |
698 | + config = upgrader.versionUpgrade(); |
699 | + bool bFirstRun = upgrader.isFirstRun(); |
700 | QString qConfigPath = config->getConfigPath(); |
701 | |
702 | #ifdef __C_METRICS__ |
703 | @@ -198,7 +202,7 @@ |
704 | frame = new QFrame; |
705 | setCentralWidget(frame); |
706 | |
707 | - m_pLibrary = new Library(this, config); |
708 | + m_pLibrary = new Library(this, config, bFirstRun); |
709 | |
710 | //Create the "players" (virtual playback decks) |
711 | m_pPlayer1 = new Player(config, buffer1, "[Channel1]"); |
712 | @@ -348,6 +352,16 @@ |
713 | channel1->setEngineBuffer(buffer1); |
714 | channel2->setEngineBuffer(buffer2); |
715 | |
716 | + //Automatically load specially marked promotional tracks on first run |
717 | + if (bFirstRun) |
718 | + { |
719 | + QList<TrackInfoObject*> tracksToAutoLoad = m_pLibrary->getTracksToAutoLoad(); |
720 | + if (tracksToAutoLoad.count() > 0) |
721 | + m_pPlayer1->slotLoadTrack(tracksToAutoLoad.at(0)); |
722 | + if (tracksToAutoLoad.count() > 1) |
723 | + m_pPlayer2->slotLoadTrack(tracksToAutoLoad.at(1)); |
724 | + } |
725 | + |
726 | #ifdef __SCRIPT__ |
727 | scriptEng = new ScriptEngine(this, m_pTrack); |
728 | #endif |
729 | |
730 | === modified file 'mixxx/src/upgrade.cpp' |
731 | --- mixxx/src/upgrade.cpp 2009-09-08 00:07:24 +0000 |
732 | +++ mixxx/src/upgrade.cpp 2010-02-03 05:15:24 +0000 |
733 | @@ -21,9 +21,19 @@ |
734 | #include "configobject.h" |
735 | #include "upgrade.h" |
736 | |
737 | +Upgrade::Upgrade() |
738 | +{ |
739 | + m_bFirstRun = false; |
740 | +} |
741 | + |
742 | +Upgrade::~Upgrade() |
743 | +{ |
744 | + |
745 | +} |
746 | + |
747 | // We return the ConfigObject here because we have to make changes to the |
748 | // configuration and the location of the file may change between releases. |
749 | -ConfigObject<ConfigValue>* versionUpgrade() { |
750 | +ConfigObject<ConfigValue>* Upgrade::versionUpgrade() { |
751 | |
752 | /* Pre-1.7.0: |
753 | * |
754 | @@ -144,7 +154,9 @@ |
755 | if (configVersion.isEmpty()) { |
756 | qDebug() << "No version number in configuration file. Setting to" << VERSION; |
757 | config->set(ConfigKey("[Config]","Version"), ConfigValue(VERSION)); |
758 | - return config; |
759 | + |
760 | + //This must have been the first run... right? :) |
761 | + m_bFirstRun = true; |
762 | } |
763 | |
764 | // Allows for incremental upgrades incase someone upgrades from a few versions prior |
765 | |
766 | === modified file 'mixxx/src/upgrade.h' |
767 | --- mixxx/src/upgrade.h 2009-04-14 04:47:13 +0000 |
768 | +++ mixxx/src/upgrade.h 2010-02-03 05:15:24 +0000 |
769 | @@ -18,6 +18,15 @@ |
770 | #ifndef UPGRADE_H |
771 | #define UPGRADE_H |
772 | |
773 | -ConfigObject<ConfigValue>* versionUpgrade(); |
774 | +class Upgrade |
775 | +{ |
776 | + public: |
777 | + Upgrade(); |
778 | + ~Upgrade(); |
779 | + ConfigObject<ConfigValue>* versionUpgrade(); |
780 | + bool isFirstRun() { return m_bFirstRun; }; |
781 | + private: |
782 | + bool m_bFirstRun; |
783 | +}; |
784 | |
785 | #endif |
786 | |
787 | === modified file 'mixxx/src/widget/wlibrary.cpp' |
788 | --- mixxx/src/widget/wlibrary.cpp 2010-01-06 10:29:44 +0000 |
789 | +++ mixxx/src/widget/wlibrary.cpp 2010-02-03 05:15:24 +0000 |
790 | @@ -39,10 +39,11 @@ |
791 | |
792 | void WLibrary::switchToView(const QString& name) { |
793 | QMutexLocker lock(&m_mutex); |
794 | - //qDebug() << "WLibrary::switchToView" << name; |
795 | + qDebug() << "WLibrary::switchToView" << name; |
796 | if (m_viewMap.contains(name)) { |
797 | QWidget* widget = m_viewMap[name]; |
798 | if (widget != NULL && currentWidget() != widget) { |
799 | + qDebug() << "WLibrary::setCurrentWidget" << name; |
800 | setCurrentWidget(widget); |
801 | dynamic_cast<LibraryView*>(widget)->onShow(); |
802 | } |
Fixed the conflicts... does this regenerate the diff?