Beispiel #1
0
static QJSValue aProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
  QScreen *src = QGuiApplication::screens().at(0);

  QJSValue value = scriptEngine->newObject();
  value.setProperty("screenWidth", src->availableGeometry().width());
  value.setProperty("screenHeight", src->availableGeometry().height());

  return value;
}
Beispiel #2
0
UIWindow::UIWindow(QWindow *window) :
	QPlatformWindow(window),
	position_includes_frame(false),
	visible(false),
	pending_geometry_change_on_show(true),
	z_level(0.0),
	opacity_level(1.0)
{
	PROFILE_FUNCTION

	QRect geom(window->geometry());
	QScreen *screen = window->screen();
	QRect screenGeom(screen->availableGeometry());
	int x = screenGeom.x() + screenGeom.width()/2. - geom.width()/2.;
	int y = screenGeom.y() + screenGeom.height()/2. - geom.height()/2.;
	geom.setX(x);
	geom.setY(y);
	
	setGeometry(geom);
	setWindowFlags(window->flags());
	setWindowState(window->windowState());

	QWindowSystemInterface::flushWindowSystemEvents();

	static WId counter = 0;
	win_id = ++counter;

	raise();
	mIsDecorationUpdateNeeded = true;
	checkDecorations();
}
Beispiel #3
0
Datei: run.cpp Projekt: trtikm/E2
void run()
{
    TMPROF_BLOCK();

    int argc = 1;
    char* argv[] = { "" };
    QGuiApplication app(argc, argv);

    QScreen *screen = QGuiApplication::primaryScreen();
    QRect screenGeometry = screen->availableGeometry();
    QPoint center = QPoint(screenGeometry.center().x(), screenGeometry.top() + 80);
    QSize windowSize(400, 320);
    int delta = 40;

    QList<QWindow *> windows;
    xqtgl::window *windowA = new xqtgl::window(&init,&step,&draw,&fini);
    windowA->setGeometry(QRect(center, windowSize).translated(-windowSize.width() - delta / 2, 0));
    windowA->setTitle(QStringLiteral("Window"));
    windowA->setVisible(true);
    windows.prepend(windowA);

    app.exec();

    qDeleteAll(windows);

}
Beispiel #4
0
int main(int argc, char *argv[])
{
    // Enable the following to have touch events generated from mouse events.
    // Very handy for testing touch event delivery without a real touch device.
    // QGuiApplication::setAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents, true);

    QGuiApplication app(argc, argv);
    QScreen *screen = QGuiApplication::primaryScreen();
    QRect screenGeometry = screen->availableGeometry();

    QSurfaceFormat format;
    format.setDepthBufferSize(16);

    QRect geom = screenGeometry;
    if (QCoreApplication::arguments().contains(QLatin1String("-nofullscreen")))
        geom = QRect(screenGeometry.width() / 4, screenGeometry.height() / 4,
                     screenGeometry.width() / 2, screenGeometry.height() / 2);

    QOpenGLWindow window(format, geom);
    QWindowCompositor compositor(&window);

    window.show();

    return app.exec();
}
Beispiel #5
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setApplicationName("RabbitIm");
    a.setOrganizationName("KangLin studio");

    //QFontDatabase::addApplicationFont("://DejaVuSans.ttf");
    //a.setFont(QFont(DejaVuSans));
    LOG_MODEL_DEBUG("main", "font:%s;codec:%s",
                    a.font().family().toStdString().c_str(),
                    QTextCodec::codecForLocale()->name().data());

    //设置插件路径(msvc 下没有用)   
    a.addLibraryPath(CGlobal::Instance()->GetDirApplication());
    a.addLibraryPath(CGlobal::Instance()->GetDirApplication() + QDir::separator() + "plugins");

    CTool::SetFFmpegLog();

    //*
    MainWindow w;
#ifndef MOBILE
    //加载窗口位置  
    QSettings conf(CGlobal::Instance()->GetApplicationConfigureFile(), QSettings::IniFormat);
    QScreen *pScreen = QGuiApplication::primaryScreen();
    int top = conf.value("UI/MainWindow/top", (pScreen->availableGeometry().height() - w.height()) >> 1).toInt();
    int left = conf.value("UI/MainWindow/left", (pScreen->availableGeometry().width() - w.width()) >> 1).toInt();
    int Width = conf.value("UI/MainWindow/width", w.geometry().width()).toInt();
    int Height = conf.value("UI/MainWindow/height", w.geometry().height()).toInt();
    w.resize(Width, Height);
    w.move(left, top);
#endif
    w.show();//*/

#ifdef RABBITIM_USER_LIBCURL
    //检查版本更新  
    CDownLoadHandleVersionFile update;
    update.Start();
#endif
    /*以下为视频捕获、显示测试代码(CFrmPlayer::TestCamera())  
    CFrmPlayer player;
    player.TestCamera();
    player.show();//*/

    return a.exec();
}
Beispiel #6
0
//Primary/private  function
void NativeWindowSystem::arrangeWindows(NativeWindowObject *primary, QString type, bool primaryonly){
  if(type.isEmpty()){ type = "center"; }
  if(primary==0){
    //Get the currently active window and treat that as the primary
    for(int i=0; i<NWindows.length(); i++){
      if(NWindows[i]->property(NativeWindowObject::Active).toBool()){ primary = NWindows[i]; }
    }
    if(primary==0 && !NWindows.isEmpty()){ primary = NWindows[0]; } //just use the first one in the list
  }
  //Now get the current screen that the mouse cursor is over (and valid area)
  QScreen *screen = screenUnderMouse();
  if(screen==0){ return; } //should never happen (theoretically)
  QRect desktopArea = screen->availableGeometry();
  //qDebug() << "Arrange Windows:" << primary->geometry() << type << primaryonly << desktopArea;
  //Now start filtering out all the windows that need to be ignored
  int wkspace = primary->property(NativeWindowObject::Workspace).toInt();
  QList<NativeWindowObject*> winlist = NWindows;
  for(int i=0; i<winlist.length(); i++){
    if(winlist[i]->property(NativeWindowObject::Workspace).toInt()!=wkspace
	|| !winlist[i]->property(NativeWindowObject::Visible).toBool()
	|| desktopArea.intersected(winlist[i]->geometry()).isNull() ){
      //window is outside of the desired area or invisible - ignore it
      winlist.removeAt(i);
      i--;
    }
  }
  if(!winlist.contains(primary)){ winlist << primary; } //could be doing this on a window right before it is shown
  else if(primaryonly){ winlist.removeAll(primary); winlist << primary; } //move primary window to last
  //QRegion used;
  for(int i=0; i<winlist.length(); i++){
    if(primaryonly && winlist[i]!=primary){ continue; } //skip this window
    //Now loop over the windows and arrange them as needed
    QRect geom = winlist[i]->geometry();
    //verify that the window is contained by the desktop area
    if(geom.width()>desktopArea.width()){ geom.setWidth(desktopArea.width()); }
    if(geom.height()>desktopArea.height()){ geom.setHeight(desktopArea.height()); }
    //Now apply the proper placement routine
    if(type=="center"){
      QPoint ct = desktopArea.center();
      winlist[i]->setGeometryNow( QRect( ct.x()-(geom.width()/2), ct.y()-(geom.height()/2), geom.width(), geom.height()) );
    }else if(type=="snap"){

    }else if(type=="single_max"){
      winlist[i]->setGeometryNow( QRect( desktopArea.x(), desktopArea.y(), desktopArea.width(), desktopArea.height()) );
    }else if(type=="under-mouse"){
      QPoint ct = QCursor::pos();
      geom = QRect(ct.x()-(geom.width()/2), ct.y()-(geom.height()/2), geom.width(), geom.height() );
      //Now verify that the top of the window is still contained within the desktop area
      if(geom.y() < desktopArea.y() ){ geom.moveTop(desktopArea.y()); }
      winlist[i]->setGeometryNow(geom);

    }
    //qDebug() << " - New Geometry:" << winlist[i]->geometry();
  } //end loop over winlist
}
Beispiel #7
0
void View::positionOnScreen()
{
    QScreen* shownOnScreen = 0;
    if (QGuiApplication::screens().count() <= 1) {
        shownOnScreen = QGuiApplication::primaryScreen();
    } else {
        Q_FOREACH (QScreen* screen, QGuiApplication::screens()) {
            if (screen->geometry().contains(QCursor::pos(screen))) {
                shownOnScreen = screen;
                break;
            }
        }
    }
    Q_ASSERT(shownOnScreen);

    setScreen(shownOnScreen);
    const QRect r = shownOnScreen->availableGeometry();

    if (m_floating && !m_customPos.isNull()) {
        int x = qBound(r.left(), m_customPos.x(), r.right() - width());
        int y = qBound(r.top(), m_customPos.y(), r.bottom() - height());
        setPosition(x, y);
        show();
        return;
    }

    const int w = width();
    int x = r.left() + (r.width() * m_offset) - (w / 2);

    int y = r.top();
    if (m_floating) {
        y += r.height() / 3;
    }

    x = qBound(r.left(), x, r.right() - width());
    y = qBound(r.top(), y, r.bottom() - height());

    setPosition(x, y);

    if (m_floating) {
        KWindowSystem::setOnDesktop(winId(), KWindowSystem::currentDesktop());
        KWindowSystem::setType(winId(), NET::Normal);
        //Turn the sliding effect off
        KWindowEffects::slideWindow(winId(), KWindowEffects::NoEdge, 0);
    } else {
        KWindowSystem::setOnAllDesktops(winId(), true);
        KWindowEffects::slideWindow(winId(), KWindowEffects::TopEdge, 0);
    }

    KWindowSystem::forceActiveWindow(winId());
    //qDebug() << "moving to" << m_screenPos[screen];
}
Beispiel #8
0
MainWindow::MainWindow(QGuiApplication& app, QWindow *parent) :
    QQuickView(parent)
{
    this->setSource(QUrl::fromLocalFile("qml/main.qml"));
    this->setWindowTitle("Tori");
    this->setResizeMode(QQuickView::SizeRootObjectToView);

    QScreen* screen = app.primaryScreen();
    this->setX(screen->availableGeometry().width() - this->width() - 20);
    this->setY(70);

    this->initializeTwitterAccess();
}
Beispiel #9
0
QRect SubMenu::availableScreenRectForItem(QQuickItem *item) const
{
    QScreen *screen = QGuiApplication::primaryScreen();

    const QPoint globalPosition = item->window()->mapToGlobal(item->position().toPoint());

    foreach(QScreen *s, QGuiApplication::screens()) {
        if (s->geometry().contains(globalPosition)) {
            screen = s;
        }
    }

    return screen->availableGeometry();
}
Beispiel #10
0
void GetScreenInfoFromNativeWindow(QWindow* window, blink::WebScreenInfo* results)
{
    QScreen* screen = window->screen();

    blink::WebScreenInfo r;
    r.deviceScaleFactor = screen->devicePixelRatio();
    r.depthPerComponent = 8;
    r.depth = screen->depth();
    r.isMonochrome = (r.depth == 1);

    QRect screenGeometry = screen->geometry();
    r.rect = blink::WebRect(screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), screenGeometry.height());
    QRect available = screen->availableGeometry();
    r.availableRect = blink::WebRect(available.x(), available.y(), available.width(), available.height());
    *results = r;
}
Beispiel #11
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    const bool multipleWindows = false;

    QScreen *screen = QGuiApplication::primaryScreen();

    QRect screenGeometry = screen->availableGeometry();

    QSurfaceFormat format;
    format.setDepthBufferSize(16);
    format.setSamples(4);

    QPoint center = QPoint(screenGeometry.center().x(), screenGeometry.top() + 80);
    QSize windowSize(400, 320);
    int delta = 40;

    QList<QWindow *> windows;
    QSharedPointer<Renderer> rendererA(new Renderer(format));

    HelloWindow *windowA = new HelloWindow(rendererA);
    windowA->setGeometry(QRect(center, windowSize).translated(-windowSize.width() - delta / 2, 0));
    windowA->setTitle(QStringLiteral("Thread A - Context A"));
    windowA->setVisible(true);
    windows.prepend(windowA);

    QList<QThread *> renderThreads;
    if (multipleWindows) {
        QSharedPointer<Renderer> rendererB(new Renderer(format, rendererA.data()));

        QThread *renderThread = new QThread;
        rendererB->moveToThread(renderThread);
        renderThreads << renderThread;

        HelloWindow *windowB = new HelloWindow(rendererA);
        windowB->setGeometry(QRect(center, windowSize).translated(delta / 2, 0));
        windowB->setTitle(QStringLiteral("Thread A - Context A"));
        windowB->setVisible(true);
        windows.prepend(windowB);

        HelloWindow *windowC = new HelloWindow(rendererB);
        windowC->setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, windowSize.height() + delta));
        windowC->setTitle(QStringLiteral("Thread B - Context B"));
        windowC->setVisible(true);
        windows.prepend(windowC);

        for (int i = 1; i < QGuiApplication::screens().size(); ++i) {
            QScreen *screen = QGuiApplication::screens().at(i);
            QSharedPointer<Renderer> renderer(new Renderer(format, rendererA.data(), screen));

            renderThread = new QThread;
            renderer->moveToThread(renderThread);
            renderThreads.prepend(renderThread);

            QRect screenGeometry = screen->availableGeometry();
            QPoint center = screenGeometry.center();

            QSize windowSize = screenGeometry.size() * 0.8;

            HelloWindow *window = new HelloWindow(renderer);
            window->setScreen(screen);
            window->setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, -windowSize.height() / 2));

            QChar id = QChar('B' + i);
            window->setTitle(QStringLiteral("Thread ") + id + QStringLiteral(" - Context ") + id);
            window->setVisible(true);
            windows.prepend(window);
        }
    }

    for (int i = 0; i < renderThreads.size(); ++i) {
        QObject::connect(qGuiApp, SIGNAL(lastWindowClosed()), renderThreads.at(i), SLOT(quit()));
        renderThreads.at(i)->start();
    }

    const int exitValue = app.exec();

    for (int i = 0; i < renderThreads.size(); ++i)
        renderThreads.at(i)->wait();

    qDeleteAll(windows);
    qDeleteAll(renderThreads);

    return exitValue;
}
Beispiel #12
0
int main(int argc, char* argv[])
{
    QGuiApplication app(argc,argv);

#ifdef QT_WEBVIEW_WEBENGINE_BACKEND
    QtWebEngine::initialize();
#endif // QT_WEBVIEW_WEBENGINE_BACKEND

    qreal screenH=0;
    qreal screenW=0;
    bool firstLaunch=false;

    FileService fileservice;   
    InternetServices internetservices;

    //Translation
    QTranslator translator;
    QDropbox dropbox(APP_KEY, APP_SECRET);
    DropBoxOperations dropboxOperations;
    dropboxOperations.setDropboxObject(&dropbox);


#ifdef IOS
    qmlRegisterType<PDFVisu>("PDFVisu", 1, 0, "PDFVisu");
#endif

#ifdef ANDROID
    qmlRegisterType<PdfCore>("ANDPDFVisu", 1, 0, "ANDPDFVisu");
#endif


    translator.load(":/playlistPlayer."+ QLocale::system().name());

    if(QGuiApplication::screens().length()>1){
        QScreen *scrn = QGuiApplication::primaryScreen();
        screenH=scrn->availableGeometry().size().height();
        screenW=scrn->availableGeometry().size().width();
    }

    app.setOrganizationName("Monasys");
    app.setOrganizationDomain("Monasys.fr");

    app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName());

    //Translation

    app.installTranslator(&translator);

    QQuickView view;
    view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));

    // Test if local Documents Dir exists, if not creates it

    if(!QDir(documents).exists()){        
        if(QDir(documents.left(documents.lastIndexOf("/"))).exists()){
            QDir(documents.left(documents.lastIndexOf("/"))).mkdir(QDir(documents).dirName());
        }
    }
    if(!QDir(documents + "/playlists").exists()){
        // First launch, install examples
        QDir(documents).mkdir("playlists");
        QDir(documents + "/playlists").mkdir("audio");
        QDir(documents + "/playlists").mkdir("chords");
        QDir(documents + "/playlists").mkdir("lyrics");
        QFile::copy(":/playlists/mysetlist.csv",documents + "/playlists/example.csv") ;
        QFile::copy(":/playlists/audio/onemore.mp3",documents + "/playlists/audio/onemore.mp3") ;        
        QFile::copy(":/playlists/lyrics/onemore.txt",documents + "/playlists/lyrics/onemore.txt") ;
        QFile::copy(":/playlists/lyrics/mysong.txt",documents + "/playlists/lyrics/mysong.txt") ;
        QFile::copy(":/playlists/chords/onemore.png", documents + "/playlists/chords/onemore.png") ;

        setFileAttribute(documents + "/playlists/example.csv");
        setFileAttribute(documents + "/playlists/audio/onemore.mp3");
        setFileAttribute(documents + "/playlists/lyrics/onemore.txt");
        setFileAttribute(documents + "/playlists/lyrics/mysong.txt");
        setFileAttribute(documents + "/playlists/chords/onemore.png");

#ifdef IOS
        // 20160124 Rend ces fichiers non sauvegardable sur iCloud
        backupAttrib bckAtt;
        bool statAttrib;

        setFileAttribute(documents + "/playlists/example.csv");
        setFileAttribute(documents + "/playlists/audio/onemore.mp3");
        setFileAttribute(documents + "/playlists/lyrics/onemore.txt");
        setFileAttribute(documents + "/playlists/lyrics/mysong.txt");
        setFileAttribute(documents + "/playlists/chords/onemore.png");

        statAttrib = bckAtt.setAttribExclude(documents + "/playlists/example.csv");
        statAttrib = bckAtt.setAttribExclude(documents + "/playlists/audio/onemore.mp3");
        statAttrib = bckAtt.setAttribExclude(documents + "/playlists/lyrics/onemore.txt");
        statAttrib = bckAtt.setAttribExclude(documents + "/playlists/lyrics/mysong.txt");
        statAttrib = bckAtt.setAttribExclude(documents + "/playlists/chords/onemore.png");
#endif

        firstLaunch=true;
    }


    //qDebug() << ">>>>>>>>>>>>> Kernel " << QSysInfo::productType() << QSysInfo::kernelVersion() << " Location " << documents;


    /*****
    if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {
        QSurfaceFormat f = view.format();
        f.setProfile(QSurfaceFormat::CoreProfile);
        f.setVersion(4, 4);
        view.setFormat(f);
    }
    ******/

    view.rootContext()->setContextProperty("firstLaunch",firstLaunch);
    view.rootContext()->setContextProperty("fileService",&fileservice);
    view.rootContext()->setContextProperty("internetServices",&internetservices);
    view.rootContext()->setContextProperty("deviceType",QSysInfo::productType());
    view.rootContext()->setContextProperty("screenH",screenH);
    view.rootContext()->setContextProperty("screenW",screenW);
    view.rootContext()->setContextProperty("liteMode",LiteMode);

    //20150723 Ajout de la property setlistDir
    view.rootContext()->setContextProperty("setlistDir",documents + "/playlists/");

    view.rootContext()->setContextProperty("dropBoxOperations",&dropboxOperations);
    view.rootContext()->setContextProperty("android",false);
    view.setSource(QUrl("qrc:/qml/main.qml"));


    view.setResizeMode(QQuickView::SizeRootObjectToView);

    if (QGuiApplication::platformName() == QLatin1String("qnx") ||  QGuiApplication::platformName() == QLatin1String("eglfs")) {
        view.showFullScreen();
    } else {
        view.show() ;
    }

    QObject *qmlRoot = view.rootObject() ;
    QMetaObject::invokeMethod(qmlRoot, "main");

    return app.exec();
}