Esempio n. 1
0
File: ffcp.cpp Progetto: sylzd/FFCP
void FFCP::createDockWidget()
{
	//设置主窗体的第一个QDockWidget  
	QDockWidget *firstDockWidget = new QDockWidget(this);
	//设置第一个QDockWidget的窗口名称  
	firstDockWidget->setWindowTitle(tr("代码查看器"));
	//设置第一个QDockWidget的可停靠区域,全部可停靠  
	firstDockWidget->setAllowedAreas(Qt::AllDockWidgetAreas);
	//设置第一个QDockWidget内的控件并设置该控件的属性  
	codeViewer = new QTextEdit(tr("打开main.c文件"));  //前面别给定义 内存要报错 弄了我一天!!!!!!!!
	codeViewer->setAcceptDrops(false);  //禁止向codeViewer拖入东西
	firstDockWidget->setWidget(codeViewer);
	//向主窗体中添加第一个QDockWidget控件 第一个参数表示初始显示的位置 第二个参数是要添加的QDockWidget控件  
	this->addDockWidget(Qt::RightDockWidgetArea, firstDockWidget);
	//向菜单和工具栏中添加第一个QDockWidget的显示和隐藏动作  
	viewMenu->addAction(firstDockWidget->toggleViewAction());



	//设置第二个QDockWidget  
	QDockWidget *secondDockWidget = new QDockWidget(this);
	secondDockWidget->setWindowTitle(tr("功能编辑盒"));
	secondDockWidget->setAllowedAreas(Qt::AllDockWidgetAreas);
	functionBox = new FunctionBox;
	secondDockWidget->setWidget(functionBox);
	this->addDockWidget(Qt::LeftDockWidgetArea, secondDockWidget);
	//向菜单和工具栏中添加第一个QDockWidget的显示和隐藏动作  
	viewMenu->addAction(secondDockWidget->toggleViewAction());
}
Esempio n. 2
0
void InvMain::makeLayout()
{

    // create a docking window for several lists on the right side

    QDockWidget *dw = new QDockWidget(this);
    dw->setWindowTitle("Renderer Listbox ");
    /*qt3 dw->setFeatures(Qt::Horizontal);
   dw->setCloseMode(QDockWidget::Docked);
   dw->setResizeEnabled(true);*/

    listTabs = new QTabWidget(dw);
    listTabs->setMinimumWidth(250);

    /*colorListBox = new QListView(listTabs);
	  colorStringList = new QStringList();
      colorListModel = new QStringListModel(*colorStringList, NULL);
	  colorListBox->setModel(colorListModel);*/
    colorListWidget = new QListWidget(listTabs);
    colorListWidget->setViewMode(QListView::IconMode);

    treeWidget = new objTreeWidget(this, listTabs);
    treeWidget->show();

    listTabs->addTab(treeWidget, "Object Tree");
    listTabs->addTab(colorListWidget, "ColorMap List");

    dw->setWidget(listTabs);
    addDockWidget(Qt::RightDockWidgetArea, dw, Qt::Horizontal);

    // make a central widget window for the render area

    QWidget *main = new QWidget(this);
    main->setMinimumSize(720, 574); // will give PAL size images
    viewer = new InvViewer(main);
    setCentralWidget(main);

    // create the lower docking window for sequencer

    dw = new QDockWidget(this);
    addDockWidget(Qt::BottomDockWidgetArea, dw, Qt::Vertical);
    dw->setWindowTitle("Renderer Sequencer");
    // qt3 dw->setHorizontallyStretchable(true);
    // qt3 dw->setResizeEnabled(true);
    sequencer = new InvSequencer(dw);
    dw->setWidget(sequencer);
    dw->hide();

    // set the view all mode for the renderer
    viewer->viewAll();

    //connect( colorListBox->selectionModel(), SIGNAL(selectionChanged ( QItemSelection,QItemSelection )),
    //         this, SLOT(colorSelectionChanged ( QItemSelection,QItemSelection )) );
}
void ExecutingPietLibraries::MakeGLView (std::vector<PietTree> & pt){
    if(pt.size() == 0 )return;
    if(pt[0].isLeaf()) return;
    pt = pt[0].Nodes();

    if(pt.size() < 3) return;
    int w = pt[0].Val();
    int h = pt[1].Val();
    QString title = pt[2].toString();
    for(int i:range(3)) pt.pop_back();
    GLGameWidget* glgw = GLGameWidget::MakeUniqueGLWidget(nullptr);
    if(glgw == nullptr) return ;
    glgw->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    glgw->setSize(w,h);

    QDockWidget* dw = new QDockWidget(nullptr);
    dw->setFloating(true);
    dw->setAllowedAreas(Qt::NoDockWidgetArea);
    dw->connect(dw,&QDockWidget::dockLocationChanged,[=](){ dw->setFloating(true);});
    dw->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    dw->setWidget(glgw);
    dw->setAttribute(Qt::WA_DeleteOnClose);
    dw->setWindowTitle(title);
    dw->show();
}
Esempio n. 4
0
/**
 * Adds a new dock window to the main window and embeds the given \a widget.
 */
QDockWidget* DockWindowManager::addDockWindow(const char* name, QWidget* widget, Qt::DockWidgetArea pos)
{
    // creates the dock widget as container to embed this widget
    MainWindow* mw = getMainWindow();
    QDockWidget* dw = new QDockWidget(mw);
    // Note: By default all dock widgets are hidden but the user can show them manually in the view menu.
    // First, hide immediately the dock widget to avoid flickering, after setting up the dock widgets
    // MainWindow::loadLayoutSettings() is called to restore the layout.
    dw->hide();
    switch (pos) {
    case Qt::LeftDockWidgetArea:
    case Qt::RightDockWidgetArea:
    case Qt::TopDockWidgetArea:
    case Qt::BottomDockWidgetArea:
        mw->addDockWidget(pos, dw);
    default:
        break;
    }
    connect(dw, SIGNAL(destroyed(QObject*)),
            this, SLOT(onDockWidgetDestroyed(QObject*)));
    connect(widget, SIGNAL(destroyed(QObject*)),
            this, SLOT(onWidgetDestroyed(QObject*)));

    // add the widget to the dock widget
    widget->setParent(dw);
    dw->setWidget(widget);

    // set object name and window title needed for i18n stuff
    dw->setObjectName(QLatin1String(name));
    dw->setWindowTitle(QDockWidget::trUtf8(name));
    dw->setFeatures(QDockWidget::AllDockWidgetFeatures);

    d->_dockedWindows.push_back(dw);
    return dw;
}
void MainWindow::createDockWidget()
{
    CreateDockWidgetDialog dialog(this);
    int ret = dialog.exec();
    if (ret == QDialog::Rejected)
        return;

    QDockWidget *dw = new QDockWidget;
    dw->setObjectName(dialog.objectName());
    dw->setWindowTitle(dialog.objectName());
    dw->setWidget(new QTextEdit);

    Qt::DockWidgetArea area = dialog.location();
    switch (area) {
        case Qt::LeftDockWidgetArea:
        case Qt::RightDockWidgetArea:
        case Qt::TopDockWidgetArea:
        case Qt::BottomDockWidgetArea:
            addDockWidget(area, dw);
            break;
        default:
            if (!restoreDockWidget(dw)) {
                QMessageBox::warning(this, QString(), tr("Failed to restore dock widget"));
                delete dw;
                return;
            }
            break;
    }

    extraDockWidgets.append(dw);
    destroyDockWidgetMenu->setEnabled(true);
    destroyDockWidgetMenu->addAction(new QAction(dialog.objectName(), this));
}
void ConsoleWidgetCollection::onConsoleWindowTitleChanged(const QString & title)
{
	QWidget* widget = dynamic_cast<QWidget*>(sender());
	QDockWidget* dockWidget = dynamic_cast<QDockWidget*>(sender()->parent());
	if (!widget || !dockWidget)
		return;
	dockWidget->setWindowTitle(widget->windowTitle());
}
Esempio n. 7
0
QDockWidget *
MainWindow::createDockWidget( QWidget * widget, const QString& title, const QString& pageName )
{
    if ( widget->windowTitle().isEmpty() ) // avoid QTC_CHECK warning on console
        widget->setWindowTitle( title );

    if ( widget->objectName().isEmpty() )
        widget->setObjectName( pageName );

    QDockWidget * dockWidget = addDockForWidget( widget );
    dockWidget->setObjectName( pageName.isEmpty() ? widget->objectName() : pageName );

    if ( title.isEmpty() )
        dockWidget->setWindowTitle( widget->objectName() );
    else
        dockWidget->setWindowTitle( title );

    return dockWidget;
}
Esempio n. 8
0
EDATool::EDATool() {
	this->setWindowTitle(tr("EDATool"));

	boardScene = new QGraphicsScene();
	
	boardView = new BoardView(this, boardScene);
	if (!QCoreApplication::arguments().contains("-nogl"))
		boardView->setViewport(new QGLWidget);
	
	QTabWidget *tabs = new QTabWidget(this);
	tabs->setFocusPolicy(Qt::NoFocus); // don't let the tab header itself steal focus
	tabs->addTab(boardView, QString("Document"));
	tabs->setDocumentMode(true);
	this->setCentralWidget(tabs);
	QDockWidget *temp = new QDockWidget(this);
	QTreeWidget *tree = new QTreeWidget(this);
	temp->setWindowTitle("Tool settings");
	temp->setWidget(tree);
	tree->setColumnCount(1);
	tree->setHeaderLabel("Name");
	this->addDockWidget(Qt::LeftDockWidgetArea, temp);
	
	this->fileMenu = this->menuBar()->addMenu(tr("File"));
	this->editMenu = this->menuBar()->addMenu(tr("Edit"));
	this->placeMenu = this->menuBar()->addMenu(tr("&Place"));
	
	QLabel *t = new QLabel("LOL FU");
	t->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
	this->statusBar()->addPermanentWidget(t);
	t = new QLabel("MOAR TESTING");
	t->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
	this->statusBar()->addPermanentWidget(t);
	this->statusBar()->showMessage("showmessage", 2000);
	resize(700, 500);
	//Board board;
	toolBar = addToolBar("Tools");
	toolBar->setIconSize(QSize(16, 16));
	
	toolActionGroup = new QActionGroup(this);
	
	SelectTool *selTool = new SelectTool(this);
	selTool->install();
	RouteTool *tool = new RouteTool(this);
	tool->install();
	cache = new QHash<QString, QGraphicsItemGroup*>();
	QFile file("C:\\Users\\andreas\\workspace\\edatool\\test.brd");
	EagleFormat *eagleFormat = new EagleFormat();
	eagleFormat->read(&file,cache);
	QHashIterator<QString, QGraphicsItemGroup*> i(*cache);
	while (i.hasNext()) {
		i.next();
		QTreeWidgetItem *item = new QTreeWidgetItem(tree, QStringList(i.key()));
	}
	connect(tree,SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),this,SLOT(itemClicked(QTreeWidgetItem*,QTreeWidgetItem*)));
}
Esempio n. 9
0
DockedMainWindow::DockWidgetList DockedMainWindow::addToolWindows(const DesignerToolWindowList &tls)
{
    DockWidgetList rc;
    foreach (QDesignerToolWindow *tw, tls) {
        QDockWidget *dockWidget = new QDockWidget;
        dockWidget->setObjectName(tw->objectName() + QLatin1String("_dock"));
        dockWidget->setWindowTitle(tw->windowTitle());
        addDockWidget(tw->dockWidgetAreaHint(), dockWidget);
        dockWidget->setWidget(tw);
        rc.push_back(dockWidget);
    }
Esempio n. 10
0
void DockWidgetManager::transLateWidgetTitle()
{
    QMap<QString, QDockWidget*>::iterator ed = m_dockWidgets.end();
    QMap<QString, QDockWidget*>::iterator it;

    for ( it = m_dockWidgets.begin() ; it != ed ; ++it )
    {
        QDockWidget *widget = it.value();
        widget->setWindowTitle( QApplication::translate( "MainWindow",
                                                         it.key().toStdString().c_str() ) );
    }
}
Esempio n. 11
0
RightPanel::RightPanel(RestClientMainWindow* app)
{
    m_responseHeaders = new QTextEdit;
    m_responseHeaders->setAcceptRichText(false);
    m_responseHeaders->setReadOnly(true);

    QDockWidget *dock = new QDockWidget(app);
    dock->setObjectName("Right");
    dock->setWindowTitle(QObject::tr("Response Headers"));
    dock->setWidget(m_responseHeaders);
    dock->setFeatures(QDockWidget::DockWidgetMovable
                      | QDockWidget::DockWidgetFloatable);
    app->addDockWidget(Qt::LeftDockWidgetArea, dock);
}
void UiController::addDockWidget(Qt::DockWidgetArea area, QString name, QWidget *widget)
{
    QDockWidget *dockWidget = new QDockWidget;
    dockWidget->setWindowTitle(name);
    dockWidget->setObjectName(name);
    dockWidget->setWidget(widget);
    widget->setParent(dockWidget);

    _mainWindow.addDockWidget(area, dockWidget);
    if (area == Qt::BottomDockWidgetArea) {
        if (_lastBottomDockWidgetAdded)
            _mainWindow.tabifyDockWidget(_lastBottomDockWidgetAdded, dockWidget);
        _lastBottomDockWidgetAdded = dockWidget;
    }
}
/**
*  @brief
*    Constructor
*/
DockWidgetRTTIBrowser::DockWidgetRTTIBrowser(QMainWindow *pQMainWindow, DockWidgetManager *pDockWidgetManager) : DockWidget(reinterpret_cast<QWidget*>(pQMainWindow), pDockWidgetManager)
{
	// Get encapsulated Qt dock widget
	QDockWidget *pQDockWidget = GetQDockWidget();
	if (pQDockWidget) {
		// Create RTTI browser widget
		pQDockWidget->setWidget(new RTTIBrowserWidget());

		// Set window title
		pQDockWidget->setWindowTitle(pQDockWidget->tr(GetClass()->GetProperties().Get("Title")));

		// Add the created Qt dock widget to the given Qt main window and tabify it for better usability
		AddDockWidgetAndTabify(*pQMainWindow, Qt::BottomDockWidgetArea, *pQDockWidget);
	}
}
Esempio n. 14
0
void MainWindow::createHeader()
{
//    QToolBar *tb = new QToolBar(this);
    QDockWidget *header = new QDockWidget(this);
    QHBoxLayout *ly = new QHBoxLayout();
    QFrame *frm = new QFrame();
    QPushButton *pbExit = new QPushButton();
    pbExit->setIcon(QIcon(":/images/meiti-up.png"));
    pbExit->setIconSize(QSize(40,40));

    pbExit->setFocusPolicy(Qt::NoFocus);
    pbExit->setFocusProxy(0);
    pbExit->setStyleSheet(QString("background-image: url(:/images/meiti-up.png);\n\n#pbExit:pressed {background-image: url(:/images/meiti-down.png) 4 4 4 4 strech strech;}\n\n#pbExit:hover {background-image: url(:/images/meiti-over.png) 4 4 4 4 strech strech;}\n"));

    connect(pbExit, SIGNAL(clicked()), qApp, SLOT(quit()));


    ly->addWidget(pbExit);
    ly->setAlignment(pbExit,Qt::AlignCenter);
    frm->setLayout(ly);
    frm->setAttribute(Qt::WA_TranslucentBackground, true);        // 设置背景透明(version >= QT4.5

    header->setWidget(frm);

    header->setAttribute(Qt::WA_TranslucentBackground, true);        // 设置背景透明(version >= QT4.5

    //header->setWindowFlags(Qt::FramelessWindowHint);
    header->setWindowTitle(QString(""));
    header->setTitleBarWidget(new QWidget);
    header->setFocusPolicy(Qt::NoFocus);
    header->setFocusProxy(0);
    header->setFeatures(QDockWidget::NoDockWidgetFeatures);
    header->setBaseSize(0,40);

    addDockWidget(Qt::TopDockWidgetArea,header, Qt::Horizontal);

//    tb->addWidget(frm);
//    pbExit->setText(QString("%1--%2--%3").arg(this->width()).arg(tb->width()).arg(pbExit->width()));
//
//    tb->setMovable(false);
//
//    this->addToolBar(tb);

//	dockWidget->setWidget(keyboardfrm);
//	dockWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
//	dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
//	addDockWidget(Qt::BottomDockWidgetArea,dockWidget);
}
void XletAgentStatusDashboard::updateQueueConfig(const QString & queue_id)
{
    QDockWidget * dock;
    FilteredAgentList * filtered_agent_list;
    if (m_filtered_agent_lists.contains(queue_id)) {
        dock = this->m_window->findChild<QDockWidget *>(queue_id);
        filtered_agent_list = this->m_filtered_agent_lists.value(queue_id);
    } else {
        dock = this->createDock(queue_id);
        filtered_agent_list = this->createFilteredAgentList(queue_id);
        QWidget * agent_list_view = dynamic_cast<QWidget *>(filtered_agent_list->getView());
        dock->setWidget(agent_list_view);
        dock->show();
    }
    dock->setWindowTitle(filtered_agent_list->getQueueName());
}
Esempio n. 16
0
QDockWidget *DockWidgetCatalog::addDockWidget(QWidget *widget, const QString &windowTitle, Qt::DockWidgetArea area)
{
    if (widget == nullptr)
        return nullptr;

    QDockWidget *dock = new QDockWidget();
    dock->setWidget(widget);
    dock->setWindowTitle(windowTitle);
    dock->setObjectName(windowTitle);

    m_widgets.push_back(dock);
    m_mainWindow.addDockWidget(area, dock);

    onDockWidgetAdded(dock);

    return dock;
}
Esempio n. 17
0
void MainWindow::initHistory(int snapType)
{
	QString title = dockCtrlNames[snapType];
	QDockWidget *dockWidget = new QDockWidget(this);

	dockWidget->setObjectName("dockWidget_" + title);
	dockWidget->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable|QDockWidget::NoDockWidgetFeatures);
	QWidget *dockWidgetContents = new QWidget(dockWidget);
	dockWidgetContents->setObjectName("dockWidgetContents_" + title);
	QGridLayout *gridLayout = new QGridLayout(dockWidgetContents);
	gridLayout->setObjectName("gridLayout_" + title);
	gridLayout->setContentsMargins(0, 0, 0, 0);

	QTextBrowser * tb;
	if (snapType == DOCK_HISTORY)
	{
		tb = tbHistory = new QTextBrowser(dockWidgetContents);
		tbHistory->setOpenExternalLinks(true);
	}
	else if (snapType == DOCK_MAMEINFO)
		tb = tbMameinfo = new QTextBrowser(dockWidgetContents);
	else if (snapType == DOCK_DRIVERINFO)
		tb = tbDriverinfo = new QTextBrowser(dockWidgetContents);
	else if (snapType == DOCK_STORY)
		tb = tbStory = new QTextBrowser(dockWidgetContents);
	else
		tb = tbCommand = new QTextBrowser(dockWidgetContents);
	
	tb->setObjectName("textBrowser_" + title);
	tb->setFrameShape(QFrame::NoFrame);

	gridLayout->addWidget(tb);

	dockWidget->setWidget(dockWidgetContents);
	dockWidget->setWindowTitle(tr(qPrintable(title)));
	addDockWidget(static_cast<Qt::DockWidgetArea>(Qt::RightDockWidgetArea), dockWidget);

	// create tabbed history widgets
	if (dwHistory)
		tabifyDockWidget(dwHistory, dockWidget);
	else
		dwHistory = dockWidget;

	menuDocuments->addAction(dockWidget->toggleViewAction());
	dockCtrls[snapType] = dockWidget;
}
Esempio n. 18
0
void ControlSingleton::showDialog(Gui::TaskView::TaskDialog *dlg)
{
    // only one dialog at a time
    assert(!ActiveDialog || ActiveDialog==dlg);
    Gui::DockWnd::CombiView* pcCombiView = qobject_cast<Gui::DockWnd::CombiView*>
        (Gui::DockWindowManager::instance()->getDockWindow("Combo View"));
    // should return the pointer to combo view
    if (pcCombiView) {
        pcCombiView->showDialog(dlg);
        // make sure that the combo view is shown
        QDockWidget* dw = qobject_cast<QDockWidget*>(pcCombiView->parentWidget());
        if (dw) {
            dw->setVisible(true);
            dw->toggleViewAction()->setVisible(true);
            dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
        }

        if (ActiveDialog == dlg)
            return; // dialog is already defined
        ActiveDialog = dlg;
        connect(dlg, SIGNAL(destroyed()), this, SLOT(closedDialog()));
    }
    // not all workbenches have the combo view enabled
    else if (!_taskPanel) {
        QDockWidget* dw = new QDockWidget();
        dw->setWindowTitle(tr("Task panel"));
        dw->setFeatures(QDockWidget::DockWidgetMovable);
        _taskPanel = new Gui::TaskView::TaskView(dw);
        dw->setWidget(_taskPanel);
        _taskPanel->showDialog(dlg);
        getMainWindow()->addDockWidget(Qt::LeftDockWidgetArea, dw);
        connect(dlg, SIGNAL(destroyed()), dw, SLOT(deleteLater()));

        // if we have the normal tree view available then just tabify with it
        QWidget* treeView = Gui::DockWindowManager::instance()->getDockWindow("Tree view");
        QDockWidget* par = treeView ? qobject_cast<QDockWidget*>(treeView->parent()) : 0;
        if (par && par->isVisible()) {
            getMainWindow()->tabifyDockWidget(par, dw);
            qApp->processEvents(); // make sure that the task panel is tabified now
            dw->show();
            dw->raise();
        }
    }
}
Esempio n. 19
0
// Inicializa los elementos necesarios para la aplicación
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
	setupUi(this);
	setupActions();
	
	// Configura la barra de herramienta
	QMenu *toolBarMenu = menuSettings->addMenu(tr("&Toolbars"));
	toolBar->toggleViewAction()->setShortcut(tr("CTRL+T"));
	toolBar->toggleViewAction()->setStatusTip(tr("Show/Hide Main Toolbar"));
	toolBar->toggleViewAction()->setText(tr("&Main Toolbar"));
	toolBarMenu->addAction(toolBar->toggleViewAction());
	
	actionUndo->setEnabled(false);
	actionRepeat->setEnabled(false);
	
	mStatLabel = new QLabel();
	statusBar()->addPermanentWidget(mStatLabel);
	
	connect(textEdit, SIGNAL(textChanged()),
			this, SLOT(updateStats()));
	
	updateStats();
	
	QDockWidget *templateDocker = new QDockWidget;
	templateDocker->setAllowedAreas(Qt::LeftDockWidgetArea|
									Qt::RightDockWidgetArea);
	templateDocker->setObjectName("TemplateDocker");
	templateDocker->setWindowTitle("Templates");
	addDockWidget(Qt::LeftDockWidgetArea,templateDocker);
	
	QListView *view = new QListView();
	templateDocker->setWidget(view);
	
	TemplateHandler *mTemplate = new TemplateHandler(view, textEdit, this);
	
	templateDocker->toggleViewAction()->setShortcut(tr("CTRL+M"));
	templateDocker->toggleViewAction()->setStatusTip(tr("Show/Hide Template Docker"));
	templateDocker->toggleViewAction()->setText(tr("&Template Docker"));
	toolBarMenu->addAction(templateDocker->toggleViewAction());
	
	// Recuoera la configuración del editor
	readsettings();
}
Esempio n. 20
0
void Recorder::updateSimulatorSettings() {
    QDockWidget* dockWidget =
        qobject_cast<QDockWidget*>(patientStatusBar_->parentWidget());
    dockWidget->setWindowTitle(options()->recorderFlags
                               .testFlag(Options::PatientStatusBarHasTitle)
        ? tr("Patient Status") : "");
    if (options()->recorderFlags.testFlag(Options::ImmovablePatientStatusBar))
        dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
    else
        dockWidget->setFeatures(QDockWidget::DockWidgetClosable
            | QDockWidget::DockWidgetMovable 
            | QDockWidget::DockWidgetFloatable);
    updateMenus();
    //setupInitialScreen(true);
    // signal update simulator settings in Navigator
    /// TODO ? how to handle disk caching in middle of study
    // ? disallow it
    emit simulatorSettingsChanged();
}
Esempio n. 21
0
QDockWidget* DockHost::createDock(QWidget* parent, QWidget* widget, const QString &title)
{
    static int counter = 0;
    QDockWidget* dock = new QDockWidget(parent);
    dock->setObjectName(QString("dock%1").arg(++counter));
    dock->setWidget(widget);
    dock->setWindowTitle(title);
    QObject::connect(dock, &QDockWidget::topLevelChanged, this, &DockHost::onDockTopLevelChanged);
    QObject::connect(dock, &QDockWidget::visibilityChanged, this, &DockHost::onDockVisibilityChanged);
    QObject::connect(dock, &QDockWidget::featuresChanged, this, &DockHost::onDockFeaturesChanged);

    QAction* action = dock->toggleViewAction();
    action->disconnect();
    QObject::connect(action, &QAction::triggered, this, &DockHost::onDockActionTriggered);

    dock->installEventFilter(this);

    widgets << widget;
    return dock;
}
/**
*  @brief
*    Constructor
*/
DockWidgetVolumeTransferFunction::DockWidgetVolumeTransferFunction(QMainWindow *pQMainWindow, DockWidgetManager *pDockWidgetManager) : DockWidgetVolume(reinterpret_cast<QWidget*>(pQMainWindow), pDockWidgetManager),
	m_pDockWidgetVolumeTransferFunctionQObject(new DockWidgetVolumeTransferFunctionQObject(*this)),
	m_pTransferFunctionWidget(nullptr),
	m_pTransferFunctionResultWidget(nullptr)
{
	// Get encapsulated Qt dock widget
	QDockWidget *pQDockWidget = GetQDockWidget();
	if (pQDockWidget) {
		// Set window title
		pQDockWidget->setWindowTitle(pQDockWidget->tr(GetClass()->GetProperties().Get("Title")));

		// Add the created Qt dock widget to the given Qt main window and tabify it for better usability
		AddDockWidgetAndTabify(*pQMainWindow, Qt::LeftDockWidgetArea, *pQDockWidget);

		// The Qt object should receive events from the encapsulated Qt dock widget
		pQDockWidget->installEventFilter(m_pDockWidgetVolumeTransferFunctionQObject);

		// Update the volume information
		UpdateObject(GetSelectedObject());
	}
}
Esempio n. 23
0
QDockWidget* DockHost::createDock(QWidget* parent, QWidget* widget, const QString& title)
{
    static int counter = 0;
    QDockWidget* dock = new QDockWidget(parent);
    dock->setObjectName(QString("dock%1").arg(++counter));

    QMargins widgetMargins = widget->layout()->contentsMargins();
    widgetMargins.setTop(widgetMargins.top() + 2);
    widget->layout()->setContentsMargins(widgetMargins);
    dock->setWidget(widget);
    dock->setWindowTitle(title);

    QObject::connect(dock, &QDockWidget::topLevelChanged, this, &DockHost::onDockTopLevelChanged);

    QAction* action = dock->toggleViewAction();
    action->disconnect();
    QObject::connect(action, &QAction::triggered, this, &DockHost::onDockActionTriggered);

    dock->installEventFilter(this);

    widgets << widget;
    return dock;
}
Esempio n. 24
0
void MainWindow::createModelAndView()
{
    m_treeView = new TreeView(this);
    m_treeView->setPluginManager(m_pluginManager);
    QDockWidget *treeViewDock = new QDockWidget("Tree View", this);
    treeViewDock->setWidget(m_treeView);
    treeViewDock->setWindowTitle("Tree View");
    addDockWidget(Qt::RightDockWidgetArea, treeViewDock);
    treeViewDock->setVisible(false);
    connect(ui->viewTreeViewAction, &QAction::triggered,
            [this, treeViewDock] (bool checked) {
        treeViewDock->setVisible(checked);
    });
    connect(treeViewDock, &QDockWidget::visibilityChanged,
            [this] (bool visible) {
        ui->viewTreeViewAction->setChecked(visible);
    });
    m_graphicsItemView = new GraphicsItemView(this);
    m_graphicsItemView->setPluginManager(m_pluginManager);
    m_graphicsItemView->setApplication(m_sharedApplication);

    MusicModel *musicModel = new MusicModel(this);
    musicModel->setPluginManager(m_pluginManager);

    m_model = musicModel;

    MusicProxyModel *proxyModel = new MusicProxyModel(this);
    proxyModel->setPluginManager(m_pluginManager);
    proxyModel->setSourceModel(m_model);
    m_proxyModel = proxyModel;

    m_treeView->setModel(m_proxyModel);

    m_graphicsItemView->setModel(m_model);
    setCentralWidget(m_graphicsItemView);
}
Esempio n. 25
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
    selectInteractor(0), newLineItemInteractor(0),
    newRectItemInteractor(0), newTextItemInteractor(0) {

    setObjectName(QStringLiteral("MainWindow"));
    resize(1024, 768);

    graphicsSheet = new GraphicsSheet(this);
    QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect(graphicsSheet);
    shadow->setBlurRadius(20);
    shadow->setColor(QColor(0xa0, 0xa0, 0xa0));
    graphicsSheet->setGraphicsEffect(shadow);

    graphicsSheet->setScaleBackground(QColor(0xFF, 0xFF, 0xF8));

    QLayout* layout = new ScrollAreaLayout();
    layout->addWidget(graphicsSheet);

    QWidget *centralwidget = new QWidget(this);
    centralwidget->setLayout(layout);
    setCentralWidget(centralwidget);

/*****************************************************************************/
    menubar = new QMenuBar(this);
    menubar->setObjectName(QStringLiteral("menubar"));
    menubar->setGeometry(QRect(0, 0, 401, 21));
    setMenuBar(menubar);

    statusbar = new QStatusBar(this);
    statusbar->setObjectName(QStringLiteral("statusbar"));
    setStatusBar(statusbar);

    toolBar = new QToolBar(this);
    toolBar->setObjectName(QStringLiteral("toolBar"));
    addToolBar(Qt::TopToolBarArea, toolBar);
/*****************************************************************************/

/* Initialize zoom, scale, and paper formats */
    graphicsSheet->addScale("1:10",  0.1);
    graphicsSheet->addScale("1:5",   0.2);
    graphicsSheet->addScale("1:2",   0.5);
    graphicsSheet->addScale("1:1",   1.0);
    graphicsSheet->addScale("2:1",   2.0);
    graphicsSheet->addScale("5:1",   5.0);
    graphicsSheet->addScale("10:1", 10.0);

    LabelledComboBox* scaleWidget = new LabelledComboBox(toolBar, "Scale: ");
    scaleWidget->getComboBox()->addItems(graphicsSheet->getScaleNames());
    toolBar->addWidget(scaleWidget);
    QObject::connect(scaleWidget->getComboBox(), SIGNAL(currentIndexChanged(int)),
                     graphicsSheet, SLOT(setScale(int)));

    graphicsSheet->addZoom("50%",  0.5);
    graphicsSheet->addZoom("75%",  0.75);
    graphicsSheet->addZoom("100%", 1.0);
    graphicsSheet->addZoom("125%", 1.25);
    graphicsSheet->addZoom("150%", 1.5);
    graphicsSheet->addZoom("200%", 2.0);

    LabelledComboBox* zoomWidget = new LabelledComboBox(toolBar, "Zoom: ");
    zoomWidget->getComboBox()->addItems(graphicsSheet->getZoomNames());
    toolBar->addWidget(zoomWidget);
    QObject::connect(zoomWidget->getComboBox(), SIGNAL(currentIndexChanged(int)),
                     graphicsSheet, SLOT(setZoom(int)));

    graphicsSheet->setUnit("mm");
    graphicsSheet->addSize("DIN A3", QSizeF(297.0, 420.0));
    graphicsSheet->addSize("DIN A4", QSizeF(210.0, 297.0));
    graphicsSheet->addSize("Letter", QSizeF(215.9, 279.4));
    graphicsSheet->addSize("DIN A5", QSizeF(148.0, 210.0));

    LabelledComboBox* sizeWidget = new LabelledComboBox(toolBar, "Sheet Size: ");
    sizeWidget->getComboBox()->addItems(graphicsSheet->getSizeNames());
    toolBar->addWidget(sizeWidget);
    QObject::connect(sizeWidget->getComboBox(), SIGNAL(currentIndexChanged(int)),
                     graphicsSheet, SLOT(setSize(int)));

    QCheckBox* checkbox = new QCheckBox("Landscape", toolBar);
    toolBar->addWidget(checkbox);
    QObject::connect(checkbox, SIGNAL(stateChanged(int)),
                     graphicsSheet, SLOT(setDirection(int)));

    QIcon icon;
    icon.addFile(QStringLiteral(":/Icons/file-load.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionLoad = new QAction(icon, "Load drawing ...", this);
    toolBar->addAction(actionLoad);
    QObject::connect(actionLoad, SIGNAL(triggered()), this, SLOT(doActionLoad()));

    QIcon icon2;
    icon2.addFile(QStringLiteral(":/Icons/file-save.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionSave = new QAction(icon2, "Save drawing", this);
    toolBar->addAction(actionSave);
    QObject::connect(actionSave, SIGNAL(triggered()), this, SLOT(doActionSave()));

    QIcon icon3;
    icon3.addFile(QStringLiteral(":/Icons/file-save-as.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionSaveAs = new QAction(icon3, "Save drawing as ...", this);
    toolBar->addAction(actionSaveAs);
    QObject::connect(actionSaveAs, SIGNAL(triggered()), this, SLOT(doActionSaveAs()));

    QIcon icon4;
    icon4.addFile(QStringLiteral(":/Icons/object-select.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionSelect = new QAction(icon4, "Edit object", this);
    actionSelect->setCheckable(true);
    toolBar->addAction(actionSelect);
    QObject::connect(actionSelect, SIGNAL(triggered()), this, SLOT(doActionSelect()));

    QIcon icon5;
    icon5.addFile(QStringLiteral(":/Icons/object-newline.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewLineItem = new QAction(icon5, "New line", this);
    actionNewLineItem->setCheckable(true);
    toolBar->addAction(actionNewLineItem);
    QObject::connect(actionNewLineItem, SIGNAL(triggered()), this, SLOT(doActionNewLineItem()));

    QIcon icon6;
    icon6.addFile(QStringLiteral(":/Icons/object-newrect.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewRectItem = new QAction(icon6, "New rectangle", this);
    actionNewRectItem->setCheckable(true);
    toolBar->addAction(actionNewRectItem);
    QObject::connect(actionNewRectItem, SIGNAL(triggered()), this, SLOT(doActionNewRectItem()));

    QIcon icon7;
    icon7.addFile(QStringLiteral(":/Icons/object-newtext.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewTextItem = new QAction(icon7, "New text rectangle", this);
    actionNewTextItem->setCheckable(true);
    toolBar->addAction(actionNewTextItem);
    QObject::connect(actionNewTextItem, SIGNAL(triggered()), this, SLOT(doActionNewTextItem()));

    QIcon icon8;
    icon8.addFile(QStringLiteral(":/Icons/object-newcircle.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewCircleItem = new QAction(icon8, "New circle", this);
    actionNewCircleItem->setCheckable(true);
    toolBar->addAction(actionNewCircleItem);
    QObject::connect(actionNewCircleItem, SIGNAL(triggered()), this, SLOT(doActionNewCircleItem()));

    QIcon icon9;
    icon9.addFile(QStringLiteral(":/Icons/object-newellipse.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewEllipseItem = new QAction(icon9, "New ellipse", this);
    actionNewEllipseItem->setCheckable(true);
    toolBar->addAction(actionNewEllipseItem);
    QObject::connect(actionNewEllipseItem, SIGNAL(triggered()), this, SLOT(doActionNewEllipseItem()));

    QIcon icon10;
    icon10.addFile(QStringLiteral(":/Icons/object-newbezier.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewBezierItem = new QAction(icon10, "New bezier curve", this);
    actionNewBezierItem->setCheckable(true);
    toolBar->addAction(actionNewBezierItem);
    QObject::connect(actionNewBezierItem, SIGNAL(triggered()), this, SLOT(doActionNewBezierItem()));

    QIcon icon11;
    icon11.addFile(QStringLiteral(":/Icons/object-delete.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionDeleteItem = new QAction(icon11, "Delete selected objects", this);
    toolBar->addAction(actionDeleteItem);
    QObject::connect(actionDeleteItem, SIGNAL(triggered()), graphicsSheet, SLOT(deleteSelectedItems()));

    QIcon icon12;
    icon12.addFile(QStringLiteral(":/Icons/edit-redo.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionRedo = new QAction(icon12, "Redo last undone action", this);
    toolBar->addAction(actionRedo);
    QObject::connect(actionRedo, SIGNAL(triggered()), this, SLOT(doActionRedo()));

    QIcon icon13;
    icon13.addFile(QStringLiteral(":/Icons/edit-undo.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionUndo = new QAction(icon13, "Undo last action", this);
    toolBar->addAction(actionUndo);
    QObject::connect(actionUndo, SIGNAL(triggered()), this, SLOT(doActionUndo()));

    QActionGroup* actionGroup = new QActionGroup(this);
    actionGroup->addAction(actionSelect);
    actionGroup->addAction(actionNewLineItem);
    actionGroup->addAction(actionNewRectItem);
    actionGroup->addAction(actionNewTextItem);
    actionGroup->addAction(actionNewCircleItem);
    actionGroup->addAction(actionNewEllipseItem);
    actionGroup->addAction(actionNewBezierItem);
    actionSelect->setChecked(true);

#if 0
    QAction* actionInfo = new QAction("Info", this);
    toolBar->addAction(actionInfo);
    QObject::connect(actionInfo, SIGNAL(triggered(bool)),
                     this, SLOT(printInfo()));

    QAction* actionRotate = new QAction("Rotate", this);
    toolBar->addAction(actionRotate);
    QObject::connect(actionRotate, SIGNAL(triggered(bool)),
                     this, SLOT(rotateItem()));

    QAction* actionResize = new QAction("ResizeHandle", this);
    toolBar->addAction(actionResize);
    QObject::connect(actionResize, SIGNAL(triggered(bool)),
                     this, SLOT(resizeItem()));
#endif

    zoomWidget->getComboBox()->setCurrentIndex(2);
    sizeWidget->getComboBox()->setCurrentIndex(3);
    scaleWidget->getComboBox()->setCurrentIndex(2);
    checkbox->setChecked(true);

/*****************************************************************************/

    GraphicsScene* scene = dynamic_cast<GraphicsScene*>(graphicsSheet->scene());
    QObject::connect(scene, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
    scene->loadFromFile("sample.drw");

    selectInteractor = new EditItemInteractor();
// TODO: get all registered items from the factory!
#if 0
    newLineItemInteractor = new NewItemInteractor(LineItem::create, 1); // LineItem::P2Handle);
    QObject::connect(newLineItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
    newRectItemInteractor = new NewItemInteractor(RectItem::create, 1); // RectItem::BottomRightHandle);
    QObject::connect(newRectItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
    newTextItemInteractor = new NewItemInteractor(TextItem::create, 1); // TextItem::BottomRightHandle);
    QObject::connect(newTextItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
    newCircleItemInteractor = new NewItemInteractor(CircleItem::create, 1); // CircleItem::RadHandle);
    QObject::connect(newCircleItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
    newEllipseItemInteractor = new NewItemInteractor(EllipseItem::create, 1); // EllipseItem::BottomRightHandle);
    QObject::connect(newEllipseItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
    newBezierItemInteractor = new NewItemInteractor(BezierItem::create, 1); // BezierItem::P2Handle);
    QObject::connect(newBezierItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
#endif

    graphicsSheet->setInteractor(selectInteractor);
    graphicsSheet->setSnapper(new EdgeSnapper(new GridSnapper()));

    propertyEditor = new ObjectController();
    QDockWidget* propertiesDock = new QDockWidget(this);
    propertiesDock->setObjectName(QStringLiteral("propertiesDock"));
    propertiesDock->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
    propertiesDock->setWindowTitle("Item properties");
    propertiesDock->setWidget(propertyEditor);
    addDockWidget(static_cast<Qt::DockWidgetArea>(2), propertiesDock);
}
QDockWidget *TikzCommandInserter::getDockWidget(QWidget *parent)
{
	QDockWidget *tikzDock = new QDockWidget(parent);
	tikzDock->setObjectName("CommandsDock");
	tikzDock->setAllowedAreas(Qt::AllDockWidgetAreas);
	tikzDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
	tikzDock->setWindowTitle(m_tikzSections.title);
	tikzDock->setWhatsThis(tr("<p>This is a list of TikZ "
	                          "commands.  You can insert these commands in your code by "
	                          "clicking on them.  You can obtain more commands by "
	                          "changing the category in the combo box.</p>"));

	QAction *focusTikzDockAction = new QAction(parent);
	focusTikzDockAction->setShortcut(QKeySequence(tr("Alt+I")));
	tikzDock->addAction(focusTikzDockAction);
	connect(focusTikzDockAction, SIGNAL(triggered()), tikzDock, SLOT(setFocus()));

	QLabel *commandsComboLabel = new QLabel(tr("Category:"));
	ComboBox *commandsCombo = new ComboBox;
	commandsCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
	QStackedWidget *commandsStack = new QStackedWidget;
	connect(commandsCombo, SIGNAL(currentIndexChanged(int)), commandsStack, SLOT(setCurrentIndex(int)));

	QListWidget *tikzListWidget = new QListWidget;
	addListWidgetItems(tikzListWidget, m_tikzSections, false); // don't add children
	tikzListWidget->setMouseTracking(true);
	connect(tikzListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
	connect(tikzListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
	connect(tikzListWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
//	connect(tikzListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
	commandsCombo->addItem(tr("General"));
	commandsStack->addWidget(tikzListWidget);

	for (int i = 0; i < m_tikzSections.children.size(); ++i)
	{
		QListWidget *tikzListWidget = new QListWidget;
		addListWidgetItems(tikzListWidget, m_tikzSections.children.at(i));
		tikzListWidget->setMouseTracking(true);
		connect(tikzListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
		connect(tikzListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
		connect(tikzListWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
//		connect(tikzListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));

		QString comboItemText = m_tikzSections.children.at(i).title;
		commandsCombo->addItem(comboItemText.remove('&'));
		commandsStack->addWidget(tikzListWidget);
	}

	QGridLayout *tikzLayout = new QGridLayout;
	tikzLayout->addWidget(commandsComboLabel, 0, 0);
	tikzLayout->addWidget(commandsCombo, 0, 1);
	tikzLayout->addWidget(commandsStack, 1, 0, 1, 2);
	tikzLayout->setMargin(5);

	TikzCommandWidget *tikzWidget = new TikzCommandWidget;
	tikzWidget->setLayout(tikzLayout);
	tikzDock->setWidget(tikzWidget);
	tikzDock->setFocusProxy(commandsCombo);

	return tikzDock;
}
Esempio n. 27
0
void AcceleratorManagerPrivate::calculateAccelerators(Item *item, QString &used)
{
    if (!item->m_children)
        return;

    // collect the contents
    AccelStringList contents;
    for (Item *it: *item->m_children) {
        contents << it->m_content;
    }

    // find the right accelerators
    AccelManagerAlgorithm::findAccelerators(contents, used);

    // write them back into the widgets
    int cnt = -1;
    for (Item *it: *item->m_children) {
        cnt++;

        QDockWidget *dock = qobject_cast<QDockWidget*>(it->m_widget);
        if (dock) {
            if (checkChange(contents[cnt]))
                dock->setWindowTitle(contents[cnt].accelerated());
            continue;
        }
        QTabBar *tabBar = qobject_cast<QTabBar*>(it->m_widget);
        if (tabBar) {
            if (checkChange(contents[cnt]))
                tabBar->setTabText(it->m_index, contents[cnt].accelerated());
            continue;
        }
        QMenuBar *menuBar = qobject_cast<QMenuBar*>(it->m_widget);
        if (menuBar) {
            if (it->m_index >= 0) {
                QAction *maction = menuBar->actions()[it->m_index];
                if (maction) {
                    checkChange(contents[cnt]);
                    maction->setText(contents[cnt].accelerated());
                }
                continue;
            }
        }

        // we possibly reserved an accel, but we won't set it as it looks silly
        QGroupBox *groupBox = qobject_cast<QGroupBox*>(it->m_widget);
        if (groupBox && !groupBox->isCheckable())
            continue;

        int tprop = it->m_widget->metaObject()->indexOfProperty("text");
        if (tprop != -1)  {
            if (checkChange(contents[cnt]))
                it->m_widget->setProperty("text", contents[cnt].accelerated());
        } else {
            tprop = it->m_widget->metaObject()->indexOfProperty("title");
            if (tprop != -1 && checkChange(contents[cnt]))
                it->m_widget->setProperty("title", contents[cnt].accelerated());
        }
    }

    // calculate the accelerators for the children
    for (Item *it: *item->m_children) {
        if (it->m_widget && it->m_widget->isVisibleTo( item->m_widget ) )
            calculateAccelerators(it, used);
    }
}
Esempio n. 28
0
/**
*  @brief
*    Selects the given object
*/
void DockWidgetObject::SelectObject(Object *pObject)
{
	// State change?
	if (m_pObject != pObject) {
		// Disconnect event handler
		if (m_pObject)
			m_pObject->SignalDestroyed.Disconnect(SlotOnDestroyed);

		// Backup the given object pointer
		m_pObject = pObject;

		// Connect event handler
		if (m_pObject)
			m_pObject->SignalDestroyed.Connect(SlotOnDestroyed);

		// Is there a PL introspection model instance?
		if (m_pPLIntrospectionModel) {
			// Set object
			m_pPLIntrospectionModel->SetObject(m_pObject);

			{ // Usability: Resize the first tree view column given to the size of its contents
				// No need to backup current expanded state and restore it after we're done because we set new content above resulting in that all is collapsed when we're in here
				m_pQTreeView->expandAll();
				m_pQTreeView->resizeColumnToContents(0);
				m_pQTreeView->collapseAll();
			}

			// Get encapsulated Qt dock widget and set a decent window title
			QDockWidget *pQDockWidget = GetQDockWidget();
			if (pQDockWidget) {
				// Set window title
				QString sQStringWindowTitle = pQDockWidget->tr(GetClass()->GetProperties().Get("Title"));
				if (m_pObject) { 
					// Append class name
					sQStringWindowTitle += ": ";
					sQStringWindowTitle += QtStringAdapter::PLToQt('\"' + m_pObject->GetClass()->GetClassName() + '\"');	// Put it into quotes to make it possible to see e.g. trailing spaces

					// An "PLCore::Object" itself has no "name", we could show the memory address but this wouldn't be that useful to the user
					// -> Try "GetAbsoluteName()"-method to get an absolute name
					// -> In case there's no name, check whether there's an name attribute
					// -> In case there's still no name, check whether or not there's an filename attribute
					String sName;
					{ // Try "GetAbsoluteName()"-method to get an absolute name
						// Get the typed dynamic parameters
						Params<String> cParams;

						// Call the RTTI method
						m_pObject->CallMethod("GetAbsoluteName", cParams);

						// Get the result
						sName = cParams.Return;
						if (sName.GetLength())
							sName = "Name = \"" + sName + '\"';	// Put it into quotes to make it possible to see e.g. trailing spaces
					}

					// Do we already have a name?
					if (!sName.GetLength()) {
						// Check whether there's an name attribute
						DynVar *pDynVar = m_pObject->GetAttribute("Name");
						if (pDynVar)
							sName = "Name = \"" + pDynVar->GetString() + '\"';	// Put it into quotes to make it possible to see e.g. trailing spaces

						// In case there's still no name, check whether or not there's an filename attribute
						if (!sName.GetLength()) {
							DynVar *pDynVar = m_pObject->GetAttribute("Filename");
							if (pDynVar)
								sName = "Filename = \"" + pDynVar->GetString() + '\"';	// Put it into quotes to make it possible to see e.g. trailing spaces
						}
					}

					// Use the name, if we have one
					if (sName.GetLength()) {
						// We have a representable name, show it to the user
						sQStringWindowTitle += ": ";
						sQStringWindowTitle += QtStringAdapter::PLToQt(sName);
					}
				}
				pQDockWidget->setWindowTitle(sQStringWindowTitle);
			}
		}
	}
}
Esempio n. 29
0
bool MainWindowImpl::loadFile( QFileInfo const & fi )
{
    if( ! fi.isFile() ) return false;
	// FIXME: this dispatch needs to be generalized.
	QString fn( fi.filePath() ); // fi.absoluteFilePath() );
	bool worked = false;
	if( impl->gstate.board().fileNameMatches(fn) )
	{
		worked = impl->gstate.board().s11nLoad(fn);
	}
	else if( impl->gstate.fileNameMatches(fn) )
	{
		worked = this->loadGame(fn);
	}
	else if( fn.endsWith(".wiki") )
	{
	    worked = true;
	    QString lbl = QString("Wiki: %1").arg(fi.fileName());
	    QDockWidget * win = new QDockWidget( lbl, this );
	    qboard::WikiLiteView * v = new qboard::WikiLiteView;
	    win->setAttribute(Qt::WA_DeleteOnClose);
	    win->setWidget( v );
	    win->move( impl->gv->viewport()->mapToGlobal(QPoint(0,0)) );
	    win->resize( impl->gv->viewport()->size() );
	    win->setFloating(true);
	    this->addDockWidget(Qt::RightDockWidgetArea, win );
	    v->parseFile(fn);
	    win->setWindowTitle( v->windowTitle() );
	}
	else if( QRegExp("\\.[jq]s$",Qt::CaseInsensitive).indexIn(fn) > 0 )
	{
	    QScriptEngine & js( impl->gstate.jsEngine() );
	    qDebug() << "[ running script"<<fn<<"]";
	    QScriptValue rv = qboard::jsInclude( &js, fn );
	    if( rv.isError() )
	    {
		QStringList bt( js.uncaughtExceptionBacktrace() );
		QScriptValue exv = rv.isError() ? rv : js.uncaughtException();
		QString msg("Script threw or returned an exception:\n");
		msg += exv.toString()
		    + "\nBacktrace:\n"
		    + bt.join("\n");
		QMessageBox::warning( this, "JavaScript Exception",
				      msg,
				      QMessageBox::Ok, QMessageBox::Ok );
		worked = false;
	    }
	    else
	    {
		worked = true;
	    }
	    qDebug() << "[ done running script"<<fn<<"]";
	}
	else if( QRegExp("\\.(html|txt)$",Qt::CaseInsensitive).indexIn(fn) > 0 )
	{
#if QT_VERSION >= 0x040400
		QBoardDocsBrowser * b = new QBoardDocsBrowser;
		b->setHome(fn);
		b->setWindowTitle(fn);
		b->show();
		worked = true;
#else
		QMessageBox::warning( this, "Not implemented!",
				      "MainWindowImpl::loadFile(*.{txt,html}) not implemented for Qt < 4.4",
				      QMessageBox::Ok, QMessageBox::Ok );
		worked = false;
#endif
	}
	else if( QRegExp("\\.(png|jpg|gif|xpm|svg|bmp)$",Qt::CaseInsensitive).indexIn(fn) > 0 )
	{ // ^^^ FIXME: get the list of image formats from somewhere dynamic
		const size_t threshold = 10 * 1024;
		// ^^^ fixme: ^^^^ do this based on image resolution, not file size, cuz many
		// large-sized PNGs are quite small.
		if( fi.size() < threshold )
		{
			worked = this->loadPiece(fi);
		}
		else
		{
			worked = this->impl->gstate.board().s11nLoad(fn); // fi.absoluteFilePath());
		}
	}
	if( worked )
	{
		this->statusBar()->showMessage("Loaded: "+fn); // fi.absoluteFilePath());
	}
	else
	{
		this->statusBar()->showMessage("Load FAILED: "+fn); // fi.absoluteFilePath());
	}
	return worked;
}
Esempio n. 30
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), bonjourResolver(0)
{
    qDebug() << "NUview is starting in: MainWindow.cpp";
    debug.open("debug.log");
    errorlog.open("error.log");

    m_platform = new NUPlatform();                      // you could make the arguement that NUView should have its own platform, for now we just use a 'blank' one
    m_blackboard = new NUBlackboard();
    m_blackboard->add(new NUSensorsData());
    m_blackboard->add(new NUActionatorsData());
    m_blackboard->add(new FieldObjects());
    m_blackboard->add(new JobList());
    m_blackboard->add(new GameInformation(0, 0));
    m_blackboard->add(new TeamInformation(0, 0));
    
    m_nuview_io = new NUviewIO();

    // create mdi workspace
    mdiArea = new QMdiArea(this);
    mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

    createActions();
    createMenus();
    createContextMenu();
    createToolBars();
    createStatusBar();

    sensorDisplay = new SensorDisplayWidget(this);
    QDockWidget* sensorDock = new QDockWidget("Sensor Values");
    sensorDock->setObjectName("Sensor Values");
    sensorDock->setWidget(sensorDisplay);
    sensorDock->setShown(false);
    addDockWidget(Qt::RightDockWidgetArea,sensorDock);

    // Add localisation widget
    localisation = new LocalisationWidget(this);
    addDockWidget(Qt::BottomDockWidgetArea,localisation);
    localisation->setVisible(false);

    // Add Vision Widgets to Tab then Dock them on Screen
    visionTabs = new QTabWidget(this);
    layerSelection = new LayerSelectionWidget(mdiArea,this);
    visionTabs->addTab(layerSelection,layerSelection->objectName());
    classification = new ClassificationWidget(this);
    visionTabs->addTab(classification,classification->objectName());
    visionTabDock = new QDockWidget("Vision");
    visionTabDock->setWidget(visionTabs);
    visionTabDock->setObjectName(tr("visionTab"));
    addDockWidget(Qt::RightDockWidgetArea, visionTabDock);
    
    // Add Network widgets to Tabs then dock them on Screen
    networkTabs = new QTabWidget(this);
    connection = new ConnectionWidget(this);
    networkTabs->addTab(connection, connection->objectName());
    walkParameter = new WalkParameterWidget(mdiArea, this);
    kick = new KickWidget(mdiArea, this);
    networkTabs->addTab(walkParameter, walkParameter->objectName());
    networkTabs->addTab(kick, kick->objectName());
    VisionStreamer = new visionStreamWidget(mdiArea, this);
    LocWmStreamer = new locwmStreamWidget(mdiArea, this);
    networkTabs->addTab(VisionStreamer, VisionStreamer->objectName());
    networkTabs->addTab(LocWmStreamer, LocWmStreamer->objectName());
    cameraSetting = new cameraSettingsWidget(mdiArea, this);
    networkTabs->addTab(cameraSetting, cameraSetting->objectName());

    //networkTabs->addTab(kick, kick->objectName());
    networkTabDock = new QDockWidget("Network");
    networkTabDock->setWidget(networkTabs);
    networkTabDock->setObjectName(tr("networkTab"));
    addDockWidget(Qt::RightDockWidgetArea, networkTabDock);

    frameInfo = new frameInformationWidget(this);
    QDockWidget* temp = new QDockWidget(this);
    temp->setWidget(frameInfo);
    temp->setObjectName("Frame Information Dock");
    temp->setWindowTitle(frameInfo->windowTitle());
    addDockWidget(Qt::RightDockWidgetArea,temp);

    createConnections();
    setCentralWidget(mdiArea);
    qDebug() << "Main Window Starting";
    setWindowTitle(QString("NUview"));
    glManager.clearAllDisplays();
    qDebug() << "Display Cleared";
    readSettings();
    qDebug() << "Main Window Started";

    //glManager.writeWMBallToDisplay(100,100,30,GLDisplay::CalGrid);
    glManager.writeCalGridToDisplay(GLDisplay::CalGrid);
    //
    //glManager.writeCalGridToDisplay(GLDisplay::CalGrid);
    //
}