PreFlightGliderPage::PreFlightGliderPage(QWidget *parent) : QWidget(parent), m_lastGlider(0) { setObjectName("PreFlightGliderPage"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("PreFlight - Glider") ); if( parent ) { resize( parent->size() ); } QHBoxLayout *contentLayout = new QHBoxLayout; setLayout(contentLayout); QGridLayout* topLayout = new QGridLayout; topLayout->setMargin(5); contentLayout->addLayout(topLayout); int row = 0; QLabel* lblPilot = new QLabel(tr("Pilot:"), this); topLayout->addWidget(lblPilot, row, 0); Qt::InputMethodHints imh; m_edtPilot = new QLineEdit(this); imh = (m_edtPilot->inputMethodHints() | Qt::ImhNoPredictiveText); m_edtPilot->setInputMethodHints(imh); m_edtPilot->setText( GeneralConfig::instance()->getSurname() ); connect( m_edtPilot, SIGNAL(returnPressed()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); topLayout->addWidget(m_edtPilot, row, 1); QLabel* lblLoad = new QLabel(tr("Load corr:"), this); topLayout->addWidget(lblLoad, row, 2); m_edtLoad = new NumberEditor; m_edtLoad->setDecimalVisible( false ); m_edtLoad->setPmVisible( true ); m_edtLoad->setMaxLength(4); m_edtLoad->setSuffix(" kg"); m_edtLoad->setRange( -999, 999 ); m_edtLoad->setValue( 0 ); topLayout->addWidget(m_edtLoad, row, 3); row++; m_edtCoPilotLabel = new QLabel(tr("Copilot:"), this); topLayout->addWidget(m_edtCoPilotLabel, row, 0); m_edtCoPilot = new QLineEdit(this); m_edtCoPilot->setInputMethodHints(imh); connect( m_edtCoPilot, SIGNAL(returnPressed()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); topLayout->addWidget(m_edtCoPilot, row, 1); QLabel* lblWater = new QLabel(tr("Water ballast:"), this); topLayout->addWidget(lblWater, row, 2); m_edtWater = new NumberEditor; m_edtWater->setDecimalVisible( false ); m_edtWater->setPmVisible( false ); m_edtWater->setMaxLength(4); m_edtWater->setSuffix(" l"); m_edtWater->setRange( 0, 9999 ); m_edtWater->setValue( 0 ); topLayout->addWidget(m_edtWater, row, 3); row++; QHBoxLayout* hbox = new QHBoxLayout; hbox->addWidget( new QLabel(tr("Ref. weight:"), this) ); m_refWeight = new QLabel; m_refWeight->setFocusPolicy(Qt::NoFocus); hbox->addWidget( m_refWeight, 10 ); topLayout->addLayout( hbox, row, 0, 1, 2 ); hbox = new QHBoxLayout; hbox->addWidget( new QLabel(tr("Wing load:"), this) ); m_wingLoad = new QLabel; m_wingLoad->setFocusPolicy(Qt::NoFocus); hbox->addWidget( m_wingLoad, 10 ); topLayout->addLayout( hbox, row, 2, 1, 2 ); row++; topLayout->setRowMinimumHeight( row, 10 ); row++; m_gliderList = new GliderListWidget( this, true ); #ifndef ANDROID m_gliderList->setToolTip(tr("Select a glider to be used")); #endif #ifdef ANDROID QScrollBar* lvsb = m_gliderList->verticalScrollBar(); lvsb->setStyleSheet( Layout::getCbSbStyle() ); #endif #ifdef QSCROLLER QScroller::grabGesture(m_gliderList->viewport(), QScroller::LeftMouseButtonGesture); #endif #ifdef QTSCROLLER QtScroller::grabGesture(m_gliderList->viewport(), QtScroller::LeftMouseButtonGesture); #endif topLayout->addWidget(m_gliderList, row, 0, 1, 4); row++; //--------------------------------------------------------------------- QPushButton* deselect = new QPushButton( tr("Deselect"), this ); #ifndef ANDROID deselect->setToolTip( tr("Clear glider selection") ); #endif topLayout->addWidget( deselect, row, 3 ); //--------------------------------------------------------------------- m_gliderList->fillList(); m_gliderList->clearSelection(); m_gliderList->selectItemFromList(); connect(deselect, SIGNAL(clicked()), this, SLOT(slotGliderDeselected()) ); connect(m_gliderList, SIGNAL(itemSelectionChanged()), this, SLOT(slotGliderChanged())); connect(m_edtLoad, SIGNAL(numberEdited(const QString&)), this, SLOT(slotLoadEdited(const QString&))); connect(m_edtWater, SIGNAL(numberEdited(const QString&)), this, SLOT(slotWaterEdited(const QString&))); QPushButton *help = new QPushButton(this); help->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("help32.png"))); help->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); help->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); 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( _globalMapConfig->createGlider(315, 1.6) ); connect(help, SIGNAL(pressed()), this, SLOT(slotHelp())); connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addWidget(help, 1); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); contentLayout->addLayout(buttonBox); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget * main_wg = new QWidget; // cria um objeto "splitter" para compartilhar widgets: QSplitter *splitter = new QSplitter(main_wg); // cria um "model" usando o "StandardModel" QStandardItemModel *model = new QStandardItemModel; const int totCols = 3; int col; // define os títulos das colunas: for (col = 0; col < totCols; ++col) { model->setHorizontalHeaderItem(col, new QStandardItem( QString("COL-%1").arg(col+1) ) ); } // alimenta linhas, colunas e sub-níveis: QStandardItem *parentItem = model->invisibleRootItem(); const int iniLevel = 0; const int totLevels= 3; QString prevRows(""); QVector<QSize> vec_ColsRows; // colunas, linhas de cada nível vec_ColsRows.reserve( totLevels ); // quantidade-colunas, quantidade-linhas vec_ColsRows << QSize(3,10) << QSize(3,3) << QSize(3,2) ; populate_model ( parentItem, vec_ColsRows, iniLevel, prevRows); // Neste exemplo, // O "model" foi alimentado com linhas, colunas e sub-níveis: // E serão criadas 4 "views" (uma "tree", uma "table", uma "list" e uma "comboBox") // relacionadas ao mesmo "model"; // Cada "view" exibe os dados de uma determinada maneira; // 1- ==== a primeira "view" é uma "tree": QTreeView *tree = new QTreeView(splitter); tree->setModel(model); // habilita classificação na tree: tree->setSortingEnabled(true); // classifica tree->sortByColumn(0); // expande toda a árvore: tree->expandAll(); // força largura de todas as colunas // para exibição completa do texto dos seus itens for (col = 0; col < totCols; ++col) tree->resizeColumnToContents(col); // configura o header para permitir mudança na ordem de classificacão: QHeaderView * hdrTree = tree->header(); hdrTree->setClickable (true); hdrTree->setSortIndicator(0,Qt::AscendingOrder); hdrTree->setSortIndicatorShown(true); hdrTree->setMovable(true); // permite mover colunas do header // 2- ==== a segunda "view" é uma "table" QTableView *table = new QTableView(splitter); table->setModel(model); table->setAlternatingRowColors(true); // habilita classificação na table: table->setSortingEnabled(true); // classifica table->sortByColumn(0); // configura o header para permitir mudança na ordem de classificacão: QHeaderView * hdrTable = table->horizontalHeader(); hdrTable->setClickable (true); hdrTable->setSortIndicator(0,Qt::AscendingOrder); hdrTable->setSortIndicatorShown(true); hdrTable->setMovable(true); // permite mover colunas do header // 3- ==== a terceira view é uma "list": QListView *list = new QListView(splitter); list->setModel(model); // 4- ==== a quarta "view" é uma "comboBox" QComboBox *combo = new QComboBox; combo->setModel(model); // configura a "splitter" definindo a largura de cada "view" int width = 800; QList< int > cols; cols << int(width* 0.45) << int(width*0.45) << int(width*0.1); splitter->setSizes(cols); // layout para agrupar a "combo" e a "splitter": QGridLayout * glayMain = new QGridLayout; main_wg->setLayout( glayMain); glayMain->addWidget( combo, 0, 1); // linha 0, coluna 0; glayMain->setRowMinimumHeight(1, glayMain->verticalSpacing() * 4); // linha 1: linha de separação glayMain->addWidget( splitter, 2, 0, 1, 3 ); // linha 2, coluna 0, rowSpan 1, colSpan 3 main_wg->setWindowTitle("06_standard - 4 'views' usando o mesmo 'model' (StandardModel) - recursivo"); main_wg->resize(800,500); main_wg->show(); return app.exec(); }
ShapeFileOptionsWidget::ShapeFileOptionsWidget(ShapeFile* pShapefile, const vector<AoiElement*>& aois, RasterElement* pRaster) : QWidget(NULL), mpShapeFile(pShapefile), mAois(aois), mpGeoref(pRaster) { // Filenames QLabel* pFilePathLabel = new QLabel("File Path:", this); QLabel* pBaseNameLabel = new QLabel("Base Name:", this); QLabel* pShpLabel = new QLabel("SHP:", this); QLabel* pShxLabel = new QLabel("SHX:", this); QLabel* pDbfLabel = new QLabel("DBF:", this); QFont ftBold = QApplication::font(); ftBold.setBold(true); pFilePathLabel->setFont(ftBold); pBaseNameLabel->setFont(ftBold); pShpLabel->setFont(ftBold); pShxLabel->setFont(ftBold); pDbfLabel->setFont(ftBold); mpFilePathEdit = new QLineEdit(this); mpFilePathEdit->setReadOnly(true); mpBaseNameEdit = new QLineEdit(this); mpBaseNameEdit->setFixedWidth(150); mpShpFileLabel = new QLabel(this); mpShxFileLabel = new QLabel(this); mpDbfFileLabel = new QLabel(this); // Browse button QIcon icnBrowse(":/icons/Open"); QPushButton* pBrowseButton = new QPushButton(icnBrowse, QString(), this); pBrowseButton->setFixedWidth(27); // Shape type QLabel* pShapeLabel = new QLabel("Shape:", this); pShapeLabel->setFont(ftBold); mpShapeCombo = new QComboBox(this); mpShapeCombo->setEditable(false); mpShapeCombo->setFixedWidth(150); vector<string> comboText = StringUtilities::getAllEnumValuesAsDisplayString<ShapefileTypes::ShapeType>(); for (vector<string>::iterator it = comboText.begin(); it != comboText.end(); ++it) { mpShapeCombo->addItem(QString::fromStdString(*it)); } // Feature list QLabel* pFeatureLabel = new QLabel("Features:", this); QStringList columnNames; columnNames.append("Feature"); mpFeatureTree = new CustomTreeWidget(this); mpFeatureTree->setColumnCount(columnNames.count()); mpFeatureTree->setHeaderLabels(columnNames); mpFeatureTree->setSelectionMode(QAbstractItemView::SingleSelection); mpFeatureTree->setRootIsDecorated(false); mpFeatureTree->setSortingEnabled(true); QHeaderView* pHeader = mpFeatureTree->header(); if (pHeader != NULL) { pHeader->setSortIndicatorShown(true); pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter); pHeader->setStretchLastSection(false); } // Feature buttons QPushButton* pAddFeatureButton = new QPushButton("Add Feature", this); QPushButton* pRemoveFeatureButton = new QPushButton("Remove Feature", this); QPushButton* pClearFeatureButton = new QPushButton("Clear Features", this); // Field buttons QPushButton* pAddFieldButton = new QPushButton("Add Field", this); QPushButton* pRemoveFieldButton = new QPushButton("Remove Field", this); // Layout QHBoxLayout* pFilePathLayout = new QHBoxLayout(); pFilePathLayout->setMargin(0); pFilePathLayout->setSpacing(5); pFilePathLayout->addWidget(mpFilePathEdit, 10); pFilePathLayout->addWidget(pBrowseButton); QHBoxLayout* pNameShapeLayout = new QHBoxLayout(); pNameShapeLayout->setMargin(0); pNameShapeLayout->setSpacing(5); pNameShapeLayout->addWidget(mpBaseNameEdit); pNameShapeLayout->addSpacing(20); pNameShapeLayout->addWidget(pShapeLabel); pNameShapeLayout->addWidget(mpShapeCombo); pNameShapeLayout->addStretch(); QVBoxLayout* pButtonLayout = new QVBoxLayout(); pButtonLayout->setMargin(0); pButtonLayout->setSpacing(5); pButtonLayout->addWidget(pAddFeatureButton); pButtonLayout->addWidget(pRemoveFeatureButton); pButtonLayout->addWidget(pClearFeatureButton); pButtonLayout->addStretch(10); pButtonLayout->addWidget(pAddFieldButton); pButtonLayout->addWidget(pRemoveFieldButton); QGridLayout* pGrid = new QGridLayout(this); pGrid->setMargin(10); pGrid->setSpacing(5); pGrid->addWidget(pFilePathLabel, 0, 0); pGrid->addLayout(pFilePathLayout, 0, 1, 1, 3); pGrid->addWidget(pBaseNameLabel, 1, 0); pGrid->addLayout(pNameShapeLayout, 1, 1, 1, 3); pGrid->addWidget(pShpLabel, 2, 0); pGrid->addWidget(mpShpFileLabel, 2, 1, 1, 3); pGrid->addWidget(pShxLabel, 3, 0); pGrid->addWidget(mpShxFileLabel, 3, 1, 1, 3); pGrid->addWidget(pDbfLabel, 4, 0); pGrid->addWidget(mpDbfFileLabel, 4, 1, 1, 3); pGrid->setRowMinimumHeight(5, 12); pGrid->addWidget(pFeatureLabel, 6, 0, 1, 4); pGrid->addWidget(mpFeatureTree, 7, 0, 1, 2); pGrid->setColumnMinimumWidth(2, 2); pGrid->addLayout(pButtonLayout, 7, 3); pGrid->setRowStretch(7, 10); pGrid->setColumnStretch(1, 10); // Initialization setWindowTitle("Shape File"); if (mpShapeFile != NULL) { // Filename const string& filename = mpShapeFile->getFilename(); if (!filename.empty()) { QFileInfo fileInfo(QString::fromStdString(filename)); mpFilePathEdit->setText(fileInfo.absolutePath()); mpBaseNameEdit->setText(fileInfo.completeBaseName()); } updateFilenames(); // Shape int index = ShapefileTypes::getIndex(mpShapeFile->getShape()); if (index < 0) { index = 0; } mpShapeCombo->setCurrentIndex(index); // Features const vector<Feature*>& features = mpShapeFile->getFeatures(); for (unsigned int i = 0; i < features.size(); i++) { Feature* pFeature = features[i]; if (pFeature != NULL) { QTreeWidgetItem* pItem = new QTreeWidgetItem(mpFeatureTree); if (pItem != NULL) { pItem->setText(0, QString::number(i + 1)); mFeatures.insert(pItem, pFeature); } } } // Fields updateFieldValues(); } // Connections connect(mpFilePathEdit, SIGNAL(textChanged(const QString&)), this, SLOT(updateFilenames())); connect(pBrowseButton, SIGNAL(clicked()), this, SLOT(browse())); connect(mpBaseNameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(updateFilenames())); connect(mpShapeCombo, SIGNAL(activated(const QString&)), this, SLOT(setShape(const QString&))); connect(pAddFeatureButton, SIGNAL(clicked()), this, SLOT(addFeature())); connect(pRemoveFeatureButton, SIGNAL(clicked()), this, SLOT(removeFeature())); connect(pClearFeatureButton, SIGNAL(clicked()), this, SLOT(clearFeatures())); connect(pAddFieldButton, SIGNAL(clicked()), this, SLOT(addField())); connect(pRemoveFieldButton, SIGNAL(clicked()), this, SLOT(removeField())); connect(mpFeatureTree, SIGNAL(cellTextChanged(QTreeWidgetItem*, int)), this, SLOT(setFieldValue(QTreeWidgetItem*, int))); }
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(); }
SettingsPageGPS4A::SettingsPageGPS4A(QWidget *parent) : QWidget(parent) { setObjectName("SettingsPageGPS4A"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("Settings - GPS") ); if( parent ) { resize( parent->size() ); } QHBoxLayout *contentLayout = new QHBoxLayout; setLayout(contentLayout); QGridLayout* topLayout = new QGridLayout; contentLayout->addLayout(topLayout, 10); int row = 0; topLayout->setRowMinimumHeight( row++, 20); // Defines from which device the altitude data shall be taken. Possible // devices are the GPS or a pressure sonde. GpsAltitude = new QComboBox; GpsAltitude->setEditable(false); GpsAltitude->addItem(tr("GPS")); GpsAltitude->addItem(tr("Pressure")); QFormLayout* fl = new QFormLayout; fl->addRow( tr("Altitude Reference:"), GpsAltitude ); topLayout->addLayout( fl, row++, 0, Qt::AlignLeft ); topLayout->setRowMinimumHeight( row++, 10); saveNmeaData = new QCheckBox (tr("Save NMEA Data to file")); topLayout->addWidget( saveNmeaData, row++, 0, Qt::AlignLeft ); topLayout->setRowStretch( row, 10 ); 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(); }
void QFontDialogPrivate::init() { Q_Q(QFontDialog); q->setSizeGripEnabled(true); q->setWindowTitle(QFontDialog::tr("Select Font")); // grid familyEdit = new QLineEdit(q); familyEdit->setReadOnly(true); familyList = new QFontListView(q); familyEdit->setFocusProxy(familyList); familyAccel = new QLabel(q); #ifndef QT_NO_SHORTCUT familyAccel->setBuddy(familyList); #endif familyAccel->setIndent(2); styleEdit = new QLineEdit(q); styleEdit->setReadOnly(true); styleList = new QFontListView(q); styleEdit->setFocusProxy(styleList); styleAccel = new QLabel(q); #ifndef QT_NO_SHORTCUT styleAccel->setBuddy(styleList); #endif styleAccel->setIndent(2); sizeEdit = new QLineEdit(q); sizeEdit->setFocusPolicy(Qt::ClickFocus); QIntValidator *validator = new QIntValidator(1, 512, q); sizeEdit->setValidator(validator); sizeList = new QFontListView(q); sizeAccel = new QLabel(q); #ifndef QT_NO_SHORTCUT sizeAccel->setBuddy(sizeEdit); #endif sizeAccel->setIndent(2); // effects box effects = new QGroupBox(q); QVBoxLayout *vbox = new QVBoxLayout(effects); strikeout = new QCheckBox(effects); vbox->addWidget(strikeout); underline = new QCheckBox(effects); vbox->addWidget(underline); sample = new QGroupBox(q); QHBoxLayout *hbox = new QHBoxLayout(sample); sampleEdit = new QLineEdit(sample); sampleEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored)); sampleEdit->setAlignment(Qt::AlignCenter); // Note that the sample text is *not* translated with tr(), as the // characters used depend on the charset encoding. sampleEdit->setText(QLatin1String("AaBbYyZz")); hbox->addWidget(sampleEdit); writingSystemCombo = new QComboBox(q); writingSystemAccel = new QLabel(q); #ifndef QT_NO_SHORTCUT writingSystemAccel->setBuddy(writingSystemCombo); #endif writingSystemAccel->setIndent(2); size = 0; smoothScalable = false; QObject::connect(writingSystemCombo, SIGNAL(activated(int)), q, SLOT(_q_writingSystemHighlighted(int))); QObject::connect(familyList, SIGNAL(highlighted(int)), q, SLOT(_q_familyHighlighted(int))); QObject::connect(styleList, SIGNAL(highlighted(int)), q, SLOT(_q_styleHighlighted(int))); QObject::connect(sizeList, SIGNAL(highlighted(int)), q, SLOT(_q_sizeHighlighted(int))); QObject::connect(sizeEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_sizeChanged(QString))); QObject::connect(strikeout, SIGNAL(clicked()), q, SLOT(_q_updateSample())); QObject::connect(underline, SIGNAL(clicked()), q, SLOT(_q_updateSample())); for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) { QFontDatabase::WritingSystem ws = QFontDatabase::WritingSystem(i); QString writingSystemName = QFontDatabase::writingSystemName(ws); if (writingSystemName.isEmpty()) break; writingSystemCombo->addItem(writingSystemName); } updateFamilies(); if (familyList->count() != 0) familyList->setCurrentItem(0); // grid layout QGridLayout *mainGrid = new QGridLayout(q); int spacing = mainGrid->spacing(); if (spacing >= 0) { // uniform spacing mainGrid->setSpacing(0); mainGrid->setColumnMinimumWidth(1, spacing); mainGrid->setColumnMinimumWidth(3, spacing); int margin = 0; mainGrid->getContentsMargins(0, 0, 0, &margin); mainGrid->setRowMinimumHeight(3, margin); mainGrid->setRowMinimumHeight(6, 2); mainGrid->setRowMinimumHeight(8, margin); } mainGrid->addWidget(familyAccel, 0, 0); mainGrid->addWidget(familyEdit, 1, 0); mainGrid->addWidget(familyList, 2, 0); mainGrid->addWidget(styleAccel, 0, 2); mainGrid->addWidget(styleEdit, 1, 2); mainGrid->addWidget(styleList, 2, 2); mainGrid->addWidget(sizeAccel, 0, 4); mainGrid->addWidget(sizeEdit, 1, 4); mainGrid->addWidget(sizeList, 2, 4); mainGrid->setColumnStretch(0, 38); mainGrid->setColumnStretch(2, 24); mainGrid->setColumnStretch(4, 10); mainGrid->addWidget(effects, 4, 0); mainGrid->addWidget(sample, 4, 2, 4, 3); mainGrid->addWidget(writingSystemAccel, 5, 0); mainGrid->addWidget(writingSystemCombo, 7, 0); buttonBox = new QDialogButtonBox(q); mainGrid->addWidget(buttonBox, 9, 0, 1, 5); QPushButton *button = static_cast<QPushButton *>(buttonBox->addButton(QDialogButtonBox::Ok)); QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept())); button->setDefault(true); buttonBox->addButton(QDialogButtonBox::Cancel); QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject())); #if defined(Q_OS_WINCE) q->resize(180, 120); #else q->resize(500, 360); #endif // Q_OS_WINCE sizeEdit->installEventFilter(q); familyList->installEventFilter(q); styleList->installEventFilter(q); sizeList->installEventFilter(q); familyList->setFocus(); retranslateStrings(); }
BackupPage::BackupPage( BackupWizard * parent ) : QWizardPage( parent ), behaviour( new QButtonGroup( this ) ), baseDirectory( new QLineEdit( this ) ), crossMountPoints( new QCheckBox( tr( "Cross mount points" ), this ) ), everything( new QRadioButton( tr( "Back up &everything" ), this ) ), something( new QRadioButton( tr( "Back up only some &subdirectories" ), this ) ), complete( false ) { setTitle( tr( "Backup" ) ); setSubTitle( tr( "Select what to back up" ) ); QPushButton * browse = new QPushButton( tr( "..." ), this ); connect( browse, SIGNAL(clicked()), this, SLOT(browseBaseDirectory()) ); connect( baseDirectory, SIGNAL(textChanged(const QString &)), this, SLOT(checkDirectories()) ); QGridLayout * l = new QGridLayout( this ); l->addWidget( new QLabel( tr( "Directory" ), this ), 0, 0, 1, 1, Qt::AlignLeft ); l->addWidget( baseDirectory, 0, 1, 1, 2 ); l->addWidget( browse, 0, 3, 1, 1 ); l->addWidget( new QLabel( tr( "Behaviour" ), this ), 2, 0, 1, 1, Qt::AlignLeft ); l->addWidget( everything, 2, 1, 1, 1, Qt::AlignLeft ); l->addWidget( something, 3, 1, 1, 1, Qt::AlignLeft ); l->addWidget( new QLabel( tr( "Options" ), this ), 5, 0, 1, 1, Qt::AlignLeft ); l->addWidget( crossMountPoints, 5, 1, 1, 2, Qt::AlignLeft ); l->setColumnStretch( 1, 2 ); l->setColumnStretch( 2, 2 ); l->setRowMinimumHeight( 1, 12 ); l->setRowMinimumHeight( 4, 12 ); behaviour->addButton( something ); behaviour->addButton( everything ); everything->setChecked( true ); crossMountPoints->setChecked( true ); baseDirectory->setText( "/" ); registerField( "baseDirectory", baseDirectory ); registerField( "crossMountPoints", crossMountPoints ); registerField( "something", something ); }
// **************************************************************************** // Constructor: XMLEditConstants::XMLEditConstants // // Programmer: Jeremy Meredith // Creation: October 17, 2002 // // Modifications: // Brad Whitlock, Thu Mar 6 16:11:47 PST 2008 // Added targets. // // Cyrus Harrison, Thu May 15 16:00:46 PDT 200 // First pass at porting to Qt 4.4.0 // // **************************************************************************** XMLEditConstants::XMLEditConstants(QWidget *p) : QFrame(p) { QHBoxLayout *hLayout = new QHBoxLayout(this); setLayout(hLayout); QGridLayout *listLayout = new QGridLayout(); constantlist = new QListWidget(this); listLayout->addWidget(constantlist, 0,0, 1,2); newButton = new QPushButton(tr("New"), this); listLayout->addWidget(newButton, 1,0); delButton = new QPushButton(tr("Del"), this); listLayout->addWidget(delButton, 1,1); hLayout->addLayout(listLayout); hLayout->addSpacing(10); QGridLayout *topLayout = new QGridLayout(); int row = 0; topLayout->addWidget(new QLabel(tr("Target"), this), row, 0); target = new QLineEdit(this); topLayout->addWidget(target, row, 1); row++; topLayout->addWidget(new QLabel(tr("Name"), this), row, 0); name = new QLineEdit(this); topLayout->addWidget(name, row, 1); row++; member = new QCheckBox(tr("Class member"), this); topLayout->addWidget(member, row,0, 1,2); row++; topLayout->addWidget(new QLabel(tr("Declaration"), this), row, 0); declaration = new QLineEdit(this); topLayout->addWidget(declaration, row, 1); row++; topLayout->addWidget(new QLabel(tr("Definition"), this), row, 0); row++; definition = new QTextEdit(this); QFont monospaced("Courier"); definition->setFont(monospaced); definition->setWordWrapMode(QTextOption::NoWrap); topLayout->addWidget(definition, row,0, 1,2); row++; topLayout->setRowMinimumHeight(row, 20); row++; hLayout->addLayout(topLayout); connect(constantlist, SIGNAL(currentRowChanged(int)), this, SLOT(UpdateWindowSingleItem())); connect(target, SIGNAL(textChanged(const QString&)), this, SLOT(targetTextChanged(const QString&))); connect(name, SIGNAL(textChanged(const QString&)), this, SLOT(nameTextChanged(const QString&))); connect(member, SIGNAL(clicked()), this, SLOT(memberChanged())); connect(declaration, SIGNAL(textChanged(const QString&)), this, SLOT(declarationTextChanged(const QString&))); connect(definition, SIGNAL(textChanged()), this, SLOT(definitionChanged())); connect(newButton, SIGNAL(clicked()), this, SLOT(constantlistNew())); connect(delButton, SIGNAL(clicked()), this, SLOT(constantlistDel())); }
void PlotWidgetImp::initialize(PlotViewImp *pPlotView, const string& plotName, PlotType plotType) { // cleanup a previous initialization delete mpPlotWidget; // Parent widget for the plot widgets mpPlotWidget = new QWidget(this); // Top labels mpTopLeftLabel = new QLabel(mpPlotWidget); mpTopCenterLabel = new QLabel(mpPlotWidget); mpTopRightLabel = new QLabel(mpPlotWidget); mpTopCenterLabel->setAlignment(Qt::AlignHCenter); // Bottom labels mpBottomLeftLabel = new QLabel(mpPlotWidget); mpBottomCenterLabel = new QLabel(mpPlotWidget); mpBottomRightLabel = new QLabel(mpPlotWidget); mpBottomCenterLabel->setAlignment(Qt::AlignHCenter); // Title mpTitleLabel = new ElidedLabel(mpPlotWidget); mpTitleLabel->setMinimumWidth(100); mpTitleLabel->setAlignment(Qt::AlignHCenter); mpTitleLabel->hide(); // Plot widget QWidget* pPlotWidget = new QWidget(this); // Plot if (pPlotView == NULL) { mpPlot = dynamic_cast<PlotViewImp*>(Service<DesktopServices>()->createPlot(plotName, plotType, pPlotWidget)); } else { mpPlot = pPlotView; } mpPlot->installEventFilter(this); CartesianPlot* pCartesianPlot = dynamic_cast<CartesianPlot*>(mpPlot); if (pCartesianPlot != NULL) { // Mouse locator labels mpXMouseLabel = new FloatingLabel(Qt::Horizontal, pPlotWidget); mpYMouseLabel = new FloatingLabel(Qt::Vertical, pPlotWidget); // Axes mpXAxis = new AxisAdapter(AXIS_BOTTOM, pPlotWidget); mpYAxis = new AxisAdapter(AXIS_LEFT, pPlotWidget); QFont ftAxis; ftAxis.setBold(true); ftAxis.setPointSize(10); mpXAxis->setFont(ftAxis); mpYAxis->setFont(ftAxis); QString strXAxisText = QString::fromStdString(pCartesianPlot->getXDataType()); QString strYAxisText = QString::fromStdString(pCartesianPlot->getYDataType()); mpXAxis->setTitle(strXAxisText); mpYAxis->setTitle(strYAxisText); } // Legend mpLegend = new Legend(); mpLegend->setFrameStyle(QFrame::NoFrame); mpLegend->setMinimumWidth(120); // Splitter widget mpSplitter = new QSplitter(Qt::Horizontal, mpPlotWidget); mpSplitter->setOpaqueResize(true); mpSplitter->installEventFilter(this); mpSplitter->insertWidget(0, pPlotWidget); mpSplitter->insertWidget(1, mpLegend); mpSplitter->setStretchFactor(0, 10); // Layout QHBoxLayout* pTopLabelLayout = new QHBoxLayout(); pTopLabelLayout->setMargin(0); pTopLabelLayout->setSpacing(5); pTopLabelLayout->addWidget(mpTopLeftLabel, 0, Qt::AlignLeft); pTopLabelLayout->addWidget(mpTopCenterLabel, 0, Qt::AlignHCenter); pTopLabelLayout->addWidget(mpTopRightLabel, 0, Qt::AlignRight); QHBoxLayout* pBottomLabelLayout = new QHBoxLayout(); pBottomLabelLayout->setMargin(0); pBottomLabelLayout->setSpacing(5); pBottomLabelLayout->addWidget(mpBottomLeftLabel, 0, Qt::AlignLeft); pBottomLabelLayout->addWidget(mpBottomCenterLabel, 0, Qt::AlignHCenter); pBottomLabelLayout->addWidget(mpBottomRightLabel, 0, Qt::AlignRight); if (pCartesianPlot == NULL) { QVBoxLayout* pPlotLayout = new QVBoxLayout(pPlotWidget); pPlotLayout->setMargin(0); pPlotLayout->setSpacing(5); pPlotLayout->addWidget(mpPlot); } else { QGridLayout* pPlotGrid = new QGridLayout(pPlotWidget); pPlotGrid->setMargin(0); pPlotGrid->setSpacing(0); pPlotGrid->addWidget(mpXMouseLabel, 0, 1); pPlotGrid->setRowMinimumHeight(1, 5); pPlotGrid->addWidget(mpYAxis, 2, 0); pPlotGrid->addWidget(mpPlot, 2, 1); pPlotGrid->setColumnMinimumWidth(2, 5); pPlotGrid->addWidget(mpYMouseLabel, 2, 3); pPlotGrid->setColumnMinimumWidth(3, mpYMouseLabel->sizeHint().width()); pPlotGrid->addWidget(mpXAxis, 3, 1); pPlotGrid->setRowStretch(2, 10); pPlotGrid->setColumnStretch(1, 10); } QVBoxLayout* pPlotLayout = new QVBoxLayout(mpPlotWidget); pPlotLayout->setMargin(10); pPlotLayout->setSpacing(5); pPlotLayout->addLayout(pTopLabelLayout); pPlotLayout->addWidget(mpTitleLabel); pPlotLayout->addWidget(mpSplitter, 10); pPlotLayout->addLayout(pBottomLabelLayout); // Initialization setWindowFlags(Qt::Widget); setBackgroundColor(Qt::white); mpPlotWidget->setAutoFillBackground(true); setCentralWidget(mpPlotWidget); setContextMenuPolicy(Qt::DefaultContextMenu); setFocusPolicy(Qt::StrongFocus); setFocusProxy(mpPlot); addToolBar(mpAnnotationToolBar); addToolBar(mpMouseModeToolBar); AnnotationLayer* pAnnotationLayer = mpPlot->getAnnotationLayer(); if (pAnnotationLayer != NULL) { mpAnnotationToolBar->setAnnotationLayer(pAnnotationLayer); } const MouseMode* pCurrentMouseMode = mpPlot->getCurrentMouseMode(); enableAnnotationToolBar(pCurrentMouseMode); vector<const MouseMode*> mouseModes = mpPlot->getMouseModes(); for (vector<const MouseMode*>::const_iterator iter = mouseModes.begin(); iter != mouseModes.end(); ++iter) { const MouseMode* pMouseMode = *iter; if (pMouseMode != NULL) { QAction* pAction = pMouseMode->getAction(); if (pAction != NULL) { mpMouseModeToolBar->addAction(pAction); } } } mpToolbarsMenu->addAction(mpAnnotationToolBar->toggleViewAction()); mpToolbarsMenu->addAction(mpMouseModeToolBar->toggleViewAction()); updateClassificationText(); list<PlotObject*> plotObjects = mpPlot->getObjects(); for (list<PlotObject*>::iterator iter = plotObjects.begin(); iter != plotObjects.end(); ++iter) { PlotObject* pObject = *iter; if (pObject != NULL) { mpLegend->insertItem(pObject); } } showLegend(false); // Connections VERIFYNR(connect(mpPlot, SIGNAL(renamed(const QString&)), this, SLOT(updateName(const QString&)))); VERIFYNR(connect(mpPlot, SIGNAL(mouseModeChanged(const MouseMode*)), this, SLOT(enableAnnotationToolBar(const MouseMode*)))); VERIFYNR(connect(mpPlot, SIGNAL(classificationChanged(const Classification*)), this, SLOT(updateClassificationText()))); VERIFYNR(connect(mpPlot, SIGNAL(classificationFontChanged(const QFont&)), this, SLOT(setClassificationFont(const QFont&)))); VERIFYNR(connect(mpPlot, SIGNAL(classificationColorChanged(const QColor&)), this, SLOT(setClassificationColor(const QColor&)))); VERIFYNR(connect(mpPlot, SIGNAL(objectAdded(PlotObject*)), mpLegend, SLOT(insertItem(PlotObject*)))); VERIFYNR(connect(mpPlot, SIGNAL(objectDeleted(PlotObject*)), mpLegend, SLOT(removeItem(PlotObject*)))); VERIFYNR(connect(mpPlot, SIGNAL(objectSelected(PlotObject*, bool)), mpLegend, SLOT(setItemSelected(PlotObject*, bool)))); VERIFYNR(connect(mpLegend, SIGNAL(itemSelected(PlotObject*, bool)), this, SLOT(selectPlotObject(PlotObject*, bool)))); if (pCartesianPlot != NULL) { VERIFYNR(connect(mpPlot, SIGNAL(displayAreaChanged()), this, SLOT(updateScaleRange()))); VERIFYNR(connect(mpPlot, SIGNAL(xScaleTypeChanged(ScaleType)), mpXAxis, SLOT(setScaleType(ScaleType)))); VERIFYNR(connect(mpPlot, SIGNAL(yScaleTypeChanged(ScaleType)), mpYAxis, SLOT(setScaleType(ScaleType)))); VERIFYNR(connect(mpPlot, SIGNAL(xDataTypeChanged(const QString&)), mpXAxis, SLOT(setTitle(const QString&)))); VERIFYNR(connect(mpPlot, SIGNAL(yDataTypeChanged(const QString&)), mpYAxis, SLOT(setTitle(const QString&)))); GridlinesImp* pGridlines = dynamic_cast<GridlinesImp*>(pCartesianPlot->getGridlines(HORIZONTAL)); if (pGridlines != NULL) { VERIFYNR(connect(pGridlines, SIGNAL(maxNumMajorLinesChanged(int)), mpYAxis, SLOT(setMaxNumMajorTicks(int)))); VERIFYNR(connect(pGridlines, SIGNAL(maxNumMinorLinesChanged(int)), mpYAxis, SLOT(setMaxNumMinorTicks(int)))); VERIFYNR(connect(mpYAxis, SIGNAL(maxNumMajorTicksChanged(int)), pGridlines, SLOT(setMaxNumMajorLines(int)))); VERIFYNR(connect(mpYAxis, SIGNAL(maxNumMinorTicksChanged(int)), pGridlines, SLOT(setMaxNumMinorLines(int)))); } pGridlines = dynamic_cast<GridlinesImp*>(pCartesianPlot->getGridlines(VERTICAL)); if (pGridlines != NULL) { VERIFYNR(connect(pGridlines, SIGNAL(maxNumMajorLinesChanged(int)), mpXAxis, SLOT(setMaxNumMajorTicks(int)))); VERIFYNR(connect(pGridlines, SIGNAL(maxNumMinorLinesChanged(int)), mpXAxis, SLOT(setMaxNumMinorTicks(int)))); VERIFYNR(connect(mpXAxis, SIGNAL(maxNumMajorTicksChanged(int)), pGridlines, SLOT(setMaxNumMajorLines(int)))); VERIFYNR(connect(mpXAxis, SIGNAL(maxNumMinorTicksChanged(int)), pGridlines, SLOT(setMaxNumMinorLines(int)))); } } LocatorImp* pLocator = dynamic_cast<LocatorImp*>(mpPlot->getMouseLocator()); if (pLocator != NULL) { VERIFYNR(connect(pLocator, SIGNAL(textChanged(const QString&, const QString&)), this, SLOT(updateMouseLabel(const QString&, const QString&)))); }
DayScreen::DayScreen(QWidget *parent) : QFrame(parent) { formalBellEffect.setSource(QUrl("qrc:/sounds/FormalTimerBell.wav")); formalBellEffect.setVolume(0.80f); dayBellEffect.setSource(QUrl("qrc:/sounds/DayTimerBell.wav")); dayBellEffect.setVolume(0.80f); // Label showing day number with button to restart (send to character screen) in same row dayLabel = new QLabel; restartButton = new QPushButton("Restart"); restartButton->setFocusPolicy(Qt::NoFocus); // Sends user to info screen infoButton = new InfoButton; QHBoxLayout *dayLayout = new QHBoxLayout; dayLayout->addWidget(dayLabel); dayLayout->addStretch(); dayLayout->addWidget(restartButton); dayLayout->addWidget(infoButton); // Labels displaying day timer dayTimerButton = new QPushButton("Timer"); dayTimerButton->setCheckable(true); dayTimerButton->setFocusPolicy(Qt::NoFocus); dayTimerLabel = new QLabel; dayTimerLabel->setObjectName("dayTimerLabel"); dayTimer = new QTimer(this); /* QHBoxLayout *dayTimerLayout = new QHBoxLayout; dayTimerLayout->addWidget(dayTimerButton); dayTimerLayout->addStretch(); dayTimerLayout->addWidget(dayTimerLabel); dayTimerLayout->addStretch(); */ // Button which when pushed, starts the formal timer formalTimerButton = new QPushButton("Formal"); formalTimerButton->setCheckable(true); formalTimerButton->setFocusPolicy(Qt::NoFocus); formalTimerLabel = new QLabel; formalTimerLabel->setObjectName("formalTimerLabel"); formalTimer = new QTimer(this); resetTimers(); /* QHBoxLayout *formalTimerLayout = new QHBoxLayout; formalTimerLayout->addWidget(formalTimerButton); formalTimerLayout->addStretch(); formalTimerLayout->addWidget(formalTimerLabel); formalTimerLayout->addStretch(); */ QGridLayout *timersLayout = new QGridLayout; timersLayout->addWidget(dayTimerButton, 0, 0); timersLayout->addWidget(dayTimerLabel, 0, 2); timersLayout->addWidget(formalTimerButton, 2, 0); timersLayout->addWidget(formalTimerLabel, 2, 2); //timersLayout->setContentsMargins(30, 30, 30, 30); timersLayout->setColumnMinimumWidth(1, 40); timersLayout->setRowMinimumHeight(1, 40); // Buttons for navigating to the morning phase, or start a new night phase prevButton = new QPushButton("Previous"); prevButton->setFocusPolicy(Qt::NoFocus); nightButton = new QPushButton("Night"); nightButton->setFocusPolicy(Qt::NoFocus); QHBoxLayout *navigBtnLayout = new QHBoxLayout; navigBtnLayout->addWidget(prevButton); navigBtnLayout->addStretch(); navigBtnLayout->addWidget(nightButton); QVBoxLayout *dayScreenLayout = new QVBoxLayout; dayScreenLayout->addLayout(dayLayout); dayScreenLayout->addStretch(); dayScreenLayout->addLayout(timersLayout); //dayScreenLayout->addLayout(dayTimerLayout); //dayScreenLayout->addLayout(formalTimerLayout); dayScreenLayout->addStretch(); dayScreenLayout->addLayout(navigBtnLayout); setLayout(dayScreenLayout); connect(dayTimer, &QTimer::timeout, this, &DayScreen::updateDayTimer); connect(dayTimerButton, &QPushButton::clicked, this, &DayScreen::startDayTimer); connect(formalTimer, &QTimer::timeout, this, &DayScreen::updateFormalTimer); connect(formalTimerButton, &QPushButton::clicked, this, &DayScreen::startFormalTimer); }
SubSurfaceInspectorView::SubSurfaceInspectorView(bool isIP, const openstudio::model::Model& model, QWidget * parent ) : ModelObjectInspectorView(model, true, parent) { m_isIP = isIP; QWidget* hiddenWidget = new QWidget(); this->stackedWidget()->insertWidget(0, hiddenWidget); QWidget* visibleWidget = new QWidget(); this->stackedWidget()->insertWidget(1, visibleWidget); this->stackedWidget()->setCurrentIndex(0); QGridLayout* mainGridLayout = new QGridLayout(); mainGridLayout->setContentsMargins(7,7,7,7); mainGridLayout->setSpacing(14); visibleWidget->setLayout(mainGridLayout); // name QVBoxLayout* vLayout = new QVBoxLayout(); QLabel* label = new QLabel(); label->setText("Name: "); label->setStyleSheet("QLabel { font: bold; }"); vLayout->addWidget(label); m_nameEdit = new OSLineEdit(); vLayout->addWidget(m_nameEdit); mainGridLayout->addLayout(vLayout,0,0,1,2, Qt::AlignTop|Qt::AlignLeft); // subsurface type vLayout = new QVBoxLayout(); label = new QLabel(); label->setText("Sub Surface Type: "); label->setStyleSheet("QLabel { font: bold; }"); vLayout->addWidget(label); m_subSurfaceType = new OSComboBox(); vLayout->addWidget(m_subSurfaceType); vLayout->addStretch(); mainGridLayout->addLayout(vLayout,1,0); // construction vLayout = new QVBoxLayout(); label = new QLabel(); label->setText("Construction: "); label->setStyleSheet("QLabel { font: bold; }"); vLayout->addWidget(label); m_constructionVectorController = new SubSurfaceConstructionVectorController(); m_constructionDropZone = new OSDropZone(m_constructionVectorController); m_constructionDropZone->setMinItems(0); m_constructionDropZone->setMaxItems(1); m_constructionDropZone->setItemsAcceptDrops(true); vLayout->addWidget(m_constructionDropZone); vLayout->addStretch(); mainGridLayout->addLayout(vLayout,1,1); // outside boundary condition object vLayout = new QVBoxLayout(); label = new QLabel(); label->setText("Outside Boundary Condition Object: "); label->setStyleSheet("QLabel { font: bold; }"); vLayout->addWidget(label); m_outsideBoundaryConditionObjectVectorController = new SubSurfaceOutsideBoundaryConditionObjectVectorController(); m_outsideBoundaryConditionObjectDropZone = new OSDropZone(m_outsideBoundaryConditionObjectVectorController); m_outsideBoundaryConditionObjectDropZone->setMinItems(0); m_outsideBoundaryConditionObjectDropZone->setMaxItems(1); m_outsideBoundaryConditionObjectDropZone->setItemsAcceptDrops(true); vLayout->addWidget(m_outsideBoundaryConditionObjectDropZone); vLayout->addStretch(); mainGridLayout->addLayout(vLayout,2,0); // multiplier vLayout = new QVBoxLayout(); label = new QLabel(); label->setText("Multiplier: "); label->setStyleSheet("QLabel { font: bold; }"); vLayout->addWidget(label); m_multiplier = new OSDoubleEdit(); vLayout->addWidget(m_multiplier); vLayout->addStretch(); mainGridLayout->addLayout(vLayout,3,0); // separator vLayout = new QVBoxLayout(); QWidget * hLine = new QWidget(); hLine->setObjectName("HLine"); hLine->setStyleSheet("QWidget#HLine { background: #445051;}"); hLine->setFixedHeight(2); vLayout->addWidget(hLine); label = new QLabel(); label->setText("Vertices: "); label->setStyleSheet("QLabel { font: bold; }"); vLayout->addWidget(label); mainGridLayout->addWidget(hLine,4,0,1,2); // planar surface widget m_planarSurfaceWidget = new PlanarSurfaceWidget(m_isIP); bool isConnected = connect(this, SIGNAL(toggleUnitsClicked(bool)), m_planarSurfaceWidget, SLOT(toggleUnits(bool))); OS_ASSERT(isConnected); mainGridLayout->addWidget(m_planarSurfaceWidget,5,0,1,2); mainGridLayout->setColumnMinimumWidth(0, 80); mainGridLayout->setColumnMinimumWidth(1, 80); mainGridLayout->setColumnStretch(2,1); mainGridLayout->setRowMinimumHeight(0, 30); mainGridLayout->setRowMinimumHeight(1, 30); mainGridLayout->setRowMinimumHeight(2, 30); mainGridLayout->setRowMinimumHeight(3, 30); mainGridLayout->setRowMinimumHeight(4, 30); mainGridLayout->setRowMinimumHeight(5, 30); mainGridLayout->setRowStretch(6,1); }
PeopleDefinitionInspectorView::PeopleDefinitionInspectorView(bool isIP, const openstudio::model::Model& model, QWidget * parent) : ModelObjectInspectorView(model, true, parent) { m_isIP = isIP; //QWidget* hiddenWidget = new QWidget(); //this->stackedWidget()->insertWidget(0, hiddenWidget); QWidget* visibleWidget = new QWidget(); this->stackedWidget()->addWidget(visibleWidget); //this->stackedWidget()->setCurrentIndex(0); QGridLayout* mainGridLayout = new QGridLayout(); mainGridLayout->setContentsMargins(7,7,7,7); mainGridLayout->setSpacing(14); visibleWidget->setLayout(mainGridLayout); // name QVBoxLayout* vLayout = new QVBoxLayout(); QLabel* label = new QLabel("Name: "); label->setObjectName("H2"); vLayout->addWidget(label); m_nameEdit = new OSLineEdit2(); vLayout->addWidget(m_nameEdit); mainGridLayout->addLayout(vLayout,0,0,1,3, Qt::AlignTop); // number of people, people per area, and area per person vLayout = new QVBoxLayout(); label = new QLabel("Number of People: "); label->setObjectName("H2"); vLayout->addWidget(label); bool isConnected = false; m_numberofPeopleEdit = new OSDoubleEdit2(); vLayout->addWidget(m_numberofPeopleEdit); mainGridLayout->addLayout(vLayout,1,0, Qt::AlignTop|Qt::AlignLeft); vLayout = new QVBoxLayout(); label = new QLabel("People per Space Floor Area: "); label->setObjectName("H2"); vLayout->addWidget(label); m_peopleperSpaceFloorAreaEdit = new OSQuantityEdit2("people/m^2", "people/m^2", "people/ft^2", m_isIP); isConnected = connect(this, SIGNAL(toggleUnitsClicked(bool)), m_peopleperSpaceFloorAreaEdit, SLOT(onUnitSystemChange(bool))); OS_ASSERT(isConnected); vLayout->addWidget(m_peopleperSpaceFloorAreaEdit); mainGridLayout->addLayout(vLayout,1,1, Qt::AlignTop|Qt::AlignLeft); vLayout = new QVBoxLayout(); label = new QLabel("Space Floor Area per Person: "); label->setObjectName("H2"); vLayout->addWidget(label); m_spaceFloorAreaperPersonEdit = new OSQuantityEdit2("m^2/person", "m^2/person", "ft^2/person", m_isIP); isConnected = connect(this, SIGNAL(toggleUnitsClicked(bool)), m_spaceFloorAreaperPersonEdit, SLOT(onUnitSystemChange(bool))); OS_ASSERT(isConnected); vLayout->addWidget(m_spaceFloorAreaperPersonEdit); mainGridLayout->addLayout(vLayout,1,2, Qt::AlignTop|Qt::AlignLeft); // fraction radiance, sensible heat fraction, carbon dioxide rate vLayout = new QVBoxLayout(); label = new QLabel("Fraction Radiant: "); label->setObjectName("H2"); vLayout->addWidget(label); m_fractionRadiantEdit = new OSDoubleEdit2(); vLayout->addWidget(m_fractionRadiantEdit); mainGridLayout->addLayout(vLayout,2,0, Qt::AlignTop|Qt::AlignLeft); vLayout = new QVBoxLayout(); label = new QLabel("Sensible Heat Fraction Radiant: "); label->setObjectName("H2"); vLayout->addWidget(label); m_sensibleHeatFractionEdit = new OSDoubleEdit2(); vLayout->addWidget(m_sensibleHeatFractionEdit); mainGridLayout->addLayout(vLayout,2,1, Qt::AlignTop|Qt::AlignLeft); vLayout = new QVBoxLayout(); label = new QLabel("Carbon Dioxide Generation Rate: "); label->setObjectName("H2"); vLayout->addWidget(label); m_carbonDioxideGenerationRateEdit = new OSQuantityEdit2("m^3/s*W", "L/s*W", "ft^3*hr/min*Btu", m_isIP); isConnected = connect(this, SIGNAL(toggleUnitsClicked(bool)), m_carbonDioxideGenerationRateEdit, SLOT(onUnitSystemChange(bool))); OS_ASSERT(isConnected); vLayout->addWidget(m_carbonDioxideGenerationRateEdit); mainGridLayout->addLayout(vLayout,2,2, Qt::AlignTop|Qt::AlignLeft); mainGridLayout->setColumnMinimumWidth(0, 80); mainGridLayout->setColumnMinimumWidth(1, 80); mainGridLayout->setColumnMinimumWidth(2, 80); mainGridLayout->setColumnStretch(3,1); mainGridLayout->setRowMinimumHeight(0, 30); mainGridLayout->setRowMinimumHeight(1, 30); mainGridLayout->setRowMinimumHeight(2, 30); mainGridLayout->setRowStretch(3,1); }
int main(int argc, char **argv) { QApplication app(argc, argv); // Initializing the graph and its container Q3DScatter *graph = new Q3DScatter(); QWidget *container = QWidget::createWindowContainer(graph); //! [0] QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2.25, screenSize.height() / 4)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); //! [1] QWidget *widget = new QWidget; QGroupBox *menuLayout = new QGroupBox; QGroupBox *optionLayout = new QGroupBox; QVBoxLayout *vLayout = new QVBoxLayout(widget); vLayout->addWidget(menuLayout); vLayout->addWidget(container, 1); vLayout->addWidget(optionLayout); //! [1] widget->setWindowTitle(QStringLiteral("CRN Dava Visualization")); //! [4] /* QComboBox *themeList = new QComboBox(widget); themeList->addItem(QStringLiteral("Qt")); themeList->addItem(QStringLiteral("Primary Colors")); themeList->addItem(QStringLiteral("Digia")); themeList->addItem(QStringLiteral("Stone Moss")); themeList->addItem(QStringLiteral("Army Blue")); themeList->addItem(QStringLiteral("Retro")); themeList->addItem(QStringLiteral("Ebony")); themeList->addItem(QStringLiteral("Isabelle")); themeList->setCurrentIndex(6); QPushButton *labelButton = new QPushButton(widget); labelButton->setText(QStringLiteral("Change label style")); */ int logoHeight = 100, logoWidth = 300; int buttonSize = 100; QGridLayout *gridMenu = new QGridLayout(); QPushButton *taLogoLabel = new QPushButton(); QPushButton *configLabel = new QPushButton(); QPushButton *saveLabel = new QPushButton(); QPushButton *openLabel = new QPushButton(); QPushButton *globeLabel = new QPushButton(); QPixmap taLogoPix("/home/adityarputra/Pictures/placeholder.png"); QIcon taLogoIcon(taLogoPix); QPixmap configPix("/home/adityarputra/Pictures/placeholder.png"); QIcon configIcon(configPix); QPixmap savePix("/home/adityarputra/Pictures/placeholder.png"); QIcon saveIcon(savePix); QPixmap openPix("/home/adityarputra/Pictures/placeholder.png"); QIcon openIcon(openPix); QPixmap globePix("/home/adityarputra/Pictures/placeholder.png"); QIcon globeIcon(globePix); taLogoLabel->setIcon(taLogoIcon); taLogoLabel->setMaximumSize(logoWidth,logoHeight); //taLogoLabel->setText("TA logo label"); configLabel->setIcon(configIcon); configLabel->setMaximumSize(buttonSize,buttonSize); //configLabel->setText("Config Icon"); saveLabel->setIcon(saveIcon); saveLabel->setMaximumSize(buttonSize,buttonSize); //saveLabel->setText("Save Icon"); openLabel->setIcon(openIcon); openLabel->setMaximumSize(buttonSize,buttonSize); //openLabel->setText("Open Icon"); globeLabel->setIcon(globeIcon); globeLabel->setMaximumSize(buttonSize,buttonSize); //globeLabel->setText("Globe Icon"); gridMenu->addWidget(taLogoLabel,0,0); gridMenu->addWidget(configLabel,0,2); gridMenu->addWidget(saveLabel,0,3); gridMenu->addWidget(openLabel,0,4); gridMenu->addWidget(globeLabel,0,5); gridMenu->setColumnStretch(0,300); gridMenu->setRowMinimumHeight(0,100); gridMenu->setColumnStretch(1,100); gridMenu->setColumnStretch(2,100); gridMenu->setColumnStretch(3,100); gridMenu->setColumnStretch(4,100); gridMenu->setColumnStretch(5,100); menuLayout->setLayout(gridMenu); //-----------------------------------// QGridLayout *gridOption = new QGridLayout(); QComboBox *gasTypeCombo = new QComboBox(); QPushButton *rewindButton = new QPushButton(); QPushButton *prevButton = new QPushButton(); QPushButton *startButton = new QPushButton(); QPushButton *nextButton = new QPushButton(); QPushButton *forwardButton = new QPushButton(); QTableWidget *sensorDataTable = new QTableWidget(); QPlainTextEdit *console = new QPlainTextEdit(); sensorDataTable->setRowCount(60); sensorDataTable->setColumnCount(9); QPixmap buttonPix("/home/adityarputra/Pictures/placeholder.png"); QIcon buttonIcon(buttonPix); rewindButton->setIcon(buttonIcon); rewindButton->setMaximumWidth(50); prevButton->setIcon(buttonIcon); prevButton->setMaximumWidth(50); startButton->setIcon(buttonIcon); startButton->setMaximumWidth(50); nextButton->setIcon(buttonIcon); nextButton->setMaximumWidth(50); forwardButton->setIcon(buttonIcon); forwardButton->setMaximumWidth(50); gridOption->addWidget(sensorDataTable,0,6,3,1); gridOption->addWidget(gasTypeCombo,0,0,1,5); gridOption->addWidget(rewindButton,1,0); gridOption->addWidget(prevButton,1,1); gridOption->addWidget(startButton,1,2); gridOption->addWidget(nextButton,1,3); gridOption->addWidget(forwardButton,1,4); gridOption->addWidget(console,2,0,1,5); gridOption->setColumnStretch(0,50); gridOption->setColumnStretch(1,50); gridOption->setColumnStretch(2,50); gridOption->setColumnStretch(3,50); gridOption->setColumnStretch(4,50); gridOption->setColumnStretch(5,50); gridOption->setColumnStretch(6,400); optionLayout->setLayout(gridOption); //----------------------------------To be deleted--------------------------------- /*QCheckBox *smoothCheckBox = new QCheckBox(widget); smoothCheckBox->setText(QStringLiteral("Smooth dots")); smoothCheckBox->setChecked(true); QComboBox *itemStyleList = new QComboBox(widget); itemStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere)); itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube)); itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal)); itemStyleList->addItem(QStringLiteral("Point"), int(QAbstract3DSeries::MeshPoint)); itemStyleList->setCurrentIndex(0); QPushButton *cameraButton = new QPushButton(widget); cameraButton->setText(QStringLiteral("Change camera preset")); QPushButton *itemCountButton = new QPushButton(widget); itemCountButton->setText(QStringLiteral("Toggle item count")); QCheckBox *backgroundCheckBox = new QCheckBox(widget); backgroundCheckBox->setText(QStringLiteral("Show background")); backgroundCheckBox->setChecked(true); QCheckBox *gridCheckBox = new QCheckBox(widget); gridCheckBox->setText(QStringLiteral("Show grid")); gridCheckBox->setChecked(true); QComboBox *shadowQuality = new QComboBox(widget); shadowQuality->addItem(QStringLiteral("None")); shadowQuality->addItem(QStringLiteral("Low")); shadowQuality->addItem(QStringLiteral("Medium")); shadowQuality->addItem(QStringLiteral("High")); shadowQuality->addItem(QStringLiteral("Low Soft")); shadowQuality->addItem(QStringLiteral("Medium Soft")); shadowQuality->addItem(QStringLiteral("High Soft")); shadowQuality->setCurrentIndex(4); QFontComboBox *fontList = new QFontComboBox(widget); fontList->setCurrentFont(QFont("Arial"));*/ //---------------------------------------------------------------- // Adding widget to respective layout /* vLayout->addWidget(labelButton, 0, Qt::AlignTop); vLayout->addWidget(cameraButton, 0, Qt::AlignTop); vLayout->addWidget(itemCountButton, 0, Qt::AlignTop); vLayout->addWidget(backgroundCheckBox); vLayout->addWidget(gridCheckBox); vLayout->addWidget(smoothCheckBox, 0, Qt::AlignTop); vLayout->addWidget(new QLabel(QStringLiteral("Change dot style"))); vLayout->addWidget(itemStyleList); vLayout->addWidget(new QLabel(QStringLiteral("Change theme"))); vLayout->addWidget(themeList); vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality"))); vLayout->addWidget(shadowQuality); vLayout->addWidget(new QLabel(QStringLiteral("Change font"))); vLayout->addWidget(fontList, 1, Qt::AlignTop); */ //! [5] //! [2] ScatterDataModifier *modifier = new ScatterDataModifier(graph); //! [2] connect(configLabel,SIGNAL(clicked(bool)),this, /* QObject::connect(cameraButton, &QPushButton::clicked, modifier, &ScatterDataModifier::changePresetCamera); QObject::connect(labelButton, &QPushButton::clicked, modifier, &ScatterDataModifier::changeLabelStyle); QObject::connect(itemCountButton, &QPushButton::clicked, modifier, &ScatterDataModifier::toggleItemCount); QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier, &ScatterDataModifier::setBackgroundEnabled); QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier, &ScatterDataModifier::setGridEnabled); QObject::connect(smoothCheckBox, &QCheckBox::stateChanged, modifier, &ScatterDataModifier::setSmoothDots); QObject::connect(modifier, &ScatterDataModifier::backgroundEnabledChanged, backgroundCheckBox, &QCheckBox::setChecked); QObject::connect(modifier, &ScatterDataModifier::gridEnabledChanged, gridCheckBox, &QCheckBox::setChecked); QObject::connect(itemStyleList, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeStyle(int))); QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeTheme(int))); QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeShadowQuality(int))); QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality, &QComboBox::setCurrentIndex); QObject::connect(graph, &Q3DScatter::shadowQualityChanged, modifier, &ScatterDataModifier::shadowQualityUpdatedByVisual); QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier, &ScatterDataModifier::changeFont); QObject::connect(modifier, &ScatterDataModifier::fontChanged, fontList, &QFontComboBox::setCurrentFont); */ //! [6] //! [3] widget->show(); return app.exec(); //! [3] }
//! [1] Window::Window() { renderArea = new RenderArea; shapeComboBox = new QComboBox; shapeComboBox->addItem(tr("Polygon"), RenderArea::Polygon); shapeComboBox->addItem(tr("Rectangle"), RenderArea::Rect); shapeComboBox->addItem(tr("Rounded Rectangle"), RenderArea::RoundedRect); shapeComboBox->addItem(tr("Ellipse"), RenderArea::Ellipse); shapeComboBox->addItem(tr("Pie"), RenderArea::Pie); shapeComboBox->addItem(tr("Chord"), RenderArea::Chord); shapeComboBox->addItem(tr("Path"), RenderArea::Path); shapeComboBox->addItem(tr("Line"), RenderArea::Line); shapeComboBox->addItem(tr("Polyline"), RenderArea::Polyline); shapeComboBox->addItem(tr("Arc"), RenderArea::Arc); shapeComboBox->addItem(tr("Points"), RenderArea::Points); shapeComboBox->addItem(tr("Text"), RenderArea::Text); shapeComboBox->addItem(tr("Pixmap"), RenderArea::Pixmap); shapeLabel = new QLabel(tr("&Shape:")); shapeLabel->setBuddy(shapeComboBox); //! [1] //! [2] penWidthSpinBox = new QSpinBox; penWidthSpinBox->setRange(0, 20); penWidthSpinBox->setSpecialValueText(tr("0 (cosmetic pen)")); penWidthLabel = new QLabel(tr("Pen &Width:")); penWidthLabel->setBuddy(penWidthSpinBox); //! [2] //! [3] penStyleComboBox = new QComboBox; penStyleComboBox->addItem(tr("Solid"), Qt::SolidLine); penStyleComboBox->addItem(tr("Dash"), Qt::DashLine); penStyleComboBox->addItem(tr("Dot"), Qt::DotLine); penStyleComboBox->addItem(tr("Dash Dot"), Qt::DashDotLine); penStyleComboBox->addItem(tr("Dash Dot Dot"), Qt::DashDotDotLine); penStyleComboBox->addItem(tr("None"), Qt::NoPen); penStyleLabel = new QLabel(tr("&Pen Style:")); penStyleLabel->setBuddy(penStyleComboBox); penCapComboBox = new QComboBox; penCapComboBox->addItem(tr("Flat"), Qt::FlatCap); penCapComboBox->addItem(tr("Square"), Qt::SquareCap); penCapComboBox->addItem(tr("Round"), Qt::RoundCap); penCapLabel = new QLabel(tr("Pen &Cap:")); penCapLabel->setBuddy(penCapComboBox); penJoinComboBox = new QComboBox; penJoinComboBox->addItem(tr("Miter"), Qt::MiterJoin); penJoinComboBox->addItem(tr("Bevel"), Qt::BevelJoin); penJoinComboBox->addItem(tr("Round"), Qt::RoundJoin); penJoinLabel = new QLabel(tr("Pen &Join:")); penJoinLabel->setBuddy(penJoinComboBox); //! [3] //! [4] brushStyleComboBox = new QComboBox; brushStyleComboBox->addItem(tr("Linear Gradient"), Qt::LinearGradientPattern); brushStyleComboBox->addItem(tr("Radial Gradient"), Qt::RadialGradientPattern); brushStyleComboBox->addItem(tr("Conical Gradient"), Qt::ConicalGradientPattern); brushStyleComboBox->addItem(tr("Texture"), Qt::TexturePattern); brushStyleComboBox->addItem(tr("Solid"), Qt::SolidPattern); brushStyleComboBox->addItem(tr("Horizontal"), Qt::HorPattern); brushStyleComboBox->addItem(tr("Vertical"), Qt::VerPattern); brushStyleComboBox->addItem(tr("Cross"), Qt::CrossPattern); brushStyleComboBox->addItem(tr("Backward Diagonal"), Qt::BDiagPattern); brushStyleComboBox->addItem(tr("Forward Diagonal"), Qt::FDiagPattern); brushStyleComboBox->addItem(tr("Diagonal Cross"), Qt::DiagCrossPattern); brushStyleComboBox->addItem(tr("Dense 1"), Qt::Dense1Pattern); brushStyleComboBox->addItem(tr("Dense 2"), Qt::Dense2Pattern); brushStyleComboBox->addItem(tr("Dense 3"), Qt::Dense3Pattern); brushStyleComboBox->addItem(tr("Dense 4"), Qt::Dense4Pattern); brushStyleComboBox->addItem(tr("Dense 5"), Qt::Dense5Pattern); brushStyleComboBox->addItem(tr("Dense 6"), Qt::Dense6Pattern); brushStyleComboBox->addItem(tr("Dense 7"), Qt::Dense7Pattern); brushStyleComboBox->addItem(tr("None"), Qt::NoBrush); brushStyleLabel = new QLabel(tr("&Brush Style:")); brushStyleLabel->setBuddy(brushStyleComboBox); //! [4] //! [5] otherOptionsLabel = new QLabel(tr("Other Options:")); //! [5] //! [6] antialiasingCheckBox = new QCheckBox(tr("&Antialiasing")); //! [6] //! [7] transformationsCheckBox = new QCheckBox(tr("&Transformations")); //! [7] //! [8] connect(shapeComboBox, SIGNAL(activated(int)), this, SLOT(shapeChanged())); connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(penChanged())); connect(penStyleComboBox, SIGNAL(activated(int)), this, SLOT(penChanged())); connect(penCapComboBox, SIGNAL(activated(int)), this, SLOT(penChanged())); connect(penJoinComboBox, SIGNAL(activated(int)), this, SLOT(penChanged())); connect(brushStyleComboBox, SIGNAL(activated(int)), this, SLOT(brushChanged())); connect(antialiasingCheckBox, SIGNAL(toggled(bool)), renderArea, SLOT(setAntialiased(bool))); connect(transformationsCheckBox, SIGNAL(toggled(bool)), renderArea, SLOT(setTransformed(bool))); //! [8] //! [9] QGridLayout *mainLayout = new QGridLayout; //! [9] //! [10] mainLayout->setColumnStretch(0, 1); mainLayout->setColumnStretch(3, 1); mainLayout->addWidget(renderArea, 0, 0, 1, 4); mainLayout->setRowMinimumHeight(1, 6); mainLayout->addWidget(shapeLabel, 2, 1, Qt::AlignRight); mainLayout->addWidget(shapeComboBox, 2, 2); mainLayout->addWidget(penWidthLabel, 3, 1, Qt::AlignRight); mainLayout->addWidget(penWidthSpinBox, 3, 2); mainLayout->addWidget(penStyleLabel, 4, 1, Qt::AlignRight); mainLayout->addWidget(penStyleComboBox, 4, 2); mainLayout->addWidget(penCapLabel, 5, 1, Qt::AlignRight); mainLayout->addWidget(penCapComboBox, 5, 2); mainLayout->addWidget(penJoinLabel, 6, 1, Qt::AlignRight); mainLayout->addWidget(penJoinComboBox, 6, 2); mainLayout->addWidget(brushStyleLabel, 7, 1, Qt::AlignRight); mainLayout->addWidget(brushStyleComboBox, 7, 2); mainLayout->setRowMinimumHeight(8, 6); mainLayout->addWidget(otherOptionsLabel, 9, 1, Qt::AlignRight); mainLayout->addWidget(antialiasingCheckBox, 9, 2); mainLayout->addWidget(transformationsCheckBox, 10, 2); setLayout(mainLayout); shapeChanged(); penChanged(); brushChanged(); antialiasingCheckBox->setChecked(true); setWindowTitle(tr("Basic Drawing")); }
ThresholdDialog::ThresholdDialog(const GrayscaleImage* image, bool converted) : _image(image){ this->setWindowTitle(tr("ThresholdOp")); this->setMinimumWidth(160); QGridLayout * layout = new QGridLayout(); this->setLayout(layout); QVBoxLayout* Vboxlayout = new QVBoxLayout(); if(converted) { Vboxlayout->addWidget(new QLabel(tr("<font color=red><i>Information : The input image has been converted to grayscale.</i></font>"))); } QGroupBox* threshGroup = new QGroupBox(tr("Threshold"), this); QHBoxLayout* threshLayout = new QHBoxLayout(threshGroup); _doubleBox = new QCheckBox(tr("Double threshold (right clic to move the second threshold)")); threshLayout->addWidget(_doubleBox); Vboxlayout->addWidget(threshGroup); QHBoxLayout* box1layout = new QHBoxLayout(); _spin1label = new QLabel(tr("Threshold : ")); _spinbox1 = new QSpinBox(); _spinbox1->setRange(0, 255); _spinbox1->setValue(127); QPushButton* otsuButton = new QPushButton(tr("Otsu")); box1layout->addWidget(_spin1label); box1layout->addWidget(_spinbox1); box1layout->addWidget(otsuButton); Vboxlayout->addLayout(box1layout); QHBoxLayout* box2layout = new QHBoxLayout(); QLabel* spin2label = new QLabel(tr("Threshold #2 : ")); spin2label->setVisible(false); _spinbox2 = new QSpinBox(); _spinbox2->setRange(0, 255); _spinbox2->setValue(255); _spinbox2->setVisible(false); box2layout->addWidget(spin2label); box2layout->addWidget(_spinbox2); Vboxlayout->addLayout(box2layout); QHBoxLayout* radiolayout = new QHBoxLayout(); QLabel* radioLabel = new QLabel(tr("Color between thresholds :")); QRadioButton* whiteButton = new QRadioButton(tr("White")); _blackButton = new QRadioButton(tr("Black")); radiolayout->addWidget(radioLabel); radiolayout->addWidget(whiteButton); radiolayout->addWidget(_blackButton); whiteButton->setChecked(true); Vboxlayout->addLayout(radiolayout); radioLabel->setVisible(false); whiteButton->setVisible(false); _blackButton->setVisible(false); Rectangle rect(0, 0, image->getWidth(), image->getHeight()); GenericHistogramView* histo = new GenericHistogramView(image, rect); QwtPlot* plot = histo->getGraphicalHistogram(); _marker1 = new QwtPlotMarker(); _marker1->setLineStyle(QwtPlotMarker::VLine); _marker1->setLinePen(QPen(Qt::black)); _marker1->setXValue(127); _marker1->attach(plot); _marker2 = new QwtPlotMarker(); _marker2->setLineStyle(QwtPlotMarker::VLine); _marker2->setLinePen(QPen(Qt::black)); _marker2->setXValue(255); _marker2->attach(plot); _marker2->hide(); _preview = new ImageWidget(this, _image); _preview->setFixedSize(256*_preview->pixmap().width()/_preview->pixmap().height(), 256); layout->setColumnMinimumWidth(0,256*_preview->pixmap().width()/_preview->pixmap().height()); layout->addWidget(_preview,0,0,0,0,Qt::AlignTop); Vboxlayout->addWidget(plot); layout->setRowMinimumHeight(0,256); layout->setColumnMinimumWidth(1,20); layout->addLayout(Vboxlayout,0,2,0,2,Qt::AlignLeft); _previewBox = new QCheckBox(tr("Aperçu")); _previewBox->setChecked(true); updatePreview(); layout->addWidget(_previewBox,1,0,1,0,Qt::AlignTop); layout->setSizeConstraint(QLayout::SetMinimumSize); QPushButton *okButton = new QPushButton(tr("Validate"), this); okButton->setDefault(true); Vboxlayout->addWidget(okButton); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(histo, SIGNAL(leftMoved(const QPointF&)), this, SLOT(marker1Moved(const QPointF&))); connect(histo, SIGNAL(rightMoved(const QPointF&)), this, SLOT(marker2Moved(const QPointF&))); connect(_spinbox1, SIGNAL(valueChanged(int)), this, SLOT(spinbox1Changed(int))); connect(_spinbox2, SIGNAL(valueChanged(int)), this, SLOT(spinbox2Changed(int))); connect(_doubleBox, SIGNAL(toggled(bool)), _spinbox2, SLOT(setVisible(bool))); connect(_doubleBox, SIGNAL(toggled(bool)), spin2label, SLOT(setVisible(bool))); connect(_doubleBox, SIGNAL(toggled(bool)), radioLabel, SLOT(setVisible(bool))); connect(_doubleBox, SIGNAL(toggled(bool)), whiteButton, SLOT(setVisible(bool))); connect(_doubleBox, SIGNAL(toggled(bool)), _blackButton, SLOT(setVisible(bool))); connect(_doubleBox, SIGNAL(toggled(bool)), otsuButton, SLOT(setHidden(bool))); connect(_doubleBox, SIGNAL(toggled(bool)), this, SLOT(doubleThreshold(bool))); connect(_previewBox, SIGNAL(toggled(bool)), this, SLOT(showPreview(bool))); connect(_previewBox, SIGNAL(toggled(bool)), this, SLOT(updatePreview())); connect(otsuButton, SIGNAL(pressed()), this, SLOT(otsu())); connect(_doubleBox, SIGNAL(toggled(bool)), this, SLOT(updatePreview())); connect(_blackButton, SIGNAL(toggled(bool)), this, SLOT(updatePreview())); // connect (this, SIGNAL(spinbox1Changed(int)), this, SLOT(updatePreview(bool))); // connect (this, SIGNAL(spinbox2Changed(int)), this, SLOT(updatePreview(bool))); }
ThemeDialog::ThemeDialog(Theme& theme, QWidget* parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), m_theme(theme) { setWindowTitle(tr("Edit Theme")); setWindowModality(Qt::WindowModal); // Create name edit m_name = new QLineEdit(this); m_name->setText(m_theme.name()); connect(m_name, SIGNAL(textChanged(QString)), this, SLOT(checkNameAvailable())); QHBoxLayout* name_layout = new QHBoxLayout; name_layout->setMargin(0); name_layout->addWidget(new QLabel(tr("Name:"), this)); name_layout->addWidget(m_name); // Create scrollarea QWidget* contents = new QWidget(this); QScrollArea* scroll = new QScrollArea(this); scroll->setWidget(contents); scroll->setWidgetResizable(true); // Create text group QGroupBox* text_group = new QGroupBox(tr("Text"), contents); m_text_color = new ColorButton(text_group); m_text_color->setColor(m_theme.textColor()); connect(m_text_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview())); m_font_names = new FontComboBox(text_group); m_font_names->setEditable(false); m_font_names->setCurrentFont(m_theme.textFont()); connect(m_font_names, SIGNAL(activated(int)), this, SLOT(fontChanged())); connect(m_font_names, SIGNAL(activated(int)), this, SLOT(renderPreview())); m_font_sizes = new QComboBox(text_group); m_font_sizes->setEditable(true); m_font_sizes->setMinimumContentsLength(3); connect(m_font_sizes, SIGNAL(editTextChanged(QString)), this, SLOT(renderPreview())); fontChanged(); m_misspelled_color = new ColorButton(text_group); m_misspelled_color->setColor(m_theme.misspelledColor()); connect(m_misspelled_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview())); QHBoxLayout* font_layout = new QHBoxLayout; font_layout->addWidget(m_font_names); font_layout->addWidget(m_font_sizes); QFormLayout* text_layout = new QFormLayout(text_group); text_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); text_layout->addRow(tr("Color:"), m_text_color); text_layout->addRow(tr("Font:"), font_layout); text_layout->addRow(tr("Misspelled:"), m_misspelled_color); // Create background group QGroupBox* background_group = new QGroupBox(tr("Window Background"), contents); m_background_color = new ColorButton(background_group); m_background_color->setColor(m_theme.backgroundColor()); connect(m_background_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview())); m_background_image = new ImageButton(background_group); m_background_image->setImage(m_theme.backgroundImage(), m_theme.backgroundPath()); connect(m_background_image, SIGNAL(changed(QString)), this, SLOT(imageChanged())); m_clear_image = new QPushButton(tr("Remove"), background_group); connect(m_clear_image, SIGNAL(clicked()), m_background_image, SLOT(unsetImage())); m_background_type = new QComboBox(background_group); m_background_type->addItems(QStringList() << tr("No Image") << tr("Tiled") << tr("Centered") << tr("Stretched") << tr("Scaled") << tr("Zoomed")); m_background_type->setCurrentIndex(m_theme.backgroundType()); connect(m_background_type, SIGNAL(activated(int)), this, SLOT(renderPreview())); QVBoxLayout* image_layout = new QVBoxLayout; image_layout->setSpacing(0); image_layout->setMargin(0); image_layout->addWidget(m_background_image); image_layout->addWidget(m_clear_image); QFormLayout* background_layout = new QFormLayout(background_group); background_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); background_layout->addRow(tr("Color:"), m_background_color); background_layout->addRow(tr("Image:"), image_layout); background_layout->addRow(tr("Type:"), m_background_type); // Create foreground group QGroupBox* foreground_group = new QGroupBox(tr("Text Background"), contents); m_foreground_color = new ColorButton(foreground_group); m_foreground_color->setColor(m_theme.foregroundColor()); connect(m_foreground_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview())); m_foreground_opacity = new QSpinBox(foreground_group); m_foreground_opacity->setCorrectionMode(QSpinBox::CorrectToNearestValue); m_foreground_opacity->setSuffix(QLocale().percent()); m_foreground_opacity->setRange(theme.foregroundOpacity().minimumValue(), theme.foregroundOpacity().maximumValue()); m_foreground_opacity->setValue(m_theme.foregroundOpacity()); connect(m_foreground_opacity, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); m_foreground_position = new QComboBox(foreground_group); m_foreground_position->addItems(QStringList() << tr("Left") << tr("Centered") << tr("Right") << tr("Stretched")); m_foreground_position->setCurrentIndex(m_theme.foregroundPosition()); connect(m_foreground_position, SIGNAL(currentIndexChanged(int)), this, SLOT(positionChanged(int))); m_foreground_width = new QSpinBox(foreground_group); m_foreground_width->setCorrectionMode(QSpinBox::CorrectToNearestValue); m_foreground_width->setSuffix(tr(" pixels")); m_foreground_width->setRange(theme.foregroundWidth().minimumValue(), theme.foregroundWidth().maximumValue()); m_foreground_width->setValue(m_theme.foregroundWidth()); m_foreground_width->setEnabled(m_theme.foregroundPosition() != 3); connect(m_foreground_width, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); QFormLayout* foreground_layout = new QFormLayout(foreground_group); foreground_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); foreground_layout->addRow(tr("Color:"), m_foreground_color); foreground_layout->addRow(tr("Opacity:"), m_foreground_opacity); foreground_layout->addRow(tr("Position:"), m_foreground_position); foreground_layout->addRow(tr("Width:"), m_foreground_width); // Create rounding group m_round_corners = new QGroupBox(tr("Round Text Background Corners"), contents); m_round_corners->setCheckable(true); m_round_corners->setChecked(m_theme.roundCornersEnabled()); connect(m_round_corners, SIGNAL(clicked()), this, SLOT(renderPreview())); m_corner_radius = new QSpinBox(m_round_corners); m_corner_radius->setCorrectionMode(QSpinBox::CorrectToNearestValue); m_corner_radius->setSuffix(tr(" pixels")); m_corner_radius->setRange(theme.cornerRadius().minimumValue(), theme.cornerRadius().maximumValue()); m_corner_radius->setValue(m_theme.cornerRadius()); connect(m_corner_radius, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); QFormLayout* corner_layout = new QFormLayout(m_round_corners); corner_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); corner_layout->addRow(tr("Radius:"), m_corner_radius); // Create blur group m_blur = new QGroupBox(tr("Blur Text Background"), contents); m_blur->setCheckable(true); m_blur->setChecked(m_theme.blurEnabled()); connect(m_blur, SIGNAL(clicked()), this, SLOT(renderPreview())); m_blur_radius = new QSpinBox(m_blur); m_blur_radius->setCorrectionMode(QSpinBox::CorrectToNearestValue); m_blur_radius->setSuffix(tr(" pixels")); m_blur_radius->setRange(theme.blurRadius().minimumValue(), theme.blurRadius().maximumValue()); m_blur_radius->setValue(m_theme.blurRadius()); connect(m_blur_radius, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); QFormLayout* blur_layout = new QFormLayout(m_blur); blur_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); blur_layout->addRow(tr("Radius:"), m_blur_radius); // Create shadow group m_shadow = new QGroupBox(tr("Text Background Drop Shadow"), contents); m_shadow->setCheckable(true); m_shadow->setChecked(m_theme.shadowEnabled()); connect(m_shadow, SIGNAL(clicked()), this, SLOT(renderPreview())); m_shadow_color = new ColorButton(m_shadow); m_shadow_color->setColor(m_theme.shadowColor()); connect(m_shadow_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview())); m_shadow_radius = new QSpinBox(m_shadow); m_shadow_radius->setCorrectionMode(QSpinBox::CorrectToNearestValue); m_shadow_radius->setSuffix(tr(" pixels")); m_shadow_radius->setRange(theme.shadowRadius().minimumValue(), theme.shadowRadius().maximumValue()); m_shadow_radius->setValue(m_theme.shadowRadius()); connect(m_shadow_radius, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); m_shadow_offset = new QSpinBox(m_shadow); m_shadow_offset->setCorrectionMode(QSpinBox::CorrectToNearestValue); m_shadow_offset->setSuffix(tr(" pixels")); m_shadow_offset->setRange(theme.shadowOffset().minimumValue(), theme.shadowOffset().maximumValue()); m_shadow_offset->setValue(m_theme.shadowOffset()); connect(m_shadow_offset, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); QFormLayout* shadow_layout = new QFormLayout(m_shadow); shadow_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); shadow_layout->addRow(tr("Color:"), m_shadow_color); shadow_layout->addRow(tr("Radius:"), m_shadow_radius); shadow_layout->addRow(tr("Vertical Offset:"), m_shadow_offset); // Create margins group QGroupBox* margins_group = new QGroupBox(tr("Margins"), contents); m_foreground_margin = new QSpinBox(margins_group); m_foreground_margin->setCorrectionMode(QSpinBox::CorrectToNearestValue); m_foreground_margin->setSuffix(tr(" pixels")); m_foreground_margin->setRange(theme.foregroundMargin().minimumValue(), theme.foregroundMargin().maximumValue()); m_foreground_margin->setValue(m_theme.foregroundMargin()); connect(m_foreground_margin, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); m_foreground_padding = new QSpinBox(margins_group); m_foreground_padding->setCorrectionMode(QSpinBox::CorrectToNearestValue); m_foreground_padding->setSuffix(tr(" pixels")); m_foreground_padding->setRange(theme.foregroundPadding().minimumValue(), theme.foregroundPadding().maximumValue()); m_foreground_padding->setValue(m_theme.foregroundPadding()); connect(m_foreground_padding, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); QFormLayout* margins_layout = new QFormLayout(margins_group); margins_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); margins_layout->addRow(tr("Window:"), m_foreground_margin); margins_layout->addRow(tr("Page:"), m_foreground_padding); // Create line spacing group QGroupBox* line_spacing = new QGroupBox(tr("Line Spacing"), contents); m_line_spacing_type = new QComboBox(line_spacing); m_line_spacing_type->setEditable(false); m_line_spacing_type->addItems(QStringList() << tr("Single") << tr("1.5 Lines") << tr("Double") << tr("Proportional")); m_line_spacing_type->setCurrentIndex(3); m_line_spacing = new QSpinBox(line_spacing); m_line_spacing->setSuffix(QLocale().percent()); m_line_spacing->setRange(theme.lineSpacing().minimumValue(), theme.lineSpacing().maximumValue()); m_line_spacing->setValue(m_theme.lineSpacing()); m_line_spacing->setEnabled(false); switch (m_theme.lineSpacing()) { case 100: m_line_spacing_type->setCurrentIndex(0); break; case 150: m_line_spacing_type->setCurrentIndex(1); break; case 200: m_line_spacing_type->setCurrentIndex(2); break; default: m_line_spacing->setEnabled(true); break; } connect(m_line_spacing_type, SIGNAL(currentIndexChanged(int)), this, SLOT(lineSpacingChanged(int))); connect(m_line_spacing_type, SIGNAL(currentIndexChanged(int)), this, SLOT(renderPreview())); connect(m_line_spacing, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); QFormLayout* line_spacing_layout = new QFormLayout(line_spacing); line_spacing_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); line_spacing_layout->addRow(tr("Type:"), m_line_spacing_type); line_spacing_layout->addRow(tr("Height:"), m_line_spacing); #if (QT_VERSION < QT_VERSION_CHECK(4,8,0)) line_spacing->hide(); #endif // Create paragraph spacing group QGroupBox* paragraph_spacing = new QGroupBox(tr("Paragraph Spacing"), contents); m_tab_width = new QSpinBox(paragraph_spacing); m_tab_width->setSuffix(tr(" pixels")); m_tab_width->setRange(theme.tabWidth().minimumValue(), theme.tabWidth().maximumValue()); m_tab_width->setValue(m_theme.tabWidth()); connect(m_tab_width, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); m_spacing_above_paragraph = new QSpinBox(paragraph_spacing); m_spacing_above_paragraph->setSuffix(tr(" pixels")); m_spacing_above_paragraph->setRange(theme.spacingAboveParagraph().minimumValue(), theme.spacingAboveParagraph().maximumValue()); m_spacing_above_paragraph->setValue(m_theme.spacingAboveParagraph()); connect(m_spacing_above_paragraph, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); m_spacing_below_paragraph = new QSpinBox(paragraph_spacing); m_spacing_below_paragraph->setSuffix(tr(" pixels")); m_spacing_below_paragraph->setRange(theme.spacingBelowParagraph().minimumValue(), theme.spacingBelowParagraph().maximumValue()); m_spacing_below_paragraph->setValue(m_theme.spacingBelowParagraph()); connect(m_spacing_below_paragraph, SIGNAL(valueChanged(int)), this, SLOT(renderPreview())); m_indent_first_line = new QCheckBox(tr("Indent first line"), paragraph_spacing); m_indent_first_line->setChecked(m_theme.indentFirstLine()); connect(m_indent_first_line, SIGNAL(toggled(bool)), this, SLOT(renderPreview())); QFormLayout* paragraph_spacing_layout = new QFormLayout(paragraph_spacing); paragraph_spacing_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint); paragraph_spacing_layout->addRow(tr("Tab Width:"), m_tab_width); paragraph_spacing_layout->addRow(tr("Above:"), m_spacing_above_paragraph); paragraph_spacing_layout->addRow(tr("Below:"), m_spacing_below_paragraph); paragraph_spacing_layout->addRow("", m_indent_first_line); // Create preview m_preview_text = new QTextEdit; m_preview_text->setFrameStyle(QFrame::NoFrame); m_preview_text->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_preview_text->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QFile file(":/lorem.txt"); if (file.open(QFile::ReadOnly)) { m_preview_text->setPlainText(QString::fromLatin1(file.readAll())); file.close(); } m_preview = new QLabel(this); m_preview->setAlignment(Qt::AlignCenter); m_preview->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel); QPixmap pixmap(480, 270); pixmap.fill(palette().window().color()); m_preview->setPixmap(pixmap); m_theme_renderer = new ThemeRenderer(this); connect(m_theme_renderer, SIGNAL(rendered(QImage,QRect,Theme)), this, SLOT(renderPreview(QImage,QRect,Theme))); renderPreview(); // Lay out dialog QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); m_ok = buttons->button(QDialogButtonBox::Ok); connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); QVBoxLayout* groups_layout = new QVBoxLayout(contents); groups_layout->addWidget(text_group); groups_layout->addWidget(background_group); groups_layout->addWidget(foreground_group); groups_layout->addWidget(m_round_corners); groups_layout->addWidget(m_blur); groups_layout->addWidget(m_shadow); groups_layout->addWidget(margins_group); groups_layout->addWidget(line_spacing); groups_layout->addWidget(paragraph_spacing); QGridLayout* layout = new QGridLayout(this); layout->setColumnStretch(0, 1); layout->setRowStretch(1, 1); layout->setRowMinimumHeight(2, layout->margin()); layout->addLayout(name_layout, 0, 0, 1, 2); layout->addWidget(scroll, 1, 0, 1, 1); layout->addWidget(m_preview, 1, 1, 1, 1, Qt::AlignCenter); layout->addWidget(buttons, 3, 0, 1, 2); resize(QSettings().value("ThemeDialog/Size", sizeHint()).toSize()); }
EditorPage::EditorPage(QWidget* parent) : SettingsPage(parent) { QGridLayout* layout = new QGridLayout(); this->setLayout(layout); int row = 0; antialiasing = new QCheckBox(tr("High quality map display (antialiasing)"), this); antialiasing->setToolTip(tr("Antialiasing makes the map look much better, but also slows down the map display")); layout->addWidget(antialiasing, row++, 0, 1, 2); text_antialiasing = new QCheckBox(tr("High quality text display in map (antialiasing), slow"), this); text_antialiasing->setToolTip(tr("Antialiasing makes the map look much better, but also slows down the map display")); layout->addWidget(text_antialiasing, row++, 0, 1, 2); QLabel* tolerance_label = new QLabel(tr("Click tolerance:")); QSpinBox* tolerance = Util::SpinBox::create(0, 50, tr("mm", "millimeters")); layout->addWidget(tolerance_label, row, 0); layout->addWidget(tolerance, row++, 1); QLabel* snap_distance_label = new QLabel(tr("Snap distance (%1):").arg(ModifierKey::shift())); QSpinBox* snap_distance = Util::SpinBox::create(0, 100, tr("mm", "millimeters")); layout->addWidget(snap_distance_label, row, 0); layout->addWidget(snap_distance, row++, 1); QLabel* fixed_angle_stepping_label = new QLabel(tr("Stepping of fixed angle mode (%1):").arg(ModifierKey::control())); QSpinBox* fixed_angle_stepping = Util::SpinBox::create(1, 180, trUtf8("°", "Degree sign for angles")); layout->addWidget(fixed_angle_stepping_label, row, 0); layout->addWidget(fixed_angle_stepping, row++, 1); QCheckBox* select_symbol_of_objects = new QCheckBox(tr("When selecting an object, automatically select its symbol, too")); layout->addWidget(select_symbol_of_objects, row++, 0, 1, 2); QCheckBox* zoom_out_away_from_cursor = new QCheckBox(tr("Zoom away from cursor when zooming out")); layout->addWidget(zoom_out_away_from_cursor, row++, 0, 1, 2); QCheckBox* draw_last_point_on_right_click = new QCheckBox(tr("Drawing tools: set last point on finishing with right click")); layout->addWidget(draw_last_point_on_right_click, row++, 0, 1, 2); QCheckBox* keep_settings_of_closed_templates = new QCheckBox(tr("Templates: keep settings of closed templates")); layout->addWidget(keep_settings_of_closed_templates, row++, 0, 1, 2); layout->setRowMinimumHeight(row++, 16); layout->addWidget(Util::Headline::create(tr("Edit tool:")), row++, 0, 1, 2); edit_tool_delete_bezier_point_action = new QComboBox(); edit_tool_delete_bezier_point_action->addItem(tr("Retain old shape"), (int)Settings::DeleteBezierPoint_RetainExistingShape); edit_tool_delete_bezier_point_action->addItem(tr("Reset outer curve handles"), (int)Settings::DeleteBezierPoint_ResetHandles); edit_tool_delete_bezier_point_action->addItem(tr("Keep outer curve handles"), (int)Settings::DeleteBezierPoint_KeepHandles); layout->addWidget(new QLabel(tr("Action on deleting a curve point with %1:").arg(ModifierKey::control())), row, 0); layout->addWidget(edit_tool_delete_bezier_point_action, row++, 1); edit_tool_delete_bezier_point_action_alternative = new QComboBox(); edit_tool_delete_bezier_point_action_alternative->addItem(tr("Retain old shape"), (int)Settings::DeleteBezierPoint_RetainExistingShape); edit_tool_delete_bezier_point_action_alternative->addItem(tr("Reset outer curve handles"), (int)Settings::DeleteBezierPoint_ResetHandles); edit_tool_delete_bezier_point_action_alternative->addItem(tr("Keep outer curve handles"), (int)Settings::DeleteBezierPoint_KeepHandles); layout->addWidget(new QLabel(tr("Action on deleting a curve point with %1:").arg(ModifierKey::controlShift())), row, 0); layout->addWidget(edit_tool_delete_bezier_point_action_alternative, row++, 1); layout->setRowMinimumHeight(row++, 16); layout->addWidget(Util::Headline::create(tr("Rectangle tool:")), row++, 0, 1, 2); QLabel* rectangle_helper_cross_radius_label = new QLabel(tr("Radius of helper cross:")); QSpinBox* rectangle_helper_cross_radius = Util::SpinBox::create(0, 999999, tr("mm", "millimeters")); layout->addWidget(rectangle_helper_cross_radius_label, row, 0); layout->addWidget(rectangle_helper_cross_radius, row++, 1); QCheckBox* rectangle_preview_line_width = new QCheckBox(tr("Preview the width of lines with helper cross")); layout->addWidget(rectangle_preview_line_width, row++, 0, 1, 2); antialiasing->setChecked(Settings::getInstance().getSetting(Settings::MapDisplay_Antialiasing).toBool()); text_antialiasing->setChecked(Settings::getInstance().getSetting(Settings::MapDisplay_TextAntialiasing).toBool()); tolerance->setValue(Settings::getInstance().getSetting(Settings::MapEditor_ClickToleranceMM).toInt()); snap_distance->setValue(Settings::getInstance().getSetting(Settings::MapEditor_SnapDistanceMM).toInt()); fixed_angle_stepping->setValue(Settings::getInstance().getSetting(Settings::MapEditor_FixedAngleStepping).toInt()); select_symbol_of_objects->setChecked(Settings::getInstance().getSetting(Settings::MapEditor_ChangeSymbolWhenSelecting).toBool()); zoom_out_away_from_cursor->setChecked(Settings::getInstance().getSetting(Settings::MapEditor_ZoomOutAwayFromCursor).toBool()); draw_last_point_on_right_click->setChecked(Settings::getInstance().getSetting(Settings::MapEditor_DrawLastPointOnRightClick).toBool()); keep_settings_of_closed_templates->setChecked(Settings::getInstance().getSetting(Settings::Templates_KeepSettingsOfClosed).toBool()); edit_tool_delete_bezier_point_action->setCurrentIndex(edit_tool_delete_bezier_point_action->findData(Settings::getInstance().getSetting(Settings::EditTool_DeleteBezierPointAction).toInt())); edit_tool_delete_bezier_point_action_alternative->setCurrentIndex(edit_tool_delete_bezier_point_action_alternative->findData(Settings::getInstance().getSetting(Settings::EditTool_DeleteBezierPointActionAlternative).toInt())); rectangle_helper_cross_radius->setValue(Settings::getInstance().getSetting(Settings::RectangleTool_HelperCrossRadiusMM).toInt()); rectangle_preview_line_width->setChecked(Settings::getInstance().getSetting(Settings::RectangleTool_PreviewLineWidth).toBool()); layout->setRowStretch(row, 1); updateWidgets(); connect(antialiasing, &QAbstractButton::toggled, this, &EditorPage::antialiasingClicked); connect(text_antialiasing, &QAbstractButton::toggled, this, &EditorPage::textAntialiasingClicked); connect(tolerance, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &EditorPage::toleranceChanged); connect(snap_distance, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &EditorPage::snapDistanceChanged); connect(fixed_angle_stepping, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &EditorPage::fixedAngleSteppingChanged); connect(select_symbol_of_objects, &QAbstractButton::clicked, this, &EditorPage::selectSymbolOfObjectsClicked); connect(zoom_out_away_from_cursor, &QAbstractButton::clicked, this, &EditorPage::zoomOutAwayFromCursorClicked); connect(draw_last_point_on_right_click, &QAbstractButton::clicked, this, &EditorPage::drawLastPointOnRightClickClicked); connect(keep_settings_of_closed_templates, &QAbstractButton::clicked, this, &EditorPage::keepSettingsOfClosedTemplatesClicked); connect(edit_tool_delete_bezier_point_action, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &EditorPage::editToolDeleteBezierPointActionChanged); connect(edit_tool_delete_bezier_point_action_alternative, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &EditorPage::editToolDeleteBezierPointActionAlternativeChanged); connect(rectangle_helper_cross_radius, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &EditorPage::rectangleHelperCrossRadiusChanged); connect(rectangle_preview_line_width, &QAbstractButton::clicked, this, &EditorPage::rectanglePreviewLineWidthChanged); }
GliderEditorNumPad::GliderEditorNumPad(QWidget *parent, Glider *glider ) : QWidget(parent), m_gliderCreated(false) { setWindowFlags(Qt::Tool); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); // Resize the window to the same size as the main window has. That will // completely hide the parent window. resize( MainWindow::mainWindow()->size() ); // save current horizontal/vertical speed unit. This unit must be considered // during storage. m_currHSpeedUnit = Speed::getHorizontalUnit(); m_currVSpeedUnit = Speed::getVerticalUnit(); if (glider == 0) { setWindowTitle(tr("New Glider")); m_isNew = true; } else { setWindowTitle(tr("Edit Glider")); m_isNew = false; } m_glider = glider; QHBoxLayout* topLayout = new QHBoxLayout(this); QGridLayout* itemsLayout = new QGridLayout; itemsLayout->setHorizontalSpacing(10); itemsLayout->setVerticalSpacing(10); int row = 0; if( m_isNew ) { itemsLayout->addWidget(new QLabel(tr("Glider Pool:"), this), row, 0); m_openGliderList = new QPushButton( tr("Open") ); itemsLayout->addWidget(m_openGliderList, row, 1, 1, 3); connect( m_openGliderList, SIGNAL(clicked()), SLOT(slot_openGliderSelectionList()) ); row++; } Qt::InputMethodHints imh = Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText; itemsLayout->addWidget(new QLabel(tr("Glider Type:"), this), row, 0); m_edtGType = new QLineEdit(this); imh |= m_edtGType->inputMethodHints(); m_edtGType->setInputMethodHints(imh); connect( m_edtGType, SIGNAL(returnPressed()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); itemsLayout->addWidget(m_edtGType, row, 1, 1, 3); row++; itemsLayout->addWidget(new QLabel(tr("Registration:"), this), row, 0); m_edtGReg = new QLineEdit(this); m_edtGReg->setInputMethodHints(imh); connect( m_edtGReg, SIGNAL(returnPressed()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); itemsLayout->addWidget(m_edtGReg, row, 1); itemsLayout->addWidget(new QLabel(tr("Seats:"), this), row, 2); m_seats = new QPushButton( this ); itemsLayout->addWidget(m_seats, row, 3); connect( m_seats, SIGNAL(clicked()), SLOT(slot_changeSeats()) ); row++; itemsLayout->addWidget(new QLabel(tr("Call Sign:"), this), row, 0); m_edtGCall = new QLineEdit(this); m_edtGCall->setInputMethodHints(imh); connect( m_edtGCall, SIGNAL(returnPressed()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); itemsLayout->addWidget(m_edtGCall, row, 1); itemsLayout->addWidget(new QLabel(tr("Wing Area:"), this), row, 2); m_dneWingArea = new DoubleNumberEditor(this); m_dneWingArea->setDecimalVisible( true ); m_dneWingArea->setPmVisible( false ); m_dneWingArea->setMaxLength(7); m_dneWingArea->setDecimals( 2 ); QChar tsChar(Qt::Key_twosuperior); m_dneWingArea->setSuffix( QString(" m") + tsChar ); itemsLayout->addWidget(m_dneWingArea, row, 3); row++; itemsLayout->setRowMinimumHeight(row++, 10); QGridLayout* spinboxLayout = new QGridLayout; spinboxLayout->setHorizontalSpacing(10); spinboxLayout->setVerticalSpacing(10); int srow = 0; spinboxLayout->addWidget(new QLabel("v1:", this), srow, 0); m_dneV1 = new DoubleNumberEditor(this); m_dneV1->setDecimalVisible( true ); m_dneV1->setPmVisible( false ); m_dneV1->setMaxLength(5); m_dneV1->setRange(0.0, 250.0); m_dneV1->setDecimals( 1 ); m_dneV1->setSuffix( " " + Speed::getHorizontalUnitText() ); spinboxLayout->addWidget(m_dneV1, srow, 1); spinboxLayout->addWidget(new QLabel("w1:", this), srow, 2); m_dneW1 = new DoubleNumberEditor(this); m_dneW1->setDecimalVisible( true ); m_dneW1->setPmVisible( true ); m_dneW1->setMaxLength(7); m_dneW1->setDecimals( 2 ); m_dneW1->setSuffix( " " + Speed::getVerticalUnitText() ); QRegExpValidator *eValidator = new QRegExpValidator( QRegExp( "-[0-9]+\\.?[0-9]*" ), this ); m_dneW1->setValidator(eValidator); spinboxLayout->addWidget(m_dneW1, srow, 3); spinboxLayout->addWidget(new QLabel(tr("Ref. weight:"), this), srow, 4); m_grossWeight = new NumberEditor( this ); m_grossWeight->setDecimalVisible( false ); m_grossWeight->setPmVisible( false ); m_grossWeight->setMaxLength(4); m_grossWeight->setSuffix(" kg"); m_grossWeight->setRange( 0, 9999 ); spinboxLayout->addWidget(m_grossWeight, srow, 5); srow++; spinboxLayout->addWidget(new QLabel("v2", this), srow, 0); m_dneV2 = new DoubleNumberEditor(this); m_dneV2->setDecimalVisible( true ); m_dneV2->setPmVisible( false ); m_dneV2->setMaxLength(5); m_dneV2->setRange(0.0, 250.0); m_dneV2->setDecimals( 1 ); m_dneV2->setSuffix( " " + Speed::getHorizontalUnitText() ); spinboxLayout->addWidget(m_dneV2, srow, 1); spinboxLayout->addWidget(new QLabel("w2:", this), srow, 2); m_dneW2 = new DoubleNumberEditor(this); m_dneW2->setDecimalVisible( true ); m_dneW2->setPmVisible( true ); m_dneW2->setMaxLength(7); m_dneW2->setDecimals( 2 ); m_dneW2->setSuffix( " " + Speed::getVerticalUnitText() ); eValidator = new QRegExpValidator( QRegExp( "-[0-9]+\\.?[0-9]*" ), this ); m_dneW2->setValidator(eValidator); spinboxLayout->addWidget(m_dneW2, srow, 3); spinboxLayout->addWidget(new QLabel(tr("Load corr.:"), this), srow, 4); m_addedLoad = new NumberEditor( this ); m_addedLoad->setDecimalVisible( false ); m_addedLoad->setPmVisible( true ); m_addedLoad->setMaxLength(4); m_addedLoad->setSuffix(" kg"); m_addedLoad->setRange( -999, 999 ); spinboxLayout->addWidget(m_addedLoad, srow, 5); srow++; spinboxLayout->addWidget(new QLabel("v3:", this), srow, 0); m_dneV3 = new DoubleNumberEditor(this); m_dneV3->setDecimalVisible( true ); m_dneV3->setPmVisible( false ); m_dneV3->setMaxLength(5); m_dneV3->setRange(0.0, 250.0); m_dneV3->setDecimals( 1 ); m_dneV3->setSuffix( " " + Speed::getHorizontalUnitText() ); spinboxLayout->addWidget(m_dneV3, srow, 1); spinboxLayout->addWidget(new QLabel("w3:", this), srow, 2); m_dneW3 = new DoubleNumberEditor(this); m_dneW3->setDecimalVisible( true ); m_dneW3->setPmVisible( true ); m_dneW3->setMaxLength(7); m_dneW3->setDecimals( 2 ); m_dneW3->setSuffix( " " + Speed::getVerticalUnitText() ); eValidator = new QRegExpValidator( QRegExp( "-[0-9]+\\.?[0-9]*" ), this ); m_dneW3->setValidator(eValidator); spinboxLayout->addWidget(m_dneW3, srow, 3); spinboxLayout->addWidget(new QLabel(tr("Max. water:"), this), srow, 4); m_addedWater = new NumberEditor( this ); m_addedWater->setDecimalVisible( false ); m_addedWater->setPmVisible( false ); m_addedWater->setMaxLength(4); m_addedWater->setSuffix(" l"); m_addedWater->setRange( 0, 9999 ); spinboxLayout->addWidget(m_addedWater, srow++, 5); spinboxLayout->setColumnStretch(6, 10); spinboxLayout->setRowMinimumHeight(srow++, 20); m_buttonShow = new QPushButton(tr("Show Polar")); QHBoxLayout* buttonRow = new QHBoxLayout; buttonRow->setSpacing(0); buttonRow->addStretch( 10 ); buttonRow->addWidget( m_buttonShow ); spinboxLayout->addLayout(buttonRow, srow++, 0, 1, 6); spinboxLayout->setRowStretch( srow++, 10 ); itemsLayout->addLayout(spinboxLayout, row++, 0, 1, 4); itemsLayout->setColumnStretch( 1, 10 ); itemsLayout->setColumnStretch( 4, 20 ); connect(m_buttonShow, SIGNAL(pressed()), this, SLOT(slotButtonShow())); 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); connect(ok, SIGNAL(pressed()), this, SLOT(accept())); connect(cancel, SIGNAL(pressed()), this, SLOT(reject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); topLayout->addLayout(itemsLayout); topLayout->addLayout(buttonBox); if( m_isNew ) { readLK8000PolarData(); } else { load(); } show(); }
NewGameTab::NewGameTab(const QStringList& files, QDialog* parent) : QWidget(parent) { // Add image filter m_image_tags = new TagManager(this); connect(m_image_tags, &TagManager::filterChanged, this, &NewGameTab::filterImages); connect(m_image_tags, &TagManager::tagsChanged, this, &NewGameTab::updateTagsStrings); // Add image selector m_images = new ToolBarList(this); m_images->setViewMode(QListView::IconMode); m_images->setIconSize(QSize(74, 74)); m_images->setMinimumSize(460 + m_images->verticalScrollBar()->sizeHint().width(), 230); m_images->setItemDelegate(new ThumbnailDelegate(m_images)); connect(m_images, &ToolBarList::currentItemChanged, this, &NewGameTab::imageSelected); connect(m_images, &ToolBarList::itemActivated, this, &NewGameTab::editImageProperties); // Add image actions QAction* add_action = new QAction(m_images->fetchIcon("list-add"), tr("Add Image"), this); m_images->addToolBarAction(add_action); connect(add_action, &QAction::triggered, this, &NewGameTab::addImageClicked); m_remove_action = new QAction(m_images->fetchIcon("list-remove"), tr("Remove Image"), this); m_images->addToolBarAction(m_remove_action); connect(m_remove_action, &QAction::triggered, this, &NewGameTab::removeImage); m_tag_action = new QAction(m_images->fetchIcon("image-x-generic"), tr("Image Properties"), this); m_images->addToolBarAction(m_tag_action); connect(m_tag_action, &QAction::triggered, this, &NewGameTab::editImageProperties); // Add image splitter m_image_contents = new QSplitter(this); m_image_contents->addWidget(m_image_tags); m_image_contents->addWidget(m_images); m_image_contents->setStretchFactor(0, 0); m_image_contents->setStretchFactor(1, 1); m_image_contents->setSizes(QList<int>() << 130 << m_images->minimumWidth()); // Add pieces slider m_slider = new QSlider(Qt::Horizontal, this); m_slider->setRange(1, 1); connect(m_slider, &QSlider::valueChanged, this, &NewGameTab::pieceCountChanged); m_count = new QLabel(this); m_count->setAlignment(Qt::AlignRight | Qt::AlignVCenter); m_count->setMinimumWidth(m_count->fontMetrics().boundingRect(tr("%L1 pieces").arg(9999)).width()); // Add buttons QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); connect(buttons, &QDialogButtonBox::accepted, this, &NewGameTab::accept); connect(buttons, &QDialogButtonBox::rejected, parent, &QDialog::reject); m_accept_button = buttons->button(QDialogButtonBox::Ok); m_accept_button->setEnabled(false); // Arrange widgets QGridLayout* layout = new QGridLayout(this); layout->setColumnStretch(1, 1); layout->setRowStretch(0, 1); layout->addWidget(m_image_contents, 0, 0, 1, 2); layout->setRowMinimumHeight(1, 12); layout->addWidget(m_count, 2, 0); layout->addWidget(m_slider, 2, 1); layout->setRowMinimumHeight(3, 12); layout->addWidget(buttons, 4, 0, 1, 2); // Load images QSettings details(Path::image("details"), QSettings::IniFormat); QListWidgetItem* item = 0; for (const QString& image : QDir(Path::images(), "*.*").entryList(QDir::Files, QDir::Time | QDir::Reversed)) { item = createItem(image, details); } m_images->sortItems(); // Load values QSettings settings; item = m_images->item(0); QString image = settings.value("NewGame/Image").toString(); if (!image.isEmpty()) { for (int i = m_images->count() - 1; i >= 0; --i) { item = m_images->item(i); if (item->data(ImageRole) == image) { break; } } } m_images->setCurrentItem(item); m_slider->setValue(settings.value("NewGame/Pieces", 2).toInt()); pieceCountChanged(m_slider->value()); // Add new images addImages(files); // Resize contents m_image_contents->restoreState(settings.value("NewGame/SplitterSizes").toByteArray()); }