📄 main.cpp
字号:
KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KUniqueApplication::addCmdLineOptions(); // Add KUniqueApplication options. if (!RosegardenApplication::start()) return 0; RosegardenApplication app; // // Ensure quit on last window close // Register main DCOP interface // QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); app.dcopClient()->registerAs(app.name(), false); app.dcopClient()->setDefaultObject(ROSEGARDEN_GUI_IFACE_NAME); // Parse cmd line args // KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (!args->isSet("ignoreversion")) { // Give up immediately if we haven't been installed or if the // installation is out of date // testInstalledVersion(); } KConfig *config = kapp->config(); // If there is no config setting for the startup window size, set // one now. But base the default on the appropriate desktop size // (i.e. not the entire desktop, if Xinerama is in use). This is // obtained from KGlobalSettings::desktopGeometry(), but we can't // give it a meaningful point to measure from at this stage so we // always use the "leftmost" display (point 0,0). // The config keys are "Height X" and "Width Y" where X and Y are // the sizes of the available desktop (i.e. the whole shebang if // under Xinerama). These are obtained from QDesktopWidget. config->setGroup("MainView"); QDesktopWidget *desktop = KApplication::desktop(); if (desktop) { QRect totalRect(desktop->availableGeometry()); QRect desktopRect = KGlobalSettings::desktopGeometry(QPoint(0, 0)); QSize startupSize; if (desktopRect.height() <= 800) { startupSize = QSize((desktopRect.width() * 6) / 7, (desktopRect.height() * 6) / 7); } else { startupSize = QSize((desktopRect.width() * 4) / 5, (desktopRect.height() * 4) / 5); } QString widthKey = QString("Width %1").arg(totalRect.width()); QString heightKey = QString("Height %1").arg(totalRect.height()); if (!config->hasKey(widthKey)) { config->writeEntry(widthKey, startupSize.width()); } if (!config->hasKey(heightKey)) { config->writeEntry(heightKey, startupSize.height()); } } config->setGroup("KDE Action Restrictions"); config->writeEntry("action/help_report_bug", false); config->setGroup(GeneralOptionsConfigGroup); int install = config->readNumEntry("Install Own Theme", 1); if (install == 2 || (install == 1 && !getenv("KDE_FULL_SESSION"))) { kapp->setStyle(new KlearlookStyle); } // Show Startup logo // (this code borrowed from KDevelop 2.0, // (c) The KDevelop Development Team // config->setGroup(GeneralOptionsConfigGroup); KStartupLogo* startLogo = 0L; // See if the config wants us to control JACK // if (config->readBoolEntry("Logo", true) && (!kapp->isRestored() && args->isSet("splash")) ) { RG_DEBUG << k_funcinfo << "Showing startup logo\n"; startLogo = KStartupLogo::getInstance(); startLogo->show(); } struct timeval logoShowTime; gettimeofday(&logoShowTime, 0); // // Start application // RosegardenGUIApp *rosegardengui = 0; if (app.isRestored()) { RG_DEBUG << "Restoring from session\n"; // RESTORE(RosegardenGUIApp); int n = 1; while (KMainWindow::canBeRestored(n)) { // memory leak if more than one can be restored? RG_DEBUG << "Restoring from session - restoring app #" << n << endl; (rosegardengui = new RosegardenGUIApp)->restore(n); n++; } } else {#ifndef NO_SOUND app.setNoSequencerMode(!args->isSet("sequencer"));#else app.setNoSequencerMode(true);#endif // NO_SOUND rosegardengui = new RosegardenGUIApp(!app.noSequencerMode(), args->isSet("existingsequencer"), startLogo); app.setMainWidget(rosegardengui); rosegardengui->show(); // raise start logo // if (startLogo) { startLogo->raise(); startLogo->setHideEnabled(true); QApplication::flushX(); } if (args->count()) { rosegardengui->openFile(QFile::decodeName(args->arg(0)), RosegardenGUIApp::ImportCheckType); } else { // rosegardengui->openDocumentFile(); } args->clear(); } QObject::connect(&app, SIGNAL(aboutToSaveState()), rosegardengui, SLOT(slotDeleteTransport())); // Now that we've started up, raise start logo // if (startLogo) { startLogo->raise(); startLogo->setHideEnabled(true); QApplication::flushX(); } // Check for sequencer and launch if needed // try { rosegardengui->launchSequencer(args->isSet("existingsequencer")); } catch (std::string e) { RG_DEBUG << "RosegardenGUI - " << e << endl; } catch (QString e) { RG_DEBUG << "RosegardenGUI - " << e << endl; } catch (Exception e) { RG_DEBUG << "RosegardenGUI - " << e.getMessage() << endl; } if (startLogo) { // pause to ensure the logo has been visible for a reasonable // length of time, just 'cos it looks a bit silly to show it // and remove it immediately struct timeval now; gettimeofday(&now, 0); RealTime visibleFor = RealTime(now.tv_sec, now.tv_usec * 1000) - RealTime(logoShowTime.tv_sec, logoShowTime.tv_usec * 1000); if (visibleFor < RealTime(2, 0)) { int waitTime = visibleFor.sec * 1000 + visibleFor.msec(); QTimer::singleShot(2500 - waitTime, startLogo, SLOT(close())); } else { startLogo->close(); } } else { // if the start logo is there, it's responsible for showing this; // otherwise we have to RG_DEBUG << "main: Showing Tips\n"; KTipDialog::showTip(locate("data", "rosegarden/tips")); } config->setGroup(SequencerOptionsConfigGroup); // See if the config wants us to load a soundfont // if (config->readBoolEntry("sfxloadenabled", false)) { QString sfxLoadPath = config->readEntry("sfxloadpath", "/bin/sfxload"); QString soundFontPath = config->readEntry("soundfontpath", ""); QFileInfo sfxLoadInfo(sfxLoadPath), soundFontInfo(soundFontPath); if (sfxLoadInfo.isExecutable() && soundFontInfo.isReadable()) { KProcess* sfxLoadProcess = new KProcess; (*sfxLoadProcess) << sfxLoadPath << soundFontPath; RG_DEBUG << "Starting sfxload : " << sfxLoadPath << " " << soundFontPath << endl; QObject::connect(sfxLoadProcess, SIGNAL(processExited(KProcess*)), &app, SLOT(sfxLoadExited(KProcess*))); sfxLoadProcess->start(); } else { RG_DEBUG << "sfxload not executable or soundfont not readable : " << sfxLoadPath << " " << soundFontPath << endl; } } else { RG_DEBUG << "sfxload disabled\n"; }#ifdef Q_WS_X11 XSetErrorHandler( _x_errhandler );#endif return kapp->exec();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -