void MainWindow::filterTrainData(QString trainID, QString startingStation, QString terminalStation)
{
    //refresh
    for(int i = 0; i < trainTable->rowCount(); ++i)
        trainTable->showRow(i);
    //filter trainID
    for(int i = 0; i < trainTable->rowCount(); ++i)
    {
        if(!trainTable->item(i, 0)->text().contains(trainID))
            trainTable->hideRow(i);
    }
    //filter starting station
    for(int rowNum = 0; rowNum < trainTable->rowCount(); ++rowNum)
    {
        bool isFind = false;
        QComboBox *comboBox = (QComboBox*)trainTable->cellWidget(rowNum, 8);
        for(int i = 0 ; i < comboBox->count(); ++i)
        {
            if(comboBox->itemText(i).contains(startingStation))
            {
                comboBox->setCurrentIndex(i);
                isFind = true;
                break;
            }
        }
        if(isFind == false)
            trainTable->hideRow(rowNum);
    }

    //filter terminal station
    for(int rowNum = 0; rowNum < trainTable->rowCount(); ++rowNum)
    {
        bool isFind = false;
        QComboBox *comboBox = (QComboBox*)trainTable->cellWidget(rowNum, 8);
        int startingStationIndex = comboBox->currentIndex();
        for(int i = 0 ; i < comboBox->count(); ++i)
        {
            //terminal should be after startingStation
            if(comboBox->itemText(i).contains(terminalStation) && startingStationIndex < i)
            {
                isFind = true;
                break;
            }
        }
        if(isFind == false)
            trainTable->hideRow(rowNum);
    }
}
Example #2
0
bool StylesStBar::styleSel( )
{
    //> Get syles list
    XMLNode req("get");
    req.setAttr("path","/ses_"+mainWin()->workSess()+"/%2fobj%2fcfg%2fstLst");
    mainWin()->cntrIfCmd(req);

    if( req.childSize() <= 1 ) return false;

    InputDlg dlg( this, mainWin()->windowIcon(),_("Select your style from list."),_("Style select"),false,false);
    QLabel *lab = new QLabel(_("Style:"),&dlg);
    lab->setSizePolicy( QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred) );
    dlg.edLay()->addWidget( lab, 0, 0 );
    QComboBox *stls = new QComboBox(&dlg);
    dlg.edLay()->addWidget( stls, 0, 1 );
    for(unsigned i_s = 0; i_s < req.childSize(); i_s++)
    {
	stls->addItem(req.childGet(i_s)->text().c_str(),atoi(req.childGet(i_s)->attr("id").c_str()));
	if(atoi(req.childGet(i_s)->attr("id").c_str()) == style())
	    stls->setCurrentIndex(i_s);
    }
    dlg.resize(300,120);
    if( dlg.exec() == QDialog::Accepted && stls->currentIndex() >= 0 )
    {
	setStyle( stls->itemData(stls->currentIndex()).toInt(), stls->itemText(stls->currentIndex()).toAscii().data() );
	emit styleChanged( );
	return true;
    }

    return false;
}
void MainWindow::modifyTrainDialog()
{
    if(this->visitorMode == true)
    {
        QMessageBox::warning(this, QString::fromLocal8Bit("失败"), QString::fromLocal8Bit("游客身份无法修改车次"));
        return;
    }
    //set default content
    int curRow = trainTable->currentRow();
    if(curRow == -1)
    {
        QMessageBox::warning(this, QString::fromLocal8Bit("修改失败"), QString::fromLocal8Bit("请选择要修改的车次"));
        return;
    }
    else
    {
//        format
//        trainIDLine
//        departureTimeLine
//        drivingTimeLine
//        priceLine
//        maxPassengersLine
//        routesText  以|分隔
        QStringList trainData;
        trainData << trainTable->item(curRow, 0)->text();
        trainData << trainTable->item(curRow, 3)->text();
        trainData << trainTable->item(curRow, 4)->text();
        trainData << trainTable->item(curRow, 5)->text();
        trainData << trainTable->item(curRow, 6)->text();

        QComboBox *comboBox = (QComboBox*)trainTable->cellWidget(curRow, 8);
        QString singleRoute;
        for(int i = 0 ; i < comboBox->count(); ++i)//split route and seats data in the comboBox
        {
            if(i)
                singleRoute += '|';

            QString stationWithSeat = comboBox->itemText(i);
            QStringList t = stationWithSeat.split(" ", QString::SkipEmptyParts);
            if(t.size() < 2)
            {
                qDebug() << "wrong in modiftTrain()";
                return;
            }

            if(t.at(1) != trainData[4] && i != comboBox->count() - 1)
            {
                QMessageBox::warning(this, QString::fromLocal8Bit("修改失败"), QString::fromLocal8Bit("该车次已售票,不可修改"));
                return;
            }
            singleRoute += t.at(0);
        }
        trainData << singleRoute;

        trainAMDialog *modifyDialog = new trainAMDialog(this);
        modifyDialog->setTrainData(trainData);  //set default data
        connect(modifyDialog, &trainAMDialog::modifyValueChanged, this, &MainWindow::modifyTrainInfo);
        modifyDialog->exec();
    }
}
void MainWindow::sellTicketDialog()
{
    int rowNum = trainTable->currentRow();
    if(rowNum >= 0)
    {
        QString trainID_ = trainTable->item(rowNum, 0)->text();
        QString departureTime_ = trainTable->item(rowNum, 3)->text();
        QString price_ = trainTable->item(rowNum, 5)->text();
        QStringList routesWithSeats;
        QComboBox *comboBox = (QComboBox*)trainTable->cellWidget(rowNum, 8);
        for(int i = 0 ; i < comboBox->count(); ++i)
        {
            routesWithSeats << comboBox->itemText(i);
        }

        SellDialog *sellDialog = new SellDialog(this);
        sellDialog->setTicketData(trainID_, departureTime_, price_, routesWithSeats);
        connect(sellDialog, &SellDialog::buyTicket, this, &MainWindow::sellTicket);
        sellDialog->exec();
    }
    else
    {
        QMessageBox::warning(this, QString::fromLocal8Bit("购票失败"), QString::fromLocal8Bit("请选择要购买的车次"));
    }
}
void ArchiveDelegate::setModelData(QWidget *AEditor, QAbstractItemModel *AModel, const QModelIndex &AIndex) const
{
	switch (AIndex.column())
	{
	case COL_SAVE:
	case COL_OTR:
	case COL_EXACT:
		{
			QComboBox *comboBox = qobject_cast<QComboBox *>(AEditor);
			if (comboBox)
			{
				int index = comboBox->currentIndex();
				AModel->setData(AIndex,comboBox->itemText(index),Qt::DisplayRole);
				AModel->setData(AIndex,comboBox->itemData(index),Qt::UserRole);
			}
		}
		break;
	case COL_EXPIRE:
		{
			QComboBox *comboBox = qobject_cast<QComboBox *>(AEditor);
			if (comboBox)
			{
				int expire = comboBox->currentText().toInt()*ONE_DAY;
				AModel->setData(AIndex,expireName(expire),Qt::DisplayRole);
				AModel->setData(AIndex,expire,Qt::UserRole);
			}
		}
		break;
	default:
		break;
	}
}
Example #6
0
void ComboDelegate::setModelData (QWidget* editor,
				  QAbstractItemModel *model,
				  const QModelIndex &index) const
{
	QComboBox* combo = static_cast<QComboBox*>(editor);
	
	// Set the data in the given model
	model->setData(index,combo->itemText(combo->currentIndex()),Qt::EditRole);
}
QString ExprParamElement::toString()
{
    QString str = "";
    if (isStringSearchExpression())
    {
        str = QString("\"") + getStrSearchValue() + QString("\""); 
        // we don't bother with case if hash search
	if (searchType != HashSearch) {
	    str += (ignoreCase() ? QString(" (ignore case)") 
                            : QString(" (case sensitive)")); 
	}
    } else 
    {
        if (searchType ==  DateSearch) {
            QDateEdit * dateEdit =  qFindChild<QDateEdit *> (internalframe, "param1");
            str = dateEdit->text();
            if (inRangedConfig)
            {
                str += QString(" ") + tr("to") + QString(" ");
                dateEdit = qFindChild<QDateEdit *> (internalframe, "param2");
                str += dateEdit->text();
            }
        } else if (searchType == SizeSearch) 
        {
            QLineEdit * lineEditSize =  qFindChild<QLineEdit*>(internalframe, "param1");
            str = ("" == lineEditSize->text()) ? "0"
                                               : lineEditSize->text();
            QComboBox * cb = qFindChild<QComboBox*> (internalframe, "unitsCb1");
            str += QString(" ") + cb->itemText(cb->currentIndex());
            if (inRangedConfig)
            {
                str += QString(" ") + tr("to") + QString(" ");
                lineEditSize =  qFindChild<QLineEdit*>(internalframe, "param2");
                str += ("" == lineEditSize->text()) ? "0"
                                                    : lineEditSize->text();
                cb = qFindChild<QComboBox*> (internalframe, "unitsCb2");
                str += QString(" ") + cb->itemText(cb->currentIndex());
            }
        }
    }
    return str;
}
Example #8
0
QComboBox* LayoutManager::copyComboBox(QObject *obj) {
    QComboBox *oldComboBox = qobject_cast<QComboBox*>(obj);
    QComboBox *newComboBox = new QComboBox();

    for(int i=0;i<oldComboBox->count();i++) {
        newComboBox->addItem(oldComboBox->itemText(i),oldComboBox->itemData(i));
    }
    newComboBox->setObjectName(oldComboBox->objectName() + " " + QString::number(keyLayouts.size()));

    return newComboBox;
}
Example #9
0
void ComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                   const QModelIndex &index) const
{
    if (QString(editor->metaObject()->className())==tr("QComboBox")){
       QComboBox *cb = static_cast<QComboBox*>(editor);
       QString str = cb->itemText(cb->currentIndex());
       model->setData(index, QVariant(str.right(3).trimmed()), Qt::EditRole);
    }
    else{
      QItemDelegate::setModelData(editor,model,index);
    }
}
Example #10
0
void TaskItemDelegate::setEditorData(QWidget *editor,
                                       const QModelIndex &index) const
{
    const QString& value ( index.data().toString() );
    
    QComboBox *e = static_cast<QComboBox*>(editor);
    for(int i=0; i<e->count(); i++) {
        if (e->itemText(i) == value) {
            e->setCurrentIndex(i);
            break;
        }
    }
}
Example #11
0
void CComboBox::GetLBText(int nIndex, CString& rString) const
{
    assert(m_hWnd);
	
	if (m_hWnd)
	{
        QString text;
        QComboBox *comboBox = (QComboBox *)m_hWnd;
        text = comboBox->itemText(nIndex);

        rString = text.toStdWString().c_str();
	}
}
Example #12
0
void Setting::save(const QString& section, const QString& prefix, const QComboBox& cmb, bool all)
{
    QSettings& store = storage();

    store.beginGroup(section);

    QString tkey = prefix + SET_PFX_CMBTXT;

    QString tval = cmb.currentText().trimmed();
    if (!tval.isEmpty())
        store.setValue(tkey, tval);

    if (all)
    {
        QStringList keys, vals;

        keys = store.childKeys();
        qint32 n = keys.size();
        if (n > 0)
        {
            keys.sort();

            while (n--)
            {
                QString k = keys[n];
                if ((k!=tkey) && k.startsWith(prefix))
                {
                    QString v = store.value(k).toString().trimmed();
                    if (!v.isEmpty() && (-1 == cmb.findText(v)))
                        vals.prepend(v);

                    store.remove(k);
                }
            }
        }

        n = cmb.count();
        if (n > SET_MAX_CMBITM)
            n = SET_MAX_CMBITM;

        qint32 i = 0;
        for (i=0; i<n; ++i)
            store.setValue(prefix+QString::number(i), cmb.itemText(i));

        n = (vals.count() > SET_MAX_CMBITM) ? SET_MAX_CMBITM : vals.count();
        for (qint32 j=0; i<n; ++i,++j)
            store.setValue(prefix+QString::number(i), vals[j]);
    }

    store.endGroup();
}
Example #13
0
LoadWindow::LoadWindow(QWidget *parent, const QStringList &tierList, const QString &name) :
    QDialog(parent),
    ui(new Ui::LoadWindow)
{
    ui->setupUi(this);

    holder.load();

    LoadLine *array[] = {ui->line1, ui->line2, ui->line3, ui->line4, ui->line5, ui->line6};
    memcpy(lines, array, sizeof(array));

    lines[0]->setUi(ui->name1, ui->gen1, ui->tier1, ui->browser1, tierList);
    lines[1]->setUi(ui->name2, ui->gen2, ui->tier2, ui->browser2, tierList);
    lines[2]->setUi(ui->name3, ui->gen3, ui->tier3, ui->browser3, tierList);
    lines[3]->setUi(ui->name4, ui->gen4, ui->tier4, ui->browser4, tierList);
    lines[4]->setUi(ui->name5, ui->gen5, ui->tier5, ui->browser5, tierList);
    lines[5]->setUi(ui->name6, ui->gen6, ui->tier6, ui->browser6, tierList);

    for (int i = 0; i < 6; i++) {
        if (i >= holder.count()) {
            lines[i]->setChecked(false);
        } else {
            lines[i]->setTeam(holder.team(i));
            lines[i]->setChecked(true);
        }
    }

    /* Hide profile & color from TeamBuilder, since there's a few bugs and you can edit it all in TeamBuilder anyway... */
    if (name == "") {
        ui->profileList->hide();
        ui->colorButton->hide();
    }

    /* To reduce excessive code, this will make the color the same color as your current profile by default */
    on_profileList_currentIndexChanged(name);

    QSettings s;

    QStringList profiles = holder.profile().getProfileList(s.value("Profile/Path").toString());
    QComboBox *profileList = ui->profileList;
    profileList->blockSignals(true);
    profileList->addItems(profiles);
    profileList->blockSignals(false);
    for (int i = 0; i < profileList->count(); ++i) {
        if (profileList->itemText(i) == name)
            profileList->setCurrentIndex(i);
    }

    connect(this, SIGNAL(accepted()), SLOT(onAccept()));
}
Example #14
0
void QgsDataDefinedSymbolDialog::expressionButtonClicked()
{
  QgsDebugMsg( "Expression button clicked" );

  //find out row
  QObject* senderObj = sender();
  int row = 0;
  for ( ; row < mTableWidget->rowCount(); ++row )
  {
    if ( senderObj == mTableWidget->cellWidget( row, 3 ) )
    {
      break;
    }
  }

  QComboBox* attributeCombo = qobject_cast<QComboBox*>( mTableWidget->cellWidget( row, 2 ) );
  if ( !attributeCombo )
  {
    return;
  }

  QString previousText = attributeCombo->itemText( attributeCombo->currentIndex() );
  if ( attributeCombo->currentIndex() > 0 )
  {
    previousText.prepend( "\"" ).append( "\"" );
  }

  QgsExpressionBuilderDialog d( const_cast<QgsVectorLayer*>( mVectorLayer ), previousText );
  if ( d.exec() == QDialog::Accepted )
  {
    QString expressionString = d.expressionText();
    int comboIndex = comboIndexForExpressionString( d.expressionText(), attributeCombo );

    if ( comboIndex == -1 )
    {
      attributeCombo->setItemText( 0, d.expressionText() );
      attributeCombo->setCurrentIndex( 0 );
      Q_ASSERT( d.expressionText() == attributeCombo->currentText() );
    }
    else
    {
      if ( comboIndex != 0 )
      {
        attributeCombo->setItemText( 0, QString() );
      }
      attributeCombo->setCurrentIndex( comboIndex );
    }
  }
}
Example #15
0
int CComboBox::GetLBTextLen(int nIndex) const
{
    assert(m_hWnd);

    if (m_hWnd)
    {
        QString text;
        QComboBox *comboBox = (QComboBox *)m_hWnd;
        text = comboBox->itemText(nIndex);

        return text.length();
    }

	return 0;
}
Example #16
0
int CComboBox::GetLBText(int nIndex, LPTSTR lpszText) const
{
    QString text;

    assert(m_hWnd);

    if (m_hWnd)
    {
       QComboBox *comboBox = (QComboBox *)m_hWnd;
       text = comboBox->itemText(nIndex);
       wcscpy(lpszText, text.toStdWString().c_str());
    }

    return text.length();
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_combobox_item_text (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QComboBox *cb = self->v8_to_qobject<QComboBox> (Args.This ());;
      if (cb) {

         if (Args.Length () > 0) {

            result = qstring_to_v8 (cb->itemText (v8_to_number(Args[0])));
         }
      }
   }

   return scope.Close (result);
}
Example #18
0
//! Writes current program state to data structures in Config class
//! @see closeEvent()
void Window::exportSettings() const
{
	config->clear();
	int index;

	config->pathlistInfile.append(comboInfile->currentText());
	for(index = 0; index < comboInfile->count(); ++index) {
		config->pathlistInfile.append(comboInfile->itemText(index));
	}
	config->pathlistInfile.removeDuplicates();

	config->pathlistOutfile.append(comboOutfile->currentText());
	for(index = 0; index < comboOutfile->count(); ++index) {
		config->pathlistOutfile.append(comboOutfile->itemText(index));
	}
	config->pathlistOutfile.removeDuplicates();

	config->boxOpen = checkBoxOpenWhenDone->isChecked();

	if(comboRowLimit->count() > comboRowLimitDefaultItemCount) {
		config->limitRows = comboRowLimit->currentText();
	}
	config->colCount = spinColumns->value();

	QStringList sl;
	for(index = 0; index < spinColumns->value(); ++index) { // For each column
		QComboBox *cBox = dataComboName.at(index);
		sl.append(cBox->currentText()); // Add the currently displayed text
		// For each name in this combobox
		for(int name = 0; name < cBox->count(); ++name) {
			sl.append(cBox->itemText(name));
		}
		sl.removeDuplicates();
		config->colNames.append(sl);
		sl.clear();
		config->colBoxChecked.append(dataCheckBox.at(index)->isChecked());
		config->colBytes.append(dataSpinNumBytes.at(index)->value());
	}
}
void MainWindow::deleteRoute()
{
    if(this->visitorMode == true)
    {
        QMessageBox::warning(this, QString::fromLocal8Bit("失败"), QString::fromLocal8Bit("游客身份无法删除车次"));
        return;
    }
    int rowNum = trainTable->currentRow();
    if(rowNum >= 0)
    {
        QComboBox *comboBox = (QComboBox*)trainTable->cellWidget(rowNum, 8);
        for(int i = 0; i < comboBox->count(); ++i)
        {
            QStringList routesWithSeats = comboBox->itemText(i).split(QString(" "), QString::SkipEmptyParts);
            if(routesWithSeats.size() < 2)
                qDebug() << "error in deleteRoute()";
            if(routesWithSeats[1] != trainTable->item(rowNum, 6)->text() && i != comboBox->count() - 1)
            {
                QMessageBox::warning(this, QString::fromLocal8Bit("删除失败"), QString::fromLocal8Bit("该车次已售票,不可删除"));
                return;
            }
        }

        if(QMessageBox::Yes == QMessageBox::question(this,QString::fromLocal8Bit("删除确认"),QString::fromLocal8Bit("你确定要删除%1车次列车吗?").arg(trainTable->item(rowNum, 0)->text())))
        {
            trainRoutes.deleteRoute(trainTable->item(rowNum, 0)->text(),
                                    trainTable->item(rowNum, 3)->text());
            //trainRoutes.refreshTrainInfo(trainTable);
            trainTable->removeRow(rowNum);  //much fater
        }
        else
            return;
    }
    else
    {
        QMessageBox::warning(this, QString::fromLocal8Bit("删除失败"), QString::fromLocal8Bit("请选择要删除的车次"));
    }
}
Example #20
0
void BuildIndexDialogFiller::commonScenario() {

    QWidget* dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog, "activeModalWidget is NULL");

    QComboBox* methodNamesBox = dialog->findChild<QComboBox*>("methodNamesBox");
    for(int i=0; i < methodNamesBox->count();i++){
        if(methodNamesBox->itemText(i) == method){
            GTComboBox::setCurrentIndex(os, methodNamesBox, i);
        }
    }

    GTFileDialogUtils *ob = new GTFileDialogUtils(os, refPath, refFileName);
    GTUtilsDialog::waitForDialog(os, ob);
    GTWidget::click(os, GTWidget::findWidget(os, "addRefButton",dialog));

    if (!useDefaultIndexName) {
        QLineEdit* indexFileNameEdit = dialog->findChild<QLineEdit*>("indexFileNameEdit");
        indexFileNameEdit->clear();
        indexFileNameEdit->setText(indPath + indFileName);
    }

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
Example #21
0
void OptionsDialog::doSaveConfs() {
     MainWindow* mw = qobject_cast<MainWindow*>(parent());
     Q_CHECK_PTR( mw );
     TextEdit* te = mw->centraledit();
     for( int i = 0; i < te->listConfs().count(); i++) {
          QString wkey = te->listConfs().at(i)["namewidget"].toString();
          QMap<QString,QWidget*> mymap =  widgetmap [ wkey ];
          QMap<QString,QVariant>& myconf = const_cast<QMap<QString,QVariant>&>(te->listConfs().at(i));
          for(int j=0; j < mymap.keys().count(); j++) {
               QWidget* pwidget = mymap.value( mymap.keys().at(j));
               qDebug("...doSaveConfs()...(3)...mymap.keys().at(j): %s", qPrintable(mymap.keys().at(j)));
               if (pwidget != NULL) {
//                    qDebug("...doSaveConfs()...(4).i=%d..mymap.keys().at(%d):%s", i, j, qPrintable(mymap.keys().at(j)));
//                    qDebug("...doSaveConfs()...(6)...te->listConfs().at(%d)[\"namewidget\"]=%s",i,
//                           qPrintable(te->listConfs().at(i)["namewidget"].toString()));
//                         qDebug("...doSaveConfs()...(10)...te->listConfs().at(i).count(): %d",
//                                te->listConfs().at(i).count());
                    if ( te->listConfs().at(i)[mymap.keys().at(j)].type() == QVariant::String ) {
 //                        qDebug("...doSaveConfs()...(9)...");
                         QLineEdit* pedit = qobject_cast<QLineEdit*>(pwidget);
                         QString text = "";
                         if ( pedit == NULL) {
                            QComboBox* pcombo = qobject_cast<QComboBox*>(pwidget);                            
                            if ( pcombo == NULL ) {
                                InflowEditQListWidget* editlistwidget = (qobject_cast<InflowEditQListWidget*>(pwidget));
                                Q_CHECK_PTR( editlistwidget );
                                QString text = editlistwidget->editList().join(";");
                                text +=";";
                                myconf[mymap.keys().at(j)] = text;
                                qDebug("...OptionsDialog::doSaveConfs: |%s|",
                                       qPrintable(text));
                                continue;
                            }

                             for(int k=0;k<pcombo->count();k++){
                                    text += pcombo->itemText(k);
                                    if (k == pcombo->currentIndex() ) text += "+";
                                    text += ",";
                             }
                             text.chop(1);                        

           //              qDebug("...doSaveConfs()...(10)...combobox...text: %s", qPrintable(text));
                         myconf[mymap.keys().at(j)] = text;

                         } else {
                             QString text = (pedit)->text();

             //                qDebug("...doSaveConfs()...(8)...lineedit...text: %s", qPrintable(text));

                             myconf[mymap.keys().at(j)] = text;
                         }

                    }
                    else if (te->listConfs().at(i)[mymap.keys().at(j)].type() == QVariant::Int ) {
                         int value = (qobject_cast<QSpinBox*>(pwidget))->value();
                         myconf[mymap.keys().at(j)] = value;
                    }
                    else if (te->listConfs().at(i)[mymap.keys().at(j)].type() == QVariant::Bool ) {
                         Qt::CheckState state  = (qobject_cast<QCheckBox*>(pwidget))->checkState();
                         myconf[mymap.keys().at(j)] = (state == Qt::Checked);
                    }

               }
          }
     } 

}
AutoConfig::AutoConfig(QWidget *parent)
	: QWizard(parent)
{
	EnableThreadedMessageBoxes(true);

	calldata_t cd = {0};
	calldata_set_int(&cd, "seconds", 5);

	proc_handler_t *ph = obs_get_proc_handler();
	proc_handler_call(ph, "twitch_ingests_refresh", &cd);
	calldata_free(&cd);

	OBSBasic *main = reinterpret_cast<OBSBasic*>(parent);
	main->EnableOutputs(false);

	installEventFilter(CreateShortcutFilter());

	std::string serviceType;
	GetServiceInfo(serviceType, serviceName, server, key);
#ifdef _WIN32
	setWizardStyle(QWizard::ModernStyle);
#endif
	streamPage = new AutoConfigStreamPage();

	setPage(StartPage, new AutoConfigStartPage());
	setPage(VideoPage, new AutoConfigVideoPage());
	setPage(StreamPage, streamPage);
	setPage(TestPage, new AutoConfigTestPage());
	setWindowTitle(QTStr("Basic.AutoConfig"));
	setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

	obs_video_info ovi;
	obs_get_video_info(&ovi);

	baseResolutionCX = ovi.base_width;
	baseResolutionCY = ovi.base_height;

	/* ----------------------------------------- */
	/* check to see if Twitch's "auto" available */

	OBSData twitchSettings = obs_data_create();
	obs_data_release(twitchSettings);

	obs_data_set_string(twitchSettings, "service", "Twitch");

	obs_properties_t *props = obs_get_service_properties("rtmp_common");
	obs_properties_apply_settings(props, twitchSettings);

	obs_property_t *p = obs_properties_get(props, "server");
	const char *first = obs_property_list_item_string(p, 0);
	twitchAuto = strcmp(first, "auto") == 0;

	obs_properties_destroy(props);

	/* ----------------------------------------- */
	/* load service/servers                      */

	customServer = serviceType == "rtmp_custom";

	QComboBox *serviceList = streamPage->ui->service;

	if (!serviceName.empty()) {
		serviceList->blockSignals(true);

		int count = serviceList->count();
		bool found = false;

		for (int i = 0; i < count; i++) {
			QString name = serviceList->itemText(i);

			if (name == serviceName.c_str()) {
				serviceList->setCurrentIndex(i);
				found = true;
				break;
			}
		}

		if (!found) {
			serviceList->insertItem(0, serviceName.c_str());
			serviceList->setCurrentIndex(0);
		}

		serviceList->blockSignals(false);
	}

	streamPage->UpdateServerList();
	streamPage->UpdateKeyLink();
	streamPage->lastService.clear();

	if (!customServer) {
		QComboBox *serverList = streamPage->ui->server;
		int idx = serverList->findData(QString(server.c_str()));
		if (idx == -1)
			idx = 0;

		serverList->setCurrentIndex(idx);
	} else {
		streamPage->ui->customServer->setText(server.c_str());
		int idx = streamPage->ui->service->findData(
				QVariant((int)ListOpt::Custom));
		streamPage->ui->service->setCurrentIndex(idx);
	}

	if (!key.empty())
		streamPage->ui->key->setText(key.c_str());

	int bitrate = config_get_int(main->Config(), "SimpleOutput", "VBitrate");
	streamPage->ui->bitrate->setValue(bitrate);
	streamPage->ServiceChanged();

	TestHardwareEncoding();
	if (!hardwareEncodingAvailable) {
		delete streamPage->ui->preferHardware;
		streamPage->ui->preferHardware = nullptr;
	} else {
		/* Newer generations of NVENC have a high enough quality to
		 * bitrate ratio that if NVENC is available, it makes sense to
		 * just always prefer hardware encoding by default */
		bool preferHardware = nvencAvailable ||
		                      os_get_physical_cores() <= 4;
		streamPage->ui->preferHardware->setChecked(preferHardware);
	}

	setOptions(0);
	setButtonText(QWizard::FinishButton,
			QTStr("Basic.AutoConfig.ApplySettings"));
	setButtonText(QWizard::BackButton, QTStr("Back"));
	setButtonText(QWizard::NextButton, QTStr("Next"));
	setButtonText(QWizard::CancelButton, QTStr("Cancel"));
}
Example #23
0
int drv_combobox(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QComboBox *self = (QComboBox*)head->native;
    switch (drvid) {
    case COMBOBOX_INIT: {
        drvNewObj(a0,new QComboBox);
        break;
    }
    case COMBOBOX_COUNT: {
        drvSetInt(a1,self->count());
        break;
    }
    case COMBOBOX_SETCURRENTINDEX: {
        self->setCurrentIndex(drvGetInt(a1));
        break;
    }
    case COMBOBOX_CURRENTINDEX: {
        drvSetInt(a1,self->currentIndex());
        break;
    }
    case COMBOBOX_CURRENTTEXT: {
        drvSetString(a1,self->currentText());
        break;
    }
    case COMBOBOX_SETEDITABLE: {
        self->setEditable(drvGetBool(a1));
        break;
    }
    case COMBOBOX_ISEDITABLE: {
        drvSetBool(a1,self->isEditable());
        break;
    }
    case COMBOBOX_SETMAXCOUNT: {
        self->setMaxCount(drvGetInt(a1));
        break;
    }
    case COMBOBOX_MAXCOUNT: {
        drvSetInt(a1,self->maxCount());
        break;
    }
    case COMBOBOX_SETMAXVISIBLEITEMS: {
        self->setMaxVisibleItems(drvGetInt(a1));
        break;
    }
    case COMBOBOX_MAXVISIBLEITEMS: {
        drvSetInt(a1,self->maxVisibleItems());
        break;
    }
    case COMBOBOX_SETMINIMUMCONTENTSLENGTH: {
        self->setMinimumContentsLength(drvGetInt(a1));
        break;
    }
    case COMBOBOX_MINIMUNCONTENTSLENGHT: {
        drvSetInt(a1,self->minimumContentsLength());
        break;
    }
    case COMBOBOX_ADDITEM: {
        self->addItem(drvGetString(a1));
        break;
    }
    case COMBOBOX_INSERTITEM: {
        self->insertItem(drvGetInt(a1),drvGetString(a2));
        break;
    }
    case COMBOBOX_REMOVEITEM: {
        self->removeItem(drvGetInt(a1));
        break;
    }
    case COMBOBOX_ITEMTEXT: {
        drvSetString(a2,self->itemText(drvGetInt(a1)));
        break;
    }
    case COMBOBOX_ONCURRENTINDEXCHANGED: {
        QObject::connect(self,SIGNAL(currentIndexChanged(int)),drvNewSignal(self,a1,a2),SLOT(call(int)));
        break;
    }
    default:
        return 0;
    }
    return 1;
}
void synthv1widget_controls_item_delegate::setModelData ( QWidget *pEditor,
	QAbstractItemModel *pModel,	const QModelIndex& index ) const
{
#ifdef CONFIG_DEBUG_0
	qDebug("synthv1widget_controls_item_delegate::setModelData(%p, %d, %d)",
		pEditor, index.row(), index.column());
#endif

	switch (index.column()) {
	case 0: // Channel.
	{
		QSpinBox *pSpinBox = qobject_cast<QSpinBox *> (pEditor);
		if (pSpinBox) {
			const int iChannel = pSpinBox->value();
			const QString& sText
				= (iChannel > 0 ? QString::number(iChannel) : tr("Auto"));
			pModel->setData(index, sText);
		}
		break;
	}

	case 1: // Type.
	{
		QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
		if (pComboBox) {
			const QString& sType = pComboBox->currentText();
			pModel->setData(index, sType);
		}
		break;
	}

	case 2: // Parameter.
	{
		QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
		if (pComboBox) {
			const int iIndex = pComboBox->currentIndex();
			QString sText;
			int iParam;
			if (iIndex >= 0) {
				sText = pComboBox->itemText(iIndex);
				iParam = pComboBox->itemData(iIndex).toInt();
			} else {
				sText = pComboBox->currentText();
				iParam = sText.toInt();
			}
			pModel->setData(index, sText);
			pModel->setData(index, iParam, Qt::UserRole);
		}
		break;
	}

	case 3: // Subject.
	{
		QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
		if (pComboBox) {
			const int iIndex = pComboBox->currentIndex();
			pModel->setData(index,
				synthv1_param::paramName(synthv1::ParamIndex(iIndex)));
			pModel->setData(index, iIndex, Qt::UserRole);
		}
		break;
	}

	default:
		break;
	}

	// Done.
}
Example #25
0
QByteArray TableItem::GenHTMLForm() {
    QString ret;
    QString objTypeName = obj->metaObject()->className();

    if(objTypeName == "QPlainTextEdit") {
        QPlainTextEdit *item = (QPlainTextEdit *) obj;

#if 0
        ret = QString("<form method=\"post\">"
                   "  <input type=\"hidden\" name=\"action\" value=\"%2\">"
                   "<div class=\"form_info\">%1</div>"
                   "<div class=\"form_editor\"><textarea name=\"%2\" cols=\"20\" rows=\"4\">%3</textarea></div>"
                   "<div class=\"form_submitter\"><input type=\"submit\" value=\"&gt;&gt;\"></div>"
                   "<div class=\"form_tooltip\">%4</div>"
                   "</form>")
                .arg(desc).arg(short_d).arg(item->toPlainText()).arg(item->toolTip());
#endif
        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                      "<div class=\"prop\"><p>%1:</p></div>"
                      "<div class=\"val\"><p><textarea name=\"%2\" cols=\"16\" rows=\"3\">%3</textarea></p></div>"
                      "<div class=\"submit\"><p> %4</p></div>"
                      "<div class=\"tooltip\"><p> %5</p></div>"
                      "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(item->toPlainText())
                .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QLineEdit") {
        QLineEdit *item = (QLineEdit *) obj;

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p><input type=\"text\" name=\"%2\" value=\"%3\" /></p></div>"
                        "<div class=\"submit\"><p> %4</p></div>"
                        "<div class=\"tooltip\"><p> %5</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(item->text())
                .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QCheckBox") {
        QCheckBox *item = (QCheckBox *) obj;
        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p><input type=\"checkbox\" name=\"%2\" value=\"true\" %3/></p></div>"
                        "<div class=\"submit\"><p> %4</p></div>"
                        "<div class=\"tooltip\"><p> %5</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(item->isChecked() ? "checked" : "")
                .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QSpinBox") {
        QSpinBox *item = (QSpinBox *) obj;

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p><input type=\"number\" name=\"%2\" value=\"%3\" min=\"%4\" max=\"%5\" step=\"%6\" /></p></div>"
                        "<div class=\"submit\"><p> %7</p></div>"
                        "<div class=\"tooltip\"><p> %8</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(item->value())
                .arg(item->minimum())
                .arg(item->maximum())
                .arg(item->singleStep())
                .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QDoubleSpinBox") {
        QDoubleSpinBox *item = (QDoubleSpinBox *) obj;

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p><input type=\"number\" name=\"%2\" value=\"%3\" min=\"%4\" max=\"%5\" step=\"%6\" /></p></div>"
                        "<div class=\"submit\"><p> %7</p></div>"
                        "<div class=\"tooltip\"><p> %8</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(item->value())
                .arg(item->minimum())
                .arg(item->maximum())
                .arg(item->singleStep())
                .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QComboBox") {
        QComboBox *item = (QComboBox *) obj;

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p>\n<select name=\"%2\" style=\"max-width:170px;\">\n").arg(desc).arg(short_d);
                      int current = item->currentIndex();
                      for (int i = 0; i < item->count(); i++) {
                          ret.append(QString("<option value=\"%1\" %2>%3</option>\n").arg(i).arg(i==current ? "selected" : "").arg(item->itemText(i)));
                      }

                      ret.append(QString("</select>\n</p></div>"
                        "<div class=\"submit\"><p> %1</p></div>"
                        "<div class=\"tooltip\"><p> %2</p></div>"
                        "</div></form>\n")
                        .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                        .arg(item->toolTip()));

    }
    else if(objTypeName == "QRadioButton") {
        QRadioButton *item = (QRadioButton *) obj;

        QString rb_vals;

        if(item->objectName() == "radioButton_rds_music") {
            rb_vals = QString("<input type=\"radio\" name=\"%1\" value=\"true\" %2/> Music <input type=\"radio\" name=\"%1\" value=\"false\" %3/> Speech")
                .arg(short_d).arg(item->isChecked() ? "checked" : "").arg(item->isChecked() ? "" : "checked");
        }

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p>%3</p></div>"
                        "<div class=\"submit\"><p> %4</p></div>"
                        "<div class=\"tooltip\"><p> %5</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg(rb_vals)
                .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else if(objTypeName == "QPushButton") {
        QPushButton *item = (QPushButton *) obj;

        ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />"
                      "<div class=\"row\">"
                        "<div class=\"prop\"><p>%1:</p></div>"
                        "<div class=\"val\"><p>%3</p></div>"
                        "<div class=\"submit\"><p> %4</p></div>"
                        "<div class=\"tooltip\"><p> %5</p></div>"
                        "</div></form>\n")
                .arg(desc)
                .arg(short_d)
                .arg("action")
                .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\"&gt;&gt;\" />")
                .arg(item->toolTip());
    }
    else {
        qDebug() << "unimplemented obj_type: " << objTypeName;
    }

    return ret.toUtf8();
};
Example #26
0
ProjectionManagement::ProjectionManagement(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ProjectionManagement)
{
    ui->setupUi(this);
    ui->hintLabel->setText(tr("Please set all parameters below in order to create your projecttion"));

    QVBoxLayout *scrollLayout = new QVBoxLayout();

    //limit the start year and the area
    QGroupBox *yearAndAreaBox = new QGroupBox(tr("select the year and area"));

    QLabel *yearLabel = new QLabel(tr("start year"));
    yearLabel->setMaximumWidth(120);

    QComboBox *yearBox = new QComboBox();
    YearItemModel *yearItems = new YearItemModel(this);
    yearBox->setModel(yearItems);
    this->year = yearBox->itemText(0).toInt();

    QLabel *areaLabel = new QLabel(tr("study area"));
    areaLabel->setMaximumWidth(120);

    QComboBox *areaBox = new QComboBox();
    AreaItemModel *areaItems = new AreaItemModel(this);
    areaBox->setModel(areaItems);
    this->area = areaBox->itemText(0);

    QHBoxLayout *yearAndAreaLayout = new QHBoxLayout();
    yearAndAreaLayout->addWidget(yearLabel);
    yearAndAreaLayout->addWidget(yearBox);
    yearAndAreaLayout->addWidget(areaLabel);
    yearAndAreaLayout->addWidget(areaBox);

    yearAndAreaBox->setLayout(yearAndAreaLayout);

    scrollLayout->addWidget(yearAndAreaBox);

    //select the name and the path
    QGroupBox *nameAndPathBox = new QGroupBox(tr("name and path"));

    QHBoxLayout *nameAndPathLayout = new QHBoxLayout();

    QPushButton *nameAndPathButton = new QPushButton(tr("projection name"));
    nameAndPathLayout->addWidget(nameAndPathButton);

    filePathLabel = new QLabel();
    nameAndPathLayout->addWidget(filePathLabel);
    this->reloadData();

    nameAndPathBox->setLayout(nameAndPathLayout);

    scrollLayout->addWidget(nameAndPathBox);

    //if anything more

    ui->scrollAreaWidgetContents->setLayout(scrollLayout);

    //actionss
    connect(nameAndPathButton, SIGNAL(clicked()), this, SLOT(saveProjection()));
    connect(yearBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(yearChanged(QString)));
    connect(areaBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(areaChanged(QString)));

}
Example #27
0
void ActionItemEditDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
	const DAVA::ActionComponent::Action& currentAction = targetComponent->Get(index.row());

	switch(index.column())
	{
		case COLUMN_ACTION_TYPE:
		{
			QComboBox* combo = static_cast<QComboBox*>(editor);
			combo->setCurrentIndex((int)currentAction.type - 1);
			
			break;
		}
			
		case COLUMN_ENTITY_NAME:
		{
			QComboBox* combo = static_cast<QComboBox*>(editor);
			for(int i = 0; i < combo->count(); ++i)
			{
				if(combo->itemText(i) == currentAction.entityName.c_str())
				{
					combo->setCurrentIndex(i);
					break;
				}
			}
			
			break;
		}
			
		case COLUMN_DELAY:
		{
			QDoubleSpinBox* spinBox = static_cast<QDoubleSpinBox*>(editor);
			spinBox->setValue(currentAction.delay);
			
			break;
		}
			
		case COLUMN_SWITCH_INDEX:
		{
			QSpinBox* spinBox = static_cast<QSpinBox*>(editor);
			spinBox->setValue(currentAction.switchIndex);
			
			break;
		}
			
		case COLUMN_STOPAFTERNREPEATS_INDEX:
		{
			QSpinBox* spinBox = static_cast<QSpinBox*>(editor);
			spinBox->setValue(currentAction.stopAfterNRepeats);
			
			break;
		}
			
		case COLUMN_STOPWHENEMPTY_INDEX:
		{
			QComboBox* combo = static_cast<QComboBox*>(editor);
			combo->setCurrentIndex(currentAction.stopWhenEmpty ? COMBO_YES_INDEX : COMBO_NO_INDEX);
			break;
		}

	}

}
Example #28
0
QWidget *OBSPropertiesView::AddList(obs_property_t *prop, bool &warning)
{
	const char       *name  = obs_property_name(prop);
	QComboBox        *combo = new QComboBox();
	obs_combo_type   type   = obs_property_list_type(prop);
	obs_combo_format format = obs_property_list_format(prop);
	size_t           count  = obs_property_list_item_count(prop);
	int              idx    = -1;

	for (size_t i = 0; i < count; i++)
		AddComboItem(combo, prop, format, i);

	if (type == OBS_COMBO_TYPE_EDITABLE)
		combo->setEditable(true);

	string value = from_obs_data(settings, name, format);

	if (format == OBS_COMBO_FORMAT_STRING &&
			type == OBS_COMBO_TYPE_EDITABLE)
		combo->lineEdit()->setText(QT_UTF8(value.c_str()));
	else
		idx = combo->findData(QT_UTF8(value.c_str()));

	if (type == OBS_COMBO_TYPE_EDITABLE)
		return NewWidget(prop, combo,
				SIGNAL(editTextChanged(const QString &)));

	if (idx != -1)
		combo->setCurrentIndex(idx);
	
	if (obs_data_has_autoselect_value(settings, name)) {
		string autoselect =
			from_obs_data_autoselect(settings, name, format);
		int id = combo->findData(QT_UTF8(autoselect.c_str()));

		if (id != -1 && id != idx) {
			QString actual   = combo->itemText(id);
			QString selected = combo->itemText(idx);
			QString combined = QTStr(
				"Basic.PropertiesWindow.AutoSelectFormat");
			combo->setItemText(idx,
					combined.arg(selected).arg(actual));
		}
	}


	QAbstractItemModel *model = combo->model();
	warning = idx != -1 &&
		model->flags(model->index(idx, 0)) == Qt::NoItemFlags;

	WidgetInfo *info = new WidgetInfo(this, prop, combo);
	connect(combo, SIGNAL(currentIndexChanged(int)), info,
				SLOT(ControlChanged()));
	children.push_back(std::move(unique_ptr<WidgetInfo>(info)));

	/* trigger a settings update if the index was not found */
	if (idx == -1)
		info->ControlChanged();

	return combo;
}
Example #29
0
void ModelMgrWidget::updateModels()
{
    //
    QLayoutItem *child;
    while (child = q_horiLayoutMain->takeAt(0)) {
        QWidget *widget = child->widget();
        if (widget) {
            widget->setParent(0);
            widget->deleteLater();
        }
        delete child;
    }

    //
    IconButton *buttonHome = new IconButton(QPixmap(":/application/image/home-1.png"), this);
    buttonHome->setObjectName("buttonHome");
    buttonHome->setFixedSize(25, 25);
    buttonHome->setToolTip(QStringLiteral("主页"));
    q_horiLayoutMain->addWidget(buttonHome);

    QComboBox *comboBoxModel = new QComboBox(this);
    comboBoxModel->addItem(QStringLiteral("数据管理"));
    comboBoxModel->addItem(QStringLiteral("数据查询"));
    comboBoxModel->addItem(QStringLiteral("数据分析"));
    comboBoxModel->setMinimumWidth(QFontMetrics(comboBoxModel->font())
                                   .width(comboBoxModel->itemText(0)) + 50);
    comboBoxModel->setToolTip(QStringLiteral("只切换模式界面,不初始化界面数据"));
    q_horiLayoutMain->addWidget(comboBoxModel);

    //
    connect(buttonHome, &QPushButton::clicked, [=](bool){
        setCurrentModel(QStringLiteral("数据管理"));
    });

    //
    QStringListIterator citerModelStack(q_modelStack);
    while (citerModelStack.hasNext()) {
        const QString &model = citerModelStack.next();
        //

        JClickableLabel *labelName = new JClickableLabel(model, this);
        labelName->setObjectName("labelName");
        labelName->setAlignment(Qt::AlignVCenter);
        labelName->setText(model);
        IconButton *buttonArrow = new IconButton(QPixmap(":/application/image/arrow-1.png"), this);
        buttonArrow->setObjectName("buttonArrow");
        buttonArrow->setFixedSize(20, 25);
        q_horiLayoutMain->addWidget(labelName);
        q_horiLayoutMain->addWidget(buttonArrow);

        //
        connect(labelName, &JClickableLabel::clicked, [=](){
            setCurrentModel(labelName->text());
        });
    }

    //
    comboBoxModel->setCurrentText(q_modelStack.last());

    //
    connect(comboBoxModel, &QComboBox::currentTextChanged, [=](const QString &text){
        setCurrentModel(text, false);
        Q_EMIT currentIndexChanged(text);
    });
}
Example #30
0
void ChatAppearance::makeSettings() {
	m_current_variables.clear();
	if (settingsWidget)
		delete settingsWidget;
	settingsWidget = new QWidget(this);
	QFormLayout *layout = new QFormLayout(settingsWidget);
	layout->setLabelAlignment(Qt::AlignLeft|Qt::AlignVCenter);
	QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
	settingsWidget->setLayout(layout);
	QString category = "webkitstyle";
	StyleVariants variants = ChatStyleGenerator::listVariants(ThemeManager::path(category, m_current_style_name)
															  .append("/Contents/Resources/Variants"));
	if (!variants.isEmpty()) {
		QLabel *label = new QLabel(tr("Style variant:"), settingsWidget);
		label->setSizePolicy(sizePolicy);
		QComboBox *variantBox = new QComboBox(settingsWidget);
		layout->addRow(label, variantBox);
		StyleVariants::const_iterator it;
		for (it=variants.begin(); it!=variants.end(); it++)
			variantBox->addItem(it.key());
		connect(variantBox, SIGNAL(currentIndexChanged(QString)), SLOT(onVariantChanged(QString)));
		int index = isLoad ? variantBox->findText(m_current_variant) : 0;
		m_current_variant = variantBox->itemText(index);
		variantBox->setCurrentIndex(index);
		onVariantChanged(m_current_variant);
	}
	Config achat(QStringList()
				 << "appearance/adiumChat"
				 << ThemeManager::path(category,m_current_style_name)
				 .append("/Contents/Resources/custom.json"));
	ConfigGroup variables = achat;
	int count = variables.beginArray(m_current_style_name);
	for (int num = 0; num < count; num++) {
		ConfigGroup parameter = variables.arrayElement(num);
		QString type = parameter.value("type", QString());
		QString text = parameter.value("label", QString());
		text = parameter.value(QString("label-").append(QLocale().name()), text);
		CustomChatStyle style;
		style.parameter = parameter.value("parameter", QString());
		style.selector = parameter.value("selector", QString());
		style.value = parameter.value("value", QString());
		if (type == "font") {
			QLabel *label = new QLabel(text % ":", settingsWidget);
			label->setSizePolicy(sizePolicy);
			ChatFont *fontField = new ChatFont(style, settingsWidget);
			layout->addRow(label, fontField);
			connect(fontField, SIGNAL(changeValue()), SLOT(onVariableChanged()));
			if (ChatVariable *widget = qobject_cast<ChatVariable*>(fontField))
				m_current_variables.append(widget);
		} else if (type == "color") {
			QLabel *label = new QLabel(text % ":", settingsWidget);
			label->setSizePolicy(sizePolicy);
			ChatColor *colorField = new ChatColor(style, settingsWidget);
			layout->addRow(label, colorField);
			connect(colorField, SIGNAL(changeValue()), SLOT(onVariableChanged()));
			if (ChatVariable *widget = qobject_cast<ChatVariable*>(colorField))
				m_current_variables.append(widget);
		} else if (type == "numeric") {
			QLabel *label = new QLabel(text % ":", settingsWidget);
			label->setSizePolicy(sizePolicy);
			double min = parameter.value<double>("min", 0);
			double max = parameter.value<double>("max", 0);
			double step = parameter.value<double>("step", 1);
			ChatNumeric *numField = new ChatNumeric(style, min, max, step, settingsWidget);
			layout->addRow(label, numField);
			connect(numField, SIGNAL(changeValue()), SLOT(onVariableChanged()));
			if (ChatVariable *widget = qobject_cast<ChatVariable*>(numField))
				m_current_variables.append(widget);
		} else if (type == "boolean") {
			QString trueValue = parameter.value("true", QString());
			QString falseValue = parameter.value("false", QString());
			ChatBoolean *boolField = new ChatBoolean(style, trueValue, falseValue, settingsWidget);
			boolField->setText(text);
			layout->addRow(boolField);
			connect(boolField, SIGNAL(changeValue()), SLOT(onVariableChanged()));
			if (ChatVariable *widget = qobject_cast<ChatVariable*>(boolField))
				m_current_variables.append(widget);
		}
	}
	onVariableChanged();
	QSpacerItem *space = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
	layout->addItem(space);
	ui->scrollAreaLayout->addWidget(settingsWidget);
}