示例#1
0
void AvatarEditor::InitEditorWindow()
{
    Foundation::UiServiceInterface *ui = rexlogicmodule_->GetFramework()->GetService<Foundation::UiServiceInterface>();
    if (ui == 0) // If this occurs, we're most probably operating in headless mode.
        return;

    QUiLoader loader;
    loader.setLanguageChangeEnabled(true);
    QFile file("./data/ui/avatareditor.ui");
    if (!file.exists())
    {
        RexLogicModule::LogError("Cannot find avatar editor .ui file.");
        return;
    }

    avatar_widget_ = loader.load(&file, this);
    if (!avatar_widget_)
        return;

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addWidget(avatar_widget_);
    layout->setContentsMargins(0, 0, 0, 0);
    setLayout(layout);

    // Connect signals.
    QPushButton *button = avatar_widget_->findChild<QPushButton *>("but_export");
    if (button)
        QObject::connect(button, SIGNAL(clicked()), this, SLOT(ExportAvatar()));

    button = avatar_widget_->findChild<QPushButton *>("but_exportlocal");
    if (button)
        QObject::connect(button, SIGNAL(clicked()), this, SLOT(ExportAvatarLocal()));

    button = avatar_widget_->findChild<QPushButton *>("but_load");
    if (button)
        QObject::connect(button, SIGNAL(clicked()), this, SLOT(LoadAvatar()));

    button = avatar_widget_->findChild<QPushButton *>("but_revert");
    if (button)
        QObject::connect(button, SIGNAL(clicked()), this, SLOT(RevertAvatar()));

    button = avatar_widget_->findChild<QPushButton *>("but_attachment");
    if (button)
        QObject::connect(button, SIGNAL(clicked()), this, SLOT(AddAttachment()));

    setWindowTitle(tr("Avatar Editor"));
    ui->AddWidgetToScene(this);
    ui->AddWidgetToMenu(this);
}
示例#2
0
    void NoteCardManager::Initialize()
    {
        QUiLoader loader;
        loader.setLanguageChangeEnabled(true);
        QFile file("./data/ui/notecardmanager.ui");
        file.open(QFile::ReadOnly);
        contents_ = loader.load(&file, this);
        if (!contents_)
        {
            NoteCardModule::LogError("Could not load notecard manager layout");
            return;
        }
        file.close();

        QVBoxLayout *layout = new QVBoxLayout;
        layout->addWidget(contents_);
        layout->setContentsMargins(0,0,0,0);
        setLayout(layout);

        boost::shared_ptr<UiServices::UiModule> ui_module = framework_->GetModuleManager()->GetModule<UiServices::UiModule>().lock();
        if (ui_module)
        {
            UiServices::UiWidgetProperties widget_properties(contents_->windowTitle(), UiServices::SceneWidget);
            proxy_ = ui_module->GetInworldSceneController()->AddWidgetToScene(this, widget_properties);
        }
        else
            NoteCardModule::LogError("Could not add widget to scene");

        tree_ = findChild<QTreeWidget*>("tree_cards");
        if (tree_)
        {
            QObject::connect(tree_, SIGNAL(itemActivated(QTreeWidgetItem *, int)), this, SLOT(SelectNoteCard()));
        }
        create_button_ = findChild<QPushButton*>("but_create");
        if (create_button_)
        {
            QObject::connect(create_button_, SIGNAL(pressed()), this, SLOT(CreateNoteCard()));
        }
        delete_button_ = findChild<QPushButton*>("but_delete");
        if (delete_button_)
        {
            QObject::connect(delete_button_, SIGNAL(pressed()), this, SLOT(DeleteNoteCard()));
        }
    }
示例#3
0
    void TerrainWeightEditor::Initialize()
    {
        if (fw_->IsHeadless())
            return;

        QUiLoader loader;
        loader.setLanguageChangeEnabled(true);
        QString str("./data/ui/terrainwtex_editor.ui");
        QFile file(str);
        if(!file.exists())
        {
            EnvironmentModule::LogError("Cannot find " +str.toStdString()+ " file");
            return;
        }

        editor_widget_ = loader.load(&file, this);
        if (editor_widget_ == 0)
            return;

//        UiProxyWidget *editor_proxy = fw_->Ui()->AddWidgetToScene(this);
//        if (editor_proxy == 0)
//            return;

//        ui->AddWidgetToMenu(this, tr("Terrain Texture Weightmap Editor"));
//        ui->RegisterUniversalWidget("Weights", editor_proxy);

        QSpinBox *box = editor_widget_->findChild<QSpinBox*>("brush_size");
        if(box)
        {
            brush_size_max_ = box->maximum();
            brush_size_ = box->value();
        }
        box = editor_widget_->findChild<QSpinBox*>("brush_modifier");
        if(box)
            brush_modifier_ = box->maximum();

        QDoubleSpinBox *dbox = editor_widget_->findChild<QDoubleSpinBox*>("brush_falloff");
        if(dbox)
            falloff_percentage_ = dbox->value();

        InitializeCanvases();
        InitializeConnections();
        emit BrushValueChanged();
    }
示例#4
0
void InventoryWindow::InitInventoryWindow()
{
    QUiLoader loader;
    loader.setLanguageChangeEnabled(true);
    QFile uiFile("./data/ui/inventory.ui");
    mainWidget_ = loader.load(&uiFile, this);
    uiFile.close();

    setWindowTitle(QApplication::translate("Inventory::InventoryWindow", "Inventory"));

    // Layout
    layout_ = new QVBoxLayout(this);
    layout_->addWidget(mainWidget_);
    layout_->setContentsMargins(0, 0, 0, 0);
    setLayout(layout_);

///\todo Disable crappy search line edit feature for now. Maybe do better some day.
    /*
        QHBoxLayout *line_layout = new QHBoxLayout();
        line_layout->setContentsMargins(7, 0, 7, 0);
        QLineEdit *lineEditSearch_ = new QLineEdit(mainWidget_);
        QObject::connect(lineEditSearch_, SIGNAL(textChanged(const QString &)), this, SLOT(Search(const QString &)));
        lineEditSearch_->setText("Search...");
        line_layout->addWidget(lineEditSearch_);
    */
    // Create inventory tree view.
    treeView_ = new InventoryTreeView(mainWidget_);

//    layout_->addLayout(line_layout);
    layout_->addWidget(treeView_);

    // Connect signals
    ///\todo Connecting both these signals causes WebDav inventory to work incorrectly.
//    connect(treeView_, SIGNAL(expanded(const QModelIndex &)), this, SLOT(ExpandFolder(const QModelIndex &)));
    connect(treeView_, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(OpenItem()));

    CreateActions();
}
示例#5
0
ECEditorWindow::ECEditorWindow(Framework* fw, QWidget *parent) :
    QWidget(parent),
    framework(fw),
    toggleEntitiesButton(0),
    entityList(0),
    ecBrowser(0),
    hasFocus(true)
{
    QUiLoader loader;
    loader.setLanguageChangeEnabled(true);
    QFile file(Application::InstallationDirectory() + "data/ui/eceditor.ui");
    file.open(QFile::ReadOnly);
    if (!file.exists())
    {
        LogError("Cannot find " + Application::InstallationDirectory() + "data/ui/eceditor.ui file.");
        return;
    }

    QWidget *contents = loader.load(&file, this);
    if (!contents)
    {
        LogError("Could not load editor layout");
        return;
    }
    contents->installEventFilter(this);
    file.close();

    Scene *scene = fw->Scene()->MainCameraScene();
    assert(scene);
    undoManager_ = new UndoManager(scene->shared_from_this(), this);
    transformEditor = new TransformEditor(scene->shared_from_this(), undoManager_);

    QVBoxLayout *layout = new QVBoxLayout(this);
    undoButton_ = findChild<QToolButton *>("undoButton");
    undoButton_->setDisabled(true);
    redoButton_ = findChild<QToolButton *>("redoButton");
    redoButton_->setDisabled(true);

    undoButton_->setIcon(QIcon(Application::InstallationDirectory() + "data/ui/images/icon/undo-icon.png"));
    redoButton_->setIcon(QIcon(Application::InstallationDirectory() + "data/ui/images/icon/redo-icon.png"));

    undoButton_->setMenu(undoManager_->UndoMenu());
    redoButton_->setMenu(undoManager_->RedoMenu());

    layout->addWidget(contents);
    layout->setContentsMargins(0,0,0,0);
    setLayout(layout);
    setWindowTitle(contents->windowTitle());
    resize(contents->size());

    toggleEntitiesButton = findChild<QPushButton *>("but_show_entities");
    entityList = findChild<QListWidget*>("list_entities");
    QWidget *entity_widget = findChild<QWidget*>("entity_widget");
    if(entity_widget)
        entity_widget->hide();

    QWidget *browserWidget = findChild<QWidget*>("browser_widget");
    if (browserWidget)
    {
        ecBrowser = new ECBrowser(framework, this, browserWidget);
        ecBrowser->setMinimumWidth(100);
        QVBoxLayout *property_layout = dynamic_cast<QVBoxLayout *>(browserWidget->layout());
        if (property_layout)
            property_layout->addWidget(ecBrowser);
    }

    ECEditorModule *ecEditorModule = framework->GetModule<ECEditorModule>();
    if (ecBrowser)
    {
        // signals from attribute browser to editor window.
        connect(ecBrowser, SIGNAL(ShowXmlEditorForComponent(const QString &)), SLOT(ShowXmlEditorForComponent(const QString &)));
        connect(ecBrowser, SIGNAL(CreateNewComponent()), SLOT(CreateComponent()));
        connect(ecBrowser, SIGNAL(SelectionChanged(const QString&, const QString &, const QString&, const QString&)),
            SLOT(HighlightEntities(const QString&, const QString&)));
        connect(ecBrowser, SIGNAL(SelectionChanged(const QString&, const QString &, const QString&, const QString&)),
            SIGNAL(SelectionChanged(const QString&, const QString&, const QString&, const QString&)), Qt::UniqueConnection);

        ecBrowser->SetItemExpandMemory(ecEditorModule->ExpandMemory());
    }

    if (entityList)
    {
        entityList->setSelectionMode(QAbstractItemView::ExtendedSelection);
        connect(entityList, SIGNAL(itemSelectionChanged()), this, SLOT(RefreshPropertyBrowser()));
        connect(entityList, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ShowEntityContextMenu(const QPoint &)));
    }

    if (toggleEntitiesButton)
        connect(toggleEntitiesButton, SIGNAL(pressed()), this, SLOT(ToggleEntityList()));

    QPushButton *expandOrCollapseButton = findChild<QPushButton *>("expandOrCollapseButton");
    if (expandOrCollapseButton && ecBrowser)
        connect(expandOrCollapseButton, SIGNAL(clicked()), ecBrowser, SLOT(ExpandOrCollapseAll()));

    connect(scene, SIGNAL(EntityRemoved(Entity*, AttributeChange::Type)), SLOT(RemoveEntity(Entity*)), Qt::UniqueConnection);
    connect(scene, SIGNAL(ActionTriggered(Entity *, const QString &, const QStringList &, EntityAction::ExecTypeField)),
        SLOT(OnActionTriggered(Entity *, const QString &, const QStringList &)), Qt::UniqueConnection);

    connect(this, SIGNAL(FocusChanged(ECEditorWindow *)), ecEditorModule, SLOT(ECEditorFocusChanged(ECEditorWindow*)));
    connect(this, SIGNAL(EditEntityXml(const QList<EntityPtr> &)), ecEditorModule, SLOT(CreateXmlEditor(const QList<EntityPtr> &)));
    connect(this, SIGNAL(EditComponentXml(const QList<ComponentPtr> &)), ecEditorModule, SLOT(CreateXmlEditor(const QList<ComponentPtr> &)));
    //connect(this, SIGNAL(AttributeAboutToBeEdited(IAttribute *)), this, SLOT(OnAboutToEditAttribute(IAttribute* )));
    connect(undoManager_, SIGNAL(CanUndoChanged(bool)), this, SLOT(OnUndoChanged(bool)));
    connect(undoManager_, SIGNAL(CanRedoChanged(bool)), this, SLOT(OnRedoChanged(bool)));
    connect(undoButton_, SIGNAL(clicked()), undoManager_, SLOT(Undo()));
    connect(redoButton_, SIGNAL(clicked()), undoManager_, SLOT(Redo()));
}