void RosegardenApplication::slotSetStatusMessage(QString msg) { //### dtb: Using topLevelWidgets()[0] in place of mainWidget() is a big assumption on my part. QMainWindow* window = dynamic_cast<QMainWindow*>(topLevelWidgets()[0]); if (window) { if (msg.isEmpty()) msg = TmpStatusMsg::getDefaultMsg(); //@@@ mainWindow->statusBar()->changeItem(QString(" %1").arg(msg), TmpStatusMsg::getDefaultId()); window->statusBar()->showMessage(QString(" %1").arg(msg)); } }
void QApplication::alert(QWidget *widget, int duration) { if (widget) { if (widget->window()->isActiveWindow() && !(widget->window()->windowState() & Qt::WindowMinimized)) return; if (QWindow *window= QApplicationPrivate::windowForWidget(widget)) window->alert(duration); } else { foreach (QWidget *topLevel, topLevelWidgets()) QApplication::alert(topLevel, duration); } }
/*! \reimp */ bool QAccessibleApplication::doAction(int action, int child, const QVariantList ¶m) { if (action == 0 || action == 1) { QWidget *w = 0; w = QApplication::activeWindow(); if (!w) w = topLevelWidgets().at(0); if (!w) return false; w->activateWindow(); return true; } return QAccessibleObject::doAction(action, child, param); }
/*&&& int RosegardenApplication::newInstance() { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (RosegardenMainWindow::self() && args->count() && RosegardenMainWindow::self()->getDocument() && RosegardenMainWindow::self()->getDocument()->saveIfModified()) { // Check for modifications and save if necessary - if cancelled // then don't load the new file. // RosegardenMainWindow::self()->openFile(args->arg(0)); } return KUniqueApplication::newInstance(); } */ void RosegardenApplication::sfxLoadExited(QProcess *proc) { if (proc->exitStatus() != QProcess::NormalExit ) { QSettings settings; settings.beginGroup( SequencerOptionsConfigGroup ); QString soundFontPath = settings.value("soundfontpath", "").toString() ; settings.endGroup(); // corresponding to: settings().beginGroup( SequencerOptionsConfigGroup ); //### dtb: Using topLevelWidgets()[0] in place of mainWidget() is a big assumption on my part. QMessageBox::critical( topLevelWidgets()[0], "", tr("Failed to load soundfont %1").arg(soundFontPath )); } else { RG_DEBUG << "RosegardenApplication::sfxLoadExited() : sfxload exited normally\n"; } }
EditorMainWindow* EditorApplication::GetMainWindow() { auto topLevelWidgetList = topLevelWidgets(); EditorMainWindow* mainWindow = nullptr; for (auto currentWidgetIter = topLevelWidgetList.begin(); currentWidgetIter != topLevelWidgetList.end(); ++currentWidgetIter) { if (EditorMainWindow* currentWidget = qobject_cast<EditorMainWindow*>(*currentWidgetIter)) { mainWindow = currentWidget; break; } } return mainWindow; }
/*! \sa LQApplication::killWidgets(), stopWidgetEngine() */ LQApplication::~LQApplication() { // killWidgets() should have already taken care of these, but just in case... // We must preemptively delete all widgets here. If we leave it up // to the QApplication destructor instead, it will try to query // the widgets' meta objects. However, those won't exist anymore after the // LQApplication destructor is done! for (auto widget : topLevelWidgets()) { qWarning() << "Widget was not deleted before LQApplication:" << widget; delete widget; } // QMetaObjectBuilder creates these objects using malloc(), // so they must be free()'d. for(auto obj : lqMetaObjects) free(obj); for(auto obj : staleMetaObjects) free(obj); }
/*! This function provides a way to gracefully delete all widgets before stopping the GUI event loop. Some complex widgets (e.g. QComboBox) don't like direct deletion, so we must ensure they receive and act on a QDeferredDeleteEvent. \sa LQApplication::~LQApplication(), stopWidgetEngine() */ void LQApplication::killWidgets() { for (auto widget : topLevelWidgets()) widget->deleteLater(); }
/*! \reimp */ int QAccessibleApplication::childCount() const { return topLevelWidgets().count(); }