--- qsampler/trunk/src/qsamplerMainForm.cpp 2008/12/22 10:04:59 1815 +++ qsampler/trunk/src/qsamplerMainForm.cpp 2010/01/07 18:42:26 2038 @@ -1,7 +1,7 @@ // qsamplerMainForm.cpp // /**************************************************************************** - Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved. Copyright (C) 2007, 2008 Christian Schoenebeck This program is free software; you can redistribute it and/or @@ -56,6 +56,14 @@ #include #include +#if QT_VERSION < 0x040500 +namespace Qt { +const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000); +#if QT_VERSION < 0x040200 +const WindowFlags CustomizeWindowHint = WindowFlags(0x02000000); +#endif +} +#endif #ifdef HAVE_SIGNAL_H #include @@ -375,26 +383,28 @@ // What style do we create these forms? Qt::WindowFlags wflags = Qt::Window -#if QT_VERSION >= 0x040200 | Qt::CustomizeWindowHint -#endif | Qt::WindowTitleHint | Qt::WindowSystemMenuHint - | Qt::WindowMinMaxButtonsHint; + | Qt::WindowMinMaxButtonsHint + | Qt::WindowCloseButtonHint; if (m_pOptions->bKeepOnTop) wflags |= Qt::Tool; + // Some child forms are to be created right now. m_pMessages = new Messages(this); m_pDeviceForm = new DeviceForm(this, wflags); #ifdef CONFIG_MIDI_INSTRUMENT m_pInstrumentListForm = new InstrumentListForm(this, wflags); #else - viewInstrumentsAction->setEnabled(false); + m_ui.viewInstrumentsAction->setEnabled(false); #endif + // Setup messages logging appropriately... m_pMessages->setLogging( m_pOptions->bMessagesLog, m_pOptions->sMessagesLogPath); + // Set message defaults... updateMessagesFont(); updateMessagesLimit(); @@ -585,26 +595,26 @@ case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO: if (m_pDeviceForm) m_pDeviceForm->refreshDevices(); break; -#if CONFIG_EVENT_CHANNEL_MIDI + #if CONFIG_EVENT_CHANNEL_MIDI case LSCP_EVENT_CHANNEL_MIDI: { const int iChannelID = pEvent->data().section(' ', 0, 0).toInt(); ChannelStrip *pChannelStrip = channelStrip(iChannelID); if (pChannelStrip) - pChannelStrip->midiArrived(); + pChannelStrip->midiActivityLedOn(); break; } -#endif -#if CONFIG_EVENT_DEVICE_MIDI + #endif + #if CONFIG_EVENT_DEVICE_MIDI case LSCP_EVENT_DEVICE_MIDI: { const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt(); const int iPortID = pEvent->data().section(' ', 1, 1).toInt(); - DeviceStatusForm* pDeviceStatusForm = - DeviceStatusForm::getInstance(iDeviceID); + DeviceStatusForm *pDeviceStatusForm + = DeviceStatusForm::getInstance(iDeviceID); if (pDeviceStatusForm) pDeviceStatusForm->midiArrived(iPortID); break; } -#endif + #endif default: appendMessagesColor(tr("Notify event: %1 data: %2") .arg(::lscp_event_to_text(pEvent->event())) @@ -613,21 +623,22 @@ } } -void MainForm::updateViewMidiDeviceStatusMenu() { + +void MainForm::updateViewMidiDeviceStatusMenu (void) +{ m_ui.viewMidiDeviceStatusMenu->clear(); - const std::map statusForms = - DeviceStatusForm::getInstances(); - for ( - std::map::const_iterator iter = statusForms.begin(); - iter != statusForms.end(); ++iter - ) { - DeviceStatusForm* pForm = iter->second; + const std::map statusForms + = DeviceStatusForm::getInstances(); + std::map::const_iterator iter + = statusForms.begin(); + for ( ; iter != statusForms.end(); ++iter) { + DeviceStatusForm *pStatusForm = iter->second; m_ui.viewMidiDeviceStatusMenu->addAction( - pForm->visibleAction() - ); + pStatusForm->visibleAction()); } } + // Context menu event handler. void MainForm::contextMenuEvent( QContextMenuEvent *pEvent ) { @@ -759,7 +770,8 @@ "\"%1\"\n\n" "Do you want to replace it?") .arg(sFilename), - tr("Replace"), tr("Cancel")) > 0) + QMessageBox::Yes | QMessageBox::No) + == QMessageBox::No) return false; } } @@ -782,11 +794,13 @@ "\"%1\"\n\n" "Do you want to save the changes?") .arg(sessionName(m_sFilename)), - tr("Save"), tr("Discard"), tr("Cancel"))) { - case 0: // Save... + QMessageBox::Save | + QMessageBox::Discard | + QMessageBox::Cancel)) { + case QMessageBox::Save: bClose = saveSession(false); // Fall thru.... - case 1: // Discard + case QMessageBox::Discard: break; default: // Cancel. bClose = false; @@ -1307,7 +1321,8 @@ "Please note that this operation may cause\n" "temporary MIDI and Audio disruption.\n\n" "Do you want to reset the sampler engine now?"), - tr("Reset"), tr("Cancel")) > 0) + QMessageBox::Ok | QMessageBox::Cancel) + == QMessageBox::Cancel) return; // Trye closing the current session, first... @@ -1348,7 +1363,7 @@ "Please note that this operation may cause\n" "temporary MIDI and Audio disruption.\n\n" "Do you want to restart the connection now?"), - tr("Restart"), tr("Cancel")) == 0); + QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok); } // Are we still for it? @@ -1429,7 +1444,8 @@ "%1\n\n" "Are you sure?") .arg(pChannelStrip->windowTitle()), - tr("OK"), tr("Cancel")) > 0) + QMessageBox::Ok | QMessageBox::Cancel) + == QMessageBox::Cancel) return; } @@ -1647,7 +1663,7 @@ QMessageBox::information(this, QSAMPLER_TITLE ": " + tr("Information"), tr("Some settings may be only effective\n" - "next time you start this program."), tr("OK")); + "next time you start this program.")); updateMessagesCapture(); } // Check wheather something immediate has changed. @@ -1865,9 +1881,10 @@ setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); // Update the main menu state... - ChannelStrip* pChannelStrip = activeChannelStrip(); - bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); + ChannelStrip *pChannelStrip = activeChannelStrip(); + bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); bool bHasChannel = (bHasClient && pChannelStrip != NULL); + bool bHasChannels = (bHasClient && m_pWorkspace->windowList().count() > 0); m_ui.fileNewAction->setEnabled(bHasClient); m_ui.fileOpenAction->setEnabled(bHasClient); m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); @@ -1883,7 +1900,7 @@ m_ui.editEditChannelAction->setEnabled(false); #endif m_ui.editResetChannelAction->setEnabled(bHasChannel); - m_ui.editResetAllChannelsAction->setEnabled(bHasChannel); + m_ui.editResetAllChannelsAction->setEnabled(bHasChannels); m_ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible()); #ifdef CONFIG_MIDI_INSTRUMENT m_ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm @@ -1895,7 +1912,9 @@ m_ui.viewDevicesAction->setChecked(m_pDeviceForm && m_pDeviceForm->isVisible()); m_ui.viewDevicesAction->setEnabled(bHasClient); - m_ui.channelsArrangeAction->setEnabled(bHasChannel); + m_ui.viewMidiDeviceStatusMenu->setEnabled( + DeviceStatusForm::getInstances().size() > 0); + m_ui.channelsArrangeAction->setEnabled(bHasChannels); #ifdef CONFIG_VOLUME // Toolbar widgets are also affected... @@ -2228,7 +2247,7 @@ QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); QMessageBox::critical(this, - QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); + QSAMPLER_TITLE ": " + tr("Error"), s, QMessageBox::Cancel); } @@ -2516,17 +2535,13 @@ // Is the server process instance still here? if (m_pServer) { - switch (QMessageBox::warning(this, + if (QMessageBox::warning(this, QSAMPLER_TITLE ": " + tr("Warning"), tr("Could not start the LinuxSampler server.\n\n" "Maybe it is already started."), - tr("Stop"), tr("Kill"), tr("Cancel"))) { - case 0: + QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { m_pServer->terminate(); - break; - case 1: m_pServer->kill(); - break; } return; } @@ -2600,9 +2615,8 @@ "running in the background. The sampler would continue to work\n" "according to your current sampler session and you could alter the\n" "sampler session at any time by relaunching QSampler.\n\n" - "Do you want LinuxSampler to stop or to keep running in\n" - "the background?"), - tr("Stop"), tr("Keep Running")) == 1) + "Do you want LinuxSampler to stop?"), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { bForceServerStop = false; }