Exemplo n.º 1
0
PictureContent::PictureContent(QGraphicsScene * scene, QGraphicsItem * parent)
    : AbstractContent(scene, parent, false)
    , m_photo(0)
    , m_opaquePhoto(false)
    , m_progress(0)
    , m_netWidth(0)
    , m_netHeight(0)
    , m_netReply(0)
{
    // enable frame text
    setFrameTextEnabled(true);
    setFrameText(tr("..."));

    // add flipping buttons
    ButtonItem * bFlipH = new ButtonItem(ButtonItem::FlipH, Qt::blue, QIcon(":/data/action-flip-horizontal.png"), this);
    bFlipH->setToolTip(tr("Flip horizontally"));
    bFlipH->setFlag(QGraphicsItem::ItemIgnoresTransformations, false);
    connect(bFlipH, SIGNAL(clicked()), this, SIGNAL(flipHorizontally()));
    addButtonItem(bFlipH);

    ButtonItem * bFlipV = new ButtonItem(ButtonItem::FlipV, Qt::blue, QIcon(":/data/action-flip-vertical.png"), this);
    bFlipV->setToolTip(tr("Flip vertically"));
    bFlipV->setFlag(QGraphicsItem::ItemIgnoresTransformations, false);
    addButtonItem(bFlipV);
    connect(bFlipV, SIGNAL(clicked()), this, SIGNAL(flipVertically()));

    /*ButtonItem * bCrop = new ButtonItem(ButtonItem::Control, Qt::blue, QIcon(":/data/action-scale.png"), this);
    bCrop->setToolTip(tr(""));
    bCrop->setFlag(QGraphicsItem::ItemIgnoresTransformations, false);
    addButtonItem(bCrop);
    connect(bCrop, SIGNAL(clicked()), this, SIGNAL(toggleCropMode()));*/
}
bool WebGraphicsContext3DDefaultImpl::readBackFramebuffer(unsigned char* pixels, size_t bufferSize)
{
    if (bufferSize != static_cast<size_t>(4 * width() * height()))
        return false;

    makeContextCurrent();

    // Earlier versions of this code used the GPU to flip the
    // framebuffer vertically before reading it back for compositing
    // via software. This code was quite complicated, used a lot of
    // GPU memory, and didn't provide an obvious speedup. Since this
    // vertical flip is only a temporary solution anyway until Chrome
    // is fully GPU composited, it wasn't worth the complexity.

    bool mustRestoreFBO = false;
    if (m_attributes.antialias) {
        glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
        glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
        glBlitFramebufferEXT(0, 0, m_cachedWidth, m_cachedHeight, 0, 0, m_cachedWidth, m_cachedHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
        mustRestoreFBO = true;
    } else {
        if (m_boundFBO != m_fbo) {
            mustRestoreFBO = true;
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
        }
    }

    GLint packAlignment = 4;
    bool mustRestorePackAlignment = false;
    glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment);
    if (packAlignment > 4) {
        glPixelStorei(GL_PACK_ALIGNMENT, 4);
        mustRestorePackAlignment = true;
    }

    // FIXME: OpenGL ES 2 does not support GL_BGRA so this fails when
    // using that backend.
    glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_BGRA, GL_UNSIGNED_BYTE, pixels);

    if (mustRestorePackAlignment)
        glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);

    if (mustRestoreFBO)
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);

#ifdef FLIP_FRAMEBUFFER_VERTICALLY
    if (pixels)
        flipVertically(pixels, m_cachedWidth, m_cachedHeight);
#endif

    return true;
}
Exemplo n.º 3
0
ImageIO::errorType ImageIO::loadPPM(const char * filename)
{
  FILE * file = fopen(filename, "rb");
  if(!file)
    return IO_ERROR;

  char buf[4096];
  char * result = fgets(buf, 4096, file);
  result = result + 1; // to avoid a compiler warning
  if(strncmp(buf, "P6", 2))
  {
    printf("Error in loadPPM: File is not a raw RGB ppm.\n");
    fclose(file);
    return INVALID_FILE_FORMAT;
  }

  // read image width and height
  int i = 0;
  int maxval;
  while(i < 3)
  {
    char * dummy = fgets(buf, 4096, file);
    dummy = dummy + 1; // to suppress compiler warning
    if(buf[0] == '#') // ignore comments
      continue;
    if(i == 0)
      i += sscanf(buf, "%d %d %d", &width, &height, &maxval);
    else if (i == 1)
      i += sscanf(buf, "%d %d", &height, &maxval);
    else if (i == 2)
      i += sscanf(buf, "%d", &maxval);
  }

  bytesPerPixel = 3;

  // read the pixels
  free(pixels);
  pixels = (unsigned char*) malloc (sizeof(unsigned char) * 3 * width * height);
  if(fread(pixels, sizeof(unsigned char), 3 * width * height, file) < 3 * width * height)
  {
    printf("Error in loadPPM: Error reading ppm image from %s.\n", filename);
    free(pixels);
    fclose(file);
    return IO_ERROR;
  }

  fclose(file);

  flipVertically();

  return OK;
}
bool WebGraphicsContext3DDefaultImpl::readBackFramebuffer(unsigned char* pixels, size_t bufferSize)
{
    if (bufferSize != static_cast<size_t>(4 * width() * height()))
        return false;

    makeContextCurrent();

#ifdef RENDER_TO_DEBUGGING_WINDOW
    SwapBuffers(m_canvasDC);
#else
    // Earlier versions of this code used the GPU to flip the
    // framebuffer vertically before reading it back for compositing
    // via software. This code was quite complicated, used a lot of
    // GPU memory, and didn't provide an obvious speedup. Since this
    // vertical flip is only a temporary solution anyway until Chrome
    // is fully GPU composited, it wasn't worth the complexity.

    bool mustRestoreFBO;
    if (m_attributes.antialias) {
        glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
        glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
        glBlitFramebufferEXT(0, 0, m_cachedWidth, m_cachedHeight, 0, 0, m_cachedWidth, m_cachedHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
        mustRestoreFBO = true;
    } else {
        if (m_boundFBO != m_fbo) {
            mustRestoreFBO = true;
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
        }
    }
#if PLATFORM(SKIA)
    glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
#elif PLATFORM(CG)
    glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
#else
#error Must port to your platform
#endif

    if (mustRestoreFBO)
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);

#ifdef FLIP_FRAMEBUFFER_VERTICALLY
    if (pixels)
        flipVertically(pixels, m_cachedWidth, m_cachedHeight);
#endif

#endif // RENDER_TO_DEBUGGING_WINDOW
    return true;
}
Exemplo n.º 5
0
CircuitView::CircuitView(CircuitDocument *circuitDocument, ViewContainer *viewContainer, uint viewAreaId, const char *name)
        : ICNView(circuitDocument, viewContainer, viewAreaId, name),
        p_circuitDocument(circuitDocument) {
    KActionCollection *ac = actionCollection();

    new KAction("Dump linear equations", Qt::CTRL | Qt::Key_D, circuitDocument, SLOT(displayEquations()), ac, "dump_les");

    //BEGIN Item Control Actions
    KRadioAction * ra;
    ra = new KRadioAction(i18n("0 Degrees"), "", 0, circuitDocument, SLOT(setOrientation0()), ac, "edit_orientation_0");
    ra->setExclusiveGroup("orientation");
    ra->setChecked(true);
    ra = new KRadioAction(i18n("90 Degrees"), "", 0, circuitDocument, SLOT(setOrientation90()), ac, "edit_orientation_90");
    ra->setExclusiveGroup("orientation");
    ra = new KRadioAction(i18n("180 Degrees"), "", 0, circuitDocument, SLOT(setOrientation180()), ac, "edit_orientation_180");
    ra->setExclusiveGroup("orientation");
    ra = new KRadioAction(i18n("270 Degrees"), "", 0, circuitDocument, SLOT(setOrientation270()), ac, "edit_orientation_270");
    ra->setExclusiveGroup("orientation");

    new KAction(i18n("Create Subcircuit"), "", 0, circuitDocument, SLOT(createSubcircuit()), ac, "circuit_create_subcircuit");
    new KAction(i18n("Rotate Clockwise"), "rotate_cw", "]", circuitDocument, SLOT(rotateClockwise()), ac, "edit_rotate_cw");
    new KAction(i18n("Rotate Counter-Clockwise"), "rotate_ccw", "[", circuitDocument, SLOT(rotateCounterClockwise()), ac, "edit_rotate_ccw");
    new KAction(i18n("Flip Horizontally"), "", 0, circuitDocument, SLOT(flipHorizontally()), ac, "edit_flip_horizontally");
    new KAction(i18n("Flip Vertically"), "", 0, circuitDocument, SLOT(flipVertically()), ac, "edit_flip_vertically");
    //END Item Control Actions

    setXMLFile("ktechlabcircuitui.rc", true);

    QWhatsThis::add(this, i18n(
                        "Construct a circuit by dragging components from the Component selector from the left. Create the connections by dragging a wire from the component connectors.<br><br>"

                        "The simulation is running by default, but can be paused and resumed from the Tools menu.<br><br>"

                        "To delete a wire, select it with a select box, and hit delete.<br><br>"

                        "To edit the attributes of a component, select it (making sure that no components of another type are also selected), and edit in the toolbar. More advanced properties can be edited using the item editor on the right.<br><br>"

                        "Subcircuits can be created by connecting the components with an External Connection, selecting the desired components and clicking on \"Create Subcircuit\" in the right-click menu.")
                   );

    m_pViewIface = new CircuitViewIface(this);

    m_statusBar->insertItem("", ViewStatusBar::SimulationState);
    connect(Simulator::self(), SIGNAL(simulatingStateChanged(bool)), this, SLOT(slotUpdateRunningStatus(bool)));
    slotUpdateRunningStatus(Simulator::self()->isSimulating());
}
Exemplo n.º 6
0
bool Sprite::loading(Resources &resources) {
	if (_fileName.empty())
		return true;

	byte   flippedHorizontally = _flippedHorizontally;
	byte   flippedVertically   = _flippedVertically;
	uint32 scale               = _scale;

	loadFromImage(resources, _fileName);

	if (flippedHorizontally)
		flipHorizontally();
	if (flippedVertically)
		flipVertically();

	setScale(scale);

	return true;
}
Exemplo n.º 7
0
void DrawingBuffer::paintFramebufferToCanvas(int framebuffer, int width, int height, bool premultiplyAlpha, ImageBuffer* imageBuffer)
{
    unsigned char* pixels = 0;

    const SkBitmap& canvasBitmap = imageBuffer->bitmap();
    const SkBitmap* readbackBitmap = 0;
    ASSERT(canvasBitmap.config() == SkBitmap::kARGB_8888_Config);
    if (canvasBitmap.width() == width && canvasBitmap.height() == height) {
        // This is the fastest and most common case. We read back
        // directly into the canvas's backing store.
        readbackBitmap = &canvasBitmap;
        m_resizingBitmap.reset();
    } else {
        // We need to allocate a temporary bitmap for reading back the
        // pixel data. We will then use Skia to rescale this bitmap to
        // the size of the canvas's backing store.
        if (m_resizingBitmap.width() != width || m_resizingBitmap.height() != height) {
            m_resizingBitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
            if (!m_resizingBitmap.allocPixels())
                return;
        }
        readbackBitmap = &m_resizingBitmap;
    }

    // Read back the frame buffer.
    SkAutoLockPixels bitmapLock(*readbackBitmap);
    pixels = static_cast<unsigned char*>(readbackBitmap->getPixels());

    m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
    readBackFramebuffer(pixels, width, height, ReadbackSkia, premultiplyAlpha ? WebGLImageConversion::AlphaDoPremultiply : WebGLImageConversion::AlphaDoNothing);
    flipVertically(pixels, width, height);

    readbackBitmap->notifyPixelsChanged();
    if (m_resizingBitmap.readyToDraw()) {
        // We need to draw the resizing bitmap into the canvas's backing store.
        SkCanvas canvas(canvasBitmap);
        SkRect dst;
        dst.set(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(canvasBitmap.width()), SkIntToScalar(canvasBitmap.height()));
        canvas.drawBitmapRect(m_resizingBitmap, 0, dst);
    }
}
Exemplo n.º 8
0
PictureContent::PictureContent(bool spontaneous, QGraphicsScene * scene, QGraphicsItem * parent)
    : AbstractContent(scene, spontaneous, false, parent)
    , m_photo(0)
    , m_opaquePhoto(false)
    , m_progress(0)
    , m_netWidth(0)
    , m_netHeight(0)
    , m_netReply(0)
    , m_watcher(0)
    , m_watcherTimer(0)
{
    // enable frame text
    setFrameTextEnabled(true);
    setFrameText(tr("..."));

    // allow dropping
    setAcceptDrops(true);

    // add flipping buttons
    ButtonItem * bFlipH = new ButtonItem(ButtonItem::FlipH, Qt::blue, QIcon(":/data/action-flip-horizontal.png"), this);
    bFlipH->setToolTip(tr("Flip horizontally"));
    bFlipH->setFlag(QGraphicsItem::ItemIgnoresTransformations, false);
    connect(bFlipH, SIGNAL(clicked()), this, SIGNAL(flipHorizontally()));
    addButtonItem(bFlipH);

    ButtonItem * bFlipV = new ButtonItem(ButtonItem::FlipV, Qt::blue, QIcon(":/data/action-flip-vertical.png"), this);
    bFlipV->setToolTip(tr("Flip vertically"));
    bFlipV->setFlag(QGraphicsItem::ItemIgnoresTransformations, false);
    addButtonItem(bFlipV);
    connect(bFlipV, SIGNAL(clicked()), this, SIGNAL(flipVertically()));

#if 0
    // add cropping button (TODO: enable this?)
    ButtonItem * bCrop = new ButtonItem(ButtonItem::Control, Qt::blue, QIcon(":/data/action-scale.png"), this);
    bCrop->setToolTip(tr(""));
    bCrop->setFlag(QGraphicsItem::ItemIgnoresTransformations, false);
    addButtonItem(bCrop);
    connect(bCrop, SIGNAL(clicked()), this, SIGNAL(requestCrop()));
#endif
}
Exemplo n.º 9
0
PassRefPtr<Uint8ClampedArray> DrawingBuffer::paintRenderingResultsToImageData(int& width, int& height)
{
    if (m_attributes.premultipliedAlpha)
        return nullptr;

    width = size().width();
    height = size().height();

    Checked<int, RecordOverflow> dataSize = 4;
    dataSize *= width;
    dataSize *= height;
    if (dataSize.hasOverflowed())
        return nullptr;

    RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(width * height * 4);

    m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer());
    readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing);
    flipVertically(pixels->data(), width, height);

    return pixels.release();
}
Exemplo n.º 10
0
bool DrawingBuffer::paintRenderingResultsToImageData(int& width, int& height, SourceDrawingBuffer sourceBuffer, WTF::ArrayBufferContents& contents)
{
    ASSERT(!m_premultipliedAlpha);
    width = size().width();
    height = size().height();

    CheckedNumeric<int> dataSize = 4;
    dataSize *= width;
    dataSize *= height;
    if (!dataSize.IsValid())
        return false;

    WTF::ArrayBufferContents pixels(width * height, 4, WTF::ArrayBufferContents::NotShared, WTF::ArrayBufferContents::DontInitialize);

    GLuint fbo = 0;
    if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) {
        m_gl->GenFramebuffers(1, &fbo);
        m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo);
        m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_frontColorBuffer.texInfo.parameters.target, m_frontColorBuffer.texInfo.textureId, 0);
    } else {
        m_gl->BindFramebuffer(GL_FRAMEBUFFER, framebuffer());
    }

    readBackFramebuffer(static_cast<unsigned char*>(pixels.data()), width, height, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing);
    flipVertically(static_cast<uint8_t*>(pixels.data()), width, height);

    if (fbo) {
        m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_frontColorBuffer.texInfo.parameters.target, 0, 0);
        m_gl->DeleteFramebuffers(1, &fbo);
    }

    restoreFramebufferBindings();

    pixels.transfer(contents);
    return true;
}
Exemplo n.º 11
0
void MainWindow::createActions()
{
    openAct = new QAction(tr("&Open"), this);
    openAct->setToolTip(tr("Open an image"));
    actionsManager->addAction(openAct, "_open", this, this, SLOT(open()), QKeySequence::Open);

    saveAct = new QAction(tr("&Save"), this);
    saveAct->setEnabled(false);
    actionsManager->addAction(saveAct, "_save", this, this, SLOT(save()), QKeySequence::Save);

    exitAct = new QAction(tr("&Exit"), this);
    actionsManager->addAction(exitAct, "_exit", this, this, SLOT(close()), QKeySequence::Quit);

    filePropertiesAct = new QAction(tr("Properties"), this);
    filePropertiesAct->setEnabled(false);
    actionsManager->addAction(filePropertiesAct, "_fileProperties", this, this,
                              SLOT(fileProperties()), QKeySequence("Ctrl+."));

    zoomInAct = new QAction(tr("Zoom In"), this);
    zoomInAct->setEnabled(false);
    actionsManager->addAction(zoomInAct, "_zoomIn", this, this, SLOT(zoomIn()), QKeySequence("+"));

    zoomOutAct = new QAction(tr("Zoom Out"), this);
    zoomOutAct->setEnabled(false);
    actionsManager->addAction(zoomOutAct, "_zoomOut", this, this, SLOT(zoomOut()), QKeySequence("-"));

    normalSizeAct = new QAction(tr("Normal Size"), this);
    normalSizeAct->setEnabled(false);
    actionsManager->addAction(normalSizeAct, "_normalSize", this, this, SLOT(normalSize()), QKeySequence("1"));

    adjustSizeAct = new QAction(tr("Best Fit"), this);
    adjustSizeAct->setEnabled(false);
    adjustSizeAct->setCheckable(true);
    actionsManager->addAction(adjustSizeAct, "_adjustSize", this, this, SLOT(adjustSizeSlot()), QKeySequence("0"));

    rotateRightAct = new QAction(tr("Rotate to right"), this);
    rotateRightAct->setToolTip(tr("Rotate image in the clockwise clock"));
    rotateRightAct->setEnabled(false);
    actionsManager->addAction(rotateRightAct, "_rotateRight", this, this, SLOT(rotateRight()));

    rotateLeftAct = new QAction(tr("Rotate to Left"), this);
    rotateLeftAct->setToolTip(tr("Rotate image counter-clockwise to clockwise"));
    rotateLeftAct->setEnabled(false);
    actionsManager->addAction(rotateLeftAct, "_rotateLeft", this, this, SLOT(rotateLeft()));

    flipVerticallyAct = new QAction(tr("Flip vertically"), this);
    flipVerticallyAct->setToolTip(tr("Turns vertically the image"));
    flipVerticallyAct->setEnabled(false);
    actionsManager->addAction(flipVerticallyAct, "_flipVertically", this, this, SLOT(flipVertically()));

    flipHorizontallyAct = new QAction(tr("Flip horizontally"), this);
    flipHorizontallyAct->setToolTip(tr("Reflects the image"));
    flipHorizontallyAct->setEnabled(false);
    actionsManager->addAction(flipHorizontallyAct, "_flipHorizontally", this, this, SLOT(flipHorizontally()));

    aboutAct = new QAction(tr("A&bout"), this);
    actionsManager->addAction(aboutAct, "_about", this, this, SLOT(about()), QKeySequence::HelpContents);

    nextAct = new QAction(tr("Ne&xt"), this);
    nextAct->setStatusTip(tr("Loads next image"));
    nextAct->setEnabled(false);
    actionsManager->addAction(nextAct, "_next", this, this, SLOT(next()), Qt::Key_Right);

    goFirstAct = new QAction(tr("Go to the first"), this);
    goFirstAct->setStatusTip(tr("Loads the first image in the folder"));
    goFirstAct->setEnabled(false);
    actionsManager->addAction(goFirstAct, "_goFirst", this, this, SLOT(goFirst()), Qt::Key_Home);

    prevAct = new QAction(tr("Pre&vious"), this);
    prevAct->setStatusTip(tr("Loads previous image"));
    prevAct->setEnabled(false);
    actionsManager->addAction(prevAct, "_previous", this, this, SLOT(previous()), Qt::Key_Left);

    goLastAct = new QAction(tr("Go to the last"), this);
    goLastAct->setStatusTip(tr("Loads the last image in the folder"));
    goLastAct->setEnabled(false);
    actionsManager->addAction(goLastAct, "_goLast", this, this, SLOT(goLast()), Qt::Key_End);

    openDirAct = new QAction(tr("Open &Folder"), this);
    openDirAct->setStatusTip("Open a folder to explore images inside it");
    actionsManager->addAction(openDirAct, "_openFolder", this, this, SLOT(openDir()), QKeySequence("Ctrl+Shift+O"));

    showMenuBarAct = new QAction(tr("Show Menu Bar"), this);
    showMenuBarAct->setCheckable(true);
    actionsManager->addAction(showMenuBarAct, "_showMenuBar", this, this, SLOT(showMenuBar()), QKeySequence("Ctrl+M"));

    configAct = new QAction(tr("Configuration"), this);
    configAct->setEnabled(true);
    actionsManager->addAction(configAct, "_configuration", this, this, SLOT(configureProgram()), QKeySequence("Ctrl+C"));

    deleteRecentFilesAct = new QAction(tr("Delete list"), this);
    deleteRecentFilesAct->setIcon(QIcon::fromTheme("edit-clear"));
    connect(deleteRecentFilesAct, SIGNAL(triggered()), this, SLOT(deleteRecentFiles()));

    printAct = new QAction(tr("Print"), this);
    printAct->setEnabled(false);
    actionsManager->addAction(printAct, "_print", this, this, SLOT(print()), QKeySequence::Print);

    deleteFileAct = new QAction(tr("Delete"), this);
    deleteFileAct->setEnabled(false);
    deleteFileAct->setToolTip(tr("This deletes completly the file from the disk, doesn't move it to the trash"));
    actionsManager->addAction(deleteFileAct, "_deleteFile", this, this, SLOT(deleteFileSlot()), QKeySequence::Delete);

    moveToAct = new QAction(tr("Move to..."), this);
    moveToAct->setEnabled(false);
    actionsManager->addAction(moveToAct, "_moveTo", this, this, SLOT(moveToSlot()));

    goToAct = new QAction(tr("Go to"), this);
    goToAct->setEnabled(false);
    actionsManager->addAction(goToAct, "_goTo", this, this, SLOT(goToSlot()), QKeySequence("Ctrl+J"));

    configureToolBarAct = new QAction(tr("Configure toolbar"), this);
    actionsManager->addAction(configureToolBarAct, "_configureToolBar", this, this, SLOT(configureToolBarSlot()));

    //set the icons, becouse QIcon::name() was included in Qt4.7
    actionsManager->setActionIcon("_about", "help-about");
    actionsManager->setActionIcon("_adjustSize", "zoom-fit-best");
    actionsManager->setActionIcon("_configuration", "configure");
    actionsManager->setActionIcon("_deleteFile", "edit-delete");
    actionsManager->setActionIcon("_exit", "application-exit");
    actionsManager->setActionIcon("_fileProperties", "document-properties");
    actionsManager->setActionIcon("_flipHorizontally", "object-flip-horizontal");
    actionsManager->setActionIcon("_flipVertically", "object-flip-vertical");
    actionsManager->setActionIcon("_goFirst", "go-first");
    actionsManager->setActionIcon("_goLast", "go-last");
    actionsManager->setActionIcon("_goTo", "go-jump");
    actionsManager->setActionIcon("_moveTo", "none");
    actionsManager->setActionIcon("_next", "go-next");
    actionsManager->setActionIcon("_normalSize", "zoom-original");
    actionsManager->setActionIcon("_open", "document-open");
    actionsManager->setActionIcon("_openFolder", "folder-open");
    actionsManager->setActionIcon("_previous", "go-previous");
    actionsManager->setActionIcon("_print", "document-print");
    actionsManager->setActionIcon("_rotateLeft", "object-rotate-left");
    actionsManager->setActionIcon("_rotateRight", "object-rotate-right");
    actionsManager->setActionIcon("_save", "document-save");
    actionsManager->setActionIcon("_showMenuBar", "show-menu");
    actionsManager->setActionIcon("_showToolBar", "configure-toolbars");
    actionsManager->setActionIcon("_tbMovable", "configure-toolbars");
    actionsManager->setActionIcon("_configureToolBar", "configure-toolbars");
    actionsManager->setActionIcon("_zoomIn", "zoom-in");
    actionsManager->setActionIcon("_zoomOut", "zoom-out");
}
Exemplo n.º 12
0
void ImageWindow::createActions()
{
    openAction = new QAction(tr("&Open..."), this);
    openAction->setShortcut(tr("Ctrl+O"));
    openAction->setStatusTip(tr("Open an existing image file"));
    connect(openAction, SIGNAL(triggered()), this, SLOT(open()));

    saveAction = new QAction(tr("&Save"), this);
    saveAction->setShortcut(tr("Ctrl+S"));
    saveAction->setStatusTip(tr("Save the image to disk"));
    connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));

    saveAsAction = new QAction(tr("Save &As..."), this);
    saveAsAction->setStatusTip(tr("Save the image under a new name"));
    connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));

    exitAction = new QAction(tr("E&xit"), this);
    exitAction->setShortcut(tr("Ctrl+Q"));
    exitAction->setStatusTip(tr("Exit the application"));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

    flipHorizontallyAction = new QAction(tr("Flip &Horizontally"),
                                         this);
    flipHorizontallyAction->setShortcut(tr("Ctrl+H"));
    flipHorizontallyAction->setStatusTip(tr("Flip the image "
                                         "horizontally"));
    connect(flipHorizontallyAction, SIGNAL(triggered()),
            this, SLOT(flipHorizontally()));

    flipVerticallyAction = new QAction(tr("Flip &Vertically"), this);
    flipVerticallyAction->setShortcut(tr("Ctrl+V"));
    flipVerticallyAction->setStatusTip(tr("Flip the image vertically"));
    connect(flipVerticallyAction, SIGNAL(triggered()),
            this, SLOT(flipVertically()));

    resizeAction = new QAction(tr("&Resize..."), this);
    resizeAction->setShortcut(tr("Ctrl+R"));
    resizeAction->setStatusTip(tr("Resize the image"));
    connect(resizeAction, SIGNAL(triggered()),
            this, SLOT(resizeImage()));

    convertTo32BitAction = new QAction(tr("32 Bit"), this);
    convertTo32BitAction->setStatusTip(tr("Convert to 32-bit image"));
    connect(convertTo32BitAction, SIGNAL(triggered()),
            this, SLOT(convertTo32Bit()));

    convertTo8BitAction = new QAction(tr("8 Bit"), this);
    convertTo8BitAction->setStatusTip(tr("Convert to 8-bit image"));
    connect(convertTo8BitAction, SIGNAL(triggered()),
            this, SLOT(convertTo8Bit()));

    convertTo1BitAction = new QAction(tr("1 Bit"), this);
    convertTo1BitAction->setStatusTip(tr("Convert to 1-bit image"));
    connect(convertTo1BitAction, SIGNAL(triggered()),
            this, SLOT(convertTo1Bit()));

    aboutAction = new QAction(tr("&About"), this);
    aboutAction->setStatusTip(tr("Show the application's About box"));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));

    aboutQtAction = new QAction(tr("About &Qt"), this);
    aboutQtAction->setStatusTip(tr("Show the Qt library's About box"));
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
Exemplo n.º 13
0
void RoombotBuildPlan::turnNinetyDegreesClockwise()
{
    turnAndMirror();
    flipVertically();
}
Exemplo n.º 14
0
 void rotate(vector<vector<int>> &matrix) {
     flipVertically(matrix);
     transpose(matrix);
 }