コード例 #1
0
ファイル: OSItem.cpp プロジェクト: NREL/OpenStudio
void OSItem::createLayout()
{
  auto mainHLayout = new QHBoxLayout();
  mainHLayout->setContentsMargins(10,5,10,5);
  mainHLayout->setAlignment(Qt::AlignVCenter);
  setLayout(mainHLayout);

  auto leftVBoxLayout = new QVBoxLayout();

  m_imageLeftLbl = new QLabel(this);
  leftVBoxLayout->addWidget(m_imageLeftLbl);

  m_measureBadge = new MeasureBadge();
  //m_measureBadge->setFixedWidth(25); NOTE mirror other instance?

  leftVBoxLayout->addWidget(m_measureBadge);

  mainHLayout->addLayout(leftVBoxLayout);

  std::shared_ptr<OSDocument> doc = OSAppBase::instance()->currentDocument();
  if(doc){
    boost::optional<IddObjectType> iddObjectType = doc->getIddObjectType(m_itemId);
    if(iddObjectType){
      const QPixmap * pixmap = IconLibrary::Instance().findMiniIcon(iddObjectType->value());
      if(pixmap){
        setLeftPixmap(*pixmap);
      }

      pixmap = IconLibrary::Instance().findIcon(iddObjectType->value());
      if(pixmap){
        m_largePixmap = *pixmap;
      }
    }
  }
  {
    int w = leftPixmap().size().width();
    int h = leftPixmap().size().height();
    if(w==-1 || h==-1){
      setLeftPixmap(QPixmap(":/images/lilBug.png"));
    }
    else{
      setLeftPixmap(leftPixmap());
    }
  }

  m_textLbl = new QLabel(this);
  m_textLbl->setWordWrap(true);
  mainHLayout->addWidget(m_textLbl);

  mainHLayout->addStretch();

  m_removeButton = new QPushButton(this);
  mainHLayout->addWidget(m_removeButton);

  QString style;
  style.append("QWidget { ");
  style.append("border: none;");
  style.append(" background-image: url(\":/images/delete.png\")");
  style.append("}");

  m_removeButton->setFlat(true);
  m_removeButton->setStyleSheet(style);
  m_removeButton->setFixedSize(20,20);

  if (m_itemId.isDefaulted()){
    m_textLbl->setStyleSheet("QLabel { color: #006837 }");
    this->setRemoveable(false);
  }

  connect(m_removeButton, &QPushButton::clicked, this, &OSItem::onRemoveClicked);
}
コード例 #2
0
ファイル: qteruputer.cpp プロジェクト: clach04/Aurex2
QTERuputer::QTERuputer(Frame *_frame, Directory *_sddir, Option *option, UFilerIni *ini) : QMainWindow(NULL, "Aurex"), Ruputer(_frame, _sddir, option, ini)
{
//	qteruputer=this;
//	palette = NULL;

#if 1
/* configure menu */
	openFileMenu = new QPopupMenu(this);
	menuBar()->insertItem(tr("File"), openFileMenu);

	openAction = new QAction("Open", "Open", 0, this);
	openAction->addTo(openFileMenu);
	connect(openAction, SIGNAL(activated()), this, SLOT(openFile(void)));

	connect(openFileMenu, SIGNAL(aboutToShow()), this, SLOT(pauseEmulate(void)));
	connect(openFileMenu, SIGNAL(aboutToHide()), this, SLOT(resumeEmulate(void)));

/* configure tool button */
	enterAction = new QAction("enter", "enter", 0, this);
	QPixmap enterPixmap( (const char **)enter );
	QIconSet enterIconSet( enterPixmap, QIconSet::Small );
	enterAction->setIconSet(enterIconSet);

	elAction = new QAction("el", "el", 0, this);
	QPixmap elPixmap( (const char **)el );
	QIconSet elIconSet( elPixmap , QIconSet::Small );
	elAction->setIconSet(elIconSet);

	menuAction = new QAction("menu", "menu", 0, this);
	QPixmap menuPixmap( (const char **)menu );
	QIconSet menuIconSet( menuPixmap , QIconSet::Small);
	menuAction->setIconSet(menuIconSet);

	filerAction = new QAction("filer", "filer", 0, this);
	QPixmap filerPixmap( (const char **)filer );
	QIconSet filerIconSet( filerPixmap , QIconSet::Small );
	filerAction->setIconSet(filerIconSet);


	upAction = new QAction("up", "up", 0, this);
	QPixmap upPixmap( (const char **)up_arrow_xpm );
	QIconSet upIconSet( upPixmap , QIconSet::Small );
	upAction->setIconSet(upIconSet);

	rightAction = new QAction("right", "right", 0, this);
	QPixmap rightPixmap( (const char **)right_arrow_xpm );
	QIconSet rightIconSet( rightPixmap , QIconSet::Small );
	rightAction->setIconSet(rightIconSet);

	leftAction = new QAction("left", "left", 0, this);
	QPixmap leftPixmap( (const char **)left_arrow_xpm );
	QIconSet leftIconSet( leftPixmap , QIconSet::Small );
	leftAction->setIconSet(leftIconSet);

	downAction = new QAction("down", "down", 0, this);
	QPixmap downPixmap( (const char **)down_arrow_xpm );
	QIconSet downIconSet( downPixmap , QIconSet::Small );
	downAction->setIconSet(downIconSet);

	connect(enterAction, SIGNAL(activated()), this, SLOT(pushPaletteEnter(void)));
	connect(elAction, SIGNAL(activated()), this, SLOT(pushPaletteEl(void)));
	connect(menuAction, SIGNAL(activated()), this, SLOT(pushPaletteMenu(void)));
	connect(filerAction, SIGNAL(activated()), this, SLOT(pushPaletteFiler(void)));
	connect(upAction, SIGNAL(activated()), this, SLOT(pushPaletteUp(void)));
	connect(downAction, SIGNAL(activated()), this, SLOT(pushPaletteDown(void)));
	connect(leftAction, SIGNAL(activated()), this, SLOT(pushPaletteLeft(void)));
	connect(rightAction, SIGNAL(activated()), this, SLOT(pushPaletteRight(void)));

	palette = new QToolBar(this, "Palette");
//	palette->setVerticalStretchable( true );
//	palette->setHorizontalStretchable( true );

	enterAction->addTo(palette);
	menuAction->addTo(palette);
	upAction->addTo(palette);
	downAction->addTo(palette);
	leftAction->addTo(palette);
	rightAction->addTo(palette);

	elAction->addTo(palette);
	filerAction->addTo(palette);
	setDockEnabled(palette, Bottom, true);
	moveToolBar(palette, Bottom);

	qtelcd=new QTELcd(getSystemAddress(), this, getCMLcd(), menuBar()->height(), palette->height(), palette->width());
	setSDLcd(qtelcd);
#endif
	setCaption("Aurex");
}