* plugins and core: use new pluginPixmapLoader

* lmmsStyle-class: load stylesheet here
* comboBox/comboBoxModel: use pixmapLoader-pointers rather than QPixmap-pointers
* in plugin-descriptor, hold a pointer to pixmapLoader instead of QPixmap itself
* embed-framework: introduced pixmapLoader and pluginPixmapLoader-classes for abstracting QPixmap-instantiation - models can hold pixmapLoaders without actually instantiating a QPixmap-object and views can access the pixmap
* main-window: removed settings-menu and moved setup-dialog to edit-menu
* config-manager: removed all the obsolete first-startup-wizard-code



git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@999 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-05-20 23:41:45 +00:00
parent 895cde07b1
commit aa08d06068
45 changed files with 309 additions and 746 deletions

View File

@@ -26,6 +26,7 @@
#include "bb_track_container.h"
#include "bb_track.h"
#include "combobox.h"
#include "embed.h"
#include "engine.h"
#include "song.h"
@@ -214,8 +215,7 @@ void bbTrackContainer::updateComboBox( void )
{
bbTrack * bbt = bbTrack::findBBTrack( i );
m_bbComboBoxModel.addItem( bbt->name(),
bbt->pixmap() ? new QPixmap( *bbt->pixmap() )
: NULL );
new pixmapLoader( bbt->icon() ) );
}
setCurrentBB( cur_bb );
}

View File

@@ -33,64 +33,11 @@
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtGui/QMessageBox>
#include <QtGui/QLabel>
#include <QtGui/QLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QFileDialog>
#include <QtGui/QRadioButton>
#include <QtGui/QButtonGroup>
#include <QtGui/QApplication>
#include "config_mgr.h"
#include "embed.h"
#include "gui_templates.h"
/*
void linkFile( const QString & _src, const QString & _dst )
{
#ifdef QT4
// simple clean solution with Qt4...
QFile::link( _src, _dst );
#else
// ...but Qt3 needs additional (unportable) code...
symlink( _src.ascii(), _dst.ascii() );
#endif
}
void copyFile( const QString & _src, const QString & _dst )
{
#ifdef QT4
// simple clean solution with Qt4...
QFile::copy( _src, _dst );
#else
// ...but Qt3 needs additional code...
QFile in( _src );
QFile out( _dst );
in.open( IO_ReadOnly );
out.open( IO_WriteOnly );
char buffer[1024];
while( !in.atEnd() )
{
Q_LONG read = in.readBlock( buffer, 1024 );
if( read == -1 )
{
break;
}
if( out.writeBlock( buffer, read ) == -1 )
{
break;
}
}
#endif
}
*/
#include "main_window.h"
@@ -98,7 +45,6 @@ configManager * configManager::s_instanceOfMe = NULL;
configManager::configManager( void ) :
QDialog(),
m_lmmsRcFile( QDir::home().absolutePath() + "/.lmmsrc.xml" ),
m_workingDir( QDir::home().absolutePath() + "/lmms" ),
m_dataDir( qApp->applicationDirPath().section( '/', 0, -2 ) +
@@ -107,9 +53,7 @@ configManager::configManager( void ) :
m_pluginDir( qApp->applicationDirPath().section( '/', 0, -2 ) +
"/lib/lmms/" ),
m_vstDir( QDir::home().absolutePath() ),
m_flDir( QDir::home().absolutePath() ),
m_currentPage( 0 ),
m_mainLayout( NULL )
m_flDir( QDir::home().absolutePath() )
{
}
@@ -124,308 +68,7 @@ configManager::~configManager()
void configManager::createWidgets( void )
{
m_mainLayout = new QHBoxLayout( this );
m_mainLayout->setMargin( 0 );
m_mainLayout->setSpacing( 10 );
m_mainLayout->addSpacing( 8 );
setLayout( m_mainLayout );
m_contentWidget = new QWidget( this );
m_contentLayout = new QVBoxLayout( m_contentWidget );
m_contentLayout->setMargin( 0 );
m_contentLayout->setSpacing( 10 );
m_contentLayout->addSpacing( 8 );
m_contentWidget->setLayout( m_contentLayout );
m_mainLayout->addWidget( m_contentWidget );
m_mainLayout->addSpacing( 8 );
// wizard-init
m_hbar = new QFrame( m_contentWidget );
m_hbar->setFrameStyle( QFrame::Sunken + QFrame::HLine );
m_hbar->setFixedHeight( 4 );
m_title = new QLabel( m_contentWidget );
m_title->setFixedHeight( 16 );
QFont f = m_title->font();
f.setBold( TRUE );
m_title->setFont( pointSize<12>( f ) );
QWidget * button_widget = new QWidget( m_contentWidget );
button_widget->setFixedHeight( 40 );
m_buttonLayout = new QHBoxLayout( button_widget );
m_buttonLayout->setMargin( 0 );
m_buttonLayout->setSpacing( 0 );
m_buttonLayout->addStretch( 1 );
button_widget->setLayout( m_buttonLayout );
m_cancelButton = new QPushButton( tr( "&Cancel" ), button_widget );
m_backButton = new QPushButton( tr( "< &Back" ), button_widget );
m_nextButton = new QPushButton( tr( "&Next >" ), button_widget );
m_finishButton = new QPushButton( tr( "&Finish" ), button_widget );
connect( m_cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( m_backButton, SIGNAL( clicked() ), this,
SLOT( backButtonClicked() ) );
connect( m_nextButton, SIGNAL( clicked() ), this,
SLOT( nextButtonClicked() ) );
connect( m_finishButton, SIGNAL( clicked() ), this,
SLOT( accept() ) );
m_buttonLayout->addWidget( m_cancelButton );
m_buttonLayout->addWidget( m_backButton );
m_buttonLayout->addWidget( m_nextButton );
m_buttonLayout->addWidget( m_finishButton );
m_buttonLayout->addSpacing( 15 );
m_contentLayout->addWidget( m_title );
m_contentLayout->addWidget( m_hbar );
m_contentLayout->addWidget( button_widget );
m_contentLayout->addSpacing( 8 );
// wizard-setup
setWindowTitle( tr( "Setup LMMS" ) );
setWindowIcon( embed::getIconPixmap( "wizard" ) );
m_pageIntro = new QWidget( m_contentWidget );
QHBoxLayout * intro_layout = new QHBoxLayout( m_pageIntro );
intro_layout->setMargin( 0 );
intro_layout->setSpacing( 15 );
m_pageIntro->setLayout( intro_layout );
QLabel * intro_logo_lbl = new QLabel( m_pageIntro );
intro_logo_lbl->setPixmap( embed::getIconPixmap( "wizard_intro" ) );
intro_logo_lbl->setFrameStyle( QFrame::Panel | QFrame::Sunken );
intro_logo_lbl->setFixedSize( 240, 300 );
QLabel * intro_txt_lbl = new QLabel( tr( "LMMS needs to be setup in "
"order to run properly. "
"This wizard will help you to "
"setup your personal LMMS-"
"installation.\n\n"
"If you're unsure what to do "
"at a step, just click on "
"'Next'. LMMS will "
"automatically select the best "
"options for you.\n\n\n"
"Now click on 'Next' to get to "
"the next page." ),
m_pageIntro );
intro_txt_lbl->setWordWrap( TRUE );
intro_layout->addWidget( intro_logo_lbl );
intro_layout->addWidget( intro_txt_lbl );
m_pageWorkingDir = new QWidget( m_contentWidget );
QHBoxLayout * workingdir_layout = new QHBoxLayout( m_pageWorkingDir );
workingdir_layout->setMargin( 0 );
workingdir_layout->setSpacing( 15 );
QLabel * workingdir_logo_lbl = new QLabel( m_pageWorkingDir );
workingdir_logo_lbl->setPixmap( embed::getIconPixmap(
"wizard_workingdir" ) );
workingdir_logo_lbl->setFrameStyle( QFrame::Panel | QFrame::Sunken );
workingdir_logo_lbl->setFixedSize( 240, 300 );
QWidget * workingdir_content = new QWidget( m_pageWorkingDir );
QVBoxLayout * workingdir_content_layout = new QVBoxLayout(
workingdir_content );
workingdir_content_layout->setMargin( 0 );
workingdir_content_layout->setSpacing( 0 );
QLabel * workingdir_txt_lbl = new QLabel(
tr( "When working with LMMS there needs to "
"be a working-directory.\nThis "
"directory is used for storing your "
"projects, presets, samples etc.\n\n\n"
"Please select a directory:" ),
workingdir_content );
workingdir_txt_lbl->setWordWrap( TRUE );
QWidget * workingdir_input_fields = new QWidget( workingdir_content );
QHBoxLayout * workingdir_input_fields_layout = new QHBoxLayout(
workingdir_input_fields );
workingdir_input_fields_layout->setSpacing( 10 );
workingdir_input_fields_layout->setMargin( 0 );
m_wdLineEdit = new QLineEdit( m_workingDir, workingdir_input_fields );
connect( m_wdLineEdit, SIGNAL( textChanged( const QString & ) ), this,
SLOT( setWorkingDir( const QString & ) ) );
QPushButton * workingdir_select_btn = new QPushButton(
embed::getIconPixmap( "project_open" ), "",
workingdir_input_fields );
workingdir_select_btn->setFixedSize( 24, 24 );
connect( workingdir_select_btn, SIGNAL( clicked() ), this,
SLOT( openWorkingDir() ) );
workingdir_input_fields_layout->addWidget( m_wdLineEdit );
workingdir_input_fields_layout->addWidget( workingdir_select_btn );
workingdir_content_layout->addWidget( workingdir_txt_lbl );
workingdir_content_layout->addWidget( workingdir_input_fields );
workingdir_layout->addWidget( workingdir_logo_lbl );
workingdir_layout->addWidget( workingdir_content );
/*
// page for files-management
m_pageFiles = new QWidget( m_contentWidget );
QHBoxLayout * files_layout = new QHBoxLayout( m_pageFiles );
files_layout->setSpacing( 15 );
files_layout->setMargin( 0 );
QWidget * files_content = new QWidget( m_pageFiles );
QVBoxLayout * files_content_layout = new QVBoxLayout( files_content );
files_content_layout->setSpacing( 10 );
files_content_layout->setMargin( 0 );
#ifdef QT4
files_content->setLayout( files_content_layout );
#endif
QLabel * files_logo_lbl = new QLabel( m_pageFiles );
files_logo_lbl->setPixmap( embed::getIconPixmap( "wizard_files" ) );
files_logo_lbl->setFrameStyle( QFrame::Panel | QFrame::Sunken );
files_logo_lbl->setFixedSize( 240, 300 );
QLabel * files_txt_lbl = new QLabel(
tr( "For using the ready presets and samples of "
"LMMS and enjoying the demo-songs the "
"according files have to be copied or "
"linked into your LMMS-working-"
"directory.\nWhen copying files, you "
"can modify them, but they need "
"additional space in your working-"
"directory. If you link files, you "
"cannot modify them, but they need "
"no extra space. So it's recommended "
"to copy presets and demo-projects "
"and link samples, which are bigger "
"in size.\n" ), files_content );
#ifdef QT4
files_txt_lbl->setWordWrap( TRUE );
#else
files_txt_lbl->setAlignment( files_txt_lbl->alignment() | WordBreak );
#endif
QWidget * samples_widget = new QWidget( files_content );
QHBoxLayout * samples_layout = new QHBoxLayout( samples_widget );
samples_layout->setSpacing( 5 );
samples_layout->setMargin( 0 );
QLabel * samples_pic_lbl = new QLabel( samples_widget );
samples_pic_lbl->setPixmap( embed::getIconPixmap( "sound_file" ) );
QLabel * samples_txt_lbl = new QLabel( tr( "samples:" ),
samples_widget );
samples_txt_lbl->setFixedWidth( 144 );
QButtonGroup * samples_bg = new QButtonGroup( samples_widget );
#ifndef qt4
samples_bg->hide();
#endif
m_samplesCopyRB = new QRadioButton( tr( "copy" ), samples_widget );
QRadioButton * samples_link_rb = new QRadioButton( tr( "link" ),
samples_widget );
samples_link_rb->setChecked( TRUE );
samples_bg->addButton( m_samplesCopyRB );
samples_bg->addButton( samples_link_rb );
samples_layout->addWidget( samples_pic_lbl );
samples_layout->addWidget( samples_txt_lbl );
samples_layout->addWidget( m_samplesCopyRB );
samples_layout->addSpacing( 15 );
samples_layout->addWidget( samples_link_rb );
samples_layout->addStretch( 400 );
QWidget * presets_widget = new QWidget( files_content );
QHBoxLayout * presets_layout = new QHBoxLayout( presets_widget );
presets_layout->setSpacing( 5 );
presets_layout->setMargin( 0 );
QLabel * presets_pic_lbl = new QLabel( presets_widget );
presets_pic_lbl->setPixmap( embed::getIconPixmap( "preset_file" ) );
QLabel * presets_txt_lbl = new QLabel( tr( "presets:" ),
presets_widget );
presets_txt_lbl->setFixedWidth( 144 );
QButtonGroup * presets_bg = new QButtonGroup( presets_widget );
#ifndef QT4
presets_bg->hide();
#endif
m_presetsCopyRB = new QRadioButton( tr( "copy" ), presets_widget );
m_presetsCopyRB->setChecked( TRUE );
QRadioButton * presets_link_rb = new QRadioButton( tr( "link" ),
presets_widget );
presets_bg->addButton( m_presetsCopyRB );
presets_bg->addButton( presets_link_rb );
presets_layout->addWidget( presets_pic_lbl );
presets_layout->addWidget( presets_txt_lbl );
presets_layout->addWidget( m_presetsCopyRB );
presets_layout->addSpacing( 15 );
presets_layout->addWidget( presets_link_rb );
presets_layout->addStretch( 400 );
QWidget * projects_widget = new QWidget( files_content );
QHBoxLayout * projects_layout = new QHBoxLayout( projects_widget );
projects_layout->setSpacing( 5 );
projects_layout->setMargin( 0 );
QLabel * projects_pic_lbl = new QLabel( projects_widget );
projects_pic_lbl->setPixmap( embed::getIconPixmap( "project_file" ) );
QLabel * projects_txt_lbl = new QLabel( tr( "demo projects:" ),
projects_widget );
projects_txt_lbl->setFixedWidth( 144 );
QButtonGroup * projects_bg = new QButtonGroup( projects_widget );
#ifndef QT4
projects_bg->hide();
#endif
m_projectsCopyRB = new QRadioButton( tr( "copy" ), projects_widget );
m_projectsCopyRB->setChecked( TRUE );
QRadioButton * projects_link_rb = new QRadioButton( tr( "link" ),
projects_widget );
projects_bg->addButton( m_projectsCopyRB );
projects_bg->addButton( projects_link_rb );
projects_layout->addWidget( projects_pic_lbl );
projects_layout->addWidget( projects_txt_lbl );
projects_layout->addWidget( m_projectsCopyRB );
projects_layout->addSpacing( 15 );
projects_layout->addWidget( projects_link_rb );
projects_layout->addStretch( 400 );
files_content_layout->addWidget( files_txt_lbl );
files_content_layout->addWidget( samples_widget );
files_content_layout->addWidget( presets_widget );
files_content_layout->addWidget( projects_widget );
files_layout->addWidget( files_logo_lbl );
files_layout->addWidget( files_content );
*/
addPage( m_pageIntro, tr( "Welcome to LMMS" ) );
addPage( m_pageWorkingDir, tr( "Select working directory" ) );
//addPage( m_pageFiles, tr( "Copy or link files" ) );
switchPage( static_cast<int>( 0 ) );
}
void configManager::openWorkingDir( void )
/*void configManager::openWorkingDir( void )
{
QString new_dir = QFileDialog::getExistingDirectory( this,
tr( "Choose LMMS working directory" ),
@@ -434,7 +77,7 @@ void configManager::openWorkingDir( void )
{
m_wdLineEdit->setText( new_dir );
}
}
}*/
@@ -488,7 +131,7 @@ void configManager::setSTKDir( const QString & _fd )
/*
void configManager::accept( void )
{
if( m_workingDir.right( 1 ) != "/" )
@@ -517,100 +160,12 @@ void configManager::accept( void )
QDir().mkpath( userProjectsDir() );
QDir().mkpath( userSamplesDir() );
QDir().mkpath( userPresetsDir() );
/* processFilesRecursively( m_dataDir + "samples/", m_workingDir +
"samples/",
m_samplesCopyRB->isChecked() ?
&copyFile :
&linkFile );
processFilesRecursively( m_dataDir + "presets/", m_workingDir +
"presets/",
m_presetsCopyRB->isChecked() ?
&copyFile :
&linkFile );
processFilesRecursively( m_dataDir + "projects/", m_workingDir +
"projects/",
m_projectsCopyRB->isChecked() ?
&copyFile :
&linkFile );*/
saveConfigFile();
QDialog::accept();
}
void configManager::backButtonClicked( void )
{
switchPage( m_currentPage-1 );
}
void configManager::nextButtonClicked( void )
{
switchPage( m_currentPage+1 );
}
void configManager::switchPage( int _pg )
{
if( m_currentPage >= 0 && m_currentPage < m_pages.size() )
{
m_pages[m_currentPage].first->hide();
m_contentLayout->removeWidget( m_pages[m_currentPage].first );
}
if( _pg < m_pages.size() )
{
QWidget * p = m_pages[_pg].first;
m_contentLayout->insertWidget( 2, p );
p->show();
p->setFocus();
m_title->setText( m_pages[_pg].second );
m_currentPage = _pg;
}
m_backButton->setEnabled( _pg > 0 );
if( _pg == m_pages.size() - 1 )
{
m_nextButton->setEnabled( FALSE );
m_finishButton->setEnabled( TRUE );
m_finishButton->setDefault( TRUE );
}
else
{
m_nextButton->setEnabled( TRUE );
m_nextButton->setDefault( TRUE );
m_finishButton->setEnabled( FALSE );
}
}
void configManager::switchPage( QWidget * _pg )
{
for( int i = 0; i < m_pages.size(); ++i )
{
if( m_pages[i].first == _pg )
{
switchPage( i );
break;
}
}
}
void configManager::addPage( QWidget * _w, const QString & _title )
{
_w->hide();
m_pages.push_back( qMakePair( _w, _title ) );
}
*/
@@ -674,24 +229,16 @@ void configManager::setValue( const QString & _class,
bool configManager::loadConfigFile( void )
{
if( !m_mainLayout )
{
createWidgets();
}
// read the XML file and create DOM tree
QFile cfg_file( m_lmmsRcFile );
if( !cfg_file.open( QIODevice::ReadOnly ) )
{
if( !( exec() && cfg_file.open( QIODevice::ReadOnly ) ) )
{
return( FALSE );
}
return( FALSE );
}
QDomDocument dom_tree;
if( !dom_tree.setContent( &cfg_file ) )
{
QMessageBox::critical( 0, tr( "Error in configuration-file" ),
/* QMessageBox::critical( 0, tr( "Error in configuration-file" ),
tr( "Error while parsing "
"configuration-file %1.\n"
"The setup-wizard will be "
@@ -703,9 +250,9 @@ bool configManager::loadConfigFile( void )
return( loadConfigFile() );
}
else
{
{*/
return( FALSE );
}
//}
}
cfg_file.close();
@@ -796,40 +343,9 @@ bool configManager::loadConfigFile( void )
}
#endif
if( root.isElement() )
{
QString cfg_file_ver = root.toElement().attribute( "version" );
if( ( cfg_file_ver.length() == 0 || cfg_file_ver != VERSION ) &&
value( "app", "nowizard" ).toInt() == FALSE &&
QMessageBox::question
( 0, tr( "Version mismatches" ),
tr( "Accordingly to the information in "
"your LMMS-configuration-file "
"you seem to have run a "
"different (probably older) "
"version of LMMS before.\n"
"It is recommended to run the "
"setup-wizard again to ensure "
"that the latest samples, "
"presets, demo-projects etc. "
"are installed in your "
"LMMS-working-directory.\n"
"Run the setup-wizard now?" ),
QMessageBox::Yes, QMessageBox::No )
== QMessageBox::Yes )
{
if( exec() )
{
return( loadConfigFile() );
}
}
}
QDir::setSearchPaths( "resources", QStringList() << artworkDir()
<< defaultArtworkDir() );
loadStyleSheet();
return( TRUE );
}
@@ -881,15 +397,14 @@ void configManager::saveConfigFile( void )
QFile outfile( m_lmmsRcFile );
if( !outfile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
{
QMessageBox::critical( NULL, tr( "Could not save config-file" ),
tr( "Could not save configuration "
"file %1. You probably are not "
"permitted to write to this "
"file.\n"
"Please make sure you have "
"write-access to the file and "
"try again." ).arg(
m_lmmsRcFile ) );
QMessageBox::critical( NULL,
mainWindow::tr( "Could not save config-file" ),
mainWindow::tr( "Could not save configuration file %1. "
"You're probably not permitted to "
"write to this file.\n"
"Please make sure you have write-"
"access to the file and try again." ).
arg( m_lmmsRcFile ) );
return;
}
@@ -899,45 +414,4 @@ void configManager::saveConfigFile( void )
void configManager::loadStyleSheet( void )
{
QFile file( "resources:style.css" );
file.open( QIODevice::ReadOnly );
qApp->setStyleSheet( file.readAll() );
}
/*
void configManager::processFilesRecursively( const QString & _src_dir,
const QString & _dst_dir,
void( * _proc_func )( const QString & _src, const QString & _dst ) )
{
QDir().mkpath( _dst_dir );
QStringList files = QDir( _src_dir ).entryList();
for( QStringList::iterator it = files.begin(); it != files.end(); ++it )
{
if( ( *it )[0] == '.' )
{
continue;
}
if( QFileInfo( _src_dir + *it ).isFile() )
{
_proc_func( _src_dir + *it, _dst_dir + *it );
}
else if( QFileInfo( _src_dir + *it ).isDir () )
{
processFilesRecursively( _src_dir + *it + "/",
_dst_dir + *it + "/",
_proc_func );
}
}
}
*/
#include "config_mgr.moc"
#endif

View File

@@ -30,6 +30,7 @@
#include "instrument_track.h"
#include "dummy_instrument.h"
#include "note_play_handle.h"
#include "embed.h"
instrument::instrument( instrumentTrack * _instrument_track,
@@ -153,8 +154,8 @@ void instrumentView::setModel( ::model * _model, bool )
if( dynamic_cast<instrument *>( _model ) != NULL )
{
modelView::setModel( _model );
getInstrumentTrackWindow()->setWindowIcon( *( model()->
getDescriptor()->logo ) );
getInstrumentTrackWindow()->setWindowIcon(
model()->getDescriptor()->logo->pixmap() );
connect( model(), SIGNAL( destroyed( QObject * ) ),
this, SLOT( close() ) );
}

View File

@@ -310,12 +310,9 @@ arpeggiator::arpeggiator( instrumentTrack * _instrument_track ) :
m_arpDirectionModel.setInitValue( ArpDirUp );
m_arpModeModel.setTrack( _instrument_track );
m_arpModeModel.addItem( tr( "Free" ), new QPixmap(
embed::getIconPixmap( "arp_free" ) ) );
m_arpModeModel.addItem( tr( "Sort" ), new QPixmap(
embed::getIconPixmap( "arp_sort" ) ) );
m_arpModeModel.addItem( tr( "Sync" ), new QPixmap(
embed::getIconPixmap( "arp_sync" ) ) );
m_arpModeModel.addItem( tr( "Free" ), new pixmapLoader( "arp_free" ) );
m_arpModeModel.addItem( tr( "Sort" ), new pixmapLoader( "arp_sort" ) );
m_arpModeModel.addItem( tr( "Sync" ), new pixmapLoader( "arp_sync" ) );
}

View File

@@ -79,22 +79,22 @@ instrumentSoundShaping::instrumentSoundShaping(
m_filterEnabledModel.setTrack( _instrument_track );
m_filterModel.addItem( tr( "LowPass" ), new QPixmap(
embed::getIconPixmap( "filter_lp" ) ) );
m_filterModel.addItem( tr( "HiPass" ), new QPixmap(
embed::getIconPixmap( "filter_hp" ) ) );
m_filterModel.addItem( tr( "BandPass csg" ), new QPixmap(
embed::getIconPixmap( "filter_bp" ) ) );
m_filterModel.addItem( tr( "BandPass czpg" ), new QPixmap(
embed::getIconPixmap( "filter_bp" ) ) );
m_filterModel.addItem( tr( "Notch" ), new QPixmap(
embed::getIconPixmap( "filter_notch" ) ) );
m_filterModel.addItem( tr( "Allpass" ), new QPixmap(
embed::getIconPixmap( "filter_ap" ) ) );
m_filterModel.addItem( tr( "Moog" ), new QPixmap(
embed::getIconPixmap( "filter_lp" ) ) );
m_filterModel.addItem( tr( "2x LowPass" ), new QPixmap(
embed::getIconPixmap( "filter_2lp" ) ) );
m_filterModel.addItem( tr( "LowPass" ),
new pixmapLoader( "filter_lp" ) );
m_filterModel.addItem( tr( "HiPass" ),
new pixmapLoader( "filter_hp" ) );
m_filterModel.addItem( tr( "BandPass csg" ),
new pixmapLoader( "filter_bp" ) );
m_filterModel.addItem( tr( "BandPass czpg" ),
new pixmapLoader( "filter_bp" ) );
m_filterModel.addItem( tr( "Notch" ),
new pixmapLoader( "filter_notch" ) );
m_filterModel.addItem( tr( "Allpass" ),
new pixmapLoader( "filter_ap" ) );
m_filterModel.addItem( tr( "Moog" ),
new pixmapLoader( "filter_lp" ) );
m_filterModel.addItem( tr( "2x LowPass" ),
new pixmapLoader( "filter_2lp" ) );
m_filterModel.setTrack( _instrument_track );
m_filterCutModel.setTrack( _instrument_track );

View File

@@ -32,6 +32,7 @@
#include "plugin.h"
#include "embed.h"
#include "mixer.h"
#include "config_mgr.h"
#include "dummy_plugin.h"
@@ -60,7 +61,7 @@ plugin::plugin( const descriptor * _descriptor, model * _parent ) :
{
if( dummy_plugin_descriptor.logo == NULL )
{
dummy_plugin_descriptor.logo = new QPixmap();
dummy_plugin_descriptor.logo = new pixmapLoader;
}
if( m_descriptor == NULL )

View File

@@ -27,9 +27,9 @@
#include "tool.h"
#include <QtGui/QIcon>
#include <QtGui/QMdiArea>
#include "embed.h"
#include "engine.h"
#include "main_window.h"
@@ -86,7 +86,7 @@ toolView::toolView( tool * _tool ) :
}
window->setWindowTitle( _tool->publicName() );
window->setWindowIcon( *_tool->getDescriptor()->logo );
window->setWindowIcon( _tool->getDescriptor()->logo->pixmap() );
}

View File

@@ -1312,7 +1312,7 @@ track::track( TrackTypes _type, trackContainer * _tc ) :
m_trackContainer( _tc ),
m_type( _type ),
m_name(),
m_pixmap( NULL ),
m_pixmapLoader( NULL ),
m_mutedModel( FALSE, this ),
m_trackContentObjects(),
m_automationPatterns()

View File

@@ -3,7 +3,7 @@
/*
* embed.cpp - misc stuff for using embedded resources (linked into binary)
*
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*

View File

@@ -1,17 +1,57 @@
/*
* lmms_style.cpp - the graphical style used by LMMS to create a consistent
* interface
*
* Copyright (c) 2007-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#include <QtCore/QFile>
#include <QtGui/QApplication>
#include <QtGui/QFrame>
#include <QtGui/QPainter>
#include <QtGui/QPlastiqueStyle>
#include <QtGui/QStyleOption>
#include <QtGui/QPainter>
#include <QtGui/QWidget>
#include <QtGui/QFrame>
#include "lmms_style.h"
lmmsStyle::lmmsStyle() :
QPlastiqueStyle()
{
QFile file( "resources:style.css" );
file.open( QIODevice::ReadOnly );
qApp->setStyleSheet( file.readAll() );
}
void lmmsStyle::drawPrimitive( PrimitiveElement element,
const QStyleOption *option, QPainter *painter,
const QWidget *widget) const
{
if( element == QStyle::PE_Frame || element == QStyle::PE_FrameLineEdit ||
if( element == QStyle::PE_Frame ||
element == QStyle::PE_FrameLineEdit ||
element == QStyle::PE_PanelLineEdit )
{
const QRect rect = option->rect;
@@ -32,10 +72,14 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element,
// 50%
black.setAlpha(a100);
painter->setPen(QPen(black, 0));
lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, rect.top() + 1);
lines[1] = QLine(rect.left() + 2, rect.bottom() - 1, rect.right() - 2, rect.bottom() - 1);
lines[2] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2);
lines[3] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2);
lines[0] = QLine(rect.left() + 2, rect.top() + 1,
rect.right() - 2, rect.top() + 1);
lines[1] = QLine(rect.left() + 2, rect.bottom() - 1,
rect.right() - 2, rect.bottom() - 1);
lines[2] = QLine(rect.left() + 1, rect.top() + 2,
rect.left() + 1, rect.bottom() - 2);
lines[3] = QLine(rect.right() - 1, rect.top() + 2,
rect.right() - 1, rect.bottom() - 2);
painter->drawLines(lines, 4);
// black inside dots
@@ -52,8 +96,10 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element,
// 100%
shadow.setAlpha(a75);
painter->setPen(QPen(shadow, 0));
lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top());
lines[1] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2);
lines[0] = QLine(rect.left() + 2, rect.top(),
rect.right() - 2, rect.top());
lines[1] = QLine(rect.left(), rect.top() + 2,
rect.left(), rect.bottom() - 2);
painter->drawLines(lines, 2);
// outside corner dots - shadow
@@ -79,8 +125,10 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element,
// 100%
highlight.setAlpha(a75);
painter->setPen(QPen(highlight, 0));
lines[0] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom());
lines[1] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2);
lines[0] = QLine(rect.left() + 2, rect.bottom(),
rect.right() - 2, rect.bottom());
lines[1] = QLine(rect.right(), rect.top() + 2,
rect.right(), rect.bottom() - 2);
painter->drawLines(lines, 2);
// outside corner dots - highlight
@@ -103,13 +151,15 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element,
}
else
{
QPlastiqueStyle::drawPrimitive( element, option, painter, widget );
QPlastiqueStyle::drawPrimitive( element, option, painter,
widget );
}
}
int lmmsStyle::pixelMetric( PixelMetric _metric, const QStyleOption * _option, const QWidget * _widget ) const
int lmmsStyle::pixelMetric( PixelMetric _metric, const QStyleOption * _option,
const QWidget * _widget ) const
{
switch( _metric )
{
@@ -120,7 +170,8 @@ int lmmsStyle::pixelMetric( PixelMetric _metric, const QStyleOption * _option, c
return 20;
default:
return QPlastiqueStyle::pixelMetric( _metric, _option, _widget );
return QPlastiqueStyle::pixelMetric( _metric, _option,
_widget );
}
}

View File

@@ -405,16 +405,9 @@ void mainWindow::finalize( void )
tr( "Redo" ),
this, SLOT( redo() ),
Qt::CTRL + Qt::Key_R );
QMenu * settings_menu = new QMenu( this );
menuBar()->addMenu( settings_menu )->setText( tr( "&Settings" ) );
settings_menu->addAction( embed::getIconPixmap( "setup_general" ),
tr( "Show settings dialog" ),
edit_menu->addAction( embed::getIconPixmap( "setup_general" ),
tr( "Settings" ),
this, SLOT( showSettingsDialog() ) );
settings_menu->addAction( embed::getIconPixmap( "wizard" ),
tr( "Show setup wizard" ),
configManager::inst(), SLOT( exec() ) );
m_toolsMenu = new QMenu( this );
@@ -426,7 +419,8 @@ void mainWindow::finalize( void )
{
if( it->type == plugin::Tool )
{
m_toolsMenu->addAction( *it->logo, it->public_name );
m_toolsMenu->addAction( it->logo->pixmap(),
it->public_name );
m_tools.push_back( tool::instantiate( it->name,
/*this*/NULL )->createView( this ) );
}

View File

@@ -379,16 +379,14 @@ pianoRoll::pianoRoll( void ) :
QLabel * note_len_lbl = new QLabel( m_toolBar );
note_len_lbl->setPixmap( embed::getIconPixmap( "note" ) );
m_noteLenModel->addItem( tr( "Last note" ), new QPixmap(
embed::getIconPixmap( "edit_draw" ) ) );
m_noteLenModel->addItem( tr( "Last note" ),
new pixmapLoader( "edit_draw" ) );
const QString pixmaps[] = { "whole", "half", "quarter", "eighth",
"sixteenth", "thirtysecond" } ;
for( int i = 0; i < 6; ++i )
{
m_noteLenModel->addItem( "1/" + QString::number( 1 << i ),
new QPixmap( embed::getIconPixmap(
QString( "note_" + pixmaps[i] ).
toAscii().constData() ) ) );
new pixmapLoader( "note_" + pixmaps[i] ) );
}
m_noteLenModel->addItem( "1/192" );
m_noteLenModel->setValue( 0 );

View File

@@ -101,7 +101,7 @@ pluginDescWidget::pluginDescWidget( const plugin::descriptor & _pd,
QWidget( _parent ),
m_updateTimer( this ),
m_pluginDescriptor( _pd ),
m_logo( *_pd.logo ),
m_logo( _pd.logo->pixmap() ),
m_mouseOver( FALSE ),
m_targetHeight( 24 )
{

View File

@@ -128,8 +128,8 @@ void comboBox::mousePressEvent( QMouseEvent * _me )
for( int i = 0; i < model()->size(); ++i )
{
QAction * a = m_menu.addAction(
model()->itemPixmap( i ) ?
*model()->itemPixmap( i ) :
model()->itemPixmap( i ) ?
model()->itemPixmap( i )->pixmap() :
QPixmap(),
model()->itemText( i ) );
a->setData( i );
@@ -201,11 +201,11 @@ void comboBox::paintEvent( QPaintEvent * _pe )
p.setFont( font() );
p.setClipRect( QRect( 5, 2, width() - CB_ARROW_BTN_WIDTH - 8,
height() - 2 ) );
const QPixmap * item_pm = model()->currentData();
QPixmap pm = model()->currentData() ?
model()->currentData()->pixmap() : QPixmap();
int tx = 4;
if( item_pm != NULL )
if( !pm.isNull() )
{
QPixmap pm = *item_pm;
if( pm.height() > 16 )
{
pm = pm.scaledToHeight( 16,
@@ -237,14 +237,6 @@ void comboBox::wheelEvent( QWheelEvent * _we )
void comboBox::deletePixmap( QPixmap * _pixmap )
{
delete _pixmap;
}
void comboBox::setItem( QAction * _item )
{
model()->setInitValue( _item->data().toInt() );
@@ -258,9 +250,9 @@ void comboBox::setItem( QAction * _item )
void comboBoxModel::addItem( const QString & _item, QPixmap * _pixmap )
void comboBoxModel::addItem( const QString & _item, pixmapLoader * _pl )
{
m_items.push_back( qMakePair( _item, _pixmap ) );
m_items.push_back( qMakePair( _item, _pl ) );
setRange( 0, m_items.size() - 1 );
}
@@ -272,7 +264,7 @@ void comboBoxModel::clear( void )
setRange( 0, 0 );
foreach( const item & _i, m_items )
{
emit itemPixmapRemoved( _i.second );
delete _i.second;
}
m_items.clear();
emit propertiesChanged();