DiagramDialog::DiagramDialog(Diagram *d, const QString& _DataSet, QWidget *parent, Graph *currentGraph) : QDialog(parent, 0, TRUE, Qt::WDestructiveClose) { Diag = d; Graphs.setAutoDelete(true); copyDiagramGraphs(); // make a copy of all graphs defaultDataSet = _DataSet; setCaption(tr("Edit Diagram Properties")); changed = false; transfer = false; // have changes be applied ? (used by "Cancel") toTake = false; // double-clicked variable be inserted into graph list ? Expr.setPattern("[^\"]+"); Validator = new QRegExpValidator(Expr, this); ValInteger = new QIntValidator(0, 360, this); ValDouble = new QDoubleValidator(-1e200, 1e200, 6, this); QString NameY, NameZ; if((Diag->Name == "Rect") || (Diag->Name == "Curve")) { NameY = tr("left Axis"); NameZ = tr("right Axis"); } else if(Diag->Name == "Polar") { NameY = tr("y-Axis"); } else if((Diag->Name == "Smith") || (Diag->Name == "ySmith")) { NameY = tr("y-Axis"); } else if(Diag->Name == "PS") { NameY = tr("smith Axis"); NameZ = tr("polar Axis"); } else if(Diag->Name == "SP") { NameY = tr("polar Axis"); NameZ = tr("smith Axis"); } else if(Diag->Name == "Rect3D") { NameY = tr("y-Axis"); NameZ = tr("z-Axis"); } all = new QVBoxLayout(this); // to provide neccessary size QTabWidget *t = new QTabWidget(this); all->addWidget(t); // ........................................................... QVBox *Tab1 = new QVBox(this); Tab1->setSpacing(5); Label4 = 0; // different types with same content yrLabel = 0; yAxisBox = 0; Property2 = 0; ColorButt = 0; hideInvisible = 0; rotationX = rotationY = rotationZ = 0; QVButtonGroup *InputGroup = new QVButtonGroup(tr("Graph Input"), Tab1); GraphInput = new QLineEdit(InputGroup); GraphInput->setValidator(Validator); connect(GraphInput, SIGNAL(textChanged(const QString&)), SLOT(slotResetToTake(const QString&))); QHBox *Box2 = new QHBox(InputGroup); Box2->setSpacing(5); if(Diag->Name == "Tab") { Label1 = new QLabel(tr("Number Notation: "), Box2); PropertyBox = new QComboBox(Box2); PropertyBox->insertItem(tr("real/imaginary")); PropertyBox->insertItem(tr("magnitude/angle (degree)")); PropertyBox->insertItem(tr("magnitude/angle (radian)")); PropertyBox->setCurrentItem(1); connect(PropertyBox, SIGNAL(activated(int)), SLOT(slotSetNumMode(int))); Box2->setStretchFactor(new QWidget(Box2), 5); // stretchable placeholder Label2 = new QLabel(tr("Precision:"), Box2); Property2 = new QLineEdit(Box2); Property2->setValidator(ValInteger); Property2->setMaxLength(2); Property2->setMaximumWidth(25); Property2->setText("3"); } else if(Diag->Name != "Truth") { Label1 = new QLabel(tr("Color:"),Box2); ColorButt = new QPushButton(" ",Box2); ColorButt->setMinimumWidth(50); ColorButt->setEnabled(false); connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor())); Box2->setStretchFactor(new QWidget(Box2), 5); // stretchable placeholder Label3 = new QLabel(tr("Style:"),Box2); Label3->setEnabled(false); PropertyBox = new QComboBox(Box2); PropertyBox->insertItem(tr("solid line")); PropertyBox->insertItem(tr("dash line")); PropertyBox->insertItem(tr("dot line")); if(Diag->Name != "Time") { PropertyBox->insertItem(tr("long dash line")); PropertyBox->insertItem(tr("stars")); PropertyBox->insertItem(tr("circles")); PropertyBox->insertItem(tr("arrows")); } connect(PropertyBox, SIGNAL(activated(int)), SLOT(slotSetGraphStyle(int))); Box2->setStretchFactor(new QWidget(Box2), 5); // stretchable placeholder Label2 = new QLabel(tr("Thickness:"),Box2); Property2 = new QLineEdit(Box2); Property2->setValidator(ValInteger); Property2->setMaximumWidth(25); Property2->setMaxLength(2); Property2->setText("0"); if((Diag->Name=="Rect") || (Diag->Name=="PS") || (Diag->Name=="SP") || (Diag->Name=="Curve")) { QHBox *Box3 = new QHBox(InputGroup); Box3->setSpacing(5); Label4 = new QLabel(tr("y-Axis:"),Box3); Label4->setEnabled(false); yAxisBox = new QComboBox(Box3); yAxisBox->insertItem(NameY); yAxisBox->insertItem(NameZ); yAxisBox->setEnabled(false); connect(yAxisBox, SIGNAL(activated(int)), SLOT(slotSetYAxis(int))); Box3->setStretchFactor(new QWidget(Box3), 5); // stretchable placeholder } } if(Property2) { connect(Property2, SIGNAL(textChanged(const QString&)), SLOT(slotSetProp2(const QString&))); Label1->setEnabled(false); PropertyBox->setEnabled(false); Label2->setEnabled(false); Property2->setEnabled(false); } QHBox *Box1 = new QHBox(Tab1); Box1->setSpacing(5); QVButtonGroup *DataGroup = new QVButtonGroup(tr("Dataset"), Box1); ChooseData = new QComboBox(false, DataGroup); ChooseData->setMinimumWidth(200); connect(ChooseData, SIGNAL(activated(int)), SLOT(slotReadVars(int))); ChooseVars = new QListView(DataGroup); ChooseVars->addColumn(tr("Name")); ChooseVars->addColumn(tr("Type")); ChooseVars->addColumn(tr("Size")); connect(ChooseVars, SIGNAL(doubleClicked(QListViewItem*)), SLOT(slotTakeVar(QListViewItem*))); QVButtonGroup *GraphGroup = new QVButtonGroup(tr("Graph"), Box1); GraphList = new QListBox(GraphGroup); connect(GraphList, SIGNAL(clicked(QListBoxItem*)), SLOT(slotSelectGraph(QListBoxItem*))); QPushButton *NewButt = new QPushButton(tr("New Graph"), GraphGroup); connect(NewButt, SIGNAL(clicked()), SLOT(slotNewGraph())); QPushButton *DelButt = new QPushButton(tr("Delete Graph"), GraphGroup); connect(DelButt, SIGNAL(clicked()), SLOT(slotDeleteGraph())); t->addTab(Tab1, tr("Data")); // ........................................................... int Row = 0; if(Diag->Name.at(0) != 'T') { // not tabular or timing diagram QWidget *Tab2 = new QWidget(t); QGridLayout *gp = new QGridLayout(Tab2,13,3,5,5); gp->addMultiCellWidget(new QLabel(tr("x-Axis Label:"), Tab2), Row,Row,0,0); xLabel = new QLineEdit(Tab2); xLabel->setValidator(Validator); gp->addMultiCellWidget(xLabel, Row,Row,1,2); Row++; gp->addMultiCellWidget( new QLabel(NameY+" "+tr("Label:"), Tab2), Row,Row,0,0); ylLabel = new QLineEdit(Tab2); ylLabel->setValidator(Validator); gp->addMultiCellWidget(ylLabel, Row,Row,1,2); Row++; if((Diag->Name != "Smith") && (Diag->Name != "Polar")) { gp->addMultiCellWidget( new QLabel(NameZ +" "+tr("Label:"), Tab2), Row,Row,0,0); yrLabel = new QLineEdit(Tab2); yrLabel->setValidator(Validator); gp->addMultiCellWidget(yrLabel, Row,Row,1,2); Row++; } gp->addMultiCellWidget(new QLabel( tr("<b>Label text</b>: Use LaTeX style for special characters, e.g. \\tau"), Tab2), Row,Row,0,2); Row++; if(Diag->Name != "Rect3D") { GridOn = new QCheckBox(tr("show Grid"), Tab2); gp->addMultiCellWidget(GridOn, Row,Row,0,2); Row++; GridLabel1 = new QLabel(tr("Grid Color:"),Tab2); gp->addMultiCellWidget(GridLabel1, Row,Row,0,0); GridColorButt = new QPushButton(" ",Tab2); connect(GridColorButt, SIGNAL(clicked()), SLOT(slotSetGridColor())); gp->addMultiCellWidget(GridColorButt, Row,Row,1,2); Row++; GridColorButt->setPaletteBackgroundColor(Diag->GridPen.color()); GridLabel2 = new QLabel(tr("Grid Style: "), Tab2); gp->addMultiCellWidget(GridLabel2, Row,Row,0,0); GridStyleBox = new QComboBox(Tab2); GridStyleBox->insertItem(tr("solid line")); GridStyleBox->insertItem(tr("dash line")); GridStyleBox->insertItem(tr("dot line")); GridStyleBox->insertItem(tr("dash dot line")); GridStyleBox->insertItem(tr("dash dot dot line")); gp->addMultiCellWidget(GridStyleBox, Row,Row,1,2); Row++; GridStyleBox->setCurrentItem(Diag->GridPen.style()-1); GridOn->setChecked(Diag->xAxis.GridOn); if(!Diag->xAxis.GridOn) slotSetGridBox(QButton::Off); connect(GridOn, SIGNAL(stateChanged(int)), SLOT(slotSetGridBox(int))); } else { GridOn = 0; GridColorButt = 0; GridStyleBox = 0; } // ........................................................... xLabel->setText(Diag->xAxis.Label); ylLabel->setText(Diag->yAxis.Label); if(yrLabel) yrLabel->setText(Diag->zAxis.Label); if((Diag->Name.left(4) == "Rect") || (Diag->Name == "Curve")) { GridLogX = new QCheckBox(tr("logarithmical X Axis Grid"), Tab2); gp->addMultiCellWidget(GridLogX, Row,Row,0,2); Row++; GridLogY = new QCheckBox(tr("logarithmical")+" "+NameY+" "+tr("Grid"), Tab2); gp->addMultiCellWidget(GridLogY, Row,Row,0,2); Row++; GridLogZ = new QCheckBox(tr("logarithmical")+" "+NameZ+" "+tr("Grid"), Tab2); gp->addMultiCellWidget(GridLogZ, Row,Row,0,2); Row++; // ........................................................... // transfer the diagram properties to the dialog GridLogX->setChecked(Diag->xAxis.log); GridLogY->setChecked(Diag->yAxis.log); GridLogZ->setChecked(Diag->zAxis.log); if(Diag->Name == "Rect3D") { hideInvisible = new QCheckBox(tr("hide invisible lines"), Tab2); gp->addMultiCellWidget(hideInvisible, Row,Row,0,2); Row++; QLabel *LabelRotX = new QLabel(tr("Rotation around x-Axis:"), Tab2); LabelRotX->setPaletteForegroundColor(Qt::red); gp->addWidget(LabelRotX, Row,0); SliderRotX = new QSlider(0,360,20, ((Rect3DDiagram*)Diag)->rotX, Qt::Horizontal, Tab2); gp->addWidget(SliderRotX, Row,1); connect(SliderRotX, SIGNAL(valueChanged(int)), SLOT(slotNewRotX(int))); rotationX = new QLineEdit(Tab2); rotationX->setValidator(ValInteger); rotationX->setMaxLength(3); rotationX->setMaximumWidth(40); gp->addWidget(rotationX, Row,2); connect(rotationX, SIGNAL(textChanged(const QString&)), SLOT(slotEditRotX(const QString&))); Row++; QLabel *LabelRotY = new QLabel(tr("Rotation around y-Axis:"), Tab2); LabelRotY->setPaletteForegroundColor(Qt::green); gp->addWidget(LabelRotY, Row,0); SliderRotY = new QSlider(0,360,20, ((Rect3DDiagram*)Diag)->rotY, Qt::Horizontal, Tab2); gp->addWidget(SliderRotY, Row,1); connect(SliderRotY, SIGNAL(valueChanged(int)), SLOT(slotNewRotY(int))); rotationY = new QLineEdit(Tab2); rotationY->setValidator(ValInteger); rotationY->setMaxLength(3); rotationY->setMaximumWidth(40); gp->addWidget(rotationY, Row,2); connect(rotationY, SIGNAL(textChanged(const QString&)), SLOT(slotEditRotY(const QString&))); Row++; QLabel *LabelRotZ = new QLabel(tr("Rotation around z-Axis:"), Tab2); LabelRotZ->setPaletteForegroundColor(Qt::blue); gp->addWidget(LabelRotZ, Row,0); SliderRotZ = new QSlider(0,360,20, ((Rect3DDiagram*)Diag)->rotZ, Qt::Horizontal, Tab2); gp->addWidget(SliderRotZ, Row,1); connect(SliderRotZ, SIGNAL(valueChanged(int)), SLOT(slotNewRotZ(int))); rotationZ = new QLineEdit(Tab2); rotationZ->setValidator(ValInteger); rotationZ->setMaxLength(3); rotationZ->setMaximumWidth(40); gp->addWidget(rotationZ, Row,2); connect(rotationZ, SIGNAL(textChanged(const QString&)), SLOT(slotEditRotZ(const QString&))); Row++; gp->addWidget(new QLabel(tr("2D-projection:"), Tab2), Row,0); DiagCross = new Cross3D(((Rect3DDiagram*)Diag)->rotX, ((Rect3DDiagram*)Diag)->rotY, ((Rect3DDiagram*)Diag)->rotZ, Tab2); gp->addWidget(DiagCross, Row,1); // transfer the diagram properties to the dialog hideInvisible->setChecked(Diag->hideLines); rotationX->setText(QString::number(((Rect3DDiagram*)Diag)->rotX)); rotationY->setText(QString::number(((Rect3DDiagram*)Diag)->rotY)); rotationZ->setText(QString::number(((Rect3DDiagram*)Diag)->rotZ)); } } else GridLogX = GridLogY = GridLogZ = 0; t->addTab(Tab2, tr("Properties")); // ........................................................... QVBox *Tab3 = new QVBox(this); Tab1->setSpacing(5); QHGroupBox *axisX = new QHGroupBox(tr("x-Axis"), Tab3); QVBox *VBox1 = new QVBox(axisX); VBox1->setStretchFactor(new QWidget(VBox1),5); // stretchable placeholder manualX = new QCheckBox(tr("manual"), VBox1); connect(manualX, SIGNAL(stateChanged(int)), SLOT(slotManualX(int))); QVBox *VBox2 = new QVBox(axisX); new QLabel(tr("start"), VBox2); startX = new QLineEdit(VBox2); startX->setValidator(ValDouble); QVBox *VBox3 = new QVBox(axisX); new QLabel(tr("step"), VBox3); stepX = new QLineEdit(VBox3); stepX->setValidator(ValDouble); QVBox *VBox4 = new QVBox(axisX); new QLabel(tr("stop"), VBox4); stopX = new QLineEdit(VBox4); stopX->setValidator(ValDouble); QHGroupBox *axisY; axisY = new QHGroupBox(NameY, Tab3); QVBox *VBox5 = new QVBox(axisY); VBox5->setStretchFactor(new QWidget(VBox5),5); // stretchable placeholder manualY = new QCheckBox(tr("manual"), VBox5); connect(manualY, SIGNAL(stateChanged(int)), SLOT(slotManualY(int))); QVBox *VBox6 = new QVBox(axisY); new QLabel(tr("start"), VBox6); startY = new QLineEdit(VBox6); startY->setValidator(ValDouble); QVBox *VBox7 = new QVBox(axisY); if((Diag->Name=="Smith") || (Diag->Name=="ySmith") || (Diag->Name=="PS")) new QLabel(tr("number"), VBox7); else new QLabel(tr("step"), VBox7); stepY = new QLineEdit(VBox7); stepY->setValidator(ValDouble); QVBox *VBox8 = new QVBox(axisY); new QLabel(tr("stop"), VBox8); stopY = new QLineEdit(VBox8); stopY->setValidator(ValDouble); QHGroupBox *axisZ; axisZ = new QHGroupBox(NameZ, Tab3); QVBox *VBox9 = new QVBox(axisZ); VBox9->setStretchFactor(new QWidget(VBox9),5); // stretchable placeholder manualZ = new QCheckBox(tr("manual"), VBox9); connect(manualZ, SIGNAL(stateChanged(int)), SLOT(slotManualZ(int))); QVBox *VBox10 = new QVBox(axisZ); new QLabel(tr("start"), VBox10); startZ = new QLineEdit(VBox10); startZ->setValidator(ValDouble); QVBox *VBox11 = new QVBox(axisZ); if(Diag->Name == "SP") new QLabel(tr("number"), VBox11); else new QLabel(tr("step"), VBox11); stepZ = new QLineEdit(VBox11); stepZ->setValidator(ValDouble); QVBox *VBox12 = new QVBox(axisZ); new QLabel(tr("stop"), VBox12); stopZ = new QLineEdit(VBox12); stopZ->setValidator(ValDouble); Tab3->setStretchFactor(new QWidget(Tab3),5); // stretchable placeholder t->addTab(Tab3, tr("Limits")); // ........................................................... // transfer the diagram properties to the dialog if(Diag->xAxis.autoScale) slotManualX(QButton::Off); else manualX->setChecked(true); if(Diag->yAxis.autoScale) slotManualY(QButton::Off); else manualY->setChecked(true); if(Diag->zAxis.autoScale) slotManualZ(QButton::Off); else manualZ->setChecked(true); Diag->calcLimits(); // inserts auto-scale values if not manual startX->setText(QString::number(Diag->xAxis.limit_min)); stepX->setText(QString::number(Diag->xAxis.step)); stopX->setText(QString::number(Diag->xAxis.limit_max)); startY->setText(QString::number(Diag->yAxis.limit_min)); stepY->setText(QString::number(Diag->yAxis.step)); stopY->setText(QString::number(Diag->yAxis.limit_max)); startZ->setText(QString::number(Diag->zAxis.limit_min)); stepZ->setText(QString::number(Diag->zAxis.step)); stopZ->setText(QString::number(Diag->zAxis.limit_max)); if((Diag->Name == "Smith") || (Diag->Name == "ySmith") || (Diag->Name == "Polar")) { axisZ->setEnabled(false); } if(Diag->Name.left(4) != "Rect") // cartesian 2D and 3D if(Diag->Name != "Curve") { axisX->setEnabled(false); startY->setEnabled(false); startZ->setEnabled(false); } } else stepX = 0; connect(t, SIGNAL(currentChanged(QWidget*)), SLOT(slotChangeTab(QWidget*))); // ........................................................... QHBox *Butts = new QHBox(this); Butts->setSpacing(5); Butts->setMargin(5); all->addWidget(Butts); QPushButton *OkButt = new QPushButton(tr("OK"), Butts); connect(OkButt, SIGNAL(clicked()), SLOT(slotOK())); QPushButton *ApplyButt = new QPushButton(tr("Apply"), Butts); connect(ApplyButt, SIGNAL(clicked()), SLOT(slotApply())); QPushButton *CancelButt = new QPushButton(tr("Cancel"), Butts); connect(CancelButt, SIGNAL(clicked()), SLOT(slotCancel())); OkButt->setDefault(true); // ........................................................... // put all data files into ComboBox QFileInfo Info(defaultDataSet); QDir ProjDir(Info.dirPath()); QStringList Elements = ProjDir.entryList("*.dat", QDir::Files, QDir::Name); QStringList::iterator it; for(it = Elements.begin(); it != Elements.end(); ++it) { ChooseData->insertItem((*it).left((*it).length()-4)); if((*it) == Info.fileName()) // default dataset should be the current ChooseData->setCurrentItem(ChooseData->count()-1); } slotReadVars(0); // put variables into the ListView // ........................................................... // put all graphs into the ListBox Row = 0; for(Graph *pg = Diag->Graphs.first(); pg != 0; pg = Diag->Graphs.next()) { GraphList->insertItem(pg->Var); if(pg == currentGraph) { GraphList->setCurrentItem(Row); // select current graph SelectGraph(currentGraph); } Row++; } if(ColorButt) if(!currentGraph) ColorButt->setPaletteBackgroundColor (QColor(DefaultColors[GraphList->count()])); }
///////////////////////////////////////////////////////////////////////////////////////////////// // Trade dialog class ///////////////////////////////////////////////////////////////////////////////////////////////// CasinoDialog::CasinoDialog(const PlayerState* player, QWidget *parent, const char * name) : QDialog(parent, name, true) { unsigned int money = player->get_money(); setCaption("Welcome to the Casino."); //----------------------------------------------------------------------------------------------- // Set up acceptance and rejection buttons //----------------------------------------------------------------------------------------------- QPushButton *ok = new QPushButton ("Place your bet", this); ok->setGeometry( 110, 300, 215, 30); connect( ok, SIGNAL(clicked()), SLOT(accept())); //----------------------------------------------------------------------------------------------- // Set up frames for trading players //----------------------------------------------------------------------------------------------- QLabel *avail = new QLabel ( QString("Available Money: $") + QString::number(money), this); avail->setGeometry( 130, 170, 205, 30); QLabel *betLabel = new QLabel ( "Place Your Bet:", this); betLabel->setGeometry( 130, 200, 205, 30); _spin = new QSpinBox( (money < 100 ? money : 100) , money, 100, this, "_spin"); _spin->setGeometry(230, 205, 50, 20); //----------------------------------------------------------------------------------------------- // Set up property check boxes for first player //----------------------------------------------------------------------------------------------- QRadioButton *Prop1, *Prop2, *Prop3, *Prop4, *Prop5; Prop1 = new QRadioButton( "Any Craps: wins on a throw of 2, 3 or 12 with a payoff of 8:1", this); Prop1->setGeometry( 5, 0, 400, 30); Prop2 = new QRadioButton( "Any Seven: wins on a throw of 7 with a payoff of 5:1", this); Prop2->setGeometry( 5, 25, 400, 30); Prop3 = new QRadioButton( "Eleven: wins on a throw of 11 with a payoff of 16:1", this); Prop3->setGeometry( 5, 50, 400, 30); Prop4 = new QRadioButton( "Ace Duece: wins on a throw of 3 with a payoff of 16:1", this); Prop4->setGeometry( 5, 75, 400, 30); Prop5 = new QRadioButton( "Aces or Boxcars: wins on a throw of 2 or 12 with a payoff of 30:1", this); Prop5->setGeometry( 5, 100, 410, 30); _group = new QButtonGroup(this); _group->setGeometry(0, 0, 0, 0); // type = kCCraps, kCSeven, kCEleven, kCDuece, kCAorB _group->insert(Prop1,0); // any craps _group->insert(Prop2,1); // any seven _group->insert(Prop3,2); // eleven _group->insert(Prop4,3); // ace duece _group->insert(Prop5,4); // aces or boxcars setFixedSize(420,335); }
GameCFGWidget::GameCFGWidget(QWidget* parent) : QGroupBox(parent) , mainLayout(this) , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}") { mainLayout.setMargin(0); setMinimumHeight(310); setMaximumHeight(447); setMinimumWidth(470); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_master = true; // Easy containers for the map/game options in either stacked or tabbed mode mapContainerFree = new QWidget(); mapContainerTabbed = new QWidget(); optionsContainerFree = new QWidget(); optionsContainerTabbed = new QWidget(); tabbed = false; // Container for when in tabbed mode tabs = new QTabWidget(this); tabs->setFixedWidth(470); tabs->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); tabs->addTab(mapContainerTabbed, tr("Map")); tabs->addTab(optionsContainerTabbed, tr("Game options")); tabs->setObjectName("gameCfgWidgetTabs"); mainLayout.addWidget(tabs, 1); tabs->setVisible(false); // Container for when in stacked mode StackContainer = new QWidget(); StackContainer->setObjectName("gameStackContainer"); mainLayout.addWidget(StackContainer, 1); QVBoxLayout * stackLayout = new QVBoxLayout(StackContainer); // Map options pMapContainer = new HWMapContainer(mapContainerFree); stackLayout->addWidget(mapContainerFree, 0, Qt::AlignHCenter); pMapContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); pMapContainer->setFixedSize(width() - 14, 278); mapContainerFree->setFixedSize(pMapContainer->width(), pMapContainer->height()); // Horizontal divider QFrame * divider = new QFrame(); divider->setFrameShape(QFrame::HLine); divider->setFrameShadow(QFrame::Plain); stackLayout->addWidget(divider, 0, Qt::AlignBottom); //stackLayout->setRowMinimumHeight(1, 10); // Game options optionsContainerTabbed->setContentsMargins(0, 0, 0, 0); optionsContainerFree->setFixedSize(width() - 14, 140); stackLayout->addWidget(optionsContainerFree, 0, Qt::AlignHCenter); OptionsInnerContainer = new QWidget(optionsContainerFree); m_childWidgets << OptionsInnerContainer; OptionsInnerContainer->setFixedSize(optionsContainerFree->width(), optionsContainerFree->height()); OptionsInnerContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); GBoxOptionsLayout = new QGridLayout(OptionsInnerContainer); GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), this), 1, 0); Scripts = new QComboBox(this); GBoxOptionsLayout->addWidget(Scripts, 1, 1); Scripts->setModel(DataManager::instance().gameStyleModel()); m_curScript = Scripts->currentText(); connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int))); QWidget *SchemeWidget = new QWidget(this); GBoxOptionsLayout->addWidget(SchemeWidget, 2, 0, 1, 2); QGridLayout *SchemeWidgetLayout = new QGridLayout(SchemeWidget); SchemeWidgetLayout->setMargin(0); GameSchemes = new QComboBox(SchemeWidget); SchemeWidgetLayout->addWidget(GameSchemes, 0, 2); connect(GameSchemes, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeChanged(int))); SchemeWidgetLayout->addWidget(new QLabel(QLabel::tr("Scheme"), SchemeWidget), 0, 0); QPixmap pmEdit(":/res/edit.png"); QPushButton * goToSchemePage = new QPushButton(SchemeWidget); goToSchemePage->setWhatsThis(tr("Edit schemes")); goToSchemePage->setIconSize(pmEdit.size()); goToSchemePage->setIcon(pmEdit); goToSchemePage->setMaximumWidth(pmEdit.width() + 6); SchemeWidgetLayout->addWidget(goToSchemePage, 0, 3); connect(goToSchemePage, SIGNAL(clicked()), this, SLOT(jumpToSchemes())); SchemeWidgetLayout->addWidget(new QLabel(QLabel::tr("Weapons"), SchemeWidget), 1, 0); WeaponsName = new QComboBox(SchemeWidget); SchemeWidgetLayout->addWidget(WeaponsName, 1, 2); connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int))); QPushButton * goToWeaponPage = new QPushButton(SchemeWidget); goToWeaponPage->setWhatsThis(tr("Edit weapons")); goToWeaponPage->setIconSize(pmEdit.size()); goToWeaponPage->setIcon(pmEdit); goToWeaponPage->setMaximumWidth(pmEdit.width() + 6); SchemeWidgetLayout->addWidget(goToWeaponPage, 1, 3); connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons())); bindEntries = new QCheckBox(SchemeWidget); bindEntries->setWhatsThis(tr("Game scheme will auto-select a weapon")); bindEntries->setChecked(true); bindEntries->setMaximumWidth(42); bindEntries->setStyleSheet( "QCheckBox::indicator:checked { image: url(\":/res/lock.png\"); }" "QCheckBox::indicator:unchecked { image: url(\":/res/unlock.png\"); }" ); SchemeWidgetLayout->addWidget(bindEntries, 0, 1, 0, 1, Qt::AlignVCenter); connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &))); connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &))); connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator))); connect(pMapContainer, SIGNAL(mazeSizeChanged(int)), this, SLOT(maze_sizeChanged(int))); connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &))); connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int))); connect(pMapContainer, SIGNAL(drawMapRequested()), this, SIGNAL(goToDrawMap())); connect(pMapContainer, SIGNAL(drawnMapChanged(const QByteArray &)), this, SLOT(onDrawnMapChanged(const QByteArray &))); connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(updateModelViews())); }
HelpAbout::HelpAbout( QWidget* parent, HELPABOUT::TabId tabid ) : QDialog( parent ) { setObjectName( QString::fromUtf8( "HelpAbout" ) ); title = VkCfg::appName() + " Information"; setWindowTitle( title ); // top layout QVBoxLayout* vbox = new QVBoxLayout( this ); vbox->setObjectName( QString::fromUtf8( "vbox" ) ); // widget for the top part QWidget* hLayoutWidget = new QWidget( this ); hLayoutWidget->setObjectName( QString::fromUtf8( "hLayoutWidget" ) ); vbox->addWidget( hLayoutWidget ); // hbox for pic + appname QHBoxLayout* hbox = new QHBoxLayout( hLayoutWidget ); hbox->setObjectName( QString::fromUtf8( "hbox" ) ); // pic QLabel* pic = new QLabel( this ); pic->setPixmap( QPixmap( ":/vk_icons/icons/valkyrie.xpm" ) ); pic->setFixedSize( pic->sizeHint() ); hbox->addWidget( pic ); // app info QLabel* appName = new QLabel( this ); QString str = VkCfg::appName() + " v" + VkCfg::appVersion(); appName->setText( str ); appName->setFont( QFont( "Times", 18, QFont::Bold ) ); appName->setFixedSize( appName->sizeHint() ); hbox->addWidget( appName ); // push the pix+info over to the left hbox->addStretch( 10 ); // tabwidget tabParent = new QTabWidget( this ); tabParent->setObjectName( QString::fromUtf8( "tabParent" ) ); connect( tabParent, SIGNAL( currentChanged( int ) ), this, SLOT( showTab( int ) ) ); vbox->addWidget( tabParent ); // about_vk tab aboutVk = new QTextBrowser( tabParent ); aboutVk->setObjectName( QString::fromUtf8( "aboutVk" ) ); QString VkName = VkCfg::appName(); VkName.replace( 0, 1, VkName[0].toUpper() ); str = "About " + VkName; tabParent->insertTab( HELPABOUT::ABOUT_VK, aboutVk, str ); // license tab license = new QTextBrowser( tabParent ); license->setObjectName( QString::fromUtf8( "license" ) ); tabParent->insertTab( HELPABOUT::LICENSE, license, "License Agreement" ); // support tab support = new QTextBrowser( tabParent ); support->setObjectName( QString::fromUtf8( "support" ) ); tabParent->insertTab( HELPABOUT::SUPPORT, support, "Support" ); QPushButton* okButt = new QPushButton( "Close", this ); okButt->setDefault( true ); okButt->setFixedSize( okButt->sizeHint() ); connect( okButt, SIGNAL( clicked() ), this, SLOT( accept() ) ); okButt->setFocus(); vbox->addWidget( okButt, 0, Qt::AlignRight ); // setup text-browsers license->setSource( VkCfg::docDir() + "/about_gpl.html" ); support->setSource( VkCfg::docDir() + "/support.html" ); // about_vk source needs version args updating: QFile file( VkCfg::docDir() + "/about_vk.html" ); if ( file.open( QIODevice::ReadOnly ) ) { QTextStream ts( &file ); aboutVk->setText( ts.readAll().arg( QT_VERSION_STR ).arg( qVersion() ) ); } // start up with the correct page loaded tabParent->setCurrentIndex( tabid ); // and start up at a reasonable size resize( 600, 380 ); }
void NewActionDialog::updateButtons() { QPushButton *okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok); okButton->setEnabled(!actionText().isEmpty() && !actionName().isEmpty()); }
/** * Constructor. */ InstrumentWindow::InstrumentWindow(const QString &wsName, const QString &label, ApplicationWindow *app, const QString &name, Qt::WFlags f) : MdiSubWindow(app, label, name, f), WorkspaceObserver(), m_InstrumentDisplay(NULL), m_simpleDisplay(NULL), m_workspaceName(wsName), m_instrumentActor(NULL), m_surfaceType(FULL3D), m_savedialog_dir(QString::fromStdString( Mantid::Kernel::ConfigService::Instance().getString( "defaultsave.directory"))), mViewChanged(false), m_blocked(false), m_instrumentDisplayContextMenuOn(false) { setFocusPolicy(Qt::StrongFocus); QVBoxLayout *mainLayout = new QVBoxLayout(this); QSplitter *controlPanelLayout = new QSplitter(Qt::Horizontal); // Add Tab control panel mControlsTab = new QTabWidget(this, 0); controlPanelLayout->addWidget(mControlsTab); controlPanelLayout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // Create the display widget m_InstrumentDisplay = new MantidGLWidget(this); m_InstrumentDisplay->installEventFilter(this); connect(this, SIGNAL(enableLighting(bool)), m_InstrumentDisplay, SLOT(enableLighting(bool))); // Create simple display widget m_simpleDisplay = new SimpleWidget(this); m_simpleDisplay->installEventFilter(this); QWidget *aWidget = new QWidget(this); m_instrumentDisplayLayout = new QStackedLayout(aWidget); m_instrumentDisplayLayout->addWidget(m_InstrumentDisplay); m_instrumentDisplayLayout->addWidget(m_simpleDisplay); controlPanelLayout->addWidget(aWidget); mainLayout->addWidget(controlPanelLayout); m_xIntegration = new XIntegrationControl(this); mainLayout->addWidget(m_xIntegration); connect(m_xIntegration, SIGNAL(changed(double, double)), this, SLOT(setIntegrationRange(double, double))); // Set the mouse/keyboard operation info and help button QHBoxLayout *infoLayout = new QHBoxLayout(); mInteractionInfo = new QLabel(); infoLayout->addWidget(mInteractionInfo); QPushButton *helpButton = new QPushButton("?"); helpButton->setMaximumWidth(25); connect(helpButton, SIGNAL(clicked()), this, SLOT(helpClicked())); infoLayout->addWidget(helpButton); infoLayout->setStretchFactor(mInteractionInfo, 1); infoLayout->setStretchFactor(helpButton, 0); mainLayout->addLayout(infoLayout); QSettings settings; settings.beginGroup("Mantid/InstrumentWindow"); // Background colour setBackgroundColor( settings.value("BackgroundColor", QColor(0, 0, 0, 1.0)).value<QColor>()); // Create the b=tabs createTabs(settings); settings.endGroup(); // Init actions m_clearPeakOverlays = new QAction("Clear peaks", this); connect(m_clearPeakOverlays, SIGNAL(activated()), this, SLOT(clearPeakOverlays())); confirmClose(app->confirmCloseInstrWindow); setAttribute(Qt::WA_DeleteOnClose); // Watch for the deletion of the associated workspace observePreDelete(); observeAfterReplace(); observeRename(); observeADSClear(); connect(app->mantidUI->getAlgMonitor(), SIGNAL(algorithmStarted(void *)), this, SLOT(block())); connect(app->mantidUI->getAlgMonitor(), SIGNAL(allAlgorithmsStopped()), this, SLOT(unblock())); const int windowWidth = 800; const int tabsSize = windowWidth / 4; QList<int> sizes; sizes << tabsSize << windowWidth - tabsSize; controlPanelLayout->setSizes(sizes); controlPanelLayout->setStretchFactor(0, 0); controlPanelLayout->setStretchFactor(1, 1); resize(windowWidth, 650); tabChanged(0); connect(this, SIGNAL(needSetIntegrationRange(double, double)), this, SLOT(setIntegrationRange(double, double)), Qt::QueuedConnection); setAcceptDrops(true); setWindowTitle(QString("Instrument - ") + m_workspaceName); }
ItemMargin::ItemMargin(MainWindow* main) : QuasarWindow(main, "ItemMargin") { _helpSource = "item_margin.html"; QFrame* frame = new QFrame(this); QFrame* top = new QFrame(frame); _lookup = new ItemLookup(_main, this); _lookup->soldOnly = true; _lookup->store_id = _quasar->defaultStore(); QLabel* itemLabel = new QLabel(tr("Item Number:"), top); _item = new ItemEdit(_lookup, top); _item->setLength(18, '9'); itemLabel->setBuddy(_item); QLabel* descLabel = new QLabel(tr("Description:"), top); _desc = new LineEdit(top); _desc->setLength(30); _desc->setFocusPolicy(NoFocus); QLabel* storeLabel = new QLabel(tr("Store:"), top); _store = new LookupEdit(new StoreLookup(_main, this), top); _store->setLength(30); storeLabel->setBuddy(_store); QGridLayout* topGrid = new QGridLayout(top); topGrid->setMargin(3); topGrid->setSpacing(3); topGrid->setColStretch(2, 1); topGrid->addWidget(itemLabel, 0, 0); topGrid->addWidget(_item, 0, 1, AlignLeft | AlignVCenter); topGrid->addWidget(descLabel, 1, 0); topGrid->addWidget(_desc, 1, 1, AlignLeft | AlignVCenter); topGrid->addWidget(storeLabel, 2, 0); topGrid->addWidget(_store, 2, 1, AlignLeft | AlignVCenter); QGroupBox* price = new QGroupBox(tr("Price"), frame); QGridLayout* priceGrid = new QGridLayout(price,2,1,price->frameWidth()*2); priceGrid->addRowSpacing(0, price->fontMetrics().height()); QLabel* priceSizeLabel = new QLabel(tr("Size:"), price); _priceSize = new ComboBox(price); priceSizeLabel->setBuddy(_priceSize); QLabel* priceLabel = new QLabel(tr("Price:"), price); _price = new PriceEdit(price); priceLabel->setBuddy(_price); QLabel* priceTaxLabel = new QLabel(tr("Tax:"), price); _priceTax = new MoneyEdit(price); _priceTax->setFocusPolicy(NoFocus); priceTaxLabel->setBuddy(_priceTax); QLabel* priceDepositLabel = new QLabel(tr("Deposit:"), price); _priceDeposit = new MoneyEdit(price); _priceDeposit->setFocusPolicy(NoFocus); priceDepositLabel->setBuddy(_priceDeposit); QLabel* priceBaseLabel = new QLabel(tr("Base:"), price); _priceBase = new MoneyEdit(price); priceBaseLabel->setBuddy(_priceBase); priceGrid->setColStretch(2, 1); priceGrid->addWidget(priceSizeLabel, 1, 0); priceGrid->addWidget(_priceSize, 1, 1, AlignLeft | AlignVCenter); priceGrid->addWidget(priceLabel, 2, 0); priceGrid->addWidget(_price, 2, 1, AlignLeft | AlignVCenter); priceGrid->addWidget(priceTaxLabel, 3, 0); priceGrid->addWidget(_priceTax, 3, 1, AlignLeft | AlignVCenter); priceGrid->addWidget(priceDepositLabel, 4, 0); priceGrid->addWidget(_priceDeposit, 4, 1, AlignLeft | AlignVCenter); priceGrid->addWidget(priceBaseLabel, 5, 0); priceGrid->addWidget(_priceBase, 5, 1, AlignLeft | AlignVCenter); QGroupBox* cost = new QGroupBox(tr("Rep Cost"), frame); QGridLayout* costGrid = new QGridLayout(cost,2,1,cost->frameWidth()*2); costGrid->addRowSpacing(0, cost->fontMetrics().height()); QLabel* costSizeLabel = new QLabel(tr("Size:"), cost); _costSize = new ComboBox(cost); costSizeLabel->setBuddy(_costSize); QLabel* costLabel = new QLabel(tr("Cost:"), cost); _cost = new PriceEdit(cost); costLabel->setBuddy(_cost); QLabel* costTaxLabel = new QLabel(tr("Tax:"), cost); _costTax = new MoneyEdit(cost); _costTax->setFocusPolicy(NoFocus); costTaxLabel->setBuddy(_costTax); QLabel* costDepositLabel = new QLabel(tr("Deposit:"), cost); _costDeposit = new MoneyEdit(cost); _costDeposit->setFocusPolicy(NoFocus); costDepositLabel->setBuddy(_costDeposit); QLabel* costBaseLabel = new QLabel(tr("Base:"), cost); _costBase = new MoneyEdit(cost); costBaseLabel->setBuddy(_costBase); costGrid->setColStretch(2, 1); costGrid->addWidget(costSizeLabel, 1, 0); costGrid->addWidget(_costSize, 1, 1, AlignLeft | AlignVCenter); costGrid->addWidget(costLabel, 2, 0); costGrid->addWidget(_cost, 2, 1, AlignLeft | AlignVCenter); costGrid->addWidget(costTaxLabel, 3, 0); costGrid->addWidget(_costTax, 3, 1, AlignLeft | AlignVCenter); costGrid->addWidget(costDepositLabel, 4, 0); costGrid->addWidget(_costDeposit, 4, 1, AlignLeft | AlignVCenter); costGrid->addWidget(costBaseLabel, 5, 0); costGrid->addWidget(_costBase, 5, 1, AlignLeft | AlignVCenter); QGroupBox* margin = new QGroupBox(tr("Margin"), frame); QGridLayout* marginGrid = new QGridLayout(margin, 2, 1, margin->frameWidth()*2); marginGrid->addRowSpacing(0, margin->fontMetrics().height()); QLabel* marginSizeLabel = new QLabel(tr("Size:"), margin); _marginSize = new ComboBox(margin); marginSizeLabel->setBuddy(_marginSize); QLabel* marginPriceLabel = new QLabel(tr("Price:"), margin); _marginPrice = new MoneyEdit(margin); marginPriceLabel->setBuddy(_marginPrice); QLabel* targetLabel = new QLabel(tr("Target GM:"), margin); _targetGM = new PercentEdit(margin); _targetGM->setFocusPolicy(NoFocus); targetLabel->setBuddy(_targetGM); QLabel* repCostLabel = new QLabel(tr("Rep Cost:"), margin); _repCost = new MoneyEdit(margin); repCostLabel->setBuddy(_repCost); QLabel* repProfitLabel = new QLabel(tr("Rep Profit:"), margin); _repProfit = new MoneyEdit(margin); repProfitLabel->setBuddy(_repProfit); QLabel* repMarginLabel = new QLabel(tr("Rep Margin:"), margin); _repMargin = new PercentEdit(margin); repMarginLabel->setBuddy(_repMargin); QLabel* lastCostLabel = new QLabel(tr("Last Cost:"), margin); _lastCost = new MoneyEdit(margin); _lastCost->setFocusPolicy(NoFocus); lastCostLabel->setBuddy(_lastCost); QLabel* lastProfitLabel = new QLabel(tr("Last Profit:"), margin); _lastProfit = new MoneyEdit(margin); lastProfitLabel->setBuddy(_lastProfit); QLabel* lastMarginLabel = new QLabel(tr("Last Margin:"), margin); _lastMargin = new PercentEdit(margin); lastMarginLabel->setBuddy(_lastMargin); QLabel* avgCostLabel = new QLabel(tr("Avg Cost:"), margin); _avgCost = new MoneyEdit(margin); _avgCost->setFocusPolicy(NoFocus); avgCostLabel->setBuddy(_avgCost); QLabel* avgProfitLabel = new QLabel(tr("Avg Profit:"), margin); _avgProfit = new MoneyEdit(margin); avgProfitLabel->setBuddy(_avgProfit); QLabel* avgMarginLabel = new QLabel(tr("Avg Margin:"), margin); _avgMargin = new PercentEdit(margin); avgMarginLabel->setBuddy(_avgMargin); marginGrid->setColStretch(2, 1); marginGrid->setColStretch(5, 1); marginGrid->addColSpacing(2, 10); marginGrid->addColSpacing(5, 10); marginGrid->addWidget(marginSizeLabel, 1, 0); marginGrid->addWidget(_marginSize, 1, 1, AlignLeft | AlignVCenter); marginGrid->addWidget(marginPriceLabel, 1, 3); marginGrid->addWidget(_marginPrice, 1, 4, AlignLeft | AlignVCenter); marginGrid->addWidget(targetLabel, 1, 6); marginGrid->addWidget(_targetGM, 1, 7, AlignLeft | AlignVCenter); marginGrid->addWidget(repCostLabel, 2, 0); marginGrid->addWidget(_repCost, 2, 1, AlignLeft | AlignVCenter); marginGrid->addWidget(repProfitLabel, 2, 3); marginGrid->addWidget(_repProfit, 2, 4, AlignLeft | AlignVCenter); marginGrid->addWidget(repMarginLabel, 2, 6); marginGrid->addWidget(_repMargin, 2, 7, AlignLeft | AlignVCenter); marginGrid->addWidget(lastCostLabel, 3, 0); marginGrid->addWidget(_lastCost, 3, 1, AlignLeft | AlignVCenter); marginGrid->addWidget(lastProfitLabel, 3, 3); marginGrid->addWidget(_lastProfit, 3, 4, AlignLeft | AlignVCenter); marginGrid->addWidget(lastMarginLabel, 3, 6); marginGrid->addWidget(_lastMargin, 3, 7, AlignLeft | AlignVCenter); marginGrid->addWidget(avgCostLabel, 4, 0); marginGrid->addWidget(_avgCost, 4, 1, AlignLeft | AlignVCenter); marginGrid->addWidget(avgProfitLabel, 4, 3); marginGrid->addWidget(_avgProfit, 4, 4, AlignLeft | AlignVCenter); marginGrid->addWidget(avgMarginLabel, 4, 6); marginGrid->addWidget(_avgMargin, 4, 7, AlignLeft | AlignVCenter); QFrame* box = new QFrame(frame); QPushButton* refresh = new QPushButton(tr("&Refresh"), box); refresh->setMinimumSize(refresh->sizeHint()); connect(refresh, SIGNAL(clicked()), SLOT(slotRefresh())); QPushButton* save = new QPushButton(tr("&Save"), box); save->setMinimumSize(refresh->sizeHint()); connect(save, SIGNAL(clicked()), SLOT(slotSave())); QPushButton* close = new QPushButton(tr("Cl&ose"), box); close->setMinimumSize(refresh->sizeHint()); connect(close, SIGNAL(clicked()), SLOT(slotClose())); QGridLayout* boxGrid = new QGridLayout(box); boxGrid->setSpacing(6); boxGrid->setMargin(6); boxGrid->setColStretch(1, 1); boxGrid->addWidget(refresh, 0, 0, AlignLeft | AlignVCenter); boxGrid->addWidget(save, 0, 1, AlignRight | AlignVCenter); boxGrid->addWidget(close, 0, 2, AlignRight | AlignVCenter); QGridLayout* grid = new QGridLayout(frame); grid->setSpacing(6); grid->setMargin(6); grid->addMultiCellWidget(top, 0, 0, 0, 1); grid->addWidget(price, 1, 0); grid->addWidget(cost, 1, 1); grid->addMultiCellWidget(margin, 2, 2, 0, 1); grid->addMultiCellWidget(box, 3, 3, 0, 1); connect(_item, SIGNAL(validData()), SLOT(slotItemChanged())); connect(_store, SIGNAL(validData()), SLOT(slotStoreChanged())); connect(_priceSize, SIGNAL(activated(int)), SLOT(slotPriceSizeChanged())); connect(_price, SIGNAL(validData()), SLOT(slotPriceChanged())); connect(_priceBase, SIGNAL(validData()), SLOT(slotPriceBaseChanged())); connect(_costSize, SIGNAL(activated(int)), SLOT(slotCostSizeChanged())); connect(_cost, SIGNAL(validData()), SLOT(slotCostChanged())); connect(_costBase, SIGNAL(validData()), SLOT(slotCostBaseChanged())); connect(_marginSize, SIGNAL(activated(int)),SLOT(slotMarginSizeChanged())); connect(_marginPrice, SIGNAL(validData()), SLOT(slotMarginPriceChanged())); connect(_repCost, SIGNAL(validData()), SLOT(slotRepCostChanged())); connect(_repProfit, SIGNAL(validData()), SLOT(slotRepProfitChanged())); connect(_repMargin, SIGNAL(validData()), SLOT(slotRepMarginChanged())); connect(_lastProfit, SIGNAL(validData()), SLOT(slotLastProfitChanged())); connect(_lastMargin, SIGNAL(validData()), SLOT(slotLastMarginChanged())); connect(_avgProfit, SIGNAL(validData()), SLOT(slotAvgProfitChanged())); connect(_avgMargin, SIGNAL(validData()), SLOT(slotAvgMarginChanged())); setStoreId(_quasar->defaultStore()); _item->setFocus(); setCentralWidget(frame); setCaption(tr("Item Margin")); finalize(); }
/* * Initialize the GUI interface for the plugin - this is only called once when the plugin is * added to the plugin registry in the QGIS application. */ void CoordinateCapture::initGui() { mCrs.createFromSrsId( GEOCRS_ID ); // initialize the CRS object connect( mQGisIface->mapCanvas()->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( setSourceCrs() ) ); connect( mQGisIface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) ); setSourceCrs(); //set up the source CRS mTransform.setDestCRS( mCrs ); // set the CRS in the transform mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 5 : 3; // precision depends on CRS units // Create the action for tool mQActionPointer = new QAction( QIcon(), tr( "Coordinate Capture" ), this ); // Set the what's this text mQActionPointer->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) ); // Connect the action to the run connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) ); mQGisIface->addPluginToMenu( tr( "&Coordinate Capture" ), mQActionPointer ); // create our map tool mpMapTool = new CoordinateCaptureMapTool( mQGisIface->mapCanvas() ); connect( mpMapTool, SIGNAL( mouseMoved( QgsPoint ) ), this, SLOT( mouseMoved( QgsPoint ) ) ); connect( mpMapTool, SIGNAL( mouseClicked( QgsPoint ) ), this, SLOT( mouseClicked( QgsPoint ) ) ); // create a little widget with x and y display to put into our dock widget QWidget * mypWidget = new QWidget(); QGridLayout *mypLayout = new QGridLayout( mypWidget ); mypLayout->setColumnMinimumWidth( 0, 36 ); mypWidget->setLayout( mypLayout ); mypUserCrsToolButton = new QToolButton( mypWidget ); mypUserCrsToolButton->setToolTip( tr( "Click to select the CRS to use for coordinate display" ) ); connect( mypUserCrsToolButton, SIGNAL( clicked() ), this, SLOT( setCRS() ) ); mypCRSLabel = new QLabel( mypWidget ); mypCRSLabel->setGeometry( mypUserCrsToolButton->geometry() ); mpUserCrsEdit = new QLineEdit( mypWidget ); mpUserCrsEdit->setReadOnly( true ); mpUserCrsEdit->setToolTip( tr( "Coordinate in your selected CRS" ) ); mpCanvasEdit = new QLineEdit( mypWidget ); mpCanvasEdit->setReadOnly( true ); mpCanvasEdit->setToolTip( tr( "Coordinate in map canvas coordinate reference system" ) ); QPushButton * mypCopyButton = new QPushButton( mypWidget ); mypCopyButton->setText( tr( "Copy to clipboard" ) ); connect( mypCopyButton, SIGNAL( clicked() ), this, SLOT( copy() ) ); mpTrackMouseButton = new QToolButton( mypWidget ); mpTrackMouseButton->setCheckable( true ); mpTrackMouseButton->setToolTip( tr( "Click to enable mouse tracking. Click the canvas to stop" ) ); mpTrackMouseButton->setChecked( false ); // Create the action for tool mpCaptureButton = new QPushButton( mypWidget ); mpCaptureButton->setText( tr( "Start capture" ) ); mpCaptureButton->setToolTip( tr( "Click to enable coordinate capture" ) ); mpCaptureButton->setIcon( QIcon( ":/coordinate_capture/coordinate_capture.png" ) ); mpCaptureButton->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) ); connect( mpCaptureButton, SIGNAL( clicked() ), this, SLOT( run() ) ); // Set the icons setCurrentTheme( "" ); mypLayout->addWidget( mypUserCrsToolButton, 0, 0 ); mypLayout->addWidget( mpUserCrsEdit, 0, 1 ); mypLayout->addWidget( mypCRSLabel, 1, 0 ); mypLayout->addWidget( mpCanvasEdit, 1, 1 ); mypLayout->addWidget( mpTrackMouseButton, 2, 0 ); mypLayout->addWidget( mypCopyButton, 2, 1 ); mypLayout->addWidget( mpCaptureButton, 3, 1 ); //create the dock widget mpDockWidget = new QDockWidget( tr( "Coordinate Capture" ), mQGisIface->mainWindow() ); mpDockWidget->setObjectName( "CoordinateCapture" ); mpDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); mQGisIface->addDockWidget( Qt::LeftDockWidgetArea, mpDockWidget ); // now add our custom widget to the dock - ownership of the widget is passed to the dock mpDockWidget->setWidget( mypWidget ); }
// // riceve i caratteri che sono stati digitati: void widgetKeyBoard::receiptChildKey(QKeyEvent *event, QLineEdit *focusThisControl, bool reset) { static QLineEdit *nextInput = NULL; if (reset == true) { // reinizializza il controllo nextInput = this->getNextTextbox(focusThisControl, true); return; } if (nextInput == NULL) return; // // inizia l'analisi del carattere ricevuto: QString newKey = event->text(); QString tmpReceiptString = nextInput->text(); int tmpPos = nextInput->cursorPosition(); if (NO_SPECIAL_KEY(newKey) == false) { if (IS_RETURN(newKey) == true ) { // trattasi di TAB, si sposta alla text successiva emit return_touched(); } if (IS_TAB(newKey) == true) { // trattasi di TAB, si sposta alla text successiva nextInput = this->setDefaultTextStyle(nextInput); nextInput->deselect(); nextInput = this->getNextTextbox(); this->controlKeyEcho(nextInput); // status of key echo here if (nextInput != NULL) { nextInput->setCursorPosition(nextInput->text().length()); // comment this line if you want caret position at current char inserted nextInput->setFocus(Qt::TabFocusReason); } } else if (IS_BACK(newKey) == true || IS_BACK_EMB(newKey) == true) { // trattasi di CANCELLARE carattere, elimina il carattere a sinistra if (tmpPos-1 >= 0) { tmpReceiptString = tmpReceiptString.remove(tmpPos-1, 1); nextInput->setText(tmpReceiptString); nextInput->setCursorPosition(tmpPos-1); nextInput->setSelection(tmpPos-2, 1); } } else if (IS_CANC(newKey) == true) { // trattasi di CANC carattere, elimina il carattere a destra tmpReceiptString = tmpReceiptString.remove(tmpPos, 1); nextInput->setText(tmpReceiptString); nextInput->setCursorPosition(tmpPos); nextInput->setSelection(tmpPos-1, 1); } else if (IS_COPY(newKey) == true || IS_CUT_LEFT(newKey) == true) { QPushButton *button = this->findChild<QPushButton *>(KEY_PASTE); if (button != NULL) { if (nextInput->text().length() != 0) { this->m_clipboard->setText(nextInput->text()); if (IS_CUT_LEFT(newKey) == true) nextInput->setText(""); button->setEnabled(true); } else button->setEnabled(false); } } else if (IS_PASTE(newKey) == true) nextInput->setText(this->m_clipboard->text()); else if (IS_ALT(newKey) == true || IS_CTRL_LEFT(newKey) == true) { ; // non esegue nessuna operazione } } else { // si tratta di un carattere da visualizzare nella casella di testo corrente tmpReceiptString = tmpReceiptString.insert(tmpPos, newKey); nextInput->setText(tmpReceiptString); nextInput->setCursorPosition(tmpPos+1); nextInput->setSelection(tmpPos, 1); } }
void ItemHandlerCombobox::Handle (const QDomElement& item, QWidget *pwidget) { QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ()); QHBoxLayout *hboxLay = new QHBoxLayout; QComboBox *box = new QComboBox (XSD_); hboxLay->addWidget (box); XSD_->SetTooltip (box, item); box->setObjectName (item.attribute ("property")); box->setSizeAdjustPolicy (QComboBox::AdjustToContents); if (item.hasAttribute ("maxVisibleItems")) box->setMaxVisibleItems (item.attribute ("maxVisibleItems").toInt ()); bool mayHaveDataSource = item.hasAttribute ("mayHaveDataSource") && item.attribute ("mayHaveDataSource").toLower () == "true"; if (mayHaveDataSource) { const QString& prop = item.attribute ("property"); Factory_->RegisterDatasourceSetter (prop, [this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog *xsd) { SetDataSource (str, m, xsd); }); Propname2Combobox_ [prop] = box; Propname2Item_ [prop] = item; } hboxLay->addStretch (); if (item.hasAttribute ("moreThisStuff")) { QPushButton *moreButt = new QPushButton (tr ("More stuff...")); hboxLay->addWidget (moreButt); moreButt->setObjectName (item.attribute ("moreThisStuff")); connect (moreButt, SIGNAL (released ()), XSD_, SLOT (handleMoreThisStuffRequested ())); } QDomElement option = item.firstChildElement ("option"); while (!option.isNull ()) { const auto& images = XSD_->GetImages (option); if (!images.isEmpty ()) { const QIcon icon (QPixmap::fromImage (images.at (0))); box->addItem (icon, XSD_->GetLabel (option), option.attribute ("name")); } else box->addItem (XSD_->GetLabel (option), option.attribute ("name")); auto setColor = [&option, box] (const QString& attr, Qt::ItemDataRole role) -> void { if (option.hasAttribute (attr)) { const QColor color (option.attribute (attr)); box->setItemData (box->count () - 1, color, role); } }; setColor ("color", Qt::ForegroundRole); setColor ("bgcolor", Qt::BackgroundRole); option = option.nextSiblingElement ("option"); } connect (box, SIGNAL (currentIndexChanged (int)), this, SLOT (updatePreferences ())); QDomElement scriptContainer = item.firstChildElement ("scripts"); if (!scriptContainer.isNull ()) { Scripter scripter (scriptContainer); QStringList fromScript = scripter.GetOptions (); Q_FOREACH (const QString& elm, scripter.GetOptions ()) box->addItem (scripter.HumanReadableOption (elm), elm); }
ThreeAxisDataVisualizator::ThreeAxisDataVisualizator(int duree,int dataFreq,int min, int max, int _type, QWidget *parent): QWidget(parent), duree_de_visualisation(duree), frequency(dataFreq), type(_type), min(0), max(0) { curves = QList<QString>(); QString typeStr; if(type==DataType::acc){ typeStr = "accelerometre"; }else if(type==DataType::gyro){ typeStr = "gyroscope"; }else if(type==DataType::euler){ typeStr = "euler"; }else if(type==DataType::qua){ typeStr = "quaternion"; } curves.append(typeStr+" x"); curves.append(typeStr+" y"); curves.append(typeStr+" z"); QHBoxLayout * mainLayout = new QHBoxLayout; this->setLayout(mainLayout); plot = new QwtPlot(); mainLayout->addWidget(plot,5); QWidget * checkBoxGroup = new QWidget(this); mainLayout->addWidget(checkBoxGroup,1); QVBoxLayout * checkBoxGroupLayout = new QVBoxLayout; checkBoxGroup->setLayout(checkBoxGroupLayout); QPushButton * resetScaleButton = new QPushButton; resetScaleButton->setText("reset y scale"); setStyleSheet("QPushButton{" "font-family: Futura;" "color:#4C6BCF;" "font-size: 14px;" "border:2px solid ;" "border-color: #4C6BCF;" "border-radius:5px;" "min-height:60;}"); checkBoxGroupLayout->addWidget(resetScaleButton); checkBoxX = new QCheckBox(curves.at(0),checkBoxGroup); checkBoxGroupLayout->addWidget(checkBoxX); checkBoxY = new QCheckBox(curves.at(1),checkBoxGroup); checkBoxGroupLayout->addWidget(checkBoxY); checkBoxZ = new QCheckBox(curves.at(2),checkBoxGroup); checkBoxGroupLayout->addWidget(checkBoxZ); timeSlider = new QSlider(Qt::Horizontal,checkBoxGroup); checkBoxGroupLayout->addWidget(timeSlider); checkBoxX->setChecked(true); checkBoxY->setChecked(true); checkBoxZ->setChecked(true); QSignalMapper * mapper = new QSignalMapper; mapper->setMapping(checkBoxX,0); mapper->setMapping(checkBoxY,1); mapper->setMapping(checkBoxZ,2); connect(checkBoxX,SIGNAL(stateChanged(int)),mapper,SLOT(map())); connect(checkBoxY,SIGNAL(stateChanged(int)),mapper,SLOT(map())); connect(checkBoxZ,SIGNAL(stateChanged(int)),mapper,SLOT(map())); connect(mapper,SIGNAL(mapped(int)),SLOT(handleCheckBox(int))); // canvas QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setLineWidth( 1 ); canvas->setFrameStyle( QFrame::Box | QFrame::Plain ); canvas->setBorderRadius( 15 ); QPalette canvasPalette( Qt::white ); canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) ); canvas->setPalette( canvasPalette ); plot->setCanvas( canvas ); QwtPlotScaleItem *it1 = new QwtPlotScaleItem(QwtScaleDraw::BottomScale ,0.0); it1->attach(plot); plot->enableAxis(QwtPlot::xBottom,false); plot->setAxisScale( QwtPlot::xBottom, 0.0, duree_de_visualisation ); plot->setAxisScale( QwtPlot::yLeft, min, max ); xCurve = new QwtPlotCurve( curves.at(0)); xCurve->setRenderHint( QwtPlotItem::RenderAntialiased ); xCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); xCurve->setPen( Qt::red ); xCurve->attach( plot ); yCurve = new QwtPlotCurve(curves.at(1)); yCurve->setRenderHint( QwtPlotItem::RenderAntialiased ); yCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); yCurve->setPen( Qt::blue ); yCurve->attach( plot ); zCurve = new QwtPlotCurve( curves.at(2)); zCurve->setRenderHint( QwtPlotItem::RenderAntialiased ); zCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); zCurve->setPen( Qt::green ); zCurve->attach( plot ); timerReplot = new QTimer; timerReplot->setInterval(50); connect(timerReplot,SIGNAL(timeout()),plot,SLOT(replot())); connect(timeSlider,SIGNAL(sliderMoved(int)),SLOT(updateVizualizatorTimeWindow(int))); timerRescale = new QTimer; timerRescale->setInterval(1000); connect(timerRescale,SIGNAL(timeout()),SLOT(rescale())); connect(resetScaleButton,SIGNAL(clicked(bool)),SLOT(resetScale())); setEnabled(false); }
dvrkTeleopQWidget::dvrkTeleopQWidget(const std::string &name, const double &period): QWidget(), counter_(0) { is_head_in_ = false; is_clutched_ = false; is_move_psm_ = false; // subscriber // NOTE: queue size is set to 1 to make sure data is fresh sub_mtm_pose_ = nh_.subscribe("/dvrk_mtm/cartesian_pose_current", 1, &dvrkTeleopQWidget::master_pose_cb, this); sub_psm_pose_ = nh_.subscribe("/dvrk_psm/cartesian_pose_current", 1, &dvrkTeleopQWidget::slave_pose_cb, this); // publisher pub_teleop_enable_ = nh_.advertise<std_msgs::Bool>("/dvrk_teleop/enable", 100); pub_mtm_control_mode_ = nh_.advertise<std_msgs::Int8>("/dvrk_mtm/control_mode", 100); pub_psm_control_mode_ = nh_.advertise<std_msgs::Int8>("/dvrk_psm/control_mode", 100); pub_enable_slider_ = nh_.advertise<sensor_msgs::JointState>("/dvrk_mtm/joint_state_publisher/enable_slider", 100); // pose display mtm_pose_qt_ = new vctQtWidgetFrame4x4DoubleRead; psm_pose_qt_ = new vctQtWidgetFrame4x4DoubleRead; QVBoxLayout *poseLayout = new QVBoxLayout; poseLayout->addWidget(mtm_pose_qt_); poseLayout->addWidget(psm_pose_qt_); // common console QGroupBox *consoleBox = new QGroupBox("Console"); QPushButton *consoleHomeButton = new QPushButton(tr("Home")); QPushButton *consoleManualButton = new QPushButton(tr("Manual")); QPushButton *consoleTeleopTestButton = new QPushButton(tr("TeleopTest")); consoleTeleopButton = new QPushButton(tr("Teleop")); consoleHomeButton->setStyleSheet("font: bold; color: green;"); consoleManualButton->setStyleSheet("font: bold; color: red;"); consoleTeleopTestButton->setStyleSheet("font: bold; color: blue;"); consoleTeleopButton->setStyleSheet("font: bold; color: brown;"); consoleHomeButton->setCheckable(true); consoleManualButton->setCheckable(true); consoleTeleopTestButton->setCheckable(true); consoleTeleopButton->setCheckable(true); QButtonGroup *consoleButtonGroup = new QButtonGroup; consoleButtonGroup->setExclusive(true); consoleButtonGroup->addButton(consoleHomeButton); consoleButtonGroup->addButton(consoleManualButton); consoleButtonGroup->addButton(consoleTeleopTestButton); consoleButtonGroup->addButton(consoleTeleopButton); QHBoxLayout *consoleBoxLayout = new QHBoxLayout; consoleBoxLayout->addWidget(consoleHomeButton); consoleBoxLayout->addWidget(consoleManualButton); consoleBoxLayout->addWidget(consoleTeleopTestButton); consoleBoxLayout->addWidget(consoleTeleopButton); consoleBoxLayout->addStretch(); consoleBox->setLayout(consoleBoxLayout); // mtm console mtmBox = new QGroupBox("MTM"); QVBoxLayout *mtmBoxLayout = new QVBoxLayout; mtmClutchButton = new QPushButton(tr("Clutch")); mtmClutchButton->setCheckable(true); mtmBoxLayout->addWidget(mtmClutchButton); mtmHeadButton = new QPushButton(tr("Head")); mtmHeadButton->setCheckable(true); mtmBoxLayout->addWidget(mtmHeadButton); mtmBoxLayout->addStretch(); mtmBox->setLayout(mtmBoxLayout); // psm console psmBox = new QGroupBox("PSM"); QVBoxLayout *psmBoxLayout = new QVBoxLayout; psmMoveButton = new QPushButton(tr("Move Tool")); psmMoveButton->setCheckable(true); psmBoxLayout->addWidget(psmMoveButton); psmBoxLayout->addStretch(); psmBox->setLayout(psmBoxLayout); // rightLayout QGridLayout *rightLayout = new QGridLayout; rightLayout->addWidget(consoleBox, 0, 0, 1, 2); rightLayout->addWidget(mtmBox, 1, 0); rightLayout->addWidget(psmBox, 1, 1); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addLayout(poseLayout); mainLayout->addLayout(rightLayout); this->setLayout(mainLayout); this->resize(sizeHint()); this->setWindowTitle("Teleopo GUI"); // set stylesheet std::string filename = ros::package::getPath("dvrk_teleop"); filename.append("/src/default.css"); QFile defaultStyleFile(filename.c_str()); defaultStyleFile.open(QFile::ReadOnly); QString styleSheet = QLatin1String(defaultStyleFile.readAll()); this->setStyleSheet(styleSheet); // now connect everything connect(consoleHomeButton, SIGNAL(clicked()), this, SLOT(slot_homeButton_pressed())); connect(consoleManualButton, SIGNAL(clicked()), this, SLOT(slot_manualButton_pressed())); connect(consoleTeleopTestButton, SIGNAL(clicked()), this, SLOT(slot_teleopTestButton_pressed())); connect(consoleTeleopButton, SIGNAL(toggled(bool)), this, SLOT(slot_teleopButton_toggled(bool))); connect(mtmHeadButton, SIGNAL(clicked(bool)), this, SLOT(slot_headButton_pressed(bool))); connect(mtmClutchButton, SIGNAL(clicked(bool)), this, SLOT(slot_clutchButton_pressed(bool))); connect(psmMoveButton, SIGNAL(clicked(bool)), this, SLOT(slot_moveToolButton_pressed(bool))); // show widget & start timer startTimer(period); // 50 ms slot_teleopButton_toggled(false); }
SettingsPageInformation::SettingsPageInformation( QWidget *parent ) : QWidget(parent) { setObjectName("SettingsPageInformation"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("Settings - Information") ); if( parent ) { resize( parent->size() ); } // Layout used by scroll area QHBoxLayout *sal = new QHBoxLayout; // new widget used as container for the dialog layout. QWidget* sw = new QWidget; // Scroll area QScrollArea* sa = new QScrollArea; sa->setWidgetResizable( true ); sa->setFrameStyle( QFrame::NoFrame ); sa->setWidget( sw ); #ifdef QSCROLLER QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture ); #endif #ifdef QTSCROLLER QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture ); #endif // Add scroll area to its own layout sal->addWidget( sa ); QHBoxLayout *contentLayout = new QHBoxLayout; setLayout(contentLayout); // Pass scroll area layout to the content layout. contentLayout->addLayout( sal, 10 ); // The parent of the layout is the scroll widget QGridLayout *topLayout = new QGridLayout(sw); topLayout->setHorizontalSpacing(20 * Layout::getIntScaledDensity() ); topLayout->setVerticalSpacing(10 * Layout::getIntScaledDensity() ); int row=0; #ifndef ANDROID QHBoxLayout *hBox = new QHBoxLayout(); QPushButton *soundSelection = new QPushButton( tr("Sound Player"), this ); soundSelection->setToolTip(tr("Select a sound player, use %s if played file is enclosed in command line arguments")); hBox->addWidget(soundSelection); connect(soundSelection, SIGNAL( clicked()), this, SLOT(slot_openToolDialog()) ); Qt::InputMethodHints imh; soundTool = new QLineEdit( this ); imh = (soundTool->inputMethodHints() | Qt::ImhNoPredictiveText); soundTool->setInputMethodHints(imh); connect( soundTool, SIGNAL(returnPressed()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); hBox->addWidget(soundTool); topLayout->addLayout( hBox, row++, 0, 1, 3 ); topLayout->setRowMinimumHeight( row++, 10 ); #endif topLayout->addWidget(new QLabel(tr("Airfield display time:"), this), row, 0); spinAirfield = createNumEd( this ); topLayout->addWidget( spinAirfield, row, 1 ); row++; topLayout->addWidget(new QLabel(tr("Airspace display time:"), this), row, 0); spinAirspace = createNumEd( this ); topLayout->addWidget( spinAirspace, row, 1 ); row++; topLayout->addWidget(new QLabel(tr("Info display time:"), this), row, 0); spinInfo = createNumEd( this ); topLayout->addWidget( spinInfo, row, 1 ); row++; topLayout->addWidget(new QLabel(tr("Waypoint display time:"), this), row, 0); spinWaypoint = createNumEd( this ); topLayout->addWidget( spinWaypoint, row, 1 ); row++; topLayout->addWidget(new QLabel(tr("Warning display time:"), this), row, 0); spinWarning = createNumEd( this ); topLayout->addWidget( spinWarning, row, 1 ); row++; topLayout->addWidget(new QLabel(tr("Warning suppress time:"), this), row, 0); spinSuppress = new NumberEditor; spinSuppress->setDecimalVisible( false ); spinSuppress->setPmVisible( false ); spinSuppress->setMaxLength(3); spinSuppress->setRange(0, 60); spinSuppress->setSpecialValueText(tr("Off")); spinSuppress->setSuffix( " min" ); spinSuppress->setTip("0...60 min"); QRegExpValidator* eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,2})" ), this ); spinSuppress->setValidator( eValidator ); // Sets a minimum width for the widget int mw = QFontMetrics(font()).width(QString("999 min")) + 10; spinSuppress->setMinimumWidth( mw ); topLayout->addWidget( spinSuppress, row, 1 ); buttonReset = new QPushButton (tr("Defaults"), this); topLayout->addWidget( buttonReset, row, 2, Qt::AlignLeft ); row++; checkAlarmSound = new QCheckBox(tr("Alarm Sound"), this); checkAlarmSound->setObjectName("checkAlarmSound"); checkAlarmSound->setChecked(true); topLayout->addWidget( checkAlarmSound, row, 0 ); checkFlarmAlarms = new QCheckBox(tr("Flarm Alarms"), this); checkFlarmAlarms->setObjectName("checkFlarmAlarms"); checkFlarmAlarms->setChecked(true); topLayout->addWidget( checkFlarmAlarms, row, 1, 1, 2 ); row++; calculateNearestSites = new QCheckBox(tr("Nearest Site Calculator"), this); calculateNearestSites->setObjectName("calcNearest"); calculateNearestSites->setChecked(true); topLayout->addWidget( calculateNearestSites, row, 0 ); inverseInfoDisplay = new QCheckBox(tr("Black Display"), this); inverseInfoDisplay->setObjectName("inverseDisplay"); inverseInfoDisplay->setChecked(false); topLayout->addWidget( inverseInfoDisplay, row, 1, 1, 2 ); row++; topLayout->setRowStretch ( row, 10 ); topLayout->setColumnStretch( 2, 10 ); connect( buttonReset, SIGNAL(clicked()), SLOT(slot_setFactoryDefault()) ); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *ok = new QPushButton(this); ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); titlePix->setPixmap(GeneralConfig::instance()->loadPixmap("setup.png")); connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); contentLayout->addLayout(buttonBox); load(); }
SyntaxEditorWindow::SyntaxEditorWindow(const QSharedPointer<SyntaxList> &syntaxList, const QString &syntaxName, const QString &category, const QString &syntaxHint, QWidget *parent) : QWidget(parent), syntaxList(syntaxList), syntaxName(syntaxName) { setWindowRole("kadu-syntax-editor"); setWindowTitle(tr("Kadu syntax editor")); setAttribute(Qt::WA_DeleteOnClose); QVBoxLayout *layout = new QVBoxLayout(this); QSplitter *splitter = new QSplitter(this); layout->addWidget(splitter); splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); splitter->setChildrenCollapsible(false); QWidget *splitterleft = new QWidget(splitter); QVBoxLayout *splitterleftlayout = new QVBoxLayout(splitterleft); splitterleftlayout->setMargin(0); splitterleftlayout->setSpacing(5); editor = new QTextEdit(this); splitterleftlayout->addWidget(editor); editor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); editor->setAcceptRichText(true); editor->setPlainText(syntaxList->readSyntax(syntaxName)); QFont font = this->font(); font.setFamily("monospace"); if(font.pixelSize() == -1) font.setPointSizeF(font.pointSizeF() - 0.5); else font.setPixelSize(font.pixelSize() - 2); editor->setFont(font); editor->setMinimumSize(EDITOR_MINIMUM_SIZE); if (!syntaxHint.isEmpty()) { QLabel *editorhint = new QLabel(this); splitterleftlayout->addWidget(editorhint); editorhint->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); editorhint->setWordWrap(true); editorhint->setText(syntaxHint); } QWidget *splitterright = new QWidget(splitter); QVBoxLayout *splitterrightlayout = new QVBoxLayout(splitterright); splitterrightlayout->setMargin(0); splitterrightlayout->setSpacing(5); previewPanel = new Preview(this); splitterrightlayout->addWidget(previewPanel); previewPanel->setMinimumHeight(0); previewPanel->setMaximumHeight(QWIDGETSIZE_MAX); previewPanel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); previewPanel->setResetBackgroundColor(config_file.readEntry("Look", category + "BgColor")); previewPanel->setMinimumSize(PREVIEW_MINIMUM_SIZE); QPushButton *previewbutton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_BrowserReload), tr("Refresh Preview"), this); splitterrightlayout->addWidget(previewbutton); connect(previewbutton, SIGNAL(clicked()), this, SLOT(refreshPreview())); QDialogButtonBox *buttonslayout = new QDialogButtonBox(Qt::Horizontal, this); layout->addWidget(buttonslayout); QPushButton *saveSyntax = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogOkButton), tr("Save"), this); QPushButton *saveAsSyntax = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogSaveButton), tr("Save as..."), this); QPushButton *cancel = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogCancelButton), tr("Cancel"), this); buttonslayout->addButton(saveSyntax, QDialogButtonBox::YesRole); buttonslayout->addButton(saveAsSyntax, QDialogButtonBox::ActionRole); buttonslayout->addButton(cancel, QDialogButtonBox::RejectRole); splitter->setSizes( QList<int>() << splitter->sizeHint().width() << 1 ); if (syntaxList->isGlobal(syntaxName)) saveSyntax->setDisabled(true); else connect(saveSyntax, SIGNAL(clicked()), this, SLOT(save())); connect(saveAsSyntax, SIGNAL(clicked()), this, SLOT(saveAs())); connect(cancel, SIGNAL(clicked()), this, SLOT(close())); loadWindowGeometry(this, "Look", "SyntaxEditorGeometry", 0, 50, 790, 480); }
GBAKeyEditor::GBAKeyEditor(InputController* controller, int type, const QString& profile, QWidget* parent) : QWidget(parent) , m_profileSelect(nullptr) , m_type(type) , m_profile(profile) , m_controller(controller) { setWindowFlags(windowFlags() & ~Qt::WindowFullscreenButtonHint); setMinimumSize(300, 300); const GBAInputMap* map = controller->map(); m_keyDU = new KeyEditor(this); m_keyDD = new KeyEditor(this); m_keyDL = new KeyEditor(this); m_keyDR = new KeyEditor(this); m_keySelect = new KeyEditor(this); m_keyStart = new KeyEditor(this); m_keyA = new KeyEditor(this); m_keyB = new KeyEditor(this); m_keyL = new KeyEditor(this); m_keyR = new KeyEditor(this); refresh(); #ifdef BUILD_SDL lookupAxes(map); if (type == SDL_BINDING_BUTTON) { m_profileSelect = new QComboBox(this); m_profileSelect->addItems(controller->connectedGamepads(type)); int activeGamepad = controller->gamepad(type); if (activeGamepad > 0) { m_profileSelect->setCurrentIndex(activeGamepad); } connect(m_profileSelect, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this] (int i) { m_controller->setGamepad(m_type, i); m_profile = m_profileSelect->currentText(); m_controller->loadProfile(m_type, m_profile); refresh(); }); } #endif connect(m_keyDU, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(m_keyDD, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(m_keyDL, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(m_keyDR, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(m_keySelect, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(m_keyStart, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(m_keyA, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(m_keyB, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(m_keyL, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(m_keyR, SIGNAL(valueChanged(int)), this, SLOT(setNext())); connect(m_keyDU, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); connect(m_keyDD, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); connect(m_keyDL, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); connect(m_keyDR, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); connect(m_keySelect, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); connect(m_keyStart, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); connect(m_keyA, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); connect(m_keyB, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); connect(m_keyL, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); connect(m_keyR, SIGNAL(axisChanged(int, int)), this, SLOT(setNext())); m_buttons = new QWidget(this); QVBoxLayout* layout = new QVBoxLayout; m_buttons->setLayout(layout); QPushButton* setAll = new QPushButton(tr("Set all")); connect(setAll, SIGNAL(pressed()), this, SLOT(setAll())); layout->addWidget(setAll); QPushButton* save = new QPushButton(tr("Save")); connect(save, SIGNAL(pressed()), this, SLOT(save())); layout->addWidget(save); layout->setSpacing(6); m_keyOrder = QList<KeyEditor*>{ m_keyDU, m_keyDR, m_keyDD, m_keyDL, m_keyA, m_keyB, m_keySelect, m_keyStart, m_keyL, m_keyR }; m_currentKey = m_keyOrder.end(); m_background.load(":/res/keymap.qpic"); setAll->setFocus(); }
LRESULT CALLBACK BorderlessWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { BorderlessWindow* window = reinterpret_cast<BorderlessWindow*>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); if (!window) return DefWindowProc(hWnd, message, wParam, lParam); switch (message) { case WM_KEYDOWN: { switch (wParam) { case VK_F5: { window->borderlessResizeable = !window->borderlessResizeable; break; } case VK_F6: { window->toggleShadow(); window->toggleBorderless(); SetFocus(g_winId); break; } case VK_F7: { window->toggleShadow(); break; } } if (wParam != VK_TAB) return DefWindowProc(hWnd, message, wParam, lParam); SetFocus(g_winId); break; } // ALT + SPACE or F10 system menu case WM_SYSCOMMAND: { if (wParam == SC_KEYMENU) { RECT winrect; GetWindowRect(hWnd, &winrect); TrackPopupMenu(GetSystemMenu(hWnd, false), TPM_TOPALIGN | TPM_LEFTALIGN, winrect.left + 5, winrect.top + 5, 0, hWnd, NULL); break; } else { return DefWindowProc(hWnd, message, wParam, lParam); } } case WM_SETFOCUS: { QString str("Got focus"); QWidget* widget = QWidget::find((WId)HWND(wParam)); if (widget) str += QString(" from %1 (%2)").arg(widget->objectName()).arg(widget->metaObject()->className()); str += "\n"; OutputDebugStringA(str.toLocal8Bit().data()); break; } case WM_NCCALCSIZE: { //this kills the window frame and title bar we added with //WS_THICKFRAME and WS_CAPTION if (window->borderless) { return 0; } break; } case WM_KILLFOCUS: { QString str("Lost focus"); QWidget* widget = QWidget::find((WId)HWND(wParam)); if (widget) str += QString(" to %1 (%2)").arg(widget->objectName()).arg(widget->metaObject()->className()); str += "\n"; OutputDebugStringA(str.toLocal8Bit().data()); break; } case WM_DESTROY: { PostQuitMessage(0); break; } case WM_NCHITTEST: { if (window->borderless) { if (window->borderlessResizeable) { const LONG c_borderWidth = 8; //in pixels RECT winrect; GetWindowRect(hWnd, &winrect); long x = GET_X_LPARAM(lParam); long y = GET_Y_LPARAM(lParam); //bottom left corner if (x >= winrect.left && x < winrect.left + c_borderWidth && y < winrect.bottom && y >= winrect.bottom - c_borderWidth) { return HTBOTTOMLEFT; } //bottom right corner if (x < winrect.right && x >= winrect.right - c_borderWidth && y < winrect.bottom && y >= winrect.bottom - c_borderWidth) { return HTBOTTOMRIGHT; } //top left corner if (x >= winrect.left && x < winrect.left + c_borderWidth && y >= winrect.top && y < winrect.top + c_borderWidth) { return HTTOPLEFT; } //top right corner if (x < winrect.right && x >= winrect.right - c_borderWidth && y >= winrect.top && y < winrect.top + c_borderWidth) { return HTTOPRIGHT; } //left border if (x >= winrect.left && x < winrect.left + c_borderWidth) { return HTLEFT; } //right border if (x < winrect.right && x >= winrect.right - c_borderWidth) { return HTRIGHT; } //bottom border if (y < winrect.bottom && y >= winrect.bottom - c_borderWidth) { return HTBOTTOM; } //top border if (y >= winrect.top && y < winrect.top + c_borderWidth) { return HTTOP; } } return HTCAPTION; } break; } case WM_SIZE: { RECT winrect; GetClientRect(hWnd, &winrect); WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(hWnd, &wp); if (wp.showCmd == SW_MAXIMIZE) { QPushButton* pushButtonMaximize = mainPanel->findChild<QPushButton*>("pushButtonMaximize"); pushButtonMaximize->setStyleSheet("#pushButtonMaximize {image: url(:/SystemMenu/Icons/Restore.png);} #pushButtonMaximize:hover { image: url(:/SystemMenu/Icons/RestoreHover.png); }"); mainPanel->setGeometry(8, 8, winrect.right - 16, winrect.bottom - 16); } else { QPushButton* pushButtonMaximize = mainPanel->findChild<QPushButton*>("pushButtonMaximize"); pushButtonMaximize->setStyleSheet("#pushButtonMaximize {image: url(:/SystemMenu/Icons/Maximize.png);} #pushButtonMaximize:hover { image: url(:/SystemMenu/Icons/MaximizeHover.png); }"); mainPanel->setGeometry(2, 2, winrect.right - 4, winrect.bottom - 4); } break; } case WM_GETMINMAXINFO: { MINMAXINFO* minMaxInfo = (MINMAXINFO*)lParam; if (window->minimumSize.required) { minMaxInfo->ptMinTrackSize.x = window->getMinimumWidth();; minMaxInfo->ptMinTrackSize.y = window->getMinimumHeight(); } if (window->maximumSize.required) { minMaxInfo->ptMaxTrackSize.x = window->getMaximumWidth(); minMaxInfo->ptMaxTrackSize.y = window->getMaximumHeight(); } return 0; } } return DefWindowProc(hWnd, message, wParam, lParam); }
HatPrompt::HatPrompt(int currentIndex, QWidget* parent) : QDialog(parent) { setModal(true); setWindowFlags(Qt::Sheet); setWindowModality(Qt::WindowModal); setMinimumSize(550, 430); resize(550, 430); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setStyleSheet("QPushButton { padding: 5px; margin-top: 10px; }"); // Hat model, and a model for setting a filter HatModel * hatModel = DataManager::instance().hatModel(); filterModel = new QSortFilterProxyModel(); filterModel->setSourceModel(hatModel); filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); // Grid QGridLayout * dialogLayout = new QGridLayout(this); dialogLayout->setSpacing(0); dialogLayout->setColumnStretch(1, 1); QHBoxLayout * topLayout = new QHBoxLayout(); // Help/prompt message at top QLabel * lblDesc = new QLabel(tr("Search for a hat:")); lblDesc->setObjectName("lblDesc"); lblDesc->setStyleSheet("#lblDesc { color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-top-left-radius: 10px; padding: 4px 10px;}"); lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); lblDesc->setFixedHeight(24); lblDesc->setMinimumWidth(0); // Filter text box QWidget * filterContainer = new QWidget(); filterContainer->setFixedHeight(24); filterContainer->setObjectName("filterContainer"); filterContainer->setStyleSheet("#filterContainer { background: #F6CB1C; border-top-right-radius: 10px; padding: 3px; }"); filterContainer->setFixedWidth(150); txtFilter = new LineEditCursor(filterContainer); txtFilter->setFixedWidth(150); txtFilter->setFocus(); txtFilter->setFixedHeight(22); txtFilter->setStyleSheet("LineEditCursor { border-width: 0px; border-radius: 6px; margin-top: 3px; margin-right: 3px; padding-left: 4px; padding-bottom: 2px; background-color: rgb(23, 11, 54); } LineEditCursor:hover, LineEditCursor:focus { background-color: rgb(13, 5, 68); }"); connect(txtFilter, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged(const QString &))); connect(txtFilter, SIGNAL(moveUp()), this, SLOT(moveUp())); connect(txtFilter, SIGNAL(moveDown()), this, SLOT(moveDown())); connect(txtFilter, SIGNAL(moveLeft()), this, SLOT(moveLeft())); connect(txtFilter, SIGNAL(moveRight()), this, SLOT(moveRight())); // Corner widget QLabel * corner = new QLabel(); corner->setPixmap(QPixmap(QString::fromUtf8(":/res/inverse-corner-bl.png"))); corner->setFixedSize(10, 10); // Add widgets to top layout topLayout->addWidget(lblDesc); topLayout->addWidget(filterContainer); topLayout->addWidget(corner, 0, Qt::AlignBottom); topLayout->addStretch(1); // Cancel button (closes dialog) QPushButton * btnCancel = new QPushButton(tr("Cancel")); connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); // Select button QPushButton * btnSelect = new QPushButton(tr("Use selected hat")); btnSelect->setDefault(true); connect(btnSelect, SIGNAL(clicked()), this, SLOT(onAccepted())); // Add hats list = new HatListView(); list->setModel(filterModel); list->setViewMode(QListView::IconMode); list->setResizeMode(QListView::Adjust); list->setMovement(QListView::Static); list->setEditTriggers(QAbstractItemView::NoEditTriggers); list->setSpacing(8); list->setWordWrap(true); list->setSelectionMode(QAbstractItemView::SingleSelection); list->setObjectName("hatList"); list->setCurrentIndex(filterModel->index(currentIndex, 0)); connect(list, SIGNAL(activated(const QModelIndex &)), this, SLOT(hatChosen(const QModelIndex &))); connect(list, SIGNAL(clicked(const QModelIndex &)), this, SLOT(hatChosen(const QModelIndex &))); // Add elements to layouts dialogLayout->addLayout(topLayout, 0, 0, 1, 3); dialogLayout->addWidget(list, 1, 0, 1, 3); dialogLayout->addWidget(btnCancel, 2, 0, 1, 1, Qt::AlignLeft); dialogLayout->addWidget(btnSelect, 2, 2, 1, 1, Qt::AlignRight); }
void BehaviorConfig_Shorten::slotConfigureClicked() { qCDebug(CHOQOK); KPluginInfo pluginInfo = availablePlugins.value(shortenPlugins->itemData(shortenPlugins->currentIndex()).toString()); qCDebug(CHOQOK) << pluginInfo.name() << pluginInfo.kcmServices().count(); QPointer<QDialog> configDialog = new QDialog(this); configDialog->setWindowTitle(pluginInfo.name()); // The number of KCModuleProxies in use determines whether to use a tabwidget QTabWidget *newTabWidget = 0; // Widget to use for the setting dialog's main widget, // either a QTabWidget or a KCModuleProxy QWidget *mainWidget = 0; // Widget to use as the KCModuleProxy's parent. // The first proxy is owned by the dialog itself QWidget *moduleProxyParentWidget = configDialog; for (const KService::Ptr &servicePtr: pluginInfo.kcmServices()) { if (!servicePtr->noDisplay()) { KCModuleInfo moduleInfo(servicePtr); KCModuleProxy *currentModuleProxy = new KCModuleProxy(moduleInfo, moduleProxyParentWidget); if (currentModuleProxy->realModule()) { moduleProxyList << currentModuleProxy; if (mainWidget && !newTabWidget) { // we already created one KCModuleProxy, so we need a tab widget. // Move the first proxy into the tab widget and ensure this and subsequent // proxies are in the tab widget newTabWidget = new QTabWidget(configDialog); moduleProxyParentWidget = newTabWidget; mainWidget->setParent(newTabWidget); KCModuleProxy *moduleProxy = qobject_cast<KCModuleProxy *>(mainWidget); if (moduleProxy) { newTabWidget->addTab(mainWidget, moduleProxy->moduleInfo().moduleName()); mainWidget = newTabWidget; } else { delete newTabWidget; newTabWidget = 0; moduleProxyParentWidget = configDialog; mainWidget->setParent(0); } } if (newTabWidget) { newTabWidget->addTab(currentModuleProxy, servicePtr->name()); } else { mainWidget = currentModuleProxy; } } else { delete currentModuleProxy; } } } // it could happen that we had services to show, but none of them were real modules. if (moduleProxyList.count()) { QWidget *showWidget = new QWidget(configDialog); QVBoxLayout *layout = new QVBoxLayout; showWidget->setLayout(layout); layout->addWidget(mainWidget); layout->insertSpacing(-1, QApplication::style()->pixelMetric(QStyle::PM_DialogButtonsSeparator)); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, configDialog.data(), &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, configDialog.data(), &QDialog::reject); layout->addWidget(buttonBox); showWidget->adjustSize(); // connect(&configDialog, SIGNAL(defaultClicked()), this, SLOT(slotDefaultClicked())); if (configDialog->exec() == QDialog::Accepted) { for (KCModuleProxy *moduleProxy: moduleProxyList) { QStringList parentComponents = moduleProxy->moduleInfo().service()->property(QLatin1String("X-KDE-ParentComponents")).toStringList(); moduleProxy->save(); } } else { for (KCModuleProxy *moduleProxy: moduleProxyList) { moduleProxy->load(); } } qDeleteAll(moduleProxyList); moduleProxyList.clear(); } }
void ResourceManager::displayLanguages() { tabs->setTabText(0,tr("Languages")); DownloadUtils *js = new DownloadUtils(this); js->setTarget(baseAddr + "languages/details.json"); js->download(); QByteArray json = js->returnData(); QJsonParseError err; QJsonDocument result = QJsonDocument::fromJson(json, &err); if (err.error != QJsonParseError::NoError || !result.isObject()) { qFatal("An error occured during parsing"); return; } int rowCount = result.object().keys().size(); rowCount -= 2; //version and type qDebug() << result.object().keys().size(); qDebug() << result.toJson(); languagesTable->setRowCount(rowCount); int row = 0; int col = 0; QPushButton* updateButtons[rowCount]; QPushButton* temp; languagesTable->verticalHeader()->show(); QCryptographicHash hash(QCryptographicHash::Sha1); for (QString key : result.object().keys()) { if (!result.object().value(key).isObject()) continue; QJsonObject value = result.object().value(key).toObject(); col = 0; QString test = value.value("file_name").toString(); if(test.length() == 0) continue; QString filename = value.value("file_name").toString(); QString name = value.value("name").toString(); QString fileSize = value.value("file_size").toString(); QString hashValue = value.value("hash").toString(); languagesTable->setItem(row,col++,new QTableWidgetItem (name)); languagesTable->setItem(row,col++,new QTableWidgetItem (filename)); languagesTable->setItem(row,col++,new QTableWidgetItem (tr("%1 KB").arg(fileSize))); updateButtons[row] = new QPushButton(tr("Update")); temp = updateButtons[row]; buttonMap[temp] = "languages/" + filename; buttonHashMap[temp] = hashValue; languagesTable->setIndexWidget(languagesTable->model()->index(row,col++), temp); QString local = dataPath + "/locale/" + filename; QFileInfo fileLocal(local); if(!fileLocal.exists()) local = mscoreGlobalShare + "locale/" + filename;; if(verifyFile(local, hashValue)) { temp->setText(tr("No update")); temp->setDisabled(1); } else { connect(temp, SIGNAL(clicked()), this, SLOT(download())); } row++; } }
WorkoutEditorBase::WorkoutEditorBase(QStringList &colms, QWidget *parent =0 ) :QFrame(parent) { QVBoxLayout *layout = new QVBoxLayout(); QHBoxLayout *row1Layout = new QHBoxLayout(); table = new QTableWidget(); table->setColumnCount(colms.count()); table->setHorizontalHeaderLabels(colms); table->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); table->setShowGrid(true); table->setAlternatingRowColors(true); table->resizeColumnsToContents(); row1Layout->addWidget(table); connect(table,SIGNAL(cellChanged(int,int)),this,SLOT(cellChanged(int,int))); QHBoxLayout *row2Layout = new QHBoxLayout(); QPushButton *delButton = new QPushButton(); delButton->setText(tr("Delete")); delButton->setToolTip(tr("Delete the highlighted row")); connect(delButton,SIGNAL(clicked()),this,SLOT(delButtonClicked())); row2Layout->addWidget(delButton); QPushButton *addButton = new QPushButton(); addButton->setText(tr("Add")); addButton->setToolTip(tr("Add row at end")); connect(addButton,SIGNAL(clicked()),this,SLOT(addButtonClicked())); row2Layout->addWidget(addButton); QPushButton *insertButton = new QPushButton(); insertButton->setText(tr("Insert")); insertButton->setToolTip(tr("Add a Lap below the highlighted row")); connect(insertButton,SIGNAL(clicked()),this,SLOT(insertButtonClicked())); row2Layout->addWidget(insertButton); QPushButton *lapButton = new QPushButton(); lapButton->setText(tr("Lap")); lapButton->setToolTip(tr("Add a Lap below the highlighted row")); row2Layout->addWidget(lapButton); connect(lapButton,SIGNAL(clicked()),this,SLOT(lapButtonClicked())); layout->addLayout(row1Layout); layout->addLayout(row2Layout); setLayout(layout); }
RgShortestPathWidget::RgShortestPathWidget( QWidget* theParent, RoadGraphPlugin *thePlugin ) : QDockWidget( theParent ), mPlugin( thePlugin ) { setWindowTitle( tr( "Shortest path" ) ); setObjectName( "ShortestPathDock" ); setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); QWidget *myWidget = new QWidget( this ); setWidget( myWidget ); QVBoxLayout *v = new QVBoxLayout( myWidget ); QHBoxLayout *h = NULL; QLabel *l = NULL; l = new QLabel( tr( "Start" ), myWidget ); v->addWidget( l ); h = new QHBoxLayout(); mFrontPointLineEdit = new QLineEdit( myWidget ); mFrontPointLineEdit->setReadOnly( true ); QToolButton *selectFrontPoint = new QToolButton( myWidget ); selectFrontPoint->setCheckable( true ); selectFrontPoint->setIcon( QPixmap( ":/roadgraph/coordinate_capture.png" ) ); h->addWidget( mFrontPointLineEdit ); h->addWidget( selectFrontPoint ); v->addLayout( h ); l = new QLabel( tr( "Stop" ), myWidget ); v->addWidget( l ); h = new QHBoxLayout(); mBackPointLineEdit = new QLineEdit( myWidget ); mBackPointLineEdit->setReadOnly( true ); QToolButton *selectBackPoint = new QToolButton( myWidget ); selectBackPoint->setCheckable( true ); selectBackPoint->setIcon( QPixmap( ":/roadgraph/coordinate_capture.png" ) ); h->addWidget( mBackPointLineEdit ); h->addWidget( selectBackPoint ); v->addLayout( h ); h = new QHBoxLayout(); l = new QLabel( tr( "Criterion" ), myWidget ); mCriterionName = new QComboBox( myWidget ); mCriterionName->insertItem( 0, tr( "Length" ) ); mCriterionName->insertItem( 1, tr( "Time" ) ); h->addWidget( l ); h->addWidget( mCriterionName ); v->addLayout( h ); h = new QHBoxLayout(); l = new QLabel( tr( "Length" ), myWidget ); mPathCostLineEdit = new QLineEdit( myWidget ); mPathCostLineEdit->setReadOnly( true ); h->addWidget( l ); h->addWidget( mPathCostLineEdit ); v->addLayout( h ); h = new QHBoxLayout(); l = new QLabel( tr( "Time" ), myWidget ); mPathTimeLineEdit = new QLineEdit( myWidget ); mPathTimeLineEdit->setReadOnly( true ); h->addWidget( l ); h->addWidget( mPathTimeLineEdit ); v->addLayout( h ); h = new QHBoxLayout(); mCalculate = new QPushButton( tr( "Calculate" ), myWidget ); h->addWidget( mCalculate ); QPushButton *pbExport = new QPushButton( tr( "Export" ), myWidget ); h->addWidget( pbExport ); connect( pbExport, SIGNAL( clicked( bool ) ), this, SLOT( exportPath() ) ); mClear = new QPushButton( tr( "Clear" ), myWidget ); h->addWidget( mClear ); v->addLayout( h ); h = new QHBoxLayout(); QPushButton *helpButton = new QPushButton( tr( "Help" ), this ); helpButton->setIcon( style()->standardIcon( QStyle::SP_DialogHelpButton ) ); h->addWidget( helpButton ); v->addLayout( h ); v->addStretch(); mFrontPointMapTool = new QgsMapToolEmitPoint( mPlugin->iface()->mapCanvas() ); mFrontPointMapTool->setButton( selectFrontPoint ); mBackPointMapTool = new QgsMapToolEmitPoint( mPlugin->iface()->mapCanvas() ); mBackPointMapTool->setButton( selectBackPoint ); connect( selectFrontPoint, SIGNAL( clicked( bool ) ), this, SLOT( onSelectFrontPoint() ) ); connect( mFrontPointMapTool, SIGNAL( canvasClicked( const QgsPoint&, Qt::MouseButton ) ), this, SLOT( setFrontPoint( const QgsPoint& ) ) ); connect( selectBackPoint, SIGNAL( clicked( bool ) ), this, SLOT( onSelectBackPoint() ) ); connect( mBackPointMapTool, SIGNAL( canvasClicked( const QgsPoint&, Qt::MouseButton ) ), this, SLOT( setBackPoint( const QgsPoint& ) ) ); connect( helpButton, SIGNAL( clicked( bool ) ), this, SLOT( helpRequested() ) ); connect( mCalculate, SIGNAL( clicked( bool ) ), this, SLOT( findingPath() ) ); connect( mClear, SIGNAL( clicked( bool ) ), this, SLOT( clear() ) ); mrbFrontPoint = new QgsRubberBand( mPlugin->iface()->mapCanvas(), QGis::Polygon ); mrbFrontPoint->setColor( QColor( 0, 255, 0, 65 ) ); mrbFrontPoint->setWidth( 2 ); mrbBackPoint = new QgsRubberBand( mPlugin->iface()->mapCanvas(), QGis::Polygon ); mrbBackPoint->setColor( QColor( 255, 0, 0, 65 ) ); mrbBackPoint->setWidth( 2 ); mrbPath = new QgsRubberBand( mPlugin->iface()->mapCanvas(), QGis::Line ); mrbPath->setWidth( 2 ); connect( mPlugin->iface()->mapCanvas(), SIGNAL( extentsChanged() ), this, SLOT( mapCanvasExtentsChanged() ) ); } //RgShortestPathWidget::RgShortestPathWidget()
void HorizontalTabWidget::setCurrentIndex(int index) { int xPos = 0; for(unsigned i = 0; i < m_tabButtons.size(); i++) { QPushButton * button = m_tabButtons[i]; if(button->isHidden()){ button->move(0,0); continue; } QString style; style.append("QPushButton { border: none; background-color: #808080; "); style.append(" border-right: 1px solid black;"); style.append(" border-bottom: 1px solid black;"); style.append(" padding-left: 10px;"); style.append(" padding-right: 10px;"); style.append(" padding-top: 5px;"); style.append(" color: white;"); if( i == m_tabButtons.size() - 1 ) { style.append(" border-right: none;"); } style.append("}"); button->setStyleSheet(style); button->adjustSize(); button->move(xPos,0); xPos = xPos + button->width(); } m_tabBarLine->setFixedWidth(xPos); m_tabBarLine->raise(); QPushButton * button = m_tabButtons[index]; QString style; style.append("QPushButton { border: none; background-color: #95B3DE; "); style.append(" border-right: 1px solid black;"); style.append(" padding-left: 10px;"); style.append(" padding-right: 10px;"); style.append(" padding-top: 5px;"); style.append(" color: white;"); if( index == int(m_tabButtons.size() - 1) ) { style.append(" border-right: none;"); } style.append("}"); button->setStyleSheet(style); button->raise(); m_pageStack->setCurrentIndex(index); }
CAllStockDialog::CAllStockDialog( QWidget* parent /*= 0*/ ) : QDialog(parent) { QSplitter* pSplitter = new QSplitter(Qt::Vertical,this); QVBoxLayout* pLayout = new QVBoxLayout(this); pLayout->addWidget(pSplitter); pLayout->setSpacing(0); setLayout(pLayout); m_pWidgetAll = new CAllStockWidget(0); pSplitter->addWidget(m_pWidgetAll); QWidget* pWidgetCtrl = new QWidget(pSplitter); pSplitter->addWidget(pWidgetCtrl); pSplitter->setSizes(QList<int>()<<70<<30); QHBoxLayout* pHLayout = new QHBoxLayout(pWidgetCtrl); pHLayout->setSpacing(0); pWidgetCtrl->setLayout(pHLayout); { m_pWidgetKLine = new CKLineWidget(0); // QFile file(qApp->applicationDirPath()+"/AllStock.xml"); if(file.open(QFile::ReadOnly)) { QDomDocument doc; doc.setContent(file.readAll()); file.close(); QDomElement eleRoot = doc.firstChildElement("ROOT"); if(eleRoot.isElement()) { QDomElement eleWidget = eleRoot.firstChildElement("widget"); if(eleWidget.isElement()) { m_pWidgetKLine->loadPanelInfo(eleWidget); } } } connect(m_pWidgetAll,SIGNAL(stockFocus(CStockInfoItem*)),this,SLOT(onStockFocusChanged(CStockInfoItem*))); pHLayout->addWidget(m_pWidgetKLine,70); } { QGridLayout* pGLayout = new QGridLayout(); { //初始化周期按钮 QPushButton* pBtn5Min = new QPushButton(pWidgetCtrl); pBtn5Min->setText(tr("5分")); connect(pBtn5Min,SIGNAL(clicked()),this,SLOT(onCircle5Min())); pGLayout->addWidget(pBtn5Min,0,0,1,1); QPushButton* pBtnDay = new QPushButton(pWidgetCtrl); pBtnDay->setText(tr("日线")); connect(pBtnDay,SIGNAL(clicked()),this,SLOT(onCircleDay())); pGLayout->addWidget(pBtnDay,0,1,1,1); QPushButton* pBtnWeek = new QPushButton(pWidgetCtrl); pBtnWeek->setText(tr("周线")); connect(pBtnWeek,SIGNAL(clicked()),this,SLOT(onCircleWeek())); pGLayout->addWidget(pBtnWeek,0,2,1,1); QPushButton* pBtnMonth = new QPushButton(pWidgetCtrl); pBtnMonth->setText(tr("月线")); connect(pBtnMonth,SIGNAL(clicked()),this,SLOT(onCircleMonth())); pGLayout->addWidget(pBtnMonth,0,3,1,1); } { //初始化排序按钮 // SortByCode = 1, //按股票代码排序 // SortByZGB, //按总股本排序 // SortByIncrease, //按涨幅排序 // SortByTurnRatio, //按换手率排序 // SortByVolumeRatio, //按量比排序 QPushButton* pBtnStCode = new QPushButton(pWidgetCtrl); pBtnStCode->setText(tr("代码")); connect(pBtnStCode,SIGNAL(clicked()),this,SLOT(onSortCode())); pGLayout->addWidget(pBtnStCode,1,0,1,1); QPushButton* pBtnStZGB = new QPushButton(pWidgetCtrl); pBtnStZGB->setText(tr("总股本")); connect(pBtnStZGB,SIGNAL(clicked()),this,SLOT(onSortZGB())); pGLayout->addWidget(pBtnStZGB,1,1,1,1); QPushButton* pBtnStInc = new QPushButton(pWidgetCtrl); pBtnStInc->setText(tr("涨幅")); connect(pBtnStInc,SIGNAL(clicked()),this,SLOT(onSortInc())); pGLayout->addWidget(pBtnStInc,1,2,1,1); QPushButton* pBtnStTurnRatio = new QPushButton(pWidgetCtrl); pBtnStTurnRatio->setText(tr("换手率")); connect(pBtnStTurnRatio,SIGNAL(clicked()),this,SLOT(onSortTurnRatio())); pGLayout->addWidget(pBtnStTurnRatio,1,3,1,1); QPushButton* pBtnStVolumeRatio = new QPushButton(pWidgetCtrl); pBtnStVolumeRatio->setText(tr("量比")); connect(pBtnStVolumeRatio,SIGNAL(clicked()),this,SLOT(onSortVolumeRatio())); pGLayout->addWidget(pBtnStVolumeRatio,1,4,1,1); } pHLayout->addLayout(pGLayout,30); } showMaximized(); }
//----------------------------------------------------------------------------- StyleDialog::StyleDialog(QWidget *parent) : QDialog(parent) { grBuf = 0; setWindowTitle(tr("UDAV - Insert style/scheme")); QWidget *p; QHBoxLayout *h; QVBoxLayout *v, *u, *vv; QGridLayout *g; QLabel *l; QPushButton *b; tab = new QTabWidget(this); // line style p = new QWidget(this); v = new QVBoxLayout(p); g = new QGridLayout; g->setAlignment(Qt::AlignTop); v->addLayout(g); // g->setColStretch(0, 1); g->setColStretch(1, 1); g->setColStretch(2, 1); l = new QLabel(tr("Arrow at start"), p); g->addWidget(l, 0, 0); l = new QLabel(tr("Dashing"), p); g->addWidget(l, 0, 1); l = new QLabel(tr("Arrow at end"), p); g->addWidget(l, 0, 2); a1 = new QComboBox(p); g->addWidget(a1, 1, 0); fillArrows(a1); dash = new QComboBox(p); g->addWidget(dash, 1, 1); fillDashes(dash); a2 = new QComboBox(p); g->addWidget(a2, 1, 2); fillBArrows(a2); l = new QLabel(tr("Color"), p); g->addWidget(l, 2, 0, Qt::AlignRight); cline=new QComboBox(p); g->addWidget(cline, 2, 1); fillColors(cline); nline = new QSlider(p); g->addWidget(nline, 2, 2); nline->setRange(1, 9); nline->setValue(5); nline->setTickPosition(QSlider::TicksBothSides); nline->setTickInterval(1); nline->setPageStep(2); nline->setOrientation(Qt::Horizontal); l = new QLabel(tr("Marks"), p); g->addWidget(l, 3, 0, Qt::AlignRight); mark = new QComboBox(p); g->addWidget(mark, 3, 1); fillMarkers(mark); l = new QLabel(tr("Line width"), p); g->addWidget(l, 4, 0, Qt::AlignRight); width = new QSpinBox(p); g->addWidget(width, 4, 1); width->setRange(1,9); width->setValue(1); v->addStretch(1); l = new QLabel(tr("Manual dashing"), p); v->addWidget(l); h = new QHBoxLayout; v->addLayout(h); h->setSpacing(1); for(int i=0;i<16;i++) { dash_bit[i] = new QToolButton(this); dash_bit[i]->setCheckable(true); h->addWidget(dash_bit[i]); connect(dash_bit[i],SIGNAL(toggled(bool)), this, SLOT(updatePic())); } connect(a1,SIGNAL(activated(int)), this, SLOT(updatePic())); connect(a2,SIGNAL(activated(int)), this, SLOT(updatePic())); connect(dash,SIGNAL(activated(int)), this, SLOT(updatePic())); connect(mark,SIGNAL(activated(int)), this, SLOT(updatePic())); connect(cline,SIGNAL(activated(int)), this, SLOT(updatePic())); connect(nline,SIGNAL(valueChanged(int)), this, SLOT(updatePic())); connect(width,SIGNAL(valueChanged(int)), this, SLOT(updatePic())); tab->addTab(p, tr("Line style")); // color scheme p = new QWidget(this); v = new QVBoxLayout(p); v->setAlignment(Qt::AlignTop); g = new QGridLayout(); v->addLayout(g); // g->setColStretch(0, 1); g->setColStretch(1, 1); l = new QLabel(tr("Color order"), p); g->addWidget(l, 0, 0); l = new QLabel(tr("Saturation"),p); g->addWidget(l, 0, 1); for(int i=0;i<7;i++) { cc[i] = new QComboBox(p); g->addWidget(cc[i], i+1, 0); fillColors(cc[i]); nn[i] = new QSlider(p); g->addWidget(nn[i], i+1, 1); nn[i]->setRange(1, 9); nn[i]->setValue(5); nn[i]->setTickPosition(QSlider::TicksBothSides); nn[i]->setTickInterval(1); nn[i]->setPageStep(2); nn[i]->setOrientation(Qt::Horizontal); connect(cc[i],SIGNAL(activated(int)), this, SLOT(updatePic())); connect(nn[i],SIGNAL(valueChanged(int)), this, SLOT(updatePic())); } swire = new QCheckBox(tr("Wire or mesh plot"),p); v->addWidget(swire); g = new QGridLayout(); v->addLayout(g); l = new QLabel(tr("Axial direction"), p); g->addWidget(l, 0, 0, Qt::AlignRight); l = new QLabel(tr("Text on contours"), p); g->addWidget(l, 1, 0, Qt::AlignRight); l = new QLabel(tr("Mask for bitmap coloring"), p); g->addWidget(l, 2, 0, Qt::AlignRight); l = new QLabel(tr("Mask rotation angle"), p); g->addWidget(l, 3, 0, Qt::AlignRight); l = new QLabel(tr("Mask size"), p); g->addWidget(l, 4, 0, Qt::AlignRight); axial = new QComboBox(p); g->addWidget(axial, 0, 1); axial->addItem(tr("none")); axial->addItem("x"); axial->addItem("y"); axial->addItem("z"); ctext = new QComboBox(p); g->addWidget(ctext, 1, 1); ctext->addItem(tr("none")); ctext->addItem(tr("under")); ctext->addItem(tr("above")); mask = new QComboBox(p); g->addWidget(mask, 2, 1); fillMasks(mask); angle = new QComboBox(p); g->addWidget(angle, 3, 1); angle->addItem(tr("none")); angle->addItem(QString::fromWCharArray(L"+45°")); angle->addItem(QString::fromWCharArray(L"-45°")); angle->addItem(QString::fromWCharArray(L"90°")); msize = new QSlider(p); g->addWidget(msize, 4, 1); msize->setRange(1, 9); msize->setValue(1); msize->setTickPosition(QSlider::TicksBothSides); msize->setTickInterval(1); msize->setPageStep(2); msize->setOrientation(Qt::Horizontal); connect(axial,SIGNAL(activated(int)), this, SLOT(updatePic())); connect(ctext,SIGNAL(activated(int)), this, SLOT(updatePic())); connect(swire,SIGNAL(toggled(bool)), this, SLOT(updatePic())); connect(mask,SIGNAL(activated(int)), this, SLOT(updatePic())); connect(angle,SIGNAL(activated(int)), this, SLOT(updatePic())); connect(msize,SIGNAL(valueChanged(int)), this, SLOT(updatePic())); tab->addTab(p, tr("Color scheme")); // font style p = new QWidget(this); v = new QVBoxLayout(p); v->setAlignment(Qt::AlignTop); h = new QHBoxLayout(); v->addLayout(h); u = new QVBoxLayout(); h->addLayout(u); bold = new QCheckBox(tr("Bold style"), p); u->addWidget(bold); ital = new QCheckBox(tr("Italic style"), p);u->addWidget(ital); wire = new QCheckBox(tr("Wire style"), p); u->addWidget(wire); uline = new QCheckBox(tr("Underline"), p); u->addWidget(uline); oline = new QCheckBox(tr("Overline"), p); u->addWidget(oline); font_sch = new QCheckBox(tr("Use color scheme"), p); u->addWidget(font_sch); u = new QVBoxLayout(); h->addLayout(u); l = new QLabel(tr("Text color"), p); u->addWidget(l); cfont = new QComboBox(p); fillColors(cfont); u->addWidget(cfont); u->addSpacing(6); align = new QGroupBox(tr("Text align"), p); u->addWidget(align); vv = new QVBoxLayout(align); //vv->addSpacing(11); rbL = new QRadioButton(tr("left"), align); vv->addWidget(rbL); rbC = new QRadioButton(tr("at center"), align); vv->addWidget(rbC); rbC->setChecked(true); rbR = new QRadioButton(tr("right"), align); vv->addWidget(rbR); connect(bold,SIGNAL(toggled(bool)), this, SLOT(updatePic())); connect(ital,SIGNAL(toggled(bool)), this, SLOT(updatePic())); connect(wire,SIGNAL(toggled(bool)), this, SLOT(updatePic())); connect(uline,SIGNAL(toggled(bool)), this, SLOT(updatePic())); connect(oline,SIGNAL(toggled(bool)), this, SLOT(updatePic())); connect(font_sch,SIGNAL(toggled(bool)), this, SLOT(updatePic())); connect(cfont,SIGNAL(activated(int)), this, SLOT(updatePic())); connect(rbL,SIGNAL(toggled(bool)), this, SLOT(updatePic())); connect(rbC,SIGNAL(toggled(bool)), this, SLOT(updatePic())); connect(rbR,SIGNAL(toggled(bool)), this, SLOT(updatePic())); tab->addTab(p, tr("Font style")); connect(tab,SIGNAL(currentChanged(int)), this, SLOT(updatePic())); // hex-mask p = new QWidget(this); g = new QGridLayout(p); g->setAlignment(Qt::AlignTop); for(int i=0;i<64;i++) { mask_bit[i] = new QToolButton(this); mask_bit[i]->setCheckable(true); g->addWidget(mask_bit[i],7-i/8,i%8); connect(mask_bit[i],SIGNAL(toggled(bool)), this, SLOT(updatePic())); } tab->addTab(p, tr("Manual mask")); // dialog itself v = new QVBoxLayout(this); v->addWidget(tab); h = new QHBoxLayout(); v->addLayout(h); l = new QLabel(tr("Resulting string"), this); h->addWidget(l); h->addStretch(1); pic = new QLabel(this); pic->setMinimumSize(QSize(128,30)); h->addWidget(pic); res = new QLineEdit(this); res->setReadOnly(true); v->addWidget(res); h = new QHBoxLayout(); v->addLayout(h); h->addStretch(1); b = new QPushButton(tr("Cancel"), this); h->addWidget(b); connect(b, SIGNAL(clicked()),this, SLOT(reject())); b = new QPushButton(tr("OK"), this); h->addWidget(b); connect(b, SIGNAL(clicked()),this, SLOT(accept())); b->setDefault(true); }
StatisticsDlg::StatisticsDlg(const QString& strCaption, const vector<string>& aoiNames, QWidget* parent) : QDialog(parent) { // Subset QGroupBox* pSubsetGroup = new QGroupBox("Subset", this); // Skip factors mpFactorRadio = new QRadioButton("Skip Factors:", pSubsetGroup); mpFactorRadio->setFocusPolicy(Qt::StrongFocus); QLabel* pRowLabel = new QLabel("Row:", pSubsetGroup); mpRowSpin = new QSpinBox(pSubsetGroup); mpRowSpin->setFixedWidth(50); mpRowSpin->setMinimum(1); QLabel* pColumnLabel = new QLabel("Column:", pSubsetGroup); mpColumnSpin = new QSpinBox(pSubsetGroup); mpColumnSpin->setFixedWidth(50); mpColumnSpin->setMinimum(1); connect(mpFactorRadio, SIGNAL(toggled(bool)), pRowLabel, SLOT(setEnabled(bool))); connect(mpFactorRadio, SIGNAL(toggled(bool)), mpRowSpin, SLOT(setEnabled(bool))); connect(mpFactorRadio, SIGNAL(toggled(bool)), pColumnLabel, SLOT(setEnabled(bool))); connect(mpFactorRadio, SIGNAL(toggled(bool)), mpColumnSpin, SLOT(setEnabled(bool))); // AOI mpAoiRadio = new QRadioButton("AOI:", pSubsetGroup); mpAoiRadio->setFocusPolicy(Qt::StrongFocus); mpAoiCombo = new QComboBox(pSubsetGroup); mpAoiCombo->setEditable(false); mpAoiCombo->setMinimumWidth(150); for (vector<string>::const_iterator iter = aoiNames.begin(); iter != aoiNames.end(); ++iter) { mpAoiCombo->addItem(QString::fromStdString(*iter)); } connect(mpAoiRadio, SIGNAL(toggled(bool)), mpAoiCombo, SLOT(setEnabled(bool))); QGridLayout* pSubsetGrid = new QGridLayout(pSubsetGroup); pSubsetGrid->setMargin(10); pSubsetGrid->setSpacing(5); pSubsetGrid->setColumnMinimumWidth(0, 14); pSubsetGrid->addWidget(mpFactorRadio, 0, 0, 1, 4); pSubsetGrid->addWidget(pRowLabel, 1, 1); pSubsetGrid->addWidget(mpRowSpin, 1, 2); pSubsetGrid->addWidget(pColumnLabel, 2, 1); pSubsetGrid->addWidget(mpColumnSpin, 2, 2); pSubsetGrid->addWidget(mpAoiRadio, 3, 0, 1, 4); pSubsetGrid->addWidget(mpAoiCombo, 4, 1, 1, 3); pSubsetGrid->setColumnStretch(3, 10); // Horizontal line QFrame* pHLine = new QFrame(this); pHLine->setFrameStyle(QFrame::HLine | QFrame::Sunken); // OK and Cancel buttons QPushButton* pOk = new QPushButton("&OK", this); pOk->setDefault(true); QPushButton* pCancel = new QPushButton("&Cancel", this); connect(pOk, SIGNAL(clicked()), this, SLOT(accept())); connect(pCancel, SIGNAL(clicked()), this, SLOT(reject())); QHBoxLayout* pButtonLayout = new QHBoxLayout(); pButtonLayout->setMargin(0); pButtonLayout->setSpacing(5); pButtonLayout->addStretch(10); pButtonLayout->addWidget(pOk); pButtonLayout->addWidget(pCancel); // Layout QVBoxLayout* pLayout = new QVBoxLayout(this); pLayout->setMargin(10); pLayout->setSpacing(10); pLayout->addWidget(pSubsetGroup); pLayout->addStretch(); pLayout->addWidget(pHLine); pLayout->addLayout(pButtonLayout); // Initialization if (strCaption.isEmpty()) { setWindowTitle("PCA Statistics"); } else { setWindowTitle(strCaption); } setModal(true); resize(300, 250); mpFactorRadio->setChecked(true); mpAoiCombo->setEnabled(false); }
void ShaderParamsDialog::buildLayout() { QPushButton *loadButton = NULL; QPushButton *saveButton = NULL; QPushButton *removeButton = NULL; QPushButton *applyButton = NULL; QHBoxLayout *topButtonLayout = NULL; QMenu *loadMenu = NULL; QMenu *saveMenu = NULL; QMenu *removeMenu = NULL; struct video_shader *menu_shader = NULL; struct video_shader *video_shader = NULL; struct video_shader *avail_shader = NULL; const char *shader_path = NULL; unsigned i; bool hasPasses = false; getShaders(&menu_shader, &video_shader); /* NOTE: For some reason, menu_shader_get() returns a COPY of what get_current_shader() gives us. * And if you want to be able to change shader settings/parameters from both the raster menu and * Qt at the same time... you must change BOTH or one will overwrite the other. * * AND, during a context reset, video_shader will be NULL but not menu_shader, so don't totally bail * just because video_shader is NULL. * * Someone please fix this mess. */ if (video_shader) { avail_shader = video_shader; if (video_shader->passes == 0) setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS)); } /* Normally we'd only use video_shader, but the vulkan driver returns a NULL shader when there * are zero passes, so just fall back to menu_shader. */ else if (menu_shader) { avail_shader = menu_shader; if (menu_shader->passes == 0) setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS)); } else { setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS)); /* no shader is available yet, just keep retrying until it is */ QTimer::singleShot(0, this, SLOT(buildLayout())); return; } clearLayout(); /* Only check video_shader for the path, menu_shader seems stale... e.g. if you remove all the shader passes, * it still has the old path in it, but video_shader does not */ if (video_shader) { if (!string_is_empty(video_shader->path)) { shader_path = video_shader->path; setWindowTitle(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CURRENT_SHADER)) + ": " + QFileInfo(shader_path).fileName()); } } else if (menu_shader) { if (!string_is_empty(menu_shader->path)) { shader_path = menu_shader->path; setWindowTitle(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CURRENT_SHADER)) + ": " + QFileInfo(shader_path).fileName()); } } else setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS)); loadButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_LOAD), this); saveButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SAVE), this); removeButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_REMOVE), this); applyButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_APPLY), this); loadMenu = new QMenu(loadButton); loadMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET), this, SLOT(onShaderLoadPresetClicked())); loadMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SHADER_ADD_PASS), this, SLOT(onShaderAddPassClicked())); loadButton->setMenu(loadMenu); saveMenu = new QMenu(saveButton); saveMenu->addAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS)) + "...", this, SLOT(onShaderSavePresetAsClicked())); saveMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_CORE), this, SLOT(onShaderSaveCorePresetClicked())); saveMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_PARENT), this, SLOT(onShaderSaveParentPresetClicked())); saveMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_GAME), this, SLOT(onShaderSaveGamePresetClicked())); saveButton->setMenu(saveMenu); removeMenu = new QMenu(removeButton); /* When there are no passes, at least on first startup, it seems video_shader erroneously shows 1 pass, with an empty source file. * So we use menu_shader instead for that. */ if (menu_shader) { for (i = 0; i < menu_shader->passes; i++) { QFileInfo fileInfo(menu_shader->pass[i].source.path); QString shaderBasename = fileInfo.completeBaseName(); QAction *action = removeMenu->addAction(shaderBasename, this, SLOT(onShaderRemovePassClicked())); action->setData(i); } } removeMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SHADER_CLEAR_ALL_PASSES), this, SLOT(onShaderClearAllPassesClicked())); removeButton->setMenu(removeMenu); connect(applyButton, SIGNAL(clicked()), this, SLOT(onShaderApplyClicked())); topButtonLayout = new QHBoxLayout(); topButtonLayout->addWidget(loadButton); topButtonLayout->addWidget(saveButton); topButtonLayout->addWidget(removeButton); topButtonLayout->addWidget(applyButton); m_layout->addLayout(topButtonLayout); /* NOTE: We assume that parameters are always grouped in order by the pass number, e.g., all parameters for pass 0 come first, then params for pass 1, etc. */ for (i = 0; avail_shader && i < avail_shader->passes; i++) { QFormLayout *form = NULL; QGroupBox *groupBox = NULL; QFileInfo fileInfo(avail_shader->pass[i].source.path); QString shaderBasename = fileInfo.completeBaseName(); QHBoxLayout *filterScaleHBoxLayout = NULL; QComboBox *filterComboBox = new QComboBox(this); QComboBox *scaleComboBox = new QComboBox(this); QToolButton *moveDownButton = NULL; QToolButton *moveUpButton = NULL; unsigned j = 0; /* Sometimes video_shader shows 1 pass with no source file, when there are really 0 passes. */ if (shaderBasename.isEmpty()) continue; hasPasses = true; filterComboBox->setProperty("pass", i); scaleComboBox->setProperty("pass", i); moveDownButton = new QToolButton(this); moveDownButton->setText("↓"); moveDownButton->setProperty("pass", i); moveUpButton = new QToolButton(this); moveUpButton->setText("↑"); moveUpButton->setProperty("pass", i); /* Can't move down if we're already at the bottom. */ if (i < avail_shader->passes - 1) connect(moveDownButton, SIGNAL(clicked()), this, SLOT(onShaderPassMoveDownClicked())); else moveDownButton->setDisabled(true); /* Can't move up if we're already at the top. */ if (i > 0) connect(moveUpButton, SIGNAL(clicked()), this, SLOT(onShaderPassMoveUpClicked())); else moveUpButton->setDisabled(true); for (;;) { QString filterLabel = getFilterLabel(j); if (filterLabel.isEmpty()) break; if (j == 0) filterLabel = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DONT_CARE); filterComboBox->addItem(filterLabel, j); j++; } for (j = 0; j < 7; j++) { QString label; if (j == 0) label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DONT_CARE); else label = QString::number(j) + "x"; scaleComboBox->addItem(label, j); } filterComboBox->setCurrentIndex(static_cast<int>(avail_shader->pass[i].filter)); scaleComboBox->setCurrentIndex(static_cast<int>(avail_shader->pass[i].fbo.scale_x)); /* connect the signals only after the initial index is set */ connect(filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onFilterComboBoxIndexChanged(int))); connect(scaleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onScaleComboBoxIndexChanged(int))); form = new QFormLayout(); groupBox = new QGroupBox(shaderBasename); groupBox->setLayout(form); groupBox->setProperty("pass", i); groupBox->setContextMenuPolicy(Qt::CustomContextMenu); connect(groupBox, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onGroupBoxContextMenuRequested(const QPoint&))); m_layout->addWidget(groupBox); filterScaleHBoxLayout = new QHBoxLayout(); filterScaleHBoxLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); filterScaleHBoxLayout->addWidget(new QLabel(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FILTER)) + ":", this)); filterScaleHBoxLayout->addWidget(filterComboBox); filterScaleHBoxLayout->addWidget(new QLabel(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCALE)) + ":", this)); filterScaleHBoxLayout->addWidget(scaleComboBox); filterScaleHBoxLayout->addSpacerItem(new QSpacerItem(20, 0, QSizePolicy::Preferred, QSizePolicy::Preferred)); if (moveUpButton) filterScaleHBoxLayout->addWidget(moveUpButton); if (moveDownButton) filterScaleHBoxLayout->addWidget(moveDownButton); form->addRow("", filterScaleHBoxLayout); for (j = 0; j < avail_shader->num_parameters; j++) { struct video_shader_parameter *param = &avail_shader->parameters[j]; if (param->pass != static_cast<int>(i)) continue; addShaderParam(param, form); } } if (!hasPasses) { QLabel *noParamsLabel = new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SHADER_NO_PASSES), this); noParamsLabel->setAlignment(Qt::AlignCenter); m_layout->addWidget(noParamsLabel); } m_layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding)); /* Why is this required?? The layout is corrupt without both resizes. */ resize(width() + 1, height()); show(); resize(width() - 1, height()); }
void DVGui::MsgBoxInPopup(MsgType type, const QString &text) { // this function must be called by the main thread only // (only the main thread should access directly the GUI) // (note: working thread can and should call MsgBox(type,text) instead; see tmsgcore.h) Q_ASSERT(QApplication::instance()->thread() == QThread::currentThread()); // a working thread can trigger a call to this function (by the main thread) also when a popup is already open // therefore we need a messageQueue // note: no mutex are needed because only the main thread call this function static QList<QPair<MsgType, QString>> messageQueue; static bool popupIsOpen = false; messageQueue.append(qMakePair(type, text)); if (popupIsOpen) return; popupIsOpen = true; Dialog dialog(0, true); dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint); dialog.setAlignment(Qt::AlignLeft); QLabel *mainTextLabel = new QLabel("", &dialog); mainTextLabel->setMinimumWidth(400); QLabel *iconLabel = new QLabel(&dialog); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addWidget(iconLabel); mainLayout->addStretch(); mainLayout->addWidget(mainTextLabel); mainLayout->addStretch(); dialog.addLayout(mainLayout); // ButtonGroup: is used only to retrieve the clicked button QButtonGroup *buttonGroup = new QButtonGroup(&dialog); QPushButton *button = new QPushButton(QPushButton::tr("OK"), &dialog); button->setDefault(true); dialog.addButtonBarWidget(button); buttonGroup->addButton(button, 1); QObject::connect(buttonGroup, SIGNAL(buttonPressed(int)), &dialog, SLOT(done(int))); while (!messageQueue.empty()) { MsgType type1 = messageQueue.first().first; QString text1 = messageQueue.first().second; messageQueue.pop_front(); mainTextLabel->setText(text1); QString msgBoxTitle = getMsgBoxTitle(type1); dialog.setWindowTitle(msgBoxTitle); QPixmap iconPixmap = getMsgBoxPixmap(type1); if (!iconPixmap.isNull()) { iconLabel->setPixmap(iconPixmap); iconLabel->setVisible(true); } else { iconLabel->setVisible(false); } dialog.raise(); dialog.exec(); } // loop: open the next dialog in the queue popupIsOpen = false; }
MainApplication::MainApplication(QWidget *parent) : QWidget(parent) { const int textSize = 12; const int toolBoxWidth = 160; const int toolBoxWidgetsWidth = 140; const int toolBoxSubWidgetsWidth = 120; QSize textEditSize = QSize(40, 30); int windowHeight = 500; int windowWidth = 800; /*---- Buttons ----*/ QPushButton *rangeQueryButton = new QPushButton(tr("Range")); rangeQueryButton->setFont(QFont("Times", textSize, QFont::AnyStyle)); QPushButton *radiusQueryButton = new QPushButton(tr("Radius")); radiusQueryButton->setFont(QFont("Times", textSize, QFont::AnyStyle)); QPushButton *loadButton = new QPushButton(tr("Load")); loadButton->setFont(QFont("Times", textSize, QFont::AnyStyle)); QPushButton *nnQueryButton = new QPushButton(tr("NN-Query")); nnQueryButton->setFont(QFont("Times", textSize, QFont::AnyStyle)); QPushButton *smoothingButton = new QPushButton(tr("Smooth")); smoothingButton->setFont(QFont("Times", textSize, QFont::AnyStyle)); QPushButton *distanceColorMapButton = new QPushButton(tr("ColorbyDist")); distanceColorMapButton->setFont(QFont("Times", textSize, QFont::AnyStyle)); QPushButton *thinningButton = new QPushButton(tr("Thinning")); thinningButton->setFont(QFont("Times", textSize, QFont::AnyStyle)); QPushButton *lineFittingButton = new QPushButton(tr("fit Line")); lineFittingButton->setFont(QFont("Times", textSize, QFont::AnyStyle)); QPushButton *planeFittingButton = new QPushButton(tr("fit Plane")); planeFittingButton->setFont(QFont("Times", textSize, QFont::AnyStyle)); QPushButton *sphereFittingButton = new QPushButton(tr("fit Sphere")); sphereFittingButton->setFont(QFont("Times", textSize, QFont::AnyStyle)); connect(loadButton, SIGNAL(clicked()), this, SLOT(loadPoints())); connect(rangeQueryButton, SIGNAL(clicked()), this, SLOT(rangeQuery())); connect(radiusQueryButton, SIGNAL(clicked()), this, SLOT(radiusQuery())); connect(smoothingButton, SIGNAL(clicked()), this, SLOT(smoothPointCloud())); connect(nnQueryButton, SIGNAL(clicked()), this, SLOT(nnQuery())); connect(distanceColorMapButton, SIGNAL(clicked()), this, SLOT(colorPointsByDistance())); connect(thinningButton, SIGNAL(clicked()), this, SLOT(applyThinning())); connect(lineFittingButton, SIGNAL(clicked()), this, SLOT(fitLine())); connect(planeFittingButton, SIGNAL(clicked()), this, SLOT(fitPlane())); connect(sphereFittingButton, SIGNAL(clicked()), this, SLOT(fitSphere())); /*---- Labels ----*/ labelCloudBounds = new QLabel("---", this); labelCloudBounds->setMaximumHeight(60); labelPoints = new QLabel("---", this); labelPoints->setMaximumHeight(60); labelTime = new QLabel("---", this); labelTime->setMaximumHeight(60); labelFitting = new QLabel("p: dir:", this); labelFitting->setMaximumHeight(120); /*---- Text Edits ----*/ QDoubleValidator *validDouble = new QDoubleValidator(); minXRange = new QLineEdit(); minXRange->setMaximumSize(textEditSize); minXRange->setValidator(validDouble); maxXRange = new QLineEdit(); maxXRange->setMaximumSize(textEditSize); maxXRange->setValidator(validDouble); minYRange = new QLineEdit(); minYRange->setMaximumSize(textEditSize); minYRange->setValidator(validDouble); maxYRange = new QLineEdit(); maxYRange->setMaximumSize(textEditSize); maxYRange->setValidator(validDouble); minZRange = new QLineEdit(); minZRange->setMaximumSize(textEditSize); minZRange->setValidator(validDouble); maxZRange = new QLineEdit(); maxZRange->setMaximumSize(textEditSize); maxZRange->setValidator(validDouble); xRadius = new QLineEdit(); xRadius->setMaximumSize(textEditSize); xRadius->setValidator(validDouble); yRadius = new QLineEdit(); yRadius->setMaximumSize(textEditSize); yRadius->setValidator(validDouble); zRadius = new QLineEdit(); zRadius->setMaximumSize(textEditSize); zRadius->setValidator(validDouble); rRadius = new QLineEdit(); rRadius->setMaximumSize(textEditSize); rRadius->setValidator(validDouble); xNeighbour = new QLineEdit(); xNeighbour->setMaximumSize(textEditSize); xNeighbour->setValidator(validDouble); yNeighbour = new QLineEdit(); yNeighbour->setMaximumSize(textEditSize); yNeighbour->setValidator(validDouble); zNeighbour = new QLineEdit(); zNeighbour->setMaximumSize(textEditSize); zNeighbour->setValidator(validDouble); rSmoothing = new QLineEdit(); rSmoothing->setMaximumSize(textEditSize); rSmoothing->setMaximumWidth(toolBoxSubWidgetsWidth); rSmoothing->setValidator(validDouble); rThinning = new QLineEdit(); rThinning->setMaximumSize(textEditSize); rThinning->setMaximumWidth(toolBoxSubWidgetsWidth); rThinning->setValidator(validDouble); /*---- Tool Box and Tool Box Widgets ----*/ QToolBox *toolBox = new QToolBox(); //Load QVBoxLayout *layoutLoad = new QVBoxLayout(); layoutLoad->addWidget(loadButton); QWidget* LoadWidget = new QWidget(); LoadWidget->setLayout(layoutLoad); LoadWidget->setFixedWidth(toolBoxWidgetsWidth); toolBox->addItem(LoadWidget, "Load Data"); // Range Query QGridLayout *layoutRangeTextEdits = new QGridLayout(); layoutRangeTextEdits->addWidget(minXRange,0,0,0); layoutRangeTextEdits->addWidget(maxXRange,0,1,0); layoutRangeTextEdits->addWidget(minYRange,1,0,0); layoutRangeTextEdits->addWidget(maxYRange,1,1,0); layoutRangeTextEdits->addWidget(minZRange,2,0,0); layoutRangeTextEdits->addWidget(maxZRange,2,1,0); QWidget* RangeTextEditsWidget = new QWidget(); RangeTextEditsWidget->setLayout(layoutRangeTextEdits); RangeTextEditsWidget->setFixedWidth(toolBoxSubWidgetsWidth); QVBoxLayout *layoutRange = new QVBoxLayout(); layoutRange->addWidget(RangeTextEditsWidget); layoutRange->addWidget(rangeQueryButton); QWidget* RangeWidget = new QWidget(); RangeWidget->setLayout(layoutRange); RangeWidget->setFixedWidth(toolBoxWidgetsWidth); toolBox->addItem(RangeWidget, "Range Query"); // Radius Query QGridLayout *layoutRadiusTextEdits = new QGridLayout(); layoutRadiusTextEdits->addWidget(xRadius, 0, 0, 0); layoutRadiusTextEdits->addWidget(yRadius, 0, 1, 0); layoutRadiusTextEdits->addWidget(zRadius, 0, 3, 0); layoutRadiusTextEdits->addWidget(rRadius, 1, 1, 0); QWidget* RadiusTextEditsWidget = new QWidget(); RadiusTextEditsWidget->setLayout(layoutRadiusTextEdits); RadiusTextEditsWidget->setFixedWidth(toolBoxSubWidgetsWidth); QVBoxLayout *layoutRadius = new QVBoxLayout(); layoutRadius->addWidget(RadiusTextEditsWidget); layoutRadius->addWidget(radiusQueryButton); QWidget* RadiusWidget = new QWidget(); RadiusWidget->setLayout(layoutRadius); RadiusWidget->setFixedWidth(toolBoxWidgetsWidth); toolBox->addItem(RadiusWidget, "Radius Query"); // NN Query QGridLayout *layoutNNTextEdits = new QGridLayout(); layoutNNTextEdits->addWidget(xNeighbour, 0, 0, 0); layoutNNTextEdits->addWidget(yNeighbour, 0, 1, 0); layoutNNTextEdits->addWidget(zNeighbour, 0, 3, 0); QWidget* NNTextEditsWidget = new QWidget(); NNTextEditsWidget->setLayout(layoutNNTextEdits); NNTextEditsWidget->setFixedWidth(toolBoxSubWidgetsWidth); QVBoxLayout *layoutNN = new QVBoxLayout(); layoutNN->addWidget(NNTextEditsWidget); layoutNN->addWidget(nnQueryButton); QWidget* NNWidget = new QWidget(); NNWidget->setLayout(layoutNN); NNWidget->setFixedWidth(toolBoxWidgetsWidth); toolBox->addItem(NNWidget, "Nearest Neighbour"); // Thinning QVBoxLayout *layoutThinning = new QVBoxLayout(); layoutThinning->addWidget(rThinning); layoutThinning->addWidget(thinningButton); QWidget* ThinningWidget = new QWidget(); ThinningWidget->setLayout(layoutThinning); ThinningWidget->setFixedWidth(toolBoxWidgetsWidth); toolBox->addItem(ThinningWidget, "Thinning"); // Smoothing QVBoxLayout *layoutSmoothing = new QVBoxLayout(); layoutSmoothing->addWidget(rSmoothing); layoutSmoothing->addWidget(smoothingButton); QWidget* SmoothingWidget = new QWidget(); SmoothingWidget->setLayout(layoutSmoothing); SmoothingWidget->setFixedWidth(toolBoxWidgetsWidth); toolBox->addItem(SmoothingWidget, "Smoothing"); // Fitting QVBoxLayout *layoutFitting = new QVBoxLayout(); layoutFitting->addWidget(labelFitting); layoutFitting->addWidget(planeFittingButton); layoutFitting->addWidget(lineFittingButton); layoutFitting->addWidget(sphereFittingButton); QWidget* FittingWidget = new QWidget(); FittingWidget->setLayout(layoutFitting); FittingWidget->setFixedWidth(toolBoxWidgetsWidth); toolBox->addItem(FittingWidget, "Fitting"); // Color QVBoxLayout *layoutColorByDist = new QVBoxLayout(); layoutColorByDist->addWidget(distanceColorMapButton); QWidget* ColorByDistWidget = new QWidget(); ColorByDistWidget->setLayout(layoutColorByDist); ColorByDistWidget->setFixedWidth(toolBoxWidgetsWidth); toolBox->addItem(ColorByDistWidget, "Color by Distance"); /*---- Data Group Box ----*/ QGroupBox *dataBox = new QGroupBox(tr("Data")); QVBoxLayout *layoutDataBox = new QVBoxLayout; layoutDataBox->addWidget(labelPoints); layoutDataBox->addWidget(labelCloudBounds); dataBox->setLayout(layoutDataBox); /*---- Side Bar ----*/ QVBoxLayout *layoutSideBar = new QVBoxLayout(); layoutSideBar->addWidget(dataBox); layoutSideBar->addWidget(toolBox); layoutSideBar->addWidget(labelTime); QWidget* sideBarWidget = new QWidget(); sideBarWidget->setLayout(layoutSideBar); sideBarWidget->setFixedWidth(toolBoxWidth); /*---- Main Widget ----*/ glWidget = new MainGLWidget(); glWidget->resize(windowWidth, windowHeight); glWidget->setMinimumWidth(windowWidth); glWidget->setMinimumHeight(windowHeight); QHBoxLayout *layoutMain = new QHBoxLayout(); layoutMain->addWidget(glWidget); layoutMain->addWidget(sideBarWidget); setLayout(layoutMain); }
void MainWindow::showEvent(QShowEvent *) { //Setting the QGraphicsScene scene = new QGraphicsScene(0,0,width(),ui->graphicsView->height()); ui->graphicsView->setScene(scene); //set background QImage bg; bg.load(":/image/background.jpg"); bg = bg.scaled(960,540); scene->setBackgroundBrush(bg); //bgm bgm = new QMediaPlayer(); bgm->setMedia(QUrl("qrc:/sound/Super Mario Bros. Music - Ground Theme (1).1.mp3")); bgm->setVolume(50); bgm->play(); //Create world world = new b2World(b2Vec2(0.0f, -9.8f)); //Setting Size GameItem::setGlobalSize(QSizeF(32,18),size()); //Create ground itemList.push_back(new Land(16,1.5,32,3,QPixmap(":/image/ground.png").scaled(width()*2,height()/5.0),world,scene)); //add slingshot image (just image, no box2D body) QGraphicsPixmapItem *slingShot = new QGraphicsPixmapItem(); QPixmap slingPic; slingPic.load(":/image/slingshot.png"); slingPic = slingPic.scaled(slingPic.width()*0.07, slingPic.height()*0.07, Qt::KeepAspectRatio); slingShot->setPixmap(slingPic); slingShot->setPos(170,300); scene->addItem(slingShot); //Create slingshot(removed tempararily) //sling = new Slingshot(3.5,5.5,2.5,4,QPixmap(":/image/slingshot.png").scaled(width()*0.06,height()*0.3),world,scene); /*Replace slingshot with a base point(with respect to the final cursor point we dragged to) * and try to use ApplyForce() on the boody (requires b2Vec2(force)) */ //add base point(reference point), to indicate direction QPen pen; scene->addEllipse(200,300,10,10,pen,QBrush(Qt::red)); //Create bird mushroom = new Bird(6,8,0.5f,&timer,QPixmap(":/image/mushroom.png").scaled(height()/8.0,height()/8.0),world,scene); goomba = new FloppyBird(7,8,0.5f,&timer,QPixmap(":/image/goo.png").scaled(height()/8.0,height()/8.0),world,scene); kirby = new SprintBird(8,8,0.5f,&timer,QPixmap(":/image/kirby.png").scaled(height()/7.0,height()/7.0),world,scene); turtle = new StrikeBird(9,8,0.5f,&timer,QPixmap(":/image/turtle.png").scaled(height()/8.0,height()/8.0),world,scene); fist = new Bird(18,40,0.9f,&timer,QPixmap(":/image/fist.png").scaled(height()*0.5,height()*0.5),world,scene); fist->g_body->SetAwake(false); //deactivate the fist at first, wait for strike bird //Create barrier wood = new Barrier(24,6,1,5,&timer,QPixmap(":/image/barrier.png").scaled(height()/10.0,height()/2.0),world,scene); wood2 = new Barrier(18,6,1,5,&timer,QPixmap(":/image/barrier.png").scaled(height()/10.0,height()/2.0),world,scene); hori_wood = new Barrier(19,16,5,1,&timer,QPixmap(":/image/barrier_hori.png").scaled(height()/2.0,height()/2.8),world,scene); //Create enemy lbj = new Bird(21,6,1.0f,&timer,QPixmap(":/image/LBJ.png").scaled(height()/6.0,height()/5.0),world,scene); //Store birds BirdList.push_back(mushroom); BirdList.push_back(goomba); BirdList.push_back(kirby); BirdList.push_back(turtle); //Store barriers and enemy itemList.push_back(wood); itemList.push_back(wood2); itemList.push_back(hori_wood); itemList.push_back(lbj); itemList.push_back(fist); //Reset button QPushButton *resetBtn = new QPushButton("RESET"); resetBtn->setFont(QFont("Courier",16,QFont::Bold)); resetBtn->setGeometry(100,0,70,40); scene->addWidget(resetBtn); //Quit button QPushButton *quitBtn = new QPushButton("QUIT"); quitBtn->setFont(QFont("Courier",16,QFont::Bold)); quitBtn->setGeometry(0,0,70,40); scene->addWidget(quitBtn); //scoreboard QLabel *scoreboard = new QLabel("SCORE:"); scoreboard->setFont(QFont("Courier",20,QFont::Bold)); scoreboard->setGeometry(200,0,100,40); scene->addWidget(scoreboard); //score score = new QLabel(QString::number(scoreNum)); score->setFont(QFont("Courier",20,QFont::Bold)); score->setGeometry(330,0,200,40); scene->addWidget(score); //if(!isConnected) //{ // Timer and calculate score connect(&timer,SIGNAL(timeout()),this,SLOT(tick())); //} timer.start(100/6); //button connect connect(this,SIGNAL(quitGame()),this,SLOT(QUITSLOT())); connect(quitBtn,SIGNAL(clicked()),this,SLOT(closeGame())); connect(resetBtn,SIGNAL(clicked()),this,SLOT(resetGame())); }
QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title, const QString& message, QSystemTrayIcon *ti) : QWidget(0, Qt::ToolTip), trayIcon(ti), timerId(-1) { setAttribute(Qt::WA_DeleteOnClose); QObject::connect(ti, SIGNAL(destroyed()), this, SLOT(close())); QLabel *titleLabel = new QLabel; titleLabel->installEventFilter(this); titleLabel->setText(title); QFont f = titleLabel->font(); f.setBold(true); #ifdef Q_WS_WINCE f.setPointSize(f.pointSize() - 2); #endif titleLabel->setFont(f); titleLabel->setTextFormat(Qt::PlainText); // to maintain compat with windows #ifdef Q_WS_WINCE const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize); const int closeButtonSize = style()->pixelMetric(QStyle::PM_SmallIconSize) - 2; #else const int iconSize = 18; const int closeButtonSize = 15; #endif QPushButton *closeButton = new QPushButton; closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton)); closeButton->setIconSize(QSize(closeButtonSize, closeButtonSize)); closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); closeButton->setFixedSize(closeButtonSize, closeButtonSize); QObject::connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); QLabel *msgLabel = new QLabel; #ifdef Q_WS_WINCE f.setBold(false); msgLabel->setFont(f); #endif msgLabel->installEventFilter(this); msgLabel->setText(message); msgLabel->setTextFormat(Qt::PlainText); msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); // smart size for the message label #ifdef Q_WS_WINCE int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 2; #else int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 3; #endif if (msgLabel->sizeHint().width() > limit) { msgLabel->setWordWrap(true); if (msgLabel->sizeHint().width() > limit) { msgLabel->d_func()->ensureTextControl(); if (QTextControl *control = msgLabel->d_func()->control) { QTextOption opt = control->document()->defaultTextOption(); opt.setWrapMode(QTextOption::WrapAnywhere); control->document()->setDefaultTextOption(opt); } } #ifdef Q_WS_WINCE // Make sure that the text isn't wrapped "somewhere" in the balloon widget // in the case that we have a long title label. setMaximumWidth(limit); #else // Here we allow the text being much smaller than the balloon widget // to emulate the weird standard windows behavior. msgLabel->setFixedSize(limit, msgLabel->heightForWidth(limit)); #endif } QIcon si; switch (icon) { case QSystemTrayIcon::Warning: si = style()->standardIcon(QStyle::SP_MessageBoxWarning); break; case QSystemTrayIcon::Critical: si = style()->standardIcon(QStyle::SP_MessageBoxCritical); break; case QSystemTrayIcon::Information: si = style()->standardIcon(QStyle::SP_MessageBoxInformation); break; case QSystemTrayIcon::NoIcon: default: break; } QGridLayout *layout = new QGridLayout; if (!si.isNull()) { QLabel *iconLabel = new QLabel; iconLabel->setPixmap(si.pixmap(iconSize, iconSize)); iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); iconLabel->setMargin(2); layout->addWidget(iconLabel, 0, 0); layout->addWidget(titleLabel, 0, 1); } else { layout->addWidget(titleLabel, 0, 0, 1, 2); } layout->addWidget(closeButton, 0, 2); layout->addWidget(msgLabel, 1, 0, 1, 3); layout->setSizeConstraint(QLayout::SetFixedSize); layout->setMargin(3); setLayout(layout); QPalette pal = palette(); pal.setColor(QPalette::Window, QColor(0xff, 0xff, 0xe1)); pal.setColor(QPalette::WindowText, Qt::black); setPalette(pal); }