Ejemplo n.º 1
0
/**
 * Positions child widgets into their docking stations, and performs some
 * other main window initialisation.
 */
void KScope::initMainWindow()
{
	KStatusBar* pStatus;
	KDockWidget* pMainDock;
	QPopupMenu* pPopup;
	
	// Create the status bar
	pStatus = statusBar();
	pStatus->insertItem(i18n(" Line: N/A Col: N/A "), 0, 0, true);

	// Create the main dock for the editor tabs widget
	pMainDock = createDockWidget("Editors Window", QPixmap());
	pMainDock->setWidget(m_pEditTabs);
	pMainDock->setDockSite(KDockWidget::DockCorner);
	setMainDockWidget(pMainDock);
	setView(pMainDock);
	pMainDock->setEnableDocking(KDockWidget::DockNone);

	// Create the query window dock
	m_pQueryDock->setWidget(m_pQueryWidget);
	m_pQueryDock->manualDock(pMainDock, KDockWidget::DockBottom, 65);

	// Update the relevant shell action when the dock is hidden through its
	// close button
	connect(m_pQueryDock, SIGNAL(headerCloseButtonClicked()), m_pActions,
		SLOT(slotQueryDockClosed()));
		
	// Create the file view dock
	m_pFileViewDock->setWidget(m_pFileView);
	m_pFileViewDock->manualDock(pMainDock, KDockWidget::DockRight, 80);
	
	// Update the relevant shell action when the dock is hidden through its
	// close button
	connect(m_pFileViewDock, SIGNAL(headerCloseButtonClicked()), m_pActions,
		SLOT(slotFileViewDockClosed()));
	
	// Associate the "Window" menu with the editor tabs widdget
	pPopup = (QPopupMenu*)factory()->container("window", this);
	m_pEditTabs->setWindowMenu(pPopup);

	// Associate the "Query" popup menu with the query widget
	pPopup = (QPopupMenu*)factory()->container("query_popup", this);
	m_pQueryWidget->setPageMenu(pPopup, m_pActions->getLockAction());
	
	// Restore dock configuration
	Config().loadWorkspace(this);
	m_bHideQueryOnSelection = m_pQueryDock->isHidden();
	m_pActions->initLayoutActions();
}
Ejemplo n.º 2
0
void MyFracWindow::createWidgets()
{
	KDockWidget* dockMain = createDockWidget("main", NULL);
	_tabWidget = new QTabWidget(dockMain);
	dockMain->setWidget(_tabWidget);

	_view2D = new ViewWidget(true, _tabWidget);
	_tabWidget->addTab(_view2D, SmallIconSet("frtab2d"), i18n("2D View"));

	_view3D = new View3DWidget(_tabWidget);
	_tabWidget->addTab(_view3D, SmallIconSet("frtab3d"), i18n("3D View"));

	_dockParams = createDockWidget("params", SmallIcon("frparams"), NULL,
		i18n("Parameters"));
	QWidget* params = createParamsDock(_dockParams);
	_dockParams->setWidget(params);

	_dockDisplay = createDockWidget("display", SmallIcon("frdisplay"), NULL,
		i18n("Display"));
	QWidget* display = createDisplayDock(_dockParams);
	_dockDisplay->setWidget(display);

	_dockPreview = createDockWidget("preview", SmallIcon("viewmag"), NULL, i18n("Preview"));
	ViewWidget* preview = new ViewWidget(false, _dockPreview);
	_dockPreview->setWidget(preview);

	dockMain->setDockSite(KDockWidget::DockCorner);
	dockMain->setEnableDocking(KDockWidget::DockNone);
	setView(dockMain);
	setMainDockWidget(dockMain);

	KDockWidget* dock1 = _dockDisplay->manualDock(_dockParams, KDockWidget::DockCenter);
	KDockWidget* dock2 = _dockPreview->manualDock(dock1, KDockWidget::DockBottom, 65);
	dock2->manualDock(dockMain, KDockWidget::DockRight, 65);

	connect(_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged()));

	connect(this, SIGNAL(view2DEnabled(bool)), _view2D, SLOT(setVisible(bool)));
	connect(this, SIGNAL(view3DEnabled(bool)), _view3D, SLOT(setVisible(bool)));
	connect(this, SIGNAL(previewEnabled(bool)), _view2D, SLOT(enablePreview(bool)));

	connect(this, SIGNAL(positionChanged(double, double, double, double)), _view2D, SLOT(setPosition(double, double, double, double)));
	connect(this, SIGNAL(positionChanged(double, double, double, double)), _view3D, SLOT(setPosition(double, double, double, double)));
	connect(this, SIGNAL(positionChanged(double, double, double, double)), preview, SLOT(setPreviewPosition(double, double, double, double)));

	connect(this, SIGNAL(modeChangedMandelbrot()), _view2D, SLOT(setMandelbrotMode()));
	connect(this, SIGNAL(modeChangedMandelbrot()), _view3D, SLOT(setMandelbrotMode()));
	connect(this, SIGNAL(modeChangedJulia(double, double)), _view2D, SLOT(setJuliaMode(double, double)));
	connect(this, SIGNAL(modeChangedJulia(double, double)), _view3D, SLOT(setJuliaMode(double, double)));

	connect(this, SIGNAL(precisionChanged(double, double)), _view2D, SLOT(setQuality(double, double)));
	connect(this, SIGNAL(precisionChanged(double, double)), _view3D, SLOT(setQuality(double, double)));
	connect(this, SIGNAL(precisionChanged(double, double)), preview, SLOT(setQuality(double, double)));

	connect(this, SIGNAL(backgroundChanged(QRgb)), _view2D, SLOT(setBackground(QRgb)));
	connect(this, SIGNAL(backgroundChanged(QRgb)), _view3D, SLOT(setBackground(QRgb)));
	connect(this, SIGNAL(backgroundChanged(QRgb)), preview, SLOT(setBackground(QRgb)));

	connect(this, SIGNAL(gradientChanged(const QRgb*, double, double)), _view2D, SLOT(setGradient(const QRgb*, double, double)));
	connect(this, SIGNAL(gradientChanged(const QRgb*, double, double)), _view3D, SLOT(setGradient(const QRgb*, double, double)));
	connect(this, SIGNAL(gradientChanged(const QRgb*, double, double)), preview, SLOT(setGradient(const QRgb*, double, double)));

	connect(_view2D, SIGNAL(previewVisible(bool)), preview, SLOT(setVisible(bool)));
	connect(_view2D, SIGNAL(previewPosition(double, double)), preview, SLOT(setJuliaMode(double, double)));

	connect(_view2D, SIGNAL(positionChanged(double, double, double, double)), this, SLOT(setPosition(double, double, double, double)));
	connect(_view2D, SIGNAL(previewDoubleClick(double, double)), this, SLOT(setJuliaMode(double, double)));

	connect(this, SIGNAL(gridSizeChanged(int, int)), _view3D, SLOT(setGridSize(int, int)));
	connect(this, SIGNAL(heightScaleChanged(double)), _view3D, SLOT(setHeightScale(double)));

	_view2D->enableTransform(true);

	KStatusBar* status = statusBar();
	status->setSizeGripEnabled(false);

	QProgressBar* progress = new QProgressBar(100, status);
	progress->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	progress->setMaximumHeight(status->sizeHint().height() - 2);
	progress->setMinimumWidth(120);
	progress->setProgress(100);
	status->addWidget(progress, 0, true);

	connect(_view2D, SIGNAL(updateProgress(int)), progress, SLOT(setProgress(int)));
	connect(_view3D, SIGNAL(updateProgress(int)), progress, SLOT(setProgress(int)));
}