Exemple #1
0
void PixelWidget::keyPressEvent(QKeyEvent *e)
{
    switch (e->key()) {
    case Qt::Key_Plus:
        increaseZoom();
        break;
    case Qt::Key_Minus:
        decreaseZoom();
        break;
    case Qt::Key_PageUp:
        setGridSize(m_gridSize + 1);
        break;
    case Qt::Key_PageDown:
        setGridSize(m_gridSize - 1);
        break;
    case Qt::Key_G:
        toggleGrid();
        break;
    case Qt::Key_C:
        if (e->modifiers() & Qt::ControlModifier)
            copyToClipboard();
        break;
    case Qt::Key_S:
        if (e->modifiers() & Qt::ControlModifier) {
            releaseKeyboard();
            saveToFile();
        }
        break;
    case Qt::Key_Control:
        grabKeyboard();
        break;
    }
}
Exemple #2
0
void BiomeView::keyPressEvent(QKeyEvent * a_Event)
{
	switch (a_Event->key())
	{
		case Qt::Key_Up:
		case Qt::Key_W:
		{
			m_Z -= 10.0 / m_Zoom;
			redraw();
			break;
		}

		case Qt::Key_Down:
		case Qt::Key_S:
		{
			m_Z += 10.0 / m_Zoom;
			redraw();
			break;
		}

		case Qt::Key_Left:
		case Qt::Key_A:
		{
			m_X -= 10.0 / m_Zoom;
			redraw();
			break;
		}

		case Qt::Key_Right:
		case Qt::Key_D:
		{
			m_X += 10.0 / m_Zoom;
			redraw();
			break;
		}

		case Qt::Key_PageUp:
		case Qt::Key_Q:
		{
			emit increaseZoom();
			break;
		}

		case Qt::Key_PageDown:
		case Qt::Key_E:
		{
			emit decreaseZoom();
			break;
		}
	}
}
Exemple #3
0
MainWindow::MainWindow(QWidget * parent) :
	QMainWindow(parent),
	m_GeneratorSetup(nullptr),
	m_LineSeparator(nullptr),
	m_CurrentZoomLevel(2)
{
	initMinecraftPath();

	m_BiomeView = new BiomeView();
	connect(m_BiomeView, SIGNAL(increaseZoom()), this, SLOT(increaseZoom()));
	connect(m_BiomeView, SIGNAL(decreaseZoom()), this, SLOT(decreaseZoom()));
	connect(m_BiomeView, SIGNAL(wheelUp()),      this, SLOT(increaseZoom()));
	connect(m_BiomeView, SIGNAL(wheelDown()),    this, SLOT(decreaseZoom()));
	m_BiomeView->setZoomLevel(m_ViewZooms[m_CurrentZoomLevel]);

	m_StatusBar = new QStatusBar();
	this->setStatusBar(m_StatusBar);
	m_StatusBlockX = new QLabel(tr("X"));
	m_StatusBlockZ = new QLabel(tr("Z"));
	m_StatusBiome = new QLabel(tr("B"));
	m_StatusBar->addPermanentWidget(m_StatusBlockX);
	m_StatusBar->addPermanentWidget(m_StatusBlockZ);
	m_StatusBar->addPermanentWidget(m_StatusBiome);

	m_MainLayout = new QHBoxLayout();
	m_MainLayout->addWidget(m_BiomeView, 1);
	m_MainLayout->setMenuBar(menuBar());
	m_MainLayout->setMargin(0);
	QWidget * central = new QWidget();
	central->setLayout(m_MainLayout);
	setCentralWidget(central);

	createActions();
	createMenus();

	connect(m_BiomeView, SIGNAL(hoverChanged(int, int, int)), this, SLOT(hoverChanged(int, int, int)));
}
Exemple #4
0
void PixelWidget::contextMenuEvent(QContextMenuEvent *e)
{
    QMenu menu;

    QAction title(QLatin1String("Surface Pixel Tool"), &menu);
    title.setEnabled(false);

    // Grid color options...
    QActionGroup gridGroup(this);
    QAction whiteGrid(QLatin1String("White grid"), &gridGroup);
    whiteGrid.setCheckable(true);
    whiteGrid.setChecked(m_gridActive == 2);
    whiteGrid.setShortcut(QKeySequence(Qt::Key_G));
    QAction blackGrid(QLatin1String("Black grid"), &gridGroup);
    blackGrid.setCheckable(true);
    blackGrid.setChecked(m_gridActive == 1);
    blackGrid.setShortcut(QKeySequence(Qt::Key_G));
    QAction noGrid(QLatin1String("No grid"), &gridGroup);
    noGrid.setCheckable(true);
    noGrid.setChecked(m_gridActive == 0);
    noGrid.setShortcut(QKeySequence(Qt::Key_G));

    // Grid size options
    QAction incrGrid(QLatin1String("Increase grid size"), &menu);
    incrGrid.setShortcut(QKeySequence(Qt::Key_PageUp));
    connect(&incrGrid, SIGNAL(triggered()), this, SLOT(increaseGridSize()));
    QAction decrGrid(QLatin1String("Decrease grid size"), &menu);
    decrGrid.setShortcut(QKeySequence(Qt::Key_PageDown));
    connect(&decrGrid, SIGNAL(triggered()), this, SLOT(decreaseGridSize()));

    // Zoom options
    QAction incrZoom(QLatin1String("Zoom in"), &menu);
    incrZoom.setShortcut(QKeySequence(Qt::Key_Plus));
    connect(&incrZoom, SIGNAL(triggered()), this, SLOT(increaseZoom()));
    QAction decrZoom(QLatin1String("Zoom out"), &menu);
    decrZoom.setShortcut(QKeySequence(Qt::Key_Minus));
    connect(&decrZoom, SIGNAL(triggered()), this, SLOT(decreaseZoom()));

    // Copy to clipboard / save
    QAction save(QLatin1String("Save as image"), &menu);
    save.setShortcut(QKeySequence(QLatin1String("Ctrl+S")));
    connect(&save, SIGNAL(triggered()), this, SLOT(saveToFile()));
#ifndef QT_NO_CLIPBOARD
    QAction copy(QLatin1String("Copy to clipboard"), &menu);
    copy.setShortcut(QKeySequence(QLatin1String("Ctrl+C")));
    connect(&copy, SIGNAL(triggered()), this, SLOT(copyToClipboard()));
#endif

    menu.addAction(&title);
    menu.addSeparator();
    menu.addAction(&whiteGrid);
    menu.addAction(&blackGrid);
    menu.addAction(&noGrid);
    menu.addSeparator();
    menu.addAction(&incrGrid);
    menu.addAction(&decrGrid);
    menu.addSeparator();
    menu.addAction(&incrZoom);
    menu.addAction(&decrZoom);
    menu.addSeparator();
    menu.addAction(&save);
#ifndef QT_NO_CLIPBOARD
    menu.addAction(&copy);
#endif

    menu.exec(mapToGlobal(e->pos()));

    if (noGrid.isChecked()) m_gridActive = 0;
    else if (blackGrid.isChecked()) m_gridActive = 1;
    else m_gridActive = 2;
}
Exemple #5
0
    container.indexes = callerAsList;
    foreach( int Column, sortingColumns )
    {
        action = sortingMenu->addAction( qfu( psz_column_title( Column ) ) + " " + qtr("Ascending") );
        container.column = model->columnFromMeta(Column) + 1;
        action->setData( QVariant::fromValue( container ) );

        action = sortingMenu->addAction( qfu( psz_column_title( Column ) ) + " " + qtr("Descending") );
        container.column = -1 * (model->columnFromMeta(Column)+1);
        action->setData( QVariant::fromValue( container ) );
    }
    menu.addMenu( sortingMenu );

    /* Zoom */
    QMenu *zoomMenu = new QMenu( qtr( "Display size" ) );
    zoomMenu->addAction( qtr( "Increase" ), this, SLOT( increaseZoom() ) );
    zoomMenu->addAction( qtr( "Decrease" ), this, SLOT( decreaseZoom() ) );
    menu.addMenu( zoomMenu );

    CONNECT( &menu, triggered( QAction * ), model, actionSlot( QAction * ) );

    menu.addMenu( StandardPLPanel::viewSelectionMenu( this ) );

    /* Display and forward the result */
    if( !menu.isEmpty() )
    {
        menu.exec( point ); return true;
    }
    else return false;

#undef ADD_MENU_ENTRY