Exemplo n.º 1
0
void ReportDialog::doShowReport()
{
    logMessage("ReportDialog::doShowReport()");

    QDir(tempProblemDir()).mkdir("report");

    QFile::remove(QString("%1/report/template.html").arg(tempProblemDir()));
    QFile::remove(QString("%1/report/style.css").arg(tempProblemDir()));
    bool fileTemplateOK = QFile::copy(QString(txtTemplate->text()),
                                      QString("%1/report/template.html").arg(tempProblemDir()));
    bool fileStyleOK = QFile::copy(QString(txtStyleSheet->text()),
                                      QString("%1/report/style.css").arg(tempProblemDir()));
    if (!fileTemplateOK)
        QMessageBox::critical(QApplication::activeWindow(), tr("Error"), tr("Report template could not be copied."));
    else if (!fileStyleOK)
        QMessageBox::critical(QApplication::activeWindow(), tr("Error"), tr("Template style could not be copied."));
    else
    {
        generateFigures();
        generateIndex();

        QDesktopServices::openUrl(QUrl::fromLocalFile(tempProblemDir() + "/report/report.html"));
    }
}
Exemplo n.º 2
0
SakuraMatrix::SakuraMatrix(MainWindow *pParentComponent) :
	_x_root_cell(0),
	_y_root_cell(0),
	_infiniteMode(false),
	_infiniteMode_current(false),
	_solved(false),
	_peekMode(false),
	_autoShuffle(true),
	_autoShuffle_Milliseconds(5000),
	_settingsPanelWidth(250),
	_settingsVisible(false),
	_swapMouseButtonsDirections(false),
	_swapMouseWheelDirections(false),
	_keyboardSupport(false),
	_x_focus(0),
	_y_focus(0),
	_pBackImage(nullptr),
	_pParentComponent(pParentComponent),
	_pStatusBar(nullptr),
	_iStatusBarHeight(48),
	_numberOfCellsX(7),
	_numberOfCellsY(6),
	_cellSize(48),
	_relaxMatrix(.1f),
	_decor_side_right(nullptr),
	_decor_side_left(nullptr),
	_decor_side_bottom(nullptr),
	_decor_conner_left(nullptr),
	_decor_conner_right(nullptr),
	_decor_conner_left_top(nullptr),
	_decor_conner_right_top(nullptr),
	_decor_butterfly_left(nullptr),
	_decor_title(nullptr),
	_tempWidthInCells(_numberOfCellsX),
	_tempHeightInCells(_numberOfCellsY),
	_tempCellSize(_cellSize),
	_pSettingsPanel(nullptr),
	_pWidthInCellsProperty(nullptr),
	_pHeightInCellsProperty(nullptr),
	_pCellSizeProperty(nullptr),
	_pInfiniteModeProperty(nullptr),
	_pAutoShuffleModeProperty(nullptr),
	_pAutoShuffleMillisecondsProperty(nullptr),
	_pKeyboardSupportProperty(nullptr),
	_pKeyMappingsProperty(nullptr)
{
	std::srand(std::time(nullptr));

	if(!__delta.size())
	{
		__delta.resize(4);
		__delta[int(Direction::Left)] = std::pair<int, int>(-1, 0);
		__delta[int(Direction::Top)] = std::pair<int, int>(0, -1);
		__delta[int(Direction::Right)] = std::pair<int, int>(1, 0);
		__delta[int(Direction::Bottom)] = std::pair<int, int>(0, 1);
	}

	if(!MainWindow::__pCommandManager)
	{
		MainWindow::__pCommandManager = new ApplicationCommandManager();
		MainWindow::__pCommandManager->registerAllCommandsForTarget(this);
		MainWindow::__pCommandManager->getKeyMappings()->resetToDefaultMappings();

		_pParentComponent->addKeyListener(MainWindow::__pCommandManager->getKeyMappings());
	}

	generateDecor();
	generateFigures();

	addAndMakeVisible(_pStatusBar = new StatusBarComponent(this));

	Array<PropertyComponent*> sizeProperties;
	sizeProperties.add(_pWidthInCellsProperty = new IntValueTextPropertyComponent<SakuraMatrix>(T("width in cells"), _tempWidthInCells));
	sizeProperties.add(_pHeightInCellsProperty = new IntValueTextPropertyComponent<SakuraMatrix>(T("height in cells"), _tempHeightInCells));
	sizeProperties.add(_pCellSizeProperty = new IntValueTextPropertyComponent<SakuraMatrix>(T("cell size in pixels"), _tempCellSize));
	sizeProperties.add(_pRebuildMatrixButtonProperty = new ProxyButtonPropertyComponent<SakuraMatrix>(T("apply changes"), T("Resize"), false, this));

	Array<PropertyComponent*> additinalProperties;
	additinalProperties.add(_pInfiniteModeProperty = new BooleanValuePropertyComponent<SakuraMatrix>(T("complexity"), T("infinite mode (torus)"), T("regular mode"), _infiniteMode));
	_pInfiniteModeProperty->setTooltip(T("<regular mode>: confines a branch within the matrix's edges\n\n<ninfinite mode>: the matrix's edges are no more restrictive\n\n(this setting takes effect on the next time you generate a branch)"));
	additinalProperties.add(_pRelaxMarixProperty = new DoubleValueSliderPropertyComponent<SakuraMatrix>(T("relax matrix"), .0f, .7f, .1f, 1.f, _relaxMatrix));
	_pRelaxMarixProperty->setTooltip(T("adds empty cells to the matrix so making a branch more relaxed\n\nthe greater the value the more a branch is relaxed\n\n(be careful with the high values because a branch can appear too relaxed at times :)"));
	additinalProperties.add(_pAutoShuffleModeProperty = new BooleanValuePropertyComponent<SakuraMatrix>(T("shuffle"), T("automatically"), T("manually"), _autoShuffle, this));
	_pAutoShuffleModeProperty->setTooltip(T("<automatically>: shuffles a new generated branch automatically in some time\n\n<manually>: you have to shuffle the matrix manually by pressing an appropriate button"));
	additinalProperties.add(_pAutoShuffleMillisecondsProperty = new IntValueTextPropertyComponent<SakuraMatrix>(T("milliseconds before auto-shuffle"), _autoShuffle_Milliseconds));
	_pAutoShuffleMillisecondsProperty->setEnabled(_autoShuffle);
	_pAutoShuffleMillisecondsProperty->setTooltip(T("it shuffles a branch automatically in a specified time right after a branch is generated"));
	additinalProperties.add(_pSwapMouseButtonsDirectionsProperty = new BooleanValuePropertyComponent<SakuraMatrix>(T("swap mouse buttons"), T("yes"), T("no"), _swapMouseButtonsDirections));
	additinalProperties.add(_pSwapMouseWheelDirectionsProperty = new BooleanValuePropertyComponent<SakuraMatrix>(T("swap mouse wheel directions"), T("yes"), T("no"), _swapMouseWheelDirections));
	additinalProperties.add(_pKeyboardSupportProperty = new BooleanValuePropertyComponent<SakuraMatrix>(T("keyboard"), T("enabled"), T("disabled"), _keyboardSupport, this));
	_pKeyboardSupportProperty->setTooltip(T("enables keyboard support thus letting you move and rotate cells by using keyboard buttons"));

	Array<PropertyComponent*> keymappingsProperties;
	keymappingsProperties.add(_pKeyMappingsProperty = new KeyMappingsPropertyComponent(T("keyboard"), MainWindow::__pCommandManager->getKeyMappings()));

	addAndMakeVisible(_pSettingsPanel = new PropertyPanel());
	_pSettingsPanel->addSection(T("Size properties"), sizeProperties, true);
	_pSettingsPanel->addSection(T("Additinal properties"), additinalProperties, true);
	_pSettingsPanel->addSection(T("Key-mapping properties"), keymappingsProperties, true);

	buildMatrix(_numberOfCellsX, _numberOfCellsY, _cellSize);

	_pParentComponent->centreAroundComponent(0, getWidth(), getHeight());
}