void ViewLoading::setupView() { // connect to the model connect( qApp, SIGNAL(appStateChanged(FCApp::StateInfo, FCApp::StateInfo)), SLOT(onAppStateChanged(FCApp::StateInfo, FCApp::StateInfo)) ); }
Application::Application(int &argc, char **argv) : PsApplication(argc, argv), serverName(psServerPrefix() + cGUIDStr()), closing(false), updateRequestId(0), updateReply(0), updateThread(0), updateDownloader(0) { DEBUG_LOG(("Application Info: creation..")); QByteArray d(QDir((cPlatform() == dbipWindows ? cExeDir() : cWorkingDir()).toLower()).absolutePath().toUtf8()); char h[33] = { 0 }; hashMd5Hex(d.constData(), d.size(), h); serverName = psServerPrefix() + h + '-' + cGUIDStr(); if (mainApp) { DEBUG_LOG(("Application Error: another Application was created, terminating..")); exit(0); } mainApp = this; installEventFilter(new _DebugWaiter(this)); #if defined Q_OS_LINUX || defined Q_OS_LINUX64 QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/DejaVuSans.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/NanumMyeongjo-Regular.ttf")); #endif QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/OpenSans-Regular.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/OpenSans-Bold.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/OpenSans-Semibold.ttf")); float64 dpi = primaryScreen()->logicalDotsPerInch(); if (dpi <= 108) { // 0-96-108 cSetScreenScale(dbisOne); } else if (dpi <= 132) { // 108-120-132 cSetScreenScale(dbisOneAndQuarter); } else if (dpi <= 168) { // 132-144-168 cSetScreenScale(dbisOneAndHalf); } else { // 168-192-inf cSetScreenScale(dbisTwo); } if (devicePixelRatio() > 1) { cSetRetina(true); cSetRetinaFactor(devicePixelRatio()); cSetIntRetinaFactor(int32(cRetinaFactor())); } if (!cLangFile().isEmpty()) { LangLoaderPlain loader(cLangFile()); if (!loader.errors().isEmpty()) { LOG(("Lang load errors: %1").arg(loader.errors())); } else if (!loader.warnings().isEmpty()) { LOG(("Lang load warnings: %1").arg(loader.warnings())); } } Local::start(); style::startManager(); anim::startManager(); historyInit(); DEBUG_LOG(("Application Info: inited..")); window = new Window(); psInstallEventFilter(); connect(&socket, SIGNAL(connected()), this, SLOT(socketConnected())); connect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(&socket, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(socketError(QLocalSocket::LocalSocketError))); connect(&socket, SIGNAL(bytesWritten(qint64)), this, SLOT(socketWritten(qint64))); connect(&socket, SIGNAL(readyRead()), this, SLOT(socketReading())); connect(&server, SIGNAL(newConnection()), this, SLOT(newInstanceConnected())); connect(this, SIGNAL(aboutToQuit()), this, SLOT(closeApplication())); connect(&updateCheckTimer, SIGNAL(timeout()), this, SLOT(startUpdateCheck())); connect(this, SIGNAL(updateFailed()), this, SLOT(onUpdateFailed())); connect(this, SIGNAL(updateReady()), this, SLOT(onUpdateReady())); connect(this, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onAppStateChanged(Qt::ApplicationState))); connect(&writeUserConfigTimer, SIGNAL(timeout()), this, SLOT(onWriteUserConfig())); writeUserConfigTimer.setSingleShot(true); connect(&killDownloadSessionsTimer, SIGNAL(timeout()), this, SLOT(killDownloadSessions())); if (cManyInstance()) { startApp(); } else { DEBUG_LOG(("Application Info: connecting local socket to %1..").arg(serverName)); socket.connectToServer(serverName); } }
Widget::Widget(QWidget *parent) : QWidget(parent) { connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onAppStateChanged(Qt::ApplicationState))); QGridLayout *layout = new QGridLayout(this); layout->setColumnStretch(1, 1); m_networkState = new QLabel(); layout->addWidget(m_networkState, 0, 0, 1, 2); m_connectButton = new QPushButton("Connect"); connect(m_connectButton, SIGNAL(clicked()), this, SLOT(onConnectButton())); layout->addWidget(m_connectButton, 0, 2); checkNetworkState(); layout->addWidget(new QLabel("Toast:"), 1, 0); m_toastEdit = new QLineEdit("Qt toast"); layout->addWidget(m_toastEdit, 1, 1); m_toastButton = new QPushButton("makeToast"); layout->addWidget(m_toastButton, 1, 2); connect(m_toastButton, SIGNAL(clicked()), this , SLOT(onToastButton())); layout->addWidget(new QLabel("通知:"), 2, 0); m_notificationEdit = new QLineEdit("Qt notification"); layout->addWidget(m_notificationEdit, 2, 1); m_notifyButton = new QPushButton("Send"); connect(m_notifyButton, SIGNAL(clicked()), this, SLOT(onNotifyButton())); layout->addWidget(m_notifyButton, 2, 2); layout->addWidget(new QLabel("广播:"), 3, 0); m_broadcastEdit = new QLineEdit("an.qt.extendsQt.test"); layout->addWidget(m_broadcastEdit, 3, 1); m_broadcastButton = new QPushButton("Send"); connect(m_broadcastButton, SIGNAL(clicked()), this, SLOT(onBroadcastButton())); layout->addWidget(m_broadcastButton, 3, 2); layout->addWidget(new QLabel("Activity:"), 4, 0); m_activityEdit = new QLineEdit("android.settings.SETTINGS"); layout->addWidget(m_activityEdit, 4, 1); m_activityButton = new QPushButton("Start"); connect(m_activityButton, SIGNAL(clicked()), this, SLOT(onActivityButton())); layout->addWidget(m_activityButton, 4, 2); layout->addWidget(new QLabel("Location:"), 5, 0); m_locationState = new QLabel; layout->addWidget(m_locationState, 5, 1); QPushButton * btn = new QPushButton("Get"); connect(btn, SIGNAL(clicked()), this, SLOT(onGetLocation())); layout->addWidget(btn, 5, 2); layout->addWidget(new QLabel("CaptureImage:"), 6, 0); m_captureState = new QLabel; layout->addWidget(m_captureState, 6, 1); btn = new QPushButton("camera"); connect(btn, SIGNAL(clicked()), this, SLOT(onCaptureImage())); layout->addWidget(btn, 6, 2); layout->setRowStretch(7, 1); }