コード例 #1
0
//**************************************************************************
// NameDialog :: command - Process Commands                               *
//**************************************************************************
Boolean UpdlDialog :: command(ICommandEvent& cmdevt)
{
  long index=-1;
  Appointment *appt;
  Environment *ev = somGetGlobalEnvironment();

  switch(cmdevt.commandId()) {
    case DID_OK:
                       // If a selection was made
      if ( *IDValue >= 0 ) {
                  // Ok is pressed get the modifications if there are some
        if (sequenceLength(apptList)>0) {
          appt = sequenceElement(apptList,*IDValue);
          if (appt->somIsA(_ConferenceCall)) {
                                              // Check to see if the entry changed
            if (fldPhone.hasChanged()) {
              fldPhone.selectRange();
              new_phone=fldPhone.selectedText();
            }
          } else {
            if (fldLocation.hasChanged()) {
              fldLocation.selectRange();
              new_location=fldLocation.selectedText();
            }
          }
          if (fldSubject.hasChanged()) {
            fldSubject.selectRange();
              new_subject=fldSubject.selectedText();
          }
        } /* endif */
      }
      dismiss(DID_OK);
      return(true);
      break;

    case DID_CANCEL:
      dismiss(DID_CANCEL);
      return(true);
      break;

    case DID_SELECT:
      index = listBox.selection();  // return index to selection
      if (sequenceLength(apptList)>0) {
         btnOk.enable();    // enable ok since a selection is made
         if (index >= 0) {
           appt = sequenceElement(apptList,index);
           if (!fldPhone.isEmpty()) {
             fldPhone.selectRange();
             fldPhone.clear();
           }
           if (!fldLocation.isEmpty()) {
             fldLocation.selectRange();
             fldLocation.clear();
           }
           if (!fldSubject.isEmpty()) {
             fldSubject.selectRange();
             fldSubject.clear();
           }
           if (appt->somIsA(_ConferenceCall)) {
             fldPhone.enable();
             fldPhone.setText(((ConferenceCall *)appt)->_get_phoneNumber(ev));
             fldLocation.disable();
           } else {
             fldLocation.enable();
             fldLocation.setText(((Meeting *)appt)->_get_location(ev));
             fldPhone.disable();
           }
           fldSubject.enable();
           fldSubject.setText(appt->_get_subject(ev));
           *IDValue = index;
         }
      }
      return(true);
      break;
  }/* end switch */

  return(false);  //Allow Default Processing to occur
}
コード例 #2
0
ファイル: widget-factory.c プロジェクト: Adriatic1/gtk
static void
spin_value_reset (GtkWidget *button, GtkAdjustment *adjustment)
{
  gtk_adjustment_set_value (adjustment, 50.0);
  dismiss (button);
}
コード例 #3
0
bool CmdPasteSymbolItems::performExecute() {
  // if an error occurs, undo all already executed child commands
  auto undoScopeGuard = scopeGuard([&]() { performUndo(); });

  // Notes:
  //
  //  - If the UUID is already existing, or the destination symbol is different
  //    to the source symbol, generate a new random UUID. Otherwise use the same
  //    UUID to avoid modifications after cut+paste within one symbol.
  //  - If there is already a pin with the same name, increment its number (or
  //    start adding a number if there is none already) to get unique names.
  //  - The graphics items of the added elements are selected immediately to
  //    allow dragging them afterwards.

  for (const SymbolPin& pin : mData->getPins().sortedByName()) {
    Uuid uuid = pin.getUuid();
    if (mSymbol.getPins().contains(uuid) ||
        (mSymbol.getUuid() != mData->getSymbolUuid())) {
      uuid = Uuid::createRandom();
    }
    CircuitIdentifier name = pin.getName();
    for (int i = 0; (i < 1000) && mSymbol.getPins().contains(*name); ++i) {
      name = CircuitIdentifier(
          Toolbox::incrementNumberInString(*name));  // can throw
    }
    std::shared_ptr<SymbolPin> copy =
        std::make_shared<SymbolPin>(uuid, name, pin.getPosition() + mPosOffset,
                                    pin.getLength(), pin.getRotation());
    execNewChildCmd(new CmdSymbolPinInsert(mSymbol.getPins(), copy));
    SymbolPinGraphicsItem* item = mGraphicsItem.getPinGraphicsItem(uuid);
    Q_ASSERT(item);
    item->setSelected(true);
  }

  for (const Circle& circle : mData->getCircles().sortedByUuid()) {
    Uuid uuid = circle.getUuid();
    if (mSymbol.getCircles().contains(uuid) ||
        (mSymbol.getUuid() != mData->getSymbolUuid())) {
      uuid = Uuid::createRandom();
    }
    std::shared_ptr<Circle> copy = std::make_shared<Circle>(
        uuid, circle.getLayerName(), circle.getLineWidth(), circle.isFilled(),
        circle.isGrabArea(), circle.getCenter() + mPosOffset,
        circle.getDiameter());
    execNewChildCmd(new CmdCircleInsert(mSymbol.getCircles(), copy));
    CircleGraphicsItem* item = mGraphicsItem.getCircleGraphicsItem(*copy);
    Q_ASSERT(item);
    item->setSelected(true);
  }

  for (const Polygon& polygon : mData->getPolygons().sortedByUuid()) {
    Uuid uuid = polygon.getUuid();
    if (mSymbol.getPolygons().contains(uuid) ||
        (mSymbol.getUuid() != mData->getSymbolUuid())) {
      uuid = Uuid::createRandom();
    }
    std::shared_ptr<Polygon> copy = std::make_shared<Polygon>(
        uuid, polygon.getLayerName(), polygon.getLineWidth(),
        polygon.isFilled(), polygon.isGrabArea(),
        polygon.getPath().translated(mPosOffset));
    execNewChildCmd(new CmdPolygonInsert(mSymbol.getPolygons(), copy));
    PolygonGraphicsItem* item = mGraphicsItem.getPolygonGraphicsItem(*copy);
    Q_ASSERT(item);
    item->setSelected(true);
  }

  for (const Text& text : mData->getTexts().sortedByUuid()) {
    Uuid uuid = text.getUuid();
    if (mSymbol.getTexts().contains(uuid) ||
        (mSymbol.getUuid() != mData->getSymbolUuid())) {
      uuid = Uuid::createRandom();
    }
    std::shared_ptr<Text> copy = std::make_shared<Text>(
        uuid, text.getLayerName(), text.getText(),
        text.getPosition() + mPosOffset, text.getRotation(), text.getHeight(),
        text.getAlign());
    execNewChildCmd(new CmdTextInsert(mSymbol.getTexts(), copy));
    TextGraphicsItem* item = mGraphicsItem.getTextGraphicsItem(*copy);
    Q_ASSERT(item);
    item->setSelected(true);
  }

  undoScopeGuard.dismiss();  // no undo required
  return getChildCount() > 0;
}
コード例 #4
0
ファイル: inputcapture.cpp プロジェクト: ben401/OpenEmu
void InputCalibrationWindow::closeEvent(QCloseEvent *event) {
  QbWindow::closeEvent(event);
  dismiss();
}
コード例 #5
0
void FoursquareAuthPage::tokenReceived(QString token)
{
	Q_EMIT(authenticationComplete(token));
	dismiss();
}
コード例 #6
0
Status IndexBuildInterceptor::drainWritesIntoIndex(OperationContext* opCtx,
                                                   const InsertDeleteOptions& options,
                                                   RecoveryUnit::ReadSource readSource) {
    invariant(!opCtx->lockState()->inAWriteUnitOfWork());

    // Callers may request to read at a specific timestamp so that no drained writes are timestamped
    // earlier than their original write timestamp. Also ensure that leaving this function resets
    // the ReadSource to its original value.
    auto resetReadSourceGuard =
        makeGuard([ opCtx, prevReadSource = opCtx->recoveryUnit()->getTimestampReadSource() ] {
            opCtx->recoveryUnit()->abandonSnapshot();
            opCtx->recoveryUnit()->setTimestampReadSource(prevReadSource);
        });

    if (readSource != RecoveryUnit::ReadSource::kUnset) {
        opCtx->recoveryUnit()->abandonSnapshot();
        opCtx->recoveryUnit()->setTimestampReadSource(readSource);
    } else {
        resetReadSourceGuard.dismiss();
    }

    // These are used for logging only.
    int64_t totalDeleted = 0;
    int64_t totalInserted = 0;
    Timer timer;

    const int64_t appliedAtStart = _numApplied;

    // Set up the progress meter. This will never be completely accurate, because more writes can be
    // read from the side writes table than are observed before draining.
    static const char* curopMessage = "Index Build: draining writes received during build";
    ProgressMeterHolder progress;
    {
        stdx::unique_lock<Client> lk(*opCtx->getClient());
        progress.set(CurOp::get(opCtx)->setProgress_inlock(curopMessage));
    }

    // Force the progress meter to log at the end of every batch. By default, the progress meter
    // only logs after a large number of calls to hit(), but since we batch inserts by up to
    // 1000 records, progress would rarely be displayed.
    progress->reset(_sideWritesCounter.load() - appliedAtStart /* total */,
                    3 /* secondsBetween */,
                    1 /* checkInterval */);

    // Buffer operations into batches to insert per WriteUnitOfWork. Impose an upper limit on the
    // number of documents and the total size of the batch.
    const int32_t kBatchMaxSize = 1000;
    const int64_t kBatchMaxBytes = BSONObjMaxInternalSize;

    int64_t batchSizeBytes = 0;

    std::vector<SideWriteRecord> batch;
    batch.reserve(kBatchMaxSize);

    // Hold on to documents that would exceed the per-batch memory limit. Always insert this first
    // into the next batch.
    boost::optional<SideWriteRecord> stashed;

    auto cursor = _sideWritesTable->rs()->getCursor(opCtx);

    bool atEof = false;
    while (!atEof) {
        opCtx->checkForInterrupt();

        // Stashed records should be inserted into a batch first.
        if (stashed) {
            invariant(batch.empty());
            batch.push_back(std::move(stashed.get()));
            stashed.reset();
        }

        auto record = cursor->next();

        if (record) {
            RecordId currentRecordId = record->id;
            BSONObj docOut = record->data.toBson().getOwned();

            // If the total batch size in bytes would be too large, stash this document and let the
            // current batch insert.
            int objSize = docOut.objsize();
            if (batchSizeBytes + objSize > kBatchMaxBytes) {
                invariant(!stashed);

                // Stash this document to be inserted in the next batch.
                stashed.emplace(currentRecordId, std::move(docOut));
            } else {
                batchSizeBytes += objSize;
                batch.emplace_back(currentRecordId, std::move(docOut));

                // Continue if there is more room in the batch.
                if (batch.size() < kBatchMaxSize) {
                    continue;
                }
            }
        } else {
            atEof = true;
            if (batch.empty())
                break;
        }

        invariant(!batch.empty());

        cursor->save();

        // If we are here, either we have reached the end of the table or the batch is full, so
        // insert everything in one WriteUnitOfWork, and delete each inserted document from the side
        // writes table.
        auto status = writeConflictRetry(opCtx, "index build drain", _indexCatalogEntry->ns(), [&] {
            WriteUnitOfWork wuow(opCtx);
            for (auto& operation : batch) {
                auto status =
                    _applyWrite(opCtx, operation.second, options, &totalInserted, &totalDeleted);
                if (!status.isOK()) {
                    return status;
                }

                // Delete the document from the table as soon as it has been inserted into the
                // index. This ensures that no key is ever inserted twice and no keys are skipped.
                _sideWritesTable->rs()->deleteRecord(opCtx, operation.first);
            }

            // For rollback to work correctly, these writes need to be timestamped. The actual time
            // is not important, as long as it not older than the most recent visible side write.
            IndexTimestampHelper::setGhostCommitTimestampForWrite(
                opCtx, NamespaceString(_indexCatalogEntry->ns()));

            wuow.commit();
            return Status::OK();
        });
        if (!status.isOK()) {
            return status;
        }

        progress->hit(batch.size());

        // Lock yielding will only happen if we are holding intent locks.
        _tryYield(opCtx);
        cursor->restore();

        // Account for more writes coming in during a batch.
        progress->setTotalWhileRunning(_sideWritesCounter.loadRelaxed() - appliedAtStart);

        _numApplied += batch.size();
        batch.clear();
        batchSizeBytes = 0;
    }

    progress->finished();

    int logLevel = (_numApplied - appliedAtStart > 0) ? 0 : 1;
    LOG(logLevel) << "index build: drain applied " << (_numApplied - appliedAtStart)
                  << " side writes (inserted: " << totalInserted << ", deleted: " << totalDeleted
                  << ") for '" << _indexCatalogEntry->descriptor()->indexName() << "' in "
                  << timer.millis() << " ms";

    return Status::OK();
}
コード例 #7
0
ファイル: smartptr.hpp プロジェクト: yesyestian/BNB-solver
 /**
  * Copies the content of the array pointer
  * @param sp array to clone
  */
 void copy(const SmartArrayPtr & sp) {
     dismiss();
     alloc(sp.mDim);
     for(int i = 0; i < mDim; i ++)
        ((T*)mXBlock.mP)[i] = sp[i];
 }
コード例 #8
0
void FoursquareVenueSelectionPage::venueSelected(const QModelIndex &which)
{
	dismiss();
	Q_EMIT(selected(m_model->venue(which)));
}
コード例 #9
0
ファイル: smartptr.hpp プロジェクト: yesyestian/BNB-solver
 /**
  * Destructor
  *
  */
 ~SmartArrayPtr ()
 {
   dismiss ();
 }
コード例 #10
0
ファイル: smartptr.hpp プロジェクト: yesyestian/BNB-solver
 /**
  * Assignment operator
  * @param sp
  * @return
  */
 SmartArrayPtr & operator = (const SmartArrayPtr & sp)
 {
   dismiss ();
   assign(sp);
   return *this;
 }
コード例 #11
0
ファイル: Subprocess.cpp プロジェクト: HikaruLim/folly
void Subprocess::spawn(
    std::unique_ptr<const char*[]> argv,
    const char* executable,
    const Options& optionsIn,
    const std::vector<std::string>* env) {
  if (optionsIn.usePath_ && env) {
    throw std::invalid_argument(
        "usePath() not allowed when overriding environment");
  }

  // Make a copy, we'll mutate options
  Options options(optionsIn);

  // On error, close all pipes_ (ignoring errors, but that seems fine here).
  auto pipesGuard = makeGuard([this] { pipes_.clear(); });

  // Create a pipe to use to receive error information from the child,
  // in case it fails before calling exec()
  int errFds[2];
#if FOLLY_HAVE_PIPE2
  checkUnixError(::pipe2(errFds, O_CLOEXEC), "pipe2");
#else
  checkUnixError(::pipe(errFds), "pipe");
#endif
  SCOPE_EXIT {
    CHECK_ERR(::close(errFds[0]));
    if (errFds[1] >= 0) {
      CHECK_ERR(::close(errFds[1]));
    }
  };

#if !FOLLY_HAVE_PIPE2
  // Ask the child to close the read end of the error pipe.
  checkUnixError(fcntl(errFds[0], F_SETFD, FD_CLOEXEC), "set FD_CLOEXEC");
  // Set the close-on-exec flag on the write side of the pipe.
  // This way the pipe will be closed automatically in the child if execve()
  // succeeds.  If the exec fails the child can write error information to the
  // pipe.
  checkUnixError(fcntl(errFds[1], F_SETFD, FD_CLOEXEC), "set FD_CLOEXEC");
#endif

  // Perform the actual work of setting up pipes then forking and
  // executing the child.
  spawnInternal(std::move(argv), executable, options, env, errFds[1]);

  // After spawnInternal() returns the child is alive.  We have to be very
  // careful about throwing after this point.  We are inside the constructor,
  // so if we throw the Subprocess object will have never existed, and the
  // destructor will never be called.
  //
  // We should only throw if we got an error via the errFd, and we know the
  // child has exited and can be immediately waited for.  In all other cases,
  // we have no way of cleaning up the child.

  // Close writable side of the errFd pipe in the parent process
  CHECK_ERR(::close(errFds[1]));
  errFds[1] = -1;

  // Read from the errFd pipe, to tell if the child ran into any errors before
  // calling exec()
  readChildErrorPipe(errFds[0], executable);

  // We have fully succeeded now, so release the guard on pipes_
  pipesGuard.dismiss();
}
コード例 #12
0
ファイル: SslFd.cpp プロジェクト: najibalghaeth/td
Result<SslFd> SslFd::init(SocketFd fd, CSlice host, CSlice cert_file, VerifyPeer verify_peer) {
#if TD_WINDOWS
  return Status::Error("TODO");
#else
  static bool init_openssl = [] {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
    return OPENSSL_init_ssl(0, nullptr) != 0;
#else
    OpenSSL_add_all_algorithms();
    SSL_load_error_strings();
    return OpenSSL_add_ssl_algorithms() != 0;
#endif
  }();
  CHECK(init_openssl);

  openssl_clear_errors("Before SslFd::init");
  CHECK(!fd.empty());

  auto ssl_method =
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
      TLS_client_method();
#else
      SSLv23_client_method();
#endif
  if (ssl_method == nullptr) {
    return create_openssl_error(-6, "Failed to create an SSL client method");
  }

  auto ssl_ctx = SSL_CTX_new(ssl_method);
  if (ssl_ctx == nullptr) {
    return create_openssl_error(-7, "Failed to create an SSL context");
  }
  auto ssl_ctx_guard = ScopeExit() + [&]() { SSL_CTX_free(ssl_ctx); };
  long options = 0;
#ifdef SSL_OP_NO_SSLv2
  options |= SSL_OP_NO_SSLv2;
#endif
#ifdef SSL_OP_NO_SSLv3
  options |= SSL_OP_NO_SSLv3;
#endif
  SSL_CTX_set_options(ssl_ctx, options);
  SSL_CTX_set_mode(ssl_ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER | SSL_MODE_ENABLE_PARTIAL_WRITE);

  if (cert_file.empty()) {
    SSL_CTX_set_default_verify_paths(ssl_ctx);
  } else {
    if (SSL_CTX_load_verify_locations(ssl_ctx, cert_file.c_str(), nullptr) == 0) {
      return create_openssl_error(-8, "Failed to set custom cert file");
    }
  }
  if (VERIFY_PEER && verify_peer == VerifyPeer::On) {
    SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, verify_callback);

    if (VERIFY_DEPTH != -1) {
      SSL_CTX_set_verify_depth(ssl_ctx, VERIFY_DEPTH);
    }
  } else {
    SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_NONE, nullptr);
  }

  // TODO(now): cipher list
  string cipher_list;
  if (SSL_CTX_set_cipher_list(ssl_ctx, cipher_list.empty() ? "DEFAULT" : cipher_list.c_str()) == 0) {
    return create_openssl_error(-9, PSLICE("Failed to set cipher list \"%s\"", cipher_list.c_str()));
  }

  auto ssl_handle = SSL_new(ssl_ctx);
  if (ssl_handle == nullptr) {
    return create_openssl_error(-13, "Failed to create an SSL handle");
  }
  auto ssl_handle_guard = ScopeExit() + [&]() {
    do_ssl_shutdown(ssl_handle);
    SSL_free(ssl_handle);
  };

#if OPENSSL_VERSION_NUMBER >= 0x10002000L
  X509_VERIFY_PARAM *param = SSL_get0_param(ssl_handle);
  /* Enable automatic hostname checks */
  // TODO: X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS
  X509_VERIFY_PARAM_set_hostflags(param, 0);
  X509_VERIFY_PARAM_set1_host(param, host.c_str(), 0);
#else
#warning DANGEROUS! HTTPS HOST WILL NOT BE CHECKED. INSTALL OPENSSL >= 1.0.2 OR IMPLEMENT HTTPS HOST CHECK MANUALLY
#endif

  if (!SSL_set_fd(ssl_handle, fd.get_fd().get_native_fd())) {
    return create_openssl_error(-14, "Failed to set fd");
  }

#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
  auto host_str = host.str();
  SSL_set_tlsext_host_name(ssl_handle, MutableCSlice(host_str).begin());
#endif
  SSL_set_connect_state(ssl_handle);

  ssl_ctx_guard.dismiss();
  ssl_handle_guard.dismiss();
  return SslFd(std::move(fd), ssl_handle, ssl_ctx);
#endif
}
コード例 #13
0
SwAcctEditPage::SwAcctEditPage(SwClientService *swService, QGraphicsItem *parent) :
        MApplicationPage(parent),
        mService(swService),
        mServiceConfig(mService->getServiceConfig()),
        mFlickrClicked(false)
{
    int adj = 0;
    setEscapeMode(MApplicationPageModel::EscapeManualBack);
    connect(this, SIGNAL(backButtonClicked()),
            this, SLOT(dismiss()));

    connect(mService,
            SIGNAL(CredsStateChanged(SwClientService*,SwClientService::CredsState)),
            this,
            SLOT(onCredsStateChanged(SwClientService *, SwClientService::CredsState)));
    if (!mServiceConfig->isValid())
        dismiss();
    mParams = mServiceConfig->getConfigParams();

    MLayout *layout = new MLayout;
    MGridLayoutPolicy *policy = new MGridLayoutPolicy(layout);

    QString link = mServiceConfig->getLink();
    MLabel *lblServiceName = new MLabel();
    if (!link.isEmpty())
        lblServiceName->setText(QString("<a href=\"%1\">%2</a>").arg(link, mServiceConfig->getDisplayName()));
    else
        lblServiceName->setText(mServiceConfig->getDisplayName());
    lblServiceName->setObjectName("SwAcctEditPageServiceNameLabel");
    policy->addItem(lblServiceName, 0, 0, 1, 2, Qt::AlignHCenter);

    connect(lblServiceName,
            SIGNAL(linkActivated(QString)),
            this,
            SLOT(onLinkClicked(QString)));

    QString desc = mServiceConfig->getDescription();
    if (!desc.isEmpty()) {
        MLabel *lblServiceDesc = new MLabel();
        lblServiceDesc->setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
        lblServiceDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        //Have to insert a random HTML tag to make word wrap actually work...
        //Should be able to remove at some point once MTF word wrap works properly
        lblServiceDesc->setText(QString("<b></b>").append(desc));
        lblServiceDesc->setObjectName("SwAcctEditPageServiceDescLabel");
        policy->addItem(lblServiceDesc, 1, 0, 1, 2, Qt::AlignLeft);
    } else {
        adj -= 1;
    }

    //This is *ugly*
    if (mServiceConfig->getAuthtype() == SwClientServiceConfig::AuthTypeFlickr) {
        if (!mParams.value(USER_KEY).isEmpty()) {
            //% "User %1"
            MLabel *lblUsername = new MLabel(qtTrId("label_flickr_username").arg(mParams.value(USER_KEY)));
            lblUsername->setObjectName("SwAcctEditPageFlickrUserLabel");
            policy->addItem(lblUsername, 2+adj, 0, 1, 2, Qt::AlignHCenter);
            adj += 1;
        }

        mFlickrButton = new MButton();
        mFlickrButton->setObjectName("SwAcctEditPageFlickrButton");
        policy->addItem(mFlickrButton, 2+adj, 0, 1, 2, Qt::AlignHCenter);

        connect(mFlickrButton,
                SIGNAL(clicked()),
                this,
                SLOT(onFlickrClicked()));

        adj += 1;
    } else {
        MLabel *lblUsername = new MLabel();
        lblUsername->setObjectName("SwAcctEditPageUsernameLabel");
        lblUsername->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        //% "Username:"******"label_username"));
        policy->addItem(lblUsername, 2+adj, 0);

        mEdtUsername = new MTextEdit(MTextEditModel::SingleLine);
        mEdtUsername->setObjectName("SwAcctEditPageUsernameButton");
        mEdtUsername->setText(mParams.value(USER_KEY));
        //qDebug() << QString("Set username to %1").arg(mParams.value(USER_KEY));
        policy->addItem(mEdtUsername, 2+adj, 1);

        if (mServiceConfig->getAuthtype() == SwClientServiceConfig::AuthTypePassword) {
            MLabel *lblPassword = new MLabel();
            lblPassword->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
            //% "Password:"******"label_password"));
            lblPassword->setObjectName("SwAcctEditPagePasswordLabel");
            policy->addItem(lblPassword, 3+adj, 0);
            mEdtPassword = new MTextEdit(MTextEditModel::SingleLine);
            mEdtPassword->setText(mParams.value(PASS_KEY));
            mEdtPassword->setEchoMode(MTextEditModel::Password);
            mEdtPassword->setObjectName("SwAcctEditPagePasswordButton");
    //        qDebug() << QString("Set password to %1").arg(mParams.value(PASS_KEY));
            policy->addItem(mEdtPassword, 3+adj, 1);
            connect(mEdtPassword,
                    SIGNAL(textChanged()),
                    this,
                    SLOT(onLoginChanged()));
            adj += 1;
        }
    }

    mLblStatus = new MLabel(STATUS_TEXT_UNCONFIGURED);
    mLblStatus->setObjectName("SwAcctEditPageStatusLabel");
    policy->addItem(mLblStatus, 3+adj, 0, 1, 2, Qt::AlignHCenter);

    onCredsStateChanged(mService, mService->credsState());

    MLabel *lblServiceHint = new MLabel();
    lblServiceHint->setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    lblServiceHint->setObjectName("SwAcctEditPageServiceHintLabel");
    lblServiceHint->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    lblServiceHint->setText(SERVICE_HINT_TEXT.arg(mService->getDisplayName()));
    policy->addItem(lblServiceHint, 4+adj, 0, 1, 2);


    //This, also, is *ugly*
    if (mServiceConfig->getAuthtype() != SwClientServiceConfig::AuthTypeFlickr) {
        //% "Apply"
        mBtnApply = new MButton(qtTrId("button_apply"));
        mBtnApply->setObjectName("SwAcctEditPageApplyButton");
        policy->addItem(mBtnApply, 5+adj, 0, 1, 2, Qt::AlignHCenter);

        //% "Cancel"
        mBtnCancel = new MButton(qtTrId("button_cancel"));
        mBtnCancel->setObjectName("SwAcctEditPageCancelButton");
        policy->addItem(mBtnCancel, 6+adj, 0, 1, 2, Qt::AlignHCenter);

        connect(mEdtUsername,
                SIGNAL(textChanged()),
                this,
                SLOT(onLoginChanged()));

        connect(mBtnApply,
                SIGNAL(clicked()),
                this,
                SLOT(onApplyClicked()));
        connect(mBtnCancel,
                SIGNAL(clicked()),
                this,
                SLOT(dismiss()));
    }


    layout->setPolicy(policy);
    centralWidget()->setLayout(layout);
}
コード例 #14
0
ファイル: simple_test.hpp プロジェクト: GorNishanov/range-v3
 void operator<(U const &u)
 {
     dismiss();
     if(!(t_ < u)) this->oops(u);
 }
コード例 #15
0
bool CmdPasteFootprintItems::performExecute() {
  // if an error occurs, undo all already executed child commands
  auto undoScopeGuard = scopeGuard([&]() { performUndo(); });

  // Notes:
  //
  //  - If the UUID is already existing, or the destination footprint is
  //    different to the source footprint, generate a new random UUID. Otherwise
  //    use the same UUID to avoid modifications after cut+paste within one
  //    footprint.
  //  - Footprint pads are only copied if there is an unused package pad with
  //    the same name available.
  //  - The graphics items of the added elements are selected immediately to
  //    allow dragging them afterwards.

  for (const FootprintPad& pad : mData->getFootprintPads().sortedByUuid()) {
    Uuid              uuid = pad.getPackagePadUuid();
    CircuitIdentifier name = mData->getPackagePads().get(uuid)->getName();
    std::shared_ptr<PackagePad> newPad = mPackage.getPads().find(*name);
    if (newPad && (!mFootprint.getPads().contains(newPad->getUuid()))) {
      std::shared_ptr<FootprintPad> copy = std::make_shared<FootprintPad>(
          uuid, pad.getPosition() + mPosOffset, pad.getRotation(),
          pad.getShape(), pad.getWidth(), pad.getHeight(),
          pad.getDrillDiameter(), pad.getBoardSide());
      execNewChildCmd(new CmdFootprintPadInsert(mFootprint.getPads(), copy));
      FootprintPadGraphicsItem* item = mGraphicsItem.getPadGraphicsItem(*copy);
      Q_ASSERT(item);
      item->setSelected(true);
    }
  }

  for (const Circle& circle : mData->getCircles().sortedByUuid()) {
    Uuid uuid = circle.getUuid();
    if (mFootprint.getCircles().contains(uuid) ||
        (mFootprint.getUuid() != mData->getFootprintUuid())) {
      uuid = Uuid::createRandom();
    }
    std::shared_ptr<Circle> copy = std::make_shared<Circle>(
        uuid, circle.getLayerName(), circle.getLineWidth(), circle.isFilled(),
        circle.isGrabArea(), circle.getCenter() + mPosOffset,
        circle.getDiameter());
    execNewChildCmd(new CmdCircleInsert(mFootprint.getCircles(), copy));
    CircleGraphicsItem* item = mGraphicsItem.getCircleGraphicsItem(*copy);
    Q_ASSERT(item);
    item->setSelected(true);
  }

  for (const Polygon& polygon : mData->getPolygons().sortedByUuid()) {
    Uuid uuid = polygon.getUuid();
    if (mFootprint.getPolygons().contains(uuid) ||
        (mFootprint.getUuid() != mData->getFootprintUuid())) {
      uuid = Uuid::createRandom();
    }
    std::shared_ptr<Polygon> copy = std::make_shared<Polygon>(
        uuid, polygon.getLayerName(), polygon.getLineWidth(),
        polygon.isFilled(), polygon.isGrabArea(),
        polygon.getPath().translated(mPosOffset));
    execNewChildCmd(new CmdPolygonInsert(mFootprint.getPolygons(), copy));
    PolygonGraphicsItem* item = mGraphicsItem.getPolygonGraphicsItem(*copy);
    Q_ASSERT(item);
    item->setSelected(true);
  }

  for (const StrokeText& text : mData->getStrokeTexts().sortedByUuid()) {
    Uuid uuid = text.getUuid();
    if (mFootprint.getStrokeTexts().contains(uuid) ||
        (mFootprint.getUuid() != mData->getFootprintUuid())) {
      uuid = Uuid::createRandom();
    }
    std::shared_ptr<StrokeText> copy = std::make_shared<StrokeText>(
        uuid, text.getLayerName(), text.getText(),
        text.getPosition() + mPosOffset, text.getRotation(), text.getHeight(),
        text.getStrokeWidth(), text.getLetterSpacing(), text.getLineSpacing(),
        text.getAlign(), text.getMirrored(), text.getAutoRotate());
    execNewChildCmd(new CmdStrokeTextInsert(mFootprint.getStrokeTexts(), copy));
    StrokeTextGraphicsItem* item = mGraphicsItem.getTextGraphicsItem(*copy);
    Q_ASSERT(item);
    item->setSelected(true);
  }

  for (const Hole& hole : mData->getHoles().sortedByUuid()) {
    Uuid uuid = hole.getUuid();
    if (mFootprint.getHoles().contains(uuid) ||
        (mFootprint.getUuid() != mData->getFootprintUuid())) {
      uuid = Uuid::createRandom();
    }
    std::shared_ptr<Hole> copy = std::make_shared<Hole>(
        uuid, hole.getPosition() + mPosOffset, hole.getDiameter());
    execNewChildCmd(new CmdHoleInsert(mFootprint.getHoles(), copy));
    HoleGraphicsItem* item = mGraphicsItem.getHoleGraphicsItem(*copy);
    Q_ASSERT(item);
    item->setSelected(true);
  }

  undoScopeGuard.dismiss();  // no undo required
  return getChildCount() > 0;
}
コード例 #16
0
ファイル: simple_test.hpp プロジェクト: GorNishanov/range-v3
 void operator>=(U const &u)
 {
     dismiss();
     if(!(t_ >= u)) this->oops(u);
 }
コード例 #17
0
void SimpleLayer::onClosePressed(cocos2d::Ref* sender, cocos2d::extension::Control::EventType e) {
    dismiss();
}
コード例 #18
0
ファイル: AsyncUDPSocket.cpp プロジェクト: HengWang/UdpPinger
void AsyncUDPSocket::bind(const folly::SocketAddress &address) {
  int socket = ::socket(address.getFamily(), SOCK_DGRAM, IPPROTO_UDP);
  if (socket == -1) {
    throw AsyncSocketException(AsyncSocketException::NOT_OPEN,
                               "error creating async udp socket", errno);
  }

  auto g = folly::makeGuard([&] { ::close(socket); });

  // put the socket in non-blocking mode
  int ret = fcntl(socket, F_SETFL, O_NONBLOCK);
  if (ret != 0) {
    throw AsyncSocketException(AsyncSocketException::NOT_OPEN,
                               "failed to put socket in non-blocking mode",
                               errno);
  }

  if (reuseAddr_) {
    // put the socket in reuse mode
    int value = 1;
    if (setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(value)) !=
        0) {
      throw AsyncSocketException(AsyncSocketException::NOT_OPEN,
                                 "failed to put socket in reuse mode", errno);
    }
  }

  if (reusePort_) {
    // put the socket in port reuse mode
    int value = 1;
    if (setsockopt(socket, SOL_SOCKET, SO_REUSEPORT, &value, sizeof(value)) !=
        0) {
      ::close(socket);
      throw AsyncSocketException(AsyncSocketException::NOT_OPEN,
                                 "failed to put socket in reuse_port mode",
                                 errno);
    }
  }

  // If we're using IPv6, make sure we don't accept V4-mapped connections
  if (address.getFamily() == AF_INET6) {
    int flag = 1;
    if (::setsockopt(socket, IPPROTO_IPV6, IPV6_V6ONLY, &flag, sizeof(flag))) {
      throw AsyncSocketException(AsyncSocketException::NOT_OPEN,
                                 "Failed to set IPV6_V6ONLY", errno);
    }
  }

  // bind to the address
  sockaddr_storage addrStorage;
  address.getAddress(&addrStorage);
  sockaddr *saddr = reinterpret_cast<sockaddr *>(&addrStorage);
  if (::bind(socket, saddr, address.getActualSize()) != 0) {
    throw AsyncSocketException(
        AsyncSocketException::NOT_OPEN,
        "failed to bind the async udp socket for:" + address.describe(), errno);
  }

  // success
  g.dismiss();
  fd_ = socket;
  ownership_ = FDOwnership::OWNS;

  // attach to EventHandler
  EventHandler::changeHandlerFD(fd_);

  if (address.getPort() != 0) {
    localAddress_ = address;
  } else {
    localAddress_.setFromLocalAddress(fd_);
  }
}
コード例 #19
0
void CalendarSelectionPage::calendarItemSelected(const QModelIndex &which)
{
	dismiss();
	Q_EMIT(selected(m_model->calendarItem(which)));
}