Пример #1
0
/*
 * Returns the screen size.
 */
JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenSize
(JNIEnv *env, jobject obj)
{
  QDesktopWidget *d = QApplication::desktop();
  QSize s = d->size();
  return makeDimension( env, &s );
}
Пример #2
0
MainWindow::MainWindow()
: QMainWindow(0)
, m_statusBarLabel(0)
, m_uiActions(0)
{
    setupUi(this);
    setupActions();
    setState(core::GUI_STATE_STOPPED);
    m_statusBarLabel = new QLabel;
    statusBar()->addPermanentWidget(m_statusBarLabel);

    connect(mainWidget, SIGNAL(itemCountChanged(int)),
             this, SLOT(itemCountUpdate(int)));
    connect(mainWidget, SIGNAL(romDoubleClicked(QString, unsigned int)),
             this, SLOT(romOpen(QString, unsigned int)));

    QSize size(core::config_get_number("MainWindowWidth",600),
               core::config_get_number("MainWindowHeight",400));
    QPoint position(core::config_get_number("MainWindowXPosition",0),
                    core::config_get_number("MainWindowYPosition",0));

    QDesktopWidget *d = QApplication::desktop();
    QSize desktop = d->size();

    if (position.x() > desktop.width()) {
        position.setX(0);
    }
    if (position.y() > desktop.height()) {
        position.setY(0);
    }

    if (size.width() > desktop.width()) {
        size.setWidth(600);
    }
    if (size.height() > desktop.height()) {
        size.setHeight(400);
    }

    if ((position.x() + size.width()) > desktop.width()) {
        position.setX(desktop.width() - size.width());
    }
    if ((position.y()+size.height())>desktop.height()) {
        position.setY(desktop.height() - size.height());
    }

    resize(size);
    move(position);
}
/*!
    \fn ViewerWidget::loadImage(int file_index)
    \param file_index index to QStringList files
    load files[file_index] into a texture object if it is not already cached
 */
Texture* ViewerWidget::loadImage(int file_index)
{
    int imod = file_index%CACHESIZE; //index for cache
    if (cache[imod].file_index==file_index)
    {
        //image is already cached
        kDebug() << "image " << file_index << " is already in cache@" << imod ;
        return cache[imod].texture;

    }
    else
    {
        // image is net yet loaded
        QString f = files[file_index];
        kDebug() << "loading image " << f << "(idx=" << file_index << ") to cache@" << imod ;
        cache[imod].file_index=file_index;

        //when loadImage is called the first time, the frame is not yet fullscreen
        QSize size;
        if (firstImage)
        {
            //determine screensize since its not yet known by the widget
            QDesktopWidget dw;
            QRect r = dw.screenGeometry(this);
            size    = dw.size();
            //kDebug() << "first image:size=" << size.width();
        }
        else
        {
            size = QSize(width(),height());
            //kDebug() << "next image:size=" << size.width();
        }

        // handle non-loadable images
        if (!cache[imod].texture->load(f,size,tex[0]))
        {
            cache[imod].texture->load(nullImage,size,tex[0]);
        }

        cache[imod].texture->setViewport(size.width(),size.height());
        return cache[imod].texture;
    }
}
Пример #4
0
void Widget::on_buttonFullscreen_clicked()
{
    static QSize oldSize;
    static QPoint oldPosition;
    static bool isFullScreen = false;
    QString str;
    QPixmap pixmap;

    if (isFullScreen == true) {
        ui->frameToolbar->show();
        ui->frameBottom->show();
        showNormal();
        ui->viewArea->resize(oldSize);
        ui->viewArea->move(oldPosition);
        str = currentImages.at(currentIndex)->getPathString();
        pixmap = QPixmap(str).scaled(oldSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        currentImage->setPixmap(pixmap);
        isFullScreen = false;

        if (timerId != 0)
            killTimer(timerId);

    } else {
        oldSize = ui->viewArea->size();
        oldPosition = ui->viewArea->pos();

        QDesktopWidget *desktop = QApplication::desktop();
        QSize size = desktop->size();
        ui->frameToolbar->hide();
        ui->frameBottom->hide();
        showFullScreen();
        ui->viewArea->resize(size);
        ui->viewArea->move(0, 0);
        str = currentImages.at(currentIndex)->getPathString();
        pixmap = QPixmap(str).scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        currentImage->setPixmap(pixmap);
        isFullScreen = true;
    }
}