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() ); }
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() ); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QDir::setCurrent(QCoreApplication::applicationDirPath()); QDir dir(QDir::current()); // set the slide model. QFile xmlf(dir.absoluteFilePath("userdata/test.xml")); if (!xmlf.exists()) { QMessageBox::critical(0, "error", "no xml file..."); return 0; } xmlf.open(QFile::ReadWrite); QSlideModel model(xmlf.readAll()); xmlf.close(); // set the slide scene QSlidePlayerScene *scene = new QSlidePlayerScene(0, &model); QPixmap pixmap(dir.absoluteFilePath("res/images/default-background.png")); scene->setBackgroundBrush(Qt::black); scene->setBackgroundPixmap(pixmap); //set slide view QGraphicsView *view = new QGraphicsView(scene); view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->setFrameShape(QFrame::NoFrame); // editing is not allowed. view->setInteractive(false); // scale double newScale = QApplication::desktop()->height() / scene->sceneRect().height(); QMatrix oldMatrix = view->matrix(); view->resetMatrix(); view->translate(oldMatrix.dx(), oldMatrix.dy()); view->scale(newScale, newScale); view->showFullScreen(); QHidDevice * test = new QHidDevice(0x55, 0x32, &a); return a.exec(); }
/*------------------------------------------------------------------------------ | main +-----------------------------------------------------------------------------*/ int main(int argc, char** argv) { qputenv("QT_QPA_EGLFS_FORCE888", "1"); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); QApplication a(argc, argv); const QStringList args = a.arguments(); if (args.size() < 2) { log_err("Video ID is missing."); return 1; } const QString videoId = args.at(1); log_info("Starting playback of video ID %s...", qPrintable(videoId)); POC_Bridge bridge(videoId); QGraphicsWebView* webItem = new QGraphicsWebView; webItem->page()->mainFrame()->addToJavaScriptWindowObject("bridge", &bridge); QOpenGLWidget* glViewport = new QOpenGLWidget; QGraphicsView* view = new QGraphicsView; view->setFrameShape(QFrame::NoFrame); view->setRenderHints(QPainter::Antialiasing); view->setScene(new QGraphicsScene); view->setViewport(glViewport); view->showFullScreen(); view->scene()->setBackgroundBrush(QBrush(Qt::red)); view->scene()->setSceneRect(QRectF(0, 0, 1920, 1080)); view->scene()->addItem(webItem); webItem->setUrl(QUrl("qrc:/player.html")); webItem->setMinimumSize(1920, 1080); return a.exec(); }