Exemplo n.º 1
0
void VideoView::mousePressEvent(QMouseEvent *e) {
    switch (m_currentMode) {
    case Mode::PANZOOM: {
        if (QApplication::keyboardModifiers() == Qt::NoModifier) {
            m_panZoomState.isChanged = true;
            m_panZoomState.panState = BioTracker::Core::CurrentPanState(e->localPos());
            setCursor(Qt::ClosedHandCursor);
        }
        if (e->button() == Qt::LeftButton && e->type() == QEvent::MouseButtonDblClick) {
            fitToWindow();
        }
        break;
    }
    case Mode::INTERACTION: {
        e->accept();
        QPoint p  = unprojectScreenPos(e->pos());
        const QPointF localPos(p);
        QMouseEvent modifiedEvent(e->type(),localPos,e->screenPos(),e->button(),e->buttons(),e->modifiers());
        m_biotracker.mouseEvent(&modifiedEvent);
        break;
    }
    default: {
        assert(false);
        break;
    }
    }
}
Exemplo n.º 2
0
void ImageViewer::createActions()
{


      zoomInAct = new QAction(tr("Zoom &In (25%)"), this);
      zoomInAct->setShortcut(tr("Ctrl++"));
      zoomInAct->setEnabled(false);
      connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));

      zoomOutAct = new QAction(tr("Zoom &Out (25%)"), this);
      zoomOutAct->setShortcut(tr("Ctrl+-"));
      zoomOutAct->setEnabled(false);
      connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));

      normalSizeAct = new QAction(tr("&Normal Size"), this);
      normalSizeAct->setShortcut(tr("Ctrl+S"));
      normalSizeAct->setEnabled(false);
      connect(normalSizeAct, SIGNAL(triggered()), this, SLOT(normalSize()));

      fitToWindowAct = new QAction(tr("&Fit to Window"), this);
      fitToWindowAct->setEnabled(false);
      fitToWindowAct->setCheckable(true);
      fitToWindowAct->setShortcut(tr("Ctrl+F"));
      connect(fitToWindowAct, SIGNAL(triggered()), this, SLOT(fitToWindow()));
  }
Exemplo n.º 3
0
void ImageViewer::createActions()
{
  openAct = new QAction(tr("&Open..."), this);
  openAct->setShortcut(tr("Ctrl+O"));
  connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

  saveAct = new QAction(tr("&Save..."), this);
  saveAct->setShortcut(tr("Ctrl+S"));
  connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
  saveAct->setEnabled(false);


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

  zoomInAct = new QAction(tr("Zoom &In (25%)"), this);
  zoomInAct->setShortcut(tr("Ctrl++"));
  zoomInAct->setEnabled(false);
  connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));

  zoomOutAct = new QAction(tr("Zoom &Out (25%)"), this);
  zoomOutAct->setShortcut(tr("Ctrl+-"));
  zoomOutAct->setEnabled(false);
  connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));

  normalSizeAct = new QAction(tr("&Normal Size"), this);
  normalSizeAct->setShortcut(tr("Ctrl+S"));
  normalSizeAct->setEnabled(false);
  connect(normalSizeAct, SIGNAL(triggered()), this, SLOT(normalSize()));

  fitToWindowAct = new QAction(tr("&Fit to Window"), this);
  fitToWindowAct->setEnabled(false);
  fitToWindowAct->setCheckable(true);
  fitToWindowAct->setShortcut(tr("Ctrl+F"));
  connect(fitToWindowAct, SIGNAL(triggered()), this, SLOT(fitToWindow()));

  aboutAct = new QAction(tr("&About"), this);
  connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

  aboutQtAct = new QAction(tr("About &Qt"), this);
  connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
  
  proceedAct = new QAction(tr("Proceed image"), this);
  proceedAct->setEnabled(false);
  proceedAct->setShortcut(tr("Ctrl+P"));
  connect(proceedAct, SIGNAL(triggered()),this, SLOT(proceed()));
  
  proceedByStepAct = new QAction(tr("Proceed image by step"), this);
  proceedByStepAct->setEnabled(false);
  connect(proceedByStepAct, SIGNAL(triggered()),this, SLOT(proceedByStep()));

  // Log function
  imageProcessor = new ImageProcessor();
  connect(imageProcessor,SIGNAL(sendLogMessage(QString,int)),
          this,SLOT(writeLog(QString,int)));
  connect(imageProcessor,SIGNAL(sendImage(QImage&)),
         this,SLOT(updateImage(QImage&)));

}
Exemplo n.º 4
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    scaleFactor=1.0;
    ui->setupUi(this);

    //////////////////
    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("project_DB.s3db");
    db.open();


    ui->label->setBackgroundRole(QPalette::Base);
    ui->label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    ui->label->setScaledContents(true);

    ui->scrollArea->setWidget(ui->label);
    ui->scrollArea->setBackgroundRole(QPalette::Dark);
    //setCentralWidget(ui->scrollArea);

    setWindowTitle(tr("Image Viewer"));
        resize(500, 400);

    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openfile()));
    connect(ui->actionAbout_Program, SIGNAL(triggered()), this, SLOT(aboutProg()));
    connect(ui->actionHelp, SIGNAL(triggered()), this, SLOT(help()));
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(exitApp()));
    connect(ui->actionZoomIn, SIGNAL(triggered()), this, SLOT(zoomIn()));
    connect(ui->actionZoomOut, SIGNAL(triggered()), this, SLOT(zoomOut()));
    connect(ui->actionNormal_Size, SIGNAL(triggered()), this, SLOT(normalSize()));
    connect(ui->actionFitToWindow, SIGNAL(triggered()), this, SLOT(fitToWindow()));
    connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(zoomIn()));
    connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(zoomOut()));
    connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(next()));
    connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(prev()));


    ui->actionFitToWindow->setEnabled(false);
    ui->actionFitToWindow->setCheckable(true);
    ui->actionFitToWindow->setShortcut(tr("Ctrl+F"));

    ui->actionNormal_Size->setShortcut(tr("Ctrl+S"));
    ui->actionNormal_Size->setEnabled(false);

    ui->actionZoomOut->setShortcut(tr("Ctrl+-"));
    ui->actionZoomOut->setEnabled(false);

    ui->actionZoomIn->setShortcut(tr("Ctrl++"));
    ui->actionZoomIn->setEnabled(false);

    ui->actionExit->setShortcut(tr("Ctrl+Q"));

    ui->actionOpen->setShortcut(tr("Ctrl+O"));

    namefilter.append("*.png");
    namefilter.append("*.jpg");
}
Exemplo n.º 5
0
void MainWindow::updateZoomControls() {
    bool fitChecked = ui->checkBoxFitToWindow->isChecked();

    ui->scrollArea->setVerticalScrollBarPolicy(!fitChecked ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff);
    ui->scrollArea->setHorizontalScrollBarPolicy(!fitChecked ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff);

    if (fitChecked) {
        fitToWindow();
    }
}
Exemplo n.º 6
0
void MainWindow::openFile(QString fileName) {
    delete(inputImage);
    delete(outputImage);
    inputImage = new QImage(fileName);

    if (inputImage->isNull()) {
        QMessageBox::information(this, tr("Smart Deblur"),
                                 tr("Cannot load %1.").arg(fileName));
        return;
    }

    // Resize image if it's necessary
    int width = inputImage->width();
    int height = inputImage->height();

    if (width > MAX_IMAGE_DIMENSION || height > MAX_IMAGE_DIMENSION) {
        double resizeRatio = qMin(MAX_IMAGE_DIMENSION/width, MAX_IMAGE_DIMENSION/height);
        width = width*resizeRatio;
        height = height*resizeRatio;

        width += width % 2;
        height += height % 2;

        inputImage = new QImage(inputImage->scaled(
                                    width, height,
                                    Qt::IgnoreAspectRatio, Qt::SmoothTransformation));

        QMessageBox::information(this, tr("Smart Deblur"),
                                 tr("Image was resized to %1 * %2 for performance reasons")
                                 .arg(width).arg(height));
    }

    // Crop image if sizes are odd
    if (width%2 != 0 || height%2 !=0) {
        width -= width % 2;
        height -= height % 2;
        inputImage = new QImage(inputImage->copy(0,0, width, height));
    }

    lblImageSize->setText(tr(" Image Size: %1 x %2 ").arg(inputImage->width()).arg(inputImage->height()));

    ui->btnSave->setEnabled(true);
    ui->btnShowOriginal->setEnabled(true);

    outputImage = new QImage(inputImage->width(), inputImage->height(), QImage::Format_RGB32);
    lblThreadsCount->setText(tr(" Threads: %1 ").arg(workerThread->initFFT(inputImage)));
    imageLabel->setPixmap(QPixmap::fromImage(*inputImage));
    // updateFullDeconvolution();
    ui->checkBoxFitToWindow->setChecked(true);
    fitToWindow();
}
Exemplo n.º 7
0
ImageViewer::ImageViewer()
{
  createWidgets();
  createActions();
  createMenus();

  setWindowTitle(tr("Image Viewer"));

  // Fitting to window by default
  fitToWindowAct->setChecked(true);
  fitToWindow();
  resize(500, 600);
  show();
}
Exemplo n.º 8
0
void MainWindow::connectUiToFunction()
{
    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save()));
    connect(ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(saveAs()));
    connect(ui->actionZoom_In_25, SIGNAL(triggered()), this, SLOT(zoomIn()));
    connect(ui->actionZoom_Out_25, SIGNAL(triggered()), this, SLOT(zoomOut()));
    connect(ui->actionNormal_Size, SIGNAL(triggered()), this, SLOT(normlSize()));
    connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(print()));
    connect(ui->actionHelp, SIGNAL(triggered()), this, SLOT(about()));
    connect(ui->actionFit_to_Window, SIGNAL(triggered()), this, SLOT(fitToWindow()));

    connect(ui->actionLevel_Set_Segmentation, SIGNAL(triggered()), this, SLOT(level_set()));
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void AIMImageGraphicsDelegate::on_parentResized()
{
  //qDebug() << "  AIMImageGraphicsDelegate::on_parentResized" << "\n";
//  int gvWidth = m_GraphicsView->size().width();
//  int gvHeight = m_GraphicsView->size().height();
// qDebug() << "    GV Size (W X H) :" << gvWidth << " x " << gvHeight << "\n";
  if (_shouldFitToWindow == true)
  {
    fitToWindow();
  }
  else
  {
    updateGraphicsScene();
  }
}
Exemplo n.º 10
0
void SinglePhotoPreviewLayout::updateZoomAndSize()
{
    // Set zoom for fit-in-window as minimum, but don't scale up images
    // that are smaller than the available space, only scale down.
    double fitZoom = d->zoomSettings()->fitToSizeZoomFactor(d->frameSize(), ImageZoomSettings::OnlyScaleDown);
    setMinZoomFactor(fitZoom);
    setMaxZoomFactor(12.0);

    // Is currently the zoom factor set to fit to window? Then set it again to fit the new size.
    if (zoomFactor() <= fitZoom || d->isFitToWindow)
    {
        fitToWindow();
    }

    updateLayout();
}
Exemplo n.º 11
0
void SinglePhotoPreviewLayout::toggleFitToWindowOr100()
{
    if (!d->item || !d->view)
    {
        return;
    }

    if (d->isFitToWindow)
    {
        setZoomFactor(1.0);
    }
    else
    {
        fitToWindow();
    }
}
Exemplo n.º 12
0
void ImageViewer::createActions()
{
    openAct = new QAction(tr("&Open..."), this);
    openAct->setShortcut(tr("Ctrl+O"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

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

    zoomInAct = new QAction(tr("Zoom &In (25%)"), this);
    zoomInAct->setShortcut(tr("Ctrl++"));
    zoomInAct->setEnabled(false);
    connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));

    zoomOutAct = new QAction(tr("Zoom &Out (25%)"), this);
    zoomOutAct->setShortcut(tr("Ctrl+-"));
    zoomOutAct->setEnabled(false);
    connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));

    normalSizeAct = new QAction(tr("&Normal Size"), this);
    normalSizeAct->setShortcut(tr("Ctrl+S"));
    normalSizeAct->setEnabled(false);
    connect(normalSizeAct, SIGNAL(triggered()), this, SLOT(normalSize()));

    fitToWindowAct = new QAction(tr("&Fit to Window"), this);
    fitToWindowAct->setEnabled(false);
    fitToWindowAct->setCheckable(true);
    fitToWindowAct->setShortcut(tr("Ctrl+F"));
    connect(fitToWindowAct, SIGNAL(triggered()), this, SLOT(fitToWindow()));

    greyScaleAct = new QAction(tr("&Greyscale"), this);
    greyScaleAct->setEnabled(false);
    connect(greyScaleAct, SIGNAL(triggered()), this, SLOT(greyScale()));

    negativeAct = new QAction(tr("&Negative"), this);
    negativeAct->setEnabled(false);
    connect(negativeAct, SIGNAL(triggered()), this, SLOT(negative()));

    aboutAct = new QAction(tr("&About"), this);
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

    aboutQtAct = new QAction(tr("About &Qt"), this);
    connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
Exemplo n.º 13
0
void MainWindow::openImg(QString fileName)
{
    QImage image(fileName);
    if (image.isNull()) {
        QMessageBox::information(this, tr("Image Viewer"),
                                 tr("Cannot load %1.").arg(fileName));
        return;
    }
    ui->label->setPixmap(QPixmap::fromImage(image));
    scaleFactor = 1.0;
    sh=image.height();
    sw=image.width();

    ui->actionFitToWindow->setEnabled(true);
    updateActions();

    if (!ui->actionFitToWindow->isChecked())
        ui->label->adjustSize();
    fitToWindow();



    QFileInfo *fi=new QFileInfo(fileName);
    pdr=new QDir(fi->absoluteDir());


    fnlist=pdr->entryList(namefilter);
    for (int i=0;i<fnlist.count();i++)
    {
        fnlist[i]=pdr->absoluteFilePath(fnlist[i]);
    }
    ci=fnlist.indexOf(fileName);

    QSqlQuery query;
    query.prepare("SELECT Mark,Tag FROM Images WHERE Name = :name");
    query.bindValue(":name", fnlist[ci]);
    query.exec();
    query.first();
    int mark = query.value(0).toInt();
    QString tag = query.value(1).toString();    
    ui->lineEdit->setText(tag);
    ui->spinBox->setValue(mark);
}
ImageWidget::ImageWidget(QWidget *parent) :
    QWidget(parent)
{
    setMinimumSize(300, 300);
    m_layout = new QVBoxLayout(this);
    this->setLayout(m_layout);

    m_imageLabel = new QLabel(this);
    m_imageLabel->setBackgroundRole(QPalette::Base);
    m_imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    m_imageLabel->setScaledContents(true);
    m_imageLabel->hide();
    m_scrollArea = new QScrollArea(this);
    m_scrollArea->setBackgroundRole(QPalette::Dark);
    m_scrollArea->setWidget(m_imageLabel);
    m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

    m_layout->addWidget(m_scrollArea);

    this->m_actionFitToWindow = new QAction(tr("Fit To Window"), this);
    m_actionFitToWindow->setEnabled(false);
    m_actionFitToWindow->setCheckable(true);
    this->m_actionNormalSize = new QAction(tr("Normal Size"),this);
    m_actionNormalSize->setEnabled(false);
    this->m_actionZoomIn = new QAction(tr("Zoom In"), this);
    m_actionZoomIn->setEnabled(false);
    this->m_actionZoomOut = new QAction(tr("Zoom Out"), this);
    m_actionZoomOut->setEnabled(false);
    this->m_contextMenu = new QMenu(this);
    m_contextMenu->addAction(m_actionZoomIn);
    m_contextMenu->addAction(m_actionZoomOut);
    m_contextMenu->addAction(m_actionNormalSize);
    m_contextMenu->addSeparator();
    m_contextMenu->addAction(m_actionFitToWindow);
    this->setContextMenuPolicy(Qt::DefaultContextMenu);
    connect(m_actionFitToWindow, SIGNAL(triggered()), this, SLOT(fitToWindow()));
    connect(m_actionNormalSize, SIGNAL(triggered()), this, SLOT(normalSize()));
    connect(m_actionZoomIn, SIGNAL(triggered()), this, SLOT(zoomIn()));
    connect(m_actionZoomOut, SIGNAL(triggered()), this, SLOT(zoomOut()));

}
Exemplo n.º 15
0
void ImageViewer::createActions()
{
    printAct = new QAction(tr("&Print..."), this);
    printAct->setShortcut(tr("Ctrl+P"));
    printAct->setEnabled(false);
    connect(printAct, SIGNAL(triggered()), this, SLOT(print()));

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

    zoomInAct = new QAction(tr("Zoom &In (25%)"), this);
    zoomInAct->setShortcut(tr("Ctrl++"));
    zoomInAct->setEnabled(false);
    connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));

    zoomOutAct = new QAction(tr("Zoom &Out (25%)"), this);
    zoomOutAct->setShortcut(tr("Ctrl+-"));
    zoomOutAct->setEnabled(false);
    connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));

    normalSizeAct = new QAction(tr("&Normal Size"), this);
    normalSizeAct->setShortcut(tr("Ctrl+S"));
    normalSizeAct->setEnabled(false);
    connect(normalSizeAct, SIGNAL(triggered()), this, SLOT(normalSize()));

    fitToWindowAct = new QAction(tr("&Fit to Window"), this);
    fitToWindowAct->setEnabled(false);
    fitToWindowAct->setCheckable(true);
    fitToWindowAct->setShortcut(tr("Ctrl+F"));
    connect(fitToWindowAct, SIGNAL(triggered()), this,
	    SLOT(fitToWindow()));

    aboutAct = new QAction(tr("&About"), this);
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

    aboutQtAct = new QAction(tr("About &Qt"), this);
    connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
Exemplo n.º 16
0
MoviePlayer::MoviePlayer(QWidget *parent)
    : QWidget(parent)
{
    movie = new QMovie(this);
    movie->setCacheMode(QMovie::CacheAll);

    movieLabel = new QLabel(tr("No movie loaded"));
    movieLabel->setAlignment(Qt::AlignCenter);
    movieLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    movieLabel->setBackgroundRole(QPalette::Dark);
    movieLabel->setAutoFillBackground(true);

    currentMovieDirectory = "movies";

    createControls();
    createButtons();

    connect(movie, SIGNAL(frameChanged(int)), this, SLOT(updateFrameSlider()));
    connect(movie, SIGNAL(stateChanged(QMovie::MovieState)),
            this, SLOT(updateButtons()));
    connect(fitCheckBox, SIGNAL(clicked()), this, SLOT(fitToWindow()));
    connect(frameSlider, SIGNAL(valueChanged(int)), this, SLOT(goToFrame(int)));
    connect(speedSpinBox, SIGNAL(valueChanged(int)),
            movie, SLOT(setSpeed(int)));

    mainLayout = new QVBoxLayout;
    mainLayout->addWidget(movieLabel);
    mainLayout->addLayout(controlsLayout);
    mainLayout->addLayout(buttonsLayout);
    setLayout(mainLayout);

    updateFrameSlider();
    updateButtons();

    setWindowTitle(tr("Movie Player"));
    resize(400, 400);
}
Exemplo n.º 17
0
void MainWindow::resizeEvent(QResizeEvent *resizeEvent) {
    if (ui->checkBoxFitToWindow->isChecked()) {
        fitToWindow();
    }
}
void ImageViewer::createActions()
{
    openAct = new QAction(tr("&Open..."), this);
//    openAct->setShortcut(tr("Ctrl+O"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

    printAct = new QAction(tr("&Print..."), this);
//    printAct->setShortcut(tr("Ctrl+P"));
    printAct->setEnabled(false);
    connect(printAct, SIGNAL(triggered()), this, SLOT(print()));

    exitAct = new QAction(tr("E&xit"), this);
//    exitAct->setShortcut(tr("Ctrl+Q"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    zoomInAct = new QAction(tr("Zoom &In (10%)"), this);
//    zoomInAct->setShortcut(tr("Ctrl++"));
    zoomInAct->setEnabled(false);
    connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));

    zoomOutAct = new QAction(tr("Zoom &Out (10%)"), this);
//    zoomOutAct->setShortcut(tr("Ctrl+-"));
    zoomOutAct->setEnabled(false);
    connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));

    normalSizeAct = new QAction(tr("&Normal Size"), this);
//    normalSizeAct->setShortcut(tr("Ctrl+S"));
    normalSizeAct->setEnabled(false);
    connect(normalSizeAct, SIGNAL(triggered()), this, SLOT(normalSize()));

    fitToWindowAct = new QAction(tr("&Fit to Window"), this);
    fitToWindowAct->setEnabled(false);
    fitToWindowAct->setCheckable(true);
//    fitToWindowAct->setShortcut(tr("Ctrl+F"));
    connect(fitToWindowAct, SIGNAL(triggered()), this, SLOT(fitToWindow()));

    aboutAct = new QAction(tr("&About"), this);
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

    aboutQtAct = new QAction(tr("About &Qt"), this);
    connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

    crop = new QAction(tr("Crop"),this);
    crop->setEnabled(false);
    connect(crop,SIGNAL(triggered()),this,SLOT(saveSlot()));

    rotate_left_90 = new QAction(tr("Rotate left"),this);
    rotate_left_90->setEnabled(false);
    rotate_right_90 = new QAction(tr("rotate Right"),this);
    rotate_right_90->setEnabled(false);
    QSignalMapper *sm = new QSignalMapper(this);
    connect(rotate_left_90,SIGNAL(triggered()),sm,SLOT(map()));
    connect(rotate_right_90,SIGNAL(triggered()),sm,SLOT(map()));
    sm->setMapping(rotate_left_90,90);
    sm->setMapping(rotate_right_90,-90);
    connect (sm, SIGNAL(mapped(int)), this, SLOT(rotate_with_angle(int))) ;

    rotate_custom = new QAction(tr("Custom rotation"),this);
    rotate_custom->setEnabled(false);
    connect(rotate_custom,SIGNAL(triggered()),this,SLOT(rotate_custom_slot()));

    undo = new QAction(tr("Undo"),this);
    connect(undo,SIGNAL(triggered()),this,SLOT(undo_slot()));

    redo = new QAction(tr("Redo"),this);
    connect(redo,SIGNAL(triggered()),this,SLOT(redo_slot()));

    reset = new QAction(tr("Reset"),this);
    connect(reset,SIGNAL(triggered()),this,SLOT(reset_slot()));
    reset->setEnabled(false);
    QToolBar *tb = new QToolBar ;

    saveAs = new QAction(tr("Save As"),this);
    connect(saveAs,SIGNAL(triggered()),this,SLOT(saveAs_slot()));

    tb->addAction(openAct);
    tb->addAction(zoomInAct);
    tb->addAction(zoomOutAct);
    tb->addAction(crop);
    tb->addAction(rotate_left_90);
    tb->addAction(rotate_right_90);
    tb->addAction(undo);
    tb->addAction(redo);
    tb->addAction(reset);

    addToolBar(tb);
}