/** * \class ds::ui::LayoutButton */ LayoutButton::LayoutButton(SpriteEngine& eng, const float widdy, const float hiddy) : ds::ui::LayoutSprite(eng) , mDown(*(new ds::ui::LayoutSprite(eng))) , mUp(*(new ds::ui::LayoutSprite(eng))) , mButtonBehaviour(*this) , mAnimDuration(0.1f) { setLayoutType(ds::ui::LayoutSprite::kLayoutNone); mUp.mExportWithXml = false; mUp.mLayoutUserType = ds::ui::LayoutSprite::kFillSize; mUp.setLayoutType(ds::ui::LayoutSprite::kLayoutSize); addChild(mUp); mDown.mExportWithXml = false; mDown.mLayoutUserType = ds::ui::LayoutSprite::kFillSize; mDown.setLayoutType(ds::ui::LayoutSprite::kLayoutSize); mDown.setOpacity(0.0f); addChild(mDown); mButtonBehaviour.setOnClickFn([this](){onClicked(); }); // Purely for visual state mButtonBehaviour.setOnDownFn([this](const ds::ui::TouchInfo&){showDown(); }); mButtonBehaviour.setOnEnterFn([this](){showDown(); }); mButtonBehaviour.setOnExitFn([this](){showUp(); }); mButtonBehaviour.setOnUpFn([this](){showUp(); }); }
int main(int argc, char* args[] ){ QApplication::setApplicationName("Jamtaba 2"); QApplication::setApplicationVersion(APP_VERSION); //start the configurator JTBConfig=new Configurator(); if(!JTBConfig->setUp(standalone)) qCWarning(jtConfigurator) << "JTBConfig->setUp() FAILED !" ; Persistence::Settings settings; settings.load(); SingleApplication* application = new SingleApplication(argc, args); Controller::StandaloneMainController mainController(settings, (QApplication*)application); mainController.configureStyleSheet("jamtaba.css"); mainController.start(); if(mainController.isUsingNullAudioDriver()){ QMessageBox::about(nullptr, "Fatal error!", "Jamtaba can't detect any audio device in your machine!"); } MainWindowStandalone mainWindow(&mainController); mainController.setMainWindow(&mainWindow); mainWindow.show(); //The SingleApplication class implements a showUp() signal. You can bind to that signal to raise your application's //window when a new instance had been started. QObject::connect(application, SIGNAL(showUp()), &mainWindow, SLOT(raise())); return application->exec(); }
void SjMainWindow::Timer_Constructed() { #ifndef Q_OS_OSX connect(g_pTheApp, SIGNAL(showUp()), this, SLOT(ToScr_Primary())); #endif Scr_Logs * l = Scr_Logs::Instance(); qApp->installEventFilter(this); if (l->IsExists()) // force construction if (Ctr_Openvpn::Instance()->IsOvRunning()) Ctr_Openvpn::Instance()->KillRunningOV(); AuthManager::Instance()->DetermineOldIp(); if (Setting::Instance()->IsCheckForUpdates()) { AuthManager::Instance()->StartDwnl_Updates(); } if (Setting::Instance()->IsAutoconnect()) { _ConnectAfterLogin = true; DoLogin(); } if (Setting::Instance()->IsInsecureWifi()) { StartWifiWatcher(); } }
int main(int argc, char* args[] ){ QApplication::setApplicationName("Jomtobo"); QApplication::setApplicationVersion(APP_VERSION); //start the configurator Configurator* configurator = Configurator::getInstance(); if(!configurator->setUp(standalone)) qCWarning(jtConfigurator) << "JTBConfig->setUp() FAILED !" ; Persistence::Settings settings; settings.load(); //SingleApplication is not working in mac. Using a dirty ifdef until have time to solve the SingleApplication issue in Mac #ifdef Q_OS_WIN QApplication* application = new SingleApplication(argc, args); #else QApplication* application = new QApplication(argc, args); #endif Controller::StandaloneMainController mainController(settings, (QApplication*)application); //..JOMTOBO CSS mainController.configureStyleSheet("jomtobo.css"); mainController.start(); if(mainController.isUsingNullAudioDriver()){ QMessageBox::about(nullptr, "Fatal error!", "Jamtaba can't detect any audio device in your machine!"); } MainWindowStandalone mainWindow(&mainController); mainController.setMainWindow(&mainWindow); mainWindow.show(); #ifdef Q_OS_WIN //The SingleApplication class implements a showUp() signal. You can bind to that signal to raise your application's //window when a new instance had been started. QObject::connect(application, SIGNAL(showUp()), &mainWindow, SLOT(raise())); #endif return application->exec(); }
/** * @brief SingleApplication::SingleApplication * Constructor. Checks and fires up LocalServer or closes the program * if another instance already exists * @param argc * @param argv */ SingleApplication::SingleApplication(int& argc, char* argv[]) : QApplication(argc, argv) { _shouldContinue = false; // By default this is not the main process socket = new QLocalSocket(); // Attempt to connect to the LocalServer socket->connectToServer("Quazaa"); if(socket->waitForConnected(100)){ socket->write("CMD:showUp"); socket->flush(); QThread::msleep(100); socket->close(); } else { // The attempt was insuccessful, so we continue the program _shouldContinue = true; server = new LocalServer(); server->start(); QObject::connect(server, SIGNAL(showUp()), this, SLOT(slotShowUp())); } }
/** * @brief SingleApplication::SingleApplication * Constructor. Checks and fires up LocalServer or closes the program * if another instance already exists * @param argc * @param argv */ SingleApplication::SingleApplication(QStringList &args) { _shouldContinue = false; // By default this is not the main process socket = new QUdpSocket(); QUdpSocket acceptor; acceptor.bind(QHostAddress::LocalHost, 58488, QUdpSocket::ReuseAddressHint|QUdpSocket::ShareAddress); // Attempt to connect to the LocalServer socket->connectToHost(QHostAddress::LocalHost, 58487); QString isServerRuns; if(socket->waitForConnected(100)) { socket->write(QString("CMD:Is editor running?").toUtf8()); socket->flush(); if(acceptor.waitForReadyRead(100)) { //QByteArray dataGram;//Yes, I'm runs! QByteArray datagram; datagram.resize(acceptor.pendingDatagramSize()); QHostAddress sender; quint16 senderPort; acceptor.readDatagram(datagram.data(), datagram.size(), &sender, &senderPort); if(QString::fromUtf8(datagram)=="Yes, I'm runs!") { isServerRuns="Yes!"; } } } if(args.contains("--force-run", Qt::CaseInsensitive)) { isServerRuns.clear(); args.removeAll("--force-run"); } _arguments = args; if(!isServerRuns.isEmpty()) { QString str = QString("CMD:showUp"); QByteArray bytes; for(int i=1; i<_arguments.size(); i++) { str.append(QString("\n%1").arg(_arguments[i])); } bytes = str.toUtf8(); socket->write(bytes); socket->flush(); QThread::msleep(100); socket->close(); } else { // The attempt was insuccessful, so we continue the program _shouldContinue = true; server = new LocalServer(); server->start(); QObject::connect(server, SIGNAL(showUp()), this, SLOT(slotShowUp())); QObject::connect(server, SIGNAL(dataReceived(QString)), this, SLOT(slotOpenFile(QString))); QObject::connect(server, SIGNAL(acceptedCommand(QString)), this, SLOT(slotAcceptedCommand(QString))); QObject::connect(this, SIGNAL(stopServer()), server, SLOT(stopServer())); } }
/** * @brief SingleApplication::slotShowUp * Executed when the showUp command is sent to LocalServer */ void SingleApplication::slotShowUp() { emit showUp(); }
void LayoutButton::onClicked() { showUp(); if(mClickFn) mClickFn(); }