Exemplo n.º 1
0
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	fDoc = NULL;
	fEnableAutoBreakdown = true;
	fDefaultFps = 24;

	ui->setupUi(this);

	setAcceptDrops(true);

	ui->waveformView->SetScrollArea(ui->scrollArea);
	ui->fpsEdit->setValidator(new QIntValidator(1, 120));

    ui->exportChoice->addItem("Spine");

	connect(ui->actionZoomIn, SIGNAL(triggered()), ui->waveformView, SLOT(onZoomIn()));
	connect(ui->actionZoomOut, SIGNAL(triggered()), ui->waveformView, SLOT(onZoomOut()));
	connect(ui->actionAutoZoom, SIGNAL(triggered()), ui->waveformView, SLOT(onAutoZoom()));
	connect(ui->fpsEdit, SIGNAL(textChanged(QString)), this, SLOT(onFpsChange(QString)));
	connect(ui->waveformView, SIGNAL(frameChanged(int)), ui->mouthView, SLOT(onFrameChanged(int)));

	RestoreSettings();
	updateActions();
}
Exemplo n.º 2
0
void CSceneWidget::keyPressEvent(QKeyEvent *event)
{
    switch (event->key()) {
        case Qt::Key_Plus:
            onZoomIn();
        break;
        case Qt::Key_Minus:
            onZoomOut();
        break;
        default:
            QGraphicsView::keyPressEvent(event);
    }
}
Exemplo n.º 3
0
/**
 * @brief ImageDialog::ImageDialog
 * @param parent
 */
ImageDialog::ImageDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ImageDialog)
{
    ui->setupUi(this);

#ifdef Q_WS_MAC
    setWindowFlags((windowFlags() & ~Qt::WindowType_Mask) | Qt::Sheet);
    setStyleSheet(styleSheet() + " #ImageDialog { border: 1px solid rgba(0, 0, 0, 100); border-top: none; }");
#else
    setWindowFlags((windowFlags() & ~Qt::WindowType_Mask) | Qt::Dialog);
#endif

    QSettings settings;
    resize(settings.value("ImageDialog/Size").toSize());

    connect(ui->table, SIGNAL(cellClicked(int,int)), this, SLOT(imageClicked(int, int)));
    connect(ui->table, SIGNAL(sigDroppedImage(QUrl)), this, SLOT(onImageDropped(QUrl)));
    connect(ui->buttonClose, SIGNAL(clicked()), this, SLOT(reject()));
    connect(ui->buttonChoose, SIGNAL(clicked()), this, SLOT(chooseLocalImage()));
    connect(ui->previewSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(onPreviewSizeChange(int)));
    connect(ui->buttonZoomIn, SIGNAL(clicked()), this, SLOT(onZoomIn()));
    connect(ui->buttonZoomOut, SIGNAL(clicked()), this, SLOT(onZoomOut()));
    QMovie *movie = new QMovie(":/img/spinner.gif");
    movie->start();
    ui->labelSpinner->setMovie(movie);
    clear();
    setImageType(TypePoster);
    m_currentDownloadReply = 0;

    QPixmap zoomOut(":/img/zoom_out.png");
    QPixmap zoomIn(":/img/zoom_in.png");
    QPainter p;
    p.begin(&zoomOut);
    p.setCompositionMode(QPainter::CompositionMode_SourceIn);
    p.fillRect(zoomOut.rect(), QColor(0, 0, 0, 150));
    p.end();
    p.begin(&zoomIn);
    p.setCompositionMode(QPainter::CompositionMode_SourceIn);
    p.fillRect(zoomIn.rect(), QColor(0, 0, 0, 150));
    p.end();
    ui->buttonZoomOut->setIcon(QIcon(zoomOut));
    ui->buttonZoomIn->setIcon(QIcon(zoomIn));

    m_noElementsLabel = new QLabel(tr("No images found"), ui->table);
    m_noElementsLabel->setMargin(10);
    m_noElementsLabel->hide();
}
Exemplo n.º 4
0
void SCgWindow::createToolBar()
{
    mToolBar = new QToolBar(this);

    mToolBar->setIconSize(QSize(32, 32));

    QActionGroup* group = new QActionGroup(mToolBar);

    // Select mode
    QAction *action = new QAction(findIcon("tool-select.png"), tr("Selection mode"), mToolBar);
    action->setCheckable(true);
    action->setChecked(true);
    action->setShortcut(QKeySequence(tr("1", "Selection mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Select] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectMode()));

    //Pair creation mode
    action = new QAction(findIcon("tool-pair.png"), tr("Pair creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("2", "Pair creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Pair] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onPairMode()));

    //Bus creation mode
    action = new QAction(findIcon("tool-bus.png"), tr("Bus creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("3", "Bus creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Bus] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onBusMode()));

    //Contour creation mode
    action = new QAction(findIcon("tool-contour.png"), tr("Contour creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("4", "Contour creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Contour] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onContourMode()));
    //
    mToolBar->addSeparator();
    //

    // align group button
    QToolButton *alignButton = new QToolButton(mToolBar);
    alignButton->setIcon(findIcon("tool-align.png"));
    alignButton->setPopupMode(QToolButton::InstantPopup);
    alignButton->setToolTip(tr("Alignment"));
    mToolBar->addWidget(alignButton);

    //Grid alignment
    action = new QAction(findIcon("tool-align-grid.png"), tr("Grid alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("5", "Grid alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onGridAlignment()));

    // tuple alignment
    action = new QAction(findIcon("tool-align-tuple.png"), tr("Tuple alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("6", "Tuple alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onTupleAlignment()));

    //Vertical alignment
    action = new QAction(findIcon("tool-align-vert.png"), tr("Vertical alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("7", "Vertical alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onVerticalAlignment()));

    //Horizontal alignment
    action = new QAction(findIcon("tool-align-horz.png"), tr("Horizontal alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("8", "Horizontal alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onHorizontalAlignment()));

    // selection group button
    QToolButton *selectButton = new QToolButton(mToolBar);
    selectButton->setIcon(findIcon("tool-select-group.png"));
    selectButton->setPopupMode(QToolButton::InstantPopup);
    selectButton->setToolTip(tr("Selection group"));
    mToolBar->addWidget(selectButton);

    // input/output selection
    action = new QAction(findIcon("tool-select-inout.png"), tr("Select input/output"), mToolBar);
    action->setCheckable(false);
    selectButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectInputOutput()));

    // sbgraph selection
    action = new QAction(findIcon("tool-select-subgraph.png"), tr("Select subgraph"), mToolBar);
    action->setCheckable(false);
    selectButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectSubgraph()));

    mToolBar->addSeparator();

    action = new QAction(findIcon("tool-export-image.png"), tr("Export image"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("0", "Export image")));
    mToolBar->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onExportImage()));

    //
    mToolBar->addSeparator();
    //
    //Zoom in
    action = new QAction(findIcon("tool-zoom-in.png"), tr("Zoom in"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("+", "Zoom in")));
    mToolBar->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onZoomIn()));

    //Scale combobox
    QComboBox* b = new QComboBox(mToolBar);
    b->setEditable(true);
    b->setInsertPolicy(QComboBox::NoInsert);
    b->addItems(SCgWindow::mScales);
    b->setCurrentIndex(mScales.indexOf("100"));
    mZoomFactorLine = b->lineEdit();
    mZoomFactorLine->setInputMask("D90%");
    mToolBar->addWidget(b);
    connect(mZoomFactorLine, SIGNAL(textChanged(const QString&)), mView, SLOT(setScale(const QString&)));
    connect(mView, SIGNAL(scaleChanged(qreal)), this, SLOT(onViewScaleChanged(qreal)));

    //Zoom out
    action = new QAction(findIcon("tool-zoom-out.png"), tr("Zoom out"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("-", "Zoom out")));
    mToolBar->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onZoomOut()));

    mToolBar->setWindowTitle(tr("SCg Tools"));
    mToolBar->setObjectName("SCgMainToolBar");

    //! @bug toolbar state is not saved
    mToolBar->setMovable(false);
}
Exemplo n.º 5
0
void SCgWindow::createToolBar()
{
    mToolBar = new QToolBar(this);

    mToolBar->setIconSize(QSize(32, 32));

    QActionGroup* group = new QActionGroup(mToolBar);

    // Select mode
    QAction *action = new QAction(findIcon("tool-select.png"), tr("Selection mode"), mToolBar);
    action->setCheckable(true);
    action->setChecked(true);
    action->setShortcut(QKeySequence(tr("1", "Selection mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Select] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectMode()));

    //Pair creation mode
    action = new QAction(findIcon("tool-pair.png"), tr("Pair creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("2", "Pair creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Pair] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onPairMode()));

    //Bus creation mode
    action = new QAction(findIcon("tool-bus.png"), tr("Bus creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("3", "Bus creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Bus] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onBusMode()));

    //Contour creation mode
    action = new QAction(findIcon("tool-contour.png"), tr("Contour creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("4", "Contour creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Contour] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onContourMode()));
    //
    mToolBar->addSeparator();
    //

    // align group button
    QToolButton *alignButton = new QToolButton(mToolBar);
    alignButton->setIcon(findIcon("tool-align.png"));
    alignButton->setPopupMode(QToolButton::InstantPopup);
    mToolBar->addWidget(alignButton);

    //Grid alignment
    action = new QAction(findIcon("tool-align-grid.png"), tr("Grid alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("5", "Grid alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onGridAlignment()));

    // tuple alignment
    action = new QAction(findIcon("tool-align-tuple.png"), tr("Tuple alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("6", "Tuple alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onTupleAlignment()));

    //Vertical alignment
    action = new QAction(findIcon("tool-align-vert.png"), tr("Vertical alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("7", "Vertical alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onVerticalAlignment()));

    //Horizontal alignment
    action = new QAction(findIcon("tool-align-horz.png"), tr("Horizontal alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("8", "Horizontal alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onHorizontalAlignment()));

    // Energy-based layout
    action = new QAction(findIcon("tool-align-energy.png"), tr("Energy-based layout"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("9", "Energy-based layout")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onEnergyBasedLayout()));


    // selection group button
    QToolButton *selectButton = new QToolButton(mToolBar);
    selectButton->setIcon(findIcon("tool-select-group.png"));
    selectButton->setPopupMode(QToolButton::InstantPopup);
    mToolBar->addWidget(selectButton);

    // input/output selection
    action = new QAction(findIcon("tool-select-inout.png"), tr("Select input/output"), mToolBar);
    action->setCheckable(false);
    selectButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectInputOutput()));

    // sbgraph selection
    action = new QAction(findIcon("tool-select-subgraph.png"), tr("Select subgraph"), mToolBar);
    action->setCheckable(false);
    selectButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectSubgraph()));

    mToolBar->addSeparator();

    action = new QAction(findIcon("tool-export-image.png"), tr("Export image"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("0", "Export image")));
    mToolBar->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onExportImage()));

    //
    mToolBar->addSeparator();
    //

    //Zoom label
    mZoomLabel = new QLabel(mToolBar);
    mToolBar->addWidget(mZoomLabel);

    //Zoom in
    action = new QAction(findIcon("tool-zoom-in.png"), tr("Zoom in"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("+", "Zoom in")));
    mToolBar->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onZoomIn()));

    //Zoom slider
    mZoomSlider = new QSlider(Qt::Vertical);

    //mZoomSlider->setInvertedAppearance(false);
    mZoomSlider->setRange(25, 200);
    mZoomSlider->setTickPosition(QSlider::TicksBelow);
    mZoomSlider->setTickInterval(25);
    mZoomSlider->setFixedHeight(150);
    mZoomSlider->setSliderPosition(100);
    mToolBar->addWidget(mZoomSlider);
    connect(mZoomSlider, SIGNAL(valueChanged(int)), mView, SLOT(setScale(int)));
    connect(mZoomSlider, SIGNAL(valueChanged(int)), this, SLOT(updateZoomLabel(int)));
    connect(mView, SIGNAL(scaleChanged(qreal)), this, SLOT(onViewScaleChanged(qreal)));

    //Zoom out
    action = new QAction(findIcon("tool-zoom-out.png"), tr("Zoom out"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("-", "Zoom out")));
    mToolBar->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onZoomOut()));

    mToolBar->setWindowTitle(tr("SCg Tools"));
    mToolBar->setObjectName("SCgMainToolBar");

    //! @bug toolbar state is not saved
    mToolBar->setMovable(false);
}