Exemplo n.º 1
0
void DocumentScene::loadGroup(QString fileName, Analyzer *analyzer)
{
    QString content;

    if (fileName.isEmpty())
    {
        content = "";
        fileName = QString("Unknown%1").arg(++unknownCounter);
    }
    else
    {
        QFile file(fileName);

        if (!file.open(QIODevice::ReadOnly))
        {
            QMessageBox::warning(new QWidget, tr("TrollEdit"),
                                 tr("Cannot read file %1:\n%2.").arg(file.fileName()).arg(file.errorString()));
            return;
        }

        QTextStream in(&file);
        content = in.readAll();
    }

    selectGroup();
    loadingFinished = false;

    if (groups.size() == 0)
    {
        QApplication::setOverrideCursor(Qt::WaitCursor);
    }
    else
    {
        QApplication::setOverrideCursor(Qt::CrossCursor);
        window->statusBar()->showMessage("Select position");
    }

    time.start();
    BlockGroup *newGr = new BlockGroup(content, analyzer, this);
    newGr->setVisible(false);
    groups << newGr;
    qDebug("\nGroup created: %d", time.restart());
    newGr->setFileName(fileName);
    newGr->setModified(false);
    selectGroup(newGr);

    loadingFinished = true;

    if (groups.size() == 1)
    {
        newGr->setPos(30, 30);
        newGr->setVisible(true);
        window->statusBar()->showMessage("File loaded", 2000);
        newGr->mainBlock()->getFirstLeaf()->textItem()->setTextCursorPos(0);
        QApplication::restoreOverrideCursor();
        update();
    }
}
RangeSensorWidget::RangeSensorWidget(int& argc, char * argv[]) : 
  QWidget(), 
  client_(argc, argv),
  sensor_(),
  robotName_(client_.namingContextName.c_str()),
  sensorName_("Sonar"),
  group_(0),
  timer_(0),
  drawCones_(false)
{
  // set widget size
  resize(400, 400);

  // init menu
  menuBar_  = new QMenuBar(this);
  menuFile_ = new QPopupMenu(this);
  menuView_ = new QPopupMenu(this);

  menuView_->setCheckable(true);

  menuBar_->insertItem("&Robot", menuFile_);
  menuBar_->insertItem("&View", menuView_);

  menuFile_->insertItem("Select robot", this, SLOT(selectRobot()));
  menuFile_->insertItem("Select sensor", this, SLOT(selectSensor()));
  groupIndex_ = menuFile_->insertItem("Select group", this, SLOT(selectGroup()));
  menuFile_->setItemEnabled(groupIndex_, false);

  menuFile_->insertSeparator();
  menuFile_->insertItem("Quit", qApp, SLOT(quit()));

  coneIndex_ = menuView_->insertItem("Draw Cone", this, SLOT(toggleCone()));
}
Exemplo n.º 3
0
// --------  ButtonGroupMenu
ButtonGroupMenu::ButtonGroupMenu(QObject *parent) :
    QObject(parent),
    m_selectGroupAction(new QAction(tr("Select members"), this)),
    m_breakGroupAction(new QAction(tr("Break"), this)),
    m_formWindow(0),
    m_buttonGroup(0),
    m_currentButton(0)
{
    connect(m_breakGroupAction, SIGNAL(triggered()), this, SLOT(breakGroup()));
    connect(m_selectGroupAction, SIGNAL(triggered()), this, SLOT(selectGroup()));
}
Exemplo n.º 4
0
void NewObjDialog::init(
    Panel panel,
    const std::function<void(const std::string&)>& okCallback)
{
    m_panel = panel;
    m_ok = panel.child<Button>("ok");
    m_cancel = panel.child<Button>("cancel");
    m_panel.hide();
	m_ok.setCallback([this, okCallback]() { processResult(okCallback); });
	m_cancel.setCallback([this]() { m_panel.hide(); });

    m_selector = loadObj<Selector>("ui\\Selector.json");
    m_panel.child<Layout>("main").add(m_selector);
	m_mainGroup.setCallback([this]() { selectGroup(); });

    addGroup("layout", "Layout");
    if (settings::isComplexLayerMode())
        addGroup("game", "GameExt");
    else
        addGroup("game", "Game");
    addGroup("primitive", "SimpleElement");
    addGroup("ui", "UIElement");
    addGroup("other", "Additional");

    auto presentation = presentationForDesignView();
    auto allObjects = presentation->derivedTypesByBaseTypeName("IObject");
    std::map<std::string, std::string> types;
    for (auto it = allObjects.begin(); it != allObjects.end(); ++it) {
        if (!impl::SerializableRegister::instance().isRegistered((*it)->name))
            continue;
        types[(*it)->nameInUI] = (*it)->name;
    }
    for (auto it = types.begin(); it != types.end(); ++it)
        addClass(it->second, it->first);
    m_selector.update();

	m_mainGroup.select(m_nameToGroupID["Layout"]);
}