Example #1
0
void Tank::deleteTank()
{
    alive = false;
    head->setPixmap(QPixmap(":/images/images/empty.png").scaled(pixsize,pixsize));
    setPixmap(QPixmap(":/images/images/empty.png").scaled(pixsize,pixsize));

    int stime;
    long ltime;
    int random;
    ltime = time(NULL);
    stime = (unsigned) ltime/2;
    srand(stime);
    random = rand()%3 +1;

    QMediaPlayer *explode = new QMediaPlayer();
    explode->setMedia(QUrl("qrc:/sounds/sounds/tank/explode" + QString::number(random) + ".mp3"));
    explode->play();

    // анимация
    gif_anim = new QLabel();
    gif_anim->setStyleSheet("background-color: transparent;");
    QMovie *movie = new QMovie(":/images/images/anim/Explo.gif");
    gif_anim->setMovie(movie);
    gif_anim->move(x()-25,y()-25);
    movie->setScaledSize(QSize(250,250));
    movie->start();
    QGraphicsProxyWidget *proxy = game->scene->addWidget(gif_anim);
    QTimer::singleShot(2500, this, SLOT(deleteGif()));
}
void PixmapListDialog::setMovie( const QByteArray& image )
{
	if ( label->movie() ) delete label->movie();
	if ( movie_buffer ) delete movie_buffer;

	movie_buffer = new QBuffer();
	movie_buffer->buffer() = image;
	movie_buffer->open( QIODevice::ReadOnly );

	QMovie *pm = new QMovie( movie_buffer );

	QBuffer *movie_buffer_tmp = new QBuffer();
	movie_buffer_tmp->buffer() = image;
	movie_buffer_tmp->open( QIODevice::ReadOnly );
	QMovie *pm_tmp = new QMovie( movie_buffer_tmp );
	pm_tmp->jumpToFrame ( 0 );
	QImage background_image = pm_tmp->currentImage();
	QSize scaled_size = pm_tmp->currentImage().size();
	pm_tmp->stop();
	delete pm_tmp;
	delete movie_buffer_tmp;

	scaled_size.scale( background_label->size(), Qt::KeepAspectRatio );
	pm->setScaledSize( scaled_size );
	background_label->setPixmap( QPixmap::fromImage( background_image.scaled( scaled_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) ) );
	pm->setCacheMode( QMovie::CacheAll );
	label->setMovie( pm );
	label->movie()->start();
}
Example #3
0
void InfoWidget::updateFieldLabel(IInfoWidget::InfoField AField)
{
	switch (AField)
	{
	case AccountName:
	{
		QString name = field(AField).toString();
		ui.lblAccount->setText(Qt::escape(name));
		ui.lblAccount->setVisible(isFieldVisible(AField) && !name.isEmpty());
		break;
	}
	case ContactName:
	{
		QString name = field(AField).toString();

		IRosterItem ritem = FRoster ? FRoster->rosterItem(FContactJid) : IRosterItem();
		if (isFiledAutoUpdated(AField) && ritem.name.isEmpty())
			ui.lblName->setText(Qt::escape(FContactJid.full()));
		else
			ui.lblName->setText(QString("<big><b>%1</b></big> - %2").arg(Qt::escape(name)).arg(Qt::escape(FContactJid.full())));

		ui.lblName->setVisible(isFieldVisible(AField));
		break;
	}
	case ContactStatus:
	{
		QString status = field(AField).toString();
		ui.lblStatus->setText(Qt::escape(status));
		ui.lblStatus->setVisible(isFieldVisible(AField) && !status.isEmpty());
		break;
	}
	case ContactAvatar:
	{
		if (ui.lblAvatar->movie()!=NULL)
			ui.lblAvatar->movie()->deleteLater();

		QString fileName = field(AField).toString();
		if (!fileName.isEmpty())
		{
			QMovie *movie = new QMovie(fileName,QByteArray(),ui.lblAvatar);
			QSize size = QImageReader(fileName).size();
			size.scale(QSize(32,32),Qt::KeepAspectRatio);
			movie->setScaledSize(size);
			ui.lblAvatar->setMovie(movie);
			movie->start();
		}
		else
		{
			ui.lblAvatar->setMovie(NULL);
		}
		ui.lblAvatar->setVisible(isFieldVisible(AField) && !fileName.isEmpty());

		break;
	}
	default:
		break;
	}
}
void ReceiveCoinsDialog::showBuyGuldenDialog()
{
#ifdef WIN32
    if (WIN32) {

        QDesktopServices::openUrl(QUrl("https://gulden.com/purchase"));
        return;
    }
#endif

#if defined(HAVE_WEBENGINE_VIEW) || defined(HAVE_WEBKIT)
    ui->receiveCoinsStackedWidget->setCurrentIndex(1);

    ui->accountRequestPaymentButtonComposite->setVisible(false);
    ui->accountBuyGuldenButton->setVisible(false);
    ui->accountSaveQRButtonComposite->setVisible(false);
    ui->accountCopyToClipboardButtonComposite->setVisible(false);
    ui->cancelButton->setVisible(true);
    ui->closeButton->setVisible(false);
    ui->cancelButtonGroup->setVisible(true);
    ui->generateRequestButton->setVisible(false);
    ui->generateAnotherRequestButton->setVisible(false);
    ui->accountBuyButton->setVisible(true);

    QMovie* movie = new QMovie(":/Gulden/loading_animation");
    if (movie && movie->isValid()) {
        ui->loadingAnimationLabel->setVisible(true);
        buyView->setVisible(false);
        movie->setScaledSize(QSize(30, 30));
        ui->loadingAnimationLabel->setMovie(movie);
        movie->start();
    } else {
        ui->loadingAnimationLabel->setVisible(false);
        buyView->setVisible(true);
        if (movie)
            delete movie;
    }

    buyView->load(QUrl("https://gulden.com/purchase"));

#if defined(HAVE_WEBENGINE_VIEW)
    buyView->page()->setBackgroundColor(Qt::transparent);
#else
    QPalette palette = buyView->palette();
    palette.setBrush(QPalette::Base, Qt::transparent);
    buyView->page()->setPalette(palette);
    buyView->setAttribute(Qt::WA_OpaquePaintEvent, false);
    buyView->page()->setLinkDelegationPolicy(QWebPage::DontDelegateLinks);
#endif

    connect(buyView, SIGNAL(loadFinished(bool)), this, SLOT(loadBuyViewFinished(bool)));
#endif
}
Example #5
0
Spinbox::Spinbox(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Spinbox)
{
    ui->setupUi(this);
    ui->label->setText(tr("Загрузка может занять несколько минут, подождите"));
    QMovie* spinnerMovie = new QMovie(":/spinner.gif");
    QSize t2(50, 50);
    spinnerMovie->setScaledSize(t2);
    ui->label_2->setMovie(spinnerMovie);
    spinnerMovie->start();
}
Example #6
0
MyLogo::MyLogo(QWidget *parent)
:QLabel(parent)
{
    QLabel *label_logo = new QLabel(parent);
    filename = QString::fromUtf8("./system_picture/logo.gif");
    QMovie *mygif = new QMovie(filename);
    label_logo->setGeometry(660, 30, 60, 50);
    mygif->setScaledSize(QSize(60, 50));
    label_logo->setMovie(mygif);
    mygif->setSpeed(50);
    mygif->start();
}
Example #7
0
BusyDialog::BusyDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::BusyDialog)
{
    ui->setupUi(this);
    setWindowFlags(Qt::Popup);

    QMovie *movie = new QMovie(":/loading.gif");
    movie->setParent(this);
    movie->setSpeed(50);// 50%
    movie->setScaledSize(QSize(64, 64));
    ui->labelGif->setMovie(movie);
}
Example #8
0
void AbstractItemDetail::initDialog()
{
	newNoteDialog = new CreateNoteDialog(this);
	newNoteDialog->hide();

	notesModel = new NotesModel(this);

	loading = new QLabel(this);
	QMovie *mov = new QMovie();
	mov->setCacheMode(QMovie::CacheAll);
	loading->setMovie(mov);
	mov->setFileName(":loading.gif");
	mov->setScaledSize(QSize(20, 20));
	mov->start();

	crm = SugarCrm::getInstance();

	notesTable = new QTableView(this);
	notesTable->verticalHeader()->hide();
	notesTable->horizontalHeader()->setStretchLastSection(true);
	notesTable->setSelectionBehavior(QAbstractItemView::SelectRows);
	notesTable->setSelectionMode(QAbstractItemView::SingleSelection);

	// buttons
	save = new QPushButton(QIcon(":save.png"), tr("Speichern"));
	newNote = new QPushButton(QIcon(":notes.png"), tr("Neue Notiz"));
	newDocument = new QPushButton(QIcon(":documents.png"), tr("Neues Dokument"));

	connect(save, SIGNAL(pressed()),
			this, SLOT(saveChanges()));
	connect(newNote, SIGNAL(pressed()),
			this, SLOT(showNewNoteDialog()));
	connect(newNoteDialog, SIGNAL(accepted()),
			this, SLOT(createNewNote()));
	connect(newDocument, SIGNAL(pressed()),
			this, SLOT(showNewDocumentDialog()));
	connect(notesTable, SIGNAL(doubleClicked(QModelIndex)),
			this, SLOT(downloadNoteAttachment(QModelIndex)));
}
Example #9
0
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);*/
}
Example #10
0
void Player::keyActions() // player действия при нажатии клавиши
{
    game->centerOn(this);

    lastX = x();
    lastY = y();
    lastDeg = degree;
    lastHDeg = hdegree;
    lastHealth = health;

    // эффект получения урона (должен стоять перед движением)
    if (wou)
    {
        /*
        int x1 = centralX();
        int y1 = centralY();
        wound->setPos(x1-game->width()/2,y1-game->height()/2);
        */
    }

    // движение вперед, назад
    if (mf)
    {
        moveForward();
        if (game->createBots)
            *bot << "mf ";
    }
    if (mb)
    {
        moveBack();
        if (game->createBots)
            *bot << "mb ";
    }

    // если player вышел за границы
    if (this->x() < game->dop - pixsize/2 ||
        this->x() > game->scene->width()-game->dop*2 + 20 ||
        this->y() < game->dop - pixsize/2 ||
        this->y() > game->scene->height()-game->dop*2 + 20)
    {
        // координата Х в центре экрана
        int x1 = centralX();

        // координата Y в центре экрана
        int y1 = centralY();

        if (out == false)
        {
            out = true;
            outTime = QTime::currentTime();
            outTimer = outMaxTime;

            QString image = ":/images/images/out.png";
            caution = new Caution(image, "CAUTION", 5);
            caution->setPos(x1-200,y1-88);
            game->scene->addItem(caution);
        }
        caution->setPos(x1-200, y1-88);

        if (outTime.msecsTo(QTime::currentTime()) > 1000)
        {
            if (outTimer > 0)
            {
                outTimer--;
                outTime = outTime.addSecs(1);
                caution->decTimer();
            }
            else
            {
                // DIE M**********R!
                //qDebug() << "you died";
                out = false;
                outTimer = outMaxTime;
                delete caution;

                // убить
                killPlayer();
                // BUHAHA
            }
        }
    }
    else
    {
        if (out == true)
        {
            out = false;
            outTimer = outMaxTime;
            delete caution;
        }
    }

    // универсальный поворот
    if (rl || rr)
    {
        playerRotate();
        spin++;
    }

    // ты ничего не видел
    if (rl == false && rr == false)
        spin = 0;
    // совершенно ничего
    if (spin == 540)
    {
        QMediaPlayer *sound = new QMediaPlayer();
        sound->setMedia(QUrl("qrc:/sounds/sounds/spin.mp3"));
        sound->play();
    }

    // поворот башни
    if (hl)
    {
        headLeft();
        if (game->createBots)
            *bot << "hl ";
    }
    if (hr)
    {
        headRight();
        if (game->createBots)
            *bot << "hr ";
    }

    // звук поворота башни
    if ((hr || hl) &&  tankhrotate->state() == QMediaPlayer::StoppedState) // если звук поворота еще не проигрывался
        tankhrotate->play();

    if (hr == false && hl == false && tankhrotate->state() == QMediaPlayer::PlayingState)
        tankhrotate->stop();

    // стрельба + звуки стрельбы
    if (fr && fireReady)
    {
        playerFire();
        reloading = false; // звук перезарядки еще на начат
        isFiring = 1;

        // анимация перезарядки
        reloadAnim = new QLabel();
        reloadAnim->setStyleSheet("background-color: transparent;");
        QMovie *movie = new QMovie(":/images/images/anim/Reload.gif");
        reloadAnim->setMovie(movie);
        reloadAnim->move(x()+20,y()+20);
        movie->setScaledSize(QSize(180,180));
        //movie->setSpeed(100);
        movie->start();
        QGraphicsProxyWidget *proxy = game->scene->addWidget(reloadAnim);

        if (game->createBots)
            *bot << "fr ";
    }
    if (fireReady == false) // счетчик для ожидания между выстрелами
    {
        fireCount += keyDelay;

        reloadAnim->move(x()+20,y()+20);
    }
    if ((fireCount > fireTime - bulletready->duration()) && reloading == false) // звук перезарядки
    {
        reloading = true; // перезарядка уже начата (защита от нескольких)
        bulletready->play();
    }
    if (fireCount > fireTime) // готовность выстрела
    {
        fireReady = true;
        fireCount = 0;

        delete reloadAnim;
    }

    if (game->createBots)
        *bot << endl;

    if (lastX != x() || lastY != y() || lastDeg != degree || lastHDeg != hdegree || lastHealth != health)
        emit KeyPressed();

    if (alive == false || (mf == false && mb == false && rl == false && rr == false && hl == false && hr == false && fr == false &&
                          fireReady == true && tankhrotate->state() == QMediaPlayer::StoppedState && out == false))
    {
        action = false;
        timer->stop();
    }
}
void GLabel::setGifPixmap(QString paramstr)
{
    int max_width = parent_maxwidth - 50;
    int all_word_width;

    qDebug() << paramstr;

    label_text->setWordWrap(false);
    label_text->adjustSize();

    all_word_width = label_text->width();
    label_text->setWordWrap(true);

    if (all_word_width > max_width) {
        qDebug() << parent_maxwidth;

        label_text->setMaximumWidth(max_width - 20 - 30);


        QMovie *movie = new QMovie(paramstr);
        if (movie->scaledSize().width() > 30) {
            movie->setScaledSize(QSize(30, 30));
        }
        label_text->setMovie(movie);
        movie->start();


        label_text->setTextInteractionFlags(Qt::TextSelectableByMouse);//设置文本内容可选
        label_text->adjustSize();

//        m_height = label_text->width() * 1.0 / 300 * label_text->height();
        m_height = label_text->height();
        m_width  = parent_maxwidth - 15;
        this->resize(m_width, m_height + 40);

    } else {
        label_text->setWordWrap(false);
        m_height = 66;

        QMovie *movie = new QMovie(paramstr);
        qDebug() << movie->scaledSize().height();
        if (movie->scaledSize().width() > 30) {
            movie->setScaledSize(QSize(30, 30));
        }
        label_text->setMovie(movie);
        movie->start();

        label_text->setTextInteractionFlags(Qt::TextSelectableByMouse);//设置文本内容可选
        label_text->adjustSize();

        m_width = label_text->width() + 40 + 30;
        this->resize(m_width + 10, m_height);

//        label_text->setMaximumWidth(100);
//        this->setMaximumWidth(100);
    }

    if (people == GLabel::She) {
        label_text->setGeometry(20 + 40, 20, this->width() - 40 - 30, this->height()-40);
    } else {
        label_text->setGeometry(20, 20, this->width() - 40 - 30, this->height() - 40);
    }
    update();
}