void run()
                {
                    Array<int> randomValues;
                    int lastRandomValue = 0;

                    for (int i=1; i<=400; i++)
                    {
                        if ((Desktop::getMousePosition().x * Desktop::getMousePosition().y) != lastRandomValue)
                        {
                            randomValues.add (Desktop::getMousePosition().x * Desktop::getMousePosition().y);
                        }

                        lastRandomValue = Desktop::getMousePosition().x * Desktop::getMousePosition().y;

                        setStatusMessage ("Random seed (move the mouse around to generate more): "+ STR(randomValues.size()));
                        sleep (20);

                        setProgress ((i / (double) 400));
                        if (threadShouldExit())
                            return;
                    }

                    setProgress (-1);
                    setStatusMessage ("Generating 512 bit RSA key pair, this might take a moment");
                    sleep (5);
                    RSAKey::createKeyPair (publicKey, privateKey, 512, randomValues.getRawDataPointer(), randomValues.size());
                }
void StatusRootAction::changeStatus( const Kopete::Status::Status* status )
{
	Kopete::StatusMessage statusMessage;
	statusMessage.setTitle( status->title() );
	statusMessage.setMessage( status->message() );

	if ( d->account )
	{	// Set status for this account only
		if ( d->filter == UseCategory )
		{
			if ( status->category() != 0x00 )
			{
				OnlineStatusManager *osm = OnlineStatusManager::self();
				Kopete::OnlineStatus oStatus = osm->onlineStatus( d->account->protocol(), status->category() );
				d->account->setOnlineStatus( oStatus, statusMessage, Kopete::Account::KeepSpecialFlags );
			}
			else
			{
				setStatusMessage( statusMessage );
			}
		}
		else
		{
			d->account->setOnlineStatus( d->onlineStatus, statusMessage, Kopete::Account::KeepSpecialFlags );
		}
	}
	else
	{	// Set global status
		if ( status->category() != 0x00 )
			emit changeStatus( status->category(), statusMessage );
		else
			setStatusMessage( statusMessage );
	}
}
Ejemplo n.º 3
0
    void run() override
    {
        setProgress (-1.0); // setting a value beyond the range 0 -> 1 will show a spinning bar..
        setStatusMessage ("Preparing to do some stuff...");
        wait (2000);

        const int thingsToDo = 10;

        for (int i = 0; i < thingsToDo; ++i)
        {
            // must check this as often as possible, because this is
            // how we know if the user's pressed 'cancel'
            if (threadShouldExit())
                return;

            // this will update the progress bar on the dialog box
            setProgress (i / (double) thingsToDo);

            setStatusMessage (String (thingsToDo - i) + " things left to do...");

            wait (500);
        }

        setProgress (-1.0); // setting a value beyond the range 0 -> 1 will show a spinning bar..
        setStatusMessage ("Finishing off the last few bits and pieces!");
        wait (2000);
    }
Ejemplo n.º 4
0
    Result download (MemoryBlock& dest)
    {
        setStatusMessage ("Downloading...");

        int statusCode = 302;
        const int maxRedirects = 5;

        // we need to do the redirecting manually due to inconsistencies on the way headers are handled on redirects
        ScopedPointer<InputStream> in;

        for (int redirect = 0; redirect < maxRedirects; ++redirect)
        {
            StringPairArray responseHeaders;

            in = url.createInputStream (false, nullptr, nullptr, headers, 10000, &responseHeaders, &statusCode, 0);
            if (in == nullptr || statusCode != 302)
                break;

            String redirectPath = responseHeaders ["Location"];
            if (redirectPath.isEmpty())
                break;

            url = LatestVersionChecker::getLatestVersionURL (headers, redirectPath);
        }

        if (in != nullptr && statusCode == 200)
        {
            int64 total = 0;
            MemoryOutputStream mo (dest, true);

            for (;;)
            {
                if (threadShouldExit())
                    return Result::fail ("cancel");

                int64 written = mo.writeFromInputStream (*in, 8192);

                if (written == 0)
                    break;

                total += written;

                setStatusMessage (String (TRANS ("Downloading...  (123)"))
                                  .replace ("123", File::descriptionOfSizeInBytes (total)));
            }

            return Result::ok();
        }

        return Result::fail ("Failed to download from: " + url.toString (false));
    }
Ejemplo n.º 5
0
void WindowsManager::setActiveWindowByIndex(int index)
{
	if (!m_isRestored || index >= m_mainWindow->getTabBar()->count())
	{
		return;
	}

	if (index != m_mainWindow->getTabBar()->currentIndex())
	{
		m_mainWindow->getTabBar()->setCurrentIndex(index);

		return;
	}

	Window *window = m_mainWindow->getWorkspace()->getActiveWindow();

	if (window)
	{
		disconnect(window, SIGNAL(statusMessageChanged(QString)), this, SLOT(setStatusMessage(QString)));
		disconnect(window, SIGNAL(zoomChanged(int)), this, SIGNAL(zoomChanged(int)));
		disconnect(window, SIGNAL(canZoomChanged(bool)), this, SIGNAL(canZoomChanged(bool)));
	}

	setStatusMessage(QString());

	window = getWindowByIndex(index);

	m_mainWindow->setCurrentWindow(window);

	if (window)
	{
		m_mainWindow->getWorkspace()->setActiveWindow(window);

		window->setFocus();
		window->markActive();

		setStatusMessage(window->getContentsWidget()->getStatusMessage());

		emit windowTitleChanged(window->getContentsWidget()->getTitle());
		emit zoomChanged(window->getContentsWidget()->getZoom());
		emit canZoomChanged(window->getContentsWidget()->canZoom());

		connect(window, SIGNAL(statusMessageChanged(QString)), this, SLOT(setStatusMessage(QString)));
		connect(window, SIGNAL(zoomChanged(int)), this, SIGNAL(zoomChanged(int)));
		connect(window, SIGNAL(canZoomChanged(bool)), this, SIGNAL(canZoomChanged(bool)));
	}

	m_mainWindow->getAction(ActionsManager::CloneTabAction)->setEnabled(window && window->canClone());

	emit currentWindowChanged(window ? window->getIdentifier() : -1);
}
Ejemplo n.º 6
0
void BoardSetupDialog::setBoard(const Board& b)
{
    ui.boardView->setBoard(b);
    ui.moveSpin->setValue(b.moveNumber());
    ui.halfmoveSpin->setValue(b.halfMoveClock());
    if(b.enPassantSquare() == NoEPSquare)
    {
        ui.epCombo->setCurrentIndex(0);
    }
    else if(b.toMove() == White && b.pieceAt(b.enPassantSquare() - 8) == BlackPawn &&
            b.pieceAt(b.enPassantSquare()) == Empty && b.pieceAt(b.enPassantSquare() + 8) == Empty)
    {
        ui.epCombo->setCurrentIndex(b.enPassantSquare() % 8 + 1);
    }
    else if(b.toMove() == Black && b.pieceAt(b.enPassantSquare() + 8) == WhitePawn &&
            b.pieceAt(b.enPassantSquare()) == Empty && b.pieceAt(b.enPassantSquare() - 8) == Empty)
    {
        ui.epCombo->setCurrentIndex(b.enPassantSquare() % 8 + 1);
    }
    else
    {
        ui.epCombo->setCurrentIndex(0);
    }
    ui.wkCastleCheck->setChecked(b.castlingRights() & WhiteKingside);
    ui.wqCastleCheck->setChecked(b.castlingRights() & WhiteQueenside);
    ui.bkCastleCheck->setChecked(b.castlingRights() & BlackKingside);
    ui.bqCastleCheck->setChecked(b.castlingRights() & BlackQueenside);
    m_toMove = b.toMove();
    showSideToMove();
    setStatusMessage();
}
Ejemplo n.º 7
0
Result DummyTask::run ()
{
	if (duration.inSeconds() < 0.0)
		return Result::ok ();

	Time startTime = Time::getCurrentTime();
    
    setStatusMessage(getName());

	while (elapsed < duration)
	{
		elapsed = Time::getCurrentTime () - startTime;

		if (shouldAbort())
			return Result::ok();

		double progress = 1.0;
		if (duration.inSeconds() > 0)
			progress = elapsed.inSeconds() / duration.inSeconds();
		setProgress(progress);

		Thread::sleep (50);
	}

	return Result::ok ();
}
Ejemplo n.º 8
0
YoursPlugin::YoursPlugin( QObject *parent ) :
    RoutingRunnerPlugin( parent )
{
    setSupportedCelestialBodies( QStringList() << "earth" );
    setCanWorkOffline( false );
    setStatusMessage( tr ( "This service requires an Internet connection." ) );
}
Ejemplo n.º 9
0
FWProgressBackgroundThread::FWProgressBackgroundThread(tcat::dice::FL_OP_ENUM operation_, String file_, String sector_, tcat::uint32 size_, event_device_ref device_, bool requires_entry_point_)
    : ThreadWithProgressWindow ("Firmware progress...",
                                true,
                                false),
	m_operation(operation_),
	m_file(file_),
	m_sector(sector_),
	m_size(size_),
	m_device_ref(device_),
	m_requires_entrypoint (requires_entry_point_)
{
	String msg = String::empty;
	switch (m_operation)
	{
		case tcat::dice::FL_OP_DELETE_IMAGE:
			msg.append("Deleting sector " + m_sector + " ...", 40);
			break;
		case tcat::dice::FL_OP_CREATE_IMAGE:
			msg.append("Creating sector " + m_sector + " ...", 40);
			break;
		case tcat::dice::FL_OP_UPLOAD:
			msg.append("Uploading file " + m_file + " ...", 300);
			break;
		case tcat::dice::FL_OP_READ_MEMORY:
			msg.append("Downloading entire flash to file " + m_file + " ...", 300);
			break;
		
		default:
			msg.append("...", 4);
			break;
	}
	setStatusMessage (msg);
}
Ejemplo n.º 10
0
void RKCaughtX11Window::gotoPlot (int index) {
	RK_TRACE (MISC);

	RCommand* c = new RCommand ("rk.goto.plot (" + QString::number (device_number) + ", " + QString::number (index+1) + ')', RCommand::App, i18n ("Load plot %1 in device number %2", index, device_number), error_dialog);
	setStatusMessage (i18n ("Loading plot from history"), c);
	RKGlobals::rInterface ()->issueCommand (c);
}
Ejemplo n.º 11
0
void CtrlrFileDownloader::run()
{
	ScopedPointer <InputStream> is (fileToDownload.createInputStream (false));
	const int totalLength = is->getTotalLength();
	int bytesSoFar = 0;
	const String packageFile = CtrlrUpdateManager::getMyPackage();

	if (outputFile.exists())
	{
		outputFile.deleteFile();
		outputFile.create();
	}

	while (! (is->isExhausted()))
	{
		if (threadShouldExit())
		{
			return;
		}

		MemoryBlock buffer(8192);
		const int num = is->read (buffer.getData(), 8192);

		if (num == 0)
			break;

		bytesSoFar += num;
		outputFile.appendData(buffer.getData(), buffer.getSize());

		setStatusMessage ("File: " + packageFile + "\nTotal size: " + File::descriptionOfSizeInBytes (totalLength) + " Got size: " + File::descriptionOfSizeInBytes (bytesSoFar));
		setProgress (bytesSoFar / (double)totalLength);
	}
}
void StatusRootAction::editStatusDialogFinished(int code)
{
	if (code == QDialog::Accepted ) {
		setStatusMessage( d->statusDialog->statusMessage() );
	}
	d->statusDialog->deleteLater();
}
Ejemplo n.º 13
0
bool RKCaughtX11Window::close (bool also_delete) {
	RK_TRACE (MISC);

	if (killed_in_r || RKGlobals::rInterface ()->backendIsDead ()) {
		return RKMDIWindow::close (also_delete);
	}

	if (rk_native_device) rk_native_device->stopInteraction ();

	QString status = i18n ("Closing device (saving history)");
	if (!close_attempted) {
		RCommand* c = new RCommand ("dev.off (" + QString::number (device_number) + ')', RCommand::App, i18n ("Shutting down device number %1", device_number));
		setStatusMessage (status, c);
		RKGlobals::rInterface ()->issueCommand (c);
		close_attempted = true;
	} else {
		if (KMessageBox::questionYesNo (this, i18n ("<p>The graphics device is being closed, saving the last plot to the plot history. This may take a while, if the R backend is still busy. You can close the graphics device immediately, in case it is stuck. However, the last plot may be missing from the plot history, if you do this.</p>")
#ifdef Q_WS_X11
		+ i18n ("<p>Note: On X11, the embedded window may be expurged, and you will have to close it manually in this case.</p>")
#endif
		, status, KGuiItem (i18n ("Close immediately")), KGuiItem (i18n ("Keep waiting"))) == KMessageBox::Yes) forceClose ();
	}

	return false;
}
Ejemplo n.º 14
0
void RKCaughtX11Window::lastPlot () {
	RK_TRACE (MISC);

	RCommand* c = new RCommand ("rk.last.plot (" + QString::number (device_number) + ')', RCommand::App, i18n ("Load last plot in device number %1", device_number), error_dialog);
	setStatusMessage (i18n ("Loading plot from history"), c);
	RKGlobals::rInterface ()->issueCommand (c);
}
Ejemplo n.º 15
0
/**
 * @details Constructs a CommandsItem object.
 */
CommandsItem::CommandsItem(const Platform& platform)
    : ProcedureItem(platform)
{
    _impl.reset( new CommandsItemImpl( platform ) );
    setStatusMessage( QString("executing commands on platform %1")
                            .arg(platform.name()) ); // default status message
}
Ejemplo n.º 16
0
    Result download (const ModuleList::Module& m, MemoryBlock& dest)
    {
        setStatusMessage ("Downloading " + m.uid + "...");

        if (m.url.readEntireBinaryStream (dest, false))
            return Result::ok();

        return Result::fail ("Failed to download from: " + m.url.toString (false));
    }
Ejemplo n.º 17
0
    Result unzip (const MemoryBlock& data)
    {
        setStatusMessage ("Installing...");

        File unzipTarget;
        bool isUsingTempFolder = false;

        {
            MemoryInputStream input (data, false);
            ZipFile zip (input);

            if (zip.getNumEntries() == 0)
                return Result::fail ("The downloaded file wasn't a valid JUCE file!");

            unzipTarget = targetFolder;

            if (unzipTarget.exists())
            {
                isUsingTempFolder = true;
                unzipTarget = targetFolder.getNonexistentSibling();

                if (! unzipTarget.createDirectory())
                    return Result::fail ("Couldn't create a folder to unzip the new version!");
            }

            Result r (zip.uncompressTo (unzipTarget));

            if (r.failed())
            {
                if (isUsingTempFolder)
                    unzipTarget.deleteRecursively();

                return r;
            }
        }

        if (isUsingTempFolder)
        {
            File oldFolder (targetFolder.getSiblingFile (targetFolder.getFileNameWithoutExtension() + "_old")
                                        .getNonexistentSibling());

            if (! targetFolder.moveFileTo (oldFolder))
            {
                unzipTarget.deleteRecursively();
                return Result::fail ("Could not remove the existing folder!");
            }

            if (! unzipTarget.moveFileTo (targetFolder))
            {
                unzipTarget.deleteRecursively();
                return Result::fail ("Could not overwrite the existing folder!");
            }
        }

        return Result::ok();
    }
Ejemplo n.º 18
0
    Result unzip (const ModuleList::Module& m, const MemoryBlock& data)
    {
        setStatusMessage ("Installing " + m.uid + "...");

        MemoryInputStream input (data, false);
        ZipFile zip (input);

        if (zip.getNumEntries() == 0)
            return Result::fail ("The downloaded file wasn't a valid module file!");

        return zip.uncompressTo (targetList.getModulesFolder(), true);
    }
Ejemplo n.º 19
0
/*!
  Slot activated when GDBProcessFinished signal of GDBAdapter is raised.
  Disables the program manipulation buttons.
  */
void StackFramesWidget::handleGDBProcessFinished()
{
  mpResumeToolButton->setEnabled(false);
  mpInterruptToolButton->setEnabled(false);
  mpExitToolButton->setEnabled(false);
  mpStepOverToolButton->setEnabled(false);
  mpStepIntoToolButton->setEnabled(false);
  mpStepReturnToolButton->setEnabled(false);
  mpStackFramesTreeWidget->clearStackFrames();
  mpThreadsComboBox->clear();
  setStatusMessage("Debugging finished");
}
Ejemplo n.º 20
0
    void flashTestRepeatedByte(uint8 byte)
    {
		uint8 saveBuffer[ACOUSTICIO_FLASH_BLOCK_BYTES]; 
		uint8 writeBuffer[ACOUSTICIO_FLASH_BLOCK_BYTES];
        uint8 readBuffer[ACOUSTICIO_FLASH_BLOCK_BYTES];
        
		result = dev->readFlashBlock(0, saveBuffer, sizeof(saveBuffer));
		if (result.failed())
			return;

		memset(writeBuffer, byte, sizeof(writeBuffer));
        
        setStatusMessage("Writing repeated " + String::toHexString(byte));
        
        result = dev->writeFlashBlock(0, writeBuffer, sizeof(writeBuffer));
        if (result.failed())
            return;
            
        zerostruct(readBuffer);
        
        setStatusMessage("Verifying repeated " + String::toHexString(byte));
        
        result = dev->readFlashBlock(0, readBuffer, sizeof(readBuffer));
        if (result.failed())
            return;
            
       for (size_t index = 0; index < sizeof(readBuffer); ++index)
       {
           if (readBuffer[index] != byte)
           {
               result = Result::fail("Error verifying flash block");
               return;
           }
       }

	   result = dev->writeFlashBlock(0, saveBuffer, sizeof(saveBuffer));
	   if (result.failed())
		   return;
    }
Ejemplo n.º 21
0
void MLPluginController::ConvertProgressDisplayThread::run()
{
	std::string rootStr("Converting .aupreset and .mlpreset files from /Library and ~/Library...");
	setProgress(-1.0);
	setStatusMessage (rootStr);
	
	while((myProgress < 1.0) && !threadShouldExit())
	{
		wait(50);
		myProgress = pController->getConvertProgress();
		setProgress(myProgress);
		mFilesConverted = pController->getFilesConverted();
	}
}
Ejemplo n.º 22
0
AudioCdDevice::AudioCdDevice(MusicModel *m, Solid::Device &dev)
    : Device(m, dev, false, true)
    #ifdef CDDB_FOUND
    , cddb(0)
    #endif
    #ifdef MUSICBRAINZ5_FOUND
    , mb(0)
    #endif
    , year(0)
    , disc(0)
    , time(0xFFFFFFFF)
    , lookupInProcess(false)
    , autoPlay(false)
{
    icn=Icon("media-optical");
    drive=dev.parent().as<Solid::OpticalDrive>();
    Solid::Block *block=dev.as<Solid::Block>();
    if (block) {
        device=block->device();
    } else { // With UDisks2 we cannot get block from device :-(
        QStringList parts=dev.udi().split("/", QString::SkipEmptyParts);
        if (!parts.isEmpty()) {
            parts=parts.last().split(":");
            if (!parts.isEmpty()) {
                device="/dev/"+parts.first();
            }
        }
    }
    if (!device.isEmpty()) {
        static bool registeredTypes=false;
        if (!registeredTypes) {
            qRegisterMetaType<CdAlbum >("CdAlbum");
            qRegisterMetaType<QList<CdAlbum> >("QList<CdAlbum>");
            registeredTypes=true;
        }
        devPath=Song::constCddaProtocol+device+QChar('/');
        #if defined CDDB_FOUND && defined MUSICBRAINZ5_FOUND
        connectService(Settings::self()->useCddb());
        #else
        connectService(true);
        #endif
        detailsString=i18n("Reading disc");
        setStatusMessage(detailsString);
        lookupInProcess=true;
        connect(Covers::self(), SIGNAL(cover(const Song &, const QImage &, const QString &)),
                this, SLOT(setCover(const Song &, const QImage &, const QString &)));
        emit lookup(Settings::self()->cdAuto());
    }
}
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {

    /* register several types in order to use it for qt signals/slots */
    qRegisterMetaType<cv::Mat>("cv::Mat");
    qRegisterMetaType< std::vector<cv::Mat> >("std::vector<cv::Mat>");

    /* setup camera */
    camera = new Camera();
    bool camFound = camera->open(0);
    if (!camFound) {
        /* no camera, forcing test mode */
        camera->setTestMode(true);
    } else {
        /* reset camera registers and start led ringlight */
        camera->reset();
        camera->printStatus();
    }
    
    camThread = new QThread;
    camera->moveToThread(camThread);
        
    /* creating photometric stereo process */
    ps = new PhotometricStereo(camera->width, camera->height, camera->avgImageIntensity());

    /* setup ui */
    setWindowTitle("Realtime Photometric-Stereo");
    createInterface();
    statusBar()->setStyleSheet("font-size:12px;font-weight:bold;");

    /* connecting camera with attached thread */
    connect(camThread, SIGNAL(started()), camera, SLOT(start()));
    connect(camera, SIGNAL(stopped()), camThread, SLOT(quit()));
    connect(camera, SIGNAL(stopped()), camera, SLOT(deleteLater()));
    connect(camThread, SIGNAL(finished()), camThread, SLOT(deleteLater()));
    
    /* connecting camera with camerawidget and ps process */
    connect(camera, SIGNAL(newCamFrame(cv::Mat)), camWidget, SLOT(setImage(cv::Mat)), Qt::AutoConnection);
    /* invoking ps setImage slot immediately, when the signal is emitted to ensure image order */
    connect(camera, SIGNAL(newCroppedFrame(cv::Mat)), ps, SLOT(setImage(cv::Mat)), Qt::DirectConnection);
    
    /* connecting ps process with mainwindow and modelwidget */
    connect(ps, SIGNAL(executionTime(QString)), this, SLOT(setStatusMessage(QString)), Qt::AutoConnection);
    connect(ps, SIGNAL(modelFinished(std::vector<cv::Mat>)), this, SLOT(onModelFinished(std::vector<cv::Mat>)), Qt::AutoConnection);
    
    /* start camera in separate thread with high priority */
    camThread->start();
    camThread->setPriority(QThread::TimeCriticalPriority);
}
Ejemplo n.º 24
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
  activeDocument_ = 0L;
  newcnt_ = 1;
  
  // set up the main window
  init();
  initGui();
  initActions();
  initMenus();
  initToolBars();
  initConnections();

  Config *cfg = Application::self()->config();
  QByteArray state = cfg->state();
  QByteArray geometry = cfg->geometry();
  if (!state.isEmpty())
    restoreState(state);
  if (!geometry.isEmpty())
    restoreGeometry(geometry);
  
  // to make sure that there is no open models.
  activeDocumentChanged(-1);
  
  emit actionEnabled(false);

  // parse cmd line args
  QStringList args = qApp->arguments();
  for (int i = 1; i < args.size(); ++i) {
    const QString &arg = args[i];
    if (!arg.startsWith("-"))
      openFile(arg);
  }
  
  setStatusMessage(tr("Ready..."));
}
Ejemplo n.º 25
0
void WebWidget::handleToolTipEvent(QHelpEvent *event, QWidget *widget)
{
	const HitTestResult hitResult = getHitTestResult(event->pos());
	const QString toolTipsMode = SettingsManager::getValue(QLatin1String("Browser/ToolTipsMode")).toString();
	const QString link = (hitResult.linkUrl.isValid() ? hitResult.linkUrl : hitResult.formUrl).toString();
	QString text;

	if (toolTipsMode != QLatin1String("disabled"))
	{
		const QString title = QString(hitResult.title).replace(QLatin1Char('&'), QLatin1String("&amp;")).replace(QLatin1Char('<'), QLatin1String("&lt;")).replace(QLatin1Char('>'), QLatin1String("&gt;"));

		if (toolTipsMode == QLatin1String("extended"))
		{
			if (!link.isEmpty())
			{
				text = (title.isEmpty() ? QString() : tr("Title: %1").arg(title) + QLatin1String("<br>")) + tr("Address: %1").arg(link);
			}
			else if (!title.isEmpty())
			{
				text = title;
			}
		}
		else
		{
			text = title;
		}
	}

	setStatusMessage((link.isEmpty() ? hitResult.title : link), true);

	if (!text.isEmpty())
	{
		QToolTip::showText(event->globalPos(), QStringLiteral("<div style=\"white-space:pre-line;\">%1</div>").arg(text), widget);
	}

	event->accept();
}
Ejemplo n.º 26
0
void updateCheatStatus(bool status)
{
    std::wstring msg;

    if (g_wotcheater.queryCheatStatus())
    {
        msg = L"World Of Tanks обнаружен. ";
    }
    else
    {
        msg = L"World Of Tanks не обнаружен. ";
    }

    if (g_wotcheater.getState())
    {
        msg += L"[Тундра включена!]";
    }
    else
    {
        msg += L"[Тундра не включена!]";
    }

    setStatusMessage(msg.c_str());
}
Ejemplo n.º 27
0
  void run() {
    setProgress(0.0);
    setStatusMessage("Connecting to device");

    if(threadShouldExit())
      return;

    if(!loader.init(file, options))
      return error(loader.getMessage());

    setProgress(0.02);
    setStatusMessage("Probing for DFU device");

    bool detected = loader.probeDevices();
    for(int i=0; i<40 && ! detected; ++i){
      Thread::sleep(100);
      setProgress(0.02+i*0.14/40);
      detected = loader.probeDevices();
      if(threadShouldExit())
	return error("Cancelled!");
    }

    if(!detected)
      return error("Could not find a connected DFU device");

    setProgress(0.16);
    setStatusMessage("Opening device");
    if(!loader.openDevice())
      return error(loader.getMessage());
    setProgress(0.18);
    setStatusMessage("Connecting to device");
    if(!loader.connectToDevice())
      return error(loader.getMessage());
    setProgress(0.2);

    if(threadShouldExit())
      return error("Cancelled!");

    setStatusMessage("Downloading binary image to device");
    if(!loader.loadToDevice(*this))
      return error(loader.getMessage());
    setProgress(0.85);

    setStatusMessage("Detaching device");
    if(!loader.detachDevice())
      setStatusMessage(loader.getMessage()); // continue
    setProgress(0.90);

    // setStatusMessage("Resetting device");
    // if(!loader.resetDevice())
    //   setStatusMessage(loader.getMessage()); // continue
    // //   return error(loader.getMessage());
    // setProgress(0.95);

    setStatusMessage("Closing device");
    if(!loader.closeDevice())
      return error(loader.getMessage());
    setProgress(1.0);

    setStatusMessage("Update complete");
  }
Ejemplo n.º 28
0
 void error(const String& msg){
   setStatusMessage(msg);
   loader.closeDevice();
   while(!threadShouldExit())
     Thread::sleep(100);
 }
Ejemplo n.º 29
0
Archivo: core.cpp Proyecto: Pik-9/qTox
/**
 * @brief Initializes the core, must be called before anything else
 */
void Core::start()
{
    bool isNewProfile = profile.isNewProfile();
    if (isNewProfile)
    {
        qDebug() << "Creating a new profile";
        makeTox(QByteArray());
        setStatusMessage(tr("Toxing on qTox"));
        setUsername(profile.getName());
    }
    else
    {
        qDebug() << "Loading user profile";
        QByteArray savedata = profile.loadToxSave();
        if (savedata.isEmpty())
        {
            emit failedToStart();
            return;
        }
        makeTox(savedata);
    }

    qsrand(time(nullptr));

    if (!tox)
    {
        ready = true;
        GUI::setEnabled(true);
        return;
    }

    // set GUI with user and statusmsg
    QString name = getUsername();
    if (!name.isEmpty())
        emit usernameSet(name);

    QString msg = getStatusMessage();
    if (!msg.isEmpty())
        emit statusMessageSet(msg);

    QString id = getSelfId().toString();
    if (!id.isEmpty())
        emit idSet(id);

    // TODO: This is a backwards compatibility check,
    // once most people have been upgraded away from the old HistoryKeeper, remove this
    if (Nexus::getProfile()->isEncrypted())
        checkEncryptedHistory();

    loadFriends();

    tox_callback_friend_request(tox, onFriendRequest, this);
    tox_callback_friend_message(tox, onFriendMessage, this);
    tox_callback_friend_name(tox, onFriendNameChange, this);
    tox_callback_friend_typing(tox, onFriendTypingChange, this);
    tox_callback_friend_status_message(tox, onStatusMessageChanged, this);
    tox_callback_friend_status(tox, onUserStatusChanged, this);
    tox_callback_friend_connection_status(tox, onConnectionStatusChanged, this);
    tox_callback_friend_read_receipt(tox, onReadReceiptCallback, this);
    tox_callback_group_invite(tox, onGroupInvite, this);
    tox_callback_group_message(tox, onGroupMessage, this);
    tox_callback_group_namelist_change(tox, onGroupNamelistChange, this);
    tox_callback_group_title(tox, onGroupTitleChange, this);
    tox_callback_group_action(tox, onGroupAction, this);
    tox_callback_file_chunk_request(tox, CoreFile::onFileDataCallback, this);
    tox_callback_file_recv(tox, CoreFile::onFileReceiveCallback, this);
    tox_callback_file_recv_chunk(tox, CoreFile::onFileRecvChunkCallback, this);
    tox_callback_file_recv_control(tox, CoreFile::onFileControlCallback, this);

    QPixmap pic = profile.loadAvatar();
    if (!pic.isNull() && !pic.size().isEmpty())
    {
        QByteArray data;
        QBuffer buffer(&data);
        buffer.open(QIODevice::WriteOnly);
        pic.save(&buffer, "PNG");
        buffer.close();
        setAvatar(data);
    }
    else
    {
        qDebug() << "Self avatar not found, will broadcast empty avatar to friends";
        setAvatar({});
    }

    ready = true;

    // If we created a new profile earlier,
    // now that we're ready save it and ONLY THEN broadcast the new ID.
    // This is useful for e.g. the profileForm that searches for saves.
    if (isNewProfile)
    {
        profile.saveToxSave();
        emit idSet(getSelfId().toString());
    }

    if (isReady())
        GUI::setEnabled(true);

    process(); // starts its own timer
    av->start();
}
Ejemplo n.º 30
0
/*!
  Slot activated when GDBProcessStarted signal of GDBAdapter is raised.
  Enables the GDB exit button.
  */
void StackFramesWidget::handleGDBProcessStarted()
{
  mpExitToolButton->setEnabled(true);
  setStatusMessage("Debugging started");
}