Пример #1
0
void HSCardDownloader::saveWebImage(QNetworkReply * reply)
{
    reply->deleteLater();

    QString code = gettingWebCards[reply];

    if(reply->error() != QNetworkReply::NoError)
    {
        emit pDebug("Failed to download card image: " + code, Error);
        emit pLog(tr("Web: Failed to download card image."));
        return;
    }
    QImage webImage;
    webImage.loadFromData(reply->readAll());

    if(!webImage.save(Utility::appPath() + "/HSCards/" + code + ".png", "png"))
    {
        emit pDebug("Failed to save card image to disk: " + code, Error);
        emit pLog(tr("File: ERROR:Saving card image to disk. Make sure HSCards dir is in the same place as the exe."));
        return;
    }

    emit downloaded(code);
    gettingWebCards.remove(reply);
    emit pDebug("Web Cards remaining(-1): " + QString::number(gettingWebCards.count()));
    emit pLog(tr("Web: New card image downloaded."));
}
Пример #2
0
void LogLoader::checkLogConfig(QString logConfig)
{
    emit pDebug("Checking log.config");

    QFile file(logConfig);
    if(!file.open(QIODevice::ReadWrite | QIODevice::Text))
    {
        emit pDebug("Cannot access log.config", Error);
        emit pLog(tr("Log: ERROR: Cannot access log.config"));
        QSettings settings("Arena Tracker", "Arena Tracker");
        settings.setValue("logConfig", "");
        return;
    }

    QString data = QString(file.readAll());
    QTextStream stream(&file);

    checkLogConfigOption("[Bob]", data, stream);
    checkLogConfigOption("[Power]", data, stream);
    checkLogConfigOption("[Rachelle]", data, stream);
    checkLogConfigOption("[Zone]", data, stream);
    checkLogConfigOption("[Ben]", data, stream);
    checkLogConfigOption("[Asset]", data, stream);

    file.close();
}
Пример #3
0
void PipeApprover::addDispatchOperation(const Tp::MethodInvocationContextPtr<> &context,
        const Tp::ChannelDispatchOperationPtr &dispatchOperation) 
{
    CaseHandler<void> handler = pipeCM.checkNewChannel(
            dispatchOperation->connection(),
            dispatchOperation->channels());

    pDebug() << "New channels to check at approver";
    if(handler) {
        pDebug() << "Claiming ownership of some channels from: \n"
            << "    Connection: " << dispatchOperation->connection()->busName() 
            << "\n    Channels number: " << dispatchOperation->channels().size();
        MoveOnCopy<CaseHandler<void>> moved_handler(std::move(handler));

        connect(dispatchOperation->claim(), 
                &Tp::PendingOperation::finished, 
                this, 
                [moved_handler](Tp::PendingOperation *op) {
                    if(op->isError()) 
                        pDebug() << "Error while claiming channel: " << op->errorMessage();
                    else moved_handler.value(); 
                });
    } else {
        pDebug() << "New channels are rejected: \n" 
            << "    Connection: " << dispatchOperation->connection()->busName() 
            << "\n    Channels number: " << dispatchOperation->channels().size();
    }
    SCOPE_EXIT( context->setFinished(); );
Пример #4
0
void StatesValidator::validateStateChange(Phonon::State newstate, Phonon::State oldstate)
{
    if (!validateStateTransition(newstate, oldstate)) {
        pDebug() << "Invalid state transition:" << oldstate << "->" << newstate;
        P_INVALID_STATE("Invalid state transition");
    } else {
        pDebug() << "Valid state transition:" << oldstate << "->" << newstate;
    }
    m_prevState = oldstate;
}
Пример #5
0
// time critical
bool PHPQt::qt_metacall(smokephp_object* o, Smoke::Stack args)
{
    Context::setCallType( Context::SlotCall );
    const QMetaObject* staticMetaObject = o->meta();
    const int _id = args[2].s_int;
    const int offset = staticMetaObject->methodOffset();

    const QByteArray signature( staticMetaObject->method(_id).signature() );
    const QByteArray metaMethodName = signature.left( signature.indexOf("(") );

    //! - if we have a slot overridden in php user space: call it
    //!   @see InvokeSlot
    if( PHPQt::methodExists( o->ce_ptr() , metaMethodName.constData()) ) {
        pDebug( PHPQt::Slot ) << " userspace " << signature << o->ce_ptr()->name;
        const int count = staticMetaObject->method( args[2].s_int ).parameterTypes().count() + 1;
        // zval* zmem = ALLOCA_N(zval, count);
        zval** zmem = (zval**) safe_emalloc( sizeof(zval*), count+1, 0);
        for( int i=0;i<count;i++ )
        {
            ALLOC_INIT_ZVAL( zmem[i] );
        }

        // NOTICE is memory allocation safe here?
        InvokeSlot c( o->smoke(), args, o->zval_ptr(), zmem, _id, staticMetaObject, (void**) args[3].s_voidp, metaMethodName );
        c.next();

        efree(zmem);
        return true;

    } else {
        if ( staticMetaObject->indexOfSlot( signature ) != -1 )
        {
            pDebug( PHPQt::Slot ) << " C++ " << signature;
            // return false means this will be done by smoke
            return false;
        } else {
            // TODO error case for undefined methods, see php_qt proxyMethod
            //			const int i = staticMetaObject->indexOfSignal( signature );
            //			const int offset = staticMetaObject->methodOffset(); // The offset is the summary of all methods in the class's superclasses
            pDebug( PHPQt::Signal ) << signature << staticMetaObject->className() << _id << staticMetaObject->methodOffset();

            /* C++ */	//if( _id < offset ) { qWarning() << "got an id smaller than offset"; }

            /**
            * We go through QMetaObject::activate, because it can either be connected to a C++ Slot or a user space Slot
            * cast to a QObject using smoke cast
            * */
            QObject* ptr = (QObject*) o->smoke()->cast( const_cast<void*>( o->ptr() ), o->classId(), cachedQObjectSmokeId );
            void *_b[] = { 0, ((void**) args[3].s_voidp)[1] };
            QMetaObject::activate( ptr, staticMetaObject, 0, _b );
            return true; // success
        }
    } // else method exist
    return false;
}
Пример #6
0
int main(int argc, char *argv[]) {
	int serialFileDesc;

	init(serialFileDesc);

	timeval tv, tvRef;

	unsigned long int prev, curr;

	char buf = 0;
	int a = 0;
	struct pollfd fd;

	fd.fd = serialFileDesc;
	fd.events = POLLIN;
	gettimeofday(&tvRef, NULL);
	prev = tvRef.tv_sec * 1e6 + tvRef.tv_usec;
	//for(int i = 0; i < maxBufferLen; i++) {
	while(1) {
		//pDebug("a=%d\n", a);
		if(1 > (a = poll(&fd, 1, -1))) {
			pDebug("END!! a=%d\n", a);
			return 1;
		}

		if(::read(serialFileDesc, &buf, sizeof(buf)) <= 0) {
			return 1;
		}
		gettimeofday(&tv, NULL);
		curr = tv.tv_sec * 1e6 + tv.tv_usec;
#if 1
		std::cout << std::dec << tv.tv_sec  - tvRef.tv_sec << "." << tv.tv_usec << 
			" ( " << curr - prev << " ): " <<
			std::hex << (short unsigned int)buf << " " << std::endl;
#else
		if((curr - prev) > 100) {
			std::cout << std::endl;
		} else {
			std::cout << " ";
		}
		std::cout << std::hex << (short unsigned)buf << std::flush;

#endif

		prev = curr;
	}
	pDebug("Normal end: a=%d\n", a);

	return 0;
}
Пример #7
0
void DeckHandler::newDeckCard(QString code, int total, bool add)
{
    if(code.isEmpty())  return;

    //Mazo completo
    if(deckCardList[0].total < (uint)total)
    {
        emit pDebug("Deck is full: Not adding: (" + QString::number(total) + ") " +
                    (*cardsJson)[code].value("name").toString(), Warning);
        return;
    }

    //Ya existe en el mazo
    bool found = false;
    for(int i=0; i<deckCardList.length(); i++)
    {
        if(deckCardList[i].getCode() == code)
        {
            if(!add)
            {
                emit pDebug((*cardsJson)[code].value("name").toString() + " already in deck.");
                return;
            }

            found = true;
            deckCardList[i].total+=total;
            deckCardList[i].remaining+=total;
            deckCardList[i].draw(true, this->cardHeight);
            break;
        }
    }

    if(!found)
    {
        DeckCard deckCard(code);
        deckCard.total = total;
        deckCard.remaining = total;
        deckCard.listItem = new QListWidgetItem();
        insertDeckCard(deckCard);
        deckCard.draw(true, this->cardHeight);
        emit checkCardImage(code);
    }

    deckCardList[0].total-=total;
    deckCardList[0].draw(true, this->cardHeight);
    if(deckCardList[0].total == 0)  deckCardList[0].listItem->setHidden(true);

    emit pDebug("Add to deck: (" + QString::number(total) + ")" +
                (*cardsJson)[code].value("name").toString());
}
Пример #8
0
void ArenaHandler::syncArenaCurrent()
{
    int wins = 0;
    int loses = 0;

    if(arenaCurrent != NULL)
    {
        for(int i=0; i<arenaCurrent->childCount(); i++)
        {
            QColor color = getRowColor(arenaCurrent->child(i));
            if(color == GREEN || color == YELLOW)
            {
                arenaCurrentGameList[i].isWinner?wins++:loses++;
            }
            else
            {
                setRowColor(arenaCurrent->child(i), RED);
            }
        }

        arenaCurrent->setText(2, QString::number(wins));
        arenaCurrent->setText(3, QString::number(loses));
        emit pDebug("Recalculate arena win/loses (Web sync).");
    }
}
void FactoryPrivate::phononBackendChanged()
{
    if (m_backendObject) {
        for (int i = 0; i < mediaNodePrivateList.count(); ++i) {
            mediaNodePrivateList.at(i)->deleteBackendObject();
        }
        if (objects.size() > 0) {
            pDebug() << "WARNING: we were asked to change the backend but the application did\n"
                "not free all references to objects created by the factory. Therefore we can not\n"
                "change the backend without crashing. Now we have to wait for a restart to make\n"
                "backendswitching possible.";
            // in case there were objects deleted give 'em a chance to recreate
            // them now
            for (int i = 0; i < mediaNodePrivateList.count(); ++i) {
                mediaNodePrivateList.at(i)->createBackendObject();
            }
            return;
        }
        delete m_backendObject;
        m_backendObject = 0;
    }
    createBackend();
    for (int i = 0; i < mediaNodePrivateList.count(); ++i) {
        mediaNodePrivateList.at(i)->createBackendObject();
    }
    emit backendChanged();
}
Пример #10
0
void LogLoader::readLogConfigPath()
{
    QSettings settings("Arena Tracker", "Arena Tracker");
    logConfig = settings.value("logConfig", "").toString();

    if(logConfig.isEmpty())
    {
        logConfig = createDefaultLogConfig();
        if(logConfig.isEmpty())
        {
            logConfig = QFileDialog::getOpenFileName(0,
                tr("Find Hearthstone config log (log.config)"), QDir::homePath(),
                tr("log.config (log.config)"));
        }
        settings.setValue("logConfig", logConfig);
        if(!logConfig.isEmpty())
        {
            //Remove old log.config
            QFile file(logConfig);
            if(file.exists())   file.remove();

            checkLogConfig();
            QMessageBox::information(0, tr("Restart Hearthstone"), tr("Restart Hearthstone (If running)."));
        }
    }
    else
    {
        checkLogConfig();
    }

    emit pDebug("Path log.config: " + logConfig);
    emit pLog(tr("Settings: Path log.config: ") + logConfig);
    emit logConfigSet();
}
Пример #11
0
void VideoWidget::setFullScreen(bool newFullScreen)
{
    pDebug() << Q_FUNC_INFO << newFullScreen;
    K_D(VideoWidget);
    // TODO: disable screensaver? or should we leave that responsibility to the
    // application?
    Qt::WindowFlags flags = windowFlags();
    if (newFullScreen) {
        if (!isFullScreen()) {
            //we only update that value if it is not already fullscreen
            d->changeFlags = flags & (Qt::Window | Qt::SubWindow);
            flags |= Qt::Window;
            flags ^= Qt::SubWindow;
            setWindowFlags(flags);
#ifdef Q_WS_X11
            // This works around a bug with Compiz
            // as the window must be visible before we can set the state
            show();
            raise();
            setWindowState( windowState() | Qt::WindowFullScreen ); // set
#else
            setWindowState( windowState() | Qt::WindowFullScreen ); // set
            show();
#endif
        }
    } else if (isFullScreen()) {
        flags ^= (Qt::Window | Qt::SubWindow); //clear the flags...
        flags |= d->changeFlags; //then we reset the flags (window and subwindow)
        setWindowFlags(flags);
        setWindowState( windowState()  ^ Qt::WindowFullScreen ); // reset
        show();
    }
}
Пример #12
0
void VolumeSlider::setMutedIcon(const QIcon &icon)
{
    K_D(VolumeSlider);
    pDebug() << Q_FUNC_INFO << icon;
    k_ptr->mutedIcon = icon;
    d->updateIcon();
}
void MediaObject::setCurrentSource(const MediaSource &newSource)
{
    K_D(MediaObject);
    if (!k_ptr->backendObject()) {
        d->mediaSource = newSource;
        return;
    }

    pDebug() << Q_FUNC_INFO << newSource.url();

    stop(); // first call stop as that often is the expected state
            // for setting a new URL

    d->mediaSource = newSource;
#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
    d->kiofallback = 0; // kiofallback auto-deletes
#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM

//X         if (url.scheme() == "http") {
//X             d->kiofallback = Platform::createMediaStream(url, this);
//X             if (d->kiofallback) {
//X                 ...
//X                 return;
//X             }
//X         }

#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
    if (d->mediaSource.type() == MediaSource::Stream) {
        Q_ASSERT(d->mediaSource.stream());
        d->mediaSource.stream()->d_func()->setMediaObjectPrivate(d);
    } 
#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM

    INTERFACE_CALL(setSource(d->mediaSource));
}
Пример #14
0
void LogLoader::readLogPath()
{
    QSettings settings("Arena Tracker", "Arena Tracker");
    logPath = settings.value("logPath", "").toString();

    QString logFileName;
#ifdef Q_OS_MAC
    logFileName = "Player.log";
#else
    logFileName = "output_log.txt";
#endif

    if(logPath.isEmpty() || getLogFileSize()==-1)
    {
        QMessageBox::information(0, tr("Arena Tracker"), tr("The first time you run Arena Tracker you will be asked for:\n"
                                    "1) ") + logFileName + tr(" location (If not default).\n"
                                    "2) log.config location (If not default).\n"
                                    "3) Restart Hearthstone (If running).\n"
                                    "4) Your Arena Mastery user/password.\n\n"
                                    "After your first game:\n"
                                    "5) Your Hearthstone name."));

        QString initPath = "";
        logPath = "";
#ifdef Q_OS_WIN
        initPath = "C:/Program Files (x86)/Hearthstone/Hearthstone_Data/output_log.txt";
#endif
#ifdef Q_OS_MAC
        initPath = QDir::homePath() + "/Library/Logs/Unity/Player.log";
#endif

        if(!initPath.isEmpty())
        {
            QFileInfo logFI(initPath);
            if(logFI.exists())
            {
                logPath = initPath;
            }
        }

        if(logPath.isEmpty())
        {
            logPath = QFileDialog::getOpenFileName(0,
                tr("Find Hearthstone log") + " (" + logFileName + ")", QDir::homePath(),
                "Hearthstone log (" + logFileName + ")");
        }

        settings.setValue("logPath", logPath);
    }

#ifdef QT_DEBUG
//    logPath = QString("/home/triodo/Documentos/test.txt");
#endif


    emit pDebug("Path "+ logFileName + ": " + logPath);
    emit pLog(tr("Settings: Path ") + logFileName + ": " + logPath);

}
Пример #15
0
void ArenaHandler::refresh()
{
    currentArenaToWhite();

    emit pDebug("\nRefresh Button.");
    ui->updateButton->setEnabled(false);
    webUploader->refresh();
}
bool FactoryPrivate::createBackend()
{
    Q_ASSERT(m_backendObject == 0);
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
    PlatformPlugin *f = globalFactory->platformPlugin();
    if (f) {
        m_backendObject = f->createBackend();
    }
#endif //QT_NO_PHONON_PLATFORMPLUGIN
    if (!m_backendObject) {
        ensureLibraryPathSet();

        // could not load a backend through the platform plugin. Falling back to the default
        // (finding the first loadable backend).
        const QLatin1String suffix("/phonon_backend/");
        foreach (QString libPath, QCoreApplication::libraryPaths()) {
            libPath += suffix;
            const QDir dir(libPath);
            if (!dir.exists()) {
                pDebug() << Q_FUNC_INFO << dir.absolutePath() << "does not exist";
                continue;
            }
            foreach (const QString &pluginName, dir.entryList(QDir::Files)) {
                QPluginLoader pluginLoader(libPath + pluginName);
                if (!pluginLoader.load()) {
                    pDebug() << Q_FUNC_INFO << "  load failed:"
                             << pluginLoader.errorString();
                    continue;
                }
                pDebug() << pluginLoader.instance();
                m_backendObject = pluginLoader.instance();
                if (m_backendObject) {
                    break;
                }

                // no backend found, don't leave an unused plugin in memory
                pluginLoader.unload();
            }

            if (m_backendObject) {
                break;
            }
        }
Пример #17
0
void MediaObjectPrivate::_k_currentSourceChanged(const MediaSource &source)
{
    Q_Q(MediaObject);
    pDebug() << Q_FUNC_INFO;

    if (!sourceQueue.isEmpty() && sourceQueue.head() == source)
        sourceQueue.dequeue();

    emit q->currentSourceChanged(source);
}
Пример #18
0
void LogLoader::checkLogConfigOption(QString option, QString &data, QTextStream &stream)
{
    if(!data.contains(option))
    {
        emit pDebug("Setting log.config");
        emit pLog(tr("Log: Setting log.config"));
        stream << endl << option << endl;
        stream << "LogLevel=1" << endl;
        stream << "ConsolePrinting=true" << endl;
    }
}
Пример #19
0
void LogLoader::init(qint64 &logSize)
{
    readSettings();
    logSize = getLogFileSize();

    if(logSize >= 0)
    {
        emit pDebug("Log found.");
        emit pLog(tr("Log: Log found."));

        if(logSize == 0)
        {
            emit pDebug("Log is empty.");
            emit pLog(tr("Log: Log is empty."));
        }

        this->logSize = logSize;
        firstRun = true;
        updateTime = 1000;

        logWorker = new LogWorker(this, logPath);
        connect(logWorker, SIGNAL(newLogLineRead(QString, qint64)),
                this, SLOT(emitNewLogLineRead(QString, qint64)));
        connect(logWorker, SIGNAL(seekChanged(qint64)),
                this, SLOT(updateSeek(qint64)));
        connect(logWorker, SIGNAL(pLog(QString)),
                this, SIGNAL(pLog(QString)));
        connect(logWorker, SIGNAL(pDebug(QString,DebugLevel,QString)),
                this, SIGNAL(pDebug(QString,DebugLevel,QString)));

        QTimer::singleShot(1000, this, SLOT(sendLogWorker())); //Retraso para dejar que la aplicacion se pinte.
    }
    else
    {
        QSettings settings("Arena Tracker", "Arena Tracker");
        settings.setValue("logPath", "");
        emit pDebug("Log not found.");
        emit pLog(tr("Log: Log not found. Restart Arena Tracker and set the path again."));
        QMessageBox::information((QMainWindow*)this->parent(), tr("Log not found"), tr("Log not found. Restart Arena Tracker and set the path again."));
    }
}
Пример #20
0
void LogLoader::init(qint64 &logSize)
{
    readSettings();
    logSize = getLogFileSize();

    if(logSize >= 0)
    {
        emit pDebug("Log found.");
        emit pLog(tr("Log: Log found."));

        if(logSize == 0)
        {
            emit pDebug("Log is empty.");
            emit pLog(tr("Log: Log is empty."));
        }

        this->logSize = logSize;
        firstRun = true;
        updateTime = 1000;

        logWorker = new LogWorker(this, logPath);
        connect(logWorker, SIGNAL(newLogLineRead(QString, qint64)),
                this, SLOT(emitNewLogLineRead(QString, qint64)));
        connect(logWorker, SIGNAL(seekChanged(qint64)),
                this, SLOT(updateSeek(qint64)));
        connect(logWorker, SIGNAL(pLog(QString)),
                this, SIGNAL(pLog(QString)));
        connect(logWorker, SIGNAL(pDebug(QString,DebugLevel,QString)),
                this, SIGNAL(pDebug(QString,DebugLevel,QString)));

        QTimer::singleShot(updateTime, this, SLOT(sendLogWorker()));
    }
    else
    {
        QSettings settings("Arena Tracker", "Arena Tracker");
        settings.setValue("logPath", "");
        emit pDebug("Log not found.");
        emit pLog(tr("Log: Log not found. Restart Arena Tracker and set the path again."));
    }
}
Пример #21
0
void SecretsHandler::discardSecretOptionDelay()
{
    if(secretTests.isEmpty())   return;

    SecretTest secretTest = secretTests.dequeue();
    if(secretTest.secretRevealedLastSecond)
    {
        emit pDebug("Option not discarded: " + secretTest.code + " (A secret revealed)");
        return;
    }

    discardSecretOptionNow(secretTest.code);
}
Пример #22
0
void ArenaHandler::showNoArena()
{
    if(noArena) return;

    QTreeWidgetItem *item = new QTreeWidgetItem(ui->arenaTreeWidget);
    item->setText(0, "None");
    setRowColor(item, GREEN);
    arenaCurrent = NULL;
    arenaCurrentHero = "";
    arenaCurrentGameList.clear();
    noArena = true;

    emit pDebug("Show no arena.");
}
Пример #23
0
void DeckHandler::reset()
{
    ui->deckListWidget->clear();
    deckCardList.clear();
    clearDrawList(true);

    DeckCard deckCard("");
    deckCard.total = 30;
    deckCard.listItem = new QListWidgetItem();
    deckCard.draw(true, this->cardHeight);
    insertDeckCard(deckCard);

    enableDeckButtons();

    emit pDebug("Deck list cleared.");
}
Пример #24
0
void VideoWidgetPrivate::setupBackendObject()
{
    Q_Q(VideoWidget);
    Q_ASSERT(m_backendObject);
    //AbstractVideoOutputPrivate::setupBackendObject();
    pDebug() << "calling setAspectRatio on the backend " << aspectRatio;
    pINTERFACE_CALL(setAspectRatio(aspectRatio));
    pINTERFACE_CALL(setScaleMode(scaleMode));

    QWidget *w = pINTERFACE_CALL(widget());
    if (w) {
        layout.addWidget(w);
        q->setSizePolicy(w->sizePolicy());
        w->setMouseTracking(true);
    }
}
Пример #25
0
void MediaObjectPrivate::_k_aboutToFinish()
{
    Q_Q(MediaObject);
    pDebug() << Q_FUNC_INFO;

#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
    kiofallback = 0; // kiofallback auto-deletes
#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM

    if (sourceQueue.isEmpty()) {
        emit q->aboutToFinish();
        if (sourceQueue.isEmpty()) {
            return;
        }
    }

    mediaSource = sourceQueue.head();
    pINTERFACE_CALL(setNextSource(mediaSource));
}
void FactoryPrivate::objectDescriptionChanged(ObjectDescriptionType type)
{
#ifdef PHONON_METHODTEST
    Q_UNUSED(type);
#else
    pDebug() << Q_FUNC_INFO << type;
    switch (type) {
    case AudioOutputDeviceType:
        emit availableAudioOutputDevicesChanged();
        break;
    case AudioCaptureDeviceType:
        emit availableAudioCaptureDevicesChanged();
        break;
    default:
        break;
    }
    //emit capabilitiesChanged();
#endif // PHONON_METHODTEST
}
Пример #27
0
QTreeWidgetItem *ArenaHandler::showGameResult(GameResult gameResult, bool arenaMatch)
{
    QTreeWidgetItem *item;

    if(!arenaMatch || arenaCurrent == NULL || arenaCurrentHero.compare(gameResult.playerHero)!=0)
    {
        item = new QTreeWidgetItem(arenaHomeless);
    }
    else
    {
        item = new QTreeWidgetItem(arenaCurrent);
        arenaCurrentGameList.append(gameResult);

        //Add game to score
        if(gameResult.isWinner)
        {
            int wins = arenaCurrent->text(2).toInt() + 1;
            arenaCurrent->setText(2, QString::number(wins));
        }
        else
        {
            int loses = arenaCurrent->text(3).toInt() + 1;
            arenaCurrent->setText(3, QString::number(loses));
        }
        emit pDebug("Recalculate arena win/loses (1 game).");
    }

    item->setIcon(0, QIcon(":Images/" +
                           (gameResult.playerHero==""?("secretHunter"):("hero"+gameResult.playerHero))
                           + ".png"));
    item->setText(0, "vs");
    item->setTextAlignment(0, Qt::AlignHCenter|Qt::AlignVCenter);
    item->setIcon(1, QIcon(":Images/" +
                           (gameResult.enemyHero==""?("secretHunter"):("hero"+gameResult.enemyHero))
                           + ".png"));
    item->setToolTip(1, "<span style=\"color:green;\">" + gameResult.enemyName + "</span>");
    item->setIcon(2, QIcon(gameResult.isFirst?":Images/first.png":":Images/coin.png"));
    item->setIcon(3, QIcon(gameResult.isWinner?":Images/win.png":":Images/lose.png"));

    setRowColor(item, WHITE);

    return item;
}
Пример #28
0
QString LogLoader::createDefaultLogConfig()
{
    QString initPath = "";
#ifdef Q_OS_WIN
    initPath = QDir::homePath() + "/AppData/Local/Blizzard/Hearthstone/log.config";
#endif

#ifdef Q_OS_MAC
    initPath = QDir::homePath() + "/Library/Preferences/Blizzard/Hearthstone/log.config";
#endif

#ifdef Q_OS_LINUX
#endif

    if(initPath.isEmpty()) return "";

    QFileInfo logConfigFI(initPath);
    if(logConfigFI.exists())
    {
        return initPath;
    }
    else
    {
        QString hsDir = logConfigFI.absolutePath();
        logConfigFI = QFileInfo(hsDir);
        if(logConfigFI.exists() && logConfigFI.isDir())
        {
            //Creamos log.config
            QFile logConfigFile(initPath);
            if(!logConfigFile.open(QIODevice::WriteOnly | QIODevice::Text))
            {
                emit pDebug("Cannot create default log.config", Error);
                emit pLog(tr("Log: ERROR: Cannot create default log.config"));
                return "";
            }
            logConfigFile.close();
            return initPath;
        }
    }

    return "";
}
Пример #29
0
void SecretsHandler::discardSecretOptionNow(QString code)
{
    for(QList<ActiveSecret>::iterator it = activeSecretList.begin(); it != activeSecretList.end(); it++)
    {
        for(int i=0; i<it->children.count(); i++)
        {
            if(it->children[i].code == code)
            {
                emit pDebug("Option discarded: " + code);
                it->root.treeItem->removeChild(it->children[i].treeItem);
                it->children.removeAt(i);
                QTimer::singleShot(10, this, SLOT(adjustSize()));

                //Comprobar unica posibilidad
                checkLastSecretOption(*it);
                break;
            }
        }
    }
}
Пример #30
0
void MediaObject::setCurrentSource(const MediaSource &newSource)
{
    K_D(MediaObject);
    if (!k_ptr->backendObject()) {
        d->mediaSource = newSource;
        return;
    }

    pDebug() << Q_FUNC_INFO << newSource.url();

    stop(); // first call stop as that often is the expected state
            // for setting a new URL

    MediaSource::Type oldSourceType = d->mediaSource.type();
    d->mediaSource = newSource;
    d->kiofallback = 0; // kiofallback auto-deletes

//X         if (url.scheme() == "http") {
//X             d->kiofallback = Platform::createMediaStream(url, this);
//X             if (d->kiofallback) {
//X                 ...
//X                 return;
//X             }
//X         }

    if (d->mediaSource.type() == MediaSource::Stream) {
        Q_ASSERT(d->mediaSource.stream());
        d->mediaSource.stream()->d_func()->setMediaObjectPrivate(d);
    } else if (d->mediaSource.type() == MediaSource::Invalid) {
        pWarning() << "requested invalid MediaSource for the current source of MediaObject";
        return;
    }
    if (d->mediaSource.type() == MediaSource::Url && oldSourceType != MediaSource::Url) {
        disconnect(d->m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SIGNAL(stateChanged(Phonon::State, Phonon::State)));
        connect(d->m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(_k_stateChanged(Phonon::State, Phonon::State)));
    } else if (d->mediaSource.type() != MediaSource::Url && oldSourceType == MediaSource::Url) {
        disconnect(d->m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(_k_stateChanged(Phonon::State, Phonon::State)));
        connect(d->m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SIGNAL(stateChanged(Phonon::State, Phonon::State)));
    }
    INTERFACE_CALL(setSource(d->mediaSource));
}