Exemplo n.º 1
0
void SmoothToolTip::previewLayoutChanged(Applet::PreviewLayoutType previewLayout) {
	QLayout *layout = m_widget->layout();
	switch (previewLayout) {
		case Applet::NewPreviewLayout:
			layout->setSpacing(0);
			break;
		case Applet::ClassicPreviewLayout:
		default:
			layout->setSpacing(3);
	}
	layout->activate();
}
Exemplo n.º 2
0
void QWidgetProxy::setLayout ( QObjectProxy *layoutProxy ) {

  QWidget *w = widget();
  QLayout *l = qobject_cast<QLayout*>( layoutProxy->object() );
  if( !w || !l ) return;

  QLayout *exLayout = w->layout();
  if( exLayout != l ) {
    if( exLayout != 0 ) {
      qcDebugMsg( 2, QString("Deleting old layout.") );
      delete exLayout;
    }
    qcDebugMsg( 2, QString("Setting layout.") );
    w->setLayout( l );
    l->activate();
  }
  else {
    qcDebugMsg( 2, QString("Layout same as existing. Will do nothing.") );
  }
}
Exemplo n.º 3
0
void WindowPreview::updateTheme() {
	QLayout *layout = this->layout();
	m_background->clearCache();

	// frame around preview:
	qreal hoverLeft  = 0, hoverTop  = 0, hoverRight  = 0, hoverBottom  = 0;
	qreal normalLeft = 0, normalTop = 0, normalRight = 0, normalBottom = 0;

	m_background->setElementPrefix(HOVER);
	m_background->getMargins(hoverLeft, hoverTop, hoverRight, hoverBottom);
	
	m_background->setElementPrefix(NORMAL);
	m_background->getMargins(normalLeft, normalTop, normalRight, normalBottom);

	qreal left   = qMax(normalLeft,   hoverLeft);
	qreal top    = qMax(normalTop,    hoverTop);
	qreal right  = qMax(normalRight,  hoverRight);
	qreal bottom = qMax(normalBottom, hoverBottom);

	QSizeF normalSize(
		normalLeft + m_previewSize.width()  + normalRight,
		normalTop  + m_previewSize.height() + normalBottom);

	m_background->setElementPrefix(HOVER);
//	m_background->resizeFrame(QSizeF(
//		hoverLeft + m_previewSize.width()  + hoverRight,
//		hoverTop  + m_previewSize.height() + hoverBottom));
	m_background->resizeFrame(normalSize);

	m_background->setElementPrefix(NORMAL);
	m_background->resizeFrame(normalSize);

	// placeholder for preview:
	if (m_previewSpace) {
		m_previewSpace->changeSize(
			left + m_previewSize.width()  + right,
			top  + m_previewSize.height() + bottom,
			QSizePolicy::Minimum,
			QSizePolicy::Minimum);
		
		m_previewSpace->invalidate();
	}
	
	
	layout->invalidate();
	layout->activate();
	update();
	
	if (KWindowSystem::compositingActive()) {
		if (m_toolTip->applet()->previewLayout() == Applet::NewPreviewLayout) {
			m_taskNameLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum);
		}
		else {
			m_taskNameLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
		}
	}
	else {
		m_taskNameLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
	}
	adjustSize();
}
Exemplo n.º 4
0
void QmitkToolSelectionBox::SetOrUnsetButtonForActiveTool()
{
  // we want to emit a signal in any case, whether we selected ourselves or somebody else changes "our" tool manager. --> emit before check on m_SelfCall
  int id = m_ToolManager->GetActiveToolID();

  // don't emit signal for shape model tools
  bool emitSignal = true;
  mitk::Tool* tool = m_ToolManager->GetActiveTool();
  if(tool && std::string(tool->GetGroup()) == "organ_segmentation")
    emitSignal = false;

  if(emitSignal)
    emit ToolSelected(id);

  // delete old GUI (if any)
  if ( m_LastToolGUI && m_ToolGUIWidget )
  {
    if (m_ToolGUIWidget->layout())
    {
      m_ToolGUIWidget->layout()->removeWidget(m_LastToolGUI);
    }


    //m_LastToolGUI->reparent(NULL, QPoint(0,0));
    // TODO: reparent <-> setParent, Daniel fragen
    m_LastToolGUI->setParent(0);
    delete m_LastToolGUI; // will hopefully notify parent and layouts
    m_LastToolGUI = NULL;

    QLayout* layout = m_ToolGUIWidget->layout();
    if (layout)
    {
      layout->activate();
    }
  }

  QToolButton* toolButton(NULL);
  //mitk::Tool* tool = m_ToolManager->GetActiveTool();

  if (m_ButtonIDForToolID.find(id) != m_ButtonIDForToolID.end()) // if this tool is in our box
  {
    //toolButton = dynamic_cast<QToolButton*>( Q3ButtonGroup::find( m_ButtonIDForToolID[id] ) );
    toolButton = dynamic_cast<QToolButton*>( m_ToolButtonGroup->buttons().at( m_ButtonIDForToolID[id] ) );
  }

  if ( toolButton )
  {
    // mmueller
    // uncheck all other buttons
    QAbstractButton* tmpBtn = 0;
    QList<QAbstractButton*>::iterator it;
    for(int i=0; i < m_ToolButtonGroup->buttons().size(); ++i)
    {
      tmpBtn = m_ToolButtonGroup->buttons().at(i);
      if(tmpBtn != toolButton)
        dynamic_cast<QToolButton*>( tmpBtn )->setChecked(false);
    }

    toolButton->setChecked(true);

    if (m_ToolGUIWidget && tool)
    {
      // create and reparent new GUI (if any)
      itk::Object::Pointer possibleGUI = tool->GetGUI("Qmitk", "GUI").GetPointer(); // prefix and postfix
      QmitkToolGUI* gui = dynamic_cast<QmitkToolGUI*>( possibleGUI.GetPointer() );

      //!
      m_LastToolGUI = gui;
      if (gui)
      {
        gui->SetTool( tool );

        // mmueller
        //gui->reparent(m_ToolGUIWidget, gui->geometry().topLeft(), true );
        gui->setParent(m_ToolGUIWidget);
        gui->move(gui->geometry().topLeft());
        gui->show();

        QLayout* layout = m_ToolGUIWidget->layout();
        if (!layout)
        {
          layout = new QVBoxLayout( m_ToolGUIWidget );
        }
        if (layout)
        {
          // mmueller
          layout->addWidget( gui );
          //layout->add( gui );
          layout->activate();
        }
      }
    }
  }
  else
  {
    // disable all buttons
    QToolButton* selectedToolButton = dynamic_cast<QToolButton*>( m_ToolButtonGroup->checkedButton() );
    //QToolButton* selectedToolButton = dynamic_cast<QToolButton*>( Q3ButtonGroup::find( Q3ButtonGroup::selectedId() ) );
    if (selectedToolButton)
    {
      // mmueller
      selectedToolButton->setChecked(false);
      //selectedToolButton->setOn(false);
    }
  }
}