Beispiel #1
0
void MainApplication::onMessageReceived(const QString& message)
{
  if (message.isEmpty())
    return;

  MainWindow* window = dynamic_cast<MainWindow*>(activationWindow());
  window->tabWidget()->addNewTab(QUrl(message), true);
}
Beispiel #2
0
void MainApplication::onProxyAuthenticationRequired(const QNetworkProxy& networkProxy, QAuthenticator* authenticator)
{
  PasswordDialog passwordDialog(activationWindow());
  passwordDialog.exec();

  if (passwordDialog.result() == QDialog::Accepted)
    authenticator->setUser(passwordDialog.userName());
    authenticator->setPassword(passwordDialog.password());
}
Beispiel #3
0
	  //--------------------------------------------
	  // install an event filter and post a message to the application
	  // that it should shut down
	  //--------------------------------------------
	  bool winEventFilter(MSG * msg, long * retVal)
	  {
		  if (msg->message == WM_QUERYENDSESSION )
		  {
			  QuitEvent* quitEvent = new QuitEvent(msg->message);
			  QCoreApplication::postEvent((MainWnd*)activationWindow(),quitEvent);
			  *retVal = true;	//--> indicate that app can be closed
			  return true;		//--> do not let Qt handle the message
		  }
		  return false;
	  }
bool PosixApplication::event(QEvent* pEvent)
{
   switch(pEvent->type())
   {
   case QEvent::FileOpen:
   {
      // get filename
      QString filename = static_cast<QFileOpenEvent*>(pEvent)->file();

      if (activationWindow() == NULL)
      {
         // if we don't yet have an activation window then this is a startup
         // request -- save it so DesktopMain can pull it out later
         startupOpenFileRequest_ = filename;
      }
      else
      {
         // otherwise we are already running so this is an apple event
         // targeted at opening a file in an existing instance

         // if this is a project then re-post the request back to
         // another instance using the command line (this is to
         // circumvent the fact that the first RStudio application
         // launched on OSX gets all of the apple events). note that
         // we don't make this code conditional for __APPLE__ because
         // we'd need the same logic if other platforms started posting
         // FileOpen back to existing instances (e.g. via DDE)

         FilePath filePath(filename.toUtf8().constData());
         if (filePath.exists() && filePath.extensionLowerCase() == ".rproj")
         {
            std::vector<std::string> args;
            args.push_back(filePath.absolutePath());
            launchRStudio(args);
         }
         else
         {
            openFileRequest(filename);
         }
      }

      return true;
   }

   default:
      return QtSingleApplication::event(pEvent);
   }
}