コード例 #1
0
QStringList QSettingsPrivate::sysSubkeyList( const QString &key ) const
{
    QString value;
    QStringList list;

    HKEY hkey = sysd->openKey( key + "\\", KEY_ENUMERATE_SUB_KEYS, value, globalScope );
    if ( hkey ) {
        int idx = 0;
        unsigned long count = 255;
        QByteArray ba( ( count + 1 ) * sizeof( TCHAR ) );
        FILETIME time;

        while ( QT_WA_INLINE(
                    RegEnumKeyExW( hkey, idx, ( LPTSTR ) ba.data(),
                                   &count, NULL, NULL, NULL, &time ),
                    RegEnumKeyExA( hkey, idx, ( LPSTR ) ba.data(),
                                   &count, NULL, NULL, NULL, &time ) )
                == ERROR_SUCCESS ) {
            list.append ( QT_WA_INLINE( QString::fromUcs2( ( unsigned short * ) ba.data() ),
                                        QString::fromLatin1( ( LPCSTR ) ba.data() ) ) );
            idx++;
            count = 255;        /* !! */
        }
        RegCloseKey( hkey );
    }
    return list;
}
コード例 #2
0
QStringList QSettingsPrivate::sysEntryList( const QString &key ) const
{
    QString value;
    QStringList list;

    HKEY hkey = sysd->openKey( key + "\\", KEY_QUERY_VALUE, value, globalScope );
    if ( hkey ) {
        int idx = 0;
        unsigned long count = QT_WA_INLINE( 16383, 260 );
        QByteArray ba( ( count + 1 ) * sizeof( TCHAR ) );

        while ( QT_WA_INLINE(
                    RegEnumValueW( hkey, idx, ( LPTSTR ) ba.data(),
                                   &count, NULL, NULL, NULL, NULL ),
                    RegEnumValueA( hkey, idx, ( LPSTR ) ba.data(),
                                   &count, NULL, NULL, NULL, NULL ) )
                == ERROR_SUCCESS ) {
            list.append ( QT_WA_INLINE( QString::fromUcs2( ( unsigned short * ) ba.data() ),
                                        QString::fromLatin1( ( LPCSTR ) ba.data() ) ) );
            idx++;
            count = QT_WA_INLINE( 16383, 260 );        /* !! */
        }
        RegCloseKey( hkey );
    }
    return list;
}
コード例 #3
0
void QSettingsSysPrivate::searchPath( HKEY &scope, QString &path, REGSAM access, bool global, bool readonly )
{
    const HKEY scopes[ 2 ] = {
                                 HKEY_CURRENT_USER,
                                 HKEY_LOCAL_MACHINE
                             };

    for ( QStringList::Iterator it = searchPaths.fromLast(); it != searchPaths.end(); --it ) {
        QString search_key;
        HKEY res_key;
        if ( ( *it ).length() )
            search_key = "Software\\" + ( *it );
        if ( path.length() )
            search_key += "\\" + path;
        search_key = search_key.replace( QRegExp( "(\\\\)+" ), "\\" );
        /* Now try to open this key */
        int i = global ? 1 : 0;
        for ( i ; i < 2; i++ ) {
            long ret;
            if ( readonly )
                ret = QT_WA_INLINE(
                          RegOpenKeyExW( scopes[ i ], ( LPCTSTR ) search_key.ucs2(),
                                         0, access, &res_key ),
                          RegOpenKeyExA( scopes[ i ], ( LPCSTR ) search_key.latin1(),
                                         0, access, &res_key ) );
            else
                ret = QT_WA_INLINE(
                          RegCreateKeyExW( scopes[ i ], ( LPCTSTR ) search_key.ucs2(), 0,
                                           NULL, REG_OPTION_NON_VOLATILE, access, NULL,
                                           &res_key , NULL ),
                          RegCreateKeyExA( scopes[ i ], ( LPCSTR ) search_key.latin1(), 0,
                                           NULL, REG_OPTION_NON_VOLATILE, access, NULL,
                                           &res_key , NULL ) );
            /* key found :) */
            if ( ret == ERROR_SUCCESS ) {
                RegCloseKey( res_key );
                scope = scopes[ i ];
                path = search_key;
                return ;
            }
        }
    }
    /* No key found -> use first path */
    scope = global ? scopes[ 1 ] : scopes[ 0 ];
    QString new_path = searchPaths.last();
    if ( new_path.length() && path.length() )
        new_path += "\\";
    new_path += path;
    while ( new_path[ 0 ] == '\\' )
        new_path.remove( 0, 1 );
    path = new_path;
}
コード例 #4
0
QString QSettingsPrivate::sysReadEntry( const QString &key, const QString &def, bool *ok ) const
{
#ifdef QT_CHECK_STATE
    if ( key.isNull() || key.isEmpty() ) {
        qWarning( "QSettingsPrivate::sysReadEntry: invalid null/empty key." );
        if ( ok )
            * ok = FALSE;
        return def;
    }
#endif // QT_CHECK_STATE
    QString value;

    if ( ok )
        * ok = FALSE;

    HKEY hkey = sysd->openKey( key, KEY_QUERY_VALUE , value, globalScope );
    if ( hkey ) {
        unsigned long ret, len = sizeof( int );

        /* First get the size of the data */
        ret = QT_WA_INLINE(
                  RegQueryValueExW( hkey, ( LPCTSTR ) value.ucs2(), NULL, NULL, NULL, &len ),
                  RegQueryValueExA( hkey, ( LPCSTR ) value.latin1(), NULL, NULL, NULL, &len ) );
        if ( ( ret != ERROR_SUCCESS ) || ( len == 0 ) ) {
            RegCloseKey( hkey );
            return def;
        }

        /* now create buffer to store data */
        QByteArray ba( len + 1 );   /* +1 to be sure :) */

        ret = QT_WA_INLINE(
                  RegQueryValueExW( hkey, ( LPCTSTR ) value.ucs2(), NULL, NULL,
                                    ( LPBYTE ) ba.data(), &len ),
                  RegQueryValueExA( hkey, ( LPCSTR ) value.latin1(), NULL, NULL,
                                    ( LPBYTE ) ba.data(), &len ) );
        RegCloseKey( hkey );
        if ( ( ret == ERROR_SUCCESS ) ) {
            QString str;

            str = QT_WA_INLINE( QString::fromUcs2( ( unsigned short * ) ba.data() ),
                                QString::fromLatin1( ( LPCSTR ) ba.data() ) );

            if ( ok )
                * ok = true;
            return str;
        }
    }
    return def;
}
コード例 #5
0
double QSettingsPrivate::sysReadDoubleEntry( const QString &key, double def, bool * ok ) const
{
#ifdef QT_CHECK_STATE
    if ( key.isNull() || key.isEmpty() ) {
        qWarning( "QSettingsPrivate::sysReadDoubleEntry: invalid null/empty key." );
        if ( ok )
            * ok = false;
        return def;
    }
#endif // QT_CHECK_STATE
    QString value;

    if ( ok )
        * ok = false;

    HKEY hkey = sysd->openKey( key, KEY_QUERY_VALUE , value, globalScope );
    if ( hkey ) {
        double num;
        unsigned long ret, len = sizeof( double );

        ret = QT_WA_INLINE(
                  RegQueryValueExW( hkey, ( LPCTSTR ) value.ucs2(), NULL,
                                    NULL, ( LPBYTE ) & num, &len ),
                  RegQueryValueExA( hkey, ( LPCSTR ) value.latin1(), NULL,
                                    NULL, ( LPBYTE ) & num, &len ) );
        RegCloseKey( hkey );
        if ( ( ret == ERROR_SUCCESS ) && ( len == sizeof( double ) ) ) {
            if ( ok )
                * ok = true;
            return num;
        }
    }
    return def;
}
コード例 #6
0
bool QSettingsPrivate::sysWriteEntry( const QString &key, const QString &data )
{
#ifdef QT_CHECK_STATE
    if ( key.isNull() || key.isEmpty() ) {
        qWarning( "QSettingsPrivate::sysWriteEntry: invalid null/empty key." );
        return false;
    }
#endif // QT_CHECK_STATE
    long ret = -1;
    QString value;

    HKEY hkey = sysd->createKey( key, KEY_SET_VALUE , value , globalScope );
    if ( hkey ) {
        int len = ( data.length() + 1 ) * sizeof( TCHAR );
        if ( data.length() == 0 )        /* empty string! */
            len = 0;
        ret = QT_WA_INLINE(
                  RegSetValueExW( hkey, ( LPCTSTR ) value.ucs2(), 0, REG_SZ,
                                  ( LPBYTE ) data.ucs2(), len ),
                  RegSetValueExA( hkey, ( LPCSTR ) value.latin1(), 0, REG_SZ,
                                  ( LPBYTE ) data.latin1(), len ) );
        RegCloseKey( hkey );
    }
    return ( ret == ERROR_SUCCESS );
}
コード例 #7
0
ファイル: qfont_win.cpp プロジェクト: FilipBE/qtextended
// ### maybe move to qapplication_win
QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/)
{
    QString family = QT_WA_INLINE(QString::fromUtf16((ushort*)lf.lfFaceName),
                                   QString::fromLocal8Bit((char*)lf.lfFaceName));
    QFont qf(family);
    qf.setItalic(lf.lfItalic);
    if (lf.lfWeight != FW_DONTCARE) {
        int weight;
        if (lf.lfWeight < 400)
            weight = QFont::Light;
        else if (lf.lfWeight < 600)
            weight = QFont::Normal;
        else if (lf.lfWeight < 700)
            weight = QFont::DemiBold;
        else if (lf.lfWeight < 800)
            weight = QFont::Bold;
        else
            weight = QFont::Black;
        qf.setWeight(weight);
    }
    int lfh = qAbs(lf.lfHeight);
    qf.setPointSizeF(lfh * 72.0 / GetDeviceCaps(shared_dc(),LOGPIXELSY));
    qf.setUnderline(false);
    qf.setOverline(false);
    qf.setStrikeOut(false);
    return qf;
}
コード例 #8
0
ファイル: qdir_win.cpp プロジェクト: AliYousuf/abanq-port
static QString p_getenv( QString name )
{
    DWORD len = QT_WA_INLINE(
                    GetEnvironmentVariableW ( ( LPCWSTR ) qt_winTchar ( name, true ), NULL, 0 ),
                    GetEnvironmentVariableA ( ( LPCSTR ) name.ascii(), NULL, 0 ) );
    if ( len == 0 )
        return QString::null;
    /* ansi: we allocate too much memory, but this shouldn't be the problem here ... */
    LPTSTR buf = new WCHAR[ len ];
    len = QT_WA_INLINE(
              GetEnvironmentVariableW ( ( LPCWSTR ) qt_winTchar ( name, true ), buf, len ),
              GetEnvironmentVariableA ( ( LPCSTR ) name.ascii(), ( char* ) buf, len ) );
    if ( len == 0 )
        return QString::null;
    QString ret = qt_winQString ( buf );
    delete[] buf;
    return ret;
}
コード例 #9
0
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
    : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0)
{
    resolveTimerAPI();

    wakeUpNotifier.setHandle(QT_WA_INLINE(CreateEventW(0, FALSE, FALSE, 0),
                                          CreateEventA(0, FALSE, FALSE, 0)));
    if (!wakeUpNotifier.handle())
        qWarning("QEventDispatcher: Creating QEventDispatcherWin32Private wakeup event failed");
}
コード例 #10
0
QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine()
    : msg(0)
{
    HANDLE h = QT_WA_INLINE(CreateEventW(0, false, false, 0),
                                CreateEventA(0, false, false, 0));
    if (h != INVALID_HANDLE_VALUE) {
        handles.reserve(MAXIMUM_WAIT_OBJECTS);
        handles.append(h);
    }
}
コード例 #11
0
bool QSettingsPrivate::sysRemoveEntry( const QString &key )
{
    QString value;
    long ret = -1;

    HKEY hkey = sysd->openKey( key , KEY_SET_VALUE, value, globalScope );
    if ( hkey ) {
        /* This just deletes a value, not a subkey ... */
        ret = QT_WA_INLINE( RegDeleteValueW( hkey, ( LPCTSTR ) value.ucs2() ),
                            RegDeleteValueA( hkey, ( LPCSTR ) value.latin1() ) );
        RegCloseKey( hkey );
    }
    return ( ret == ERROR_SUCCESS );
}
コード例 #12
0
HKEY QSettingsSysPrivate::openKey( const QString &key, REGSAM access, QString &value , bool global )
{
    HKEY res_key = NULL;
    HKEY scope;
    QString main_key;

    splitKey( key, main_key, value );
    searchPath( scope, main_key, access, global, 1 );

    QT_WA_INLINE(
        RegOpenKeyExW( scope, ( LPCTSTR ) main_key.ucs2(), 0, access, &res_key ),
        RegOpenKeyExA( scope, ( LPCSTR ) main_key.latin1(), 0, access, &res_key ) );

    return res_key;
}
コード例 #13
0
HKEY QSettingsSysPrivate::createKey( const QString &key, REGSAM access, QString &value , bool global )
{
    HKEY res_key = NULL;
    HKEY scope;
    QString main_key;

    splitKey( key, main_key, value );
    searchPath( scope, main_key, access, global, 0 );

    QT_WA_INLINE(
        RegCreateKeyExW( scope, ( LPCTSTR ) main_key.ucs2(), 0, NULL,
                         REG_OPTION_NON_VOLATILE, access, NULL, &res_key , NULL ),
        RegCreateKeyExA( scope, ( LPCSTR ) main_key.latin1(), 0, NULL,
                         REG_OPTION_NON_VOLATILE, access, NULL, &res_key , NULL ) );

    return res_key;
}
コード例 #14
0
int QPrintDialogPrivate::openWindowsPrintDialogModally()
{
    Q_Q(QPrintDialog);
    QWidget *parent = q->parentWidget();
    if (parent)
        parent = parent->window();
    else
        parent = qApp->activeWindow();

    QWidget modal_widget;
    modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
    modal_widget.setParent(parent, Qt::Window);
    QApplicationPrivate::enterModal(&modal_widget);

    HGLOBAL *tempDevNames = ep->createDevNames();

    bool result;
    bool done;
    void *pd = QT_WA_INLINE(
        (void*)(qt_win_make_PRINTDLG<PRINTDLGW, DEVMODEW>(parent, q, this, tempDevNames)),
        (void*)(qt_win_make_PRINTDLG<PRINTDLGA, DEVMODEA>(parent, q, this, tempDevNames))
        );

    do {
        done = true;
        QT_WA({
            PRINTDLGW *pdw = reinterpret_cast<PRINTDLGW *>(pd);
            result = PrintDlgW(pdw);
            if ((pdw->Flags & PD_PAGENUMS) && (pdw->nFromPage > pdw->nToPage))
                done = false;
            if (result && pdw->hDC == 0)
                result = false;
            else if (!result)
                done = true;
        }, {
            PRINTDLGA *pda = reinterpret_cast<PRINTDLGA *>(pd);
            result = PrintDlgA(pda);
            if ((pda->Flags & PD_PAGENUMS) && (pda->nFromPage > pda->nToPage))
                done = false;
            if (result && pda->hDC == 0)
                result = false;
            else if (!result)
                done = true;
        });
コード例 #15
0
ファイル: qlibrary_win.cpp プロジェクト: AliYousuf/abanq-port
bool QLibraryPrivate::loadLibrary()
{
    if ( pHnd )
        return TRUE;

    QString filename = library->library();

    pHnd = QT_WA_INLINE( LoadLibraryExW( ( LPCWSTR ) filename.ucs2(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH ),
                         LoadLibraryExA( ( LPCSTR )filename.latin1(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH ) );

#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)

    if ( !pHnd )
        qWarning( "LoadLibrary(%s) failed with error %i",
                  library->library().latin1(), GetLastError() );
#endif

    return pHnd != 0;
}
コード例 #16
0
ファイル: qthread_win.cpp プロジェクト: Fale/qtmoko
/*! \internal
    Adds an adopted thread to the list of threads that Qt watches to make sure
    the thread data is properly cleaned up. This function starts the watcher
    thread if necessary.
*/
void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
{
    QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
    qt_adopted_thread_handles.append(adoptedThreadHandle);
    qt_adopted_qthreads.append(qthread);

    // Start watcher thread if it is not already running.
    if (qt_adopted_thread_watcher_handle == 0) {
        if (qt_adopted_thread_wakeup == 0) {
            qt_adopted_thread_wakeup = QT_WA_INLINE(CreateEventW(0, false, false, 0),
                                                    CreateEventA(0, false, false, 0));
            qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup);
        }

        qt_adopted_thread_watcher_handle =
            (HANDLE)_beginthread(qt_adopted_thread_watcher_function, 0, NULL);
    } else {
        SetEvent(qt_adopted_thread_wakeup);
    }
}
コード例 #17
0
QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object)
    : hIcon(0), q(object)
{
    currentShellVersion = detectShellVersion();
    notifyIconSizeA = FIELD_OFFSET(NOTIFYICONDATAA, szTip[64]); // NOTIFYICONDATAA_V1_SIZE
    notifyIconSizeW = FIELD_OFFSET(NOTIFYICONDATAW, szTip[64]); // NOTIFYICONDATAW_V1_SIZE;
    maxTipLength = 64;

#if NOTIFYICON_VERSION >= 3
    if (currentShellVersion >=5) {
        notifyIconSizeA = FIELD_OFFSET(NOTIFYICONDATAA, guidItem); // NOTIFYICONDATAA_V2_SIZE
        notifyIconSizeW = FIELD_OFFSET(NOTIFYICONDATAW, guidItem); // NOTIFYICONDATAW_V2_SIZE;
        maxTipLength = 128;
    }
#endif

    // For restoring the tray icon after explorer crashes
    if (!MYWM_TASKBARCREATED) {
        MYWM_TASKBARCREATED = QT_WA_INLINE(RegisterWindowMessageW(L"TaskbarCreated"),RegisterWindowMessageA("TaskbarCreated"));
    }
}
コード例 #18
0
ファイル: main.cpp プロジェクト: Fale/qtmoko
    virtual QVariant defaultValue(const QApplicationArgument &argument) const
    {
        if(argument.name() == QLatin1String("output"))
        {
            QFile *const out = new QFile();

#ifdef Q_OS_WIN
            /* If we don't open stdout in "binary" mode on Windows, it will translate
             * 0xA into 0xD 0xA. See Trolltech task 173619, for an example. */
            _setmode(_fileno(stdout), _O_BINARY);
            m_stdout = QT_WA_INLINE(_wfdopen(_fileno(stdout), L"wb"),_fdopen(_fileno(stdout), "wb"));
            out->open(m_stdout, QIODevice::WriteOnly);
#else
            out->open(stdout, QIODevice::WriteOnly);
#endif

            return qVariantFromValue(static_cast<QIODevice *>(out));
        }
        else
            return QApplicationArgumentParser::defaultValue(argument);
    }
コード例 #19
0
bool QSettingsPrivate::sysWriteEntry( const QString &key, int data )
{
#ifdef QT_CHECK_STATE
    if ( key.isNull() || key.isEmpty() ) {
        qWarning( "QSettingsPrivate::sysWriteEntry: invalid null/empty key." );
        return false;
    }
#endif // QT_CHECK_STATE
    long ret = -1;
    QString value;

    HKEY hkey = sysd->createKey( key, KEY_SET_VALUE , value , globalScope );
    if ( hkey ) {
        ret = QT_WA_INLINE(
                  RegSetValueExW( hkey, ( LPCTSTR ) value.ucs2(), 0, REG_DWORD,
                                  ( LPBYTE ) & data, sizeof( int ) ),
                  RegSetValueExA( hkey, ( LPCSTR ) value.latin1(), 0, REG_DWORD,
                                  ( LPBYTE ) & data, sizeof( int ) ) );
        RegCloseKey( hkey );
    }
    return ( ret == ERROR_SUCCESS );
}