void QmitkUSNavigationProcessWidget::SetSettingsWidget(QmitkUSNavigationAbstractSettingsWidget* settingsWidget)
{
  // disconnect slots to settings widget if there was a widget before
  if ( m_SettingsWidget )
  {
    disconnect( ui->settingsSaveButton, SIGNAL(clicked()), m_SettingsWidget, SLOT(OnSave()) );
    disconnect( ui->settingsCancelButton, SIGNAL(clicked()), m_SettingsWidget, SLOT(OnCancel()) );

    disconnect (m_SettingsWidget, SIGNAL(Saved()), this, SLOT(OnSettingsWidgetReturned()) );
    disconnect (m_SettingsWidget, SIGNAL(Canceled()), this, SLOT(OnSettingsWidgetReturned()) );
    disconnect (m_SettingsWidget, SIGNAL(SettingsChanged(itk::SmartPointer<mitk::DataNode>)), this, SLOT(OnSettingsChanged(itk::SmartPointer<mitk::DataNode>)) );

    ui->settingsWidget->removeWidget(m_SettingsWidget);
  }

  m_SettingsWidget = settingsWidget;
  if ( m_SettingsWidget )
  {
    m_SettingsWidget->LoadSettings();

    connect( ui->settingsSaveButton, SIGNAL(clicked()), m_SettingsWidget, SLOT(OnSave()) );
    connect( ui->settingsCancelButton, SIGNAL(clicked()), m_SettingsWidget, SLOT(OnCancel()) );

    connect (m_SettingsWidget, SIGNAL(Saved()), this, SLOT(OnSettingsWidgetReturned()) );
    connect (m_SettingsWidget, SIGNAL(Canceled()), this, SLOT(OnSettingsWidgetReturned()) );
    connect (m_SettingsWidget, SIGNAL(SettingsChanged(itk::SmartPointer<mitk::DataNode>)), this, SLOT(OnSettingsChanged(itk::SmartPointer<mitk::DataNode>)) );

    if ( m_SettingsNode.IsNotNull() ) { m_SettingsWidget->SetSettingsNode(m_SettingsNode, true); }

    ui->settingsWidget->addWidget(m_SettingsWidget);
  }
  ui->settingsButton->setEnabled(m_SettingsWidget != 0);
}
예제 #2
0
ProgressBarDuo::ProgressBarDuo(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ProgressBarDuo)
{
    ui->setupUi(this);
    connect(ui->cancelButton, SIGNAL(Canceled()), this, SIGNAL(Canceled()));
}
예제 #3
0
void
ServiceWorkerUpdateJob::ContinueUpdateAfterScriptEval(bool aScriptEvaluationResult)
{
  AssertIsOnMainThread();

  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
  if (Canceled() || !swm) {
    FailUpdateJob(NS_ERROR_DOM_ABORT_ERR);
    return;
  }

  // Step 7.5 of the Update algorithm verifying that the script evaluated
  // successfully.

  if (NS_WARN_IF(!aScriptEvaluationResult)) {
    ErrorResult error;

    NS_ConvertUTF8toUTF16 scriptSpec(mScriptSpec);
    NS_ConvertUTF8toUTF16 scope(mRegistration->mScope);
    error.ThrowTypeError<MSG_SW_SCRIPT_THREW>(scriptSpec, scope);
    FailUpdateJob(error);
    return;
  }

  Install(swm);
}
예제 #4
0
void
ServiceWorkerUpdateJob::Update()
{
  AssertIsOnMainThread();
  MOZ_ASSERT(!Canceled());

  // SetRegistration() must be called before Update().
  MOZ_ASSERT(mRegistration);
  MOZ_ASSERT(!mRegistration->GetInstalling());

  // Begin the script download and comparison steps starting at step 5
  // of the Update algorithm.

  RefPtr<ServiceWorkerInfo> workerInfo = mRegistration->Newest();
  nsAutoString cacheName;

  // If the script has not changed, we need to perform a byte-for-byte
  // comparison.
  if (workerInfo && workerInfo->ScriptSpec().Equals(mScriptSpec)) {
    cacheName = workerInfo->CacheName();
  }

  RefPtr<CompareCallback> callback = new CompareCallback(this);

  nsresult rv =
    serviceWorkerScriptCache::Compare(mRegistration, mPrincipal, cacheName,
                                      NS_ConvertUTF8toUTF16(mScriptSpec),
                                      callback, mLoadGroup);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    FailUpdateJob(rv);
    return;
  }
}
예제 #5
0
    SettingsWidget::SettingsWidget(QGraphicsScene *scene, ControlPanelManager *control_panel_manager) : 
        QGraphicsProxyWidget(0, Qt::Widget),
        internal_widget_(new QWidget()),
        panel_(control_panel_manager)
    {
        setupUi(internal_widget_);
        setWidget(internal_widget_);

        setZValue(100);
        visibility_animation_ = new QPropertyAnimation(this, "opacity", this);
        visibility_animation_->setDuration(500);
        visibility_animation_->setEasingCurve(QEasingCurve::InOutSine);
        visibility_animation_->setStartValue(0);
        visibility_animation_->setEndValue(1);

        connect(opacitySlider, SIGNAL(valueChanged(int)), SLOT(OpacitySliderChanged(int)));
        connect(savePushButton, SIGNAL(clicked()), SLOT(SaveSettings()));
        connect(cancelPushButton, SIGNAL(clicked()), SLOT(Canceled()));
        connect(visibility_animation_, SIGNAL(finished()), SLOT(AnimationsFinished()));

        hide();
        scene->addItem(this);

        connect(scene, SIGNAL(sceneRectChanged(const QRectF&)), SLOT(SceneRectChanged(const QRectF&)));
    }
void
ServiceWorkerUpdateJob::ContinueAfterInstallEvent(bool aInstallEventSuccess)
{
  if (Canceled()) {
    return FailUpdateJob(NS_ERROR_DOM_ABORT_ERR);
  }

  MOZ_ASSERT(mRegistration->GetInstalling());

  // Continue executing the Install algorithm at step 12.

  // "If installFailed is true"
  if (NS_WARN_IF(!aInstallEventSuccess)) {
    // The installing worker is cleaned up by FailUpdateJob().
    FailUpdateJob(NS_ERROR_DOM_ABORT_ERR);
    return;
  }

  mRegistration->TransitionInstallingToWaiting();

  Finish(NS_OK);

  // Step 20 calls for explicitly waiting for queued event tasks to fire.  Instead,
  // we simply queue a runnable to execute Activate.  This ensures the events are
  // flushed from the queue before proceeding.

  // Step 22 of the Install algorithm.  Activate is executed after the completion
  // of this job.  The controlling client and skipWaiting checks are performed
  // in TryToActivate().
  mRegistration->TryToActivateAsync();
}
예제 #7
0
    SettingsWidget::SettingsWidget(QGraphicsScene *scene, ControlPanelManager *control_panel_manager) : 
        QGraphicsProxyWidget(0, Qt::Widget),
        internal_widget_(new QWidget()),
        panel_(control_panel_manager)
    {
        setupUi(internal_widget_);
        setWidget(internal_widget_);

        QFont titleFont("facetextrabold", 10, 25, false);
        titleFont.setCapitalization(QFont::AllUppercase);
        titleFont.setStyleStrategy(QFont::PreferAntialias);
        titleFont.setLetterSpacing(QFont::AbsoluteSpacing, 1);
        titleLabel->setFont(titleFont);

        setZValue(100);
        visibility_animation_ = new QPropertyAnimation(this, "opacity", this);
        visibility_animation_->setDuration(500);
        visibility_animation_->setEasingCurve(QEasingCurve::InOutSine);
        visibility_animation_->setStartValue(0);
        visibility_animation_->setEndValue(1);

        connect(opacitySlider, SIGNAL(valueChanged(int)), SLOT(OpacitySliderChanged(int)));
        connect(savePushButton, SIGNAL(clicked()), SLOT(SaveSettings()));
        connect(cancelPushButton, SIGNAL(clicked()), SLOT(Canceled()));
        connect(visibility_animation_, SIGNAL(finished()), SLOT(AnimationsFinished()));
        connect(scene, SIGNAL(sceneRectChanged(const QRectF&)), SLOT(SceneRectChanged(const QRectF&)));

        scene->addItem(this);
        hide();
    }
/* copy atribytes */
bool
BF_GUI_FilesPanel_CopyTask::Copy_Atributes(BNode & o_NodeSrc,BNode & o_NodeDest)
{
    char 		pcName[B_ATTR_NAME_LENGTH];
    attr_info	uAttrInfo;
    uint32		iBufMaxSize=255;
    char		*pcBuf = (char*)malloc(iBufMaxSize);

    o_NodeSrc.RewindAttrs();
    //
    while(B_OK==o_NodeSrc.GetNextAttrName(pcName)) {
        if(B_OK==o_NodeSrc.GetAttrInfo(pcName,&uAttrInfo)) {
            /* check buffer size  */
            if(uAttrInfo.size>iBufMaxSize) {
                DELETE(pcBuf);
                iBufMaxSize = uAttrInfo.size;
                pcBuf = (char*)malloc(iBufMaxSize);
            }
            /* read attr */
            o_NodeSrc.ReadAttr(pcName,uAttrInfo.type,0,
                               (void*)pcBuf,uAttrInfo.size);
            /* write attr */
            o_NodeDest.WriteAttr(pcName,uAttrInfo.type,
                                 0,(void*)pcBuf,uAttrInfo.size);
            /* check for cancel_process */
            if(Canceled()) return false;
        }
    }
    DELETE(pcBuf);
    return true;
}/* end of atributes */
bool
BF_GUI_FilesPanel_DeleteTask::DeleteList(BF_NodeCollection & lo_Node)
{
    BF_Node  	*poNode;
    status_t	uRes;
    BL_String   s;

    for(int i=0; i<lo_Node.CountItems(); i++) {
        poNode = (BF_Node*)lo_Node.ItemAt(i);

        if(poNode->iType==BF_NODE_TYPE_DIR) {
            // check folder_path+name //
            ASSERT(lo_Node.poPath);
            s = lo_Node.poPath->Path();
            s << "/";
            s << poNode->sName;
            if(!CheckFolder_ForSys(s.String())) {
                return false;
            }
        }

        if(poNode->ploChild) {
            DeleteList(*poNode->ploChild);
        }
        // check, remove file or move it to trash
        if(BF_FILESPANEL_DELETE_TO_VOID==iDeleteType) {
            BF_Roster_RemoveNode(*lo_Node.poPath,poNode);
        } else if(BF_FILESPANEL_DELETE_TO_TRASH==iDeleteType) {
            int64		iIndex = 1;
            char		*pcName=NULL;
            while(TRUE) {
                uRes = BF_Roster_MoveNode(*lo_Node.poPath,poNode,sTrashPath.String(),pcName);
                if(B_OK==uRes) break;
                /* try to move to new name */
                if(B_FILE_EXISTS==uRes) {
                    s=poNode->sName;
                    s<<" ";
                    s<<iIndex++;
                    pcName = (char*)s.String();
                    continue;
                }
                /* ups....some error */
                BL_System_TranslError(uRes,s);

                BL_List	*ploMenu = new BL_List();
                ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_TRYAGAIN),"try"));
                ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_SKIP),"skip"));

                if(1==Ask_Message(s.String(),ploMenu)) break;
            }
        }
        //
        SetProgress(++iOperIndex,iOperCount);
        /* check for cancel_process */
        if(Canceled()) return false;

    }
    return true;
}
예제 #10
0
    nana::event_handle onSaveFile(std::function<void(const nana::string& file)> sve)
	{	 
        return Save.events().click ([this,sve]()
                    { 
                      if( ! Canceled () )   
                         sve ( FileName() ) ; 
                    } );
 	}
예제 #11
0
    nana::event_handle _onSave_  (std::function<void(                       )> sve)
	{	 
        return Save.events().click([this,sve]()
                    { 
                      if( ! Canceled () )   
                         sve (  ) ; 
                    } );
 	}
예제 #12
0
    nana::event_handle onOpen    (std::function<void(                       )> opn)
	{	 
        return Open.events().click([this, opn]()
                    { 
                      if( ! Canceled () )   
                         opn (  ) ; 
                    } );
 	}
void
BF_GUI_FilesPanel_Task::RenameNodes(
    const BF_NodeCollection & lo_Node,
    const BF_FilesPath & o_SrcPath,
    const BL_String &s_NewName)
{
    BF_Node 	*poNode=NULL;
    BL_String 	s;
    const char  *pcNewName = NULL;
    BL_String 	sAfterMask;


    // check drive for read_only //
    if(o_SrcPath.IsVolumeReadOnly()) {
        Ask_Error(BF_DictAt(BF_DICT_TASKS_READONLYVOL),false);
        return;
    }


    // check mask
    if(s_NewName.FindFirst("*")<0)
    {   // has not mask_chars
        // check count
        if(lo_Node.CountItems()>1) {
            Ask_Error(BF_DictAt(BF_DICT_TASKS_ONENAMEMANYFILES),false,s_NewName.String());
            return;
        }
    }

    SetProgress(0,lo_Node.CountItems());

    for(int i=0; i<lo_Node.CountItems(); i++) {
        poNode = lo_Node.NodeAt(i);

        pcNewName = s_NewName.String();

        if(poNode->ConvertNameByMask(s_NewName,sAfterMask)) {
            pcNewName = sAfterMask.String();
        }

        ASSERT(pcNewName);

        status_t uRes = BF_Roster_RenameNode(o_SrcPath,poNode,pcNewName);
        if(uRes!=B_OK) {
            BL_String s;
            BL_System_TranslError(uRes,s);
            if(BF_GUI_OPERTASK_ERROR_OK!=Ask_Error(s.String())) return;
        }

        SetProgress(i,lo_Node.CountItems());
        if(Canceled()) return;
    }
}
예제 #14
0
void
ServiceWorkerUpdateJob::Install(ServiceWorkerManager* aSWM)
{
  AssertIsOnMainThread();
  MOZ_DIAGNOSTIC_ASSERT(!Canceled());
  MOZ_DIAGNOSTIC_ASSERT(aSWM);

  MOZ_ASSERT(!mRegistration->GetInstalling());

  // Begin step 2 of the Install algorithm.
  //
  //  https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#installation-algorithm

  mRegistration->TransitionEvaluatingToInstalling();

  // Step 6 of the Install algorithm resolving the job promise.
  InvokeResultCallbacks(NS_OK);

  // The job promise cannot be rejected after this point, but the job can
  // still fail; e.g. if the install event handler throws, etc.

  // fire the updatefound event
  nsCOMPtr<nsIRunnable> upr =
    NewRunnableMethod<RefPtr<ServiceWorkerRegistrationInfo>>(
      "dom::workers::ServiceWorkerManager::"
      "FireUpdateFoundOnServiceWorkerRegistrations",
      aSWM,
      &ServiceWorkerManager::FireUpdateFoundOnServiceWorkerRegistrations,
      mRegistration);
  NS_DispatchToMainThread(upr);

  // Call ContinueAfterInstallEvent(false) on main thread if the SW
  // script fails to load.
  nsCOMPtr<nsIRunnable> failRunnable = NewRunnableMethod<bool>(
    "dom::workers::ServiceWorkerUpdateJob::ContinueAfterInstallEvent",
    this,
    &ServiceWorkerUpdateJob::ContinueAfterInstallEvent,
    false);

  nsMainThreadPtrHandle<ServiceWorkerUpdateJob> handle(
    new nsMainThreadPtrHolder<ServiceWorkerUpdateJob>(
      "ServiceWorkerUpdateJob", this));
  RefPtr<LifeCycleEventCallback> callback = new ContinueInstallRunnable(handle);

  // Send the install event to the worker thread
  ServiceWorkerPrivate* workerPrivate =
    mRegistration->GetInstalling()->WorkerPrivate();
  nsresult rv = workerPrivate->SendLifeCycleEvent(NS_LITERAL_STRING("install"),
                                                  callback, failRunnable);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    ContinueAfterInstallEvent(false /* aSuccess */);
  }
}
void
ServiceWorkerUnregisterJob::AsyncExecute()
{
  AssertIsOnMainThread();

  if (Canceled()) {
    Finish(NS_ERROR_DOM_ABORT_ERR);
    return;
  }

  // Step 1 of the Unregister algorithm requires checking that the
  // client origin matches the scope's origin.  We perform this in
  // registration->update() method directly since we don't have that
  // client information available here.

  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();

  // "Let registration be the result of running [[Get Registration]]
  // algorithm passing scope as the argument."
  RefPtr<ServiceWorkerRegistrationInfo> registration =
    swm->GetRegistration(mPrincipal, mScope);
  if (!registration) {
    // "If registration is null, then, resolve promise with false."
    Finish(NS_OK);
    return;
  }

  // Note, we send the message to remove the registration from disk now even
  // though we may only set the mPendingUninstall flag below.  This is
  // necessary to ensure the registration is removed if the controlled
  // clients are closed by shutting down the browser.  If the registration
  // is resurrected by clearing mPendingUninstall then it should be saved
  // to disk again.
  if (mSendToParent && !registration->mPendingUninstall) {
    swm->MaybeSendUnregister(mPrincipal, mScope);
  }

  // "Set registration's uninstalling flag."
  registration->mPendingUninstall = true;

  // "Resolve promise with true"
  mResult = true;
  InvokeResultCallbacks(NS_OK);

  // "If no service worker client is using registration..."
  if (!registration->IsControllingDocuments()) {
    // "Invoke [[Clear Registration]]..."
    swm->RemoveRegistration(registration);
  }

  Finish(NS_OK);
}
void RocketFileDialogSignaler::HandleFileDialogResult(int result)
{
    QFileDialog *dialog = qobject_cast<QFileDialog *>(sender());
    if (!dialog)
        return;
    if (result == QDialog::Rejected) /// @todo For some reason when dialog is canceled we end up here twice.
    {
        emit Canceled();
        return;
    }
    const QStringList files = dialog->selectedFiles();
    if (files.size() == 1)
    {
        selection_ = files.first();
        lastDir = QFileInfo(selection_).dir().path();
        emit Selected(selection_, this);
    }
}
예제 #17
0
int GuestSessionTask::setProgress(ULONG uPercent)
{
    if (mProgress.isNull()) /* Progress is optional. */
        return VINF_SUCCESS;

    BOOL fCanceled;
    if (   SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
        && fCanceled)
        return VERR_CANCELLED;
    BOOL fCompleted;
    if (   SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
        && !fCompleted)
        return VINF_SUCCESS;
    HRESULT hr = mProgress->SetCurrentOperationProgress(uPercent);
    if (FAILED(hr))
        return VERR_COM_UNEXPECTED;

    return VINF_SUCCESS;
}
예제 #18
0
int GuestSessionTask::setProgressSuccess(void)
{
    if (mProgress.isNull()) /* Progress is optional. */
        return VINF_SUCCESS;

    BOOL fCanceled;
    BOOL fCompleted;
    if (   SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
        && !fCanceled
        && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
        && !fCompleted)
    {
        HRESULT hr = mProgress->notifyComplete(S_OK);
        if (FAILED(hr))
            return VERR_COM_UNEXPECTED; /** @todo Find a better rc. */
    }

    return VINF_SUCCESS;
}
예제 #19
0
void
ServiceWorkerUpdateJob::AsyncExecute()
{
  AssertIsOnMainThread();
  MOZ_ASSERT(GetType() == Type::Update);

  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
  if (Canceled() || !swm) {
    FailUpdateJob(NS_ERROR_DOM_ABORT_ERR);
    return;
  }

  // Begin step 1 of the Update algorithm.
  //
  //  https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#update-algorithm

  RefPtr<ServiceWorkerRegistrationInfo> registration =
    swm->GetRegistration(mPrincipal, mScope);

  if (!registration || registration->mPendingUninstall) {
    ErrorResult rv;
    rv.ThrowTypeError<MSG_SW_UPDATE_BAD_REGISTRATION>(NS_ConvertUTF8toUTF16(mScope),
                                                      NS_LITERAL_STRING("uninstalled"));
    FailUpdateJob(rv);
    return;
  }

  // If a Register job with a new script executed ahead of us in the job queue,
  // then our update for the old script no longer makes sense.  Simply abort
  // in this case.
  RefPtr<ServiceWorkerInfo> newest = registration->Newest();
  if (newest && !mScriptSpec.Equals(newest->ScriptSpec())) {
    ErrorResult rv;
    rv.ThrowTypeError<MSG_SW_UPDATE_BAD_REGISTRATION>(NS_ConvertUTF8toUTF16(mScope),
                                                      NS_LITERAL_STRING("changed"));
    FailUpdateJob(rv);
    return;
  }

  SetRegistration(registration);
  Update();
}
예제 #20
0
HRESULT GuestSessionTask::setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg)
{
    if (mProgress.isNull()) /* Progress is optional. */
        return hr; /* Return original rc. */

    BOOL fCanceled;
    BOOL fCompleted;
    if (   SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
        && !fCanceled
        && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
        && !fCompleted)
    {
        HRESULT hr2 = mProgress->notifyComplete(hr,
                                               COM_IIDOF(IGuestSession),
                                               GuestSession::getStaticComponentName(),
                                               strMsg.c_str());
        if (FAILED(hr2))
            return hr2;
    }
    return hr; /* Return original rc. */
}
예제 #21
0
void
ServiceWorkerUpdateJob::ContinueAfterInstallEvent(bool aInstallEventSuccess)
{
  if (Canceled()) {
    return FailUpdateJob(NS_ERROR_DOM_ABORT_ERR);
  }

  // If we haven't been canceled we should have a registration.  There appears
  // to be a path where it gets cleared before we call into here.  Assert
  // to try to catch this condition, but don't crash in release.
  MOZ_DIAGNOSTIC_ASSERT(mRegistration);
  if (!mRegistration) {
    return FailUpdateJob(NS_ERROR_DOM_ABORT_ERR);
  }

  // Continue executing the Install algorithm at step 12.

  // "If installFailed is true"
  if (NS_WARN_IF(!aInstallEventSuccess)) {
    // The installing worker is cleaned up by FailUpdateJob().
    FailUpdateJob(NS_ERROR_DOM_ABORT_ERR);
    return;
  }

  MOZ_DIAGNOSTIC_ASSERT(mRegistration->GetInstalling());
  mRegistration->TransitionInstallingToWaiting();

  Finish(NS_OK);

  // Step 20 calls for explicitly waiting for queued event tasks to fire.  Instead,
  // we simply queue a runnable to execute Activate.  This ensures the events are
  // flushed from the queue before proceeding.

  // Step 22 of the Install algorithm.  Activate is executed after the completion
  // of this job.  The controlling client and skipWaiting checks are performed
  // in TryToActivate().
  mRegistration->TryToActivateAsync();
}
예제 #22
0
TFutureProgress::TFutureProgress(QWidget *Parent): QWidget(Parent), d_ptr(new TFutureProgressPrivate)
   {
      Q_D(TFutureProgress);
      d->q_ptr = this;
      d->FaderWidget = new TFadeWidgetHack(this);

      QVBoxLayout *Layout = new QVBoxLayout;
      Layout->setMargin(0);
      Layout->setSpacing(0);
      Layout->addWidget(d->Progress);
      Layout->addLayout(d->WidgetLayout);
      d->WidgetLayout->setContentsMargins(2, 1, 2, 1);
      d->WidgetLayout->setSpacing(0);
      setLayout(Layout);

      connect(&d->Watcher, SIGNAL(started()), this, SLOT(_q_SetStarted()));
      connect(&d->Watcher, SIGNAL(finished()), this, SLOT(_q_SetFinished()));
      connect(&d->Watcher, SIGNAL(canceled()), this, SIGNAL(Canceled()));
      connect(&d->Watcher, SIGNAL(progressRangeChanged(int,int)), this, SLOT(_q_SetProgressRange(int,int)));
      connect(&d->Watcher, SIGNAL(progressValueChanged(int)), this, SLOT(_q_SetProgressValue(int)));
      connect(&d->Watcher, SIGNAL(progressTextChanged(QString)), this, SLOT(_q_SetProgressText(QString)));
      connect(d->Progress, SIGNAL(Clicked()), this, SLOT(_q_Cancel()));
   }
예제 #23
0
void
ServiceWorkerRegisterJob::AsyncExecute()
{
  AssertIsOnMainThread();

  if (Canceled()) {
    FailUpdateJob(NS_ERROR_DOM_ABORT_ERR);
    return;
  }

  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
  RefPtr<ServiceWorkerRegistrationInfo> registration =
    swm->GetRegistration(mPrincipal, mScope);

  if (registration) {
    // If we are resurrecting an uninstalling registration, then persist
    // it to disk again.  We preemptively removed it earlier during
    // unregister so that closing the window by shutting down the browser
    // results in the registration being gone on restart.
    if (registration->mPendingUninstall) {
      swm->StoreRegistration(mPrincipal, registration);
    }
    registration->mPendingUninstall = false;
    RefPtr<ServiceWorkerInfo> newest = registration->Newest();
    if (newest && mScriptSpec.Equals(newest->ScriptSpec())) {
      SetRegistration(registration);
      Finish(NS_OK);
      return;
    }
  } else {
    registration = swm->CreateNewRegistration(mScope, mPrincipal);
  }

  SetRegistration(registration);
  Update();
}
void
BF_GUI_FilesPanel_ChangeCaseTask::Run()
{
    // check drive for read_only //
    if(oPath.IsVolumeReadOnly()) {
        Ask_Error(BF_DictAt(BF_DICT_TASKS_READONLYVOL),false);
        return;
    }

    BF_Node *poNode=NULL;
    BL_String s;

    SetProgress(iOperIndex,iOperCount);

    for(int i=0; i<loNode.CountItems(); i++) {
        poNode = loNode.NodeAt(i);
        s = poNode->sName;
        switch(iCaseType) {
        case 0:
            s.ToLower();
            break;
        case 1:
            s.ToUpper();
            break;
        case 2:
            s.Capitalize();
            break;
        case 3:
            s.CapitalizeEachWord();
            break;
        }
        BF_Roster_RenameNode(oPath,poNode,s.String());
        SetProgress(++iOperIndex,iOperCount);
        if(Canceled()) return;
    }
}
예제 #25
0
/* static */
HRESULT GuestTask::setProgressErrorInfo(HRESULT hr, ComObjPtr<Progress> pProgress,
                                               const char *pszText, ...)
{
    BOOL fCanceled;
    BOOL fCompleted;
    if (   SUCCEEDED(pProgress->COMGETTER(Canceled(&fCanceled)))
        && !fCanceled
        && SUCCEEDED(pProgress->COMGETTER(Completed(&fCompleted)))
        && !fCompleted)
    {
        va_list va;
        va_start(va, pszText);
        HRESULT hr2 = pProgress->notifyCompleteV(hr,
                                                 COM_IIDOF(IGuest),
                                                 Guest::getStaticComponentName(),
                                                 pszText,
                                                 va);
        va_end(va);
        if (hr2 == S_OK) /* If unable to retrieve error, return input error. */
            hr2 = hr;
        return hr2;
    }
    return S_OK;
}
void QmitkNavigationToolCreationWidget::OnCancel()
{
  m_CreatedTool = NULL;

  emit Canceled();
}
void QmitkMITKIGTTrackingToolboxView::CreateQtPartControl( QWidget *parent )
{
  // build up qt view, unless already done
  if ( !m_Controls )
  {
    // create GUI widgets from the Qt Designer's .ui file
    m_Controls = new Ui::QmitkMITKIGTTrackingToolboxViewControls;
    m_Controls->setupUi( parent );

    //create connections
    connect( m_Controls->m_LoadTools, SIGNAL(clicked()), this, SLOT(OnLoadTools()) );
    connect( m_Controls->m_Connect, SIGNAL(clicked()), this, SLOT(OnConnect()) );
    connect( m_Controls->m_Disconnect, SIGNAL(clicked()), this, SLOT(OnDisconnect()) );
    connect( m_Controls->m_StartTracking, SIGNAL(clicked()), this, SLOT(OnStartTracking()) );
    connect( m_Controls->m_StopTracking, SIGNAL(clicked()), this, SLOT(OnStopTracking()) );
    connect( m_TrackingTimer, SIGNAL(timeout()), this, SLOT(UpdateTrackingTimer()));
    connect( m_Controls->m_ChooseFile, SIGNAL(clicked()), this, SLOT(OnChooseFileClicked()));
    connect( m_Controls->m_StartLogging, SIGNAL(clicked()), this, SLOT(StartLogging()));
    connect( m_Controls->m_StopLogging, SIGNAL(clicked()), this, SLOT(StopLogging()));
    connect( m_Controls->m_configurationWidget, SIGNAL(TrackingDeviceSelectionChanged()), this, SLOT(OnTrackingDeviceChanged()));
    connect( m_Controls->m_VolumeSelectionBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(OnTrackingVolumeChanged(QString)));
    connect( m_Controls->m_ShowTrackingVolume, SIGNAL(clicked()), this, SLOT(OnShowTrackingVolumeChanged()));
    connect( m_Controls->m_AutoDetectTools, SIGNAL(clicked()), this, SLOT(OnAutoDetectTools()));
    connect( m_Controls->m_ResetTools, SIGNAL(clicked()), this, SLOT(OnResetTools()));

    connect( m_Controls->m_AddSingleTool, SIGNAL(clicked()), this, SLOT(OnAddSingleTool()));
    connect( m_Controls->m_NavigationToolCreationWidget, SIGNAL(NavigationToolFinished()), this, SLOT(OnAddSingleToolFinished()));
    connect( m_Controls->m_NavigationToolCreationWidget, SIGNAL(Canceled()), this, SLOT(OnAddSingleToolCanceled()));

    //initialize widgets
    m_Controls->m_configurationWidget->EnableAdvancedUserControl(false);
    m_Controls->m_TrackingToolsStatusWidget->SetShowPositions(true);
    m_Controls->m_TrackingToolsStatusWidget->SetTextAlignment(Qt::AlignLeft);

    //initialize tracking volume node
    m_TrackingVolumeNode = mitk::DataNode::New();
    m_TrackingVolumeNode->SetName("TrackingVolume");
    m_TrackingVolumeNode->SetOpacity(0.25);
    m_TrackingVolumeNode->SetBoolProperty("Backface Culling",true);
    mitk::Color red;
    red.SetRed(1);
    m_TrackingVolumeNode->SetColor(red);
    GetDataStorage()->Add(m_TrackingVolumeNode);

    //initialize buttons
    m_Controls->m_Connect->setEnabled(true);
    m_Controls->m_Disconnect->setEnabled(false);
    m_Controls->m_StartTracking->setEnabled(false);
    m_Controls->m_StopTracking->setEnabled(false);
    m_Controls->m_AutoDetectTools->setVisible(false); //only visible if tracking device is Aurora

    //Update List of available models for selected tool.
    std::vector<mitk::TrackingDeviceData> Compatibles = mitk::GetDeviceDataForLine( m_Controls->m_configurationWidget->GetTrackingDevice()->GetType());
    m_Controls->m_VolumeSelectionBox->clear();
    for(int i = 0; i < Compatibles.size(); i++)
    {
      m_Controls->m_VolumeSelectionBox->addItem(Compatibles[i].Model.c_str());
    }

    //initialize tool storage
    m_toolStorage = mitk::NavigationToolStorage::New(GetDataStorage());
    m_toolStorage->SetName("TrackingToolbox Default Storage");
    m_toolStorage->RegisterAsMicroservice("no tracking device");
  }
}
void RocketStorageSelectionDialog::OnCancel()
{
    item_ = MeshmoonStorageItem();
    plugin_->Notifications()->ClearForeground();
    emit Canceled();
}
RocketStorageSelectionDialog::RocketStorageSelectionDialog(RocketPlugin *plugin, MeshmoonStorage *storage, const QStringList &suffixFilters, 
                                                           bool allowChangingFolder, MeshmoonStorageItem &startDirectory, QWidget *parent) :
    QDialog(parent),
    plugin_(plugin),
    storage_(storage),
    suffixFilters_(suffixFilters),
    allowChangingFolder_(allowChangingFolder),
    startDirectory_(startDirectory),
    currentFolder_(0)
{
    // Setup UI
    ui_.setupUi(this);
    ui_.scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    ui_.lineEditFilter->installEventFilter(this);

    ui_.buttonSelect->setAutoDefault(false);
    ui_.buttonCancel->setAutoDefault(false);

    view_ = new RocketStorageListWidget(this, plugin_);
    view_->SetPreviewFileOnMouse(true);
    view_->setSelectionMode(QAbstractItemView::SingleSelection);

    QVBoxLayout *l = new QVBoxLayout(ui_.scrollAreaWidgetContents);
    l->setSpacing(0);
    l->setContentsMargins(0,0,0,0);
    l->addWidget(view_);
    ui_.scrollAreaWidgetContents->setLayout(l);

    // Connections
    connect(view_, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(OnItemClicked(QListWidgetItem*)));
    connect(view_, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(OnItemDoubleClicked(QListWidgetItem*)));
    connect(ui_.buttonSelect, SIGNAL(clicked()), SLOT(OnSelect()), Qt::QueuedConnection);
    connect(ui_.buttonCancel, SIGNAL(clicked()), SLOT(reject()), Qt::QueuedConnection);
    connect(this, SIGNAL(rejected()), SLOT(OnCancel()));
    connect(ui_.lineEditFilter, SIGNAL(textChanged(const QString&)), SLOT(OnFilterChanged(const QString&)));

    // Dialog setup
    setAttribute(Qt::WA_DeleteOnClose, true);
    setWindowModality(parent != 0 ? Qt::WindowModal : Qt::ApplicationModal);
    setWindowFlags(parent != 0 ? Qt::Tool : Qt::SplashScreen);
    setWindowTitle(parent != 0 ? "Meshmoon Storage Picker" : "");
    setModal(true);

    // Center to main window or to parent window.
    if (!parent)
    {
        plugin_->Notifications()->DimForeground();
        plugin_->Notifications()->CenterToMainWindow(this);
    }
    else
        plugin_->Notifications()->CenterToWindow(parent, this);
    
    // Show and activate
    show();
    setFocus(Qt::ActiveWindowFocusReason);
    activateWindow();
    
    // If this is a splash dialog animate opacity
    if (!parent)
    {
        setWindowOpacity(0.0);

        QPropertyAnimation *showAnim = new QPropertyAnimation(this, "windowOpacity", this);
        showAnim->setStartValue(0.0);
        showAnim->setEndValue(1.0);
        showAnim->setDuration(300);
        showAnim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad)); 
        showAnim->start();
    }

    if (!plugin_ || !storage_)
    {
        view_->addItem(new QListWidgetItem("Failed to list storage content"));
        return;
    }
    if (storage_->RootDirectory().IsNull())
        view_->addItem(new QListWidgetItem("Loading..."));

    MeshmoonStorageAuthenticationMonitor *auth = storage_->Authenticate();
    connect(auth, SIGNAL(Completed()), SLOT(OnStorageAuthCompleted()), Qt::QueuedConnection);
    connect(auth, SIGNAL(Canceled()), SLOT(reject()), Qt::QueuedConnection);
    connect(auth, SIGNAL(Failed(const QString&)), SLOT(reject()), Qt::QueuedConnection);
}
void
BF_GUI_FilesPanel_MakeLinksTask::Run()
{
    // check dest_path
    {
        BL_String s(oPathDest.Path());

        if(s.FindFirst("/")==0)
        {   // path begin from /
            if(s.FindFirst("*")>=0)
            {   // path include *
                Ask_Error(BF_DictAt(BF_DICT_TASKS_CANTMAKERENAME),false);
                return;
            }
        } else
        {   // path dosn`t begin from /
            if(s.FindFirst("/")>0)
            {   // path include /
                Ask_Error(BF_DictAt(BF_DICT_TASKS_CANTMAKEINFOLDER),false,s.String());
                return;
            }
            // ? mask with *
            if(s.FindFirst("*")>=0) {
                // ok mask with *, mask = dest_path and dest_path = oPathSrc
                sMask = s;
                oPathDest = oPathSrc;
            } else {
                // f**k,mask without *
                if(loNode.CountItems()>1) {
                    Ask_Error(BF_DictAt(BF_DICT_TASKS_CANTMAKELINKONENAME),false,s.String());
                    return;
                } else {
                    // ok, we must make only one link
                    sMask = s;
                    oPathDest = oPathSrc;
                }
            }
        }
    }

    // check dest_path
    if(!Check_DestFolder(oPathDest)) return;

    // start //

    SetProgress(0,loNode.CountItems());

    BL_String 	sSrc,sDest,s,s1;
    status_t	uRes;
    BF_Node		*poNode=NULL;


    for(int i=0; i<loNode.CountItems(); i++) {
        poNode = loNode.NodeAt(i);

        sSrc = oPathSrc.Path();
        sSrc<<"/";
        sSrc<<poNode->Name();

        sDest = oPathDest.Path();
        sDest<<"/";
        sDest<<*poNode->ConvertNameByMaskExt(sMask,s1);

        uRes = BF_Roster_MakeLink(sSrc.String(),sDest.String());
        if(B_FILE_EXISTS==uRes) {
            s=BF_DictAt(BF_DICT_TASKS_DESTFILE);
            s<<poNode->sName;
            s<<BF_DictAt(BF_DICT_TASKS_DESTFILEEXIST);
            if(BF_GUI_OPERTASK_ERROR_CANCEL_ALL==Ask_Error(s.String())) return;
        } else if(uRes!=B_OK) {
            BL_System_TranslError(uRes,s);
            if(BF_GUI_OPERTASK_ERROR_CANCEL_ALL==Ask_Error(s.String())) return;
        }
        SetProgress(i,loNode.CountItems());
        if(Canceled()) return;
    }
}