int main(int argc, char **argv) { QApplication app(argc, argv); Q3DSurface *graph = new Q3DSurface(); QWidget *container = QWidget::createWindowContainer(graph); QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.6)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout); vLayout->setAlignment(Qt::AlignTop); widget->setWindowTitle(QStringLiteral("Interpolation")); QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Mode")); QRadioButton *InitPlotModelRB = new QRadioButton(widget); InitPlotModelRB->setText(QStringLiteral("Initial plot")); InitPlotModelRB->setChecked(false); QRadioButton *InterpModelRB = new QRadioButton(widget); InterpModelRB->setText(QStringLiteral("Interpolating plot")); InterpModelRB->setChecked(false); QRadioButton *InitInterpModelRB = new QRadioButton(widget); InitInterpModelRB->setText(QStringLiteral("Initial and Interpolating plots")); InitInterpModelRB->setChecked(false); QRadioButton *ResidModelRB = new QRadioButton(widget); ResidModelRB->setText(QStringLiteral("Residual norm plot")); ResidModelRB->setChecked(false); QVBoxLayout *modelVBox = new QVBoxLayout; modelVBox->addWidget(InitPlotModelRB); modelVBox->addWidget(InterpModelRB); modelVBox->addWidget(InitInterpModelRB); modelVBox->addWidget(ResidModelRB); modelGroupBox->setLayout(modelVBox); QSlider *axisMinSliderX = new QSlider(Qt::Horizontal, widget); axisMinSliderX->setMinimum(0); axisMinSliderX->setTickInterval(1); axisMinSliderX->setEnabled(true); QSlider *axisMaxSliderX = new QSlider(Qt::Horizontal, widget); axisMaxSliderX->setMinimum(1); axisMaxSliderX->setTickInterval(1); axisMaxSliderX->setEnabled(true); QSlider *axisMinSliderZ = new QSlider(Qt::Horizontal, widget); axisMinSliderZ->setMinimum(0); axisMinSliderZ->setTickInterval(1); axisMinSliderZ->setEnabled(true); QSlider *axisMaxSliderZ = new QSlider(Qt::Horizontal, widget); axisMaxSliderZ->setMinimum(1); axisMaxSliderZ->setTickInterval(1); axisMaxSliderZ->setEnabled(true); QLabel *countN = new QLabel(widget); QLabel *countM = new QLabel(widget); vLayout->addWidget(modelGroupBox); vLayout->addWidget(new QLabel(QStringLiteral("Column range"))); vLayout->addWidget(axisMinSliderX); vLayout->addWidget(axisMaxSliderX); vLayout->addWidget(new QLabel(QStringLiteral("Row range"))); vLayout->addWidget(axisMinSliderZ); vLayout->addWidget(axisMaxSliderZ); vLayout->addWidget(new QLabel(QStringLiteral("Points at X axis"))); vLayout->addWidget(countN); vLayout->addWidget(new QLabel(QStringLiteral("Points at Z axis"))); vLayout->addWidget(countM); vLayout->addWidget(new QLabel(QStringLiteral("Press 1 to change the plot\n" "Press 2 to increase number of points at X axis\n" "Press 3 to decrease number of points at X axis\n" "Press 4 to increase number of points at Z axis\n" "Press 5 to decrease number of points at Z axis"))); widget->show(); SurfaceGraph *modifier = new SurfaceGraph(graph); modifier->key1 = new QShortcut(widget); modifier->key1->setKey(Qt::Key_1); QObject::connect(modifier->key1, SIGNAL(activated()), modifier, SLOT(slotShortcut1())); modifier->key2 = new QShortcut(widget); modifier->key2->setKey(Qt::Key_2); QObject::connect(modifier->key2, SIGNAL(activated()), modifier, SLOT(slotShortcut2())); modifier->key3 = new QShortcut(widget); modifier->key3->setKey(Qt::Key_3); QObject::connect(modifier->key3, SIGNAL(activated()), modifier, SLOT(slotShortcut3())); modifier->key4 = new QShortcut(widget); modifier->key4->setKey(Qt::Key_4); QObject::connect(modifier->key4, SIGNAL(activated()), modifier, SLOT(slotShortcut4())); modifier->key5 = new QShortcut(widget); modifier->key5->setKey(Qt::Key_5); QObject::connect(modifier->key5, SIGNAL(activated()), modifier, SLOT(slotShortcut5())); QObject::connect(InitPlotModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableInitPlotModel); QObject::connect(InterpModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableInterpModel); QObject::connect(InitInterpModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableInitInterpModel); QObject::connect(ResidModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableResidModel); QObject::connect(axisMinSliderX, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustXMin); QObject::connect(axisMaxSliderX, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustXMax); QObject::connect(axisMinSliderZ, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustZMin); QObject::connect(axisMaxSliderZ, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustZMax); modifier->setAxisMinSliderX(axisMinSliderX); modifier->setAxisMaxSliderX(axisMaxSliderX); modifier->setAxisMinSliderZ(axisMinSliderZ); modifier->setAxisMaxSliderZ(axisMaxSliderZ); InitPlotModelRB->setChecked(true); modifier->setCount(countN, countM); modifier->setMode(InitPlotModelRB, InterpModelRB, InitInterpModelRB, ResidModelRB); return app.exec(); }
//------------------------------------------------------------------------------------------------ // To create the group of radiobuttons for cell constituent selection. // This uses information about active constituents fetched from the DLL. // Need to distinguish field constituent from cell constituent, because for the cell we are // interested in CFSE, volume, O2byvol in addition to the dissolved constituents: // oxygen, glucose, drugA, drugB, metabolites... //------------------------------------------------------------------------------------------------ void Field::setCellConstituentButtons(QGroupBox *gbox, QButtonGroup *bg, QVBoxLayout **vbox, QList<QRadioButton *> *rb_list, QString tag) { int ivar; QString name, str, ivar_str; QRadioButton *rb; LOG_QMSG("setCellConstituentButtons: " + tag); if (rb_list->length() != 0) { LOG_MSG("rb_list not NULL, delete it"); for (ivar=0; ivar<rb_list->length(); ivar++) { rb = (*rb_list)[ivar]; bg->removeButton(rb); delete rb; } rb_list->clear(); } if (!*vbox) { LOG_MSG("vbox = NULL, create it"); *vbox = new QVBoxLayout; gbox->setLayout(*vbox); } name = "rb_cell_constituent_"+tag; LOG_QMSG(name); sprintf(msg,"rb_list: %p vbox: %p bg: %p nvars_used: %d",rb_list,*vbox,bg,Global::nvars_used); LOG_MSG(msg); for (ivar=0; ivar<Global::nvars_used; ivar++) { ivar_str = QString::number(ivar); str = Global::var_string[ivar]; rb = new QRadioButton; rb->setText(str); rb->setObjectName(name+ivar_str); (*vbox)->addWidget(rb); rb->setEnabled(true); bg->addButton(rb,ivar); rb_list->append(rb); // LOG_QMSG(rb->objectName()); } LOG_MSG("added buttons"); if (tag.contains("FACS")) { (*rb_list)[0]->setChecked(true); // CFSE } else { (*rb_list)[1]->setChecked(true); // Oxygen } QRect rect = gbox->geometry(); rect.setHeight(25*Global::nvars_used); gbox->setGeometry(rect); gbox->show(); }
//Revise Rates tab void MainWindow::occupancyPage() { QLabel *monthLabel = new QLabel(tr("Month : ")); QLabel *averageOccupancyLabel = new QLabel(tr("Average Occupancy : ")); monthCombo = new QComboBox; averageOccupancyField = new QLineEdit; QStringList months; months <<"January"<<"February"<<"March"<<"April"<<"May"<<"June"<<"July"<<"August"<<"September"<<"October"<<"November"<<"December"; monthCombo->addItems(months); connect(monthCombo,SIGNAL(currentIndexChanged(int)),this,SLOT(setValue(const int))); connect(monthCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(showAverageOccupancy())); monthCombo->setCurrentIndex(0); averageOccupancyField->setText(QString::number(manager->getAverageOccupancy(0))); averageOccupancyField->setReadOnly(true); QLabel *reviseRatesLabel = new QLabel; reviseRatesLabel->setText(tr("Revise Rates By % : ")); reviseRatesField = new QLineEdit(tr("0")); QRadioButton *reviseRatesUpRadio = new QRadioButton; reviseRatesUpRadio->setText(tr("Increment")); QRadioButton *reviseRatesDownRadio = new QRadioButton; reviseRatesDownRadio->setText(tr("Decrement")); reviseRatesGroup = new QButtonGroup; reviseRatesGroup->addButton(reviseRatesUpRadio,0); reviseRatesGroup->addButton(reviseRatesDownRadio,1); reviseRatesUpRadio->setChecked(true); QPushButton *reviseRatesButton = new QPushButton(tr("Revise Tariff")); connect(reviseRatesButton,SIGNAL(clicked()),this,SLOT(reviseRates())); connect(reviseRatesField, SIGNAL(returnPressed()), this, SLOT(reviseRates())); occupancyWidget = new QWidget; QHBoxLayout *horizontalLayout1 = new QHBoxLayout; horizontalLayout1->addWidget(monthLabel); horizontalLayout1->addWidget(monthCombo); QHBoxLayout *horizontalLayout2 = new QHBoxLayout; horizontalLayout2->addWidget(averageOccupancyLabel); horizontalLayout2->addWidget(averageOccupancyField); QHBoxLayout *horizontalLayout3 = new QHBoxLayout; horizontalLayout3->addWidget(reviseRatesLabel); horizontalLayout3->addWidget(reviseRatesField); horizontalLayout3->addWidget(reviseRatesUpRadio); horizontalLayout3->addWidget(reviseRatesDownRadio); QVBoxLayout *verticalLayout = new QVBoxLayout; verticalLayout->addLayout(horizontalLayout1); verticalLayout->addLayout(horizontalLayout2); verticalLayout->addLayout(horizontalLayout3); verticalLayout->addWidget(reviseRatesButton); occupancyWidget->setLayout(verticalLayout); }
GNumericalExpressionSettingsWidget::GNumericalExpressionSettingsWidget( GNumericalExpression* numericalExpression, QObject* parent /*= NULL*/) { m_NumericalExpression = numericalExpression; QGroupBox* pExpressionSettings = new QGroupBox; QBoxLayout* pExpressionSettingsLayout = new QVBoxLayout; QBoxLayout* pExpressionEditLayout = new QHBoxLayout; pExpressionSettings->setFixedWidth(400); pExpressionSettings->setTitle("Expression Settings"); pExpressionSettings->setLayout(pExpressionSettingsLayout); pExpressionEditLayout->insertWidget(0, new QLabel("Expression:"), 0); pExpressionEditLayout->insertWidget(1, m_NumericalExpression->m_Expression.ProvideNewParamLineEdit(pExpressionSettings), 0); pExpressionSettingsLayout->insertLayout(0, pExpressionEditLayout); QGroupBox* pVariableSettings = new QGroupBox; QGroupBox* pShowVariables = new QGroupBox; QBoxLayout* pShowVariablesLayout = new QVBoxLayout; QBoxLayout* pVariableSettingsLayout = new QVBoxLayout; QRadioButton* pLayoutVariablesVertically = new QRadioButton; QRadioButton* pLayoutVariablesHorizontally = new QRadioButton; QRadioButton* pLayoutVariablesGrid = new QRadioButton; pVariableSettings->setFixedWidth(400); pVariableSettings->setTitle("Variable Settings"); pVariableSettings->setLayout(pVariableSettingsLayout); pShowVariables->setTitle("Show Variables"); pShowVariables->setCheckable(true); pShowVariables->setLayout(pShowVariablesLayout); pLayoutVariablesHorizontally->setText("Layout: Horizontal"); pShowVariablesLayout->insertWidget(0, pLayoutVariablesHorizontally); pLayoutVariablesVertically->setText("Layout: Vertical"); pShowVariablesLayout->insertWidget(1, pLayoutVariablesVertically); pLayoutVariablesGrid->setText("Layout: Grid"); pShowVariablesLayout->insertWidget(2, pLayoutVariablesGrid); pVariableSettingsLayout->insertWidget(0, pShowVariables); QPushButton* pAcceptButton = new QPushButton; QPushButton* pCloseButton = new QPushButton; QBoxLayout* pButtonLayout = new QHBoxLayout; pAcceptButton->setText("Accept"); connect(pAcceptButton, SIGNAL(clicked(bool)), this, SLOT(Accept())); pCloseButton->setText("Close"); connect(pCloseButton, SIGNAL(clicked(bool)), this, SLOT(close())); pButtonLayout->insertWidget(0, pAcceptButton, 1); pButtonLayout->insertWidget(1, pCloseButton, 1); QBoxLayout* pMainLayout = new QVBoxLayout; pMainLayout->setSizeConstraint(QLayout::SetFixedSize); setLayout(pMainLayout); pMainLayout->insertWidget(0, pExpressionSettings, 1); pMainLayout->insertWidget(1, pVariableSettings, 1); pMainLayout->insertLayout(2, pButtonLayout, 0); }
void PreferencesDialog::initialize(PreferencesTab initialTab, const persistence::Settings *settings, const QMap<QString, QString> &jamRecorders) { Q_UNUSED(initialTab); this->settings = settings; this->jamRecorders = jamRecorders; this->jamRecorderCheckBoxes = QMap<QCheckBox *, QString>(); this->jamDateFormatRadioButtons = QMap<const QRadioButton *, QString>(); for (const auto &jamRecorder : jamRecorders.keys()) { QCheckBox *myCheckBox = new QCheckBox(this); myCheckBox->setObjectName(jamRecorder); myCheckBox->setText(jamRecorders.value(jamRecorder)); ui->layoutRecorders->addWidget(myCheckBox); jamRecorderCheckBoxes[myCheckBox] = jamRecorder; } QDateTime now = QDateTime::currentDateTime(); Qt::DateFormat dateFormat; QString nowString; QRadioButton *myRadioButton; dateFormat = Qt::TextDate; nowString = "Jam-" + now.toString(dateFormat).replace(QRegExp("[/:]"), "-").replace(QRegExp("[ ]"), "_"); myRadioButton = new QRadioButton(this); myRadioButton->setObjectName("rbdfTextDate"); myRadioButton->setText(nowString); myRadioButton->setProperty("buttonGroup", "rbDateFormat"); ui->layoutDateFormats->addWidget(myRadioButton); jamDateFormatRadioButtons[myRadioButton] = "Qt::TextDate"; dateFormat = Qt::ISODate; nowString = "Jam-" + now.toString(dateFormat).replace(QRegExp("[/:]"), "-").replace(QRegExp("[ ]"), "_"); myRadioButton = new QRadioButton(this); myRadioButton->setObjectName("rbdfISODate"); myRadioButton->setText(nowString); myRadioButton->setProperty("buttonGroup", "rbDateFormat"); ui->layoutDateFormats->addWidget(myRadioButton); jamDateFormatRadioButtons[myRadioButton] = "Qt::ISODate"; setupSignals(); populateAllTabs(); }
//------------------------------------------------------------------------------------------------ // To create the group of radiobuttons for field constituent selection. // This uses information about active constituents fetched from the DLL. // Need to distinguish field constituent from cell constituent, because for the // field we have only the dissolved constituents: // oxygen, glucose, drugA, drugB, metabolites... //------------------------------------------------------------------------------------------------ void Field::setFieldConstituentButtons(QGroupBox *gbox, QButtonGroup *bg, QVBoxLayout **vbox, QList<QRadioButton *> *rb_list, QString tag) { int ivar; QString name, str, ivar_str; QRadioButton *rb; Global::nfieldvars_used = Global::nvars_used - Global::N_EXTRA; // LOG_QMSG("setFieldConstituentButtons: " + tag + " nfieldvars_used: " // + QString::number(Global::nfieldvars_used)); if (rb_list->length() != 0) { LOG_MSG("rb_list not NULL, delete it"); for (ivar=0; ivar<rb_list->length(); ivar++) { rb = (*rb_list)[ivar]; bg->removeButton(rb); delete rb; } rb_list->clear(); } if (!*vbox) { LOG_MSG("vbox = NULL, create it"); *vbox = new QVBoxLayout; gbox->setLayout(*vbox); } name = "rb_field_constituent_"+tag; // LOG_QMSG(name); for (ivar=0; ivar<Global::nfieldvars_used; ivar++) { ivar_str = QString::number(ivar); str = Global::var_string[ivar+1]; rb = new QRadioButton; rb->setText(str); QString objname = name+ivar_str; rb->setObjectName(objname); (*vbox)->addWidget(rb); rb->setEnabled(true); bg->addButton(rb,ivar); rb_list->append(rb); // QRadioButton *chkrb = gbox->findChild<QRadioButton *>(objname); // if (chkrb) { // QString chkstr = chkrb->objectName(); // LOG_QMSG(chkstr); // } else { // chkrb = (*rb_list)[ivar]; // LOG_QMSG("findChild failed, but: " + chkrb->objectName()); // } } (*rb_list)[0]->setChecked(true); // Oxygen QRect rect = gbox->geometry(); rect.setHeight(25*(Global::nfieldvars_used + 1)); gbox->setGeometry(rect); gbox->show(); }
/** Add a radio button to the plot options * * @param text :: text on the radio button * @param tooltip :: tooltip * @param bIntegrated :: flag to indicate that the dimension is integrated. */ void LinePlotOptions::addPlotRadioButton(const std::string &text, const std::string &tooltip, const bool bIntegrated) { QRadioButton *rad; rad = new QRadioButton(ui.widgetPlotAxis); rad->setText(QString::fromStdString(text)); rad->setToolTip(QString::fromStdString(tooltip)); rad->setEnabled(!bIntegrated); // Insert it one before the horizontal spacer. QBoxLayout *layout = qobject_cast<QBoxLayout *>(ui.widgetPlotAxis->layout()); layout->insertWidget(layout->count() - 1, rad); m_radPlots.push_back(rad); QObject::connect(rad, SIGNAL(toggled(bool)), this, SLOT(radPlot_changed())); }
egx_wnd_t egx_radiobutton_create_(int res_id,char *name,egx_uint32_t style,int x,int y,int width,int height,egx_wnd_t parent,egx_wnd_t radiogroup) { QRadioButton *button = new QRadioButton((QWidget*)(parent)); button->setText(QString::fromLocal8Bit(name)); if(x == 0 || y == 0){ button->resize(width,height); }else{ button->setGeometry(x,y,width,height); } QButtonGroup *_radiogroup = (QButtonGroup*)radiogroup; if(_radiogroup){ _radiogroup->addButton(button); } return HWND_TO_GUIWND(button); }
void KSaneDeviceDialog::updateDevicesList() { while (!m_btnGroup->buttons().isEmpty()) { delete m_btnGroup->buttons().takeFirst(); } const QList<KSaneWidget::DeviceInfo> list = m_findDevThread->devicesList(); if (list.isEmpty()) { m_btnBox->setTitle(i18n("Sorry. No devices found.")); m_btnBox->layout()->itemAt(0)->widget()->show(); // explanation m_btnBox->layout()->itemAt(1)->widget()->hide(); // scroll area enableButton(KDialog::User1, true); return; } delete m_btnLayout; m_btnLayout = new QVBoxLayout; m_btnContainer->setLayout(m_btnLayout); m_btnBox->setTitle(i18n("Found devices:")); m_btnBox->layout()->itemAt(0)->widget()->hide(); // explanation m_btnBox->layout()->itemAt(1)->widget()->show(); // scroll area for (int i=0; i< list.size(); i++) { QRadioButton *b = new QRadioButton(this); b->setObjectName(list[i].name); b->setToolTip(list[i].name); b->setText(QString("%1 : %2\n%3") .arg(list[i].vendor) .arg(list[i].model) .arg(list[i].name)); m_btnLayout->addWidget(b); m_btnGroup->addButton(b); connect(b, SIGNAL(clicked(bool)), this, SLOT(setAvailable(bool))); if((i==0) || (list[i].name == m_selectedDevice)) { b->setChecked(true); setAvailable(true); } } m_btnLayout->addStretch(); if(list.size() == 1) { button(KDialog::Ok)->animateClick(); } enableButton(KDialog::User1, true); }
void addTypeFormats(const QString &type, const QStringList &typeFormats, int current) { const int row = m_layout->rowCount(); int column = 0; QButtonGroup *group = new QButtonGroup(this); m_layout->addWidget(new QLabel(type), row, column++); for (int i = -1; i != typeFormats.size(); ++i) { QRadioButton *choice = new QRadioButton(this); choice->setText(i == -1 ? TypeFormatsDialog::tr("Reset") : typeFormats.at(i)); m_layout->addWidget(choice, row, column++); if (i == current) choice->setChecked(true); group->addButton(choice, i); } }
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // initializing facade IWorkInterface* paintingInterface = new CVisualWorkInterface( ui->DrawPadWidget->geometry().topLeft(), RSettings::cellHeight(), RSettings::cellWidth(), new CPixelMatrixBuilder); IViewInterface* resultsInterface = new CViewInterface( ui->HistogramViewWidget->geometry().topLeft(), ui->HistogramViewWidget->geometry().height(), ui->HistogramViewWidget->geometry().width(), this, this, ui->ResultLabel); IDigitNetwork* network = new CDigitNetwork; IMessageShower* messager = new CVisualMessageShower; recognizer = new CRecognizer(paintingInterface, resultsInterface, network, messager, this, this->palette()); recognizer->init(); recognizer->loadNeuronsFromFile(); // creating radio group QGridLayout* grid = new QGridLayout; for(int i = 0; i < 10; ++i) { QRadioButton *radio = new QRadioButton; digitRadioButtons[i] = radio; radio->setText(tr("Digit %1").arg(QString::number(i))); grid->addWidget(radio, i % 5, i / 5); } ui->DigitRadioBox->setLayout(grid); // initializing palette QPalette palette(MainWindow::palette()); this->setPalette(palette); }
void retranslateUi(QWidget *MainWindow2) { MainWindow2->setWindowTitle(QApplication::translate("MainWindow2", "ActionBox Example", 0, QApplication::UnicodeUTF8)); actionNew->setText(QApplication::translate("MainWindow2", "Create new file", 0, QApplication::UnicodeUTF8)); actionLoad->setText(QApplication::translate("MainWindow2", "Load a file", 0, QApplication::UnicodeUTF8)); actionSave->setText(QApplication::translate("MainWindow2", "Save current file", 0, QApplication::UnicodeUTF8)); actionPrint->setText(QApplication::translate("MainWindow2", "Print file contents", 0, QApplication::UnicodeUTF8)); ActionGroup1->setProperty("headerText", QVariant(QApplication::translate("MainWindow2", "Choose Scheme", 0, QApplication::UnicodeUTF8))); rbDefaultScheme->setText(QApplication::translate("MainWindow2", "Default", 0, QApplication::UnicodeUTF8)); rbXPBlueScheme->setText(QApplication::translate("MainWindow2", "XP Blue", 0, QApplication::UnicodeUTF8)); rbXPBlue2Scheme->setText(QApplication::translate("MainWindow2", "XP Blue 2", 0, QApplication::UnicodeUTF8)); rbVistaScheme->setText(QApplication::translate("MainWindow2", "Vista", 0, QApplication::UnicodeUTF8)); rbMacScheme->setText(QApplication::translate("MainWindow2", "MacOS", 0, QApplication::UnicodeUTF8)); rbAndroidScheme->setText(QApplication::translate("MainWindow2", "Android", 0, QApplication::UnicodeUTF8)); Q_UNUSED(MainWindow2); } // retranslateUi
SelectModule::SelectModule (const QString& type, const SelectModule::Dict& types, QWidget * parent) : QDialog(parent, Qt::WindowTitleHint) { setWindowTitle(tr("Select module")); groupBox = new QGroupBox(this); groupBox->setTitle(tr("Open %1 as").arg(type)); group = new QButtonGroup(this); gridLayout = new QGridLayout(this); gridLayout->setSpacing(6); gridLayout->setMargin(9); gridLayout1 = new QGridLayout(groupBox); gridLayout1->setSpacing(6); gridLayout1->setMargin(9); int index = 0; for (SelectModule::Dict::const_iterator it = types.begin(); it != types.end(); ++it) { QRadioButton* button = new QRadioButton(groupBox); QRegExp rx; QString filter = it.key(); QString module = it.value(); // ignore file types in (...) rx.setPattern(QLatin1String("\\s+\\([\\w\\*\\s\\.]+\\)$")); int pos = rx.indexIn(filter); if (pos != -1) { filter = filter.left(pos); } // ignore Gui suffix in module name rx.setPattern(QLatin1String("Gui$")); pos = rx.indexIn(module); if (pos != -1) { module = module.left(pos); } button->setText(QString::fromAscii("%1 (%2)").arg(filter).arg(module)); button->setObjectName(it.value()); gridLayout1->addWidget(button, index, 0, 1, 1); group->addButton(button, index); index++; } gridLayout->addWidget(groupBox, 0, 0, 1, 1); spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); gridLayout->addItem(spacerItem, 1, 0, 1, 1); hboxLayout = new QHBoxLayout(); hboxLayout->setSpacing(6); hboxLayout->setMargin(0); spacerItem1 = new QSpacerItem(131, 31, QSizePolicy::Expanding, QSizePolicy::Minimum); hboxLayout->addItem(spacerItem1); okButton = new QPushButton(this); okButton->setObjectName(QString::fromUtf8("okButton")); okButton->setText(tr("Select")); okButton->setEnabled(false); hboxLayout->addWidget(okButton); gridLayout->addLayout(hboxLayout, 2, 0, 1, 1); // connections connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(group, SIGNAL(buttonClicked(int)), this, SLOT(onButtonClicked())); }
XFormWidget::XFormWidget(QWidget *parent) : QWidget(parent), textEditor(new QLineEdit) { setWindowTitle(tr("Affine Transformations")); view = new XFormView(this); view->setMinimumSize(200, 200); QGroupBox *mainGroup = new QGroupBox(this); mainGroup->setFixedWidth(180); mainGroup->setTitle(tr("Affine Transformations")); QGroupBox *rotateGroup = new QGroupBox(mainGroup); rotateGroup->setTitle(tr("Rotate")); QSlider *rotateSlider = new QSlider(Qt::Horizontal, rotateGroup); rotateSlider->setRange(0, 3600); rotateSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); QGroupBox *scaleGroup = new QGroupBox(mainGroup); scaleGroup->setTitle(tr("Scale")); QSlider *scaleSlider = new QSlider(Qt::Horizontal, scaleGroup); scaleSlider->setRange(1, 4000); scaleSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); QGroupBox *shearGroup = new QGroupBox(mainGroup); shearGroup->setTitle(tr("Shear")); QSlider *shearSlider = new QSlider(Qt::Horizontal, shearGroup); shearSlider->setRange(-990, 990); shearSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); QGroupBox *typeGroup = new QGroupBox(mainGroup); typeGroup->setTitle(tr("Type")); QRadioButton *vectorType = new QRadioButton(typeGroup); QRadioButton *pixmapType = new QRadioButton(typeGroup); QRadioButton *textType= new QRadioButton(typeGroup); vectorType->setText(tr("Vector Image")); pixmapType->setText(tr("Pixmap")); textType->setText(tr("Text")); QPushButton *resetButton = new QPushButton(mainGroup); resetButton->setText(tr("Reset Transform")); QPushButton *animateButton = new QPushButton(mainGroup); animateButton->setText(tr("Animate")); animateButton->setCheckable(true); QPushButton *showSourceButton = new QPushButton(mainGroup); showSourceButton->setText(tr("Show Source")); #ifdef QT_OPENGL_SUPPORT QPushButton *enableOpenGLButton = new QPushButton(mainGroup); enableOpenGLButton->setText(tr("Use OpenGL")); enableOpenGLButton->setCheckable(true); enableOpenGLButton->setChecked(view->usesOpenGL()); if (!QGLFormat::hasOpenGL()) enableOpenGLButton->hide(); #endif QPushButton *whatsThisButton = new QPushButton(mainGroup); whatsThisButton->setText(tr("What's This?")); whatsThisButton->setCheckable(true); QHBoxLayout *viewLayout = new QHBoxLayout(this); viewLayout->addWidget(view); viewLayout->addWidget(mainGroup); QVBoxLayout *rotateGroupLayout = new QVBoxLayout(rotateGroup); rotateGroupLayout->addWidget(rotateSlider); QVBoxLayout *scaleGroupLayout = new QVBoxLayout(scaleGroup); scaleGroupLayout->addWidget(scaleSlider); QVBoxLayout *shearGroupLayout = new QVBoxLayout(shearGroup); shearGroupLayout->addWidget(shearSlider); QVBoxLayout *typeGroupLayout = new QVBoxLayout(typeGroup); typeGroupLayout->addWidget(vectorType); typeGroupLayout->addWidget(pixmapType); typeGroupLayout->addWidget(textType); typeGroupLayout->addSpacing(4); typeGroupLayout->addWidget(textEditor); QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup); mainGroupLayout->addWidget(rotateGroup); mainGroupLayout->addWidget(scaleGroup); mainGroupLayout->addWidget(shearGroup); mainGroupLayout->addWidget(typeGroup); mainGroupLayout->addStretch(1); mainGroupLayout->addWidget(resetButton); mainGroupLayout->addWidget(animateButton); mainGroupLayout->addWidget(showSourceButton); #ifdef QT_OPENGL_SUPPORT mainGroupLayout->addWidget(enableOpenGLButton); #endif mainGroupLayout->addWidget(whatsThisButton); connect(rotateSlider, SIGNAL(valueChanged(int)), view, SLOT(changeRotation(int))); connect(shearSlider, SIGNAL(valueChanged(int)), view, SLOT(changeShear(int))); connect(scaleSlider, SIGNAL(valueChanged(int)), view, SLOT(changeScale(int))); connect(vectorType, SIGNAL(clicked()), view, SLOT(setVectorType())); connect(pixmapType, SIGNAL(clicked()), view, SLOT(setPixmapType())); connect(textType, SIGNAL(clicked()), view, SLOT(setTextType())); connect(textType, SIGNAL(toggled(bool)), textEditor, SLOT(setEnabled(bool))); connect(textEditor, SIGNAL(textChanged(QString)), view, SLOT(setText(QString))); connect(view, SIGNAL(rotationChanged(int)), rotateSlider, SLOT(setValue(int))); connect(view, SIGNAL(scaleChanged(int)), scaleSlider, SLOT(setValue(int))); connect(view, SIGNAL(shearChanged(int)), shearSlider, SLOT(setValue(int))); connect(resetButton, SIGNAL(clicked()), view, SLOT(reset())); connect(animateButton, SIGNAL(clicked(bool)), view, SLOT(setAnimation(bool))); connect(whatsThisButton, SIGNAL(clicked(bool)), view, SLOT(setDescriptionEnabled(bool))); connect(whatsThisButton, SIGNAL(clicked(bool)), view->hoverPoints(), SLOT(setDisabled(bool))); connect(view, SIGNAL(descriptionEnabledChanged(bool)), view->hoverPoints(), SLOT(setDisabled(bool))); connect(view, SIGNAL(descriptionEnabledChanged(bool)), whatsThisButton, SLOT(setChecked(bool))); connect(showSourceButton, SIGNAL(clicked()), view, SLOT(showSource())); #ifdef QT_OPENGL_SUPPORT connect(enableOpenGLButton, SIGNAL(clicked(bool)), view, SLOT(enableOpenGL(bool))); #endif view->loadSourceFile(":res/affine/xform.cpp"); view->loadDescription(":res/affine/xform.html"); // defaults view->reset(); vectorType->setChecked(true); textEditor->setText("Qt Affine Transformation Demo"); textEditor->setEnabled(false); animateButton->animateClick(); }
static QList<QWidget*> getFormWidgets(QList<FormField> formFields, const QObject *receiver) { QList<QWidget*> formWidgets; for (int i = 0; i < formFields.size(); ++i) { Poppler::FormField *formField = formFields.at(i).field; if (formField->type() == Poppler::FormField::FormText) { Poppler::FormFieldText *formFieldText = static_cast<Poppler::FormFieldText*>(formField); switch (formFieldText->textType()) { case Poppler::FormFieldText::FileSelect: { // TODO replace this by a file selection widget QLineEdit *lineEdit = new QLineEdit; lineEdit->setText(formFieldText->text()); lineEdit->setObjectName(QLatin1String("PageItem::formField") + QString::number(i)); QObject::connect(lineEdit, SIGNAL(textEdited(QString)), receiver, SLOT(slotSetFormData(QString))); formWidgets << lineEdit; } break; case Poppler::FormFieldText::Multiline: { QTextEdit *textEdit = new QTextEdit; textEdit->setText(formFieldText->text()); textEdit->setObjectName(QLatin1String("PageItem::formField") + QString::number(i)); QObject::connect(textEdit, SIGNAL(textChanged()), receiver, SLOT(slotSetFormData())); formWidgets << textEdit; } break; case Poppler::FormFieldText::Normal: default: { QLineEdit *lineEdit = new QLineEdit; lineEdit->setText(formFieldText->text()); lineEdit->setObjectName(QLatin1String("PageItem::formField") + QString::number(i)); QObject::connect(lineEdit, SIGNAL(textEdited(QString)), receiver, SLOT(slotSetFormData(QString))); formWidgets << lineEdit; } break; } } else if (formField->type() == Poppler::FormField::FormButton) { Poppler::FormFieldButton *formFieldButton = static_cast<Poppler::FormFieldButton*>(formField); switch (formFieldButton->buttonType()) { case Poppler::FormFieldButton::CheckBox: { QCheckBox *checkBox = new QCheckBox; // checkBox->setText(formFieldButton->caption()); checkBox->setChecked(formFieldButton->state()); checkBox->setObjectName(QLatin1String("PageItem::formField") + QString::number(i)); QObject::connect(checkBox, SIGNAL(toggled(bool)), receiver, SLOT(slotSetFormData(bool))); formWidgets << checkBox; } break; case Poppler::FormFieldButton::Radio: { QRadioButton *radioButton = new QRadioButton; radioButton->setText(formFieldButton->caption()); radioButton->setChecked(formFieldButton->state()); radioButton->setObjectName(QLatin1String("PageItem::formField") + QString::number(i)); QObject::connect(radioButton, SIGNAL(toggled(bool)), receiver, SLOT(slotSetFormData(bool))); formWidgets << radioButton; } break; case Poppler::FormFieldButton::Push: default: { QPushButton *pushButton = new QPushButton; pushButton->setText(formFieldButton->caption()); pushButton->setChecked(formFieldButton->state()); pushButton->setObjectName(QLatin1String("PageItem::formField") + QString::number(i)); QObject::connect(pushButton, SIGNAL(toggled(bool)), receiver, SLOT(slotSetFormData(bool))); formWidgets << pushButton; } break; } } else if (formField->type() == Poppler::FormField::FormChoice) { Poppler::FormFieldChoice *formFieldChoice = static_cast<Poppler::FormFieldChoice*>(formField); switch (formFieldChoice->choiceType()) { case Poppler::FormFieldChoice::ComboBox: { QComboBox *comboBox = new QComboBox; comboBox->addItems(formFieldChoice->choices()); comboBox->setEditable(formFieldChoice->isEditable()); comboBox->setCurrentIndex(formFieldChoice->currentChoices().at(0)); comboBox->setObjectName(QLatin1String("PageItem::formField") + QString::number(i)); QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), receiver, SLOT(slotSetFormData(int))); formWidgets << comboBox; } break; case Poppler::FormFieldChoice::ListBox: default: { QListWidget *listWidget = new QListWidget; listWidget->addItems(formFieldChoice->choices()); if (formFieldChoice->isEditable()) { for (int j = 0; j < listWidget->count(); ++j) listWidget->item(j)->setFlags(listWidget->item(j)->flags() | Qt::ItemIsEditable); } else { for (int j = 0; j < listWidget->count(); ++j) listWidget->item(j)->setFlags(listWidget->item(j)->flags() & ~Qt::ItemIsEditable); } QList<int> currentChoices = formFieldChoice->currentChoices(); for (int j = 0; j < currentChoices.size(); ++j) listWidget->item(currentChoices.at(j))->setSelected(true); listWidget->setObjectName(QLatin1String("PageItem::formField") + QString::number(i)); QObject::connect(listWidget, SIGNAL(itemSelectionChanged()), receiver, SLOT(slotSetFormData())); formWidgets << listWidget; } break; } } else if (formField->type() == Poppler::FormField::FormSignature) { // TODO formWidgets << new QWidget; } else // make sure that m_formWidgets.at(i) corresponds to m_formFields.at(i) formWidgets << new QWidget; } return formWidgets; }
scannerwindow::scannerwindow(QList<int> parameters, QMainWindow *parent, bool load, QTextStream* stream): QObject(parent) { this->parameters=parameters; widget = new QWidget(); widget->setAttribute(Qt::WA_DeleteOnClose); graph = new Q3DSurface(); container = QWidget::createWindowContainer(graph, widget); container->setAttribute(Qt::WA_AcceptTouchEvents); widget->setGeometry( QStyle::alignedRect( Qt::LeftToRight, Qt::AlignTop, widget->size(), qApp->desktop()->availableGeometry() ) ); bitmapForward=new QCustomPlot(widget); bitmapBackward=new QCustomPlot(widget); bitmapCombined=new QCustomPlot(widget); bitmapForward->setContextMenuPolicy(Qt::CustomContextMenu); bitmapBackward->setContextMenuPolicy(Qt::CustomContextMenu); bitmapCombined->setContextMenuPolicy(Qt::CustomContextMenu); bitmapBackward->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); bitmapForward->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); bitmapCombined->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); initializeBitmapForward(bitmapForward); initializeBitmapBackward(bitmapBackward); initializeBitmapCombined(bitmapCombined); if (!graph->hasContext()) { QMessageBox msgBox; msgBox.setText("Couldn't initialize the OpenGL context."); msgBox.exec(); } QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 3, screenSize.height()/4)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); bitmapBackward->setMinimumSize(screenSize.width()/4, screenSize.height()/4); bitmapForward->setMinimumSize(screenSize.width()/4, screenSize.height()/4); bitmapCombined->setMinimumSize(screenSize.width()/4, screenSize.height()/4); QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); QSplitter *hSplitterMain = new QSplitter(); QSplitter *vSplitterRight = new QSplitter(); hLayout->setSizeConstraint(QBoxLayout::SizeConstraint::SetMinimumSize); vSplitterRight->addWidget(bitmapForward); vSplitterRight->addWidget(bitmapBackward); vSplitterRight->addWidget(bitmapCombined); vSplitterRight->setOrientation(Qt::Orientation::Vertical); vSplitterRight->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); hSplitterMain->setOrientation(Qt::Orientation::Horizontal); hSplitterMain->addWidget(container); hSplitterMain->addWidget(vSplitterRight); hSplitterMain->setStyleSheet("QSplitter::handle {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,stop:0 rgba(255, 255, 255, 0),stop:0.407273 rgba(200, 200, 200, 255),stop:0.4825 rgba(101, 104, 113, 235), stop:0.6 rgba(255, 255, 255, 0));}"); vSplitterRight->setStyleSheet("QSplitter::handle {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,stop:0 rgba(255, 255, 255, 0),stop:0.407273 rgba(200, 200, 200, 255),stop:0.4825 rgba(101, 104, 113, 235), stop:0.6 rgba(255, 255, 255, 0));}"); hLayout->addWidget(hSplitterMain); hLayout->addLayout(vLayout); vLayout->setAlignment(Qt::AlignTop); widget->setWindowTitle(QStringLiteral("AFM Scan")); QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Scan")); if(!load){ AFM_Scan_3D_RB = new QPushButton(widget); AFM_Scan_3D_RB->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); AFM_Scan_3D_RB->setText(QStringLiteral("Start Scan")); AFM_Scan_3D_RB->setCheckable(true); AFM_Scan_3D_RB->setChecked(false); } SaveSurface = new QPushButton(widget); SaveSurface->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); SaveSurface->setText(QStringLiteral("Save Data")); BitmapView = new QPushButton(widget); BitmapView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); BitmapView->setText(QStringLiteral("Save BMP")); QVBoxLayout *modelVBox = new QVBoxLayout; if(!load){ modelVBox->addWidget(AFM_Scan_3D_RB); } modelVBox->addWidget(BitmapView); modelVBox->addWidget(SaveSurface); modelGroupBox->setLayout(modelVBox); QGroupBox *selectionGroupBox = new QGroupBox(QStringLiteral("Selection Mode")); selectionGroupBox->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); QCheckBox *piezoMove = new QCheckBox(widget); piezoMove->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); piezoMove->setText(QStringLiteral("Piezo")); piezoMove->setChecked(true); modelVBox->addWidget(piezoMove); QRadioButton *modeNoneRB = new QRadioButton(widget); modeNoneRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeNoneRB->setText(QStringLiteral("No selection")); modeNoneRB->setChecked(false); QRadioButton *modeItemRB = new QRadioButton(widget); modeItemRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeItemRB->setText(QStringLiteral("Item")); modeItemRB->setChecked(false); QRadioButton *modeSliceRowRB = new QRadioButton(widget); modeSliceRowRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeSliceRowRB->setText(QStringLiteral("Row Slice")); modeSliceRowRB->setChecked(false); QRadioButton *modeSliceColumnRB = new QRadioButton(widget); modeSliceColumnRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeSliceColumnRB->setText(QStringLiteral("Column Slice")); modeSliceColumnRB->setChecked(false); QVBoxLayout *selectionVBox = new QVBoxLayout; selectionVBox->addWidget(modeNoneRB); selectionVBox->addWidget(modeItemRB); selectionVBox->addWidget(modeSliceRowRB); selectionVBox->addWidget(modeSliceColumnRB); selectionGroupBox->setLayout(selectionVBox); QSlider *axisCameraSliderZ = new QSlider(Qt::Horizontal, widget); axisCameraSliderZ->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); axisCameraSliderZ->setMinimum(0); axisCameraSliderZ->setMaximum(179); axisCameraSliderZ->setTickInterval(1); axisCameraSliderZ->setEnabled(true); QSlider *axisCameraSliderY = new QSlider(Qt::Horizontal, widget); axisCameraSliderY->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); axisCameraSliderY->setMinimum(0); axisCameraSliderY->setMaximum(180); axisCameraSliderY->setTickInterval(0); axisCameraSliderY->setEnabled(true); QComboBox *themeList = new QComboBox(widget); themeList->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); themeList->addItem(QStringLiteral("Qt")); themeList->addItem(QStringLiteral("Primary Colors")); themeList->addItem(QStringLiteral("Digia")); themeList->addItem(QStringLiteral("Stone Moss")); themeList->addItem(QStringLiteral("Army Blue")); themeList->addItem(QStringLiteral("Retro")); themeList->addItem(QStringLiteral("Ebony")); themeList->addItem(QStringLiteral("Isabelle")); QGroupBox *colorGroupBox = new QGroupBox(QStringLiteral("Custom gradient")); QLinearGradient grBtoY(0, 0, 1, 100); grBtoY.setColorAt(1.0, Qt::black); grBtoY.setColorAt(0.67, Qt::blue); grBtoY.setColorAt(0.33, Qt::red); grBtoY.setColorAt(0.0, Qt::yellow); QPixmap pm(24, 100); QPainter pmp(&pm); pmp.setBrush(QBrush(grBtoY)); pmp.setPen(Qt::NoPen); pmp.drawRect(0, 0, 24, 100); QPushButton *gradientBtoYPB = new QPushButton(widget); gradientBtoYPB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); gradientBtoYPB->setIcon(QIcon(pm)); gradientBtoYPB->setIconSize(QSize(24, 100)); QLinearGradient grGtoR(0, 0, 1, 100); grGtoR.setColorAt(1.0, Qt::darkGreen); grGtoR.setColorAt(0.5, Qt::yellow); grGtoR.setColorAt(0.2, Qt::red); grGtoR.setColorAt(0.0, Qt::darkRed); pmp.setBrush(QBrush(grGtoR)); pmp.drawRect(0, 0, 24, 100); QPushButton *gradientGtoRPB = new QPushButton(widget); gradientGtoRPB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); gradientGtoRPB->setIcon(QIcon(pm)); gradientGtoRPB->setIconSize(QSize(24, 100)); QHBoxLayout *colorHBox = new QHBoxLayout; colorHBox->addWidget(gradientBtoYPB); colorHBox->addWidget(gradientGtoRPB); colorGroupBox->setLayout(colorHBox); vLayout->addWidget(modelGroupBox); vLayout->addWidget(selectionGroupBox); vLayout->addWidget(new QLabel(QStringLiteral("Camera Position"))); vLayout->addWidget(axisCameraSliderZ); vLayout->addWidget(axisCameraSliderY); vLayout->addWidget(new QLabel(QStringLiteral("Theme"))); vLayout->addWidget(themeList); vLayout->addWidget(colorGroupBox); widget->show(); modifier= new SurfaceGraph(graph, widget,parameters); if(!load){ QObject::connect(parent, SIGNAL(plotDataReceived(QList <QByteArray>)), modifier, SLOT(dataHandler(QList <QByteArray>))); QObject::connect(AFM_Scan_3D_RB, SIGNAL (toggled(bool)), this, SLOT(AFMButtonHandler(bool))); QObject::connect(this, SIGNAL (AFMStart()), modifier, SLOT (enableAFMModel())); QObject::connect(this, SIGNAL (AFMDone()), parent, SLOT (sendDone())); QObject::connect(this, SIGNAL (AFMStart()), parent, SLOT (sendGo())); QObject::connect(this, SIGNAL (AFMStart()), parent, SLOT(sendReady()));}
int main(int argc, char **argv) { //! [0] QApplication app(argc, argv); Q3DSurface *graph = new Q3DSurface(); QWidget *container = QWidget::createWindowContainer(graph); //! [0] if (!graph->hasContext()) { QMessageBox msgBox; msgBox.setText("Couldn't initialize the OpenGL context."); msgBox.exec(); return -1; } QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.6)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); //! [1] QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout); vLayout->setAlignment(Qt::AlignTop); //! [1] widget->setWindowTitle(QStringLiteral("Surface example")); QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Model")); QRadioButton *sqrtSinModelRB = new QRadioButton(widget); sqrtSinModelRB->setText(QStringLiteral("Sqrt && Sin")); sqrtSinModelRB->setChecked(false); QRadioButton *heightMapModelRB = new QRadioButton(widget); heightMapModelRB->setText(QStringLiteral("Height Map")); heightMapModelRB->setChecked(false); QVBoxLayout *modelVBox = new QVBoxLayout; modelVBox->addWidget(sqrtSinModelRB); modelVBox->addWidget(heightMapModelRB); modelGroupBox->setLayout(modelVBox); QGroupBox *selectionGroupBox = new QGroupBox(QStringLiteral("Selection Mode")); QRadioButton *modeNoneRB = new QRadioButton(widget); modeNoneRB->setText(QStringLiteral("No selection")); modeNoneRB->setChecked(false); QRadioButton *modeItemRB = new QRadioButton(widget); modeItemRB->setText(QStringLiteral("Item")); modeItemRB->setChecked(false); QRadioButton *modeSliceRowRB = new QRadioButton(widget); modeSliceRowRB->setText(QStringLiteral("Row Slice")); modeSliceRowRB->setChecked(false); QRadioButton *modeSliceColumnRB = new QRadioButton(widget); modeSliceColumnRB->setText(QStringLiteral("Column Slice")); modeSliceColumnRB->setChecked(false); QVBoxLayout *selectionVBox = new QVBoxLayout; selectionVBox->addWidget(modeNoneRB); selectionVBox->addWidget(modeItemRB); selectionVBox->addWidget(modeSliceRowRB); selectionVBox->addWidget(modeSliceColumnRB); selectionGroupBox->setLayout(selectionVBox); QSlider *axisMinSliderX = new QSlider(Qt::Horizontal, widget); axisMinSliderX->setMinimum(0); axisMinSliderX->setTickInterval(1); axisMinSliderX->setEnabled(true); QSlider *axisMaxSliderX = new QSlider(Qt::Horizontal, widget); axisMaxSliderX->setMinimum(1); axisMaxSliderX->setTickInterval(1); axisMaxSliderX->setEnabled(true); QSlider *axisMinSliderZ = new QSlider(Qt::Horizontal, widget); axisMinSliderZ->setMinimum(0); axisMinSliderZ->setTickInterval(1); axisMinSliderZ->setEnabled(true); QSlider *axisMaxSliderZ = new QSlider(Qt::Horizontal, widget); axisMaxSliderZ->setMinimum(1); axisMaxSliderZ->setTickInterval(1); axisMaxSliderZ->setEnabled(true); QComboBox *themeList = new QComboBox(widget); themeList->addItem(QStringLiteral("Qt")); themeList->addItem(QStringLiteral("Primary Colors")); themeList->addItem(QStringLiteral("Digia")); themeList->addItem(QStringLiteral("Stone Moss")); themeList->addItem(QStringLiteral("Army Blue")); themeList->addItem(QStringLiteral("Retro")); themeList->addItem(QStringLiteral("Ebony")); themeList->addItem(QStringLiteral("Isabelle")); QGroupBox *colorGroupBox = new QGroupBox(QStringLiteral("Custom gradient")); QLinearGradient grBtoY(0, 0, 1, 100); grBtoY.setColorAt(1.0, Qt::black); grBtoY.setColorAt(0.67, Qt::blue); grBtoY.setColorAt(0.33, Qt::red); grBtoY.setColorAt(0.0, Qt::yellow); QPixmap pm(24, 100); QPainter pmp(&pm); pmp.setBrush(QBrush(grBtoY)); pmp.setPen(Qt::NoPen); pmp.drawRect(0, 0, 24, 100); QPushButton *gradientBtoYPB = new QPushButton(widget); gradientBtoYPB->setIcon(QIcon(pm)); gradientBtoYPB->setIconSize(QSize(24, 100)); QLinearGradient grGtoR(0, 0, 1, 100); grGtoR.setColorAt(1.0, Qt::darkGreen); grGtoR.setColorAt(0.5, Qt::yellow); grGtoR.setColorAt(0.2, Qt::red); grGtoR.setColorAt(0.0, Qt::darkRed); pmp.setBrush(QBrush(grGtoR)); pmp.drawRect(0, 0, 24, 100); QPushButton *gradientGtoRPB = new QPushButton(widget); gradientGtoRPB->setIcon(QIcon(pm)); gradientGtoRPB->setIconSize(QSize(24, 100)); QHBoxLayout *colorHBox = new QHBoxLayout; colorHBox->addWidget(gradientBtoYPB); colorHBox->addWidget(gradientGtoRPB); colorGroupBox->setLayout(colorHBox); vLayout->addWidget(modelGroupBox); vLayout->addWidget(selectionGroupBox); vLayout->addWidget(new QLabel(QStringLiteral("Column range"))); vLayout->addWidget(axisMinSliderX); vLayout->addWidget(axisMaxSliderX); vLayout->addWidget(new QLabel(QStringLiteral("Row range"))); vLayout->addWidget(axisMinSliderZ); vLayout->addWidget(axisMaxSliderZ); vLayout->addWidget(new QLabel(QStringLiteral("Theme"))); vLayout->addWidget(themeList); vLayout->addWidget(colorGroupBox); widget->show(); SurfaceGraph *modifier = new SurfaceGraph(graph); QObject::connect(heightMapModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableHeightMapModel); QObject::connect(sqrtSinModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableSqrtSinModel); QObject::connect(modeNoneRB, &QRadioButton::toggled, modifier, &SurfaceGraph::toggleModeNone); QObject::connect(modeItemRB, &QRadioButton::toggled, modifier, &SurfaceGraph::toggleModeItem); QObject::connect(modeSliceRowRB, &QRadioButton::toggled, modifier, &SurfaceGraph::toggleModeSliceRow); QObject::connect(modeSliceColumnRB, &QRadioButton::toggled, modifier, &SurfaceGraph::toggleModeSliceColumn); QObject::connect(axisMinSliderX, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustXMin); QObject::connect(axisMaxSliderX, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustXMax); QObject::connect(axisMinSliderZ, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustZMin); QObject::connect(axisMaxSliderZ, &QSlider::valueChanged, modifier, &SurfaceGraph::adjustZMax); QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeTheme(int))); QObject::connect(gradientBtoYPB, &QPushButton::pressed, modifier, &SurfaceGraph::setBlackToYellowGradient); QObject::connect(gradientGtoRPB, &QPushButton::pressed, modifier, &SurfaceGraph::setGreenToRedGradient); modifier->setAxisMinSliderX(axisMinSliderX); modifier->setAxisMaxSliderX(axisMaxSliderX); modifier->setAxisMinSliderZ(axisMinSliderZ); modifier->setAxisMaxSliderZ(axisMaxSliderZ); sqrtSinModelRB->setChecked(true); modeItemRB->setChecked(true); themeList->setCurrentIndex(2); return app.exec(); }
int main(int argc, char **argv) { QApplication app(argc, argv); Q3DSurface *graph = new Q3DSurface(); QWidget *container = QWidget::createWindowContainer(graph); QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.6)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); hLayout->addLayout(vLayout); hLayout->addWidget(container, 1); vLayout->setAlignment(Qt::AlignTop); widget->setWindowTitle(QStringLiteral("Интерполяция")); QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Графики")); QRadioButton *InitPlotModelRB = new QRadioButton(widget); InitPlotModelRB->setText(QStringLiteral("Начальный график")); InitPlotModelRB->setChecked(false); QRadioButton *InterpModelRB = new QRadioButton(widget); InterpModelRB->setText(QStringLiteral("Интерполяция")); InterpModelRB->setChecked(false); QRadioButton *InitInterpModelRB = new QRadioButton(widget); InitInterpModelRB->setText(QStringLiteral("Изначальный и интерполяция")); InitInterpModelRB->setChecked(false); QRadioButton *ResidModelRB = new QRadioButton(widget); ResidModelRB->setText(QStringLiteral("Невязка")); ResidModelRB->setChecked(false); QVBoxLayout *modelVBox = new QVBoxLayout; modelVBox->addWidget(InitPlotModelRB); modelVBox->addWidget(InterpModelRB); modelVBox->addWidget(InitInterpModelRB); modelVBox->addWidget(ResidModelRB); modelGroupBox->setLayout(modelVBox); QLabel *countN = new QLabel(widget); QLabel *countM = new QLabel(widget); vLayout->addWidget(modelGroupBox); vLayout->addWidget(new QLabel(QStringLiteral("точек на оси Х"))); vLayout->addWidget(countN); vLayout->addWidget(new QLabel(QStringLiteral("точек на оси Z"))); vLayout->addWidget(countM); vLayout->addWidget((new QLabel(QStringLiteral("1-графики\n" "2-больше точек на Х\n" "3-больше точек на Z\n" "4-увеличить диапазон X\n" "5-уменьшить диапазон X\n" "6-увеличить диапазон Z\n" "7-уменьшить диапазон Z\n" "8-меньше точек на X\n" "9-меньше точек на Z")))); widget->show(); SurfaceGraph *modifier = new SurfaceGraph(graph); modifier->key1 = new QShortcut(widget); modifier->key1->setKey(Qt::Key_1); QObject::connect(modifier->key1, SIGNAL(activated()), modifier, SLOT(slotShortcut1())); modifier->key2 = new QShortcut(widget); modifier->key2->setKey(Qt::Key_2); QObject::connect(modifier->key2, SIGNAL(activated()), modifier, SLOT(slotShortcut2())); modifier->key3 = new QShortcut(widget); modifier->key3->setKey(Qt::Key_3); QObject::connect(modifier->key3, SIGNAL(activated()), modifier, SLOT(slotShortcut3())); modifier->key4 = new QShortcut(widget); modifier->key4->setKey(Qt::Key_4); QObject::connect(modifier->key4, SIGNAL(activated()), modifier, SLOT(slotShortcut4())); modifier->key5 = new QShortcut(widget); modifier->key5->setKey(Qt::Key_5); QObject::connect(modifier->key5, SIGNAL(activated()), modifier, SLOT(slotShortcut5())); modifier->key6 = new QShortcut(widget); modifier->key6->setKey(Qt::Key_6); QObject::connect(modifier->key6, SIGNAL(activated()), modifier, SLOT(slotShortcut6())); modifier->key7 = new QShortcut(widget); modifier->key7->setKey(Qt::Key_7); QObject::connect(modifier->key7, SIGNAL(activated()), modifier, SLOT(slotShortcut7())); modifier->key8 = new QShortcut(widget); modifier->key8->setKey(Qt::Key_8); QObject::connect(modifier->key8, SIGNAL(activated()), modifier, SLOT(slotShortcut8())); modifier->key9 = new QShortcut(widget); modifier->key9->setKey(Qt::Key_9); QObject::connect(modifier->key9, SIGNAL(activated()), modifier, SLOT(slotShortcut9())); QObject::connect(InitPlotModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableInitPlotModel); QObject::connect(InterpModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableInterpModel); QObject::connect(InitInterpModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableInitInterpModel); QObject::connect(ResidModelRB, &QRadioButton::toggled, modifier, &SurfaceGraph::enableResidModel); InitPlotModelRB->setChecked(true); modifier->setCount(countN, countM); modifier->setKol(InitPlotModelRB,InterpModelRB, InitInterpModelRB,ResidModelRB); //изначально выставим точки return app.exec(); }
Step2::Step2(Wizard *wizard,const QHash<QString,Input*> &modelData) : m_wizard(wizard), m_modelData(modelData) { QRadioButton *r; QVBoxLayout *layout = new QVBoxLayout(this); //--------------------------------------------------- m_extractModeGroup = new QButtonGroup(this); m_extractMode = new QGroupBox(this); m_extractMode->setTitle(tr("Select the desired extraction mode:")); QGridLayout *gbox = new QGridLayout( m_extractMode ); r = new QRadioButton(tr("Documented entities only")); r->setChecked(true); m_extractModeGroup->addButton(r, 0); gbox->addWidget(r,1,0); // 1 -> EXTRACT_ALL = NO r = new QRadioButton(tr("All Entities")); m_extractModeGroup->addButton(r, 1); gbox->addWidget(r,2,0); // 2 -> EXTRACT_ALL = YES m_crossRef = new QCheckBox(m_extractMode); m_crossRef->setText(tr("Include cross-referenced source code in the output")); // m_crossRef -> SOURCE_BROWSER = YES/NO gbox->addWidget(m_crossRef,3,0); layout->addWidget(m_extractMode); //--------------------------------------------------- QFrame *f = new QFrame( this ); f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); layout->addWidget(f); m_optimizeLangGroup = new QButtonGroup(this); m_optimizeLang = new QGroupBox(this); m_optimizeLang->setTitle(tr("Select programming language to optimize the results for")); gbox = new QGridLayout( m_optimizeLang ); r = new QRadioButton(m_optimizeLang); r->setText(tr("Optimize for C++ output")); r->setChecked(true); m_optimizeLangGroup->addButton(r, 0); // 0 -> OPTIMIZE_OUTPUT_FOR_C = NO // OPTIMIZE_OUTPUT_JAVA = NO // OPTIMIZE_FOR_FORTRAN = NO // OPTIMIZE_OUTPUT_VHDL = NO // CPP_CLI_SUPPORT = NO // HIDE_SCOPE_NAMES = NO gbox->addWidget(r,0,0); r = new QRadioButton(tr("Optimize for C++/CLI output")); gbox->addWidget(r,1,0); m_optimizeLangGroup->addButton(r, 1); // 1 -> OPTIMIZE_OUTPUT_FOR_C = NO // OPTIMIZE_OUTPUT_JAVA = NO // OPTIMIZE_FOR_FORTRAN = NO // OPTIMIZE_OUTPUT_VHDL = NO // CPP_CLI_SUPPORT = YES // HIDE_SCOPE_NAMES = NO r = new QRadioButton(tr("Optimize for Java or C# output")); m_optimizeLangGroup->addButton(r, 2); // 2 -> OPTIMIZE_OUTPUT_FOR_C = NO // OPTIMIZE_OUTPUT_JAVA = YES // OPTIMIZE_FOR_FORTRAN = NO // OPTIMIZE_OUTPUT_VHDL = NO // CPP_CLI_SUPPORT = NO // HIDE_SCOPE_NAMES = NO gbox->addWidget(r,2,0); r = new QRadioButton(tr("Optimize for C or PHP output")); m_optimizeLangGroup->addButton(r, 3); // 3 -> OPTIMIZE_OUTPUT_FOR_C = YES // OPTIMIZE_OUTPUT_JAVA = NO // OPTIMIZE_FOR_FORTRAN = NO // OPTIMIZE_OUTPUT_VHDL = NO // CPP_CLI_SUPPORT = NO // HIDE_SCOPE_NAMES = YES gbox->addWidget(r,3,0); r = new QRadioButton(tr("Optimize for Fortran output")); m_optimizeLangGroup->addButton(r, 4); // 4 -> OPTIMIZE_OUTPUT_FOR_C = NO // OPTIMIZE_OUTPUT_JAVA = NO // OPTIMIZE_FOR_FORTRAN = YES // OPTIMIZE_OUTPUT_VHDL = NO // CPP_CLI_SUPPORT = NO // HIDE_SCOPE_NAMES = NO gbox->addWidget(r,4,0); r = new QRadioButton(tr("Optimize for VHDL output")); m_optimizeLangGroup->addButton(r, 5); // 5 -> OPTIMIZE_OUTPUT_FOR_C = NO // OPTIMIZE_OUTPUT_JAVA = NO // OPTIMIZE_FOR_FORTRAN = NO // OPTIMIZE_OUTPUT_VHDL = YES // CPP_CLI_SUPPORT = NO // HIDE_SCOPE_NAMES = NO gbox->addWidget(r,5,0); layout->addWidget(m_optimizeLang); layout->addStretch(1); connect(m_crossRef,SIGNAL(stateChanged(int)), SLOT(changeCrossRefState(int))); connect(m_optimizeLangGroup,SIGNAL(buttonClicked(int)), SLOT(optimizeFor(int))); connect(m_extractModeGroup,SIGNAL(buttonClicked(int)), SLOT(extractMode(int))); }
TimeWeatherWidget::TimeWeatherWidget(MainObject *mOb, QWidget *parent) : QWidget(parent) { mainObject = mOb; QHBoxLayout *mainLayout = new QHBoxLayout(); setLayout(mainLayout); //=============================================================== // Left Column with Time / Season //=============================================================== QVBoxLayout *layTimeSeason = new QVBoxLayout(); mainLayout->addLayout(layTimeSeason, 1); //=============================================================== // Time group QStringList time_vals; //= are the values time_vals << "real" << "dawn" << "morning" << "noon" << "afternoon" << "dusk" << "evening" << "midnight"; QStringList time_labels; //= are the labels time_labels << tr("Real time") << tr("Dawn") << tr("Morning") << tr("Noon") << tr("Afternoon") << tr("Dusk") << tr("Evening") << tr("Midnight"); XGroupVBox *grpBoxTime = new XGroupVBox(tr("Time")); layTimeSeason->addWidget(grpBoxTime); buttonGroupTime = new QButtonGroup(this); buttonGroupTime->setExclusive(true); connect(buttonGroupTime, SIGNAL(buttonClicked(int)), this, SLOT(on_time_clicked()) ); for(int i=0; i < time_vals.size(); i++){ QRadioButton *butt = new QRadioButton(); butt->setText(time_labels.at(i)); butt->setProperty("value", QVariant(time_vals.at(i))); grpBoxTime->addWidget(butt); buttonGroupTime->addButton(butt, i); } buttonGroupTime->button(0)->setChecked(true); //=============================================================== // Season group QStringList season_vals; //= values season_vals << "winter" << "summer"; QStringList season_labels; // = labels season_labels << tr("Winter") << tr("Summer"); XGroupVBox *grpBoxSeason = new XGroupVBox(tr("Season")); layTimeSeason->addWidget(grpBoxSeason); buttonGroupSeason = new QButtonGroup(this); buttonGroupSeason->setExclusive(true); connect(buttonGroupSeason, SIGNAL(buttonClicked(int)), this, SLOT(on_season_clicked(int)) ); for(int i=0; i < season_vals.size(); i++){ QRadioButton *buttS = new QRadioButton(); buttS->setText(season_labels.at(i)); buttS->setProperty("value", QVariant(season_vals.at(i).toLower())); grpBoxSeason->addWidget(buttS); buttonGroupSeason->addButton(buttS, i); } buttonGroupSeason->button(0)->setChecked(true); //= Add some stretch to column bottom layTimeSeason->addStretch(100); //= Add A Spacer in Middle Column mainLayout->addStretch(1); //=============================================================== // Right Column with Metar //=============================================================== QVBoxLayout *laymetar = new QVBoxLayout(); mainLayout->addLayout(laymetar, 2); //=============================================================== // Metar group QStringList metar_vals; //= values metar_vals << "none" << "live" << "custom"; QStringList metar_labels; //= labels metar_labels << tr("None (default weather)") << tr("Fetch METAR data live") << tr("Set static METAR below"); XGroupVBox *grpBoxMetar = new XGroupVBox(tr("METAR")); laymetar->setAlignment(Qt::AlignTop); laymetar->addWidget(grpBoxMetar); buttonGroupMetar = new QButtonGroup(this); buttonGroupMetar->setExclusive(true); connect(buttonGroupMetar, SIGNAL(buttonClicked(int)), this, SLOT(on_weather())); for(int i=0; i < metar_vals.size(); i++){ QRadioButton *buttM = new QRadioButton(); buttM->setText(metar_labels.at(i)); buttM->setProperty("value", QVariant(metar_vals.at(i))); grpBoxMetar->addWidget(buttM); buttonGroupMetar->addButton(buttM, i); } buttonGroupMetar->button(0)->setChecked(true); txtMetar = new QPlainTextEdit(); txtMetar->setMaximumHeight(80); grpBoxMetar->addWidget(txtMetar); laymetar->addStretch(20); connect(this, SIGNAL(setx(QString,bool,QString)), mainObject->X, SLOT(set_option(QString,bool,QString)) ); connect(mainObject->X, SIGNAL(upx(QString,bool,QString)), this, SLOT(on_upx(QString,bool,QString))); }
void PThresholdDialog::createWidgets() { setWindowTitle("Threshold Dialog"); QGroupBox *gbox = new QGroupBox(tr("threshold type")); QRadioButton *lowerButton = new QRadioButton(gbox); lowerButton->setText(tr("lower")); QRadioButton *betweenButton = new QRadioButton(gbox); betweenButton->setText(tr("between")); QRadioButton *upperButton = new QRadioButton(gbox); upperButton->setText(tr("upper")); lowerButton->setChecked(true); // Default; QHBoxLayout *choiceBox = new QHBoxLayout(gbox); choiceBox->addWidget(lowerButton); choiceBox->addWidget(betweenButton); choiceBox->addWidget(upperButton); connect(lowerButton, SIGNAL(clicked()), this, SLOT(thresholdLower())); connect(betweenButton, SIGNAL(clicked()), this, SLOT(thresholdBetween())); connect(upperButton, SIGNAL(clicked()), this, SLOT(thresholdUpper())); QLabel *upperRangeLabel1 = new QLabel("upper"); QLabel *upperRangeLabel2 = new QLabel("range"); upperMinBox = new QLineEdit; upperMinBox->setMaxLength(5); upperMinBox->setFixedWidth(50); upperMinBox->setText(QString("%1").arg(upperMin)); connect(upperMinBox, SIGNAL(textEdited(const QString &)), this, SLOT(setUpperMin(const QString &))); upperMaxBox = new QLineEdit; upperMaxBox->setMaxLength(5); upperMaxBox->setFixedWidth(50); upperMaxBox->setText(QString("%1").arg(upperMax)); connect(upperMaxBox, SIGNAL(textEdited(const QString &)), this, SLOT(setUpperMax(const QString &))); QHBoxLayout *upperRangeBox = new QHBoxLayout; upperRangeBox->addWidget(upperMinBox); upperRangeBox->addStretch(); upperRangeBox->addWidget(upperMaxBox); QLabel *upperLabel = new QLabel("upper"); upperBox = new QSpinBox; upperBox->setRange(upperMin, upperMax); upperSlider = new QSlider(Qt::Horizontal); upperSlider->setRange(upperMin, upperMax); connect(upperBox, SIGNAL(valueChanged(int)), upperSlider, SLOT(setValue(int))); connect(upperSlider, SIGNAL(valueChanged(int)), upperBox, SLOT(setValue(int))); connect(upperBox, SIGNAL(valueChanged(int)), this, SLOT(setUpper(int))); connect(upperSlider, SIGNAL(valueChanged(int)), this, SLOT(setUpper(int))); upperBox->setValue(upperMax); QLabel *lowerRangeLabel1 = new QLabel("lower"); QLabel *lowerRangeLabel2 = new QLabel("range"); lowerMinBox = new QLineEdit; lowerMinBox->setMaxLength(5); lowerMinBox->setFixedWidth(50); lowerMinBox->setText(QString("%1").arg(lowerMin)); connect(lowerMinBox, SIGNAL(textEdited(const QString &)), this, SLOT(setLowerMin(const QString &))); lowerMaxBox = new QLineEdit; lowerMaxBox->setMaxLength(5); lowerMaxBox->setFixedWidth(50); lowerMaxBox->setText(QString("%1").arg(lowerMax)); connect(lowerMaxBox, SIGNAL(textEdited(const QString &)), this, SLOT(setLowerMax(const QString &))); QHBoxLayout *lowerRangeBox = new QHBoxLayout; lowerRangeBox->addWidget(lowerMinBox); lowerRangeBox->addStretch(); lowerRangeBox->addWidget(lowerMaxBox); QLabel *lowerLabel = new QLabel("lower"); lowerBox = new QSpinBox; lowerBox->setRange(lowerMin, lowerMax); lowerSlider = new QSlider(Qt::Horizontal); lowerSlider->setRange(lowerMin, lowerMax); connect(lowerBox, SIGNAL(valueChanged(int)), lowerSlider, SLOT(setValue(int))); connect(lowerSlider, SIGNAL(valueChanged(int)), lowerBox, SLOT(setValue(int))); connect(lowerBox, SIGNAL(valueChanged(int)), this, SLOT(setLower(int))); connect(lowerSlider, SIGNAL(valueChanged(int)), this, SLOT(setLower(int))); lowerBox->setValue(lower); QLabel *fillLabel = new QLabel("fill in"); fillBox = new QLineEdit; fillBox->setMaxLength(5); fillBox->setFixedWidth(50); connect(fillBox, SIGNAL(textEdited(const QString &)), this, SLOT(setFill(const QString &))); fillBox->setText("-500"); QPushButton *closeButton = new QPushButton("close"); connect(closeButton, SIGNAL(clicked()), this, SLOT(hide())); connect(closeButton, SIGNAL(clicked()), this, SIGNAL(closed())); QHBoxLayout *closeBox = new QHBoxLayout; closeBox->addStretch(); closeBox->addWidget(closeButton); QGridLayout *grid = new QGridLayout; grid->addWidget(upperRangeLabel1, 0, 0); grid->addWidget(upperRangeLabel2, 0, 1); grid->addLayout(upperRangeBox, 0, 2); grid->addWidget(upperLabel, 1, 0); grid->addWidget(upperBox, 1, 1); grid->addWidget(upperSlider, 1, 2); grid->addWidget(lowerRangeLabel1, 2, 0); grid->addWidget(lowerRangeLabel2, 2, 1); grid->addLayout(lowerRangeBox, 2, 2); grid->addWidget(lowerLabel, 3, 0); grid->addWidget(lowerBox, 3, 1); grid->addWidget(lowerSlider, 3, 2); grid->addWidget(fillLabel, 4, 0); grid->addWidget(fillBox, 4, 1); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(gbox); mainLayout->addLayout(grid); mainLayout->addSpacing(10); mainLayout->addLayout(closeBox); setLayout(mainLayout); setFixedSize(300, 300); }
AirportsWidget::AirportsWidget(MainObject *mOb, QWidget *parent) : QWidget(parent) { mainObject = mOb; //* Main Layout QGridLayout *mainLayout = new QGridLayout(); setLayout(mainLayout); mainLayout->setSpacing(10); int m = 10; mainLayout->setContentsMargins(m,m,m,m); //===================================== //** Top Startup Option Buttons QHBoxLayout *layoutTop = new QHBoxLayout(); mainLayout->addLayout(layoutTop,0,0,1,2); buttonGroupUse = new QButtonGroup(this); buttonGroupUse->setExclusive(true); connect(buttonGroupUse, SIGNAL(buttonClicked(int)), this, SLOT(on_buttonGroupUse())); QRadioButton *radioButtonUseDefault = new QRadioButton(tr("Default (KSFO)")); radioButtonUseDefault->setChecked(true); layoutTop->addWidget(radioButtonUseDefault); buttonGroupUse->addButton(radioButtonUseDefault, USE_DEFAULT); QRadioButton *radioButtonUseAirport = new QRadioButton(tr("Start at Airport")); layoutTop->addWidget(radioButtonUseAirport); buttonGroupUse->addButton(radioButtonUseAirport, USE_AIRPORT); QRadioButton *radioButtonUseCoordinates = new QRadioButton(tr("Start at Coordinates")); layoutTop->addWidget(radioButtonUseCoordinates); buttonGroupUse->addButton(radioButtonUseCoordinates, USE_COORDINATES); layoutTop->addStretch(10); //================================================================================= //* Airport Details groupBoxAirport = new QGroupBox(this); groupBoxAirport->setTitle("Airport Details"); mainLayout->addWidget(groupBoxAirport, 1, 0); QVBoxLayout *airportsContainerLayout = new QVBoxLayout(); groupBoxAirport->setLayout(airportsContainerLayout); airportsContainerLayout->setContentsMargins(10,10,10,10); airportsContainerLayout->setSpacing(0); //================================================================== //** Airports Filter and Actions Top Bar QHBoxLayout *layoutAptTopBar = new QHBoxLayout(); layoutAptTopBar->setContentsMargins(0,0,0,0); layoutAptTopBar->setSpacing(10); airportsContainerLayout->addLayout(layoutAptTopBar); //** Filter Code layoutAptTopBar->addWidget(new QLabel(tr("Filter").append(":"))); //** Filter Buttons - TODO buttonGroupFilter = new QButtonGroup(this); buttonGroupFilter->setExclusive(true); //** Aiport Code Filter QRadioButton *buttCode = new QRadioButton(); buttCode->setText("Code"); buttCode->setProperty("filter_column_idx", QVariant(CA_CODE)); buttCode->setChecked(true); layoutAptTopBar->addWidget(buttCode); buttonGroupFilter->addButton(buttCode, 0); //** Airport Name Filter QRadioButton *buttName = new QRadioButton(); buttName->setText("Name"); buttName->setProperty("filter_column_idx", QVariant(CA_NAME)); layoutAptTopBar->addWidget(buttName); buttonGroupFilter->addButton(buttName, 1); //** Find Airport Text txtAirportsFilter = new QLineEdit(); layoutAptTopBar->addWidget(txtAirportsFilter); txtAirportsFilter->setFixedWidth(100); connect( txtAirportsFilter, SIGNAL(textChanged(QString)), this, SLOT(on_update_airports_filter()) ); layoutAptTopBar->addStretch(20); /* DEAD for now QPushButton *buttonImportAirports = new QPushButton(this); layoutAptTopBar->addWidget(buttonImportAirports); buttonImportAirports->setText("Reload"); buttonImportAirports->setToolTip("Scan directories and reload cache"); buttonImportAirports->setIcon(QIcon(":/icon/import")); buttonImportAirports->setFlat(true); connect(buttonImportAirports, SIGNAL(clicked()), this, SLOT(on_import_aptdat_clicked()) ); */ QPushButton *buttonRefreshAirports = new QPushButton(this); layoutAptTopBar->addWidget(buttonRefreshAirports); buttonRefreshAirports->setText("Import"); buttonRefreshAirports->setToolTip("Scan directories and reload cache"); buttonRefreshAirports->setIcon(QIcon(":/icon/import")); buttonRefreshAirports->setFlat(true); connect(buttonRefreshAirports, SIGNAL(clicked()), this, SLOT(on_rescan_xml_clicked()) ); //*============================================================================== //** Airports/Runways Splitter QSplitter *splitter = new QSplitter(this); airportsContainerLayout->addWidget(splitter); //=== Airport Widget + Layout QWidget *airportWidget = new QWidget(); splitter->addWidget(airportWidget); QVBoxLayout *airportsLayout = new QVBoxLayout(); airportsLayout->setContentsMargins(0,0,0,0); airportsLayout->setSpacing(0); airportWidget->setLayout(airportsLayout); /* ======== NOTE ============ # The Airports tree is a treeView ## with a model/proxt to enable filtersing ## and the columns constants a CA_ # The Airport Info is a treeWidget ## uses CI_ as the column constants */ //============================================== //** Airport Models model = new QStandardItemModel(this); model->setColumnCount(2); QStringList headerLabelsList; headerLabelsList << tr("Code") << tr("Name"); model->setHorizontalHeaderLabels(headerLabelsList); proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(model); proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); proxyModel->setFilterKeyColumn( CA_NAME ); //============================================== //** TreeView aiports treeViewAirports = new QTreeView(this); airportsLayout->addWidget(treeViewAirports, 1, 0); treeViewAirports->setModel(proxyModel); treeViewAirports->setUniformRowHeights(true); treeViewAirports->setAlternatingRowColors(true); treeViewAirports->setRootIsDecorated(false); treeViewAirports->setSortingEnabled(true); treeViewAirports->sortByColumn(CA_NAME, Qt::AscendingOrder); treeViewAirports->setSelectionMode(QAbstractItemView::SingleSelection); treeViewAirports->setSelectionBehavior(QAbstractItemView::SelectRows); treeViewAirports->setEditTriggers(QAbstractItemView::NoEditTriggers); //** Headers and columns treeViewAirports->header()->setStretchLastSection(true); treeViewAirports->setColumnWidth(CA_CODE, 80); treeViewAirports->setColumnWidth(CA_NAME, 50); connect( treeViewAirports->selectionModel(), SIGNAL( currentRowChanged(QModelIndex,QModelIndex) ), this, SLOT( on_airport_tree_selected(QModelIndex,QModelIndex) ) ); //* StatusBar for Airports statusBarAirports = new QStatusBar(); statusBarAirports->setSizeGripEnabled(false); airportsLayout->addWidget(statusBarAirports); statusBarAirports->showMessage("Idle"); //======================================================== //** Airport Info Widget QWidget *airportInfoWidget = new QWidget(); splitter->addWidget(airportInfoWidget); QVBoxLayout *airportInfoLayout = new QVBoxLayout(); airportInfoLayout->setContentsMargins(0,0,0,0); airportInfoLayout->setSpacing(0); airportInfoWidget->setLayout(airportInfoLayout); //========================================================= //* Airport Info TreeWidget treeWidgetAirportInfo = new QTreeWidget(); airportInfoLayout->addWidget(treeWidgetAirportInfo, 3); treeWidgetAirportInfo->setAlternatingRowColors(true); treeWidgetAirportInfo->setRootIsDecorated(true); QTreeWidgetItem *headerItem = treeWidgetAirportInfo->headerItem(); headerItem->setText(CI_NODE, tr("Startup Position")); headerItem->setText(1, tr("Width")); headerItem->setText(2, tr("Length")); headerItem->setText(3, tr("Lat")); headerItem->setText(4, tr("Lng")); headerItem->setText(5, tr("Alignment")); //treeWidgetAirportInfo->setColumnHidden(1,true); //treeWidgetAirportInfo->setColumnHidden(2,true); //treeWidgetAirportInfo->setColumnHidden(3,true); //treeWidgetAirportInfo->setColumnHidden(4,true); //treeWidgetAirportInfo->setColumnHidden(5,true); statusBarAirportInfo = new QStatusBar(); statusBarAirportInfo->setSizeGripEnabled(false); airportInfoLayout->addWidget(statusBarAirportInfo); statusBarAirportInfo->showMessage(""); splitter->setStretchFactor(0, 2); splitter->setStretchFactor(1, 2); //======================================================================================================== //** Use Coordinates //==================================================================== groupBoxUseCoordinates = new QGroupBox(this); groupBoxUseCoordinates->setTitle("Coordinates"); groupBoxUseCoordinates->setMaximumWidth(300); mainLayout->addWidget(groupBoxUseCoordinates, 1, 2); QVBoxLayout *layoutCoordinates = new QVBoxLayout(); groupBoxUseCoordinates->setLayout(layoutCoordinates); int space = 5; layoutCoordinates->addWidget(new QLabel(tr("Latitude (negative is west)"))); txtLat = new QLineEdit(); layoutCoordinates->addWidget(txtLat); layoutCoordinates->addSpacing(space); layoutCoordinates->addWidget(new QLabel(tr("Longtitude (negative is south)"))); txtLng = new QLineEdit(); layoutCoordinates->addWidget(txtLng); layoutCoordinates->addSpacing(space); layoutCoordinates->addWidget(new QLabel(tr("Altitude"))); txtAltitude = new QLineEdit(); layoutCoordinates->addWidget(txtAltitude); layoutCoordinates->addSpacing(space); layoutCoordinates->addWidget(new QLabel(tr("Heading"))); txtHeading = new QLineEdit(); layoutCoordinates->addWidget(txtHeading); layoutCoordinates->addSpacing(space); layoutCoordinates->addWidget(new QLabel(tr("Roll"))); txtRoll = new QLineEdit(); layoutCoordinates->addWidget(txtRoll); layoutCoordinates->addSpacing(space); layoutCoordinates->addWidget(new QLabel(tr("Pitch"))); txtPitch = new QLineEdit(); layoutCoordinates->addWidget(txtPitch); layoutCoordinates->addSpacing(space); layoutCoordinates->addWidget(new QLabel(tr("Airspeed"))); txtAirspeed = new QLineEdit(); layoutCoordinates->addWidget(txtAirspeed); layoutCoordinates->addStretch(20); //on_buttonGroupUse(); connect(buttonGroupFilter, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(on_update_airports_filter()) ); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; PaintedWidget view; //view.setMouseTracking(false); QPushButton clear_btn(&view); clear_btn.setText("Clear"); //clear_btn.show(); QObject::connect(&clear_btn,&QPushButton::clicked,&view,&PaintedWidget::clear); QObject::connect(&clear_btn,&QPushButton::clicked,&view,&PaintedWidget::clickupdate); QPushButton car_btn(&view); car_btn.setText("Start");//开始按钮 //QObject::connect(&car_btn,&QPushButton::clicked,&view,&PaintedWidget::animation); QObject::connect(&car_btn,&QPushButton::clicked,&view,&PaintedWidget::animationStart); //计算总长的按钮 QPushButton finish_btn(&view); finish_btn.setText("FinishPainting"); QObject::connect(&finish_btn,&QPushButton::clicked,&view,&PaintedWidget::Widget_Length); Set o_set; // speed 和duration成反比。。。 QLabel *labelSpeed = new QLabel("Speed"); QSlider *sliderSpeed = new QSlider(Qt::Horizontal,&view); sliderSpeed->setRange(0,20); sliderSpeed->setValue(9); void (QSpinBox::*spinBoxSignal)(int) = &QSpinBox::valueChanged; //QObject::connect(sliderSpeed,&QSlider::valueChanged,&view,&PaintedWidget::setDuration); QObject::connect(sliderSpeed,&QSlider::valueChanged,&o_set,&Set::setDurationValue); //QObject::connect(boxGrain,spinBoxSignal,&view,&PaintedWidget::Widget_Length); QSpinBox *boxSpeed = new QSpinBox(&view); boxSpeed->setRange(0,20); boxSpeed->setValue(9); QObject::connect(boxSpeed,spinBoxSignal,sliderSpeed,&QSlider::valueChanged); QObject::connect(sliderSpeed,&QSlider::valueChanged,boxSpeed,&QSpinBox::setValue); //输入弧长的box QSlider*sliderLength= new QSlider(Qt::Horizontal,&view); sliderLength->setRange(0,300); sliderLength->setValue(50); QSpinBox *boxLength = new QSpinBox(&view); boxLength->setRange(0,300); boxLength->setValue(50); QObject::connect(boxLength,spinBoxSignal,sliderLength,&QSlider::valueChanged); QObject::connect(sliderLength,&QSlider::valueChanged,boxLength,&QSpinBox::setValue); QObject::connect(boxLength,spinBoxSignal,&view,&PaintedWidget::DividSpline); //QObject::connect(boxLength,spinBoxSignal,&view,&PaintedWidget::sliderupdate); QLabel *labelLength = new QLabel("lengthunit"); //匀速 变速单选按钮 QRadioButton *uniform = new QRadioButton(&view); uniform->setText("constantSpeed"); uniform->setChecked(true); QRadioButton *variable = new QRadioButton(&view); variable->setText("freeSpeed"); QObject::connect(uniform,&QRadioButton::toggled,&view,&PaintedWidget::motion_choose1); QObject::connect(variable,&QRadioButton::toggled,&view,&PaintedWidget::motion_choose0); QGridLayout* rightlayout = new QGridLayout; rightlayout->addWidget(uniform,1,0); rightlayout->addWidget(variable,1,1); // rightlayout->addWidget(car,1,2); rightlayout->addWidget(labelSpeed,1,3); rightlayout->addWidget(sliderSpeed,1,4); rightlayout->addWidget(boxSpeed,1,5); rightlayout->addWidget(&car_btn,3,4); rightlayout->addWidget(&finish_btn,3,0); rightlayout->addWidget(&clear_btn,3,5); rightlayout->addWidget(labelLength,3,1); rightlayout->addWidget(boxLength,3,3); rightlayout->addWidget(sliderLength,3,2);//单位弧长输入 //rightlayout->addWidget(buttonGroup,5,0,2,5); //w.setLayout(rightlayout); QVBoxLayout *mainlayout = new QVBoxLayout; mainlayout->addWidget(&view); mainlayout->addLayout(rightlayout); mainlayout->setStretchFactor(&view,1); mainlayout->setStretchFactor(rightlayout,0); w.setLayout(mainlayout); // QHBoxLayout* mainlayout = new QHBoxLayout(&view); // mainlayout->addWidget(); //test timer = new QTimer(&view); QObject::connect(timer,&QTimer::timeout,&view,&PaintedWidget::animationControl); timer->start(100); // view.show(); w.show(); return a.exec(); }
void PathStrokeControls::createCommonControls(QWidget* parent) { m_capGroup = new QGroupBox(parent); m_capGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); QRadioButton *flatCap = new QRadioButton(m_capGroup); QRadioButton *squareCap = new QRadioButton(m_capGroup); QRadioButton *roundCap = new QRadioButton(m_capGroup); m_capGroup->setTitle(tr("Cap Style")); flatCap->setText(tr("Flat")); squareCap->setText(tr("Square")); roundCap->setText(tr("Round")); flatCap->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); squareCap->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); roundCap->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_joinGroup = new QGroupBox(parent); m_joinGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); QRadioButton *bevelJoin = new QRadioButton(m_joinGroup); QRadioButton *miterJoin = new QRadioButton(m_joinGroup); QRadioButton *roundJoin = new QRadioButton(m_joinGroup); m_joinGroup->setTitle(tr("Join Style")); bevelJoin->setText(tr("Bevel")); miterJoin->setText(tr("Miter")); roundJoin->setText(tr("Round")); m_styleGroup = new QGroupBox(parent); m_styleGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); QRadioButton *solidLine = new QRadioButton(m_styleGroup); QRadioButton *dashLine = new QRadioButton(m_styleGroup); QRadioButton *dotLine = new QRadioButton(m_styleGroup); QRadioButton *dashDotLine = new QRadioButton(m_styleGroup); QRadioButton *dashDotDotLine = new QRadioButton(m_styleGroup); QRadioButton *customDashLine = new QRadioButton(m_styleGroup); m_styleGroup->setTitle(tr("Pen Style")); QPixmap line_solid(":res/images/line_solid.png"); solidLine->setIcon(line_solid); solidLine->setIconSize(line_solid.size()); QPixmap line_dashed(":res/images/line_dashed.png"); dashLine->setIcon(line_dashed); dashLine->setIconSize(line_dashed.size()); QPixmap line_dotted(":res/images/line_dotted.png"); dotLine->setIcon(line_dotted); dotLine->setIconSize(line_dotted.size()); QPixmap line_dash_dot(":res/images/line_dash_dot.png"); dashDotLine->setIcon(line_dash_dot); dashDotLine->setIconSize(line_dash_dot.size()); QPixmap line_dash_dot_dot(":res/images/line_dash_dot_dot.png"); dashDotDotLine->setIcon(line_dash_dot_dot); dashDotDotLine->setIconSize(line_dash_dot_dot.size()); customDashLine->setText(tr("Custom")); int fixedHeight = bevelJoin->sizeHint().height(); solidLine->setFixedHeight(fixedHeight); dashLine->setFixedHeight(fixedHeight); dotLine->setFixedHeight(fixedHeight); dashDotLine->setFixedHeight(fixedHeight); dashDotDotLine->setFixedHeight(fixedHeight); m_pathModeGroup = new QGroupBox(parent); m_pathModeGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); QRadioButton *curveMode = new QRadioButton(m_pathModeGroup); QRadioButton *lineMode = new QRadioButton(m_pathModeGroup); m_pathModeGroup->setTitle(tr("Line Style")); curveMode->setText(tr("Curves")); lineMode->setText(tr("Lines")); // Layouts QVBoxLayout *capGroupLayout = new QVBoxLayout(m_capGroup); capGroupLayout->addWidget(flatCap); capGroupLayout->addWidget(squareCap); capGroupLayout->addWidget(roundCap); QVBoxLayout *joinGroupLayout = new QVBoxLayout(m_joinGroup); joinGroupLayout->addWidget(bevelJoin); joinGroupLayout->addWidget(miterJoin); joinGroupLayout->addWidget(roundJoin); QVBoxLayout *styleGroupLayout = new QVBoxLayout(m_styleGroup); styleGroupLayout->addWidget(solidLine); styleGroupLayout->addWidget(dashLine); styleGroupLayout->addWidget(dotLine); styleGroupLayout->addWidget(dashDotLine); styleGroupLayout->addWidget(dashDotDotLine); styleGroupLayout->addWidget(customDashLine); QVBoxLayout *pathModeGroupLayout = new QVBoxLayout(m_pathModeGroup); pathModeGroupLayout->addWidget(curveMode); pathModeGroupLayout->addWidget(lineMode); // Connections connect(flatCap, SIGNAL(clicked()), m_renderer, SLOT(setFlatCap())); connect(squareCap, SIGNAL(clicked()), m_renderer, SLOT(setSquareCap())); connect(roundCap, SIGNAL(clicked()), m_renderer, SLOT(setRoundCap())); connect(bevelJoin, SIGNAL(clicked()), m_renderer, SLOT(setBevelJoin())); connect(miterJoin, SIGNAL(clicked()), m_renderer, SLOT(setMiterJoin())); connect(roundJoin, SIGNAL(clicked()), m_renderer, SLOT(setRoundJoin())); connect(curveMode, SIGNAL(clicked()), m_renderer, SLOT(setCurveMode())); connect(lineMode, SIGNAL(clicked()), m_renderer, SLOT(setLineMode())); connect(solidLine, SIGNAL(clicked()), m_renderer, SLOT(setSolidLine())); connect(dashLine, SIGNAL(clicked()), m_renderer, SLOT(setDashLine())); connect(dotLine, SIGNAL(clicked()), m_renderer, SLOT(setDotLine())); connect(dashDotLine, SIGNAL(clicked()), m_renderer, SLOT(setDashDotLine())); connect(dashDotDotLine, SIGNAL(clicked()), m_renderer, SLOT(setDashDotDotLine())); connect(customDashLine, SIGNAL(clicked()), m_renderer, SLOT(setCustomDashLine())); // Set the defaults: flatCap->setChecked(true); bevelJoin->setChecked(true); curveMode->setChecked(true); solidLine->setChecked(true); }
KDMShutdown::KDMShutdown( int mode, QWidget* _parent, const char* _name, const char* _shutdown, const char* _restart) : FDialog( _parent, _name, true) { shutdown = _shutdown; restart = _restart; int h = 10, w = 0; QFrame* winFrame = new QFrame( this); winFrame->setFrameStyle( QFrame::WinPanel | QFrame::Raised); QBoxLayout* box = new QBoxLayout( winFrame, QBoxLayout::TopToBottom, 10, 10); QString shutdownmsg = klocale->translate( "Shutdown or restart?"); if( mode == KDMConfig::RootOnly) { shutdownmsg += '\n'; shutdownmsg += klocale->translate( "(Enter Root Password)"); } label = new QLabel( shutdownmsg, winFrame); set_fixed( label); h += label->height() + 10; w = label->width(); box->addWidget( label, 0, AlignCenter); QFrame* sepFrame = new QFrame( this); sepFrame->setFrameStyle( QFrame::HLine| QFrame::Sunken); h += sepFrame->height(); box->addWidget( sepFrame); btGroup = new QButtonGroup( /* this */); QRadioButton *rb; rb = new QRadioButton( winFrame /*btGroup*/); rb->setText( klocale->translate("Shutdown")); set_min( rb); rb->setFocusPolicy( StrongFocus); // Default action rb->setChecked( true); rb->setFocus(); cur_action = shutdown; h += rb->height() + 10; w = QMAX( rb->width(), w); box->addWidget( rb); btGroup->insert( rb); rb = new QRadioButton( winFrame /*btGroup*/); rb->setText( klocale->translate("Shutdown and restart")); set_min( rb); rb->setFocusPolicy( StrongFocus); h += rb->height() + 10; w = QMAX( rb->width(), w); box->addWidget( rb); btGroup->insert( rb); rb = new QRadioButton( winFrame /*btGroup*/); rb->setText( klocale->translate("Restart X Server"));//better description set_min( rb); rb->setFocusPolicy( StrongFocus); h += rb->height() + 10; w = QMAX( rb->width(), w); box->addWidget( rb); btGroup->insert( rb); // Passwd line edit if( mode == KDMConfig::RootOnly) { pswdEdit = new QLineEdit( winFrame); //set_min( pswdEdit); pswdEdit->setMinimumHeight( pswdEdit->sizeHint().height()); pswdEdit->setEchoMode( QLineEdit::NoEcho); /*QColorGroup passwdColGroup( QApplication::palette()->normal().foreground(), QApplication::palette()->normal().background(), QApplication::palette()->normal().light(), QApplication::palette()->normal().dark(), QApplication::palette()->normal().mid(), QApplication::palette()->normal().base(), QApplication::palette()->normal().base()); QPalette passwdPalette( passwdColGroup, passwdColGroup, passwdColGroup); pswdEdit->setPalette( passwdPalette); */ pswdEdit->setFocusPolicy( StrongFocus); pswdEdit->setFocus(); h+= pswdEdit->height() + 10; box->addWidget( pswdEdit); } QBoxLayout* box3 = new QBoxLayout( QBoxLayout::LeftToRight, 10); box->addLayout( box3); okButton = new QPushButton( klocale->translate("OK"), winFrame); set_min( okButton); okButton->setFocusPolicy( StrongFocus); cancelButton = new QPushButton( klocale->translate("Cancel"), winFrame); set_min( cancelButton); //cancelButton->setDefault( true); cancelButton->setFocusPolicy( StrongFocus); h += cancelButton->height() + 10; w = QMAX( (okButton->width() + 10 + cancelButton->width()), w); box3->addWidget( okButton); box3->addWidget( cancelButton); // Connections connect( okButton, SIGNAL(clicked()), SLOT(bye_bye())); connect( cancelButton, SIGNAL(clicked()), SLOT(reject())); connect( btGroup, SIGNAL(clicked(int)), SLOT(rb_clicked(int))); if( mode == KDMConfig::RootOnly) { okButton->setEnabled( false); connect( pswdEdit, SIGNAL( returnPressed()), this, SLOT( pw_entered())); } else cancelButton->setFocus(); resize( 20 + w, h); winFrame->setGeometry( 0, 0, width(), height()); }