Doc::Doc(QObject* parent, int universes) : QObject(parent) , m_wsPath("") , m_fixtureDefCache(new QLCFixtureDefCache) , m_modifiersCache(new QLCModifiersCache) , m_ioPluginCache(new IOPluginCache(this)) , m_ioMap(new InputOutputMap(this, universes)) , m_masterTimer(new MasterTimer(this)) , m_inputCapture(NULL) , m_monitorProps(NULL) , m_mode(Design) , m_kiosk(false) , m_clipboard(new QLCClipboard(this)) , m_latestFixtureId(0) , m_latestFixtureGroupId(0) , m_latestChannelsGroupId(0) , m_latestFunctionId(0) , m_startupFunctionId(Function::invalidId()) { Bus::init(this); resetModified(); qsrand(QTime::currentTime().msec()); }
RenderArea::RenderArea(const QString &name, FFunctions *fA, FFunctions *fB, QList< columnPoints* > *ip, QList< columnPoints* > *op, QWidget *parent) : QWidget(parent) { QTime time = QTime::currentTime(); qsrand((uint)time.msec()); randomNoiseValue = 3000; originalImage = new QImage(name); imageInput = new QImage(name); imageOutput = new QImage(imageInput->width(), imageInput->height(), QImage::Format_ARGB32); functionsA = fA; functionsB = fB; functionsA->radius = 0; functionsA->center.clear(); inputPoints = ip; outputPoints = op; imageMask = 0; centerX = 0; centerY = 0; output = true; m_points_count = imageInput->width(); hideImage = false; hideMask = false; setMinimumHeight(imageInput->height()); setMinimumWidth(imageInput->width() * 2 + SPACE); updateInputPoints(); }
int emscriptenQtSDLMain(int argc, char *argv[]) #endif { QApplication *app = new QApplication(argc, argv); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //! [0] //! [1] QGraphicsScene *scene = new QGraphicsScene(-200, -200, 400, 400); for (int i = 0; i < 10; ++i) { ColorItem *item = new ColorItem; item->setPos(::sin((i * 6.28) / 10.0) * 150, ::cos((i * 6.28) / 10.0) * 150); scene->addItem(item); } Robot *robot = new Robot; robot->scale(1.2, 1.2); robot->setPos(0, -20); scene->addItem(robot); //! [1] //! [2] GraphicsView *view = new GraphicsView(scene); view->setRenderHint(QPainter::Antialiasing); view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); view->setBackgroundBrush(QColor(230, 200, 167)); view->setWindowTitle("Drag and Drop Robot"); #if defined(Q_OS_SYMBIAN) view->showMaximized(); #else view->show(); #endif return app->exec(); }
void PasswordGenerationAlgorithm::preExecute(void) { m_password = ""; m_nbrOfCharactersGenerated = 0; qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); // should not be put in the constructor // see http://stackoverflow.com/questions/3138373/qrand-is-not-generating-a-random-number register_clarifier_new_section(); { register_classifier_shadow_message_info("Génération Aléatoire de mots de passe"); register_classifier_pause(1500); register_classifier_message("Mot de passe généré : "+m_password, 1); register_classifier_pause(1500); QString str = QString("caractère") + (nbrOfCharactersRemaining()>=2 ? "s" : ""); register_classifier_message("Reste à générer : "+QString::number(nbrOfCharactersRemaining())+" "+str, 1); register_classifier_pause(1500); } register_classifier_pause(2000); // temps d'attente pour passer aux messages suivants -> à encapsuler dans une fonction peut-être register_clarifier_new_section(); { register_classifier_shadow_message_info("Remarques"); register_classifier_pause(1500); register_classifier_message("La génération du mot de passe utilise uniquement", 1); register_classifier_pause(1500); register_classifier_message("les lettres de l'alphabet français (a-z ou A-Z)", 1); register_classifier_pause(1500); register_classifier_message("ainsi que les chiffres (0-9).", 1); register_classifier_pause(1500); } }
Plot::Plot(size_t numberOfSamples, qreal minY, qreal maxY, QWidget *parent) : QWidget(parent), ui(new Ui::Plot) { ui->setupUi(this); circularBuffer = new CircularBuffer(numberOfSamples, ui->minYSpinBox->value(), ui->maxYSpinBox->value()); ui->minYSpinBox->setValue(minY); ui->maxYSpinBox->setValue(maxY); curve = new QwtPlotCurve(); curve->setData(circularBuffer); curve->attach(ui->plot); ui->colorComboBox->addItem("Black", Qt::black); ui->colorComboBox->addItem("Dark gray", Qt::darkGray); ui->colorComboBox->addItem("Gray", Qt::gray); ui->colorComboBox->addItem("Light gray", Qt::lightGray); ui->colorComboBox->addItem("Red", Qt::red); ui->colorComboBox->addItem("Green", Qt::green); ui->colorComboBox->addItem("Blue", Qt::blue); ui->colorComboBox->addItem("Cyan", Qt::cyan); ui->colorComboBox->addItem("Magenta", Qt::magenta); ui->colorComboBox->addItem("Yellow", Qt::yellow); ui->colorComboBox->addItem("Dark red", Qt::darkRed); ui->colorComboBox->addItem("Dark green", Qt::darkGreen); ui->colorComboBox->addItem("Dark blue", Qt::darkBlue); ui->colorComboBox->addItem("Dark cyan", Qt::darkCyan); ui->colorComboBox->addItem("Dark magenta", Qt::darkMagenta); ui->colorComboBox->addItem("Dark yellow", Qt::darkYellow); qsrand(QTime::currentTime().msec()); ui->colorComboBox->setCurrentIndex(qrand() % ui->colorComboBox->count()); }
Musec::Musec(QMainWindow* parent) : QMainWindow(parent) { setupUi(this); setWindowFlags(Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground, true); fTranslator = new QTranslator(this); fScore = new Score(); fNetMgr = new NetMgr(this); fPlayer = new QMediaPlayer(this, QMediaPlayer::LowLatency); fPlaylist = new QMediaPlaylist(this); fPlayer->setPlaylist(fPlaylist); fTimer = new QTimer(this); fTimer->setSingleShot(true); fTimer->setInterval(TIME_HARD * 1000); fStartTime = -1; fDiffLock = kHard; fIsActive = false; fDragging = false; loadLanguage(getConfig("lang", QLocale::system().name())); fExtensions << "*.mp3" << "*.m4a"; // These should contain meta data btnMenuMusic->setMenu(menuMusic); btnMenuInfo->setMenu(menuInfo); btnMenuLanguage->setMenu(menuLanguage); btnMenuHelp->setMenu(menuHelp); connect(fScore, &Score::multiplierChanged, this, &Musec::multiplierChanged); connect(fNetMgr, &NetMgr::done, this, &Musec::scoreSubmitted); connect(fTimer, &QTimer::timeout, fPlayer, &QMediaPlayer::stop); connect(fPlayer, &QMediaPlayer::mediaStatusChanged, this, &Musec::mediaStatusChanged); connect(fPlaylist, &QMediaPlaylist::loaded, this, &Musec::playlistLoaded); connect(fPlaylist, &QMediaPlaylist::loadFailed, this, &Musec::playlistLoadFailed); connect(slDifficulty, &QSlider::valueChanged, this, &Musec::difficultyChanged); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); }
/** * \brief Constructor * \param parent The screen parent * \param name The name of the screen */ GallerySlideView::GallerySlideView(MythScreenStack *parent, const char *name, bool editsAllowed) : MythScreenType(parent, name), m_uiImage(NULL), m_uiStatus(NULL), m_uiSlideCount(NULL), m_uiCaptionText(NULL), m_uiHideCaptions(NULL), m_mgr(ImageManagerFe::getInstance()), m_view(NULL), m_availableTransitions(GetMythPainter()->SupportsAnimation()), m_transition(m_availableTransitions.Select( gCoreContext->GetNumSetting("GalleryTransitionType", kBlendTransition))), m_updateTransition(), m_slides(), m_infoList(*this), m_slideShowTime(gCoreContext->GetNumSetting("GallerySlideShowTime", 3000)), m_playing(false), m_suspended(false), m_showCaptions(gCoreContext->GetNumSetting("GalleryShowSlideCaptions", true)), m_transitioning(false), m_editsAllowed(editsAllowed) { // Detect when transitions finish. Queued signal to allow redraw/pulse to // complete before handling event. connect(&m_transition, SIGNAL(finished()), this, SLOT(TransitionComplete()), Qt::QueuedConnection); connect(&m_updateTransition, SIGNAL(finished()), this, SLOT(TransitionComplete()), Qt::QueuedConnection); // Seed random generator for random transitions qsrand(QTime::currentTime().msec()); // Initialise slideshow timer m_timer.setSingleShot(true); m_timer.setInterval(m_slideShowTime); connect(&m_timer, SIGNAL(timeout()), this, SLOT(ShowNextSlide())); }
/** * @brief Initializes the Sampler with the limits of robot's workspace and a point to innermodel. * The method uses that pointer to create a copy of innermodel, so the Sampler can use to test valid * robot configurations without interfering with the original one * * @param inner pointer to innerModel object * @param outerRegion_ QRectF delimiting the robot's workspace * @param innerRegions_ List of QRectF polygons delimiting forbidden regions inside robot's workspace * @return void */ void Sampler::initialize(InnerModel *inner, const RoboCompCommonBehavior::ParameterList ¶ms) { qDebug() << __FUNCTION__ << "Sampler: Copying InnerModel..."; innerModelSampler = inner->copy(); try { outerRegion.setLeft(std::stof(params.at("OuterRegionLeft").value)); outerRegion.setRight(std::stof(params.at("OuterRegionRight").value)); outerRegion.setBottom(std::stof(params.at("OuterRegionBottom").value)); outerRegion.setTop(std::stof(params.at("OuterRegionTop").value)); qDebug() << __FUNCTION__ << "OuterRegion from config: " << outerRegion; } catch(...) { qFatal("Sampler-Initialize. Aborting. OuterRegion parameters not found in config file");} //CHANGE TO THROW //innerRegions = innerRegions_; // foreach(QRectF ir, innerRegions_) // if( ir.isNull() == false) // qFatal("Sampler-Initialize. Aborting. An InnerRegion is not a valid rectangle"); // if(outerRegion.isNull()) qFatal("Sampler-Initialize. Aborting. OuterRegion is not properly initialized"); //CHANGE TO THROW robotNodes.clear(); restNodes.clear(); QStringList ls = QString::fromStdString(params.at("ExcludedObjectsInCollisionCheck").value).replace(" ", "" ).split(','); qDebug() << __FUNCTION__ << ls.size() << "objects read for exclusion list"; foreach( QString s, ls) excludedNodes.insert(s); // Compute the list of meshes that correspond to robot, world and possibly some additionally excluded ones recursiveIncludeMeshes(innerModelSampler->getRoot(), "robot", false, robotNodes, restNodes, excludedNodes); //Init random sequence generator qsrand( QTime::currentTime().msec() ); }
Wizard::Wizard(QWidget * parent) : QWizard(parent, Qt::Dialog | Qt::WindowSystemMenuHint) { //Транслятор QTranslator * appTranslator = new QTranslator(this); appTranslator->load(QString(":/translations/HoldemInstall_%1") .arg(QLocale::system().name())); qApp->installTranslator(appTranslator); QTranslator * qtTranslator = new QTranslator(this); qtTranslator->load(QString(":/translations/qt_%1") .arg(QLocale::system().name())); qApp->installTranslator(qtTranslator); BOOL IsAdmin = FALSE; BOOL success = IsUserAdmin(&IsAdmin); if (success && !IsAdmin) { //не админские права QMessageBox::warning(this, tr("Maverick Setup"), tr("You must have administrative privileges to install the program.\n" "Please run the installer with administrative privileges.")); exit(0); } qsrand(QDateTime::currentDateTime().toTime_t()); createIntroStep(); createLicenseStep(); createFolderStep(); //createRoomStep(); createProgressStep(); createFinishStep(); setWindowTitle(tr("Setup - Maverick Poker Bot")); setFixedWidth(550); setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/water.png")); setOption(QWizard::NoBackButtonOnLastPage, true); //setWizardStyle(QWizard::ClassicStyle); }
void CalibrationWnd::slotEnable() { bool en = ui.mode->isChecked(); ui.panel->setEnabled( en ); ui.clearFileBtn->setEnabled( !en ); if ( en ) { openVoltCalibrationFile(); openCurrCalibrationFile(); QTime t = QTime::currentTime(); int seed = t.msec() + (t.second() + (t.minute() + t.hour() * 24) * 60) * 1000; qsrand( seed ); setRandomVolt(); } else { if ( volt.size() >= 3 ) { calcDac2Volt(); mainWnd->setCalibrationDac( aDacLow, aDacHigh, bDac ); } if ( volt.size() >= 2 ) { calcAdcAux2Volt(); calcAdcRef2Volt(); mainWnd->setCalibrationAdcVolt( aAdcAux, bAdcAux, aAdcRef, bAdcRef ); } if ( curr.size() >= 2 ) { calcAdcI2Curr(); mainWnd->setCalibrationAdcCurr( aAdcI, bAdcI ); } closeCalibrationFiles(); } }
Folder::Folder(const QString &alias, const QString &path, const QString& secondPath, QObject *parent) : QObject(parent) , _path(path) , _secondPath(secondPath) , _alias(alias) , _enabled(true) , _thread(0) , _csync(0) , _csyncError(false) , _csyncUnavail(false) , _csync_ctx(0) { qsrand(QTime::currentTime().msec()); _timeSinceLastSync.start(); _watcher = new FolderWatcher(path, this); MirallConfigFile cfg; _watcher->addIgnoreListFile( cfg.excludeFile(MirallConfigFile::SystemScope) ); _watcher->addIgnoreListFile( cfg.excludeFile(MirallConfigFile::UserScope) ); QObject::connect(_watcher, SIGNAL(folderChanged(const QStringList &)), SLOT(slotChanged(const QStringList &))); _syncResult.setStatus( SyncResult::NotYetStarted ); // check if the local path exists checkLocalPath(); int polltime = cfg.remotePollInterval(); qDebug() << "setting remote poll timer interval to" << polltime << "msec"; _pollTimer.setInterval( polltime ); QObject::connect(&_pollTimer, SIGNAL(timeout()), this, SLOT(slotPollTimerTimeout())); _pollTimer.start(); _syncResult.setFolder(alias); }
void CentreControl::startButtonClicked() { //删除开始按钮 scene->removeItem(startButton); delete startButton; //定义三人的牌和底牌,并排序 QList<CardItem *> myCard; QList<CardItem *> leftCard; QList<CardItem *> rightCard; QList<CardItem *> bottomList; CardUtil::dealCard(myCard,leftCard,rightCard,bottomList); //选地主 qsrand(QTime::currentTime().msec()); master = qrand()%3+1; handerIndex = master; QString leftHeadImage = ":images/image/farmers_left.png"; QString rightHeadImage = ":images/image/farmers_left.png"; switch (master) { case 1: foreach(CardItem * item,bottomList){ item->isFront = true; item->setSelected(true); myCard.append(item); } break; case 2: rightCard << bottomList.at(0)<<bottomList.at(1)<< bottomList.at(2); rightHeadImage = ":images/image/lord_left.png"; break; case 3: leftCard << bottomList.at(0)<<bottomList.at(1)<< bottomList.at(2); leftHeadImage = ":images/image/lord_left.png"; break; default: break; }
void FindSpikes::GenerateSpikes() { qsrand(QTime::currentTime().msec()); QVector<double> *randomData=new QVector<double>;//durée spikes 6.5s=130points (/10 ici) //add spike to clusters int number=1; for(int spike=0;spike<number;spike++) { for(int channel=0;channel<nbChannels;channel++) { //generate spikes randomly randomData->clear(); for(int i=0;i<13*nbChannels;i++)//generate random values of spike { int value=rand()%100; randomData->append(value); //teValues->append(QString::number(value)); } } nbGenerated++; Spikes.append(randomData); } LabelNbSpikes->setText(QString::number(nbGenerated)); }
Enemy::Enemy() { QTime t; qsrand(t.currentTime().msec()); int s = qrand()%4; switch(s){ case 0: this->x = qrand()%1000; this->y = -10; break; case 1: this->x = qrand()%1; this->y = -10; break; case 2: this->x = -10; this->y = qrand()%10; break; case 3: this->x = 1290; this->y = qrand()%10; break; } hp = 100 * (qrand()%5+1); this->dx = 1.0/sqrt(2.0); this->dy = 1.0/sqrt(2.0); this->speed = 1+qrand()%20/10.1; // get resource, (see Resource.h) Resource * resource = new Resource(); pix.load(resource->picLocation + "enemy.png"); // release resource, (see Resource.h) delete resource; mouseOver = false; }
Populacja::Populacja(int r) { rozmiar=r; qsrand(time(NULL)); populacja = new QVector<Osobnik*>; for(int i=0; i<rozmiar; ++i) { int g1=qrand()%8+1; int g2=qrand()%8+1; int g3=qrand()%8+1; int g4=qrand()%8+1; int g5=qrand()%8+1; int g6=qrand()%8+1; int g7=qrand()%8+1; int g8=qrand()%8+1; populacja->push_front(new Osobnik(g1,g2,g3,g4,g5,g6,g7,g8)); // std::cout<<g1<<" "<<g2<<" "<<g3<<" "<<g4<<" "<<g5<<" "<<g6<<" "<<g7<<" "<<g8<<std::endl; // std::cout<<"size "<<populacja->size()<<std::endl; } }
void run() { qsrand(QTime::currentTime().msec()); for(qint32 i = 0; i < NUM_CYCLES; i++) { qint32 type = i % 2; switch(type) { case 0: for(qint32 j = 0; j < NUM_OBJECTS; j++) { m_pointer[j] = m_pool.pop(); Q_ASSERT(m_pointer[j]); // check for sigsegv ;) ((quint8*)m_pointer[j])[0] = i; } break; case 1: for(qint32 j = 0; j < NUM_OBJECTS; j++) { // are we the only writers here? Q_ASSERT(((quint8*)m_pointer[j])[0] == (i-1) % 256); m_pool.push(m_pointer[j]); } break; } } }
void RoomThread1v1::run(){ // initialize the random seed for this thread qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); QSet<QString> banset = Config.value("1v1/Banlist").toStringList().toSet(); general_names = Sanguosha->getRandomGenerals(10, banset); QStringList known_list = general_names.mid(0, 6); unknown_list = general_names.mid(6, 4); int i; for(i=0; i<4; i++){ general_names[i + 6] = QString("x%1").arg(i); } QString unknown_str = "+x0+x1+x2+x3"; room->broadcastInvoke("fillGenerals", known_list.join("+") + unknown_str); ServerPlayer *first = room->players.at(0), *next = room->players.at(1); askForTakeGeneral(first); while(general_names.length() > 1){ qSwap(first, next); askForTakeGeneral(first); askForTakeGeneral(first); } askForTakeGeneral(next); startArrange(first); startArrange(next); room->sem->acquire(2); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); tcpClient = new QTcpSocket(this); ui->pushSent->setEnabled(false); this->ui->timeBut->setEnabled(false); tcpClient->abort(); connect(tcpClient,&QTcpSocket::readyRead, [&](){this->ui->textEdit->append(tr("%1 Server Say:%2").arg(QTime::currentTime().toString("hh:mm:ss.zzz")).arg(QString(this->tcpClient->readAll())));}); connect(tcpClient,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(ReadError(QAbstractSocket::SocketError))); connect(&tm,&QTimer::timeout,[&](){ int i = qrand() % 6; this->ui->textEdit->append(tr("%1 Timer Sent: %2").arg(QTime::currentTime().toString("hh:mm:ss.zzz")).arg(list.at(i))); tcpClient->write(list.at(i).toUtf8()); }); list << "我是谁?" << "渡世白玉" << "hello" << "哈哈哈哈哈" << "你是坏蛋!" << "测试一下下了" << "不知道写什么" ; QTime time; time= QTime::currentTime(); qsrand(time.msec()+time.second()*1000); this->ui->txtIp->setText("127.0.0.1"); this->ui->txtPort->setText("6666"); }
int main(int argc, char *argv[]) { QApplication::setGraphicsSystem("opengl"); QApplication app(argc, argv); YagwScene scene; qsrand(0xDEADBEEF * QTime::currentTime().msec()); app.setApplicationName("Yagw: Yet Another Graphic Woobling"); SoundCenter::get_instance(); // init le son et lance la musique QGraphicsView view(&scene); GameProcessor game(scene); scene.connect(&scene, SIGNAL(quit()), &app, SLOT(quit())); view.showFullScreen(); view.setRenderHint(QPainter::Antialiasing); view.setCacheMode(QGraphicsView::CacheBackground); view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); view.show(); view.setMouseTracking(false); view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); app.setOverrideCursor( QCursor( Qt::BlankCursor ) ); app.exec(); return (0); }
void AddUserDlg::slotUserAdded(UserAccount* ua) { if (!ua) { QMessageBox::warning(this, "warning",i18n("can not find user!") ); close(); return; } if (ua->userName() != ui.userNameEdit->text()) { close(); return; } qsrand(time(NULL)); int n = qrand(); char salt[8] = ""; snprintf(salt, sizeof(salt) - 1, "$6$%02d", n); char *crystr = crypt(qPrintable(ui.verifyPwdEdit->text()), salt); if (crystr == NULL) { QMessageBox::warning(this, "warning", i18n("fail to crypt password, please change password manually.")); close(); return; } ua->setPassword(crystr); ua->setAutomaticLogin( ui.autoLoginCheckBox->isChecked() ? true : false); ua->setLocked(ui.disLoginCheckBox->isChecked() ? true : false); if (!iconFilePath.isEmpty()) { ua->setIconFileName(iconFilePath); iconFilePath = ""; } emit finished(); close(); }
MeteorShowersMgr::MeteorShowersMgr() : m_meteorShowers(NULL) , m_configDialog(NULL) , m_searchDialog(NULL) , m_conf(StelApp::getInstance().getSettings()) , m_onEarth(false) , m_enablePlugin(false) , m_activeRadiantOnly(false) , m_enableAtStartup(true) , m_enableLabels(true) , m_enableMarker(true) , m_showEnableButton(true) , m_showSearchButton(true) , m_messageTimer(NULL) , m_isUpdating(false) , m_enableAutoUpdates(true) , m_updateFrequencyHours(0) , m_statusOfLastUpdate(OUTDATED) , m_downloadMgr(NULL) , m_progressBar(NULL) { setObjectName("MeteorShowers"); qsrand(QDateTime::currentMSecsSinceEpoch()); }
void GMonteCarloLogNormalPricer::run() { qsrand(m_TotalNumberIteration); int iteration = m_PathNumber.IntValue(); // should we cycle this with a short pause bool ReIterateWithPause = iteration < 0; if(!ReIterateWithPause) { while(iteration-- && m_Run) { PlotRandIteration(); } } else { while(m_Run && m_PathNumber.IntValue()) { int iterPlus = -iteration; while(iterPlus-- && m_Run) { PlotRandIteration(); msleep(1000 / (qMax(1, abs(m_PathNumber.IntValue())))); } } } }
int main(int argc, char *argv[]) { QApplication app(argc, argv); qsrand(QTime::currentTime().msec()); qRegisterMetaType<Connection::DataType>("Connection::DataType"); QString ipAddress; QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); // use the first non-localhost IPv4 address for(int i = 0; i < ipAddressesList.size(); ++i) { if(ipAddressesList.at(i) != QHostAddress::LocalHost && ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); break; } } GameClient client(ipAddress, 30000); GameUI game; game.setClient(&client); game.show(); return app.exec(); }
quint16 StreamBase::frameLen(int streamIndex) const { int pktLen; // Decide a frame length based on length mode switch(lenMode()) { case OstProto::StreamCore::e_fl_fixed: pktLen = mCore->frame_len(); break; case OstProto::StreamCore::e_fl_inc: pktLen = frameLenMin() + (streamIndex % (frameLenMax() - frameLenMin() + 1)); break; case OstProto::StreamCore::e_fl_dec: pktLen = frameLenMax() - (streamIndex % (frameLenMax() - frameLenMin() + 1)); break; case OstProto::StreamCore::e_fl_random: //! \todo (MED) This 'random' sequence is same across iterations pktLen = 64; // to avoid the 'maybe used uninitialized' warning qsrand(reinterpret_cast<ulong>(this)); for (int i = 0; i <= streamIndex; i++) pktLen = qrand(); pktLen = frameLenMin() + (pktLen % (frameLenMax() - frameLenMin() + 1)); break; default: qWarning("Unhandled len mode %d. Using default 64", lenMode()); pktLen = 64; break; } return pktLen; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setOrganizationName("btbn.de"); app.setOrganizationDomain("btbn.de"); app.setApplicationName("TwitchWatcher"); qsrand((uint)QTime::currentTime().msec()); try { MainWin win; win.show(); return app.exec(); } catch(const std::exception &e) { QMessageBox::critical(nullptr, "Exception occured!", e.what()); } return -1; }
void mapVertex(const QVector3D &v, int ix) { static bool seeded = false; if (!seeded) qsrand(31415); Q_ASSERT(vec_data->at(ix) == v); if ((vec_data->size() - number_mapped) > map_threshold) { int to_map = vec_data->size() - number_mapped; QArray<int, 100> shuffle(to_map, -1); for (int i = number_mapped, k = 0; i < vec_data->size(); ++i, ++k) shuffle[k] = i; for (int n = to_map; n > 1; --n) { int k = qrand() % n; int tmp = shuffle[k]; shuffle[k] = shuffle[n - 1]; shuffle[n - 1] = tmp; } for (int i = 0; i < to_map; ++i) vec_map.insertMulti(vec_data->at(shuffle.at(i)), shuffle.at(i)); number_mapped += to_map; } }
triton::triton(QObject *parent) : QObject(parent) { qsrand((uint)QTime::currentTime().msec()); tm = new QTimer(this); m_pTcpSocket = new QTcpSocket(this); quantityCh=16; for (int i=0;i<quantityCh;i++) { channels["channel "+QString::number(i+1)]=new channel("channel "+QString::number(i+1)); } connect(tm,SIGNAL(timeout()),this,SLOT(sendRequest())); m_pTcpSocket->connectToHost("192.168.199.29", 22518); connect(m_pTcpSocket, SIGNAL(connected()), SLOT(slotConnected())); connect(m_pTcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead())); connect(m_pTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError))); }
void QuazaaIRC::ctcpReply(QString nick, QString request) { QStringList ctcp = request.toUpper().split(" "); QString action = ctcp.at(0); QString reply = action + " "; if (action == "VERSION") reply += QuazaaGlobals::USER_AGENT_STRING(); else if (action == "TIME") reply += QDateTime::currentDateTime().toString("ddd MMM dd HH:mm:ss yyyy"); else if (action == "PING") reply = request; else if (action == "FINGER") { qsrand(time(0)); QStringList fingers = QStringList() << tr("Go finger someone else...") << tr("You naughty!") << tr("Oh yeah baby :o") << tr("Quazaa really turns me on!"); reply += fingers.at(qrand() % fingers.size()); } else if (action == "SOURCE") { reply += "http://sourceforge.net/scm/?type=svn&group_id=286623"; } else if (action == "USERINFO") { reply += sRealName; } else if (action == "CLIENTINFO") { reply += "ACTION CLIENTINFO PING TIME VERSION FINGER SOURCE USERINFO"; } else { reply = "ERRMSG CTCP " + action + tr(" is an unknown request."); } ircSession->ctcpReply(nick, reply); }
GameEngine::GameEngine(QObject* parent) :QObject(parent) { m_timerId = 0; m_doEnemyMissile = 1500 / TIMER_SPEED; m_GameGml = 0; m_gameLevel = 0; clearQmlObjects(); // For random QTime time = QTime::currentTime(); qsrand((uint)time.msec()); // Sound engine m_soundEngine = new CInvSounds(this); // Device profile m_silent = false; #ifdef Q_OS_SYMBIAN iVibrate = CHWRMVibra::NewL(); #endif // Get device profile, is it silent? #if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 m_systemDeviceInfo = new QSystemDeviceInfo(this); QObject::connect(m_systemDeviceInfo,SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)),this, SLOT(currentProfileChanged(QSystemDeviceInfo::Profile))); QSystemDeviceInfo::Profile p = m_systemDeviceInfo->currentProfile(); if (p == QSystemDeviceInfo::SilentProfile) { m_silent = true; } #endif }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); socket = new QAsioTcpsocket(4096,this); ui->pushSent->setEnabled(false); this->ui->timeBut->setEnabled(false); connect(socket,&QAsioTcpsocket::sentReadData,this,&MainWindow::readData); connect(socket,&QAsioTcpsocket::erroString,this,&MainWindow::readError); connect(&tm,&QTimer::timeout,[&](){ int i = qrand() % 6; this->ui->textEdit->append(tr("%1 Timer Sent: %2").arg(QTime::currentTime().toString("hh:mm:ss.zzz")).arg(list.at(i))); socket->write(QByteArray(list.at(i).toUtf8())); }); connect(socket,&QAsioTcpsocket::connected,this,&MainWindow::connectdd,Qt::QueuedConnection); connect(socket,&QAsioTcpsocket::disConnected,this,&MainWindow::disconnectdd); list << "我是谁?" << "渡世白玉" << "hello" << "哈哈哈哈哈" << "你是坏蛋!" << "测试一下下了" << "不知道写什么" ; QTime time; time= QTime::currentTime(); qsrand(time.msec()+time.second()*1000); this->ui->txtIp->setText("127.0.0.1"); this->ui->txtPort->setText("2048"); }