diff --git a/include/PianoRoll.h b/include/PianoRoll.h index bc2a0d8cb1b..8f1dabdc350 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -295,7 +295,7 @@ protected slots: int m_oldNotesEditHeight; int m_notesEditHeight; - int m_ppt; + int m_ppt; // pixels per tact int m_totalKeysToScroll; // remember these values to use them diff --git a/include/Plugin.h b/include/Plugin.h index b73238ab5c7..40a075c67ac 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -134,7 +134,7 @@ class EXPORT Plugin : public Model, public JournallingObject const Plugin::PluginTypes m_type; } ; - SubPluginFeatures * subPluginFeatures; + SubPluginFeatures *subPluginFeatures; } ; @@ -148,7 +148,9 @@ class EXPORT Plugin : public Model, public JournallingObject // returns display-name out of descriptor virtual QString displayName() const { - return Model::displayName().isEmpty() ? m_descriptor->displayName : Model::displayName(); + return Model::displayName().isEmpty() + ? m_descriptor->displayName + : Model::displayName(); } // return plugin-type @@ -173,13 +175,13 @@ class EXPORT Plugin : public Model, public JournallingObject // returns an instance of a plugin whose name matches to given one // if specified plugin couldn't be loaded, it creates a dummy-plugin - static Plugin * instantiate( const QString& pluginName, Model * parent, void * data ); + static Plugin * instantiate( const QString& pluginName, Model *parent, void * data ); // fills given list with descriptors of all available plugins static void getDescriptorsOfAvailPlugins( DescriptorList& pluginDescriptors ); // create a view for the model - PluginView * createView( QWidget* parent ); + PluginView* createView( QWidget* parent ); protected: diff --git a/include/lmms_basics.h b/include/lmms_basics.h index bdd72f4fab7..ea02f77d183 100644 --- a/include/lmms_basics.h +++ b/include/lmms_basics.h @@ -78,9 +78,9 @@ struct typeInfo return 1; } - static inline bool isEqual( T _x, T _y ) + static inline bool isEqual( T x, T y ) { - return _x == _y; + return x == y; } static inline T absVal( T t ) @@ -97,13 +97,13 @@ inline float typeInfo::minEps() } template<> -inline bool typeInfo::isEqual( float _x, float _y ) +inline bool typeInfo::isEqual( float x, float y ) { - if( likely( _x == _y ) ) + if( x == y ) { return true; } - return absVal( _x - _y ) < minEps(); + return absVal( x - y ) < minEps(); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 612a7409e63..cccc7bd398f 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -83,7 +83,6 @@ MainWindow::MainWindow() : vbox->setSpacing( 0 ); vbox->setMargin( 0 ); - QWidget * w = new QWidget( main_widget ); QHBoxLayout * hbox = new QHBoxLayout( w ); hbox->setSpacing( 0 ); @@ -94,24 +93,25 @@ MainWindow::MainWindow() : QSplitter * splitter = new QSplitter( Qt::Horizontal, w ); splitter->setChildrenCollapsible( false ); - QString wdir = ConfigManager::inst()->workingDir(); + ConfigManager* confMgr = ConfigManager::inst(); + sideBar->appendTab( new PluginBrowser( splitter ) ); sideBar->appendTab( new FileBrowser( - ConfigManager::inst()->userProjectsDir() + "*" + - ConfigManager::inst()->factoryProjectsDir(), + confMgr->userProjectsDir() + "*" + + confMgr->factoryProjectsDir(), "*.mmp *.mmpz *.xml *.mid *.flp", tr( "My Projects" ), embed::getIconPixmap( "project_file" ).transformed( QTransform().rotate( 90 ) ), splitter, false, true ) ); sideBar->appendTab( new FileBrowser( - ConfigManager::inst()->userSamplesDir() + "*" + - ConfigManager::inst()->factorySamplesDir(), + confMgr->userSamplesDir() + "*" + + confMgr->factorySamplesDir(), "*", tr( "My Samples" ), embed::getIconPixmap( "sample_file" ).transformed( QTransform().rotate( 90 ) ), splitter, false, true ) ); sideBar->appendTab( new FileBrowser( - ConfigManager::inst()->userPresetsDir() + "*" + - ConfigManager::inst()->factoryPresetsDir(), + confMgr->userPresetsDir() + "*" + + confMgr->factoryPresetsDir(), "*.xpf *.cs.xml *.xiz", tr( "My Presets" ), embed::getIconPixmap( "preset_file" ).transformed( QTransform().rotate( 90 ) ), @@ -121,33 +121,30 @@ MainWindow::MainWindow() : embed::getIconPixmap( "home" ).transformed( QTransform().rotate( 90 ) ), splitter, false, true ) ); + QStringList root_paths; + QString title = tr( "Root directory" ); + bool dirs_as_items = false; + #ifdef LMMS_BUILD_APPLE + title = tr( "Volumes" ); root_paths += "/Volumes"; -#else +#elif defined(LMMS_BUILD_WIN32) + title = tr( "My Computer" ); + dirs_as_items = true; +#endif + +#if ! defined(LMMS_BUILD_APPLE) QFileInfoList drives = QDir::drives(); foreach( const QFileInfo & drive, drives ) { root_paths += drive.absolutePath(); } #endif - sideBar->appendTab( new FileBrowser( root_paths.join( "*" ), "*", -#ifdef LMMS_BUILD_WIN32 - tr( "My Computer" ), -#elif defined(LMMS_BUILD_APPLE) - tr( "Volumes" ), -#else - tr( "Root Directory" ), -#endif + sideBar->appendTab( new FileBrowser( root_paths.join( "*" ), "*", title, embed::getIconPixmap( "computer" ).transformed( QTransform().rotate( 90 ) ), - splitter, -#ifdef LMMS_BUILD_WIN32 - true -#else - false -#endif - ) ); + splitter, dirs_as_items) ); m_workspace = new QMdiArea( splitter ); @@ -190,13 +187,13 @@ MainWindow::MainWindow() : vbox->addWidget( w ); setCentralWidget( main_widget ); - m_updateTimer.start( 1000 / 20, this ); // 20 fps + m_updateTimer.start( 1000 / 20, this ); // 20 fps if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() ) { // connect auto save connect(&m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave())); - m_autoSaveTimer.start(1000 * 60); // 1 minute + m_autoSaveTimer.start(1000 * 60); // 1 minute } connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), @@ -208,12 +205,10 @@ MainWindow::MainWindow() : MainWindow::~MainWindow() { - for( QList::iterator it = m_tools.begin(); - it != m_tools.end(); ++it ) + for( PluginView *view : m_tools ) { - Model * m = ( *it )->model(); - delete *it; - delete m; + delete view->model(); + delete view; } // TODO: Close tools // destroy engine which will do further cleanups etc. diff --git a/src/gui/PluginBrowser.cpp b/src/gui/PluginBrowser.cpp index 5c10dd368ac..96f33ae7501 100644 --- a/src/gui/PluginBrowser.cpp +++ b/src/gui/PluginBrowser.cpp @@ -88,8 +88,6 @@ PluginBrowser::~PluginBrowser() - - PluginDescList::PluginDescList(QWidget *parent) : QWidget(parent) { @@ -98,7 +96,6 @@ PluginDescList::PluginDescList(QWidget *parent) : Plugin::getDescriptorsOfAvailPlugins( m_pluginDescriptors ); std::sort(m_pluginDescriptors.begin(), m_pluginDescriptors.end(), pluginBefore); - for( Plugin::DescriptorList::const_iterator it = m_pluginDescriptors.constBegin(); it != m_pluginDescriptors.constEnd(); ++it ) { @@ -117,8 +114,6 @@ PluginDescList::PluginDescList(QWidget *parent) : - - PluginDescWidget::PluginDescWidget( const Plugin::Descriptor & _pd, QWidget * _parent ) : QWidget( _parent ), @@ -181,7 +176,6 @@ void PluginDescWidget::paintEvent( QPaintEvent * ) m_targetHeight = qMax( 60, 25 + br.height() ); } } - } @@ -237,6 +231,7 @@ void PluginDescWidget::updateHeight() m_updateTimer.stop(); return; } + if( !m_updateTimer.isActive() ) { m_updateTimer.start( 15 ); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index d837292b71e..928752ace0c 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -375,7 +375,8 @@ PianoRoll::PianoRoll() : this, SLOT( quantizeChanged() ) ); // Set up scale model - const auto& chord_table = InstrumentFunctionNoteStacking::ChordTable::getInstance(); + const InstrumentFunctionNoteStacking::ChordTable& chord_table = + InstrumentFunctionNoteStacking::ChordTable::getInstance(); m_scaleModel.addItem( tr("No scale") ); for( const InstrumentFunctionNoteStacking::Chord& chord : chord_table ) @@ -3814,7 +3815,8 @@ int PianoRoll::quantization() const void PianoRoll::updateSemiToneMarkerMenu() { - const auto& chord_table = InstrumentFunctionNoteStacking::ChordTable::getInstance(); + const InstrumentFunctionNoteStacking::ChordTable& chord_table = + InstrumentFunctionNoteStacking::ChordTable::getInstance(); const InstrumentFunctionNoteStacking::Chord& scale = chord_table.getScaleByName( m_scaleModel.currentText() ); const InstrumentFunctionNoteStacking::Chord& chord = diff --git a/src/gui/embed.cpp b/src/gui/embed.cpp index 08af0c0a2cf..4e6ecaa13b7 100644 --- a/src/gui/embed.cpp +++ b/src/gui/embed.cpp @@ -45,73 +45,70 @@ namespace #include "embedded_resources.h" -QPixmap getIconPixmap( const char * _name, int _w, int _h ) +QPixmap getIconPixmap( const char * pixmapName, int width, int height ) { - if( _w == -1 || _h == -1 ) + if( width == -1 || height == -1 ) { - // Return cached pixmap - QPixmap cached = s_pixmapCache.value( _name ); + // Return cached pixmap + QPixmap cached = s_pixmapCache.value( pixmapName ); if( !cached.isNull() ) { return cached; } // Or try to load it - QList formats = - QImageReader::supportedImageFormats(); + QList formats = QImageReader::supportedImageFormats(); QList candidates; - QPixmap p; + QPixmap pixmap; QString name; int i; - for ( i = 0; i < formats.size() && p.isNull(); ++i ) + for ( i = 0; i < formats.size() && pixmap.isNull(); ++i ) { - candidates << QString( _name ) + "." + formats.at( i ).data(); + candidates << QString( pixmapName ) + "." + formats.at( i ).data(); } #ifdef PLUGIN_NAME - for ( i = 0; i < candidates.size() && p.isNull(); ++i ) { + for ( i = 0; i < candidates.size() && pixmap.isNull(); ++i ) { name = candidates.at( i ); - p = QPixmap( ConfigManager::inst()->artworkDir() + "plugins/" + + pixmap = QPixmap( ConfigManager::inst()->artworkDir() + "plugins/" + STRINGIFY( PLUGIN_NAME ) + "_" + name ); } #endif - for ( i = 0; i < candidates.size() && p.isNull(); ++i ) { + for ( i = 0; i < candidates.size() && pixmap.isNull(); ++i ) { name = candidates.at( i ); - p = QPixmap( ConfigManager::inst()->artworkDir() + name ); + pixmap = QPixmap( ConfigManager::inst()->artworkDir() + name ); } // nothing found, so look in default-artwork-dir - for ( i = 0; i < candidates.size() && p.isNull(); ++i ) { + for ( i = 0; i < candidates.size() && pixmap.isNull(); ++i ) { name = candidates.at( i ); - p = QPixmap( ConfigManager::inst()->defaultArtworkDir() - + name ); + pixmap = QPixmap( ConfigManager::inst()->defaultArtworkDir() + name ); } - for ( i = 0; i < candidates.size() && p.isNull(); ++i ) { + for ( i = 0; i < candidates.size() && pixmap.isNull(); ++i ) { name = candidates.at( i ); const embed::descriptor & e = findEmbeddedData( name.toUtf8().constData() ); // found? - if( QString( e.name ) == name ) + if( name == e.name ) { - p.loadFromData( e.data, e.size ); + pixmap.loadFromData( e.data, e.size ); } } // Fallback - if(p.isNull()) + if( pixmap.isNull() ) { - p = QPixmap( 1, 1 ); + pixmap = QPixmap( 1, 1 ); } // Save to cache and return - s_pixmapCache.insert( _name, p ); - return p; - + s_pixmapCache.insert( pixmapName, pixmap ); + return pixmap; } - return getIconPixmap( _name ). - scaled( _w, _h, Qt::IgnoreAspectRatio, + return getIconPixmap( pixmapName ). + scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); } diff --git a/src/gui/widgets/SideBar.cpp b/src/gui/widgets/SideBar.cpp index 409fbf771ed..990bae7f651 100644 --- a/src/gui/widgets/SideBar.cpp +++ b/src/gui/widgets/SideBar.cpp @@ -107,53 +107,56 @@ SideBar::~SideBar() -void SideBar::appendTab( SideBarWidget * _sbw ) +void SideBar::appendTab( SideBarWidget *widget ) { - SideBarButton * btn = new SideBarButton( orientation(), this ); - btn->setText( _sbw->title() ); - btn->setIcon( _sbw->icon() ); - btn->setCheckable( true ); - m_widgets[btn] = _sbw; - m_btnGroup.addButton( btn ); - addWidget( btn ); - - _sbw->hide(); - _sbw->setMinimumWidth( 200 ); - - ToolTip::add( btn, _sbw->title() ); + SideBarButton *button = new SideBarButton( orientation(), this ); + button->setText( widget->title() ); + button->setIcon( widget->icon() ); + button->setCheckable( true ); + m_widgets[button] = widget; + m_btnGroup.addButton( button ); + addWidget( button ); + + widget->hide(); + widget->setMinimumWidth( 200 ); + + ToolTip::add( button, widget->title() ); } -void SideBar::toggleButton( QAbstractButton * _btn ) +void SideBar::toggleButton( QAbstractButton * button ) { - QToolButton * toolButton = NULL; - QWidget * activeWidget = NULL; - for( ButtonMap::Iterator it = m_widgets.begin(); - it != m_widgets.end(); ++it ) + QToolButton *toolButton = NULL; + QWidget *activeWidget = NULL; + + for( auto it = m_widgets.begin(); it != m_widgets.end(); ++it ) { - QToolButton * curBtn = it.key(); - if( curBtn != _btn ) + QToolButton *curBtn = it.key(); + QWidget *curWidget = it.value(); + + if( curBtn == button ) { - curBtn->setChecked( false ); - curBtn->setToolButtonStyle( Qt::ToolButtonIconOnly ); + toolButton = curBtn; + activeWidget = curWidget; } else { - toolButton = it.key(); - activeWidget = it.value(); + curBtn->setChecked( false ); + curBtn->setToolButtonStyle( Qt::ToolButtonIconOnly ); } - if( it.value() ) + + if( curWidget ) { - it.value()->hide(); + curWidget->hide(); } } if( toolButton && activeWidget ) { - activeWidget->setVisible( _btn->isChecked() ); - toolButton->setToolButtonStyle( _btn->isChecked() ? + activeWidget->setVisible( button->isChecked() ); + toolButton->setToolButtonStyle( button->isChecked() ? Qt::ToolButtonTextBesideIcon : Qt::ToolButtonIconOnly ); } }