⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qapplication_x11.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
// gui or non-gui from qapplication.cppextern bool qt_is_gui_used;class QETWidget : public QWidget                // event translator widget{public:    bool translateMouseEvent(const XEvent *);    void translatePaintEvent(const XEvent *);    bool translateConfigEvent(const XEvent *);    bool translateCloseEvent(const XEvent *);    bool translateScrollDoneEvent(const XEvent *);    bool translateWheelEvent(int global_x, int global_y, int delta, Qt::MouseButtons buttons,                             Qt::KeyboardModifiers modifiers, Qt::Orientation orient);#if !defined (QT_NO_TABLET)    bool translateXinputEvent(const XEvent*, const QTabletDeviceData *tablet);#endif    bool translatePropertyEvent(const XEvent *);    void doDeferredMap()    {        Q_ASSERT(testAttribute(Qt::WA_WState_Created));        if (!testAttribute(Qt::WA_Resized)) {            adjustSize();            setAttribute(Qt::WA_Resized, false);        }        /*          workaround for WM's that throw away ConfigureRequests from the following:          window->hide();          window->move(x, y); // could also be resize(), move()+resize(), or setGeometry()          window->show();        */        QPoint p = d_func()->topData()->posFromMove ? pos() : geometry().topLeft();        QSize s = size();        XMoveResizeWindow(X11->display,                          internalWinId(),                          p.x(),                          p.y(),                          s.width(),                          s.height());        setAttribute(Qt::WA_Mapped);        d_func()->topData()->waitingForMapNotify = 1;        XMapWindow(X11->display, internalWinId());    }};void QApplicationPrivate::createEventDispatcher(){    Q_Q(QApplication);#if !defined(QT_NO_GLIB)    if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())        eventDispatcher = (q->type() != QApplication::Tty                           ? new QGuiEventDispatcherGlib(q)                           : new QEventDispatcherGlib(q));    else#endif        eventDispatcher = (q->type() != QApplication::Tty                           ? new QEventDispatcherX11(q)                           : new QEventDispatcherUNIX(q));}/*****************************************************************************  Default X error handlers *****************************************************************************/#if defined(Q_C_CALLBACKS)extern "C" {#endifstatic int (*original_x_errhandler)(Display *dpy, XErrorEvent *);static int (*original_xio_errhandler)(Display *dpy);static int qt_x_errhandler(Display *dpy, XErrorEvent *err){    switch (err->error_code) {    case BadAtom:        if (err->request_code == 20 /* X_GetProperty */            && (err->resourceid == XA_RESOURCE_MANAGER                || err->resourceid == XA_RGB_DEFAULT_MAP                || err->resourceid == ATOM(_NET_SUPPORTED)                || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK)                || err->resourceid == ATOM(KDE_FULL_SESSION)                || err->resourceid == ATOM(KWIN_RUNNING)                || err->resourceid == ATOM(XdndProxy)                || err->resourceid == ATOM(XdndAware))) {            // Perhaps we're running under SECURITY reduction? :/            return 0;        }        break;    case BadWindow:        if (err->request_code == 2 /* X_ChangeWindowAttributes */            || err->request_code == 38 /* X_QueryPointer */) {            for (int i = 0; i < ScreenCount(dpy); ++i) {                if (err->resourceid == RootWindow(dpy, i)) {                    // Perhaps we're running under SECURITY reduction? :/                    return 0;                }            }        }        X11->seen_badwindow = true;        if (err->request_code == 25 /* X_SendEvent */) {            for (int i = 0; i < ScreenCount(dpy); ++i) {                if (err->resourceid == RootWindow(dpy, i)) {                    // Perhaps we're running under SECURITY reduction? :/                    return 0;                }            }            if (X11->xdndHandleBadwindow()) {                qDebug("xdndHandleBadwindow returned true");                return 0;            }        }        if (X11->ignore_badwindow)            return 0;        break;    case BadMatch:        if (err->request_code == 42 /* X_SetInputFocus */)            return 0;        break;    default:        if (err->request_code == X11->xinput_major            && err->error_code == (X11->xinput_errorbase + XI_BadDevice)            && err->minor_code == 3 /* X_OpenDevice */) {            return 0;        }        break;    }    char errstr[256];    XGetErrorText( dpy, err->error_code, errstr, 256 );    char buffer[256];    char request_str[256];    qsnprintf(buffer, 256, "%d", err->request_code);    XGetErrorDatabaseText(dpy, "XRequest", buffer, "", request_str, 256);    if (err->request_code < 128) {        // X error for a normal protocol request        qWarning( "X Error: %s %d\n"                  "  Major opcode: %d (%s)\n"                  "  Resource id:  0x%lx",                  errstr, err->error_code,                  err->request_code,                  request_str,                  err->resourceid );    } else {        // X error for an extension request        const char *extensionName = 0;        if (err->request_code == X11->xrender_major)            extensionName = "RENDER";        else if (err->request_code == X11->xrandr_major)            extensionName = "RANDR";        else if (err->request_code == X11->xinput_major)            extensionName = "XInputExtension";        char minor_str[256];        if (extensionName) {            qsnprintf(buffer, 256, "%s.%d", extensionName, err->minor_code);            XGetErrorDatabaseText(dpy, "XRequest", buffer, "", minor_str, 256);        } else {            extensionName = "Uknown extension";            qsnprintf(minor_str, 256, "Unknown request");        }        qWarning( "X Error: %s %d\n"                  "  Extension:    %d (%s)\n"                  "  Minor opcode: %d (%s)\n"                  "  Resource id:  0x%lx",                  errstr, err->error_code,                  err->request_code,                  extensionName,                  err->minor_code,                  minor_str,                  err->resourceid );    }    // ### we really should distinguish between severe, non-severe and    // ### application specific errors    return 0;}static int qt_xio_errhandler(Display *){    qWarning("%s: Fatal IO error: client killed", appName);    QApplicationPrivate::reset_instance_pointer();    exit(1);    //### give the application a chance for a proper shutdown instead,    //### exit(1) doesn't help.    return 0;}#if defined(Q_C_CALLBACKS)}#endifstatic void qt_x11_create_intern_atoms(){    const char *names[QX11Data::NAtoms];    const char *ptr = x11_atomnames;    int i = 0;    while (*ptr) {        names[i++] = ptr;        while (*ptr)            ++ptr;        ++ptr;    }    Q_ASSERT(i == QX11Data::NPredefinedAtoms);    QByteArray settings_atom_name("_QT_SETTINGS_TIMESTAMP_");    settings_atom_name += XDisplayName(X11->displayName);    names[i++] = settings_atom_name;    Q_ASSERT(i == QX11Data::NAtoms);#if defined(XlibSpecificationRelease) && (XlibSpecificationRelease >= 6)    XInternAtoms(X11->display, (char **)names, i, False, X11->atoms);#else    for (i = 0; i < QX11Data::NAtoms; ++i)        X11->atoms[i] = XInternAtom(X11->display, (char *)names[i], False);#endif}Q_GUI_EXPORT void qt_x11_apply_settings_in_all_apps(){    QByteArray stamp;    QDataStream s(&stamp, QIODevice::WriteOnly);    s << QDateTime::currentDateTime();    XChangeProperty(QX11Info::display(), QX11Info::appRootWindow(0),                    ATOM(_QT_SETTINGS_TIMESTAMP), ATOM(_QT_SETTINGS_TIMESTAMP), 8,                    PropModeReplace, (unsigned char *)stamp.data(), stamp.size());}/*! \internal    apply the settings to the application*/bool QApplicationPrivate::x11_apply_settings(){    QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));    settings.beginGroup(QLatin1String("Qt"));    /*      Qt settings. This is now they are written into the datastream.      Palette / *                - QPalette      font                       - QFont      libraryPath                - QStringList      style                      - QString      doubleClickInterval        - int      keyboardInputInterval  - int      cursorFlashTime            - int      wheelScrollLines           - int      colorSpec                  - QString      defaultCodec               - QString      globalStrut/width          - int      globalStrut/height         - int      GUIEffects                 - QStringList      Font Substitutions/ *      - QStringList      Font Substitutions/...     - QStringList    */    QStringList strlist;    int i;    QPalette pal(Qt::black);    int groupCount = 0;    strlist = settings.value(QLatin1String("Palette/active")).toStringList();    if (strlist.count() == QPalette::NColorRoles) {        ++groupCount;        for (i = 0; i < QPalette::NColorRoles; i++)            pal.setColor(QPalette::Active, (QPalette::ColorRole) i,                         QColor(strlist[i]));    }    strlist = settings.value(QLatin1String("Palette/inactive")).toStringList();    if (strlist.count() == QPalette::NColorRoles) {        ++groupCount;        for (i = 0; i < QPalette::NColorRoles; i++)            pal.setColor(QPalette::Inactive, (QPalette::ColorRole) i,                         QColor(strlist[i]));    }    strlist = settings.value(QLatin1String("Palette/disabled")).toStringList();    if (strlist.count() == QPalette::NColorRoles) {        ++groupCount;        for (i = 0; i < QPalette::NColorRoles; i++)            pal.setColor(QPalette::Disabled, (QPalette::ColorRole) i,                         QColor(strlist[i]));    }    if (groupCount == QPalette::NColorGroups)        QApplicationPrivate::setSystemPalette(pal);    if (!appFont) {        QString str = settings.value(QLatin1String("font")).toString();        if (!str.isEmpty()) {            QFont font(QApplication::font());            font.fromString(str);            QApplicationPrivate::setSystemFont(font);        }    }    // read library (ie. plugin) path list    QString libpathkey =        QString::fromLatin1("%1.%2/libraryPath")        .arg(QT_VERSION >> 16)        .arg((QT_VERSION & 0xff00) >> 8);    QStringList pathlist = settings.value(libpathkey).toString().split(QLatin1Char(':'));    if (! pathlist.isEmpty()) {        QStringList::ConstIterator it = pathlist.constBegin();        while (it != pathlist.constEnd())            QApplication::addLibraryPath(*it++);    }    // read new QStyle    QString stylename = settings.value(QLatin1String("style")).toString();    if (QCoreApplication::startingUp()) {        if (!stylename.isEmpty() && !QApplicationPrivate::styleOverride)            QApplicationPrivate::styleOverride = new QString(stylename);    } else {        QApplication::setStyle(stylename);    }    int num =        settings.value(QLatin1String("doubleClickInterval"),                       QApplication::doubleClickInterval()).toInt();    QApplication::setDoubleClickInterval(num);    num =        settings.value(QLatin1String("cursorFlashTime"),                       QApplication::cursorFlashTime()).toInt();    QApplication::setCursorFlashTime(num);    num =        settings.value(QLatin1String("wheelScrollLines"),                       QApplication::wheelScrollLines()).toInt();    QApplication::setWheelScrollLines(num);    QString colorspec = settings.value(QLatin1String("colorSpec"),                                       QVariant(QLatin1String("default"))).toString();    if (colorspec == QLatin1String("normal"))        QApplication::setColorSpec(QApplication::NormalColor);    else if (colorspec == QLatin1String("custom"))        QApplication::setColorSpec(QApplication::CustomColor);    else if (colorspec == QLatin1String("many"))        QApplication::setColorSpec(QApplication::ManyColor);    else if (colorspec != QLatin1String("default"))        colorspec = QLatin1String("default");    QString defaultcodec = settings.value(QLatin1String("defaultCodec"),                                          QVariant(QLatin1String("none"))).toString();    if (defaultcodec != QLatin1String("none")) {        QTextCodec *codec = QTextCodec::codecForName(defaultcodec.toLatin1());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -