DesignAltContentView::DesignAltContentView(bool t_isBaseline)
  : QWidget()
{
  QVBoxLayout * mainVLayout = new QVBoxLayout();
  mainVLayout->setContentsMargins(25,0,5,5);
  mainVLayout->setSpacing(5);
  setLayout(mainVLayout);

  perturbationListView = new OSListView();
  perturbationListView->setContentsMargins(0,0,0,0);

  mainVLayout->addWidget(perturbationListView);

  QLabel * descriptionTitleLabel = new QLabel("Description");
  descriptionTitleLabel->setObjectName("H2");
  mainVLayout->addWidget(descriptionTitleLabel);

  descriptionTextEdit = new QTextEdit();
  descriptionTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  descriptionTextEdit->setMaximumWidth(600);
  descriptionTextEdit->setFixedHeight(60);
  descriptionTextEdit->setStyleSheet("QTextEdit { background: #E0E0E0; }");
  mainVLayout->addWidget(descriptionTextEdit);

  if (t_isBaseline)
  {
    perturbationListView->setStyleSheet("color:#D5D5D5");
    descriptionTitleLabel->setVisible(false);
    descriptionTextEdit->setVisible(false);
  }


  bool bingo = connect(descriptionTextEdit,SIGNAL(textChanged()),this,SLOT(onDescriptionTextChanged()));

  OS_ASSERT(bingo);
}
Beispiel #2
0
/** Show the validators for all the properties */
void AlgorithmDialog::showValidators() {
  // Do nothing for non-generic algorithm dialogs
  QStringList::const_iterator pend = m_algProperties.end();
  for (QStringList::const_iterator pitr = m_algProperties.begin(); pitr != pend;
       ++pitr) {
    const QString propName = *pitr;

    // Find the widget for this property.
    if (m_tied_properties.contains(propName)) {
      // Show/hide the validator label (that red star)
      QString error = "";
      if (m_errors.contains(propName))
        error = m_errors[propName];

      QLabel *validator = getValidatorMarker(propName);
      // If there's no validator then assume it's handling its own validation
      // notification
      if (validator && validator->parent()) {
        validator->setToolTip(error);
        validator->setVisible(error.length() != 0);
      }
    } // widget is tied
  }   // for each property
}
/// continue the creation of the widgets once the pieces XML was loaded.
/// this is where all the work of creating the family tabs and their content is performed.
void PicsSelectWidget::continueCreate()
{
	const PicBucket& bucket = PicBucket::instance();

	m_tabs = new QTabWidget(this);
	connect(m_tabs, SIGNAL(currentChanged(int)), this, SLOT(updateSetsSpinBox(int)));
	m_layout->addWidget(m_tabs);
	m_groups.resize(bucket.grps.size());

	for (int f = 0; f < bucket.families.size(); ++f)
	{
		const PicFamily &fam = bucket.families[f];

		SizedWidget *tab = new SizedWidget(QSize(6 * BOT_TOTAL_X + BOT_OFFS_X + FRAME_OFFS_SPACE_RIGHT - 5, NUM_DEFS * BOT_TOTAL_Y + FRAME_OFFS_Y), nullptr);
		//QWidget *tab = new QWidget();
		//tab->resize(QSize(6 * BOT_TOTAL_X + BOT_OFFS_X + FRAME_OFFS_SPACE_RIGHT, NUM_DEFS * BOT_TOTAL_Y + FRAME_OFFS_Y));

		QScrollArea *scroll = new QScrollArea();
		scroll->setWidget(tab);
		// the following is the voodoo needed to make the scroll area the same color as the tab
		// if this wasn't here, the scroll area would have gotten the default window color
		// this is significant in Windows XP with new apperance style where the tab color is 
		// different from the default window color
		scroll->viewport()->setAutoFillBackground(false);
		tab->setAutoFillBackground(false);
		// scroll area has a frame by default. get rid of it.
		scroll->setFrameShape(QFrame::NoFrame);

		m_tabs->addTab(scroll, fam.name.c_str());


		for (int g = fam.startIndex; g < fam.startIndex + fam.numGroups; ++g)
		{
			const PicGroupDef *grp = &(bucket.grps[g]);
			GroupCtrl &grpctrl = m_groups[g];
			int normg = (g - fam.startIndex); // normalized g with start of family

			QGroupBox *groupbox = new QGroupBox(grp->name.c_str(), tab);
			groupbox->move(BOT_OFFS_X-FRAME_OFFS_SPACE_LEFT, FRAME_OFFS_Y + normg*BOT_TOTAL_Y - 30);
			groupbox->resize(FRAME_OFFS_SPACE_RIGHT + grp->numPics() * BOT_TOTAL_X, BOT_Y + 55);

			grpctrl.num = new DataSpinBox(g, tab);
			grpctrl.num->move(grp->numPics() * BOT_TOTAL_X + BOT_OFFS_X + FRAME_OFFS_SPACE_RIGHT - 65, BOT_OFFS_Y + normg*BOT_TOTAL_Y + 40);
			grpctrl.num->resize(45, 23);
			grpctrl.num->setButtonSymbols(QAbstractSpinBox::PlusMinus);
			grpctrl.num->setRange(-1, MAX_IDENTICAL_PIECES); 
			grpctrl.num->setSpecialValueText("X");

			connect(grpctrl.num, SIGNAL(dvalueChanged(int, int)), this, SLOT(changedGrpBox(int, int)));


			for (int p = 0; p < bucket.grps[g].numPics(); ++p)
			{
				const PicDef* pic = &(grp->getPic(p));
				PicCtrl picctrl;
				int data = (g << 16) | p;

				DataPushButton *button = new DataPushButton(data, QIcon(pic->pixmap), QString(), tab);
				picctrl.bot = button;
				button->setCheckable(true);
				button->move(BOT_OFFS_X + p*BOT_TOTAL_X, BOT_OFFS_Y + normg * BOT_TOTAL_Y); // g normalized to start of family
				button->resize(BOT_X, BOT_Y);
				button->setIconSize(pic->pixmap.size()); // +1 because it's the texture + line, from Pieces.h
				connect(button, SIGNAL(pclicked(int, bool)), this, SLOT(pressedPicButton(int, bool)));

				DataSpinBox *spinbox = new DataSpinBox(data, tab);
				picctrl.num = spinbox;
				spinbox->setRange(0, MAX_IDENTICAL_PIECES);
				spinbox->move(BOT_OFFS_X + p*BOT_TOTAL_X + (BOT_X/5*2 + 2), BOT_OFFS_Y + normg*BOT_TOTAL_Y + BOT_Y + 5);
				spinbox->resize(BOT_X/5*3 - 4, EDIT_THICK + 1);
				spinbox->setButtonSymbols(QAbstractSpinBox::PlusMinus);
				
				connect(spinbox, SIGNAL(dvalueChanged(int, int)), this, SLOT(changedNumBox(int, int)));

				QLabel *solnum = new QLabel("0", tab);
				picctrl.snum = solnum;
				solnum->move(BOT_OFFS_X + p*BOT_TOTAL_X + 2, BOT_OFFS_Y + normg*BOT_TOTAL_Y + BOT_Y + 6);
				solnum->resize(BOT_X/5*2 - 4, EDIT_THICK); 
				solnum->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
				solnum->setFrameShadow(QFrame::Sunken);
				solnum->setFrameShape(QFrame::Panel);
				
				solnum->setPalette(*m_slvPalette);
				solnum->setVisible(false);


				grpctrl.pics.push_back(picctrl);
			}

		}

	}

	setBuildTilesCount(m_doc->getBuild().tilesCount());
	// prevent the build Help sidebar to get notifications. it might not be there yet.
	// eventually the sidebar will take care of itself.
	blockSignals(true); 
	changeToResetValues();
	blockSignals(false);

	m_bFinishedCreate = true;
}
LibraryTypePage::LibraryTypePage(AddLibraryWizard *parent)
    : QWizardPage(parent)
{
    setTitle(tr("Library Type"));
    setSubTitle(tr("Choose the type of the library to link to"));

    QVBoxLayout *layout = new QVBoxLayout(this);

    m_internalRadio = new QRadioButton(tr("Internal library"), this);
    layout->addWidget(m_internalRadio);

    QLabel *internalLabel = new QLabel(tr("Links to a library "
                                    "that is located in your build "
                                    "tree.\nAdds the library and "
                                    "include paths to the .pro file."));

    internalLabel->setWordWrap(true);
    internalLabel->setAttribute(Qt::WA_MacSmallSize, true);
    layout->addWidget(internalLabel);

    m_externalRadio = new QRadioButton(tr("External library"), this);
    layout->addWidget(m_externalRadio);

    QLabel *externalLabel = new QLabel(tr("Links to a library "
                                    "that is not located in your "
                                    "build tree.\nAdds the library "
                                    "and include paths to the .pro file."));

    externalLabel->setWordWrap(true);
    externalLabel->setAttribute(Qt::WA_MacSmallSize, true);
    layout->addWidget(externalLabel);

    m_systemRadio = new QRadioButton(tr("System library"), this);
    layout->addWidget(m_systemRadio);

    QLabel *systemLabel = new QLabel(tr("Links to a system library."
                                    "\nNeither the path to the "
                                    "library nor the path to its "
                                    "includes is added to the .pro file."));

    systemLabel->setWordWrap(true);
    systemLabel->setAttribute(Qt::WA_MacSmallSize, true);
    layout->addWidget(systemLabel);

    m_packageRadio = new QRadioButton(tr("System package"), this);
    layout->addWidget(m_packageRadio);

    QLabel *packageLabel = new QLabel(tr("Links to a system library using pkg-config."));

    packageLabel->setWordWrap(true);
    packageLabel->setAttribute(Qt::WA_MacSmallSize, true);
    layout->addWidget(packageLabel);

    if (Utils::HostOsInfo::isWindowsHost()) {
        m_packageRadio->setVisible(false);
        packageLabel->setVisible(false);
    }

    // select the default
    m_internalRadio->setChecked(true);

    setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Type"));
}
Beispiel #5
0
TilesetDock::TilesetDock(QWidget *parent, MapEditorController *mapEditorController)
        : QDockWidget(parent)
{
    widget = new QWidget(this);
    this->mapEditorController = mapEditorController;

    setMinimumSize(285, 300);

    QSpacerItem *spacer = new QSpacerItem(0, 100);

    /* inicializando o layout */
    layout = new QVBoxLayout(widget);
    layout->setMargin(5);
    layout->setSpacing(0);

    tabWidget = new QTabWidget(widget);
    tabWidget->setTabPosition(QTabWidget::South);

    layerSlider = new QSlider(Qt::Horizontal, this);
    layerSlider->setMinimum(0);
    layerSlider->setMaximum(4);







    /* adicionando o tilesetview e o tilesetscene */

    QObject::connect(layerSlider, SIGNAL(valueChanged(int)), this, SLOT(layerSliderMudada(int)));

    QLabel *layerLabel = new QLabel(this);
    layerLabel->setText(QString("Camada: "));

    layout->addWidget(tabWidget);
    layout->addWidget(layerLabel);
    layout->addWidget(layerSlider);

    tabWidget->setEnabled(false);

    std::stringstream ss;
    ss << QString::fromUtf8("Número da camada: ").toStdString() << layerSlider->value() + 1;

    layerSlider->setToolTip(QString(ss.str().c_str()));
    layerSlider->setEnabled(false);

    layerNumberLabel = new QLabel(QString(ss.str().c_str()));

    layout->addWidget(layerNumberLabel);

    layerButtons = new QWidget();
    layerButtons->setLayout(new QHBoxLayout(this));

    layerButton1 = new QPushButton("1");
    layerButton1->setMaximumWidth(30);
    layerButton1->setCheckable(true);

    layerButton2 = new QPushButton("2");
    layerButton2->setMaximumWidth(30);
    layerButton2->setCheckable(true);

    layerButton3 = new QPushButton("3");
    layerButton3->setMaximumWidth(30);
    layerButton3->setCheckable(true);

    layerButton4 = new QPushButton("4");
    layerButton4->setMaximumWidth(30);
    layerButton4->setCheckable(true);

    layerButton5 = new QPushButton("5");
    layerButton5->setMaximumWidth(30);
    layerButton5->setCheckable(true);

    QObject::connect(layerButton1, SIGNAL(toggled(bool)), this, SLOT(layerButton1_toggled(bool)));
    QObject::connect(layerButton2, SIGNAL(toggled(bool)), this, SLOT(layerButton2_toggled(bool)));
    QObject::connect(layerButton3, SIGNAL(toggled(bool)), this, SLOT(layerButton3_toggled(bool)));
    QObject::connect(layerButton4, SIGNAL(toggled(bool)), this, SLOT(layerButton4_toggled(bool)));
    QObject::connect(layerButton5, SIGNAL(toggled(bool)), this, SLOT(layerButton5_toggled(bool)));

    layerButtons->layout()->addWidget(new QLabel(QString(tr("Camada:"))));
    layerButtons->layout()->addWidget(layerButton1);
    layerButtons->layout()->addWidget(layerButton2);
    layerButtons->layout()->addWidget(layerButton3);
    layerButtons->layout()->addWidget(layerButton4);
    layerButtons->layout()->addWidget(layerButton5);


    layout->addWidget(layerButtons);

    layerButtons->setEnabled(false);



    setWidget(widget);
    setWindowTitle(tr("Tileset"));

    tilesetScene = NULL;



    buttonsChangable = true;

    checkLayerButton(0);

    layerSlider->setVisible(false);
    layerLabel->setVisible(false);
    layerNumberLabel->setVisible(false);



}
Beispiel #6
0
//! [0]
TestWidget::TestWidget(QWidget *parent):
    QWidget(parent)
{
    const QString romeo = tr(
        "But soft, what light through yonder window breaks? / "
        "It is the east, and Juliet is the sun. / "
        "Arise, fair sun, and kill the envious moon, / "
        "Who is already sick and pale with grief / "
        "That thou, her maid, art far more fair than she."
    );

    const QString macbeth = tr(
        "To-morrow, and to-morrow, and to-morrow, / "
        "Creeps in this petty pace from day to day, / "
        "To the last syllable of recorded time; / "
        "And all our yesterdays have lighted fools / "
        "The way to dusty death. Out, out, brief candle! / "
        "Life's but a walking shadow, a poor player, / "
        "That struts and frets his hour upon the stage, / "
        "And then is heard no more. It is a tale / "
        "Told by an idiot, full of sound and fury, / "
        "Signifying nothing."
    );

    const QString harry = tr("Feeling lucky, punk?");

    textSamples << romeo << macbeth << harry;
    //! [0]

    //! [1]
    sampleIndex = 0;
    elidedText = new ElidedLabel(textSamples[sampleIndex], this);
    elidedText->setFrameStyle(QFrame::Box);
    //! [1]

    //! [2]
    QPushButton *switchButton = new QPushButton(tr("Switch text"));
    connect(switchButton, SIGNAL(clicked(bool)), this, SLOT(switchText()));

    QPushButton *exitButton = new QPushButton(tr("Exit"));
    connect(exitButton, SIGNAL(clicked(bool)), this, SLOT(close()));

    QLabel *label = new QLabel(tr("Elided"));
    label->setVisible(elidedText->isElided());
    connect(elidedText, SIGNAL(elisionChanged(bool)), label, SLOT(setVisible(bool)));
    //! [2]

    //! [3]
    widthSlider = new QSlider(Qt::Horizontal);
    widthSlider->setMinimum(0);
    connect(widthSlider, SIGNAL(valueChanged(int)), this, SLOT(onWidthChanged(int)));

    heightSlider = new QSlider(Qt::Vertical);
    heightSlider->setInvertedAppearance(true);
    heightSlider->setMinimum(0);
    connect(heightSlider, SIGNAL(valueChanged(int)), this, SLOT(onHeightChanged(int)));
    //! [3]

    //! [4]
    QGridLayout *layout = new QGridLayout();
    layout->addWidget(label, 0, 1, Qt::AlignCenter);
    layout->addWidget(switchButton, 0, 2);
    layout->addWidget(exitButton, 0, 3);
    layout->addWidget(widthSlider, 1, 1, 1, 3);
    layout->addWidget(heightSlider, 2, 0);
    layout->addWidget(elidedText, 2, 1, 1, 3, Qt::AlignTop | Qt::AlignLeft);

    setLayout(layout);
    //! [4]

    //! [5]
}
Beispiel #7
0
pFileDialog::pFileDialog( QWidget* parent, const QString& caption, const QString& directory, const QString& filter, bool textCodecEnabled, bool openReadOnlyEnabled )
	: QFileDialog( parent, caption, directory, filter )
{
	setFileMode( QFileDialog::AnyFile );
	setOption( QFileDialog::DontUseNativeDialog );
	
	// get grid layout
	glDialog = qobject_cast<QGridLayout*>( layout() );
	
	// assert on gridlayout
	Q_ASSERT( glDialog );
	
	// relook the dialog to be more friendly
	QLabel* lLookIn = findChild<QLabel*>( "lookInLabel" );
	QComboBox* cbLookIn = findChild<QComboBox*>( "lookInCombo" );
	QToolButton* tbNewFolder = findChild<QToolButton*>( "newFolderButton" );
	QAbstractItemView* sidebar = findChild<QAbstractItemView*>( "sidebar" );
	QFrame* fFrame = findChild<QFrame*>( "frame" );
	QBoxLayout* hLayout = 0;
	
	// search layout containing tbNewFolder
	foreach ( QLayout* layout, findChildren<QLayout*>() ) {
		if ( layout->indexOf( tbNewFolder ) != -1 ) {
			hLayout = qobject_cast<QBoxLayout*>( layout );
			break;
		}
	}
	
	if ( lLookIn ) {
		lLookIn->setVisible( false );
	}
	
	if ( hLayout ) {
		hLayout->setSpacing( 3 );
		hLayout->insertStretch( hLayout->indexOf( tbNewFolder ) );
	}
	
	if ( cbLookIn && fFrame ) {
		QBoxLayout* vLayout = qobject_cast<QBoxLayout*>( fFrame->layout() );
		
		if ( vLayout ) {
			vLayout->setSpacing( 3 );
			vLayout->insertWidget( 0, cbLookIn );
			
			if ( hLayout ) {
				glDialog->removeItem( hLayout );
				hLayout->setParent( 0 );
				vLayout->insertLayout( 0, hLayout );
			}
		}
	}
	
	if ( sidebar ) {
		QWidget* viewport = sidebar->viewport();
		QPalette pal = viewport->palette();
		pal.setColor( viewport->backgroundRole(), QColor( Qt::transparent ) );
		viewport->setPalette( pal );
		sidebar->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
		sidebar->setIconSize( QSize( 16, 16 ) );
	}
	
	// text codec
	mTextCodecEnabled = true;
	
	lCodec = new QLabel( tr( "Codec:" ), this );
	cbCodec = new QComboBox( this );
	cbCodec->addItems( pCoreUtils::textCodecs() );
	setTextCodec( QTextCodec::codecForLocale()->name() );
	
	glDialog->addWidget( lCodec, 4, 0 );
	glDialog->addWidget( cbCodec, 4, 1 );
	
	// read only
	mOpenReadOnlyEnabled = true;
	
	cbOpenReadOnly = new QCheckBox( tr( "Open in read only." ), this );
	
	glDialog->addWidget( cbOpenReadOnly, 5, 1 );
	
	// configuration
	setTextCodecEnabled( textCodecEnabled );
	setOpenReadOnlyEnabled( openReadOnlyEnabled );
}
Beispiel #8
0
void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
{
    if (!model)
        return;

    // nPayAmount
    CAmount nPayAmount = 0;
    bool fDust = false;
    CMutableTransaction txDummy;
    for (const CAmount &amount : CoinControlDialog::payAmounts)
    {
        nPayAmount += amount;

        if (amount > 0)
        {
            CTxOut txout(amount, (CScript)std::vector<unsigned char>(24, 0));
            txDummy.vout.push_back(txout);
            fDust |= IsDust(txout, ::dustRelayFee);
        }
    }

    CAmount nAmount             = 0;
    CAmount nPayFee             = 0;
    CAmount nAfterFee           = 0;
    CAmount nChange             = 0;
    unsigned int nBytes         = 0;
    unsigned int nBytesInputs   = 0;
    unsigned int nQuantity      = 0;
    bool fWitness               = false;

    std::vector<COutPoint> vCoinControl;
    std::vector<COutput>   vOutputs;
    coinControl->ListSelected(vCoinControl);
    model->getOutputs(vCoinControl, vOutputs);

    for (const COutput& out : vOutputs) {
        // unselect already spent, very unlikely scenario, this could happen
        // when selected are spent elsewhere, like rpc or another computer
        uint256 txhash = out.tx->GetHash();
        COutPoint outpt(txhash, out.i);
        if (model->isSpent(outpt))
        {
            coinControl->UnSelect(outpt);
            continue;
        }

        // Quantity
        nQuantity++;

        // Amount
        nAmount += out.tx->tx->vout[out.i].nValue;

        // Bytes
        CTxDestination address;
        int witnessversion = 0;
        std::vector<unsigned char> witnessprogram;
        if (out.tx->tx->vout[out.i].scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram))
        {
            nBytesInputs += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4);
            fWitness = true;
        }
        else if(ExtractDestination(out.tx->tx->vout[out.i].scriptPubKey, address))
        {
            CPubKey pubkey;
            CKeyID *keyid = boost::get<CKeyID>(&address);
            if (keyid && model->getPubKey(*keyid, pubkey))
            {
                nBytesInputs += (pubkey.IsCompressed() ? 148 : 180);
            }
            else
                nBytesInputs += 148; // in all error cases, simply assume 148 here
        }
        else nBytesInputs += 148;
    }

    // calculation
    if (nQuantity > 0)
    {
        // Bytes
        nBytes = nBytesInputs + ((CoinControlDialog::payAmounts.size() > 0 ? CoinControlDialog::payAmounts.size() + 1 : 2) * 34) + 10; // always assume +1 output for change here
        if (fWitness)
        {
            // there is some fudging in these numbers related to the actual virtual transaction size calculation that will keep this estimate from being exact.
            // usually, the result will be an overestimate within a couple of satoshis so that the confirmation dialog ends up displaying a slightly smaller fee.
            // also, the witness stack size value is a variable sized integer. usually, the number of stack items will be well under the single byte var int limit.
            nBytes += 2; // account for the serialized marker and flag bytes
            nBytes += nQuantity; // account for the witness byte that holds the number of stack items for each input.
        }

        // in the subtract fee from amount case, we can tell if zero change already and subtract the bytes, so that fee calculation afterwards is accurate
        if (CoinControlDialog::fSubtractFeeFromAmount)
            if (nAmount - nPayAmount == 0)
                nBytes -= 34;

        // Fee
        nPayFee = CWallet::GetMinimumFee(nBytes, *coinControl, ::mempool, ::feeEstimator, nullptr /* FeeCalculation */);

        if (nPayAmount > 0)
        {
            nChange = nAmount - nPayAmount;
            if (!CoinControlDialog::fSubtractFeeFromAmount)
                nChange -= nPayFee;

            // Never create dust outputs; if we would, just add the dust to the fee.
            if (nChange > 0 && nChange < MIN_CHANGE)
            {
                CTxOut txout(nChange, (CScript)std::vector<unsigned char>(24, 0));
                if (IsDust(txout, ::dustRelayFee))
                {
                    nPayFee += nChange;
                    nChange = 0;
                    if (CoinControlDialog::fSubtractFeeFromAmount)
                        nBytes -= 34; // we didn't detect lack of change above
                }
            }

            if (nChange == 0 && !CoinControlDialog::fSubtractFeeFromAmount)
                nBytes -= 34;
        }

        // after fee
        nAfterFee = std::max<CAmount>(nAmount - nPayFee, 0);
    }

    // actually update labels
    int nDisplayUnit = WiFicoinUnits::WFC;
    if (model && model->getOptionsModel())
        nDisplayUnit = model->getOptionsModel()->getDisplayUnit();

    QLabel *l1 = dialog->findChild<QLabel *>("labelCoinControlQuantity");
    QLabel *l2 = dialog->findChild<QLabel *>("labelCoinControlAmount");
    QLabel *l3 = dialog->findChild<QLabel *>("labelCoinControlFee");
    QLabel *l4 = dialog->findChild<QLabel *>("labelCoinControlAfterFee");
    QLabel *l5 = dialog->findChild<QLabel *>("labelCoinControlBytes");
    QLabel *l7 = dialog->findChild<QLabel *>("labelCoinControlLowOutput");
    QLabel *l8 = dialog->findChild<QLabel *>("labelCoinControlChange");

    // enable/disable "dust" and "change"
    dialog->findChild<QLabel *>("labelCoinControlLowOutputText")->setEnabled(nPayAmount > 0);
    dialog->findChild<QLabel *>("labelCoinControlLowOutput")    ->setEnabled(nPayAmount > 0);
    dialog->findChild<QLabel *>("labelCoinControlChangeText")   ->setEnabled(nPayAmount > 0);
    dialog->findChild<QLabel *>("labelCoinControlChange")       ->setEnabled(nPayAmount > 0);

    // stats
    l1->setText(QString::number(nQuantity));                                 // Quantity
    l2->setText(WiFicoinUnits::formatWithUnit(nDisplayUnit, nAmount));        // Amount
    l3->setText(WiFicoinUnits::formatWithUnit(nDisplayUnit, nPayFee));        // Fee
    l4->setText(WiFicoinUnits::formatWithUnit(nDisplayUnit, nAfterFee));      // After Fee
    l5->setText(((nBytes > 0) ? ASYMP_UTF8 : "") + QString::number(nBytes));        // Bytes
    l7->setText(fDust ? tr("yes") : tr("no"));                               // Dust
    l8->setText(WiFicoinUnits::formatWithUnit(nDisplayUnit, nChange));        // Change
    if (nPayFee > 0)
    {
        l3->setText(ASYMP_UTF8 + l3->text());
        l4->setText(ASYMP_UTF8 + l4->text());
        if (nChange > 0 && !CoinControlDialog::fSubtractFeeFromAmount)
            l8->setText(ASYMP_UTF8 + l8->text());
    }

    // turn label red when dust
    l7->setStyleSheet((fDust) ? "color:red;" : "");

    // tool tips
    QString toolTipDust = tr("This label turns red if any recipient receives an amount smaller than the current dust threshold.");

    // how many satoshis the estimated fee can vary per byte we guess wrong
    double dFeeVary = (double)nPayFee / nBytes;

    QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);

    l3->setToolTip(toolTip4);
    l4->setToolTip(toolTip4);
    l7->setToolTip(toolTipDust);
    l8->setToolTip(toolTip4);
    dialog->findChild<QLabel *>("labelCoinControlFeeText")      ->setToolTip(l3->toolTip());
    dialog->findChild<QLabel *>("labelCoinControlAfterFeeText") ->setToolTip(l4->toolTip());
    dialog->findChild<QLabel *>("labelCoinControlBytesText")    ->setToolTip(l5->toolTip());
    dialog->findChild<QLabel *>("labelCoinControlLowOutputText")->setToolTip(l7->toolTip());
    dialog->findChild<QLabel *>("labelCoinControlChangeText")   ->setToolTip(l8->toolTip());

    // Insufficient funds
    QLabel *label = dialog->findChild<QLabel *>("labelCoinControlInsuffFunds");
    if (label)
        label->setVisible(nChange < 0);
}
Beispiel #9
0
void GamePadDialog::pollJoystick()
{
#if QT_HAS_SDL
	if(!m_joystick)
		return;
	SDL_JoystickUpdate();

	// Update buttons state
	for(int i=0;i<14;i++)
	{
		float val = 0;
		if(GamepadPadMapping[i].mapping_type == 0)
			val = SDL_JoystickGetButton(m_joystick,GamepadPadMapping[i].mapping_in);
		else if(GamepadPadMapping[i].mapping_type == 1)
		{
			val = SDL_JoystickGetAxis(m_joystick,GamepadPadMapping[i].mapping_in);
			if(val*GamepadPadMapping[i].mapping_sign > 16384) val = 1;
			else val = 0;
		}
		else if(GamepadPadMapping[i].mapping_type == 2)
			val = SDL_JoystickGetHat(m_joystick,GamepadPadMapping[i].mapping_in);
		QLabel* labelPreview = findChild<QLabel*>(GamepadPadMapping[i].ViewLabelName);
		if(labelPreview)
		{
			labelPreview->setVisible(val != 0);
		}
		if(val)
		{
			m_inputState->pad_buttons |= (1<<i);
		}
		else
		{
			m_inputState->pad_buttons &= ~(1<<i);
		}
	}
	// Update analog stick
	m_inputState->pad_lstick_x = 0;
	m_inputState->pad_lstick_y = 0;
	for(int i = 14; i < 18; i++)
	{
		float val = 0;
		if(GamepadPadMapping[i].mapping_type == 0)
			val = SDL_JoystickGetButton(m_joystick,GamepadPadMapping[i].mapping_in);
		else if(GamepadPadMapping[i].mapping_type == 1)
		{
			val = SDL_JoystickGetAxis(m_joystick,GamepadPadMapping[i].mapping_in);
			if((val <= 0 && GamepadPadMapping[i].mapping_sign < 0) || (val >= 0 && GamepadPadMapping[i].mapping_sign > 0))
				val = abs(val) * 1.0f / 32767;
			else
				val = 0;
		}
		else if(GamepadPadMapping[i].mapping_type == 2)
			val = SDL_JoystickGetHat(m_joystick,GamepadPadMapping[i].mapping_in);
		QLabel* labelPreview = findChild<QLabel*>(GamepadPadMapping[i].ViewLabelName);
		if(labelPreview)
		{
			labelPreview->setVisible(val != 0);
		}
		switch(i)
		{
		case 14:
			m_inputState->pad_lstick_x -= val;
			break;
		case 15:
			m_inputState->pad_lstick_x += val;
			break;
		case 16:
			m_inputState->pad_lstick_y -= val;
			break;
		default:
			m_inputState->pad_lstick_y += val;
			break;
		}
	}

	if(isVisible())
	{
		for(int i = 0; i < ui->padValues->topLevelItemCount(); i++)
		{
			QTreeWidgetItem* item = ui->padValues->topLevelItem(i);
			for(int j = 0; j < item->childCount(); j++)
			{
				QTreeWidgetItem* item2 = item->child(j);
				if(item2->data(0,Qt::UserRole).toInt() == 0)
				{
					item2->setText(1,QVariant(SDL_JoystickGetButton(m_joystick,item2->data(0,Qt::UserRole+1).toInt())).toString());
				}
				else if(item2->data(0,Qt::UserRole).toInt() == 1)
				{
					int val = SDL_JoystickGetAxis(m_joystick,item2->data(0,Qt::UserRole+1).toInt());
					if((val <= 0 && item2->data(0,Qt::UserRole+2).toInt() < 0) || (val >= 0 && item2->data(0,Qt::UserRole+2).toInt() > 0))
						item2->setText(1,QVariant(val).toString());
				}
				else if(item2->data(0,Qt::UserRole).toInt() == 2)
				{
					item2->setText(1,QVariant(SDL_JoystickGetHat(m_joystick,item2->data(0,Qt::UserRole+1).toInt())).toString());
				}
			}
		}
	}
#endif
}
Beispiel #10
0
int DriverColorsDialog::exec()
{
    SeasonData &sd = SeasonData::getInstance();
    colors = ColorsManager::getInstance().getDriverColors();
    int i = 0;
    for (; i < sd.getTeams().size(); ++i)
    {
        QList<LTDriver> drivers = sd.getMainDrivers(sd.getTeams()[i]);
        if (drivers.size() != 2)
            continue;

        if ((ui->verticalLayout->count()-2) <= i)
        {
            QHBoxLayout *layout = new QHBoxLayout();
            QLabel *label = new QLabel(this);                        

            label->setText(QString("%1 %2").arg(drivers[0].no).arg(drivers[0].name));
            label->updateGeometry();
            QToolButton *button = new QToolButton(this);
            button->setMaximumHeight(16);
            button->setMaximumWidth(16);
            setButtonColor(button, /*sd.getCarColor(sd.getTeams()[i].driver1No)*/colors[i*2]);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onColorButtonClicked()));

            button = new QToolButton(this);
            button->setText("Reset");
            button->setMaximumHeight(20);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onResetButtonClicked()));

            layout->addWidget(label);
            //colors.append(sd.getCarColor(sd.getTeams()[i].driver1No));

//            layout = new QHBoxLayout(this);
            label = new QLabel(this);
            label->setText(QString("%1 %2").arg(drivers[1].no).arg(drivers[1].name));
            label->updateGeometry();
            button = new QToolButton(this);
            button->setMaximumHeight(16);
            button->setMaximumWidth(16);
            setButtonColor(button, /*sd.getCarColor(sd.getTeams()[i].driver2No)*/colors[i*2+1]);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onColorButtonClicked()));

            button = new QToolButton(this);
            button->setText("Reset");
            button->setMaximumHeight(20);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onResetButtonClicked()));

            layout->addWidget(label);
            //colors.append(sd.getCarColor(sd.getTeams()[i].driver2No));

            ui->verticalLayout->insertLayout(ui->verticalLayout->count() - 2, layout);
        }
        else
        {
            QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
            QLabel *label = static_cast<QLabel*>(layout->itemAt(2)->widget());
            QToolButton *button = static_cast<QToolButton*>(layout->itemAt(0)->widget());

            label->setText(QString("%1 %2").arg(drivers[0].no).arg(drivers[0].name));
            setButtonColor(button, ColorsManager::getInstance().getCarColor(drivers[0].no));

            label->setVisible(true);
            button->setVisible(true);

            button = static_cast<QToolButton*>(layout->itemAt(1)->widget());
            button->setVisible(true);

            label = static_cast<QLabel*>(layout->itemAt(5)->widget());
            button = static_cast<QToolButton*>(layout->itemAt(3)->widget());

            label->setText(QString("%1 %2").arg(drivers[1].no).arg(drivers[1].name));
            setButtonColor(button, ColorsManager::getInstance().getCarColor(drivers[1].no));

            label->setVisible(true);
            button->setVisible(true);

            button = static_cast<QToolButton*>(layout->itemAt(4)->widget());
            button->setVisible(true);
        }
    }
    for (; i < ui->verticalLayout->count()-2; ++i)
    {
        QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
        QLabel *label = static_cast<QLabel*>(layout->itemAt(2)->widget());
        QToolButton *button = static_cast<QToolButton*>(layout->itemAt(0)->widget());

        label->setVisible(false);
        button->setVisible(false);

        button = static_cast<QToolButton*>(layout->itemAt(1)->widget());
        button->setVisible(false);

        label = static_cast<QLabel*>(layout->itemAt(5)->widget());
        button = static_cast<QToolButton*>(layout->itemAt(3)->widget());

        label->setVisible(false);
        button->setVisible(false);

        button = static_cast<QToolButton*>(layout->itemAt(4)->widget());
        button->setVisible(false);
    }

    return QDialog::exec();
}
Beispiel #11
0
void GraphWidget::createNodesDistribution(CategoryResult::Ptr packet) {

    float angle = 0.f, arch = 0.f, x = 0.f, y = 0.f;
    int r = 0, g = 0, b = 0, color_factor = 0;
    string genresListText = "";

    CategoryResult::GenreList genres = packet->genres();

    int num_nodes = min((int)NUM_NODES_MAX, (int)CategoryResult::numberOfResults());
    long num_nodes_cat = (num_nodes * packet->percentage());
    if(num_nodes_cat > 0){

        for (CategoryResult::GenreList::iterator it(genres.begin()); it != genres.end(); ++it) {

            Genre & genre = **it;
            GenreNode& genreNode = genre.interface()->genreNode();
            genresListText.append(genre.name());
            genresListText.append("\n");

            // POSITION
            angle += genreNode.angle();
            arch += genreNode.arch();
            // COLOR
            r += genreNode.color().red();
            g += genreNode.color().green();
            b += genreNode.color().blue();
            ++color_factor;
        }

        angle /= genres.size();
        arch /= genres.size();
        if(color_factor > 0){
            r /= color_factor;
            g /= color_factor;
            b /= color_factor;
        }


        float radius = packet->yearBlock() * 45.f + 5.f;
        float angleNoise, radiusNoise;

        for (int i = 0; i < (int)(num_nodes * packet->percentage()); ++i) {

            angleNoise = (float)drand48() * 0.2;
            radiusNoise = (float)drand48() * 60;

            x = 340 + (radius + radiusNoise) * (float)cos(angle + angleNoise);
            y = 240 + (radius + radiusNoise) * (float)sin(angle + angleNoise);

            FilmNode & filmNode = *filmNodes[n];
            filmNode.setVisible(true);
            ++n;

            if (num_nodes < NUM_NODES_MAX) {

                filmNode.setMinDiameter(30);
                filmNode.setDiameter(30);
                filmNode.setMaxDiameter(50);
                filmNode.setGeometry(x, y, 30, 30);
            }
            else {

                filmNode.setMinDiameter(8);
                filmNode.setDiameter(8);
                filmNode.setMaxDiameter(25);
                filmNode.setGeometry(x, y, 10, 10);
            }
            filmNode.setColor(QColor(r, g, b, 125));
            filmNode.setCategoryIndex(BLOCK_INDEX);

            /*filmNode.show();
            QPropertyAnimation animation(&filmNode, "geometry");
            animation.setDuration(1000);
            animation.setStartValue(QRect(x, y, 0, 0));
            animation.setEndValue(QRect(x, y, 10, 10));

            animation.setEasingCurve(QEasingCurve::OutBounce);

            animation.start();*/

        }
        categories.push_back(packet);
        BLOCK_INDEX++;

        std::ostringstream oss;

        int yearBegin = 1888+30*packet->yearBlock();
        int yearEnd = min(yearBegin + 30, 2012);

        oss << "(" << yearBegin << "-" << yearEnd << ")\n" << packet->categoryCount() << " film(s)";
        genresListText.append(oss.str());

        QLabel *label = new QLabel(this);

        // LABEL STYLE
        QString css_color("color : rgb(");
        css_color.append(QString::number(r));
        css_color.append(",");
        css_color.append(QString::number(g));
        css_color.append(",");
        css_color.append(QString::number(b));
        css_color.append(");");

        QString css_border_color("border-color : rgb(");
        css_border_color.append(QString::number(r));
        css_border_color.append(",");
        css_border_color.append(QString::number(g));
        css_border_color.append(",");
        css_border_color.append(QString::number(b));
        css_border_color.append(");");

        QString css_bg_color("background-color : rgba(");
        css_bg_color.append(QString::number(r));
        css_bg_color.append(",");
        css_bg_color.append(QString::number(g));
        css_bg_color.append(",");
        css_bg_color.append(QString::number(b));
        css_bg_color.append(",100);");

        QString css("QLabel { border-radius: 8px; padding: 5px;border-width:1px;border-style:none;");
        css.append(css_color);
        css.append(css_bg_color);
        css.append(css_border_color);
        css.append("}");
        label->setStyleSheet(css);
        label->setFrameStyle(QFrame::Panel | QFrame::Sunken);
        label->setText(QString::fromUtf8(genresListText.c_str()));
        label->setAlignment(Qt::AlignBottom | Qt::AlignRight);
        label->setVisible(false);
        labels.push_back(label);

    }
}
Beispiel #12
0
void DVGui::MsgBoxInPopup(MsgType type, const QString &text)
{
	// this function must be called by the main thread only
	// (only the main thread should access directly the GUI)
	// (note: working thread can and should call MsgBox(type,text) instead; see tmsgcore.h)

	Q_ASSERT(QApplication::instance()->thread() == QThread::currentThread());

	// a working thread can trigger a call to this function (by the main thread) also when a popup is already open
	// therefore we need a messageQueue
	// note: no mutex are needed because only the main thread call this function
	static QList<QPair<MsgType, QString>> messageQueue;
	static bool popupIsOpen = false;

	messageQueue.append(qMakePair(type, text));
	if (popupIsOpen)
		return;
	popupIsOpen = true;

	Dialog dialog(0, true);

	dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint);
	dialog.setAlignment(Qt::AlignLeft);
	QLabel *mainTextLabel = new QLabel("", &dialog);
	mainTextLabel->setMinimumWidth(400);
	QLabel *iconLabel = new QLabel(&dialog);

	QHBoxLayout *mainLayout = new QHBoxLayout;
	mainLayout->addWidget(iconLabel);
	mainLayout->addStretch();
	mainLayout->addWidget(mainTextLabel);
	mainLayout->addStretch();
	dialog.addLayout(mainLayout);

	// ButtonGroup: is used only to retrieve the clicked button
	QButtonGroup *buttonGroup = new QButtonGroup(&dialog);
	QPushButton *button = new QPushButton(QPushButton::tr("OK"), &dialog);
	button->setDefault(true);
	dialog.addButtonBarWidget(button);
	buttonGroup->addButton(button, 1);
	QObject::connect(buttonGroup, SIGNAL(buttonPressed(int)), &dialog, SLOT(done(int)));

	while (!messageQueue.empty()) {
		MsgType type1 = messageQueue.first().first;
		QString text1 = messageQueue.first().second;
		messageQueue.pop_front();

		mainTextLabel->setText(text1);

		QString msgBoxTitle = getMsgBoxTitle(type1);
		dialog.setWindowTitle(msgBoxTitle);

		QPixmap iconPixmap = getMsgBoxPixmap(type1);
		if (!iconPixmap.isNull()) {
			iconLabel->setPixmap(iconPixmap);
			iconLabel->setVisible(true);
		} else {
			iconLabel->setVisible(false);
		}

		dialog.raise();
		dialog.exec();

	} // loop: open the next dialog in the queue
	popupIsOpen = false;
}
Beispiel #13
0
int main(int argc, char** argv)
{
	QApplication app(argc, argv);

	QWidget* widget = new QWidget;
	
	QVBoxLayout* layout = new QVBoxLayout(widget);

	QPushButton* button1 = new QPushButton("Set to 10%");
	QPushButton* button2 = new QPushButton("Set to 50%");
	QPushButton* button3 = new QPushButton("Set to 80%");

	QLabel* hideMeLabel = new QLabel("Right click me to close");

	QLabel* focusLabel = new QLabel("Slider is hovered");
	focusLabel->setVisible(false);
	QSlider* slider = new QSlider(Qt::Horizontal);

	// create a callback object which sets the slider's value
	// and use QtSignalForwarder to invoke it when the button is
	// clicked
	QtCallback button1Callback(slider, SLOT(setValue(int)));
	button1Callback.bind(10);
	QtSignalForwarder::connect(button1, SIGNAL(clicked(bool)), button1Callback);

	// setup another couple of buttons.
	// Here we use a more succinct syntax to create the callback
	QtSignalForwarder::connect(button2, SIGNAL(clicked(bool)),
	  QtCallback(slider, SLOT(setValue(int))).bind(50));

#ifdef ENABLE_QTCALLBACK_TR1_FUNCTION
	// if tr1/function is available, use that to create a callback
	QtSignalForwarder::connect(button3, SIGNAL(clicked(bool)),
	  std::tr1::function<void()>(std::tr1::bind(&QAbstractSlider::setValue, slider, 80)));
#else
	QtSignalForwarder::connect(button3, SIGNAL(clicked(bool)),
	  QtCallback(slider, SLOT(setValue(int))).bind(80));
#endif

	QtSignalForwarder::connect(slider, QEvent::Enter,
	  QtCallback(focusLabel, SLOT(setVisible(bool))).bind(true));

	QtSignalForwarder::connect(slider, QEvent::Leave,
	  QtCallback(focusLabel, SLOT(setVisible(bool))).bind(false));

	QtSignalForwarder::connect(hideMeLabel, QEvent::MouseButtonRelease,
	  QtCallback(widget, SLOT(close())), matchRightClick);

	layout->addWidget(button1);
	layout->addWidget(button2);
	layout->addWidget(button3);
	layout->addWidget(slider);
	layout->addWidget(focusLabel);
	
	layout->addStretch();
	
	layout->addWidget(hideMeLabel);

	widget->show();

	return app.exec();
}
Beispiel #14
0
ThresholdDialog::ThresholdDialog(const GrayscaleImage* image, bool converted)  : _image(image){
    this->setWindowTitle(tr("ThresholdOp"));
    this->setMinimumWidth(160);

    QGridLayout * layout = new QGridLayout();
    this->setLayout(layout);

    QVBoxLayout* Vboxlayout = new QVBoxLayout();
    if(converted) {
        Vboxlayout->addWidget(new QLabel(tr("<font color=red><i>Information : The input image has been converted to grayscale.</i></font>")));
    }
    QGroupBox* threshGroup = new QGroupBox(tr("Threshold"), this);
    QHBoxLayout* threshLayout = new QHBoxLayout(threshGroup);
    _doubleBox = new QCheckBox(tr("Double threshold (right clic to move the second threshold)"));
    threshLayout->addWidget(_doubleBox);
    Vboxlayout->addWidget(threshGroup);

    QHBoxLayout* box1layout = new QHBoxLayout();
    _spin1label = new QLabel(tr("Threshold : "));
    _spinbox1 = new QSpinBox();
    _spinbox1->setRange(0, 255);
    _spinbox1->setValue(127);
    QPushButton* otsuButton = new QPushButton(tr("Otsu"));
    box1layout->addWidget(_spin1label);
    box1layout->addWidget(_spinbox1);
    box1layout->addWidget(otsuButton);
    Vboxlayout->addLayout(box1layout);

    QHBoxLayout* box2layout = new QHBoxLayout();
    QLabel* spin2label = new QLabel(tr("Threshold #2 : "));
    spin2label->setVisible(false);
    _spinbox2 = new QSpinBox();
    _spinbox2->setRange(0, 255);
    _spinbox2->setValue(255);
    _spinbox2->setVisible(false);
    box2layout->addWidget(spin2label);
    box2layout->addWidget(_spinbox2);
    Vboxlayout->addLayout(box2layout);

    QHBoxLayout* radiolayout = new QHBoxLayout();
    QLabel* radioLabel = new QLabel(tr("Color between thresholds :"));
    QRadioButton* whiteButton = new QRadioButton(tr("White"));
    _blackButton = new QRadioButton(tr("Black"));
    radiolayout->addWidget(radioLabel);
    radiolayout->addWidget(whiteButton);
    radiolayout->addWidget(_blackButton);
    whiteButton->setChecked(true);
    Vboxlayout->addLayout(radiolayout);
    radioLabel->setVisible(false);
    whiteButton->setVisible(false);
    _blackButton->setVisible(false);

    Rectangle rect(0, 0, image->getWidth(), image->getHeight());
    GenericHistogramView* histo = new GenericHistogramView(image, rect);
    QwtPlot* plot = histo->getGraphicalHistogram();


    _marker1 = new QwtPlotMarker();
    _marker1->setLineStyle(QwtPlotMarker::VLine);
    _marker1->setLinePen(QPen(Qt::black));
    _marker1->setXValue(127);
    _marker1->attach(plot);

    _marker2 = new QwtPlotMarker();
    _marker2->setLineStyle(QwtPlotMarker::VLine);
    _marker2->setLinePen(QPen(Qt::black));
    _marker2->setXValue(255);
    _marker2->attach(plot);
    _marker2->hide();

    _preview = new ImageWidget(this, _image);
    _preview->setFixedSize(256*_preview->pixmap().width()/_preview->pixmap().height(), 256);
    layout->setColumnMinimumWidth(0,256*_preview->pixmap().width()/_preview->pixmap().height());
    layout->addWidget(_preview,0,0,0,0,Qt::AlignTop);
    Vboxlayout->addWidget(plot);
    layout->setRowMinimumHeight(0,256);
    layout->setColumnMinimumWidth(1,20);
    layout->addLayout(Vboxlayout,0,2,0,2,Qt::AlignLeft);
    _previewBox = new QCheckBox(tr("Aperçu"));
    _previewBox->setChecked(true);
    updatePreview();
    layout->addWidget(_previewBox,1,0,1,0,Qt::AlignTop);


    layout->setSizeConstraint(QLayout::SetMinimumSize);

    QPushButton *okButton = new QPushButton(tr("Validate"), this);
    okButton->setDefault(true);
    Vboxlayout->addWidget(okButton);

    connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
    connect(histo, SIGNAL(leftMoved(const QPointF&)), this, SLOT(marker1Moved(const QPointF&)));
    connect(histo, SIGNAL(rightMoved(const QPointF&)), this, SLOT(marker2Moved(const QPointF&)));

    connect(_spinbox1, SIGNAL(valueChanged(int)), this, SLOT(spinbox1Changed(int)));
    connect(_spinbox2, SIGNAL(valueChanged(int)), this, SLOT(spinbox2Changed(int)));


    connect(_doubleBox, SIGNAL(toggled(bool)), _spinbox2, SLOT(setVisible(bool)));
    connect(_doubleBox, SIGNAL(toggled(bool)), spin2label, SLOT(setVisible(bool)));
    connect(_doubleBox, SIGNAL(toggled(bool)), radioLabel, SLOT(setVisible(bool)));
    connect(_doubleBox, SIGNAL(toggled(bool)), whiteButton, SLOT(setVisible(bool)));
    connect(_doubleBox, SIGNAL(toggled(bool)), _blackButton, SLOT(setVisible(bool)));
    connect(_doubleBox, SIGNAL(toggled(bool)), otsuButton, SLOT(setHidden(bool)));
    connect(_doubleBox, SIGNAL(toggled(bool)), this, SLOT(doubleThreshold(bool)));
    connect(_previewBox, SIGNAL(toggled(bool)), this, SLOT(showPreview(bool)));
    connect(_previewBox, SIGNAL(toggled(bool)), this, SLOT(updatePreview()));

    connect(otsuButton, SIGNAL(pressed()), this, SLOT(otsu()));

    connect(_doubleBox, SIGNAL(toggled(bool)), this, SLOT(updatePreview()));
    connect(_blackButton, SIGNAL(toggled(bool)), this, SLOT(updatePreview()));
//    connect (this, SIGNAL(spinbox1Changed(int)), this, SLOT(updatePreview(bool)));
//    connect (this, SIGNAL(spinbox2Changed(int)), this, SLOT(updatePreview(bool)));


}
Beispiel #15
0
void ButtonPageWidget::reloadWidget()
{
    Q_D( ButtonPageWidget );

    int padButtons = DBusTabletInterface::instance().getInformationAsInt(d->tabletId, TabletInfo::NumPadButtons);

    QLabel*                     buttonLabel;
    ButtonActionSelectorWidget* buttonSelector;

    for (int i = 1;i < 11;i++) {
        buttonSelector = this->findChild<ButtonActionSelectorWidget*>(QString::fromLatin1("button%1ActionSelector").arg(i));
        buttonLabel    = this->findChild<QLabel *>(QString::fromLatin1("button%1Label").arg(i));

        if (!buttonSelector || !buttonLabel) {
            continue;
        }

        // we have to disable the widgets as well because when writing
        // the configuration file we can not reliably determine their state
        // based on visibility.
        if (i <= padButtons) {
            buttonLabel->setVisible(true);
            buttonSelector->setEnabled(true);
            buttonSelector->setVisible(true);
        } else {
            buttonLabel->setVisible(false);
            buttonSelector->setEnabled(false);
            buttonSelector->setVisible(false);
        }
    }

    QString padLayout = DBusTabletInterface::instance().getInformationAsString(d->tabletId, TabletInfo::ButtonLayout);
    if (KStandardDirs::exists(KStandardDirs::locate("data", QString::fromLatin1("wacomtablet/images/%1.png").arg(padLayout)))) {
        d->ui->padImage->setPixmap(QPixmap(KStandardDirs::locate("data", QString::fromLatin1("wacomtablet/images/%1.png").arg(padLayout))));
    }

    bool hasLeftTouchStrip  = DBusTabletInterface::instance().getInformationAsBool(d->tabletId, TabletInfo::HasLeftTouchStrip);
    bool hasRightTouchStrip = DBusTabletInterface::instance().getInformationAsBool(d->tabletId, TabletInfo::HasRightTouchStrip);

    if (!hasLeftTouchStrip && !hasRightTouchStrip) {
        d->ui->touchStripGroupBox->setEnabled(false);
        d->ui->touchStripGroupBox->setVisible(false);

    } else {
        d->ui->touchStripGroupBox->setEnabled(true);
        d->ui->touchStripGroupBox->setVisible(true);

        // Hide the strip input widgets directly instead of
        // their parent widget, to keep the layout stable.
        // Hiding the parent widget will mess up the layout!
        // Also disable the widgets so we can reliable determine
        // which settings to save.
        if (!hasLeftTouchStrip) {
            d->ui->leftStripWidget->setEnabled(false);
            d->ui->leftStripUpLabel->setVisible(false);
            d->ui->leftStripUpSelector->setVisible(false);
            d->ui->leftStripDownLabel->setVisible(false);
            d->ui->leftStripDownSelector->setVisible(false);
        } else {
            d->ui->leftStripWidget->setEnabled(true);
            d->ui->leftStripUpLabel->setVisible(true);
            d->ui->leftStripUpSelector->setVisible(true);
            d->ui->leftStripDownLabel->setVisible(true);
            d->ui->leftStripDownSelector->setVisible(true);
        }

        if (!hasRightTouchStrip) {
            d->ui->rightStripWidget->setEnabled(false);
            d->ui->rightStripUpLabel->setVisible(false);
            d->ui->rightStripUpSelector->setVisible(false);
            d->ui->rightStripDownLabel->setVisible(false);
            d->ui->rightStripDownSelector->setVisible(false);
        } else {
            d->ui->rightStripWidget->setEnabled(true);
            d->ui->rightStripUpLabel->setVisible(true);
            d->ui->rightStripUpSelector->setVisible(true);
            d->ui->rightStripDownLabel->setVisible(true);
            d->ui->rightStripDownSelector->setVisible(true);
        }
    }

    if (!DBusTabletInterface::instance().getInformationAsBool(d->tabletId, TabletInfo::HasTouchRing)) {
        d->ui->touchRingGroupBox->setEnabled(false);
        d->ui->touchRingGroupBox->setVisible(false);
    } else {
        d->ui->touchRingGroupBox->setEnabled(true);
        d->ui->touchRingGroupBox->setVisible(true);
    }

    if (!DBusTabletInterface::instance().getInformationAsBool(d->tabletId, TabletInfo::HasWheel)) {
        d->ui->wheelGroupBox->setEnabled(false);
        d->ui->wheelGroupBox->setVisible(false);
    } else {
        d->ui->wheelGroupBox->setEnabled(true);
        d->ui->wheelGroupBox->setVisible(true);
    }
}