/** * Create or recreate the Mixer GUI elements * * @param saveConfig Whether to save all View configurations before recreating * @param forceNewTab To enforce opening a new tab, even when the profileList in the kmixrc is empty. * It should only be set to "true" in case of a Hotplug (because then the user definitely expects a new Tab to show). */ void KMixWindow::recreateGUI(bool saveConfig, const QString& mixerId, bool forceNewTab) { // -1- Remember which of the tabs is currently selected for restoration for re-insertion int oldTabPosition = m_wsMixers->currentIndex(); if (saveConfig) saveViewConfig(); // save the state before recreating // -2- RECREATE THE ALREADY EXISTING TABS ********************************** QMap<Mixer*, bool> mixerHasProfile; // -2a- Build a list of all active profiles in the main window (that means: from all tabs) QList<GUIProfile*> activeGuiProfiles; for (int i = 0; i < m_wsMixers->count(); ++i) { KMixerWidget* kmw = dynamic_cast<KMixerWidget*>(m_wsMixers->widget(i)); if (kmw) { activeGuiProfiles.append(kmw->getGuiprof()); } } // TODO The following loop is a bit buggy, as it iterates over all cached Profiles. But that is wrong for Tabs that got closed. // I need to loop over something else, e.g. a profile list built from the currently open Tabs. // Or (if it that is easier) I might discard the Profile from the cache on "close-tab" (but that must also include unplug actions). foreach( GUIProfile* guiprof, activeGuiProfiles){ KMixerWidget* kmw = findKMWforTab(guiprof->getId()); Mixer *mixer = Mixer::findMixer( guiprof->getMixerId() ); if ( mixer == 0 ) { kError() << "MixerToolBox::find() hasn't found the Mixer for the profile " << guiprof->getId(); continue; } mixerHasProfile[mixer] = true; if ( kmw == 0 ) { // does not yet exist => create addMixerWidget(mixer->id(), guiprof->getId(), -1); } else { // did exist => remove and insert new guiprof at old position int indexOfTab = m_wsMixers->indexOf(kmw); if ( indexOfTab != -1 ) m_wsMixers->removeTab(indexOfTab); delete kmw; addMixerWidget(mixer->id(), guiprof->getId(), indexOfTab); } } // Loop over all GUIProfile's
void KMixWindow::saveConfig() { saveBaseConfig(); saveViewConfig(); saveVolumes(); #ifdef __GNUC_ #warn We must Sync here, or we will lose configuration data. The reson for that is unknown. #endif // TODO cesken The reason for not writing might be that we have multiple cascaded KConfig objects. I must migrate to KSharedConfig !!! KGlobal::config()->sync(); kDebug() << "Saved config ... sync finished"; }
void Window::confirmReadyOperation() { switch (this->userOperation) { case NOP: break; case START: // Display system is started this->running = true; setSystemRunning(true); this->userOperation = NOP; break; case STOP: // Display system is stopped this->running = false; setSystemRunning(false); this->userOperation = NOP; break; case SYSTOPEN: // Open configuration openSystemConfig(); // System will then restart if it was stopped if (this->running == true) { this->userOperation = NOP; emit(this->startCore()); } this->userOperation = NOP; break; case SYSTSAVE: // Save configuration saveSystemConfig(); // System will then restart if it was stopped if (this->running == true) { this->userOperation = NOP; emit(this->startCore()); } this->userOperation = NOP; break; case SYSTREFRESH: // Refresh the appearance refreshSystemCore(); // System will then restart if it was stopped if (this->running == true) { this->userOperation = NOP; emit(this->startCore()); } this->userOperation = NOP; break; case VIEWOPEN: // Open configuration openViewConfig(); // System will then restart if it was stopped if (this->running == true) { this->userOperation = NOP; emit(this->startCore()); } this->userOperation = NOP; break; case VIEWSAVE: // Save configuration saveViewConfig(); // System will then restart if it was stopped if (this->running == true) { this->userOperation = NOP; emit(this->startCore()); } this->userOperation = NOP; break; case VIEWREFRESH: // Refresh the appearance refreshViewAppearance(); // System will then restart if it was stopped if (this->running == true) { this->userOperation = NOP; emit(this->startCore()); } this->userOperation = NOP; break; } }