void TabBarWidget::updateTabs(int index) { if (index < 0 && sender() && sender()->inherits(QStringLiteral("Otter::Window").toLatin1())) { for (int i = 0; i < count(); ++i) { if (sender() == qvariant_cast<QObject*>(tabData(i))) { index = i; break; } } } const int limit = ((index >= 0) ? (index + 1) : count()); for (int i = ((index >= 0) ? index : 0); i < limit; ++i) { const bool isLoading = getTabProperty(i, QLatin1String("isLoading"), false).toBool(); QLabel *label = qobject_cast<QLabel*>(tabButton(i, QTabBar::LeftSide)); if (label) { if (isLoading) { if (!label->movie()) { QMovie *movie = new QMovie(QLatin1String(":/icons/loading.gif"), QByteArray(), label); movie->start(); label->setMovie(movie); } } else { if (label->movie()) { label->movie()->deleteLater(); label->setMovie(NULL); } label->setPixmap(getTabProperty(i, QLatin1String("icon"), QIcon(getTabProperty(i, QLatin1String("isPrivate"), false).toBool() ? ":/icons/tab-private.png" : ":/icons/tab.png")).value<QIcon>().pixmap(16, 16)); } } } showPreview(tabAt(mapFromGlobal(QCursor::pos()))); }
void tst_QMovie::playMovie() { QFETCH(QString, fileName); QFETCH(int, frameCount); QMovie movie(fileName); QCOMPARE(movie.state(), QMovie::NotRunning); movie.setSpeed(1000); movie.start(); QCOMPARE(movie.state(), QMovie::Running); movie.setPaused(true); QCOMPARE(movie.state(), QMovie::Paused); movie.start(); QCOMPARE(movie.state(), QMovie::Running); movie.stop(); QCOMPARE(movie.state(), QMovie::NotRunning); movie.jumpToFrame(0); QCOMPARE(movie.state(), QMovie::NotRunning); movie.start(); QCOMPARE(movie.state(), QMovie::Running); connect(&movie, SIGNAL(finished()), this, SLOT(exitLoopSlot())); QLabel label; label.setMovie(&movie); label.show(); QTestEventLoop::instance().enterLoop(20); QVERIFY2(!QTestEventLoop::instance().timeout(), "Timed out while waiting for finished() signal"); QCOMPARE(movie.state(), QMovie::NotRunning); QCOMPARE(movie.frameCount(), frameCount); }
void LoginWidget::checkLogin() { QString user = _editUsername->text(); QString pass = _editPassword->text(); QString ip = _editIp->text(); QMovie *movie = new QMovie("./gui/ring.gif"); QLabel *processLabel = new QLabel(this); processLabel->setMovie(movie); movie->start(); _userString = user.toUtf8().constData(); _passString = pass.toUtf8().constData(); _ipString = ip.toUtf8().constData(); if (_userString == "" || _passString == "" || _ipString == "") { QMessageBox *msgBox = new QMessageBox(this); msgBox->setText("Please fill the fields"); msgBox->exec(); } else { _editPassword->clear(); this->clearLayout(_mainLayout); _mainLayout->addWidget(processLabel, 0, 0, Qt::AlignCenter); g_PTUser.logUser(_userString, _passString, _ipString); } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QMovie *mov = new QMovie(":/img/pics/start.gif"); QLabel *label = new QLabel("",0); label->setGeometry(450,200,500,300); label->setMovie(mov); mov->start(); label->setWindowFlags(Qt::FramelessWindowHint); label->show(); QTime t; t.start(); while(t.elapsed() < 1500) { a.processEvents(); } MainWindow w; w.show(); w.move((QApplication::desktop()->width()-w.width())/2,(QApplication::desktop()->height()-w.height())/2); label->close(); return a.exec(); }
void tst_QMovie::infiniteLoop() { QLabel label; label.show(); QMovie *movie = new QMovie(QLatin1String(":animations/corrupt.gif"), QByteArray(), &label); label.setMovie(movie); movie->start(); QTestEventLoop::instance().enterLoop(1); QTestEventLoop::instance().timeout(); }
void ImageView::setMovie(QMovie *movie) { reset(); QLabel *label = new QLabel(); label->setMovie(movie); movie->setParent(label); movie->start(); m_proxy = m_scene->addWidget(label); m_scene->setSceneRect(0, 0, label->sizeHint().width(), label->sizeHint().height()); }
void CloudView::createLoadingView() { loading_view_ = new QWidget(this); QVBoxLayout *layout = new QVBoxLayout; loading_view_->setLayout(layout); QMovie *gif = new QMovie(":/images/loading.gif"); QLabel *label = new QLabel; label->setMovie(gif); label->setAlignment(Qt::AlignCenter); gif->start(); layout->addWidget(label); }
void ImageProxyItem::Private::onFinished(int /*id*/, QMovie * movie) { QLabel * label = new QLabel; label->setMovie(movie); movie->setParent(label); movie->start(); label->resize(movie->frameRect().size()); QGraphicsProxyWidget * item = new QGraphicsProxyWidget(this->owner); item->setWidget(label); // HACK workaround for https://bugreports.qt.io/browse/QTBUG-55070 item->setOpacity(0.99); this->movie = movie; this->item = item; this->activity = Activity::Activated; emit this->owner->activated(this->owner); }
int main(int argc, char *argv[]) { Application app(argc, argv); QEventLoop loop; auto s(std::async(std::launch::async, [&loop]{ Datum::Solve solve(Datum::solve()); if (loop.isRunning()) { loop.quit(); } return std::move(solve); })); QLabel splash; splash.setMovie(new QMovie(([](){ static const QString basePath(":/splash/busy/"); const QStringList files(QDir(basePath).entryList(QStringList() << "*.gif")); std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> d(0,files.size() - 1); const QString& result(files.at(d(gen))); return basePath + result; })())); splash.movie()->start(); splash.show(); splash.setWindowTitle("computing. . ."); if (s.wait_until(std::chrono::system_clock::now()) != std::future_status::ready) { loop.exec(); } splash.hide(); app.showBarley(); Datum::Solve solve(s.get()); Datum d; while (!solve.empty()) { Application::showDatum(d); d = d.realize(solve.top()); solve.pop(); } Application::showDatum(d, false); app.quit(); return 0; }
DemoWidget::DemoWidget(QWidget* _parent) : QWidget(_parent) { QLightBoxWidget* lightBox = new QLightBoxWidget(this); QLabel* text = new QLabel("Some information in <b>html</b> format<br/>" "<ul><li>one</li><li>two</li><li>three</li></ul>"); QLabel* image = new QLabel; image->setPixmap(QPixmap(":/image.jpg")); QPushButton* showLB = new QPushButton(tr("Show")); QGridLayout* mainLayout = new QGridLayout; mainLayout->addWidget(text, 0, 0, Qt::AlignTop); mainLayout->addWidget(image, 0, 1); mainLayout->addWidget(showLB, 1, 1); this->setLayout(mainLayout); QLabel* lbTitle = new QLabel(tr("QLightBoxWidget")); lbTitle->setStyleSheet("font-size: 28px; font-weight: bold; color: white"); QLabel* lbProgress = new QLabel; QMovie* progressMovie = new QMovie(":/loader.gif"); lbProgress->setMovie(progressMovie); progressMovie->start(); QLabel* lbDescription = new QLabel(tr("Example how to use QLightBoxWidget\n" "in your QtWidgets applications...")); lbDescription->setStyleSheet("color: white"); QPushButton* lbClose = new QPushButton(tr("Close")); QGridLayout* lbLayout = new QGridLayout; lbLayout->setRowStretch(0, 1); lbLayout->setColumnStretch(0, 1); lbLayout->addWidget(lbTitle, 1, 1); lbLayout->addWidget(lbProgress, 1, 2, Qt::AlignRight); lbLayout->setColumnStretch(3, 1); lbLayout->addWidget(lbDescription, 2, 1, 1, 2); lbLayout->addWidget(lbClose, 3, 2); lbLayout->setRowStretch(4, 1); connect(showLB, SIGNAL(clicked()), lightBox, SLOT(show())); connect(lbClose, SIGNAL(clicked()), lightBox, SLOT(hide())); lightBox->setLayout(lbLayout); }
void BusyIndicator::Init(const QString& text) { movie_ = new QMovie(":spinner.gif"), label_ = new QLabel; QLabel* icon = new QLabel; icon->setMovie(movie_); icon->setMinimumSize(16, 16); label_->setWordWrap(true); label_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QHBoxLayout* layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(icon); layout->addSpacing(6); layout->addWidget(label_); set_text(text); }
QWidget* createDemoWidget( const QString& movieFile ) { QLabel* label = new QLabel; QPushButton* playBtn = new QPushButton("Play"); QPushButton* stopBtn = new QPushButton("Stop"); QWidget* demo = new QWidget; demo->setGeometry( 1, 1, 450, 450 ); demo->setLayout( new QVBoxLayout ); demo->layout()->addWidget( label ); demo->layout()->addWidget( playBtn ); demo->layout()->addWidget( stopBtn ); QMovie* movie = new QMovie(movieFile); label->setMovie( movie ); label->setFixedHeight( 400 ); QObject::connect( playBtn, SIGNAL(clicked()), movie, SLOT(start()) ); QObject::connect( stopBtn, SIGNAL(clicked()), movie, SLOT(stop()) ); return demo; }
WaterWaveBtn::WaterWaveBtn(const QString& pngFile, QWidget *parent) : QWidget(parent) { m_Movie = new QMovie(":/Resource/waterWave.gif"); m_Movie->setCacheMode(QMovie::CacheAll); QLabel* waterWaveLabel = new QLabel(this); waterWaveLabel->setMovie(m_Movie); waterWaveLabel->setAttribute(Qt::WA_TranslucentBackground,true); m_Movie->start(); m_Movie->setPaused(true); LabelBtn* labelBtn = new LabelBtn(pngFile,":/Resource/sound.wav",this); int size = QPixmap(":/Resource/waterWave.gif").width(); int gap = (size - labelBtn->width())/2; labelBtn->move(gap,gap); this->setFixedSize(size,size); this->setAttribute(Qt::WA_TranslucentBackground); // this->setWindowFlags(Qt::FramelessWindowHint|Qt::Window|Qt::WindowSystemMenuHint|Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint); connect(labelBtn, SIGNAL(clicked()), this, SLOT(showWaterWave())); }
MovieDisplay::MovieDisplay(QWidget *parent) : QDialog(parent), ui(new Ui::MovieDisplay) { ui->setupUi(this); //This block of code displays Llama gif when a riddle is anwsered correctly QMovie *movie = new QMovie("://images/pm8gm.gif"); QLabel *processLabel = new QLabel(this); processLabel->setGeometry(QRect(0,-75,300,300)); processLabel->setMovie(movie); movie->start(); //This block of code plays an audio file when a riddle is answered correctly. //IMPORTANT::Audio path must be hard coded to location of file! QMediaPlayer *player = new QMediaPlayer(this); player->setVolume(50); player->setMedia(QUrl("http://shredder.resnet.bju/sound/649341_SOUNDDOGS__an.mp3")); player->setVolume(100); player->play(); }
QLabel* Obstacle::spawnObstacles(QWidget *parent) { Obstacle& o = Obstacle::instance(); QLabel * enemyLabel = new QLabel(parent); Object * enemyObject; int enemySelect = rand() % 3; if(enemySelect==0){ QMovie * dogMovie = new QMovie(":/dog.gif"); enemyObject = new MadDog(); enemyLabel->setMovie(dogMovie); enemyLabel->setGeometry(parent->width(),460,128,192); dogMovie->start(); }else if(enemySelect == 1){ enemyObject = new LawnMower; QPixmap mower(":/lawnmower2.png"); enemyLabel->setPixmap(mower); enemyLabel->setGeometry(parent->width(), 514, 128,128); }else if(enemySelect==2){ enemyObject =new Hole; QPixmap hole(":/hole.png"); enemyLabel->setPixmap(hole); enemyLabel->setGeometry(parent->width(),615,128,768); } enemyLabel->setScaledContents(true); enemyLabel->show(); objects.push_back(enemyObject); spawnedObstacles.push_back(enemyLabel); return enemyLabel; }
QLabel* TabbedWebView::animationLoading(int index, bool addMovie) { if (index == -1) { return 0; } QLabel* loadingAnimation = qobject_cast<QLabel*>(m_tabWidget->getTabBar()->tabButton(index, QTabBar::LeftSide)); if (!loadingAnimation) { loadingAnimation = new QLabel(); } if (addMovie && !loadingAnimation->movie()) { QMovie* movie = new QMovie(":icons/other/progress.gif", QByteArray(), loadingAnimation); movie->setSpeed(70); loadingAnimation->setMovie(movie); movie->start(); } else if (loadingAnimation->movie()) { loadingAnimation->movie()->stop(); } m_tabWidget->getTabBar()->setTabButton(index, QTabBar::LeftSide, 0); m_tabWidget->getTabBar()->setTabButton(index, QTabBar::LeftSide, loadingAnimation); return loadingAnimation; }
void ImageView::setGifAnimation(QString fileName) { /* the built-in gif reader gives the first frame, which won't be shown but is used for tracking position and dimensions */ image_ = QImage(fileName); if(image_.isNull()) { if(imageItem_) { imageItem_->hide(); imageItem_->setBrush(QBrush()); } scene_->setSceneRect(0, 0, 0, 0); } else { scene_->clear(); imageItem_ = nullptr; // it's deleted by clear(); if(gifMovie_) { delete gifMovie_; gifMovie_ = nullptr; } QPixmap pix(image_.size()); pix.fill(Qt::transparent); QGraphicsItem *gifItem = new QGraphicsPixmapItem(pix); QLabel *gifLabel = new QLabel(); gifMovie_ = new QMovie(fileName); QGraphicsProxyWidget* gifWidget = new QGraphicsProxyWidget(gifItem); gifLabel->setAttribute(Qt::WA_NoSystemBackground); gifLabel->setMovie(gifMovie_); gifWidget->setWidget(gifLabel); gifMovie_->start(); scene_->addItem(gifItem); scene_->setSceneRect(gifItem->boundingRect()); } if(autoZoomFit_) zoomFit(); queueGenerateCache(); // deletes the cache timer in this case }
void LoadedAnimation::assign_to_QLabel(QLabel &label){ label.setMovie(&this->animation); this->animation.start(); }
void BaseWindow::displayAttack() { PublicPlayerMonster * otherMonster=CatchChallenger::ClientFightEngine::fightEngine.getOtherMonster(); PublicPlayerMonster * currentMonster=CatchChallenger::ClientFightEngine::fightEngine.getCurrentMonster(); if(otherMonster==NULL) { error("displayAttack(): crash: unable to get the other monster to display an attack"); doNextAction(); return; } if(currentMonster==NULL) { newError(tr("Internal error")+", file: "+QString(__FILE__)+":"+QString::number(__LINE__),"displayAttack(): crash: unable to get the current monster"); doNextAction(); return; } if(CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().isEmpty()) { newError(tr("Internal error")+", file: "+QString(__FILE__)+":"+QString::number(__LINE__),"displayAttack(): crash: display an empty attack return"); doNextAction(); return; } if( CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().lifeEffectMonster.empty() && CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().buffLifeEffectMonster.empty() && CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().addBuffEffectMonster.empty() && CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().removeBuffEffectMonster.empty() && CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().success ) { qDebug() << QStringLiteral("displayAttack(): strange: display an empty lifeEffect list into attack return, attack: %1, doByTheCurrentMonster: %2, success: %3") .arg(CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().attack) .arg(CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().doByTheCurrentMonster) .arg(CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().success); CatchChallenger::ClientFightEngine::fightEngine.removeTheFirstAttackReturn(); doNextAction(); return; } //if start, display text if(displayAttackProgression==0) { updateAttackTime.restart(); if(!displayFirstAttackText(true)) return; } const Skill::AttackReturn &attackReturn=CatchChallenger::ClientFightEngine::fightEngine.getFirstAttackReturn(); //get the life effect to display Skill::LifeEffectReturn lifeEffectReturn; if(!attackReturn.lifeEffectMonster.empty()) lifeEffectReturn=attackReturn.lifeEffectMonster.front(); else if(!attackReturn.buffLifeEffectMonster.empty()) lifeEffectReturn=attackReturn.buffLifeEffectMonster.front(); else { newError(tr("Internal error")+", file: "+QString(__FILE__)+":"+QString::number(__LINE__),QStringLiteral("displayAttack(): strange: nothing to display, lifeEffectMonster.size(): %1, buffLifeEffectMonster.size(): %2, addBuffEffectMonster.size(): %3, removeBuffEffectMonster.size(): %4, AttackReturnList: %5") .arg(attackReturn.lifeEffectMonster.size()) .arg(attackReturn.buffLifeEffectMonster.size()) .arg(attackReturn.addBuffEffectMonster.size()) .arg(attackReturn.removeBuffEffectMonster.size()) .arg(CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().size())); CatchChallenger::ClientFightEngine::fightEngine.removeTheFirstAttackReturn(); //doNextAction(); return; } bool applyOnOtherMonster=false; if(attackReturn.doByTheCurrentMonster) { if((lifeEffectReturn.on==ApplyOn_AloneEnemy) || (lifeEffectReturn.on==ApplyOn_AllEnemy)) applyOnOtherMonster=true; } else { if((lifeEffectReturn.on==ApplyOn_Themself) || (lifeEffectReturn.on==ApplyOn_AllAlly)) applyOnOtherMonster=true; } QLabel * attackMovie; if(applyOnOtherMonster) attackMovie=ui->labelFightMonsterAttackTop; else attackMovie=ui->labelFightMonsterAttackBottom; //attack animation { uint32_t attackId=attackReturn.attack; QString skillAnimation=DatapackClientLoader::datapackLoader.getDatapackPath()+QStringLiteral(DATAPACK_BASE_PATH_SKILLANIMATION); QString fileAnimation=skillAnimation+QStringLiteral("%1.mng").arg(attackId); if(QFile(fileAnimation).exists()) { movie=new QMovie(fileAnimation,QByteArray(),attackMovie); movie->setScaledSize(QSize(attackMovie->width(),attackMovie->height())); if(movie->isValid()) { attackMovie->setMovie(movie); movie->start(); } else qDebug() << QStringLiteral("movie loaded is not valid for: %1").arg(fileAnimation); } else { QString fileAnimation=skillAnimation+QStringLiteral("%1.gif").arg(attackId); if(QFile(fileAnimation).exists()) { movie=new QMovie(fileAnimation,QByteArray(),attackMovie); movie->setScaledSize(QSize(attackMovie->width(),attackMovie->height())); if(movie->isValid()) { attackMovie->setMovie(movie); movie->start(); } else qDebug() << QStringLiteral("movie loaded is not valid for: %1").arg(fileAnimation); } } } if(displayAttackProgression%100 /* each 400ms */ && attack_quantity_changed<0) { if(applyOnOtherMonster) { if(updateAttackTime.elapsed()<2000 /* 2000ms */) ui->labelFightMonsterTop->setVisible(!ui->labelFightMonsterTop->isVisible()); } else { if(updateAttackTime.elapsed()<2000 /* 2000ms */) ui->labelFightMonsterBottom->setVisible(!ui->labelFightMonsterBottom->isVisible()); } } if(updateAttackTime.elapsed()>2000) { ui->labelFightMonsterBottom->setVisible(true); ui->labelFightMonsterTop->setVisible(true); if(movie!=NULL) { movie->stop(); delete movie; } movie=NULL; ui->labelFightMonsterAttackTop->setMovie(NULL); ui->labelFightMonsterAttackBottom->setMovie(NULL); } int hp_to_change; if(applyOnOtherMonster) hp_to_change=ui->progressBarFightTopHP->maximum()/200;//0.5% else hp_to_change=ui->progressBarFightBottomHP->maximum()/200;//0.5% if(hp_to_change==0) hp_to_change=1; if(updateAttackTime.elapsed()>3000 /*3000ms*/) { //only if passe here before have updated all the stats { int hp_to_change; if(applyOnOtherMonster) hp_to_change=ui->progressBarFightTopHP->maximum(); else hp_to_change=ui->progressBarFightBottomHP->maximum(); if(attackReturn.lifeEffectMonster.empty()) hp_to_change=0; else if(attackReturn.lifeEffectMonster.front().quantity!=0) hp_to_change=attackReturn.lifeEffectMonster.front().quantity; else hp_to_change=0; if(hp_to_change!=0) { CatchChallenger::ClientFightEngine::fightEngine.firstLifeEffectQuantityChange(-hp_to_change); if(applyOnOtherMonster) { ui->progressBarFightTopHP->setValue(ui->progressBarFightTopHP->value()+hp_to_change); ui->progressBarFightTopHP->repaint(); } else { ui->progressBarFightBottomHP->setValue(ui->progressBarFightBottomHP->value()+hp_to_change); ui->progressBarFightBottomHP->repaint(); ui->labelFightBottomHP->setText(QStringLiteral("%1/%2").arg(ui->progressBarFightBottomHP->value()).arg(ui->progressBarFightBottomHP->maximum())); } } } displayAttackProgression=0; attack_quantity_changed=0; if(!attackReturn.lifeEffectMonster.empty()) CatchChallenger::ClientFightEngine::fightEngine.removeTheFirstLifeEffectAttackReturn(); else CatchChallenger::ClientFightEngine::fightEngine.removeTheFirstBuffEffectAttackReturn(); if(!CatchChallenger::ClientFightEngine::fightEngine.firstAttackReturnHaveMoreEffect()) { #ifdef CATCHCHALLENGER_DEBUG_FIGHT { qDebug() << "after display attack: currentMonster have hp" << ui->progressBarFightBottomHP->value() << "and buff" << ui->bottomBuff->count(); qDebug() << "after display attack: otherMonster have hp" << ui->progressBarFightTopHP->value() << "and buff" << ui->topBuff->count(); } #endif CatchChallenger::ClientFightEngine::fightEngine.removeTheFirstAttackReturn(); } //attack is finish doNextAction(); } else { if(attackReturn.lifeEffectMonster.empty()) hp_to_change=0; else if(attackReturn.lifeEffectMonster.front().quantity<0) { hp_to_change=-hp_to_change; if(abs(hp_to_change)>abs(attackReturn.lifeEffectMonster.front().quantity)) hp_to_change=attackReturn.lifeEffectMonster.front().quantity; } else if(attackReturn.lifeEffectMonster.front().quantity>0) { if(hp_to_change>attackReturn.lifeEffectMonster.front().quantity) hp_to_change=attackReturn.lifeEffectMonster.front().quantity; } else hp_to_change=0; if(hp_to_change!=0) { CatchChallenger::ClientFightEngine::fightEngine.firstLifeEffectQuantityChange(-hp_to_change); if(applyOnOtherMonster) { ui->progressBarFightTopHP->setValue(ui->progressBarFightTopHP->value()+hp_to_change); ui->progressBarFightTopHP->repaint(); } else { ui->progressBarFightBottomHP->setValue(ui->progressBarFightBottomHP->value()+hp_to_change); ui->progressBarFightBottomHP->repaint(); ui->labelFightBottomHP->setText(QStringLiteral("%1/%2").arg(ui->progressBarFightBottomHP->value()).arg(ui->progressBarFightBottomHP->maximum())); } } displayAttackTimer.start(); displayAttackProgression++; } }
NewGeneMainWindow::NewGeneMainWindow(QWidget * parent) : QMainWindow(parent), NewGeneWidget(WidgetCreationInfo(this, WIDGET_NATURE_GENERAL)), // 'this' pointer is cast by compiler to proper Widget instance, which is already created due to order in which base classes appear in class definition ui(new Ui::NewGeneMainWindow), messager(parent), theSplash(nullptr), newInputDataset(false), newOutputDataset(false) { NewGeneWidget::theMainWindow = this; connect(&messager, SIGNAL(DisplayMessageBox(STD_STRING)), this, SLOT(SignalMessageBox(STD_STRING))); try { // Instantiate Managers in main thread UIStatusManager::getManager(&messager); UIDocumentManager::getManager(&messager); UILoggingManager::getManager(&messager); UISettingsManager::getManager(&messager); UIModelManager::getManager(&messager); UIProjectManager::getManager(&messager); UIThreadManager::getManager(&messager); UITriggerManager::getManager(&messager); UIUIDataManager::getManager(&messager); UIUIActionManager::getManager(&messager); UIModelActionManager::getManager(&messager); UIMessager::ManagersInitialized = true; ui->setupUi(this); QLabel * labelLoadingSpinner { findChild<QLabel *>("labelLoadingSpinner") }; if (labelLoadingSpinner) { QMovie * movieLoadingSpinner = new QMovie(":/bluespinner.gif"); labelLoadingSpinner->setMask((new QPixmap(":/bluespinner.gif"))->mask()); labelLoadingSpinner->setAttribute(Qt::WA_TranslucentBackground); labelLoadingSpinner->setMovie(movieLoadingSpinner); movieLoadingSpinner->start(); } NewGeneTabWidget * pTWmain = findChild<NewGeneTabWidget *>("tabWidgetMain"); if (pTWmain) { pTWmain->NewGeneUIInitialize(); } } catch (boost::exception & e) { if (std::string const * error_desc = boost::get_error_info<newgene_error_description>(e)) { boost::format msg(error_desc->c_str()); QMessageBox msgBox; msgBox.setText(msg.str().c_str()); msgBox.exec(); } else { std::string the_error = boost::diagnostic_information(e); boost::format msg("Error: %1%"); msg % the_error.c_str(); QMessageBox msgBox; msgBox.setText(msg.str().c_str()); msgBox.exec(); } QCoreApplication::exit(-1); } catch (std::exception & e) { boost::format msg("Exception thrown: %1%"); msg % e.what(); QCoreApplication::exit(-1); } }
MainWindow::MainWindow( orcaprobe::IBrowser *browser, orcaqcm::OcmModel *model, const std::vector<std::string> & supportedInterfaces, QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags), browser_(browser), model_(model), supportedInterfaces_(supportedInterfaces) { assert(browser_ || "null pointer to browser"); assert(model_ || "null pointer to model"); setWindowTitle("Orca: Probe"); setWindowIcon ( QPixmap(orcaqt::orca2_2x3_yellow_130_xpm) ); QFont f; f.setPointSize( 7 ); setFont( f ); resize( qApp->desktop()->availableGeometry(0).width(), 400 ); pathLabel_ = new QLabel; QLabel *movLabel = new QLabel; movie_ = new QMovie(this); movie_->setCacheMode(QMovie::CacheAll); movie_->setFileName("/opt/orca2/images/working.mng"); movLabel->setMovie(movie_); QHBoxLayout *labelLayout = new QHBoxLayout; labelLayout->addWidget(pathLabel_, 0, Qt::AlignLeft ); labelLayout->addWidget(movLabel, 0, Qt::AlignRight ); QSplitter* split = new QSplitter(); split->setOrientation(Qt::Horizontal); split->setMinimumWidth( 400 ); ProbeView::config( browser_, pathLabel_, statusBar() ); regView_ = new ProbeView( "Regisry", model_, split ); platfView_ = new ProbeView( "Platform", model_, split ); compView_ = new ProbeView( "Component", model_, split ); ifaceView_ = new ProbeView( "Interface", model_, split ); operView_ = new ProbeView( "Operation", model_, split ); split->setStretchFactor( 0, 1 ); split->setStretchFactor( 1, 1 ); split->setStretchFactor( 2, 1 ); split->setStretchFactor( 3, 1 ); split->setStretchFactor( 4, 2 ); regView_->setNeighbors( 0, platfView_ ); platfView_->setNeighbors( regView_, compView_ ); compView_->setNeighbors( platfView_, ifaceView_ ); ifaceView_->setNeighbors( compView_, operView_ ); operView_->setNeighbors( ifaceView_, 0 ); QWidget *centralWidget = new QWidget; QVBoxLayout *layout = new QVBoxLayout; layout->addLayout( labelLayout, 0 ); layout->addWidget( split, 1 ); centralWidget->setLayout( layout ); setCentralWidget( centralWidget ); setupMenuBar(); statusBar()->showMessage( "Initialized", 2000 ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); dal_main = new DAL_main(this); QCoreApplication::setApplicationName("pocskaf2"); QCoreApplication::setOrganizationName("team2"); QSettings prevSettings("team2", "pocskaf2"); if (prevSettings.value("databaseName").isNull() || prevSettings.value("port").isNull() || prevSettings.value("username").isNull() || prevSettings.value("password").isNull() || prevSettings.value("host").isNull()) { accessdb *access = new accessdb(this); access->marker = 1; access->exec(); } else { if( dal_main->setConnection(prevSettings.value("databaseName").toString(),prevSettings.value("port").toInt(),prevSettings.value("host").toString(),prevSettings.value("username").toString(),prevSettings.value("password").toString())) { QMessageBox::information(this, tr("Соединение успешно"), tr("Соединение с базой данных установлено")); } else { QMessageBox::critical(this, tr("Ошибка подключения"), tr("Соединение с базой данных невозможно")); accessdb *access = new accessdb(this); access->marker = 1; access->exec(); } } Authorization *w=new Authorization(this) ; w->setWindowFlags(Qt::Dialog | Qt::Desktop); w->exec(); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(showTime())); timer->start(1000); showTime(); QPixmap pixmap(":/img/img/pocs2.png"); QSplashScreen *splash = new QSplashScreen(pixmap); QFont splashFont; splashFont.setPixelSize(17); splash->setFont(splashFont); splash->show(); QTime time; time.start(); for (int i = 0; i < 100; ) { if (time.elapsed() > 5) { time.start(); ++i; } splash->showMessage(tr(" Загрузка системы: ") + QString::number(i) + "%", Qt::AlignLeft | Qt::AlignBottom , Qt::black); QCoreApplication::processEvents(); } QSqlQuery * empNameQuery = new QSqlQuery(dal_main->db); empNameQuery->prepare("SELECT st_fio, st_photo FROM is_sotrudniki where id_sotr = " + QString::number(dal_main->getCurrentEmployee())); empNameQuery->exec(); empNameQuery->first(); if(empNameQuery->isValid()) this->setWindowTitle("SMT v. 1.0 (текущий пользователь - " + empNameQuery->value(0).toString() + ")"); checkNaznPoruch = new QSqlQuery(dal_main->db); checkNaznPoruch->prepare("SELECT count(id_poruchenie) FROM is_porucheniya where checkPoruch = 0 and poruchitel = " + QString::number(dal_main->getCurrentEmployee())); checkIspolPoruch = new QSqlQuery(dal_main->db); checkIspolPoruch->prepare("SELECT count(id_poruchenie) FROM is_porucheniya where checkIspoln = 0 and ispolnitel = " + QString::number(dal_main->getCurrentEmployee())); checker = new QTimer; // checkDatePoruch = new QSqlQuery(dal_main->db); // checkDatePoruch->prepare("SELECT count(id_poruchenie) FROM is_porucheniya where check_date and checkIspoln = 1 and ispolnitel = " + QString::number(dal_main->getCurrentEmployee())); connect(checker,SIGNAL(timeout()),this,SLOT(on_check())); checker->setInterval(10000); checker->start(); icon = new QSystemTrayIcon(this); icon->setIcon(QIcon(":/img/img/institution_icon.png")); icon->show(); //icon->setContextMenu(ui->menu_file); connect(icon,SIGNAL(messageClicked()),this,SLOT(on_actionChecks())); //Open form Request ui->pushButton_show->setVisible(false); ui->pushButton_show->setFlat(true); ui->pushButton_hide->setFlat(true); ui->groupBox_main->setContentsMargins(0,0,0,0); ui->mdiArea->setVisible(false); QGraphicsDropShadowEffect * ef1 = new QGraphicsDropShadowEffect; ef1->setBlurRadius(15); QGraphicsDropShadowEffect * ef2 = new QGraphicsDropShadowEffect; ef2->setBlurRadius(15); QGraphicsDropShadowEffect * ef3 = new QGraphicsDropShadowEffect; ef3->setBlurRadius(15); QGraphicsDropShadowEffect * ef4 = new QGraphicsDropShadowEffect; ef4->setBlurRadius(15); QGraphicsDropShadowEffect * ef5 = new QGraphicsDropShadowEffect; ef5->setBlurRadius(15); QGraphicsDropShadowEffect * ef6 = new QGraphicsDropShadowEffect; ef6->setBlurRadius(15); QGraphicsDropShadowEffect * ef7 = new QGraphicsDropShadowEffect; ef7->setBlurRadius(15); QGraphicsDropShadowEffect * ef8 = new QGraphicsDropShadowEffect; ef8->setBlurRadius(15); QGraphicsDropShadowEffect * ef9 = new QGraphicsDropShadowEffect; ef9->setBlurRadius(15); ui->pushButton1->setGraphicsEffect(ef1); ui->pushButton2->setGraphicsEffect(ef2); ui->pushButton3->setGraphicsEffect(ef3); ui->pushButton4->setGraphicsEffect(ef4); ui->pushButton5->setGraphicsEffect(ef5); ui->pushButton6->setGraphicsEffect(ef6); ui->pushButton7->setGraphicsEffect(ef7); ui->pushButton8->setGraphicsEffect(ef8); ui->pushButton9->setGraphicsEffect(ef9); // this->setCentralWidget(ui->mdiArea); // Настраиваем виджет перекрытия QLightBoxWidget* lightBox = new QLightBoxWidget(this); QLabel* lbTitle = new QLabel(empNameQuery->value(0).toString()); lbTitle->setStyleSheet("font-size: 28px; font-weight: bold; color: white"); QLabel* lbProgress = new QLabel; QMovie* progressMovie = new QMovie(empNameQuery->value(1).toString()); progressMovie->setScaledSize(QSize(250,200)); lbProgress->setMovie(progressMovie); progressMovie->start(); QLabel* lbDescription = new QLabel(tr("Для входа в систему нажмите Войти")); lbDescription->setStyleSheet("color: white"); QPushButton* lbClose = new QPushButton(tr("Войти")); QGridLayout* lbLayout = new QGridLayout; lbLayout->setRowStretch(0, 1); lbLayout->setColumnStretch(0, 1); lbLayout->addWidget(lbTitle, 1, 1); lbLayout->addWidget(lbProgress, 1, 2, Qt::AlignRight); lbLayout->setColumnStretch(3, 1); lbLayout->addWidget(lbDescription, 2, 1, 1, 2); lbLayout->addWidget(lbClose, 3, 2); lbLayout->setRowStretch(4, 1); connect(ui->action_Oteshel, SIGNAL(triggered()), lightBox, SLOT(show())); connect(lbClose, SIGNAL(clicked()), lightBox, SLOT(hide())); lightBox->setLayout(lbLayout); // ui->menuBar->setVisible(false); ui->mainToolBar->setVisible(false); ui->groupBox->setVisible(false); splash->finish(this); /*QGridLayout *userl = new QGridLayout(ui->userWidget); ui->userWidget->setLayout(userl); QLabel* lbProgress1 = new QLabel; QMovie* progressMovie1 = new QMovie(empNameQuery->value(1).toString()); progressMovie1->setScaledSize(QSize(250,200)); lbProgress1->setMovie(progressMovie1); progressMovie1->start(); userl->addWidget(lbProgress1);*/ }
int main(int argc, char *argv[]) { // QDir currentDir(QDir::currentPath()); //QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath()); for deployement ? /********************* FOR DEV ********************/ #ifdef DEV #ifdef Q_OS_LINUX //pour linux currentDir.cdUp(); currentDir.cd("bar-software"); #endif #ifdef Q_OS_MAC // Pour MAC currentDir.cd("../../../../bar-software"); #endif #ifdef Q_OS_WIN32 // Pour Windows currentDir.cd("../bar-software"); #endif GLOBAL_PATH = currentDir.absolutePath()+"/"; qDebug() << "GLOBAL_PATH :" << GLOBAL_PATH; #endif /********************************************** std::pair<std::string,std::string> name = {"Woody","Rousseau"}; Customer cus("wrousseau",name,"2014"); qDebug() << cus.getFirstName().c_str() << " " << cus.getFamilyName().c_str() << " has " << cus.getBalance() << "€ available."; cus.addToBalance(70); qDebug() << cus.getFirstName().c_str() << " " << cus.getFamilyName().c_str() << " has " << cus.getBalance() << "€ available."; // Test cart Product Duvel; Cart monPanier(Duvel); monPanier.removeProductFromCart( std::make_shared<Product>(Duvel) ); monPanier.clearCart(); Database DB; DB.openDatabase(); DB.initializeDatabaseForm(); //DB.getCustomerFromId(152); DB.getProductsFromCategory(5); DB.getProductFromId(1); DB.getLastOperations(30); Plotting plot; plot.setDb(DB.getHandle()); db_dataarray Values_2 = plot.productStock(41,1); db_dataarray Values = plot.productConsumption(41,1); DB.getAllProducts (); DB.closeDatabase(); */ QApplication application(argc, argv); application.setWindowIcon(QIcon(GLOBAL_PATH + "resources/pictures/icon.png")); QLabel* splashWidget = new QLabel; #ifndef DEV QMovie splashscreen(GLOBAL_PATH + "resources/pictures/splashscreen.gif"); splashWidget->setMovie(&splashscreen); splashscreen.start(); splashWidget->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); splashWidget->show(); #endif //Test graph Controller controller; qDebug() << "Controlleur : " << &controller; QFile css(GLOBAL_PATH + "resources/design/mainDesign.css"); if(css.open(QIODevice::ReadOnly)) { application.setStyleSheet(css.readAll()); } MainWindow mainWindow(&controller); mainWindow.setController(&controller); mainWindow.setSplashscreen(splashWidget); // Mainwindow will be shown after a timer defined in MainWindow and the splashcreen will be destroyed at the same time //delete w; // ########## TEST GRAPHS ############ //mainWindow.setGraph(Values, "xTitle", "yTitle", "Title de famille"); //mainWindow.setGraph(Values_2, "xTitle", "yTitle", "Title de famille"); return application.exec(); }
void TabBarWidget::updateTabs(int index) { if (index < 0 && sender() && sender()->inherits(QStringLiteral("Otter::Window").toLatin1())) { for (int i = 0; i < count(); ++i) { if (sender() == qvariant_cast<QObject*>(tabData(i))) { index = i; break; } } } const QSize size = tabSizeHint(count() - 1); const int limit = ((index >= 0) ? (index + 1) : count()); const bool canResize = (m_tabSize > 0); const bool isHorizontal = (shape() == QTabBar::RoundedNorth || shape() == QTabBar::RoundedSouth); const bool isNarrow = ((isHorizontal ? size.width() : size.height()) < 60); for (int i = ((index >= 0) ? index : 0); i < limit; ++i) { const bool isLoading = getTabProperty(i, QLatin1String("isLoading"), false).toBool(); QLabel *label = qobject_cast<QLabel*>(tabButton(i, QTabBar::LeftSide)); if (label) { if (isLoading) { if (!label->movie()) { QMovie *movie = new QMovie(QLatin1String(":/icons/loading.gif"), QByteArray(), label); movie->start(); label->setMovie(movie); } } else { if (label->movie()) { label->movie()->deleteLater(); label->setMovie(NULL); } label->setPixmap(getTabProperty(i, QLatin1String("icon"), QIcon(getTabProperty(i, QLatin1String("isPrivate"), false).toBool() ? ":/icons/tab-private.png" : ":/icons/tab.png")).value<QIcon>().pixmap(16, 16)); } } if (canResize) { QWidget *button = tabButton(i, QTabBar::RightSide); if (button) { button->setVisible((!isNarrow || (i == currentIndex())) && !getTabProperty(i, QLatin1String("isPinned"), false).toBool()); } } } showPreview(tabAt(mapFromGlobal(QCursor::pos()))); }
StepsNewGesture::StepsNewGesture(ExecutionManager *pExecutionManager, int pNumberOfGesture, QWidget *parent) { int labelFontSize = 23; QColor labelColor = QColor(210,210,210); this->executionManager = pExecutionManager; this->commandChooser = new CommandChooser(parent); this->stepper = new StepperNewGesture(this->executionManager, this->commandChooser, pNumberOfGesture, parent); /* Local */ QString locale = QLocale::system().name().section('_', 0, 0); XmlConf* conf = Xml().importConfig(Utils::getConfigLocation()); if (conf != NULL) { if (conf->language != NULL) { locale = conf->language; } } if (locale.compare("en") != 0 && locale.compare("fr") != 0) { locale = "en"; } /* STEP 0 */ QWidget *step = new QWidget(stepper); QVBoxLayout* vLayoutStep = new QVBoxLayout(step); vLayoutStep->setMargin(0); Label* lblStepTop = new Label(tr("\n\nThe recording of a gesture MUST start and end with a neutral stance.\n\n"),step); lblStepTop->setTextColor(labelColor); lblStepTop->changeFontSize(16); lblStepTop->setPaintShadow(false); lblStepTop->setFixedHeight(60); lblStepTop->setPaintShadow(false); QLabel *picNeutral = new QLabel(step); QPixmap pix = QPixmap(Utils::getResourcesDirectory() + "/tuto/neutral_" + locale + ".png"); picNeutral->setPixmap(pix); vLayoutStep->addWidget(lblStepTop); vLayoutStep->addWidget(picNeutral); stepper->addStep(tr("Information"),true,false,true, StepperNewGesture::First ,step); /* STEP 1 */ Label *step1 = new Label(tr("You will have 5 seconds to place\nbefore registering your gesture\n1/") + QString::number(pNumberOfGesture),stepper); step1->changeFontSize(labelFontSize); step1->setTextColor(labelColor); step1->setPaintShadow(false); stepper->addStep(tr("Add a new gesture"),true,true,true, StepperNewGesture::StartTimer ,step1); /* STEP 2 */ Label *step2 = new Label(tr("Ready ?"),stepper); step2->changeFontSize(labelFontSize); step2->setTextColor(labelColor); step2->setPaintShadow(false); stepper->addStep(tr("Add a new gesture"),false,true,true,StepperNewGesture::StartRecording ,step2); /* STEP 3 */ QWidget* step3 = new QWidget(parent); QVBoxLayout* vLayoutStep3 = new QVBoxLayout(step3); GlView* glViewStep3= new GlView(step3); DAOLayer* dao = DAOLayer::getInstance(); connect(dao, SIGNAL(skeletonDataReceived(QString)), glViewStep3,SLOT(skeletonDataReceived(QString))); Label* labelStep3 = new Label(tr("Realtime visualizer"), step3); labelStep3->setFixedHeight(50); labelStep3->changeFontSize(labelFontSize); labelStep3->setTextColor(labelColor); labelStep3->setPaintShadow(false); vLayoutStep3->addWidget(labelStep3); vLayoutStep3->addWidget(glViewStep3); glViewStep3->startAnimating(); stepper->addStep(tr("Add a new gesture"),false,true,true,StepperNewGesture::VisualizeRecording ,step3); /* STEP 4 */ QWidget* step4 = new QWidget(parent); QVBoxLayout* vLayoutStep4 = new QVBoxLayout(step4); this->glViewStep4= new GlView(step4); connect(this->executionManager, SIGNAL(gestureRecorded(Gesture*)), this, SLOT(gestureReceived(Gesture*))); Label *labelStep4 = new Label(tr("Is it the right gesture ?"),stepper); labelStep4->setFixedHeight(50); labelStep4->changeFontSize(labelFontSize); labelStep4->setTextColor(labelColor); labelStep4->setPaintShadow(false); vLayoutStep4->addWidget(labelStep4); vLayoutStep4->addWidget(this->glViewStep4); this->glViewStep4->startAnimating(); stepper->addStep(tr("Add a new gesture"),true,true,true,StepperNewGesture::ConfigureAction,step4); /* STEP 5 */ QWidget* step5 = new QWidget(parent); QVBoxLayout* vLayout = new QVBoxLayout(step5); QWidget* step5Bottom = new QWidget(step5); QHBoxLayout* hLayoutStep5 = new QHBoxLayout(step5Bottom); this->commandChooser->setParent(step5Bottom); ComboBox *combo = this->commandChooser->getCommandComboBox(); KeyListener *keyListener = this->commandChooser->getCommandKeyListener(); TextField *tfNewGesture = this->commandChooser->getCommandTextField(); ButtonElement *btnCommand = this->commandChooser->getCommandButton(); Label* labelRecordName = new Label("Record name : ",step5); labelRecordName->setPaintShadow(false); labelRecordName->setTextColor(labelColor); TextField *tfRecordName = this->commandChooser->getRecordNameTextField(); hLayoutStep5->addWidget(combo); hLayoutStep5->addWidget(keyListener); hLayoutStep5->addWidget(tfNewGesture); hLayoutStep5->addWidget(btnCommand); hLayoutStep5->addWidget(labelRecordName); hLayoutStep5->addWidget(tfRecordName); Label *labelStep5 = new Label(tr("Command linked to your gesture"),step5); labelStep5->setPaintShadow(false); labelStep5->changeFontSize(labelFontSize); labelStep5->setTextColor(labelColor); labelStep5->setFixedHeight(50); vLayout->addWidget(labelStep5); vLayout->addWidget(step5Bottom); stepper->addStep(tr("Add a new gesture"),true,false,true,StepperNewGesture::SaveRecord,step5); /* STEP 6 */ QWidget* step6 = new QWidget(parent); QLabel* labelLoading = new QLabel(step6); QMovie* loading = new QMovie(Utils::getResourcesDirectory() + "loader.gif", QByteArray(), labelLoading); labelLoading->resize(128, 128); labelLoading->setMovie(loading); loading->start(); stepper->addStep(tr("Add a new gesture"),false,false,false,StepperNewGesture::Close,step6); labelLoading->move(step6->width()/2 - labelLoading->width()/2, step6->height()/2 - labelLoading->height()/2); }