Merge remote-tracking branch 'origin/next' into stable-0.4

This commit is contained in:
Tobias Doerffel
2014-01-07 23:24:26 +01:00
10 changed files with 151 additions and 94 deletions

View File

@@ -1,8 +1,9 @@
/*
* main.cpp - just main.cpp which is starting up app...
*
* Copyright (c) 2004-2011 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* Copyright (c) 2004-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2012-2013 Paul Giblock <p/at/pgiblock.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -61,6 +62,7 @@
#include "ImportFilter.h"
#include "MainWindow.h"
#include "ProjectRenderer.h"
#include "mmp.h"
#include "song.h"
#warning TODO: move somewhere else
@@ -130,7 +132,7 @@ int main( int argc, char * * argv )
QString( argv[i] ) == "-v" )
{
printf( "\nLinux MultiMedia Studio %s\n\n"
"Copyright (c) 2004-2008 LMMS developers.\n\n"
"Copyright (c) 2004-2013 LMMS developers.\n\n"
"This program is free software; you can redistribute it and/or\n"
"modify it under the terms of the GNU General Public\n"
"License as published by the Free Software Foundation; either\n"
@@ -143,7 +145,7 @@ int main( int argc, char * * argv )
QString( argv[i] ) == "-h" ) )
{
printf( "\nLinux MultiMedia Studio %s\n"
"Copyright (c) 2004-2008 LMMS developers.\n\n"
"Copyright (c) 2004-2013 LMMS developers.\n\n"
"usage: lmms [ -r <project file> ] [ options ]\n"
" [ -u <in> <out> ]\n"
" [ -d <in> ]\n"
@@ -166,7 +168,8 @@ int main( int argc, char * * argv )
"-x, --oversampling <value> specify oversampling\n"
" possible values: 1, 2, 4, 8\n"
" default: 2\n"
"-u, --upgrade <in> <out> upgrade file <in> and save as <out>\n"
"-u, --upgrade <in> [out] upgrade file <in> and save as <out>\n"
" standard out is used if no output file is specifed\n"
"-d, --dump <in> dump XML of compressed file <in>\n"
"-v, --version show version information and exit.\n"
"-h, --help show this usage information and exit.\n\n",
@@ -176,9 +179,18 @@ int main( int argc, char * * argv )
else if( argc > i+1 && ( QString( argv[i] ) == "--upgrade" ||
QString( argv[i] ) == "-u" ) )
{
file_to_load = argv[i + 1];
file_to_save = argv[i + 2];
i += 2;
multimediaProject mmp( QString( argv[i + 1] ) );
if (argc > i+2)
{
mmp.writeFile( argv[i + 2] );
}
else
{
QTextStream ts( stdout );
mmp.write( ts );
fflush( stdout );
}
return( EXIT_SUCCESS );
}
else if( argc > i && ( QString( argv[i] ) == "--dump" ||
QString( argv[i] ) == "-d" ) )
@@ -187,7 +199,7 @@ int main( int argc, char * * argv )
f.open( QIODevice::ReadOnly );
QString d = qUncompress( f.readAll() );
printf( "%s\n", d.toUtf8().constData() );
return( 0 );
return( EXIT_SUCCESS );
}
else if( argc > i && ( QString( argv[i] ) == "--render" ||
QString( argv[i] ) == "-r" ) )
@@ -371,7 +383,7 @@ int main( int argc, char * * argv )
configManager::inst()->loadConfigFile();
if( render_out.isEmpty() && file_to_save.isEmpty() )
if( render_out.isEmpty() )
{
// init style and palette
QApplication::setStyle( new lmmsStyle() );
@@ -479,31 +491,23 @@ int main( int argc, char * * argv )
engine::getSong()->loadProject( file_to_load );
printf( "done\n" );
if( !render_out.isEmpty() )
{
// create renderer
ProjectRenderer * r = new ProjectRenderer( qs, os, eff,
render_out +
QString( ( eff ==
ProjectRenderer::WaveFile ) ?
"wav" : "ogg" ) );
QCoreApplication::instance()->connect( r,
SIGNAL( finished() ), SLOT( quit() ) );
// create renderer
ProjectRenderer * r = new ProjectRenderer( qs, os, eff,
render_out +
QString( ( eff ==
ProjectRenderer::WaveFile ) ?
"wav" : "ogg" ) );
QCoreApplication::instance()->connect( r,
SIGNAL( finished() ), SLOT( quit() ) );
// timer for progress-updates
QTimer * t = new QTimer( r );
r->connect( t, SIGNAL( timeout() ),
SLOT( updateConsoleProgress() ) );
t->start( 200 );
// timer for progress-updates
QTimer * t = new QTimer( r );
r->connect( t, SIGNAL( timeout() ),
SLOT( updateConsoleProgress() ) );
t->start( 200 );
// start now!
r->startProcessing();
}
else
{
engine::getSong()->saveProjectFile( file_to_save );
return( 0 );
}
// start now!
r->startProcessing();
}
const int ret = app->exec();

View File

@@ -2,6 +2,7 @@
* mmp.cpp - implementation of class multimediaProject
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2012-2013 Paul Giblock <p/at/pgiblock.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -66,6 +67,7 @@ multimediaProject::multimediaProject( ProjectTypes _project_type ) :
m_head(),
m_type( _project_type )
{
appendChild( createProcessingInstruction("xml", "version=\"1.0\""));
QDomElement root = createElement( "multimedia-project" );
root.setAttribute( "version", MMP_VERSION_STRING );
root.setAttribute( "type", typeName( _project_type ) );
@@ -163,7 +165,7 @@ QString multimediaProject::nameWithExtension( const QString & _fn ) const
bool multimediaProject::writeFile( const QString & _fn )
void multimediaProject::write( QTextStream & _strm )
{
if( type() == SongProject || type() == SongProjectTemplate
|| type() == InstrumentTrackSettings )
@@ -171,7 +173,14 @@ bool multimediaProject::writeFile( const QString & _fn )
cleanMetaNodes( documentElement() );
}
save(_strm, 2);
}
bool multimediaProject::writeFile( const QString & _fn )
{
QString fn = nameWithExtension( _fn );
QFile outfile( fn );
if( !outfile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
@@ -189,14 +198,18 @@ bool multimediaProject::writeFile( const QString & _fn )
).arg( fn ) );
return false;
}
QString xml = "<?xml version=\"1.0\"?>\n" + toString( 2 );
if( fn.section( '.', -1 ) == "mmpz" )
{
QString xml;
QTextStream ts( &xml );
write( ts );
outfile.write( qCompress( xml.toUtf8() ) );
}
else
{
QTextStream( &outfile ) << xml;
QTextStream ts( &outfile );
write( ts );
}
outfile.close();

View File

@@ -895,46 +895,46 @@ void trackContentWidget::updateBackground()
// Assume even-pixels-per-tact. Makes sense, should be like this anyways
int ppt = static_cast<int>( tcv->pixelsPerTact() );
int w = ppt * tactsPerBar;
int h = height();
m_background = QPixmap( w * 2, height() );
QPainter pmp( &m_background );
int w = ppt * tactsPerBar;
int h = height();
m_background = QPixmap( w * 2, height() );
QPainter pmp( &m_background );
QLinearGradient grad( 0, 1, 0, h-2 );
pmp.fillRect( 0, 0, 1, h, QColor( 96, 96, 96 ) );
pmp.fillRect( 1, 0, w+1, h, QColor( 128, 128, 128 ) );
grad.setColorAt( 0.0, QColor( 64, 64, 64 ) );
grad.setColorAt( 0.3, QColor( 128, 128, 128 ) );
grad.setColorAt( 0.5, QColor( 128, 128, 128 ) );
grad.setColorAt( 0.95, QColor( 160, 160, 160 ) );
pmp.fillRect( 0, 1, w, h-2, grad );
QLinearGradient grad( 0, 1, 0, h-2 );
pmp.fillRect( 0, 0, 1, h, QColor( 96, 96, 96 ) );
pmp.fillRect( 1, 0, w+1, h, QColor( 128, 128, 128 ) );
grad.setColorAt( 0.0, QColor( 64, 64, 64 ) );
grad.setColorAt( 0.3, QColor( 128, 128, 128 ) );
grad.setColorAt( 0.5, QColor( 128, 128, 128 ) );
grad.setColorAt( 0.95, QColor( 160, 160, 160 ) );
pmp.fillRect( 0, 1, w, h-2, grad );
QLinearGradient grad2( 0,1, 0, h-2 );
pmp.fillRect( w+1, 0, w , h, QColor( 96, 96, 96 ) );
grad2.setColorAt( 0.0, QColor( 48, 48, 48 ) );
grad2.setColorAt( 0.3, QColor( 96, 96, 96 ) );
grad2.setColorAt( 0.5, QColor( 96, 96, 96 ) );
grad2.setColorAt( 0.95, QColor( 120, 120, 120 ) );
pmp.fillRect( w, 1, w , h-2, grad2 );
QLinearGradient grad2( 0,1, 0, h-2 );
pmp.fillRect( w+1, 0, w , h, QColor( 96, 96, 96 ) );
grad2.setColorAt( 0.0, QColor( 48, 48, 48 ) );
grad2.setColorAt( 0.3, QColor( 96, 96, 96 ) );
grad2.setColorAt( 0.5, QColor( 96, 96, 96 ) );
grad2.setColorAt( 0.95, QColor( 120, 120, 120 ) );
pmp.fillRect( w, 1, w , h-2, grad2 );
// draw vertical lines
pmp.setPen( QPen( QColor( 0, 0, 0, 112 ), 1 ) );
for( float x = 0.5; x < w * 2; x += ppt )
{
pmp.drawLine( QLineF( x, 1.0, x, h-2.0 ) );
}
pmp.drawLine( 0, 1, w*2, 1 );
// draw vertical lines
pmp.setPen( QPen( QColor( 0, 0, 0, 112 ), 1 ) );
for( float x = 0.5; x < w * 2; x += ppt )
{
pmp.drawLine( QLineF( x, 1.0, x, h-2.0 ) );
}
pmp.drawLine( 0, 1, w*2, 1 );
pmp.setPen( QPen( QColor( 255, 255, 255, 32 ), 1 ) );
for( float x = 1.5; x < w * 2; x += ppt )
{
pmp.drawLine( QLineF( x, 1.0, x, h-2.0 ) );
}
pmp.drawLine( 0, h-2, w*2, h-2 );
pmp.setPen( QPen( QColor( 255, 255, 255, 32 ), 1 ) );
for( float x = 1.5; x < w * 2; x += ppt )
{
pmp.drawLine( QLineF( x, 1.0, x, h-2.0 ) );
}
pmp.drawLine( 0, h-2, w*2, h-2 );
pmp.end();
pmp.end();
// Force redraw
// Force redraw
update();
}
@@ -1206,7 +1206,9 @@ void trackContentWidget::paintEvent( QPaintEvent * _pe )
*/
void trackContentWidget::resizeEvent( QResizeEvent * resizeEvent )
{
// Update backgroud
updateBackground();
// Force redraw
QWidget::resizeEvent( resizeEvent );
}

View File

@@ -3,6 +3,7 @@
* actual setting of dynamic values
*
* Copyright (c) 2008-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2008-2013 Paul Giblock <pgib/at/users.sourceforge.net>
* Copyright (c) 2006-2008 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
@@ -89,6 +90,8 @@ AutomationEditor::AutomationEditor() :
m_action( NONE ),
m_moveStartLevel( 0 ),
m_moveStartTick( 0 ),
m_drawLastLevel( 0.0f ),
m_drawLastTick( 0 ),
m_ppt( DEFAULT_PPT ),
m_y_delta( DEFAULT_Y_DELTA ),
m_y_auto( TRUE ),

View File

@@ -32,7 +32,7 @@
#include "engine.h"
#include "embed.h"
#include "MainWindow.h"
#include "string_pair_drag.h"
@@ -115,6 +115,7 @@ void automatableButton::mousePressEvent( QMouseEvent * _me )
if( _me->button() == Qt::LeftButton &&
! ( _me->modifiers() & Qt::ControlModifier ) )
{
// User simply clicked, toggle if needed
if( isCheckable() )
{
toggle();
@@ -123,8 +124,23 @@ void automatableButton::mousePressEvent( QMouseEvent * _me )
}
else
{
AutomatableModelView::mousePressEvent( _me );
QPushButton::mousePressEvent( _me );
// Ctrl-clicked, need to prepare drag-drop
if( m_group )
{
// A group, we must get process it instead
AutomatableModelView* groupView = (AutomatableModelView*)m_group;
new stringPairDrag( "automatable_model",
QString::number( groupView->modelUntyped()->id() ),
QPixmap(), widget() );
// TODO: ^^ Maybe use a predefined icon instead of the button they happened to select
_me->accept();
}
else
{
// Otherwise, drag the standalone button
AutomatableModelView::mousePressEvent( _me );
QPushButton::mousePressEvent( _me );
}
}
}