Beispiel #1
0
void JKGStudio::onPaste()
{
	if (!activeSubWindow())
		return;

	activeSubWindow()->paste();
}
Beispiel #2
0
void JKGStudio::onExtCommand(int cmd)
{
	if (!activeSubWindow())
		return;

	activeSubWindow()->extCommand((MdiSubBase::eMdiExtCommands)cmd);
}
Beispiel #3
0
void JKGStudio::onRedo()
{
	if (!activeSubWindow())
		return;

	activeSubWindow()->redo();
}
Beispiel #4
0
void JKGStudio::onCopy()
{
	if (!activeSubWindow())
		return;

	activeSubWindow()->copy();
}
Beispiel #5
0
void JKGStudio::onSaveAs()
{
	if (!activeSubWindow())
		return;

	activeSubWindow()->saveas();
}
Beispiel #6
0
void MyMdiArea::addSubWindow(MyMdiSubWindow* window)
{
	Q_ASSERT(subWindows_.contains(window) == false);

	currentWidget_->hide();
	layout_->removeWidget(currentWidget_);

	layout_->addWidget(window);
	window->show();
	currentWidget_ = window;

	bool blocked = tabBar_->blockSignals(true);
	tabBar_->addTab(tabText(window));
	tabBar_->setCurrentIndex(tabBar_->count() - 1);
	tabBar_->blockSignals(blocked);

	QWidget* left = tabBar_->tabButton(tabBar_->count() - 1, QTabBar::LeftSide);
	QWidget* right = tabBar_->tabButton(tabBar_->count() - 1, QTabBar::RightSide);

	subWindows_.append(window);

	connect(window, SIGNAL(windowTitleChanged(const QString&)), this, SLOT(onWindowModified()));
	connect(window, SIGNAL(modifiedChanged(bool)), this, SLOT(onWindowModified()));
	connect(window, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));

	emit subWindowActivated(activeSubWindow());
}
Beispiel #7
0
void JKGStudio::onSubWindowActivated()
{
	if (!activeSubWindow())
	{
		ui.actionSave->setEnabled(false);
		ui.actionSave_As->setEnabled(false);
		ui.actionUndo->setEnabled(false);
		ui.actionRedo->setEnabled(false);
		ui.actionCut->setEnabled(false);
		ui.actionCopy->setEnabled(false);
		ui.actionPaste->setEnabled(false);
		ui.actionCompile->setEnabled(false);

		ui.menuDlgNodes->menuAction()->setVisible(false);

		m_propmanager->setActiveOwner(NULL);
		m_propmanager->setActiveWindow(NULL);
		m_propbrowser->setEnabled(false);

		m_undoview->setStack(NULL);
		m_undoview->setEnabled(false);

		
		return;
	}

	switch (activeSubWindow()->mdiWindowType())
	{
		case MdiSubBase::LuaEditor:
			ui.menuDlgNodes->menuAction()->setVisible(false);
			break;
		case MdiSubBase::DlgEditor:
			ui.menuDlgNodes->menuAction()->setVisible(true);
			break;
		case MdiSubBase::QuestEditor:
			ui.menuDlgNodes->menuAction()->setVisible(false);
			break;
		default:
			ui.menuDlgNodes->menuAction()->setVisible(false);
			break;
	}

	m_propmanager->setActiveWindow(activeSubWindow());
	m_propbrowser->setEnabled(true);

	activeSubWindow()->updateMdi();
}
TEST(LuaUIOperationsTest, Rotate) {
	QApplication app(argc, argv);
	LuaInterface luaInterface;
	auto L = luaInterface.luaState();

	luaInterface.hideUI(true);
	luaInterface.initLua();

	auto mdiArea = LuaIntf::Lua::getGlobal<QMdiArea*>(L, "mdiArea");

	if(mdiArea->subWindowList().count() == 0) {
		LuaIntf::LuaRef(L, "new_file")();
	}

	mdiArea->setActiveSubWindow(mdiArea->subWindowList().at(0));

	auto mdiChild = dynamic_cast<CadMdiChild*>(mdiArea->activeSubWindow()->widget());
	auto storageManager = mdiChild->storageManager();
	auto documentCanvas = mdiChild->viewer()->documentCanvas();

	lc::entity::Line_CSPtr createdEntity;
	std::vector<lc::entity::CADEntity_CSPtr> entities;

	entities = storageManager->entityContainer().asVector();

	for(auto entity : entities) {
		storageManager->removeEntity(entity);
	}

	EXPECT_EQ(0, storageManager->entityContainer().asVector().size());



	LuaIntf::LuaRef(L, "create_line")();
	LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(0, 0));
	LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(100, 100));

	EXPECT_EQ(1, storageManager->entityContainer().asVector().size()) << "Line was not created";



	documentCanvas->makeSelection(0, 0, 100, 100, false, false);
	documentCanvas->closeSelection();

	EXPECT_EQ(1, mdiChild->selection().size()) << "Entity not selected";



	LuaIntf::LuaRef(L, "rotate_selected_entities")();
	LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(0, 0));
	LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(0, 100));
	LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(100, 0));

	entities = storageManager->entityContainer().asVector();
	createdEntity = std::dynamic_pointer_cast<const lc::entity::Line>(entities.at(0));

	EXPECT_EQ(lc::geo::Coordinate(0, 0), createdEntity->start());
	EXPECT_EQ(lc::geo::Coordinate(100, -100), createdEntity->end());
}
Beispiel #9
0
void MyMdiArea::onCurrentChanged(int index)
{
	currentWidget_->hide();
	layout_->removeWidget(currentWidget_);

	currentWidget_ = subWindows_[index];
	layout_->addWidget(currentWidget_);
	currentWidget_->show();

	emit subWindowActivated(activeSubWindow());
}
Beispiel #10
0
QMdiSubWindow * CMDIArea::addSubWindow(QWidget * widget,
                                       Qt::WindowFlags windowFlags)
{
    QMdiSubWindow * const subWindow = QMdiArea::addSubWindow(widget, windowFlags);
    subWindow->installEventFilter(this);
    fixSystemMenu(subWindow);

    // Manual arrangement mode
    enableWindowMinMaxFlags(true);
    if (m_mdiArrangementMode == ArrangementModeManual) {
        // Note that the window size/maximization may be changed later by a session restore.
        // If we already have an active window, make the new one simular to it
        if (activeSubWindow()) {
            if (activeSubWindow()->isMaximized()) {
                subWindow->showMaximized(); // Maximize the new window
            } else {
                // Make new window the same size as the active window and move it slightly.
                subWindow->resize(activeSubWindow()->size());
                QRect subWinGeom = activeSubWindow()->geometry();
                static const int MOVESIZE = 30;
                subWinGeom.translate(MOVESIZE, MOVESIZE);
                // If it goes off screen, move it almost to the top left
                if (!frameRect().contains(subWinGeom))
                    subWinGeom.moveTo(MOVESIZE, MOVESIZE);
                subWindow->setGeometry(subWinGeom);
            }
        } else {
            //set the window to be big enough
            subWindow->resize(400, 400);
        }
        subWindow->raise();
    } else {
        // Automatic arrangement modes
        enableWindowMinMaxFlags(false);
        triggerWindowUpdate();
    }
    return subWindow;
}
Beispiel #11
0
void MyMdiArea::removeFromTab(MyMdiSubWindow* window)
{
	int index = subWindows_.indexOf(window);

	if (index >= 0)
	{
		subWindows_.removeAt(index);

		bool blocked = tabBar_->blockSignals(true);
		tabBar_->removeTab(index);
		tabBar_->blockSignals(blocked);

		layout_->removeWidget(window);

		currentWidget_ = (tabBar_->count() == 0) ? emptyWidget_ : subWindows_[tabBar_->currentIndex()];
		layout_->addWidget(currentWidget_);
		currentWidget_->show();

		emit subWindowActivated(activeSubWindow());
	}
}
Beispiel #12
0
void KviMdiManager::tileAllInternal(int maxWnds, bool bHorizontal) //int maxWnds,bool bHorizontal
{

	//NUM WINDOWS =           1,2,3,4,5,6,7,8,9
	static int colstable[9]={ 1,1,1,2,2,2,3,3,3 }; //num columns
	static int rowstable[9]={ 1,2,3,2,3,3,3,3,3 }; //num rows
	static int lastwindw[9]={ 1,1,1,1,2,1,3,2,1 }; //last window multiplier
	static int colrecall[9]={ 0,0,0,3,3,3,6,6,6 }; //adjust self
	static int rowrecall[9]={ 0,0,0,0,4,4,4,4,4 }; //adjust self

	int * pColstable = bHorizontal ? colstable : rowstable;
	int * pRowstable = bHorizontal ? rowstable : colstable;
	int * pColrecall = bHorizontal ? colrecall : rowrecall;
	int * pRowrecall = bHorizontal ? rowrecall : colrecall;

	if (g_pApp->kviClosingDown()) return;

	m_bInSDIMode=false;
	ensureNoMaximized();

	KviMdiChild * lpTop = (KviMdiChild*)activeSubWindow();
	if (!lpTop) return;

	int numVisible = getVisibleChildCount();

	if (numVisible < 1) return;

	int numToHandle = ((numVisible > maxWnds) ? maxWnds : numVisible);
	int xQuantum = viewport()->width() / pColstable[numToHandle-1];

	if(xQuantum < ((lpTop->minimumSize().width() > KVI_MDICHILD_MIN_WIDTH) ? lpTop->minimumSize().width() : KVI_MDICHILD_MIN_WIDTH))
	{
		if (pColrecall[numToHandle-1] == 0) qDebug("Tile : Not enouh space");
			else tileAllInternal(pColrecall[numToHandle-1], bHorizontal);
		return;
	}

	int yQuantum = viewport()->height() / pRowstable[numToHandle-1];

	if(yQuantum < ((lpTop->minimumSize().height() > KVI_MDICHILD_MIN_HEIGHT) ? lpTop->minimumSize().height() : KVI_MDICHILD_MIN_HEIGHT))
	{
		if (pRowrecall[numToHandle-1] == 0) qDebug("Tile : Not enough space");
			else tileAllInternal(pRowrecall[numToHandle-1], bHorizontal);
		return;
	}

	int curX = 0;
	int curY = 0;
	int curRow = 1;
	int curCol = 1;
	int curWin = 1;

	QList<QMdiSubWindow *> tmp = subWindowList(QMdiArea::StackingOrder);

	for(int i = 0; i < tmp.count(); i++)
	{
		KviMdiChild * lpC = (KviMdiChild*) tmp.at(i);

		if(lpC->state()!=KviMdiChild::Minimized)
		{
			if((curWin%numToHandle)==0)
			{
				lpC->move(curX, curY);
				lpC->resize(xQuantum * lastwindw[numToHandle-1], yQuantum);
			} else {
				lpC->move(curX, curY);
				lpC->resize(xQuantum, yQuantum);
			}
			//example : 12 windows : 3 cols 3 rows
			if (curCol < pColstable[numToHandle-1])
			{ //curCol < 3
				curX += xQuantum; //add a column in the same row
				curCol++;       //increase current column
			} else {
				curX = 0;         //new row
				curCol = 1;       //column 1
				if (curRow < pRowstable[numToHandle-1])
				{ //curRow < 3
					curY += yQuantum; //add a row
					curRow++;
				} else {
					curY = 0;         //restart from beginning
					curRow = 1;
				}
			}
			curWin++;
		}
	}
	if(lpTop)lpTop->setFocus();
}
QWidget* CWindowStack::currentSubWindow()
{
    return activeSubWindow();
}
QWidget* CWindowStack::closeActiveSubWindow()
{
    closeSubWindow(activeSubWindow());
}