bool KApplication::notify(QObject *receiver, QEvent *event) { QEvent::Type t = event->type(); if( t == QEvent::Show && receiver->isWidgetType()) { QWidget* w = static_cast< QWidget* >( receiver ); #if defined Q_WS_X11 if( w->isTopLevel() && !startupId().isEmpty()) // TODO better done using window group leader? KStartupInfo::setWindowStartupId( w->winId(), startupId()); #endif if( w->isTopLevel() && !( w->windowFlags() & Qt::X11BypassWindowManagerHint ) && w->windowType() != Qt::Popup && !event->spontaneous()) { if( d->app_started_timer == NULL ) { d->app_started_timer = new QTimer( this ); connect( d->app_started_timer, SIGNAL(timeout()), SLOT(_k_checkAppStartedSlot())); } if( !d->app_started_timer->isActive()) { d->app_started_timer->setSingleShot( true ); d->app_started_timer->start( 0 ); } } } return QApplication::notify(receiver, event); }
void KateApp::restoreKate () { // restore the nice files ;) we need it Kate::Document::setOpenErrorDialogsActivated (false); // activate again correct session!!! sessionConfig()->setGroup("General"); QString lastSession (sessionConfig()->readEntry ("Last Session", "default.katesession")); sessionManager()->activateSession (new KateSession (sessionManager(), lastSession, ""), false, false, false); m_docManager->restoreDocumentList (sessionConfig()); Kate::Document::setOpenErrorDialogsActivated (true); // restore all windows ;) for (int n=1; KMainWindow::canBeRestored(n); n++) newMainWindow(sessionConfig(), QString ("%1").arg(n)); // oh, no mainwindow, create one, should not happen, but make sure ;) if (mainWindows() == 0) newMainWindow (); // notify about start KStartupInfo::setNewStartupId( activeMainWindow(), startupId()); }
void QXcbNativeInterface::setStartupId(const char *data) { QByteArray startupId(data); QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration()); QXcbConnection *defaultConnection = integration->defaultConnection(); if (defaultConnection) defaultConnection->setStartupId(startupId); }
void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString) { void *result = 0; switch (resourceType(resourceString)) { case StartupId: result = startupId(); break; case X11Screen: result = x11Screen(); break; case RootWindow: result = rootWindow(); break; default: break; } return result; }
bool KateApp::startupKate () { // user specified session to open if (m_args->isSet ("startanon")) { sessionManager()->activateSession (sessionManager()->giveSession (""), false, false); } else if (m_args->isSet ("start")) { sessionManager()->activateSession (sessionManager()->giveSession (m_args->getOption("start")), false, false); } else if (!m_args->isSet( "stdin" ) && (m_args->count() == 0)) // only start session if no files specified { // let the user choose session if possible if (!sessionManager()->chooseSession ()) { kDebug() << "chooseSession returned false, exiting"; // we will exit kate now, notify the rest of the world we are done #ifdef Q_WS_X11 KStartupInfo::appStarted (startupId()); #endif return false; } } else { sessionManager()->activateSession( KateSession::Ptr(new KateSession (sessionManager(), QString())), false, false ); } // oh, no mainwindow, create one, should not happen, but make sure ;) if (mainWindows() == 0) newMainWindow (); // notify about start #ifdef Q_WS_X11 KStartupInfo::setNewStartupId( activeMainWindow(), startupId()); #endif QTextCodec *codec = m_args->isSet("encoding") ? QTextCodec::codecForName(m_args->getOption("encoding").toUtf8()) : 0; bool tempfileSet = KCmdLineArgs::isTempFileSet(); KTextEditor::Document *doc = 0; const QString codec_name = codec ? codec->name() : QString(); KateDocManager::self()->setSuppressOpeningErrorDialogs(true); QList<KUrl> urls; for (int z = 0; z < m_args->count(); z++) { // this file is no local dir, open it, else warn const bool noDir = !m_args->url(z).isLocalFile() || !QFileInfo (m_args->url(z).toLocalFile()).isDir(); if (noDir) { urls << m_args->url(z); } else { KMessageBox::sorry( activeMainWindow(), i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", m_args->url(z).url()) ); } } doc = activeMainWindow()->viewManager()->openUrls(urls, codec_name, tempfileSet); KateDocManager::self()->setSuppressOpeningErrorDialogs(false); // handle stdin input if( m_args->isSet( "stdin" ) ) { QTextStream input(stdin, QIODevice::ReadOnly); // set chosen codec if (codec) input.setCodec (codec); QString line; QString text; do { line = input.readLine(); text.append( line + '\n' ); } while( !line.isNull() ); openInput (text); } else if ( doc ) activeMainWindow()->viewManager()->activateView( doc ); if ( activeMainWindow()->viewManager()->viewCount () == 0 ) activeMainWindow()->viewManager()->activateView(m_docManager->document (0)); int line = 0; int column = 0; bool nav = false; if (m_args->isSet ("line")) { line = m_args->getOption ("line").toInt() - 1; nav = true; } if (m_args->isSet ("column")) { column = m_args->getOption ("column").toInt() - 1; nav = true; } if (nav && activeMainWindow()->viewManager()->activeView ()) activeMainWindow()->viewManager()->activeView ()->setCursorPosition (KTextEditor::Cursor (line, column)); // show the nice tips KTipDialog::showTip(activeMainWindow()); activeMainWindow()->setAutoSaveSettings(); kDebug() << "KateApplication::init finished successful"; return true; }
bool KateApp::startupKate () { // user specified session to open if (m_args->isSet ("start")) { sessionManager()->activateSession (sessionManager()->giveSession (QString::fromLocal8Bit(m_args->getOption("start"))), false, false); } else { // let the user choose session if possible if (!sessionManager()->chooseSession ()) { // we will exit kate now, notify the rest of the world we are done KStartupInfo::appStarted (startupId()); return false; } } // oh, no mainwindow, create one, should not happen, but make sure ;) if (mainWindows() == 0) newMainWindow (); // notify about start KStartupInfo::setNewStartupId( activeMainWindow(), startupId()); QTextCodec *codec = m_args->isSet("encoding") ? QTextCodec::codecForName(m_args->getOption("encoding")) : 0; bool tempfileSet = KCmdLineArgs::isTempFileSet(); Kate::Document::setOpenErrorDialogsActivated (false); uint id = 0; for (int z=0; z<m_args->count(); z++) { // this file is no local dir, open it, else warn bool noDir = !m_args->url(z).isLocalFile() || !QDir (m_args->url(z).path()).exists(); if (noDir) { // open a normal file if (codec) id = activeMainWindow()->viewManager()->openURL( m_args->url(z), codec->name(), false, tempfileSet ); else id = activeMainWindow()->viewManager()->openURL( m_args->url(z), QString::null, false, tempfileSet ); } else KMessageBox::sorry( activeMainWindow(), i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.").arg(m_args->url(z).url()) ); } Kate::Document::setOpenErrorDialogsActivated (true); // handle stdin input if( m_args->isSet( "stdin" ) ) { QTextIStream input(stdin); // set chosen codec if (codec) input.setCodec (codec); QString line; QString text; do { line = input.readLine(); text.append( line + "\n" ); } while( !line.isNull() ); openInput (text); } else if ( id ) activeMainWindow()->viewManager()->activateView( id ); if ( activeMainWindow()->viewManager()->viewCount () == 0 ) activeMainWindow()->viewManager()->activateView(m_docManager->firstDocument()->documentNumber()); int line = 0; int column = 0; bool nav = false; if (m_args->isSet ("line")) { line = m_args->getOption ("line").toInt(); nav = true; } if (m_args->isSet ("column")) { column = m_args->getOption ("column").toInt(); nav = true; } if (nav) activeMainWindow()->viewManager()->activeView ()->setCursorPosition (line, column); // show the nice tips KTipDialog::showTip(activeMainWindow()); return true; }