Ejemplo n.º 1
0
void DlgPreferences::onShow() {
    //
    // Read last geometry (size and position) of preferences panel
    // Bug#1299949
    //
    // init m_geometry
    if (m_geometry.length() < 4) {
        // load default values (optimum size)
        QRect defaultGeometry = getDefaultGeometry();
        QString defaultGeometryStr = QString("%1,%2,%3,%4")
                                          .arg(defaultGeometry.left())
                                            .arg(defaultGeometry.top())
                                            .arg(defaultGeometry.width())
                                            .arg(defaultGeometry.height());

        // get last geometry OR use default values from
        m_geometry = m_pConfig->getValueString(
                    ConfigKey("[Preferences]", "geometry"),
                    defaultGeometryStr).split(",");
    }

    // Update geometry with last values
    setGeometry(m_geometry[0].toInt(),  // x position
                m_geometry[1].toInt(),  // y position
                m_geometry[2].toInt(),  // width
                m_geometry[3].toInt()); // heigth

    // Notify children that we are about to show.
    emit(showDlg());
}
Ejemplo n.º 2
0
bool X11Factory::init()
{
    // make sure xlib is safe-thread
    if( !vlc_xlib_init( VLC_OBJECT( getIntf() ) ) )
    {
        msg_Err( getIntf(), "initializing xlib for multi-threading failed" );
        return false;
    }

    // Create the X11 display
    m_pDisplay = new X11Display( getIntf() );

    // Get the display
    Display *pDisplay = m_pDisplay->getDisplay();
    if( pDisplay == NULL )
    {
        // Initialization failed
        return false;
    }

    // Create the timer loop
    m_pTimerLoop = new X11TimerLoop( getIntf(),
                                     ConnectionNumber( pDisplay ) );

    // Initialize the resource path
    char *datadir = config_GetUserDir( VLC_DATA_DIR );
    m_resourcePath.push_back( (std::string)datadir + "/skins2" );
    free( datadir );
    m_resourcePath.push_back( (std::string)"share/skins2" );
    datadir = config_GetDataDir();
    m_resourcePath.push_back( (std::string)datadir + "/skins2" );
    free( datadir );

    // Determine the monitor geometry
    getDefaultGeometry( &m_screenWidth, &m_screenHeight );

    // list all available monitors
    int num_screen;
    XineramaScreenInfo* info = XineramaQueryScreens( pDisplay, &num_screen );
    if( info )
    {
        msg_Dbg( getIntf(), "number of monitors detected : %i", num_screen );
        for( int i = 0; i < num_screen; i++ )
            msg_Dbg( getIntf(), "  monitor #%i : %ix%i at +%i+%i",
                                i, info[i].width, info[i].height,
                                info[i].x_org, info[i].y_org );
        XFree( info );
    }

    return true;
}
Ejemplo n.º 3
0
void DlgPreferences::onShow() {
    // init m_geometry
    if (m_geometry.length() < 4) {
        // load default values (optimum size)
        m_geometry = m_pConfig->getValue(
                    ConfigKey("[Preferences]", "geometry")).split(",");
        if (m_geometry.length() < 4) {
            // Warning! geometry does NOT include the frame/title.
            QRect defaultGeometry = getDefaultGeometry();
            m_geometry.clear();
            m_geometry.append(QString::number(defaultGeometry.left()));
            m_geometry.append(QString::number(defaultGeometry.top()));
            m_geometry.append(QString::number(defaultGeometry.width()));
            m_geometry.append(QString::number(defaultGeometry.height()));
        }
    }
    int newX = m_geometry[0].toInt();
    int newY = m_geometry[1].toInt();
    newX = std::max(0, std::min(newX, QApplication::desktop()->screenGeometry().width()- m_geometry[2].toInt()));
    newY = std::max(0, std::min(newY, QApplication::desktop()->screenGeometry().height() - m_geometry[3].toInt()));
    m_geometry[0] = QString::number(newX);
    m_geometry[1] = QString::number(newY);

    // Update geometry with last values
#ifdef __WINDOWS__
    resize(m_geometry[2].toInt(), m_geometry[3].toInt());
#else
    // On linux, when the window is opened for the first time by the window manager, QT does not have
    // information about the frame size so the offset is zero. As such, the first time it opens the window
    // does not include the offset, so it is moved from the last position it had.
    // Excluding the offset from the saved value tries to fix that.
    int offsetX = geometry().left() - frameGeometry().left();
    int offsetY = geometry().top() - frameGeometry().top();
    newX += offsetX;
    newY += offsetY;
    setGeometry(newX,  // x position
                newY,  // y position
                m_geometry[2].toInt(),  // width
                m_geometry[3].toInt()); // height
#endif
    // Move is also needed on linux.
    move(newX, newY);

    // Notify children that we are about to show.
    emit(showDlg());
}