Пример #1
0
WormEngine::WormEngine(QObject *parent) :
    QObject(parent)
{
    QScreen* screen = QGuiApplication::primaryScreen();
    m_pagewidth = screen->size().width();
    m_pageheight = screen->size().height();

    m_isPaused = true;
    m_gameOver = false;
    m_finish = false;
    m_theend = false;
    m_pauseMenu = false;
    bodyr = m_pagewidth/13.5;

    for (int i = 0; i < 6; i++) {
        WormBody *wormBody = new WormBody((m_pagewidth/3.375)+i*(m_pagewidth/10.8), m_pageheight/2.4);
        m_wormBody.append(wormBody);
    }

    m_updater.setInterval(50);
    connect(&m_updater, SIGNAL(timeout()), this, SLOT(update()));
    m_updater.start();
    lowPx = m_pagewidth/20;
    highPx = m_pagewidth/1.04;
    lowPy = m_pageheight/48;
    highPy = m_pageheight/1.3;
    m_apples = 0;
    distCounter = 0;
    newFoodPos();
}
Пример #2
0
void Menu::scaling()
{
    QScreen *screen = QApplication::screens().at(0);
    screenHeight = screen->size().height();
    screenWidth = screen->size().width();

    /* Временные размеры экрана для тестирования
    screenWidth = 480;
    screenHeight = 800;
    */

    xScaleMultiplier = static_cast<double>(screenWidth) / defaultScreenWidth;
    yScaleMultiplier = static_cast<double>(screenHeight) / defaultScreenHeight;
}
void BleWindowsCaptureSource::run()
{
    // TODO make could select screen
    // QGuiApplication::screens();
    while (!m_stop) {
        QElapsedTimer elapsedTimer;
        elapsedTimer.start();

        QScreen *screen = QGuiApplication::primaryScreen();

        if (screen) {
            QPixmap pixmap = screen->grabWindow(m_wid, m_x, m_y, m_width, m_height);
#if 1
            // TODO to draw cursor to image
            QRect desktopRect = QRect(QPoint(0, 0), screen->size());
            if (desktopRect.contains(QCursor::pos())) {
                drawCursor(&pixmap);
            }
#endif
            QImage image = pixmap.toImage();

            m_modifyMutex.lock();           // Start lock

            BleImage be;
            be.width = image.width();
            be.height = image.height();

            int imageSize = be.width * be.height * 3;
            be.data = new char[imageSize];

            IplImage *oriImage = cvCreateImageHeader(cvSize(image.width(), image.height()), IPL_DEPTH_8U, 4);
            cvSetData(oriImage, image.bits(), image.bytesPerLine());

            IplImage *dstImage = cvCreateImageHeader(cvSize(image.width(), image.height()), IPL_DEPTH_8U, 3);
            cvSetData(dstImage, be.data, be.width * 3);

            cvCvtColor(oriImage, dstImage, CV_BGRA2BGR);

            be.dataSize = imageSize;
            be.format = BleImage_Format_BGR24;

            m_image = be;

            cvReleaseImageHeader(&oriImage);
            cvReleaseImageHeader(&dstImage);

            m_modifyMutex.unlock();        // End unlock
        }

        int elapsedMs = elapsedTimer.elapsed();
        int needSleepMs = m_interval - elapsedMs;
        if (needSleepMs < 0) {
            needSleepMs = 0;
        }
        msleep(needSleepMs);
    }

    log_trace("BleWindowsCaptureSource exit normally.");
}
Пример #4
0
QSize AsemanDevices::screenSize() const
{
    if( QGuiApplication::screens().isEmpty() )
        return QSize();

    QScreen *scr = QGuiApplication::screens().first();
    return scr->size();
}
Пример #5
0
qreal AsemanDevices::lcdPhysicalHeight() const
{
    if( QGuiApplication::screens().isEmpty() )
        return 0;

    QScreen *scr = QGuiApplication::screens().first();
    return (qreal)scr->size().height()/scr->physicalDotsPerInchY();
}
Пример #6
0
void DesktopCaptureElement::readFrame()
{
    QScreen *screen = QGuiApplication::screens()[this->m_curScreenNumber];
    AkFrac fps(30000, 1001);

    AkVideoCaps caps;
    caps.isValid() = true;
    caps.format() = AkVideoCaps::Format_rgb24;
    caps.bpp() = AkVideoCaps::bitsPerPixel(caps.format());
    caps.width() = screen->size().width();
    caps.height() = screen->size().height();
    caps.fps() = fps;

    QPixmap frame = screen->grabWindow(QApplication::desktop()->winId());
    QImage frameImg= frame.toImage().convertToFormat(QImage::Format_RGB888);
    AkPacket packet = AkUtils::imageToPacket(frameImg, caps.toCaps());

    if (!packet)
        return;

    qint64 pts = qint64(QTime::currentTime().msecsSinceStartOfDay()
                        * fps.value() / 1e3);

    packet.setPts(pts);
    packet.setTimeBase(fps.invert());
    packet.setIndex(0);
    packet.setId(this->m_id);

    if (!this->m_threadedRead) {
        emit this->oStream(packet);

        return;
    }

    if (!this->m_threadStatus.isRunning()) {
        this->m_curPacket = packet;

        this->m_threadStatus = QtConcurrent::run(&this->m_threadPool,
                                                 this->sendPacket,
                                                 this,
                                                 this->m_curPacket);
    }
}
Пример #7
0
void Theme::initDisplays()
{
#ifdef QT_DEBUG
    m_displays = {
        { "iPhone 4 (4, 4S)", 960, 640, 12.83464566929 },
        { "Galaxy SIII", 1280, 720, 12.04724409449 },
        { "iPhone 5 (5c, 5s)", 1136, 640, 12.83464566929 },
        { "Galaxy SII", 800, 480, 8.622047244094 },
        { "Google Nexus 4 by LG", 1280, 768, 12.59842519685 },
        { "Google Nexus 5 by LG", 1920, 1080, 17.36220472441 },
        { "Galaxy Nexus", 1280, 720, 12.44094488189 },
        { "Galaxy SIV", 1920, 1080, 17.36220472441 },
        { "Galaxy S Plus", 800, 480, 9.173228346457 },
        { "Galaxy Note II", 1280, 720, 10.51181102362 },
        { "Galaxy S Plus", 800, 480, 9.173228346457 },
        { "Galaxy Note", 1280, 800, 11.22047244094 },
        { "Nokia Lumia 925", 1280, 768, 13.07086614173 },
        { "iPhone (Original - 3GS)", 480, 320, 12.59842519685 },
        { "Nokia Lumia 920", 1280, 768, 13.07086614173 },
        { "Nokia Lumia (710, 800)", 800, 480, 9.92125984252 },
        { "Test", 800, 480, 15.7874015748 },
        { "Nokia Lumia 900", 800, 480, 8.543307086614 },
        { "Nokia Lumia 620", 800, 480, 9.685039370079 },
        { "Nokia Lumia 720", 800, 480, 8.543307086614 },
        { "HTC One", 1920, 1080, 18.42519685039 },
        { "Droid Razr", 960, 540, 10.07874015748 },
        { "Droid 3 & 4", 960, 540, 11.02362204724 },
        { "Droid", 854, 480, 10.43307086614 },
        { "Sony Xperia Z", 1920, 1080, 17.36220472441 },
        { "BlackBerry Q10", 720, 720, 12.99212598425 },
        { "BlackBerry Z10", 1280, 768, 14.0157480315 },
        { "Alcatel One Touch Idol Ultra", 1280, 720, 12.44094488189 },
        { "Samsung Nexus S", 800, 480, 9.251968503937 },
        { "iPhone 6+", 1920, 1080, 15.7874015748 },
        { "iPhone 6", 1334, 750, 12.83464566929 }
    };
#else
    QScreen *screen = qApp->primaryScreen();
    Q_ASSERT(screen);
    m_displays = {{ "", screen->size().height(), screen->size().width(), screen->physicalDotsPerInch() * 0.03937007874016 }};
#endif
}
Пример #8
0
AkCaps DesktopCaptureElement::caps(int stream) const
{
    if (this->m_curScreenNumber < 0
        || stream != 0)
        return AkCaps();

    QScreen *screen = QGuiApplication::screens()[this->m_curScreenNumber];

    if (!screen)
        return QString();

    AkVideoCaps caps;
    caps.isValid() = true;
    caps.format() = AkVideoCaps::Format_rgb24;
    caps.bpp() = AkVideoCaps::bitsPerPixel(caps.format());
    caps.width() = screen->size().width();
    caps.height() = screen->size().height();
    caps.fps() = this->m_fps;

    return caps.toCaps();
}
Пример #9
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    QScreen *screen = QApplication::primaryScreen();
    QSize screenSize = screen->size();

    ui->setupUi(this);

    resize(screenSize.width() * .75, screenSize.height() * .75);
    move((screenSize.width() - width())/2, (screenSize.height() - height())/2);
}
Пример #10
0
int main(int argc, char *argv[])
{
    installLogcatMessageHandler("ImageProcessor");
    QApplication a(argc, argv);
    SimpleCustomEvent::eventType();
#ifdef Q_OS_ANDROID
    registerNativeMethods();
#endif
    makeTempPath();
    Widget w;
#ifdef Q_OS_ANDROID
    g_listener = (QObject*)&w;
#endif
    QScreen *screen = a.primaryScreen();
    w.setMaximumSize(screen->size());
    w.show();

    return a.exec();
}
void BleWindowsCaptureSource::run()
{
    // TODO make could select screen
    // QGuiApplication::screens();
    while (!m_stop) {
        QElapsedTimer elapsedTimer;
        elapsedTimer.start();

        // TODO make this to option
        // option: could select screen
        QScreen *screen = QGuiApplication::primaryScreen();

        if (screen) {
            QPixmap pixmap = screen->grabWindow(m_wid, m_x, m_y, m_width, m_height);

            // TODO make this to option
#if 1
            QRect desktopRect = QRect(QPoint(0, 0), screen->size());
            if (desktopRect.contains(QCursor::pos())) {
                drawCursor(&pixmap);
            }
#endif
            m_modifyMutex.lock();           // Start lock
            m_image = pixmap.toImage();
            m_modifyMutex.unlock();
        }

        int elapsedMs = elapsedTimer.elapsed();
        int needSleepMs = m_interval - elapsedMs;
        if (needSleepMs < 0) {
            needSleepMs = 0;
        }
        msleep(needSleepMs);
    }

    log_trace("BleWindowsCaptureSource exit normally.");
}
Пример #12
0
void Wpp::realOnKeyboardVisibleChanged()
{
#if defined(Q_OS_IOS) || defined(Q_OS_ANDROID)
	qDebug() << __FUNCTION__;
	//#ifdef Q_OS_IOS
				QScreen *screen = QGuiApplication::primaryScreen();
				QWindow *window = QGuiApplication::focusWindow();
				QInputMethod *inputMethod = QGuiApplication::inputMethod();
				if ( inputMethod->isVisible() )
				{
					if ( m_softInputMode == ADJUST_RESIZE && window != 0 && screen != 0 )
					{
	#ifdef Q_OS_IOS
						QRectF kbRect = inputMethod->keyboardRectangle();
	#endif
	#ifdef Q_OS_ANDROID
						/*
						Rect r = new Rect();
						View rootview = this.getWindow().getDecorView(); // this = activity
						rootview.getWindowVisibleDisplayFrame(r);
						*/
						QAndroidJniObject visibleFrameRect("android/graphics/Rect","()V");
						qDebug() << __FUNCTION__ << "visibleFrameRect.isValid()=" << visibleFrameRect.isValid();

						QAndroidJniObject activity = QtAndroid::androidActivity();
						qDebug() << __FUNCTION__ << "activity.isValid()=" << activity.isValid();

						QAndroidJniObject androidWindow = activity.callObjectMethod(
									"getWindow","()Landroid/view/Window;");
						qDebug() << __FUNCTION__ << "androidWindow.isValid()=" << androidWindow.isValid();

						QAndroidJniObject rootview = androidWindow.callObjectMethod(
									"getDecorView","()Landroid/view/View;");
						qDebug() << __FUNCTION__ << "rootview.isValid()=" << rootview.isValid();

						//rootview.callMethod<void>("getWindowVisibleDisplayFrame","(Landroid/graphics/Rect;)V",visibleFrameRect.object<jobject>());
						rootview.callMethod<jboolean>("getLocalVisibleRect","(Landroid/graphics/Rect;)Z",visibleFrameRect.object<jobject>());
						qDebug() << __FUNCTION__ << "rootview.isValid()=" << rootview.isValid();
						qDebug() << __FUNCTION__ << "visibleFrameRect.isValid()=" << visibleFrameRect.isValid();

						jint visibleFrameTop = visibleFrameRect.getField<jint>("top");
						qDebug() << __FUNCTION__ << "visibleFrameRect.visibleFrameTop=" << visibleFrameTop;
						jint visibleFrameLeft = visibleFrameRect.getField<jint>("left");
						qDebug() << __FUNCTION__ << "visibleFrameRect.visibleFrameLeft=" << visibleFrameLeft;
						jint visibleFrameWidth = visibleFrameRect.callMethod<jint>("width","()I");
						qDebug() << __FUNCTION__ << "visibleFrameRect.width()=" << visibleFrameWidth;
						jint visibleFrameHeight = visibleFrameRect.callMethod<jint>("height","()I");
						qDebug() << __FUNCTION__ << "visibleFrameRect.height()=" << visibleFrameHeight;

						int keyboardHeight = 0;
						if ( screen != 0 )
						{
							qDebug() << __FUNCTION__ << "screen.height()=" << screen->size().height();
							keyboardHeight = screen->size().height() - visibleFrameHeight;
							qDebug() << __FUNCTION__ << "keyboardHeight=" << keyboardHeight;
						}
						QRectF kbRect(0, visibleFrameHeight, visibleFrameWidth, keyboardHeight);//assume keyboard from bottom side
	#endif
						qDebug() << __FUNCTION__ << "kbRect=" << kbRect;

						window->showNormal();
						if ( window->height() == screen->size().height() )
						{
							qDebug() << __FUNCTION__ << ":origSize=" << window->size();

							Q_ASSERT( kbRect.width() == (qreal)window->width() );//assume keyboard appears from bottom side of app window

							window->setHeight( window->height() - kbRect.height() );
							qDebug() << __FUNCTION__ << ":resize-ok-to:" << window->size();
						}

					}

				}
				else
				{
					if ( m_softInputMode == ADJUST_RESIZE && window != 0 && screen != 0 )
					{
						window->setHeight( screen->size().height() );
						qDebug() << __FUNCTION__ << ":resize-ok-to:" << screen->size();
					}
					window->showNormal();
				}
	//#endif
#endif
}
Пример #13
0
    void Reply(QTcpSocket *client )
    {
        QString line;
        line = readLine( client );
        if (line.length() > 0)
        {
            if (line.contains("val"))
            {
                writeLine( client, QString("HTTP/1.1 200 OK\r\nContent-Type: text/html \r\n\r\n") );
                for (int i=0; i<10; i++)
                {
                    for (int j=0; j<10; j++)
                    {
                        writeLine( client, QString::number(i*10+j - 4 + GetTickCount()%8 ) );
                        writeLine( client, ",");
                    }
                }
            }
            else if (line.contains("label"))
            {
                writeLine( client, QString("HTTP/1.1 200 OK\r\nContent-Type: text/html \r\n\r\n") );
                for (int i=0; i<10; i++)
                {
                    for (int j=0; j<10; j++)
                    {
                        writeLine( client, "lab_" + QString::number(i*10+j) );
                        writeLine( client, ",");
                    }
                }
            }
            else if (line.contains("@img"))
            {
                //win
                //QPixmap pm( QPixmap::grabWidget( this ) );
                //pm.save("\\screen.png");

                QFile transferedFile("\\screen.png");
                transferedFile.open(QIODevice::ReadOnly);

                writeLine( client, QString("HTTP/1.1 200 OK\r\nContent-Type: image/png \r\n\r\n") );
                QByteArray block = transferedFile.readAll();
                client->write(block);
                writeLine( client, QDateTime::currentDateTime().toString() );

                // screenshot
                QScreen *QSCREEN = QGuiApplication::primaryScreen();
                QPixmap qpix = QSCREEN->grabWindow( 0, 0, 0, QSCREEN->size().width(), QSCREEN->size().height() );
                qpix.save("\\screen.png");
            }
            else if (line.contains("@live"))
            {
                writeLine( client, QString("HTTP/1.1 200 OK\r\nContent-Type: text/html \r\n\r\n") );
                writeLine( client, QString("<html>" "\r\n"
                                           "<head>""\r\n"
                                           "\r\n"
                                           "<script src='http://code.jquery.com/jquery-latest.js'></script>"
                                           "<script>""\r\n"
                                           "$(document).ready(function(){""\r\n"
                                           "setInterval(timedRefresh, 1000);""\r\n"
                                           " });""\r\n"
                                           "function timedRefresh(timeoutPeriod) {""\r\n"
                                           "var d = new Date();""\r\n"
                                           "$('img').attr('src', $('img').attr('src') + '?_=' + d.getMilliseconds());""\r\n"
                                           "}""\r\n"
                                           "</script>""\r\n"
                                           "\r\n"
                                           "</head>""\r\n""\r\n"
                                           "<body onload='JavaScript:timedRefresh(1000);'>""\r\n"
                                           "<img src='/@img' alt='connection Error' />""\r\n"
                                           "</body>""\r\n"
                                           "</html>""\r\n"
                                           ));
            }
            else
            {
                writeLine( client, QDateTime::currentDateTime().toString() );
            }

        }
    }
AutoConfigVideoPage::AutoConfigVideoPage(QWidget *parent)
	: QWizardPage (parent),
	  ui          (new Ui_AutoConfigVideoPage)
{
	ui->setupUi(this);

	setTitle(QTStr("Basic.AutoConfig.VideoPage"));
	setSubTitle(QTStr("Basic.AutoConfig.VideoPage.SubTitle"));

	obs_video_info ovi;
	obs_get_video_info(&ovi);

	long double fpsVal =
		(long double)ovi.fps_num / (long double)ovi.fps_den;

	QString fpsStr = (ovi.fps_den > 1)
		? QString::number(fpsVal, 'f', 2)
		: QString::number(fpsVal, 'g', 2);

	ui->fps->addItem(QTStr(FPS_PREFER_HIGH_FPS),
			(int)AutoConfig::FPSType::PreferHighFPS);
	ui->fps->addItem(QTStr(FPS_PREFER_HIGH_RES),
			(int)AutoConfig::FPSType::PreferHighRes);
	ui->fps->addItem(QTStr(FPS_USE_CURRENT).arg(fpsStr),
			(int)AutoConfig::FPSType::UseCurrent);
	ui->fps->addItem(QStringLiteral("30"), (int)AutoConfig::FPSType::fps30);
	ui->fps->addItem(QStringLiteral("60"), (int)AutoConfig::FPSType::fps60);
	ui->fps->setCurrentIndex(0);

	QString cxStr = QString::number(ovi.base_width);
	QString cyStr = QString::number(ovi.base_height);

	int encRes = int(ovi.base_width << 16) | int(ovi.base_height);
	ui->canvasRes->addItem(QTStr(RES_USE_CURRENT).arg(cxStr, cyStr),
			(int)encRes);

	QList<QScreen*> screens = QGuiApplication::screens();
	for (int i = 0; i < screens.size(); i++) {
		QScreen *screen = screens[i];
		QSize as = screen->size();

		encRes = int(as.width() << 16) | int(as.height());

		QString str = QTStr(RES_USE_DISPLAY)
			.arg(QString::number(i + 1),
			     QString::number(as.width()),
			     QString::number(as.height()));

		ui->canvasRes->addItem(str, encRes);
	}

	auto addRes = [&] (int cx, int cy)
	{
		encRes = (cx << 16) | cy;
		QString str = QString("%1x%2").arg(
				QString::number(cx),
				QString::number(cy));
		ui->canvasRes->addItem(str, encRes);
	};

	addRes(1920, 1080);
	addRes(1280, 720);

	ui->canvasRes->setCurrentIndex(0);
}
Пример #15
0
void MainWindow::addPlaylistHashToGrid(const QVector<QHash<QString, QString> > &items)
{
   QScreen *screen = qApp->primaryScreen();
   QSize screenSize = screen->size();
   QListWidgetItem *currentItem = m_listWidget->currentItem();
   settings_t *settings = config_get_ptr();
   int i = 0;
   int zoomValue = m_zoomSlider->value();

   m_gridProgressBar->setMinimum(0);
   m_gridProgressBar->setMaximum(qMax(0, items.count() - 1));
   m_gridProgressBar->setValue(0);

   for (i = 0; i < items.count(); i++)
   {
      const QHash<QString, QString> &hash = items.at(i);
      QPointer<GridItem> item;
      QPointer<ThumbnailLabel> label;
      QString thumbnailFileNameNoExt;
      QLabel *newLabel = NULL;
      QSize thumbnailWidgetSizeHint(screenSize.width() / 8, screenSize.height() / 8);
      QByteArray extension;
      QString extensionStr;
      QString imagePath;
      int lastIndex = -1;

      if (m_listWidget->currentItem() != currentItem)
      {
         /* user changed the current playlist before we finished loading... abort */
         m_gridProgressWidget->hide();
         break;
      }

      item = new GridItem();

      lastIndex = hash["path"].lastIndexOf('.');

      if (lastIndex >= 0)
      {
         extensionStr = hash["path"].mid(lastIndex + 1);

         if (!extensionStr.isEmpty())
         {
            extension = extensionStr.toLower().toUtf8();
         }
      }

      if (!extension.isEmpty() && m_imageFormats.contains(extension))
      {
         /* use thumbnail widgets to show regular image files */
         imagePath = hash["path"];
      }
      else
      {
         thumbnailFileNameNoExt = hash["label_noext"];
         thumbnailFileNameNoExt.replace(m_fileSanitizerRegex, "_");
         imagePath = QString(settings->paths.directory_thumbnails) + "/" + hash.value("db_name") + "/" + THUMBNAIL_BOXART + "/" + thumbnailFileNameNoExt + ".png";
      }

      item->hash = hash;
      item->widget = new ThumbnailWidget();
      item->widget->setSizeHint(thumbnailWidgetSizeHint);
      item->widget->setFixedSize(item->widget->sizeHint());
      item->widget->setLayout(new QVBoxLayout());
      item->widget->setObjectName("thumbnailWidget");
      item->widget->setProperty("hash", QVariant::fromValue<QHash<QString, QString> >(hash));

      connect(item->widget, SIGNAL(mouseDoubleClicked()), this, SLOT(onGridItemDoubleClicked()));
      connect(item->widget, SIGNAL(mousePressed()), this, SLOT(onGridItemClicked()));

      label = new ThumbnailLabel(item->widget);
      label->setObjectName("thumbnailGridLabel");

      item->label = label;
      item->labelText = hash.value("label");

      newLabel = new QLabel(item->labelText, item->widget);
      newLabel->setObjectName("thumbnailQLabel");
      newLabel->setAlignment(Qt::AlignCenter);
      newLabel->setToolTip(item->labelText);

      calcGridItemSize(item, zoomValue);

      item->widget->layout()->addWidget(label);

      item->widget->layout()->addWidget(newLabel);
      qobject_cast<QVBoxLayout*>(item->widget->layout())->setStretchFactor(label, 1);

      m_gridLayout->addWidgetDeferred(item->widget);
      m_gridItems.append(item);

      loadImageDeferred(item, imagePath);

      if (i % 25 == 0)
      {
         /* Needed to update progress dialog while doing a lot of stuff on the main thread. */
         qApp->processEvents();
      }

      m_gridProgressBar->setValue(i);
   }

   /* If there's only one entry, a min/max/value of all zero would make an indeterminate progress bar that never ends... so just hide it when we are done. */
   if (m_gridProgressBar->value() == m_gridProgressBar->maximum())
      m_gridProgressWidget->hide();
}