Esempio n. 1
0
GenericCodeEditor::GenericCodeEditor( Document *doc, QWidget *parent ):
    QPlainTextEdit( parent ),
    mDoc(doc),
    mEditorBoxIsActive(false),
    mLastCursorBlock(-1)
{
    Q_ASSERT(mDoc != 0);

    setFrameShape(QFrame::NoFrame);

    viewport()->setAttribute( Qt::WA_MacNoClickThrough, true );

    mLineIndicator = new LineIndicator(this);
    mLineIndicator->move( contentsRect().topLeft() );

    mOverlay = new QGraphicsScene(this);

    QPalette overlayPalette;
    overlayPalette.setBrush(QPalette::Base, Qt::NoBrush);

    QGraphicsView *overlayView = new QGraphicsView(mOverlay, this);
    overlayView->setFrameShape( QFrame::NoFrame );
    overlayView->setPalette(overlayPalette);
    overlayView->setFocusPolicy( Qt::NoFocus );
    overlayView->setAttribute(Qt::WA_TransparentForMouseEvents, true);
    overlayView->setSceneRect(QRectF(0,0,1,1));
    overlayView->setAlignment(Qt::AlignLeft | Qt::AlignTop);

    mOverlayWidget = overlayView;

    mOverlayAnimator = new OverlayAnimator(this, mOverlay);

    connect( mDoc, SIGNAL(defaultFontChanged()), this, SLOT(onDocumentFontChanged()) );

    connect( this, SIGNAL(blockCountChanged(int)),
             mLineIndicator, SLOT(setLineCount(int)) );

    connect( mLineIndicator, SIGNAL( widthChanged() ),
             this, SLOT( updateLayout() ) );

    connect( this, SIGNAL(updateRequest(QRect,int)),
             this, SLOT(updateLineIndicator(QRect,int)) );

    connect( this, SIGNAL(selectionChanged()),
             mLineIndicator, SLOT(update()) );
    connect(this, SIGNAL(selectionChanged()), this, SLOT(updateDocLastSelection()));
    connect( this, SIGNAL(cursorPositionChanged()),
             this, SLOT(onCursorPositionChanged()) );

    connect( Main::instance(), SIGNAL(applySettingsRequest(Settings::Manager*)),
             this, SLOT(applySettings(Settings::Manager*)) );

    QTextDocument *tdoc = doc->textDocument();
    QPlainTextEdit::setDocument(tdoc);
    onDocumentFontChanged();
    doc->setLastActiveEditor(this);

    applySettings( Main::settings() );
}
Esempio n. 2
0
int main(int argc, char *argv[]) {

    QApplication a(argc, argv);

	// define 4 points forming a square
	Point p(100.0, 100.0);
	Point q(500.0, 100.0);
	Point r(500.0, 500.0);
	Point s(100.0, 500.0);
	// Set up a Tour with those four points
	// The constructor should link p->q->r->s->p
	Tour squareTour(p, q, r, s);
	squareTour.show();

    string filename = "tsp10.txt";
    ifstream input;
    input.open(filename);

    // get dimensions
    int width;
    int height;
    input >> width;
    input >> height;

    // setup graphical window
    QGraphicsView *view = new QGraphicsView();
    QGraphicsScene *scene = new QGraphicsScene();
    view->setScene(scene);
    view->scale(1, -1); //screen y-axis is inverted
    view->setSceneRect(0, 0, width, height);
    view->show();

    // run insertion heuristic
    Tour tour;
    double x;
    double y;
    while (input >> x >> y) {
        Point p(x, y);
		//tour.insertNearest(p);
        tour.insertSmallest(p);
        //uncomment the 4 lines below to animate
		tour.draw(scene);
		std::chrono::milliseconds dura(50);
		std::this_thread::sleep_for(dura);
		a.processEvents();
	}
    input.close();

    // print tour to standard output
    cout << "Tour distance: " << std::fixed << std::setprecision(4)
         << std::showpoint << tour.distance() << endl;
    cout << "Number of points: " << tour.size() << endl;
	tour.show();

    // draw tour
    tour.draw(scene);
	return a.exec(); // start Qt event loop
}
Esempio n. 3
0
GenericCodeEditor::GenericCodeEditor( Document *doc, QWidget *parent ):
    QPlainTextEdit( parent ),
    mDoc(doc)
{
    Q_ASSERT(mDoc != 0);

    setFrameShape( QFrame::NoFrame );

    mLineIndicator = new LineIndicator(this);
    mLineIndicator->move( contentsRect().topLeft() );

    mOverlay = new QGraphicsScene(this);

    QGraphicsView *overlayView = new QGraphicsView(mOverlay, this);
    overlayView->setFrameShape( QFrame::NoFrame );
    overlayView->setBackgroundBrush( Qt::NoBrush );
    overlayView->setStyleSheet("background: transparent");
    overlayView->setFocusPolicy( Qt::NoFocus );
    overlayView->setAttribute(Qt::WA_TransparentForMouseEvents, true);
    overlayView->setSceneRect(QRectF(0,0,1,1));
    overlayView->setAlignment(Qt::AlignLeft | Qt::AlignTop);

    mOverlayWidget = overlayView;

    connect( mDoc, SIGNAL(defaultFontChanged()), this, SLOT(onDocumentFontChanged()) );

    connect( this, SIGNAL(blockCountChanged(int)),
             mLineIndicator, SLOT(setLineCount(int)) );

    connect( mLineIndicator, SIGNAL( widthChanged() ),
             this, SLOT( updateLayout() ) );

    connect( this, SIGNAL(updateRequest(QRect,int)),
             this, SLOT(updateLineIndicator(QRect,int)) );

    connect( this, SIGNAL(selectionChanged()),
             mLineIndicator, SLOT(update()) );

    connect( Main::instance(), SIGNAL(applySettingsRequest(Settings::Manager*)),
             this, SLOT(applySettings(Settings::Manager*)) );

    QTextDocument *tdoc = doc->textDocument();
    QPlainTextEdit::setDocument(tdoc);
    onDocumentFontChanged();
    mLineIndicator->setLineCount(blockCount());

    applySettings( Main::settings() );
}
Esempio n. 4
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    // create scene
    QGraphicsScene *scene = new QGraphicsScene();

    // create Item
    MyRec * player = new MyRec();

    //add Item
    scene->addItem(player);

    //make focusable
    player->setFlag(QGraphicsItem::ItemIsFocusable);
    player->setFocus();

    //spawn enemy
    QTimer *timer = new QTimer;
    QObject::connect(timer,SIGNAL(timeout()),player,SLOT(spawn()));
    timer->start(2000);

    // vitualize
    QGraphicsView *view = new QGraphicsView(scene);
    view->setSceneRect(0,0,800,600);
    view->setFixedSize(800,600);


    //set initial position player
    player->setPos(view->width()/2,view->height()-player->rect().height());

    view->show();

//    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
//    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);


    return a.exec();
}
Esempio n. 5
0
Geometryval::Geometryval(const MltVideoProfile profile, QPoint frame_size, QWidget* parent) :
        QWidget(parent),
        m_profile(profile),
        m_paramRect(NULL),
        m_geom(NULL),
        m_path(NULL),
        m_fixedMode(false),
        m_frameSize(frame_size)
{
    m_ui.setupUi(this);
    QVBoxLayout* vbox = new QVBoxLayout(m_ui.widget);
    QGraphicsView *view = new QGraphicsView(this);
    view->setBackgroundBrush(QBrush(Qt::black));
    vbox->addWidget(view);
    vbox->setContentsMargins(0, 0, 0, 0);

    QVBoxLayout* vbox2 = new QVBoxLayout(m_ui.keyframeWidget);
    m_helper = new KeyframeHelper(this);
    vbox2->addWidget(m_helper);
    vbox2->setContentsMargins(0, 0, 0, 0);

    connect(m_helper, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int)));

    m_scene = new GraphicsSceneRectMove(this);
    m_scene->setTool(TITLE_SELECT);
    view->setScene(m_scene);
    QGraphicsRectItem *m_frameBorder = new QGraphicsRectItem(QRectF(0, 0, profile.width, profile.height));
    m_frameBorder->setZValue(-1100);
    m_frameBorder->setBrush(QColor(255, 255, 0, 30));
    m_frameBorder->setPen(QPen(QBrush(QColor(255, 255, 255, 255)), 1.0, Qt::DashLine));
    m_scene->addItem(m_frameBorder);

    m_ui.buttonNext->setIcon(KIcon("media-skip-forward"));
    m_ui.buttonNext->setToolTip(i18n("Go to next keyframe"));
    m_ui.buttonPrevious->setIcon(KIcon("media-skip-backward"));
    m_ui.buttonPrevious->setToolTip(i18n("Go to previous keyframe"));
    m_ui.buttonAdd->setIcon(KIcon("document-new"));
    m_ui.buttonAdd->setToolTip(i18n("Add keyframe"));
    m_ui.buttonDelete->setIcon(KIcon("edit-delete"));
    m_ui.buttonDelete->setToolTip(i18n("Delete keyframe"));

    QMenu *configMenu = new QMenu(i18n("Misc..."), this);
    m_ui.buttonMenu->setIcon(KIcon("system-run"));
    m_ui.buttonMenu->setMenu(configMenu);
    m_ui.buttonMenu->setPopupMode(QToolButton::QToolButton::InstantPopup);


    configMenu->addAction(i18n("Geometry"), this, SLOT(slotGeometry()));

    m_scaleMenu = new QMenu(i18n("Resize..."), this);
    configMenu->addMenu(m_scaleMenu);
    m_scaleMenu->addAction(i18n("50%"), this, SLOT(slotResize50()));
    m_scaleMenu->addAction(i18n("100%"), this, SLOT(slotResize100()));
    m_scaleMenu->addAction(i18n("200%"), this, SLOT(slotResize200()));
    m_scaleMenu->addAction(i18n("Original size"), this, SLOT(slotResizeOriginal()));
    m_scaleMenu->addAction(i18n("Custom"), this, SLOT(slotResizeCustom()));

    m_alignMenu = new QMenu(i18n("Align..."), this);
    configMenu->addMenu(m_alignMenu);
    m_alignMenu->addAction(i18n("Center"), this, SLOT(slotAlignCenter()));
    m_alignMenu->addAction(i18n("Hor. Center"), this, SLOT(slotAlignHCenter()));
    m_alignMenu->addAction(i18n("Vert. Center"), this, SLOT(slotAlignVCenter()));
    m_alignMenu->addAction(i18n("Right"), this, SLOT(slotAlignRight()));
    m_alignMenu->addAction(i18n("Left"), this, SLOT(slotAlignLeft()));
    m_alignMenu->addAction(i18n("Top"), this, SLOT(slotAlignTop()));
    m_alignMenu->addAction(i18n("Bottom"), this, SLOT(slotAlignBottom()));


    m_syncAction = configMenu->addAction(i18n("Sync timeline cursor"), this, SLOT(slotSyncCursor()));
    m_syncAction->setCheckable(true);
    m_syncAction->setChecked(KdenliveSettings::transitionfollowcursor());

    //scene->setSceneRect(0, 0, profile.width * 2, profile.height * 2);
    //view->fitInView(m_frameBorder, Qt::KeepAspectRatio);
    const double sc = 100.0 / profile.height * 0.8;
    QRectF srect = view->sceneRect();
    view->setSceneRect(srect.x(), -srect.height() / 3 + 10, srect.width(), srect.height() + srect.height() / 3 * 2 - 10);
    m_scene->setZoom(sc);
    view->centerOn(m_frameBorder);
    connect(m_ui.buttonNext , SIGNAL(clicked()) , this , SLOT(slotNextFrame()));
    connect(m_ui.buttonPrevious , SIGNAL(clicked()) , this , SLOT(slotPreviousFrame()));
    connect(m_ui.buttonDelete , SIGNAL(clicked()) , this , SLOT(slotDeleteFrame()));
    connect(m_ui.buttonAdd , SIGNAL(clicked()) , this , SLOT(slotAddFrame()));
    connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateTransitionProperties()));
    connect(m_scene, SIGNAL(doubleClickEvent()), this, SLOT(slotGeometry()));

}