示例#1
0
AQWebApplication::AQWebApplication(int &argc, char **argv) :
  QApplication(argc, argv), guiSocket_(0), ts_(0), desktop_(0), initDone_(false), inLoop_(false), finish_(false),
  ignoreEvents_(false), lastDeactivate_(0)
{
  aqWebApp = this;
  QToolTip::setGloballyEnabled(false);
  QPixmap::setDefaultOptimization(QPixmap::BestOptim);
  setCursorFlashTime(2000);
  pixmapsLoaded_.setMaxCost(AQ_MAX_CACHE);
  createdWidgets_.resize(499);

  guiTimer_ = new QTimer(this);
  connect(guiTimer_, SIGNAL(timeout()), this, SLOT(processAQEvents()));
  webTimer_ = new QTimer(this);
  connect(webTimer_, SIGNAL(timeout()), this, SLOT(processWebEvents()));

  Q_UINT16 guiPort = 2020;
  QString guiHost("localhost");

  for (int i = 1; i < argc; ++i) {
    if (qstrcmp(argv[i], "-guiport") == 0) {
      if (i != argc - 1) {
        ++i;
        guiPort = QString::fromLatin1(argv[i]).toUInt();
      }
    } else if (qstrcmp(argv[i], "-guihost") == 0) {
      if (i != argc - 1) {
        ++i;
        guiHost = QString::fromLatin1(argv[i]);
      }
    }
  }

  openConnection(guiHost, guiPort);

#ifndef AQ_USE_NOTIFY
  eventFilter_ = new AQEventFilter(this);
  qApp->installEventFilter(eventFilter_);
#endif

  desktop_ = QApplication::desktop();
  postAQEvent(new AQEvent(desktop_, new QEvent(QEvent::Create)));
}
示例#2
0
bool Application::init()
try
{
    // initialize resources
#if !defined(DESKTOP)
    Q_INIT_RESOURCE(keyboard);
    Q_INIT_RESOURCE(rotation);
    Q_INIT_RESOURCE(eink);
#if defined(EINK)
    setCursorFlashTime(0);
#endif
#endif

    QString logFile( Platform::get()->getUserSettingsPath() + QDir::separator() + applicationName() + ".log.txt" );
    g_pLog = new Log( QFile::encodeName(logFile).constData(), 1, 1 );

    g_pConfig = new Config(applicationName());
    int logLevel = g_pConfig->readInt("log_level", -1);
    if ( -1 == logLevel )
    {
        logLevel = qgetenv("VLASOVSOFT_LOG").toInt();
    } 
    if ( logLevel < 0 ) logLevel = 0;
    if ( logLevel > 2 ) logLevel = 2;
    g_pLog->setLevel( logLevel );

    g_pLog->write(1, Log::MT_I, "Program started, version: %s.%s", VERSION, REVISION);

    // set default application font
    QFont fnt = font();
    fnt.setPointSize(Platform::get()->getDefaultFontSize());
    setFont(fnt);

#if defined(EINK)
    // set palette
    QPalette pal = palette();
    pal.setColor(QPalette::Window, Qt::white);
    pal.setColor(QPalette::Highlight, Qt::black);
    setPalette(pal);
#endif

#if defined(ANDROID) || defined(SIMPLE) || defined(IOS)
    QPalette pal = palette();
    pal.setColor(QPalette::Highlight, Qt::darkBlue);
    pal.setColor(QPalette::HighlightedText, Qt::white);
    setPalette(pal);
#endif

#if !defined(DESKTOP)
    StyleEbook* pStyle = new StyleEbook(style());
    int bSize = g_pConfig->readInt( "button_size", 40 ); // 40 = 1 cm
    QSize size( getSizePx( QSize(bSize, bSize), 5 ) );
    pStyle->setButtonIconSize(qMax( size.width(), size.height() ));
    setStyle(pStyle);
#endif

#if defined(Q_WS_QWS)
    QWSServer::setBackground(QBrush(Qt::black));
    setNavigationMode( Qt::NavigationModeKeypadDirectional );
#endif

#if defined(ANDROID)
    installEventFilter(&kf);
#endif

    loadTranslations();

    customInit();

    return true;
}
catch(const Exception& e)
{
    if ( g_pLog != NULL )
        g_pLog->write(1, Log::MT_F, "Fatal error: %s", e.what());
    ::messageBox(0, QMessageBox::Critical, qApp->translate("main", "Error:"), QString::fromLocal8Bit(e.what()) );
    return false;
}
catch(...)
{
    if ( g_pLog != NULL )
        g_pLog->write(1, Log::MT_F, "Fatal error!");
    ::messageBox(0, QMessageBox::Critical, qApp->translate("main", "Error:"), "Fatal error!" );
    return false;
}
示例#3
0
int QApplication::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QCoreApplication::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 9)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 9;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< Qt::LayoutDirection*>(_v) = layoutDirection(); break;
        case 1: *reinterpret_cast< QIcon*>(_v) = windowIcon(); break;
        case 2: *reinterpret_cast< int*>(_v) = cursorFlashTime(); break;
        case 3: *reinterpret_cast< int*>(_v) = doubleClickInterval(); break;
        case 4: *reinterpret_cast< int*>(_v) = keyboardInputInterval(); break;
        case 5: *reinterpret_cast< int*>(_v) = wheelScrollLines(); break;
        case 6: *reinterpret_cast< QSize*>(_v) = globalStrut(); break;
        case 7: *reinterpret_cast< int*>(_v) = startDragTime(); break;
        case 8: *reinterpret_cast< int*>(_v) = startDragDistance(); break;
        case 9: *reinterpret_cast< bool*>(_v) = quitOnLastWindowClosed(); break;
        case 10: *reinterpret_cast< QString*>(_v) = styleSheet(); break;
        case 11: *reinterpret_cast< bool*>(_v) = autoSipEnabled(); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setLayoutDirection(*reinterpret_cast< Qt::LayoutDirection*>(_v)); break;
        case 1: setWindowIcon(*reinterpret_cast< QIcon*>(_v)); break;
        case 2: setCursorFlashTime(*reinterpret_cast< int*>(_v)); break;
        case 3: setDoubleClickInterval(*reinterpret_cast< int*>(_v)); break;
        case 4: setKeyboardInputInterval(*reinterpret_cast< int*>(_v)); break;
        case 5: setWheelScrollLines(*reinterpret_cast< int*>(_v)); break;
        case 6: setGlobalStrut(*reinterpret_cast< QSize*>(_v)); break;
        case 7: setStartDragTime(*reinterpret_cast< int*>(_v)); break;
        case 8: setStartDragDistance(*reinterpret_cast< int*>(_v)); break;
        case 9: setQuitOnLastWindowClosed(*reinterpret_cast< bool*>(_v)); break;
        case 10: setStyleSheet(*reinterpret_cast< QString*>(_v)); break;
        case 11: setAutoSipEnabled(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 12;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}