Exemplo n.º 1
0
bool QgsApplication::notify( QObject * receiver, QEvent * event )
{
  bool done = false;
  // Crashes  in customization (especially on Mac), if we're not in the main/UI thread, see #5597
  if ( thread() == receiver->thread() )
    emit preNotify( receiver, event, &done );

  if ( done )
    return true;

  // Send event to receiver and catch unhandled exceptions
  done = true;
  try
  {
    done = QApplication::notify( receiver, event );
  }
  catch ( QgsException & e )
  {
    QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
  }
  catch ( std::exception & e )
  {
    QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
  }
  catch ( ... )
  {
    QMessageBox::critical( activeWindow(), tr( "Exception" ), tr( "unknown exception" ) );
  }

  return done;
}
Exemplo n.º 2
0
bool QgsApplication::notify( QObject * receiver, QEvent * event )
{
  bool done = false;
  emit preNotify( receiver, event, &done );

  if ( done )
    return true;

  // Send event to receiver and catch unhandled exceptions
  done = true;
  try
  {
    done = QApplication::notify( receiver, event );
  }
  catch ( QgsException & e )
  {
    QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
  }
  catch ( std::exception & e )
  {
    QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
  }
  catch ( ... )
  {
    QMessageBox::critical( activeWindow(), tr( "Exception" ), tr( "unknown exception" ) );
  }

  return done;
}
Exemplo n.º 3
0
void Application::closeWindow()
{
#ifndef Q_OS_MAC
	if( MainWindow *w = qobject_cast<MainWindow*>(activeWindow()) )
		w->closeDoc();
	else
#endif
	if( QDialog *d = qobject_cast<QDialog*>(activeWindow()) )
		d->reject();
	else if( QWidget *w = qobject_cast<QWidget*>(activeWindow()) )
		w->close();
}
bool Gui::GUIApplicationNativeEventAware::processSpaceballEvent(QObject *object, QEvent *event)
{
    if (!activeWindow())
        return true;

    QApplication::notify(object, event);
    if (event->type() == Spaceball::MotionEvent::MotionEventType)
    {
        Spaceball::MotionEvent *motionEvent = dynamic_cast<Spaceball::MotionEvent*>(event);
        if (!motionEvent)
            return true;
        if (!motionEvent->isHandled())
        {
            //make a new event and post to parent.
            Spaceball::MotionEvent *newEvent = new Spaceball::MotionEvent(*motionEvent);
            postEvent(object->parent(), newEvent);
        }
    }

    if (event->type() == Spaceball::ButtonEvent::ButtonEventType)
    {
        Spaceball::ButtonEvent *buttonEvent = dynamic_cast<Spaceball::ButtonEvent*>(event);
        if (!buttonEvent)
            return true;
        if (!buttonEvent->isHandled())
        {
            //make a new event and post to parent.
            Spaceball::ButtonEvent *newEvent = new Spaceball::ButtonEvent(*buttonEvent);
            postEvent(object->parent(), newEvent);
        }
    }
    return true;
}
Exemplo n.º 5
0
void TabSwitcherWidget::showEvent(QShowEvent *event)
{
	setFocus();

	MainWindowSessionItem *mainWindowItem(SessionsManager::getModel()->getMainWindowItem(m_mainWindow));

	if (mainWindowItem)
	{
		const bool useSorting(SettingsManager::getOption(SettingsManager::Interface_TabSwitchingModeOption).toString() != QLatin1String("noSort"));

		for (int i = 0; i < mainWindowItem->rowCount(); ++i)
		{
			WindowSessionItem *windowItem(static_cast<WindowSessionItem*>(mainWindowItem->child(i, 0)));

			if (windowItem)
			{
				m_model->appendRow(createRow(windowItem->getActiveWindow(), (useSorting ? QVariant(windowItem->getActiveWindow()->getLastActivity()) : QVariant(i))));
			}
		}
	}

	m_model->sort(0, ((SettingsManager::getOption(SettingsManager::Interface_TabSwitchingModeOption).toString() == QLatin1String("noSort")) ? Qt::AscendingOrder : Qt::DescendingOrder));

	Window *activeWindow(m_mainWindow->getActiveWindow());
	const int contentsHeight(m_model->rowCount() * 22);

	m_tabsView->setCurrentIndex(m_model->index((activeWindow ? findRow(activeWindow->getIdentifier()) : 0), 0));
	m_tabsView->setMinimumHeight(qMin(contentsHeight, int(height() * 0.9)));

	QWidget::showEvent(event);

	connect(m_mainWindow, SIGNAL(windowAdded(quint64)), this, SLOT(handleWindowAdded(quint64)));
	connect(m_mainWindow, SIGNAL(windowRemoved(quint64)), this, SLOT(handleWindowRemoved(quint64)));
}
Exemplo n.º 6
0
void windowManager::openNewImage() {

  const bool warnToSave = !originalImage_.isNull();
  const QString file = ::getNewImageFileName(activeWindow(), warnToSave);
  if (!file.isEmpty()) {
    const QImage newImage(file);
    if (newImage.isNull()) {
      const QList<QByteArray> formats = QImageWriter::supportedImageFormats();
      QString supportedTypes;
      for (QList<QByteArray>::const_iterator it = formats.begin(),
             end = formats.end(); it != end; ++it) {
        supportedTypes += (*it).data() + QString(", ");
      }
      supportedTypes.chop(2);
      const QString errorString = "Unable to load " + file + ";\nplease make sure " +
        "your image is one of the supported types:\n" + supportedTypes;
      QMessageBox::warning(NULL, "Image load failed", errorString);
      return;
    }
    QFile fileDevice(file);
    fileDevice.open(QIODevice::ReadOnly);
    QByteArray byteArray(fileDevice.readAll());
    const QString imageName = QFileInfo(file).fileName();

    reset(newImage, byteArray, imageName);
    setProjectVersion(programVersion_);
    ::showAndRaise(colorChooser_.window());
    colorChooser_.window()->setNewImage(newImage);
    colorChooser_.window()->setWindowTitle(getWindowTitle());
    startOriginalImageColorCount();
  }
}
Exemplo n.º 7
0
void Manitou::onOpenTab()
{
    BrowserTab *tab = createNewTab();
    BrowserWindow *window = (BrowserWindow*) activeWindow();
    window->addTab(tab);
    window->setCurrentTab(tab);
}
Exemplo n.º 8
0
QDBusObjectPath QTerminalApp::getActiveWindow()
{
    QWidget *aw = activeWindow();
    if (aw == nullptr)
        return QDBusObjectPath("/");
    return qobject_cast<MainWindow*>(aw)->getDbusPath();
}
Exemplo n.º 9
0
void Application::showSettings()
{
    SettingsWizard wizard(activeWindow());
    wizard.setSettings(settings());
    if (wizard.exec())
        setSettings(wizard.settings());
}
Exemplo n.º 10
0
bool QuickTestEvent::keyClick(int key, int modifiers, int delay)
{
    QWindow *window = activeWindow();
    if (!window)
        return false;
    QTest::keyClick(window, Qt::Key(key), Qt::KeyboardModifiers(modifiers), delay);
    return true;
}
Exemplo n.º 11
0
bool KstIfaceImpl::deletePlot(const QString& name) {
   QString window = activeWindow();
   if (!window.isEmpty()) {
     return deletePlot(window, name);
   }

   return false;
}
Exemplo n.º 12
0
bool QuickTestEvent::keyReleaseChar(const QString &character, int modifiers, int delay)
{
    QTEST_ASSERT(character.length() == 1);
    QWindow *window = activeWindow();
    if (!window)
        return false;
    QTest::keyRelease(window, character[0].toLatin1(), Qt::KeyboardModifiers(modifiers), delay);
    return true;
}
Exemplo n.º 13
0
void windowManager::displayActionWindow(QAction* action) {

  QWidget* actionWindow = action->data().value<QWidget*>();
  imageZoomWindow* curWindow = activeWindow();
  if (actionWindow == curWindow) { // we're already there
    return;
  }
  curWindow->showQuickHelp(false);
  setNewWidgetGeometryAndRaise(actionWindow);
}
Exemplo n.º 14
0
QString KstIfaceImpl::createPlot(const QString& name) {
  QString window = activeWindow();

  //if no window exists, create one
  if (window.isEmpty()) {
    window = KstApp::inst()->newWindow(false);
  }

  return createPlot(window, name);
}
Exemplo n.º 15
0
KateMainWindow *KateApp::activeMainWindow ()
{
  if (m_mainWindows.isEmpty())
    return 0;

  int n = m_mainWindows.indexOf (static_cast<KateMainWindow *>(activeWindow()));

  if (n < 0)
    n = 0;

  return m_mainWindows[n];
}
Exemplo n.º 16
0
void GfxCanvasWindow::activate()
{
    if(isActive())
        return;
    _active.removeAll(this);
    GfxCanvasWindow *last = activeWindow();
    _active.append(this);
    if(last)
        last->deactivated(this);
    activated();
    canvas()->setFocused(focused());
}
Exemplo n.º 17
0
KateMainWindow *KateApp::activeMainWindow ()
{
  if (m_mainWindows.isEmpty())
    return 0;

  int n = m_mainWindows.findIndex ((KateMainWindow *)activeWindow());

  if (n < 0)
    n=0;

  return m_mainWindows[n];
}
Exemplo n.º 18
0
void Application::aboutOxygen()
{
    QMessageBox::about(
#ifdef Q_WS_MAC
        0,
#else
        activeWindow(),
#endif // Q_WS_MAC
        "Oxygen", QString(
        "<h3>%1</h3>"
        "<p><a href='http://www.oxygen-icons.org/'>http://www.oxygen-icons.org/</a></p>"
        ).arg(tr("About %1").arg("Oxygen")));
}
Exemplo n.º 19
0
//-----------------------------------------------
DWORD AflWindowList::onLButtonDown(DWORD dwFlags,FLOAT fX,FLOAT fY)
{
	std::list<AflSpriteWnd*>::iterator it;
	for(it=m_listWindow.begin();it!=m_listWindow.end();it++)
	{
		DWORD dwRet = (*it)->onLButtonDown(dwFlags,fX,fY);
		if(dwRet)
		{
			if(it!=m_listWindow.begin())
				activeWindow(*it);
			return dwRet;
		}
	}
	return 0;
}
Exemplo n.º 20
0
bool Application::event( QEvent *e )
{
	switch( int(e->type()) )
	{
	case REOpenEvent::Type:
		if( !activeWindow() )
			parseArgs();
		return true;
	case OpenFilesEvent::Type:
		parseArgs( static_cast<OpenFilesEvent*>(e)->files() );
		return true;
	case QEvent::FileOpen:
		parseArgs( QStringList() << static_cast<QFileOpenEvent*>(e)->file() );
		return true;
	default: return Common::event( e );
	}
}
Exemplo n.º 21
0
void Application::aboutApplication()
{
    QMessageBox::about(
#ifdef Q_WS_MAC
        0,
#else
        activeWindow(),
#endif // Q_WS_MAC
        applicationName(), QString(
        "<h3>%1</h3>"
        "<p>%2</p>"
        "<p><a href='%3'>%3</a></p>"
        "<p><small>Copyright (C) 2008-2012 J-P Nurmi &lt;"
        "<a href='mailto:[email protected]'>[email protected]</a>&gt;</small></p>")
            .arg(tr("About %1").arg(applicationName()))
            .arg(applicationSlogan())
            .arg(organizationDomain())
        );
}
Exemplo n.º 22
0
void PERAApplication::aboutPERA() {
	PERAMainWindow::aboutPERA( activeWindow() );
}
Exemplo n.º 23
0
void Application::showWarning( const QString &msg )
{ QMessageBox( QMessageBox::Warning, tr("DigiDoc3 crypto"), msg, QMessageBox::Close, activeWindow() ).exec(); }
Exemplo n.º 24
0
void Application::showSettings()
{
	SettingsDialog *s = new SettingsDialog( activeWindow() );
	s->addAction( d->closeAction );
	s->show();
}
Exemplo n.º 25
0
void Application::showAbout()
{
	AboutDialog *a = new AboutDialog( activeWindow() );
	a->addAction( d->closeAction );
	a->open();
}
Exemplo n.º 26
0
void windowManager::autoShowQuickHelp(bool show) {

  QSettings settings("cstitch", "cstitch");
  settings.setValue("auto_show_quick_help", show);
  activeWindow()->showQuickHelp(show);
}
Exemplo n.º 27
0
bool KWM::isActive(Window w){
  return (w == activeWindow());
}
Exemplo n.º 28
0
Common::Common( int &argc, char **argv, const QString &app, const QString &icon )
	: BaseApplication( argc, argv )
{
	setApplicationName( app );
	setApplicationVersion( QString( "%1.%2.%3.%4" )
		.arg( MAJOR_VER ).arg( MINOR_VER ).arg( RELEASE_VER ).arg( BUILD_VER ) );
	setOrganizationDomain( "ria.ee" );
	setOrganizationName( ORG );
	setWindowIcon( QIcon( icon ) );
	if( QFile::exists( QString("%1/%2.log").arg( QDir::tempPath(), app ) ) )
		qInstallMessageHandler(msgHandler);

#ifdef BREAKPAD
	new QBreakPad(this);
#ifdef TESTING
	if( arguments().contains( "-crash" ) )
	{
		QBreakPad *crash;
		delete crash;
	}
#endif
#endif

	Q_INIT_RESOURCE(common_images);
	Q_INIT_RESOURCE(common_tr);
#if defined(Q_OS_WIN)
	setLibraryPaths( QStringList() << applicationDirPath() );
#elif defined(Q_OS_MAC)
	setLibraryPaths( QStringList() << applicationDirPath() + "/../PlugIns" );
#endif
	setStyleSheet(
		"QDialogButtonBox { dialogbuttonbox-buttons-have-icons: 0; }\n" );
	QPalette p = palette();
	p.setBrush( QPalette::Link, QBrush( "#509B00" ) );
	p.setBrush( QPalette::LinkVisited, QBrush( "#509B00" ) );
	setPalette( p );

	qRegisterMetaType<TokenData>("TokenData");

	QNetworkProxyFactory::setUseSystemConfiguration(true);

#if defined(Q_OS_WIN)
	AllowSetForegroundWindow( ASFW_ANY );
#elif defined(Q_OS_MAC)
#ifdef BREAKPAD
	if(arguments().contains("-crashreport", Qt::CaseInsensitive))
		return;
#endif
	if(!QSettings().value("plugins").isNull())
		return;

	QTimer *timer = new QTimer(this);
	timer->setSingleShot(true);
	connect(timer, &QTimer::timeout, this, [=]{
		timer->deleteLater();
		QMessageBox *b = new QMessageBox(QMessageBox::Information, tr("Browser plugins"),
			tr("If you are using e-services for authentication and signing documents in addition to "
				"Mobile-ID an ID-card or only ID-card, you should install the browser integration packages.<br />"
				"<a href='http://installer.id.ee'>http://installer.id.ee</a>"),
			0, activeWindow());
		QAbstractButton *install = b->addButton(tr("Install"), QMessageBox::AcceptRole);
		b->addButton(tr("Remind later"), QMessageBox::AcceptRole);
		QAbstractButton *ignore = b->addButton(tr("Ignore forever"), QMessageBox::AcceptRole);
		b->exec();
		if(b->clickedButton() == install)
			QDesktopServices::openUrl(QUrl("http://installer.id.ee"));
		else if(b->clickedButton() == ignore)
			QSettings().setValue("plugins", "ignore");
	});
	timer->start(1000);
#endif
}
Exemplo n.º 29
0
void AQWebApplication::handleWebEvent(const QString &msgEvent)
{
  QStringList args(QStringList::split(AQ_MSG_SEP, msgEvent, true));
  AQ::EventType evT = webEventTypeToAQEventType(args[0]);
  QWidget *w;
  AQWidgetInfo *wInfo;

  if (evT != AQ::XProgressDialog) {
    w = AQ_WIDGET(args[1].toULongLong(0, 36));
    wInfo = createdWidgets_.find(w);
    if (!wInfo)
      return;
  }

  switch (evT) {
    case AQ::MouseButtonPress: {
      QWidget *popup = activePopupWidget();
      if (popup && popup != w->topLevelWidget())
        popup->close();

      w->raise();
      w->setActiveWindow();

      QPoint local(args[2].toInt(), args[3].toInt());
      QPoint global(w->mapToGlobal(local));
      QCursor::setPos(global);
      QMouseEvent mev(QEvent::MouseButtonPress, local, global, toQtButton(args[4]), toQtButtonState(args[5]));
      qt_sendSpontaneousEvent(w, &mev);
      break;
    }

    case AQ::MouseButtonRelease: {
      QPoint local(args[2].toInt(), args[3].toInt());
      QPoint global(w->mapToGlobal(local));
      QCursor::setPos(global);
      QMouseEvent mev(QEvent::MouseButtonRelease, local, global, toQtButton(args[4]), toQtButtonState(args[5]));
      qt_sendSpontaneousEvent(w, &mev);
      break;
    }

    case AQ::MouseButtonDblClick: {
      QPoint local(args[2].toInt(), args[3].toInt());
      QPoint global(w->mapToGlobal(local));
      QCursor::setPos(global);
      QMouseEvent mev(QEvent::MouseButtonDblClick, local, global, toQtButton(args[4]), toQtButtonState(args[5]));
      qt_sendSpontaneousEvent(w, &mev);
      break;
    }

    case AQ::MouseMove: {
      QPoint local(args[2].toInt(), args[3].toInt());
      QPoint global(w->mapToGlobal(local));
      QCursor::setPos(global);
      QMouseEvent mev(QEvent::MouseMove, local, global, toQtButton(args[4]), toQtButtonState(args[5]));
      qt_sendSpontaneousEvent(w, &mev);
      break;
    }

    case AQ::KeyPress:
    case AQ::KeyRelease: {
      int keyCode = args[2].toInt();
      QWidget *keywidget = QWidget::keyboardGrabber();
      bool grabbed = false;

      if (keywidget) {
        grabbed = true;
      } else {
        keywidget = focusWidget();
        if (!keywidget) {
          keywidget = activePopupWidget();
          if (!keywidget) {
            keywidget = activeWindow();
            if (!keywidget)
              keywidget = w->topLevelWidget();
          }
        }
      }

      if (keyCode < 0) {
        QKeyEvent kev((QEvent::Type) evT, 0, keyCode, toQtButtonState(args[3]), QChar(-keyCode));
        qt_sendSpontaneousEvent(keywidget, &kev);
      } else {
        if (evT == AQ::KeyPress && !grabbed) {
          QKeyEvent a((QEvent::Type) evT, toQtKey(keyCode), keyCode, toQtButtonState(args[3]));
          if (qt_tryAccelEvent(keywidget, &a))
            return;
        }
        QKeyEvent kev((QEvent::Type) evT, toQtKey(keyCode), keyCode, toQtButtonState(args[3]));
        qt_sendSpontaneousEvent(keywidget, &kev);
      }
      break;
    }

    case AQ::Move:
      if (w != desktop_) {
        ignoreEvents_ = true;
        w->move(args[2].toInt(), args[3].toInt());
        ignoreEvents_ = false;
      }
      break;

    case AQ::Resize:
      if (w != desktop_) {
        //ignoreEvents_ = true;
        w->resize(args[2].toInt(), args[3].toInt());
        //ignoreEvents_ = false;
      } else {
        int wt = args[2].toInt();
        int ht = args[3].toInt();
        desktopGeometry_.setRect(0, 0, wt, ht);
        desktop()->resize(wt, ht);
        postAQEvent(new AQEvent(w, new QResizeEvent(QSize(wt, ht), QSize())));
        emit desktop()->resized(0);
        if (!initDone_)
          QTimer::singleShot(0, this, SLOT(init()));
      }
      break;

    case AQ::XUpload: {
      QFileDialog *fd = ::qt_cast<QFileDialog *>(w);
      if (fd)
        fd->rereadDir();
      break;
    }

    case AQ::XProgressDialog: {
      uint pid = args[1].toUInt();
      if (args.size() == 2) {
        QProgressDialog *pd = progressDialogs_.take(pid);
        if (pd) {
          pd->close();
          pd->deleteLater();
        }
      } else {
        QProgressDialog *pd = progressDialogs_.find(pid);
        if (!pd) {
          pd = new QProgressDialog(args[2], QString(), args[3].section(';', 1, 1).toInt());
          progressDialogs_.insert(pid, pd);
        }
        pd->setProgress(args[3].section(';', 0, 0).toInt());
      }
      break;
    }

    case AQ::WindowStateChange: {
      w->setWindowState(args[2].toInt());
      break;
    }

    default: {
      QEvent ev((QEvent::Type) evT);
      qt_sendSpontaneousEvent(w, &ev);
    }
  }
}
Exemplo n.º 30
0
QString AutoTypePlatformX11::activeWindowTitle()
{
    return windowTitle(activeWindow(), true);
}