Merge pull request #3012 from BaraMGB/renamewindowtitle

Window title will be changed on rename track, now
This commit is contained in:
BaraMGB
2016-09-22 16:36:36 +02:00
committed by GitHub
7 changed files with 163 additions and 63 deletions

View File

@@ -288,6 +288,9 @@ protected slots:
void play();
void stop();
private slots:
void updateWindowTitle();
private:
QAction* m_discreteAction;
QAction* m_linearAction;

View File

@@ -384,7 +384,6 @@ private:
signals:
void positionChanged( const MidiTime & );
} ;
@@ -427,6 +426,10 @@ public:
signals:
void currentPatternChanged();
private slots:
void patternRenamed();
private:
void focusInEvent(QFocusEvent * event);

View File

@@ -64,6 +64,7 @@ protected:
virtual void moveEvent( QMoveEvent * event );
virtual void resizeEvent( QResizeEvent * event );
virtual void paintEvent( QPaintEvent * pe );
virtual void changeEvent( QEvent * event );
private:
const QSize m_buttonSize;
@@ -82,6 +83,7 @@ private:
static void elideText( QLabel *label, QString text );
bool isMaximized();
void adjustTitleBar();
};
#endif

View File

@@ -121,6 +121,20 @@ void SubWindow::paintEvent( QPaintEvent * )
void SubWindow::changeEvent( QEvent *event )
{
QMdiSubWindow::changeEvent( event );
if( event->type() == QEvent::WindowTitleChange )
{
adjustTitleBar();
}
}
void SubWindow::elideText( QLabel *label, QString text )
{
QFontMetrics metrix( label->font() );
@@ -219,7 +233,7 @@ void SubWindow::moveEvent( QMoveEvent * event )
void SubWindow::resizeEvent( QResizeEvent * event )
void SubWindow::adjustTitleBar()
{
// button adjustments
m_minimizeBtn->hide();
@@ -280,12 +294,19 @@ void SubWindow::resizeEvent( QResizeEvent * event )
elideText( m_windowTitle, widget()->windowTitle() );
m_windowTitle->setTextInteractionFlags( Qt::NoTextInteraction );
m_windowTitle->adjustSize();
}
void SubWindow::resizeEvent( QResizeEvent * event )
{
adjustTitleBar();
QMdiSubWindow::resizeEvent( event );
// if the window was resized and ISN'T minimized/maximized/fullscreen,
// then save the current size
if( !isMax && !isMin && !isFullScreen() )
if( !isMaximized() && !isMinimized() && !isFullScreen() )
{
m_trackedNormalGeom.setSize( event->size() );
}

View File

@@ -2318,6 +2318,7 @@ void AutomationEditorWindow::setCurrentPattern(AutomationPattern* pattern)
if (pattern)
{
connect(pattern, SIGNAL(dataChanged()), this, SLOT(update()));
connect( pattern, SIGNAL( dataChanged() ), this, SLOT( updateWindowTitle() ) );
connect(pattern, SIGNAL(destroyed()), this, SLOT(clearCurrentPattern()));
connect(m_flipXAction, SIGNAL(triggered()), pattern, SLOT(flipX()));
@@ -2394,3 +2395,14 @@ void AutomationEditorWindow::stop()
{
m_editor->stop();
}
void AutomationEditorWindow::updateWindowTitle()
{
if ( m_editor->m_pattern == nullptr)
{
setWindowTitle( tr( "Automation Editor - no pattern" ) );
return;
}
setWindowTitle( tr( "Automation Editor - %1" ).arg( m_editor->m_pattern->name() ) );
}

View File

@@ -3997,12 +3997,12 @@ PianoRollWindow::PianoRollWindow() :
Editor(true),
m_editor(new PianoRoll())
{
setCentralWidget(m_editor);
setCentralWidget( m_editor );
m_playAction->setToolTip(tr("Play/pause current pattern (Space)"));
m_recordAction->setToolTip(tr("Record notes from MIDI-device/channel-piano"));
m_recordAccompanyAction->setToolTip(tr("Record notes from MIDI-device/channel-piano while playing song or BB track"));
m_stopAction->setToolTip(tr("Stop playing of current pattern (Space)"));
m_playAction->setToolTip(tr( "Play/pause current pattern (Space)" ) );
m_recordAction->setToolTip(tr( "Record notes from MIDI-device/channel-piano" ) );
m_recordAccompanyAction->setToolTip( tr( "Record notes from MIDI-device/channel-piano while playing song or BB track" ) );
m_stopAction->setToolTip( tr( "Stop playing of current pattern (Space)" ) );
m_playAction->setWhatsThis(
tr( "Click here to play the current pattern. "
@@ -4023,21 +4023,21 @@ PianoRollWindow::PianoRollWindow() :
m_stopAction->setWhatsThis(
tr( "Click here to stop playback of current pattern." ) );
DropToolBar *notesActionsToolBar = addDropToolBarToTop(tr("Edit actions"));
DropToolBar *notesActionsToolBar = addDropToolBarToTop( tr( "Edit actions" ) );
// init edit-buttons at the top
ActionGroup* editModeGroup = new ActionGroup(this);
QAction* drawAction = editModeGroup->addAction(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)"));
QAction* eraseAction = editModeGroup->addAction(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)"));
QAction* selectAction = editModeGroup->addAction(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)"));
QAction* detuneAction = editModeGroup->addAction(embed::getIconPixmap("automation"), tr("Detune mode (Shift+T)"));
ActionGroup* editModeGroup = new ActionGroup( this );
QAction* drawAction = editModeGroup->addAction( embed::getIconPixmap( "edit_draw" ), tr( "Draw mode (Shift+D)" ) );
QAction* eraseAction = editModeGroup->addAction( embed::getIconPixmap( "edit_erase" ), tr("Erase mode (Shift+E)" ) );
QAction* selectAction = editModeGroup->addAction( embed::getIconPixmap( "edit_select" ), tr( "Select mode (Shift+S)" ) );
QAction* detuneAction = editModeGroup->addAction( embed::getIconPixmap( "automation" ), tr("Detune mode (Shift+T)" ) );
drawAction->setChecked( true );
drawAction->setShortcut(Qt::SHIFT | Qt::Key_D);
eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E);
selectAction->setShortcut(Qt::SHIFT | Qt::Key_S);
detuneAction->setShortcut(Qt::SHIFT | Qt::Key_T);
drawAction->setShortcut( Qt::SHIFT | Qt::Key_D );
eraseAction->setShortcut( Qt::SHIFT | Qt::Key_E );
selectAction->setShortcut( Qt::SHIFT | Qt::Key_S );
detuneAction->setShortcut( Qt::SHIFT | Qt::Key_T );
drawAction->setWhatsThis(
tr( "Click here and draw mode will be activated. In this "
@@ -4047,9 +4047,9 @@ PianoRollWindow::PianoRollWindow() :
"activate this mode. In this mode, hold %1 to "
"temporarily go into select mode." ).arg(
#ifdef LMMS_BUILD_APPLE
"") );
"" ) );
#else
"Ctrl") );
"Ctrl" ) );
#endif
eraseAction->setWhatsThis(
tr( "Click here and erase mode will be activated. In this "
@@ -4061,9 +4061,9 @@ PianoRollWindow::PianoRollWindow() :
"you can hold %1 in draw mode to temporarily use "
"select mode." ).arg(
#ifdef LMMS_BUILD_APPLE
"") );
"" ) );
#else
"Ctrl") );
"Ctrl" ) );
#endif
detuneAction->setWhatsThis(
tr( "Click here and detune mode will be activated. "
@@ -4072,10 +4072,10 @@ PianoRollWindow::PianoRollWindow() :
"notes from one to another. You can also press "
"'Shift+T' on your keyboard to activate this mode." ) );
connect(editModeGroup, SIGNAL(triggered(int)), m_editor, SLOT(setEditMode(int)));
connect( editModeGroup, SIGNAL( triggered( int ) ), m_editor, SLOT( setEditMode( int ) ) );
QAction* quantizeAction = new QAction(embed::getIconPixmap("quantize"), tr("Quantize"), this);
connect(quantizeAction, SIGNAL(triggered()), m_editor, SLOT(quantizeNotes()));
QAction* quantizeAction = new QAction(embed::getIconPixmap( "quantize" ), tr( "Quantize" ), this );
connect( quantizeAction, SIGNAL( triggered() ), m_editor, SLOT( quantizeNotes() ) );
notesActionsToolBar->addAction( drawAction );
notesActionsToolBar->addAction( eraseAction );
@@ -4085,30 +4085,30 @@ PianoRollWindow::PianoRollWindow() :
notesActionsToolBar->addAction( quantizeAction );
// Copy + paste actions
DropToolBar *copyPasteActionsToolBar = addDropToolBarToTop(tr("Copy paste controls"));
DropToolBar *copyPasteActionsToolBar = addDropToolBarToTop( tr( "Copy paste controls" ) );
QAction* cutAction = new QAction(embed::getIconPixmap("edit_cut"),
tr("Cut selected notes (%1+X)").arg(
QAction* cutAction = new QAction(embed::getIconPixmap( "edit_cut" ),
tr( "Cut selected notes (%1+X)" ).arg(
#ifdef LMMS_BUILD_APPLE
""), this);
"" ), this );
#else
"Ctrl"), this);
"Ctrl" ), this );
#endif
QAction* copyAction = new QAction(embed::getIconPixmap("edit_copy"),
tr("Copy selected notes (%1+C)").arg(
QAction* copyAction = new QAction(embed::getIconPixmap( "edit_copy" ),
tr( "Copy selected notes (%1+C)" ).arg(
#ifdef LMMS_BUILD_APPLE
""), this);
#else
"Ctrl"), this);
"Ctrl" ), this );
#endif
QAction* pasteAction = new QAction(embed::getIconPixmap("edit_paste"),
tr("Paste notes from clipboard (%1+V)").arg(
QAction* pasteAction = new QAction(embed::getIconPixmap( "edit_paste" ),
tr( "Paste notes from clipboard (%1+V)" ).arg(
#ifdef LMMS_BUILD_APPLE
""), this);
"" ), this );
#else
"Ctrl"), this);
"Ctrl" ), this );
#endif
cutAction->setWhatsThis(
@@ -4123,27 +4123,27 @@ PianoRollWindow::PianoRollWindow() :
tr( "Click here and the notes from the clipboard will be "
"pasted at the first visible measure." ) );
cutAction->setShortcut(Qt::CTRL | Qt::Key_X);
copyAction->setShortcut(Qt::CTRL | Qt::Key_C);
pasteAction->setShortcut(Qt::CTRL | Qt::Key_V);
cutAction->setShortcut( Qt::CTRL | Qt::Key_X );
copyAction->setShortcut( Qt::CTRL | Qt::Key_C );
pasteAction->setShortcut( Qt::CTRL | Qt::Key_V );
connect(cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedNotes()));
connect(copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedNotes()));
connect(pasteAction, SIGNAL(triggered()), m_editor, SLOT(pasteNotes()));
connect( cutAction, SIGNAL( triggered() ), m_editor, SLOT( cutSelectedNotes() ) );
connect( copyAction, SIGNAL( triggered() ), m_editor, SLOT( copySelectedNotes() ) );
connect( pasteAction, SIGNAL( triggered() ), m_editor, SLOT( pasteNotes() ) );
copyPasteActionsToolBar->addAction(cutAction);
copyPasteActionsToolBar->addAction(copyAction);
copyPasteActionsToolBar->addAction(pasteAction);
copyPasteActionsToolBar->addAction( cutAction );
copyPasteActionsToolBar->addAction( copyAction );
copyPasteActionsToolBar->addAction( pasteAction );
DropToolBar *timeLineToolBar = addDropToolBarToTop(tr("Timeline controls"));
m_editor->m_timeLine->addToolButtons(timeLineToolBar);
DropToolBar *timeLineToolBar = addDropToolBarToTop( tr( "Timeline controls" ) );
m_editor->m_timeLine->addToolButtons( timeLineToolBar );
addToolBarBreak();
DropToolBar *zoomAndNotesToolBar = addDropToolBarToTop(tr("Zoom and note controls"));
DropToolBar *zoomAndNotesToolBar = addDropToolBarToTop( tr( "Zoom and note controls" ) );
QLabel * zoom_lbl = new QLabel( m_toolBar );
zoom_lbl->setPixmap( embed::getIconPixmap( "zoom" ) );
@@ -4160,12 +4160,10 @@ PianoRollWindow::PianoRollWindow() :
m_quantizeComboBox->setModel( &m_editor->m_quantizeModel );
m_quantizeComboBox->setFixedSize( 64, 22 );
// setup note-len-stuff
QLabel * note_len_lbl = new QLabel( m_toolBar );
note_len_lbl->setPixmap( embed::getIconPixmap( "note" ) );
m_noteLenComboBox = new ComboBox( m_toolBar );
m_noteLenComboBox->setModel( &m_editor->m_noteLenModel );
m_noteLenComboBox->setFixedSize( 105, 22 );
@@ -4243,7 +4241,6 @@ PianoRollWindow::PianoRollWindow() :
"and in the key you have selected!"
) );
m_chordComboBox->setWhatsThis(
tr(
"Let you select a chord which LMMS then can draw or highlight."
@@ -4254,7 +4251,6 @@ PianoRollWindow::PianoRollWindow() :
"in this drop-down menu."
) );
// setup our actual window
setFocusPolicy( Qt::StrongFocus );
setFocus();
@@ -4262,21 +4258,30 @@ PianoRollWindow::PianoRollWindow() :
setCurrentPattern( NULL );
// Connections
connect(m_editor, SIGNAL(currentPatternChanged()), this, SIGNAL(currentPatternChanged()));
connect( m_editor, SIGNAL( currentPatternChanged() ), this, SIGNAL( currentPatternChanged() ) );
connect( m_editor, SIGNAL( currentPatternChanged() ), this, SLOT( patternRenamed() ) );
}
const Pattern* PianoRollWindow::currentPattern() const
{
return m_editor->currentPattern();
}
void PianoRollWindow::setCurrentPattern(Pattern* pattern)
void PianoRollWindow::setCurrentPattern( Pattern* pattern )
{
m_editor->setCurrentPattern(pattern);
m_editor->setCurrentPattern( pattern );
if ( pattern )
{
setWindowTitle( tr( "Piano-Roll - %1" ).arg( pattern->name() ) );
connect( pattern->instrumentTrack(), SIGNAL( nameChanged() ), this, SLOT( patternRenamed()) );
connect( pattern, SIGNAL( dataChanged() ), this, SLOT( patternRenamed() ) );
}
else
{
@@ -4284,64 +4289,114 @@ void PianoRollWindow::setCurrentPattern(Pattern* pattern)
}
}
bool PianoRollWindow::isRecording() const
{
return m_editor->isRecording();
}
int PianoRollWindow::quantization() const
{
return m_editor->quantization();
}
void PianoRollWindow::play()
{
m_editor->play();
}
void PianoRollWindow::stop()
{
m_editor->stop();
}
void PianoRollWindow::record()
{
m_editor->record();
}
void PianoRollWindow::recordAccompany()
{
m_editor->recordAccompany();
}
void PianoRollWindow::stopRecording()
{
m_editor->stopRecording();
}
void PianoRollWindow::reset()
{
m_editor->reset();
}
void PianoRollWindow::saveSettings(QDomDocument & doc, QDomElement & de)
void PianoRollWindow::saveSettings( QDomDocument & doc, QDomElement & de )
{
MainWindow::saveWidgetState(this, de, QSize( 640, 480 ) );
MainWindow::saveWidgetState( this, de, QSize( 640, 480 ) );
}
void PianoRollWindow::loadSettings(const QDomElement & de)
void PianoRollWindow::loadSettings( const QDomElement & de )
{
MainWindow::restoreWidgetState(this, de);
MainWindow::restoreWidgetState( this, de );
}
QSize PianoRollWindow::sizeHint() const
{
return {m_toolBar->sizeHint().width() + 10, INITIAL_PIANOROLL_HEIGHT};
return { m_toolBar->sizeHint().width() + 10, INITIAL_PIANOROLL_HEIGHT };
}
void PianoRollWindow::focusInEvent(QFocusEvent * event)
void PianoRollWindow::patternRenamed()
{
if ( currentPattern() )
{
setWindowTitle( tr( "Piano-Roll - %1" ).arg( currentPattern()->name() ) );
}
else
{
setWindowTitle( tr( "Piano-Roll - no pattern" ) );
}
}
void PianoRollWindow::focusInEvent( QFocusEvent * event )
{
// when the window is given focus, also give focus to the actual piano roll
m_editor->setFocus(event->reason());
m_editor->setFocus( event->reason() );
}

View File

@@ -154,6 +154,10 @@ void ControllerView::renameController()
if( ok && !new_name.isEmpty() )
{
c->setName( new_name );
if( getController()->type() == Controller::LfoController )
{
m_controllerDlg->setWindowTitle( tr( "LFO" ) + " (" + new_name + ")" );
}
m_nameLabel->setText( new_name );
}
}