~ubuntu-branches/ubuntu/hardy/lmms/hardy

« back to all changes in this revision

Viewing changes to src/core/lmms_main_win.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ragwitz
  • Date: 2005-12-22 16:22:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051222162250-key3p7x0212jy6dn
Tags: 0.1.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * lmms.cpp - LMMS-base-system, contains main() and main-window
3
3
 *
4
 
 * Linux MultiMedia Studio
5
 
 * Copyright (c) 2004-2005 Tobias Doerffel <tobydox@users.sourceforge.net>
 
4
 * Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
 
5
 * 
 
6
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
6
7
 *
7
8
 * This program is free software; you can redistribute it and/or
8
9
 * modify it under the terms of the GNU General Public
27
28
#ifdef QT4
28
29
 
29
30
#include <QApplication>
30
 
#include <QLocale>
31
31
#include <QFileDialog>
32
32
#include <QCloseEvent>
33
33
#include <QSplitter>
34
 
#include <QStatusBar>
35
 
#include <QMenuBar>
36
 
#include <QToolButton>
37
34
#include <QSplashScreen>
38
 
#include <QStatusBar>
39
 
#include <QToolBar>
40
 
#include <QAction>
41
35
#include <QMessageBox>
 
36
#include <QMenuBar>
42
37
 
43
38
#else
44
39
 
45
40
#include <qsplitter.h>
46
41
#include <qapplication.h>
47
 
#include <qtextcodec.h>
48
42
#include <qdir.h>
49
43
#include <qfiledialog.h>
50
44
#include <qpopupmenu.h>
 
45
#include <qmessagebox.h>
51
46
#include <qmenubar.h>
52
 
#include <qtoolbutton.h>
53
 
#include <qstatusbar.h>
54
 
#include <qaction.h>
55
 
#include <qmessagebox.h>
56
47
 
57
48
#if QT_VERSION >= 0x030200
58
49
#include <qsplashscreen.h>
71
62
#include "piano_roll.h"
72
63
#include "embed.h"
73
64
#include "about_dialog.h"
74
 
#include "browser.h"
 
65
#include "file_browser.h"
 
66
#include "plugin_browser.h"
75
67
#include "side_bar.h"
76
68
#include "config_mgr.h"
77
69
#include "mixer.h"
80
72
#include "setup_dialog.h"
81
73
#include "preset_preview_play_handle.h"
82
74
#include "audio_dummy.h"
 
75
#include "tool_button.h"
83
76
 
84
77
 
85
78
#if QT_VERSION >= 0x030100
97
90
                        0 , NULL, WDestructiveClose
98
91
#endif
99
92
                ),
 
93
        m_workspace( NULL ),
100
94
        m_templatesMenu( NULL )
101
95
{
102
96
#ifdef QT4
106
100
        // small workaround, because inst() is called by objects which
107
101
        // are created within this function
108
102
        s_instanceOfMe = this;
109
 
 
110
 
        QStatusBar * status_bar = new QStatusBar( this );
111
 
        status_bar->setSizeGripEnabled( TRUE );
112
 
 
113
 
        QWidget * w = new QWidget( this );
 
103
        bool no_mdi = configManager::inst()->value( "app", "gimplikewindows"
 
104
                                                                ).toInt();
 
105
 
 
106
        QWidget * main_widget = new QWidget( this );
 
107
        QVBoxLayout * vbox = new QVBoxLayout( main_widget );
 
108
        vbox->setSpacing( 0 );
 
109
        vbox->setMargin( 0 );
 
110
 
 
111
 
 
112
        QWidget * w = new QWidget( main_widget );
114
113
        QHBoxLayout * hbox = new QHBoxLayout( w );
 
114
        hbox->setSpacing( 0 );
 
115
        hbox->setMargin( 0 );
 
116
 
115
117
        sideBar * side_bar = new sideBar( Qt::Vertical, w );
116
118
        side_bar->setStyle( sideBar::VSNET/*KDEV3ICON*/ );
117
119
        side_bar->setPosition( sideBar::DockLeft );
123
125
 
124
126
        int id = 0;
125
127
        QString wdir = configManager::inst()->lmmsWorkingDir();
126
 
        side_bar->appendTab( new browser( wdir+"projects", "*.xml",
 
128
        side_bar->appendTab( new pluginBrowser( splitter ), ++id );
 
129
        side_bar->appendTab( new fileBrowser( wdir+"projects",
 
130
                                                        "*.mmp *.xml *.mid",
127
131
                                                        tr( "My projects" ),
128
132
                                        embed::getIconPixmap( "project_file" ),
129
133
                                                        splitter ), ++id );
130
 
        side_bar->appendTab( new browser( wdir+"samples", "*.wav *.ogg *.voc "
131
 
                                                "*.aif *.aiff *.au *.raw",
 
134
        side_bar->appendTab( new fileBrowser( wdir+"samples", "*.wav *.ogg *.au"
 
135
                                        "*.voc *.aif *.aiff *.flac *.raw",
132
136
                                                        tr( "My samples" ),
133
137
                                        embed::getIconPixmap( "sound_file" ),
134
138
                                                        splitter ), ++id );
135
 
        side_bar->appendTab( new browser( wdir+"presets", "*.cs.xml",
 
139
        side_bar->appendTab( new fileBrowser( wdir+"presets", "*.cs.xml",
136
140
                                                        tr( "My presets" ),
137
141
                                        embed::getIconPixmap( "preset_file" ),
138
142
                                                        splitter ), ++id );
139
 
        side_bar->appendTab( new browser( QDir::homePath(), "*",
 
143
        side_bar->appendTab( new fileBrowser( QDir::homePath(), "*",
140
144
                                                        tr( "My home" ),
141
145
                                        embed::getIconPixmap( "home" ),
142
146
                                                        splitter ), ++id );
143
 
        side_bar->appendTab( new browser( QDir::rootPath(), "*",
 
147
        side_bar->appendTab( new fileBrowser( QDir::rootPath(), "*",
144
148
                                                        tr( "Root directory" ),
145
149
                                        embed::getIconPixmap( "root" ),
146
150
                                                        splitter ), ++id );
147
151
 
148
 
        m_workspace = new lmmsWorkspace( splitter );
149
 
        m_workspace->setScrollBarsEnabled( TRUE );
 
152
        if( no_mdi == FALSE )
 
153
        {
 
154
                m_workspace = new QWorkspace( splitter );
 
155
                m_workspace->setScrollBarsEnabled( TRUE );
150
156
 
151
157
#ifdef QT4
152
 
        m_workspace->setBackground( embed::getIconPixmap(
153
 
                                                "background_artwork" ) );
 
158
/*              m_workspace->setBackground( embed::getIconPixmap(
 
159
                                                "background_artwork" ) );*/
154
160
#else
155
 
        m_workspace->setPaletteBackgroundPixmap( embed::getIconPixmap(
 
161
                m_workspace->setPaletteBackgroundPixmap( embed::getIconPixmap(
156
162
                                                "background_artwork" ) );
157
163
#endif
 
164
        }
158
165
 
159
166
        hbox->addWidget( side_bar );
160
167
        hbox->addWidget( splitter );
161
 
        setCentralWidget( w );
 
168
 
 
169
 
 
170
        // create global-toolbar at the top of our window
 
171
        m_toolBar = new QWidget( main_widget );
 
172
        m_toolBar->setFixedHeight( 64 );
 
173
        m_toolBar->move( 0, 0 );
 
174
#ifdef QT4
 
175
        QPalette pal;
 
176
        pal.setBrush( m_toolBar->backgroundRole(), QBrush(
 
177
                                embed::getIconPixmap( "main_toolbar_bg" ) ) );
 
178
        m_toolBar->setPalette( pal );
 
179
#else
 
180
        m_toolBar->setPaletteBackgroundPixmap(
 
181
                                embed::getIconPixmap( "main_toolbar_bg" ) );
 
182
#endif
 
183
 
 
184
        // add layout for organizing quite complex toolbar-layouting
 
185
        m_toolBarLayout = new QGridLayout( m_toolBar/*, 2, 1*/ );
 
186
        m_toolBarLayout->setMargin( 0 );
 
187
        m_toolBarLayout->setSpacing( 0 );
 
188
 
 
189
        vbox->addWidget( m_toolBar );
 
190
        vbox->addWidget( w );
 
191
        setCentralWidget( main_widget );
 
192
 
162
193
 
163
194
 
164
195
#if QT_VERSION >= 0x030200
186
217
        resetWindowTitle( "" );
187
218
        setWindowIcon( embed::getIconPixmap( "icon" ) );
188
219
 
189
 
        // TODO: when dropping qt3-support clean up the whole menu- and toolbar
190
 
        // code and create QAction's to be inserted in menu- and toolbar - the
191
 
        // current situation is horrible.....!!!!!!!
192
 
 
193
 
 
194
 
        m_projectTools = new QToolBar( this );
195
 
#ifdef QT4
196
 
        addToolBar( Qt::TopToolBarArea, m_projectTools );
197
 
#else
198
 
        addDockWindow( m_projectTools, tr( "Song management" ), DockTop,
199
 
                                                                        TRUE );
200
 
#endif
201
 
 
202
 
        QAction * a;
203
 
 
204
 
#ifdef QT4
205
 
        a = new QAction( embed::getIconPixmap( "project_new" ),
206
 
                                                tr( "Create new project" ),
207
 
                                                        m_projectTools );
208
 
        a->setShortcut( tr( "Ctrl+N" ) );
209
 
        connect( a, SIGNAL( activated() ), this, SLOT( createNewProject() ) );
210
 
 
211
 
        a = new QAction( embed::getIconPixmap( "project_open" ),
212
 
                                                tr( "Open existing project" ),
213
 
                                                        m_projectTools );
214
 
        a->setShortcut( tr( "Ctrl+O" ) );
215
 
        connect( a, SIGNAL( activated() ), this, SLOT( openProject() ) );
216
 
 
217
 
        a = new QAction( embed::getIconPixmap( "project_save" ),
218
 
                                                tr( "Save current project" ),
219
 
                                                        m_projectTools );
220
 
        a->setShortcut( tr( "Ctrl+S" ) );
221
 
        connect( a, SIGNAL( activated() ), this, SLOT( saveProject() ) );
222
 
 
223
 
        a = new QAction( embed::getIconPixmap( "project_export" ),
224
 
                                                tr( "Export current project" ),
225
 
                                                        m_projectTools );
226
 
        a->setShortcut( tr( "Ctrl+E" ) );
227
 
        connect( a, SIGNAL( activated() ), songEditor::inst(),
228
 
                                                SLOT( exportProject() ) );
229
 
 
230
 
#else
231
 
/*      a = new QAction( embed::getIconPixmap( "project_new" ),
232
 
                                                        tr( "Create new project" ),
233
 
                                                        CTRL + Key_N, this );
234
 
        connect( a, SIGNAL( activated() ), this, SLOT( createNewProject() ) );
235
 
        a->addTo( m_projectTools );*/
236
 
        QToolButton * t = new QToolButton( embed::getIconPixmap(
237
 
                                                        "project_new" ),
238
 
                                                tr( "Create new project" ),
239
 
                                                QString::null, this,
240
 
                                                SLOT( createNewProject() ),
241
 
                                                        m_projectTools );
242
 
        t->setAccel( Qt::Key_F6 );
 
220
 
 
221
        // create tool-buttons
 
222
        toolButton * project_new = new toolButton(
 
223
                                        embed::getIconPixmap( "project_new" ),
 
224
                                        tr( "Create new project" ),
 
225
                                        this, SLOT( createNewProject() ),
 
226
                                                        m_toolBar );
 
227
 
243
228
        QDir d( configManager::inst()->projectsDir() + "templates" );
244
 
        QStringList templates = d.entryList( "*.xml",
 
229
        QStringList templates = d.entryList(
 
230
#ifdef QT4
 
231
                                                QStringList( "*.mpt" ),
 
232
#else
 
233
                                                "*.mpt",
 
234
#endif
245
235
                                                QDir::Files | QDir::Readable );
246
236
        if( !templates.isEmpty() )
247
237
        {
248
 
                m_templatesMenu = new QMenu( t );
 
238
                m_templatesMenu = new QMenu( project_new );
249
239
                for( QStringList::iterator it = templates.begin();
250
240
                                                it != templates.end(); ++it )
251
241
                {
252
 
                        m_templatesMenu->insertItem(
 
242
                        m_templatesMenu->addAction(
253
243
                                        embed::getIconPixmap( "project_file" ),
254
244
                                        ( *it ).left( ( *it ).length() - 4 ) );
255
245
                }
256
246
                connect( m_templatesMenu, SIGNAL( activated( int ) ),
257
247
                        this, SLOT( createNewProjectFromTemplate( int ) ) );
258
 
                t->setMenu( m_templatesMenu );
259
 
                t->setPopupDelay( 0 );
260
 
        }
261
 
 
262
 
        a = new QAction( 
263
 
#if QT_VERSION < 0x030200
264
 
                        "",
265
 
#endif              
266
 
                        embed::getIconPixmap( "project_open" ),
267
 
                                                tr( "Open existing project" ),
268
 
                                                        CTRL + Key_O, this );
269
 
        connect( a, SIGNAL( activated() ), this, SLOT( openProject() ) );
270
 
        a->addTo( m_projectTools );
271
 
 
272
 
        a = new QAction( 
273
 
#if QT_VERSION < 0x030200
274
 
                        "",
275
 
#endif              
276
 
                        embed::getIconPixmap( "project_save" ),
277
 
                                                tr( "Save current project" ),
278
 
                                                        CTRL + Key_S, this );
279
 
        connect( a, SIGNAL( activated() ), this, SLOT( saveProject() ) );
280
 
        a->addTo( m_projectTools );
281
 
 
282
 
        a = new QAction( 
283
 
#if QT_VERSION < 0x030200
284
 
                        "",
285
 
#endif              
286
 
                        embed::getIconPixmap( "project_export" ),
287
 
                                                tr( "Export current project" ),
288
 
                                                        CTRL + Key_E, this );
289
 
        connect( a, SIGNAL( activated() ), songEditor::inst(),
290
 
                                                SLOT( exportProject() ) );
291
 
        a->addTo( m_projectTools );
292
 
 
293
 
#endif
294
 
 
295
 
 
296
 
 
297
 
        m_windowTools = new QToolBar( tr( "Windows" ), this );
 
248
                project_new->setMenu( m_templatesMenu );
298
249
#ifdef QT4
299
 
        addToolBar( Qt::TopToolBarArea, m_windowTools );
 
250
                project_new->setPopupMode( toolButton::MenuButtonPopup );
300
251
#else
301
 
        addDockWindow( m_windowTools, tr( "Windows" ), Qt::DockTop, FALSE );
 
252
                project_new->setPopupDelay( 0 );
302
253
#endif
303
 
 
304
 
 
305
 
#ifndef QT4
 
254
        }
 
255
 
 
256
 
 
257
        toolButton * project_open = new toolButton( 
 
258
                                        embed::getIconPixmap( "project_open" ),
 
259
                                        tr( "Open existing project" ),
 
260
                                        this, SLOT( openProject() ),
 
261
                                                                m_toolBar );
 
262
 
 
263
 
 
264
        toolButton * project_save = new toolButton( 
 
265
                                        embed::getIconPixmap( "project_save" ),
 
266
                                        tr( "Save current project" ),
 
267
                                        this, SLOT( saveProject() ),
 
268
                                                                m_toolBar );
 
269
 
 
270
 
 
271
        toolButton * project_export = new toolButton( 
 
272
                                embed::getIconPixmap( "project_export" ),
 
273
                                        tr( "Export current project" ),
 
274
                                        songEditor::inst(),
 
275
                                                        SLOT( exportProject() ),
 
276
                                                                m_toolBar );
 
277
 
 
278
 
 
279
        m_toolBarLayout->addWidget( project_new, 0, 0 );
 
280
        m_toolBarLayout->addWidget( project_open, 0, 1 );
 
281
        m_toolBarLayout->addWidget( project_save, 0, 2 );
 
282
        m_toolBarLayout->addWidget( project_export, 0, 3 );
 
283
 
 
284
 
306
285
 
307
286
        // window-toolbar
308
 
        m_bbEditorWindow = new QToolButton( embed::getIconPixmap( "bb_track" ),
309
 
                                                tr( "Show/Hide Beat+Bassline "
310
 
                                                        "Editor" ) + " (F6)",
311
 
                                                QString::null,
 
287
        toolButton * bb_editor_window = new toolButton(
 
288
                                        embed::getIconPixmap( "bb_track" ),
 
289
                                        tr( "Show/hide Beat+Bassline Editor" ) +
 
290
                                                                        " (F6)",
312
291
                                        this, SLOT( toggleBBEditorWin() ),
313
 
                                                                m_windowTools );
314
 
        m_bbEditorWindow->setAccel( Qt::Key_F6 );
 
292
                                                                m_toolBar );
 
293
        bb_editor_window->setShortcut( Qt::Key_F6 );
315
294
#ifdef QT4
316
 
        m_bbEditorWindow->setWhatsThis( 
 
295
        bb_editor_window->setWhatsThis(
317
296
#else
318
 
        QWhatsThis::add( m_bbEditorWindow, 
 
297
        QWhatsThis::add( bb_editor_window, 
319
298
#endif
320
299
                tr( "By pressing this button, you can show or hide the "
321
300
                        "Beat+Bassline Editor. The Beat+Bassline Editor is "
325
304
                        "that." ) );
326
305
 
327
306
 
328
 
        m_pianoRollWindow = new QToolButton( embed::getIconPixmap( "piano" ),
329
 
                                                tr( "Show/Hide Piano-Roll" ) +
 
307
        toolButton * piano_roll_window = new toolButton(
 
308
                                                embed::getIconPixmap( "piano" ),
 
309
                                                tr( "Show/hide Piano-Roll" ) +
330
310
                                                                        " (F7)",
331
 
                                                                QString::null,
332
311
                                        this, SLOT( togglePianoRollWin() ),
333
 
                                                                m_windowTools );
334
 
        m_pianoRollWindow->setAccel( Key_F7 );
335
 
        QWhatsThis::add( m_pianoRollWindow, tr( "By pressing this button, you "
336
 
                                                "can show or hide the "
337
 
                                                "Piano-Roll. With the help of "
338
 
                                                "the Piano-Roll you can edit "
339
 
                                                "melody-patterns in an easy "
340
 
                                                "way." ) );
341
 
 
342
 
        m_projectNotesWindow = new QToolButton( embed::getIconPixmap(
343
 
                                                        "project_notes" ),
344
 
                                                tr( "Show/Hide Project notes" )+
345
 
                                                                " (F10)",
346
 
                                                                QString::null,
347
 
                                        this, SLOT( toggleProjectNotesWin() ),
348
 
                                                                m_windowTools );
349
 
        m_projectNotesWindow->setAccel( Key_F10 );
350
 
        QWhatsThis::add( m_projectNotesWindow, tr( "By pressing this button, "
351
 
                                                        "you can show or hide "
352
 
                                                        "the project notes "
353
 
                                                        "window. "
354
 
                                                        "In this window you "
355
 
                                                        "can put down your "
356
 
                                                        "project notes.") );
357
 
 
358
 
        m_songEditorWindow = new QToolButton( embed::getIconPixmap(
359
 
                                                                "songeditor" ),
360
 
                                                tr( "Show/Hide Song-Editor" ) +
361
 
                                                                        " (F8)",
362
 
                                                                QString::null,
 
312
                                                                m_toolBar );
 
313
        piano_roll_window->setShortcut( Qt::Key_F7 );
 
314
#ifdef QT4
 
315
        piano_roll_window->setWhatsThis(
 
316
#else
 
317
        QWhatsThis::add( piano_roll_window,
 
318
#endif
 
319
                        tr( "By pressing this button, you can show or hide the "
 
320
                                "Piano-Roll. With the help of the Piano-Roll "
 
321
                                "you can edit melody-patterns in an easy way."
 
322
                                ) );
 
323
 
 
324
        toolButton * song_editor_window = new toolButton(
 
325
                                        embed::getIconPixmap( "songeditor" ),
 
326
                                        tr( "Show/hide Song-Editor" ) + " (F8)",
363
327
                                        this, SLOT( toggleSongEditorWin() ),
364
 
                                                                m_windowTools );
365
 
        m_songEditorWindow->setAccel( Qt::Key_F8 );
 
328
                                                                m_toolBar );
 
329
        song_editor_window->setShortcut( Qt::Key_F8 );
366
330
#ifdef QT4
367
 
        m_songEditorWindow->setWhatsThis(
 
331
        song_editor_window->setWhatsThis(
368
332
#else
369
 
        QWhatsThis::add( m_songEditorWindow,
 
333
        QWhatsThis::add( song_editor_window,
370
334
#endif
371
335
                tr( "By pressing this button, you can show or hide the "
372
 
                        "Song-Editor. With the Song-Editor you can edit the "
373
 
                        "song and set when and which track should be played. "
 
336
                        "Song-Editor. With the help of the Song-Editor you can "
 
337
                        "edit song-playlist and specify when which track "
 
338
                        "should be played. "
374
339
                        "You can also insert and move samples (e.g. "
375
 
                        "rap-samples) directly in the playlist." ) );
376
 
 
377
 
 
378
 
        m_effectBoardWindow = new QToolButton( embed::getIconPixmap(
379
 
                                                        "effect_board" ),
380
 
                                                tr( "Show/Hide EffectBoard" ) +
381
 
                                                                        " (F9)",
382
 
                                                QString::null,
383
 
                                                this, SLOT( emptySlot() ),
384
 
                                                                m_windowTools );
385
 
        m_effectBoardWindow->setAccel( Qt::Key_F9 );
 
340
                        "rap-samples) directly into the playlist." ) );
 
341
 
 
342
 
 
343
        toolButton * effect_board_window = new toolButton(
 
344
                                        embed::getIconPixmap( "effect_board" ),
 
345
                                        tr( "Show/hide EffectBoard" ) + " (F9)",
 
346
                                        this, SLOT( emptySlot() ), m_toolBar );
 
347
        effect_board_window->setShortcut( Qt::Key_F9 );
386
348
#ifdef QT4
387
 
        m_effectBoardWindow->setWhatsThis( 
 
349
        effect_board_window->setWhatsThis( 
388
350
#else
389
 
        QWhatsThis::add( m_effectBoardWindow,
 
351
        QWhatsThis::add( effect_board_window,
390
352
#endif
391
353
                tr( "By pressing this button, you can show or hide the "
392
354
                        "EffectBoard. The EffectBoard is a very powerful tool "
393
355
                        "for managing effects for your song. You can insert "
394
356
                        "effects into different effect-channels." ) );
395
357
 
 
358
        toolButton * project_notes_window = new toolButton(
 
359
                                        embed::getIconPixmap( "project_notes" ),
 
360
                                        tr( "Show/hide project notes" ) +
 
361
                                                                " (F10)",
 
362
                                        this, SLOT( toggleProjectNotesWin() ),
 
363
                                                                m_toolBar );
 
364
        project_notes_window->setShortcut( Qt::Key_F10 );
 
365
#ifdef QT4
 
366
        project_notes_window->setWhatsThis(
 
367
#else
 
368
        QWhatsThis::add( project_notes_window,
396
369
#endif
397
 
 
398
 
//#ifndef QT4
399
 
        // create a "What's this"-Button
400
 
//      (void) QWhatsThis::whatsThisButton( m_windowTools );
 
370
                tr( "By pressing this button, you can show or hide the "
 
371
                        "project notes window. In this window you can put "
 
372
                        "down your project notes.") );
 
373
 
 
374
        m_toolBarLayout->addWidget( bb_editor_window, 1, 0 );
 
375
        m_toolBarLayout->addWidget( piano_roll_window, 1, 1 );
 
376
        m_toolBarLayout->addWidget( song_editor_window, 1, 2 );
 
377
        m_toolBarLayout->addWidget( effect_board_window, 1, 3 );
 
378
        m_toolBarLayout->addWidget( project_notes_window, 1, 4 );
 
379
 
 
380
        m_toolBarLayout->setColumnStretch( 100, 1 );
 
381
 
401
382
 
402
383
 
403
384
        // project-popup-menu
404
 
        m_projectMenu = new QMenu( this );
 
385
        QMenu * project_menu = new QMenu( this );
405
386
#ifdef QT4
406
 
        menuBar()->addMenu( m_projectMenu )->setText( tr( "&Project" ) );
 
387
        menuBar()->addMenu( project_menu )->setText( tr( "&Project" ) );
407
388
#else
408
 
        menuBar()->insertItem( tr( "&Project" ), m_projectMenu );
 
389
        menuBar()->insertItem( tr( "&Project" ), project_menu );
409
390
#endif
410
 
        m_projectMenu->addAction( embed::getIconPixmap( "project_new" ),
 
391
        project_menu->addAction( embed::getIconPixmap( "project_new" ),
411
392
                                        tr( "&New" ),
412
393
                                        this, SLOT( createNewProject() ),
413
394
                                        Qt::CTRL + Qt::Key_N );
414
395
 
415
 
        m_projectMenu->addAction( embed::getIconPixmap( "project_open" ),
 
396
        project_menu->addAction( embed::getIconPixmap( "project_open" ),
416
397
                                        tr( "&Open..." ),
417
398
                                        this, SLOT( openProject() ),
418
399
                                        Qt::CTRL + Qt::Key_O ); 
419
400
 
420
 
        m_projectMenu->addAction( embed::getIconPixmap( "project_save" ),
 
401
        project_menu->addAction( embed::getIconPixmap( "project_save" ),
421
402
                                        tr( "&Save" ),
422
403
                                        this, SLOT( saveProject() ),
423
404
                                        Qt::CTRL + Qt::Key_S );
424
405
 
425
 
        m_projectMenu->addAction( embed::getIconPixmap( "project_saveas" ),
 
406
        project_menu->addAction( embed::getIconPixmap( "project_saveas" ),
426
407
                                        tr( "Save &As..." ),
427
408
                                        this, SLOT( saveProjectAs() ),
428
409
                                        Qt::CTRL + Qt::SHIFT + Qt::Key_S );
429
410
#ifdef QT4
430
 
        m_projectMenu->addSeparator();
 
411
        project_menu->addSeparator();
431
412
#else
432
 
        m_projectMenu->insertSeparator();
 
413
        project_menu->insertSeparator();
433
414
#endif
434
 
        m_projectMenu->addAction( /*embed::getIconPixmap( "project_import" ),*/
 
415
        project_menu->addAction( /*embed::getIconPixmap( "project_import" ),*/
435
416
                                        tr( "Import file" ),
436
417
                                        songEditor::inst(),
437
418
                                        SLOT( importProject() ) );
438
419
#ifdef QT4
439
 
        m_projectMenu->addSeparator();
 
420
        project_menu->addSeparator();
440
421
#else
441
 
        m_projectMenu->insertSeparator();
 
422
        project_menu->insertSeparator();
442
423
#endif
443
 
        m_projectMenu->addAction( embed::getIconPixmap( "project_export" ),
 
424
        project_menu->addAction( embed::getIconPixmap( "project_export" ),
444
425
                                        tr( "E&xport" ),
445
426
                                        songEditor::inst(),
446
427
                                        SLOT( exportProject() ),
447
428
                                        Qt::CTRL + Qt::Key_E );
448
429
#ifdef QT4
449
 
        m_projectMenu->addSeparator();
 
430
        project_menu->addSeparator();
450
431
#else
451
 
        m_projectMenu->insertSeparator();
 
432
        project_menu->insertSeparator();
452
433
#endif
453
 
        m_projectMenu->addAction( embed::getIconPixmap( "exit" ), tr( "&Quit" ),
 
434
        project_menu->addAction( embed::getIconPixmap( "exit" ), tr( "&Quit" ),
454
435
                                        qApp, SLOT( closeAllWindows() ),
455
436
                                        Qt::CTRL+Qt::Key_Q );
456
437
 
457
438
 
458
 
        QMenu * m_settingsMenu = new QMenu( this );
 
439
        QMenu * settings_menu = new QMenu( this );
459
440
#ifdef QT4
460
 
        menuBar()->addMenu( m_settingsMenu )->setText( tr( "&Settings" ) );
 
441
        menuBar()->addMenu( settings_menu )->setText( tr( "&Settings" ) );
461
442
#else
462
 
        menuBar()->insertItem( tr( "&Settings" ), m_settingsMenu );
 
443
        menuBar()->insertItem( tr( "&Settings" ), settings_menu );
463
444
#endif
464
 
        m_settingsMenu->addAction( embed::getIconPixmap( "setup_general" ),
 
445
        settings_menu->addAction( embed::getIconPixmap( "setup_general" ),
465
446
                                        tr( "Show settings dialog" ),
466
447
                                        this, SLOT( showSettingsDialog() ) );
467
 
        m_settingsMenu->addAction( embed::getIconPixmap( "wizard" ),
 
448
        settings_menu->addAction( embed::getIconPixmap( "wizard" ),
468
449
                                        tr( "Show setup wizard" ),
469
450
                                        configManager::inst(), SLOT( exec() ) );
470
451
 
471
452
        
472
453
        // help-popup-menu
473
 
        m_helpMenu = new QMenu( this );
 
454
        QMenu * help_menu = new QMenu( this );
474
455
#ifdef QT4
475
 
        menuBar()->addMenu( m_helpMenu )->setText( tr( "&Help" ) );
 
456
        menuBar()->addMenu( help_menu )->setText( tr( "&Help" ) );
476
457
#else
477
 
        menuBar()->insertItem( tr( "&Help" ), m_helpMenu );
 
458
        menuBar()->insertItem( tr( "&Help" ), help_menu );
478
459
#endif
479
 
        m_helpMenu->addAction( embed::getIconPixmap( "help" ), tr( "Help" ),
 
460
        help_menu->addAction( embed::getIconPixmap( "help" ), tr( "Help" ),
480
461
                                                        this, SLOT( help() ) );
481
 
        m_helpMenu->addAction( embed::getIconPixmap( "whatsthis" ),
 
462
        help_menu->addAction( embed::getIconPixmap( "whatsthis" ),
482
463
                                        tr( "What's this?" ),
483
464
                                        this, SLOT( enterWhatsThisMode() ) );
484
465
#ifdef QT4
485
 
        m_helpMenu->addSeparator();
 
466
        help_menu->addSeparator();
486
467
#else
487
 
        m_helpMenu->insertSeparator();
 
468
        help_menu->insertSeparator();
488
469
#endif
489
 
        m_helpMenu->addAction( embed::getIconPixmap( "icon" ), tr( "About" ),
 
470
        help_menu->addAction( embed::getIconPixmap( "icon" ), tr( "About" ),
490
471
                                                this, SLOT( aboutLMMS() ) );
491
472
 
492
 
        // now start mixer-thread
493
 
        mixer::inst()->start(
494
 
#if QT_VERSION >= 0x030200
495
 
                        QThread::HighestPriority
496
 
#endif
497
 
                                );
498
 
 
499
473
        // setup-dialog opened before?
500
474
        if( !configManager::inst()->value( "app", "configured" ).toInt() )
501
475
        {
502
476
                // no, so show it that user can setup everything
503
 
                setupDialog().exec();
504
 
                configManager::inst()->setValue( "app", "configured", "1" );
 
477
/*              setupDialog().exec();
 
478
                configManager::inst()->setValue( "app", "configured", "1" );*/
505
479
        }
506
480
        // look whether mixer could use a audio-interface beside audioDummy
507
481
        else if( mixer::inst()->audioDevName() == audioDummy::name() )
517
491
 
518
492
lmmsMainWin::~lmmsMainWin()
519
493
{
520
 
        // first make sure mixer-thread is in our way during clean-up...
521
 
        mixer::inst()->quitThread();
 
494
        // first make sure, there're no mixing/audio-device-threads any more
 
495
        mixer::inst()->stopProcessing();
522
496
 
523
497
        // destroy editors with all their children
524
498
        delete songEditor::inst();
542
516
 
543
517
 
544
518
 
 
519
int lmmsMainWin::addWidgetToToolBar( QWidget * _w, int _row, int _col )
 
520
{
 
521
        int col = ( _col == -1 ) ? m_toolBarLayout->columnCount() + 6 : _col;
 
522
        if( _w->height() > 32 || _row == -1 )
 
523
        {
 
524
#ifdef QT4
 
525
                m_toolBarLayout->addWidget( _w, 0, col, 2, 1 );
 
526
#else
 
527
                m_toolBarLayout->addMultiCellWidget( _w, 0, 1, col, col );
 
528
#endif
 
529
        }
 
530
        else
 
531
        {
 
532
                m_toolBarLayout->addWidget( _w, _row, col );
 
533
        }
 
534
        return( col );
 
535
}
 
536
 
 
537
 
 
538
 
 
539
 
 
540
void lmmsMainWin::addSpacingToToolBar( int _size )
 
541
{
 
542
        m_toolBarLayout->setColumnMinimumWidth( m_toolBarLayout->columnCount() +
 
543
                                                                6, _size );
 
544
}
 
545
 
 
546
 
 
547
 
 
548
 
545
549
void lmmsMainWin::resetWindowTitle( const QString & _add )
546
550
{
547
551
        QString title = _add;
564
568
 
565
569
 
566
570
 
 
571
void lmmsMainWin::keyPressEvent( QKeyEvent * _ke )
 
572
{
 
573
        switch( _ke->key() )
 
574
        {
 
575
                case Qt::Key_Control: m_keyMods.m_ctrl = TRUE; break;
 
576
                case Qt::Key_Shift: m_keyMods.m_shift = TRUE; break;
 
577
                case Qt::Key_Alt: m_keyMods.m_alt = TRUE; break;
 
578
                default:
 
579
                        QMainWindow::keyPressEvent( _ke );
 
580
        }
 
581
}
 
582
 
 
583
 
 
584
 
 
585
 
 
586
void lmmsMainWin::keyReleaseEvent( QKeyEvent * _ke )
 
587
{
 
588
        switch( _ke->key() )
 
589
        {
 
590
                case Qt::Key_Control: m_keyMods.m_ctrl = FALSE; break;
 
591
                case Qt::Key_Shift: m_keyMods.m_shift = FALSE; break;
 
592
                case Qt::Key_Alt: m_keyMods.m_alt = FALSE; break;
 
593
                default:
 
594
                        QMainWindow::keyReleaseEvent( _ke );
 
595
        }
 
596
}
 
597
 
 
598
 
 
599
 
 
600
 
567
601
void lmmsMainWin::closeEvent( QCloseEvent * _ce )
568
602
{
569
603
        if( songEditor::inst()->mayChangeProject() == TRUE )
600
634
        {
601
635
                songEditor::inst()->createNewProjectFromTemplate(
602
636
                        configManager::inst()->projectsDir() + "templates/" +
603
 
                                m_templatesMenu->text( _idx ) + ".xml" );
 
637
                                m_templatesMenu->text( _idx ) + ".mpt" );
604
638
        }
605
639
#endif
606
640
}
614
648
        {
615
649
#ifdef QT4
616
650
                QFileDialog ofd( this, tr( "Open project" ), "",
617
 
                                        tr( "MultiMedia Project (*.xml)" ) );
 
651
                                tr( "MultiMedia Project (*.mmp *.xml)" ) );
618
652
#else
619
653
                QFileDialog ofd( QString::null,
620
 
                                        tr( "MultiMedia Project (*.xml)" ),
 
654
                                tr( "MultiMedia Project (*.mmp *.xml)" ),
621
655
                                                        this, "", TRUE );
622
656
                ofd.setWindowTitle( tr( "Open project" ) );
623
657
#endif
655
689
{
656
690
#ifdef QT4
657
691
        QFileDialog sfd( this, tr( "Save project" ), "",
658
 
                                        tr( "MultiMedia Project (*.xml)" ) );
 
692
                                tr( "MultiMedia Project (*.mmp);;"
 
693
                                "MultiMedia Project Template (*.mpt)" ) );
659
694
#else
660
 
        QFileDialog sfd( QString::null, tr( "MultiMedia Project (*.xml)" ),
 
695
        QFileDialog sfd( QString::null,
 
696
                                tr( "MultiMedia Project (*.mmp);;"
 
697
                                        "MultiMedia Project Template (*.mpt)" ),
661
698
                                                        this, "", TRUE );
662
699
        sfd.setWindowTitle( tr( "Save project" ) );
663
700
#endif
701
738
void lmmsMainWin::toggleBBEditorWin( void )
702
739
{
703
740
        if( bbEditor::inst()->isHidden() == TRUE ||
704
 
                        m_workspace->activeWindow() != bbEditor::inst() )
 
741
                ( m_workspace != NULL &&
 
742
                        m_workspace->activeWindow() != bbEditor::inst() ) )
705
743
        {
706
744
                bbEditor::inst()->show();
707
745
                bbEditor::inst()->setFocus();
718
756
void lmmsMainWin::toggleSongEditorWin( void )
719
757
{
720
758
        if( songEditor::inst()->isHidden() == TRUE ||
721
 
                        m_workspace->activeWindow() != songEditor::inst() )
 
759
                ( m_workspace != NULL &&
 
760
                        m_workspace->activeWindow() != songEditor::inst() ) )
722
761
        {
723
762
                songEditor::inst()->show();
724
763
                songEditor::inst()->setFocus();
735
774
void lmmsMainWin::toggleProjectNotesWin( void )
736
775
{
737
776
        if( songEditor::inst()->getProjectNotesWindow()->isHidden() == TRUE ||
738
 
                m_workspace->activeWindow() !=
739
 
                                songEditor::inst()->getProjectNotesWindow() )
 
777
                ( m_workspace != NULL && m_workspace->activeWindow() !=
 
778
                                songEditor::inst()->getProjectNotesWindow() ) )
740
779
        {
741
780
                songEditor::inst()->getProjectNotesWindow()->show();
742
781
                songEditor::inst()->getProjectNotesWindow()->setFocus();
753
792
void lmmsMainWin::togglePianoRollWin( void )
754
793
{
755
794
        if( pianoRoll::inst()->isHidden() == TRUE ||
756
 
                        m_workspace->activeWindow() != pianoRoll::inst() )
 
795
                ( m_workspace != NULL &&
 
796
                        m_workspace->activeWindow() != pianoRoll::inst() ) )
757
797
        {
758
798
                pianoRoll::inst()->show();
759
799
                pianoRoll::inst()->setFocus();
789
829
                                        tr( "Currently there's no help "
790
830
                                                "available in LMMS.\n"
791
831
                                                "Please visit "
792
 
                                                "http://lmms.sourceforge.net "
793
 
                                                "and click on "
794
 
                                                "\"Documentation\".\nThere "
795
 
                                                "hopefully you'll find the "
796
 
                                                "stuff you want to know..." ),
 
832
                                                "http://wiki.mindrules.net "
 
833
                                                "for documentation on LMMS." ),
797
834
                                        QMessageBox::Ok );
798
835
}
799
836