MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { //инициализацию начальных значений векторов vectXCPU.append(10); vectYCPU.append(265); vectXGPU.append(280); vectYGPU.append(265); setWindowTitle(tr("Monitoring CPU & GPU")); QWidget * wgt = new QWidget(this); setCentralWidget(wgt); //инициализция строк для отображения информации QString nameProcessor = "Model СPU: "; nameProcessor += objectForCPU.getNameProcessor(); QString numbOfCores = "Numb Cores of CPU: "; numbOfCores += QString::number(objectForCPU.getNumbCores()); QString totalSizeRam = "Total RAM size: "; totalSizeRam += QString::number(objectForCPU.getTotalSizeRAM()) + " Mb"; //создание надписей QLabel *nameProc = new QLabel(nameProcessor); QLabel *numbCores = new QLabel(numbOfCores); QLabel *sizeRAM = new QLabel(totalSizeRam); //размещение надписей CPULayout = new QVBoxLayout; CPULayout->addWidget(nameProc); CPULayout->addWidget(numbCores); CPULayout->addWidget(sizeRAM); GPULayout = new QVBoxLayout(); QString nameGPU = "Model GPU: "; nameGPU += objectForGPU.getNameGPU(); QLabel *nameGPULabel = new QLabel(nameGPU); GPULayout->addWidget(nameGPULabel); QWidget *tempGPUWidget = new QWidget(); tempGPUWidget->setMinimumHeight(240); tempGPUWidget->setMinimumWidth(260); GPULayout->addWidget(tempGPUWidget); QWidget *tempCPUwgt = new QWidget(); tempCPUwgt->setMinimumHeight(200); tempCPUwgt->setMinimumWidth(250); CPULayout->addWidget(tempCPUwgt); CPUInfoLabel = new QLabel(); GPUInfoLabel = new QLabel(); //запуск таймера connect( &m_timer, SIGNAL( timeout() ), SLOT( drawGraphicCPUUsage() ) ); m_timer.start( 1 ); // Таймер будет срабатывать каждые 1000 миллисекунд, т.е. каждую секунду CPULayout->addWidget(CPUInfoLabel); GPULayout->addWidget(GPUInfoLabel); QHBoxLayout *mainLayout = new QHBoxLayout(); mainLayout->addLayout(CPULayout); mainLayout->addLayout(GPULayout); wgt->setLayout ( mainLayout ); }
void tst_QWidget_window::tst_updateWinId_QTBUG40681() { QWidget w; QVBoxLayout *vl = new QVBoxLayout(&w); QLabel *lbl = new QLabel("HELLO1"); lbl->setAttribute(Qt::WA_NativeWindow); lbl->setObjectName("label1"); vl->addWidget(lbl); w.setMinimumWidth(200); w.show(); QVERIFY(QTest::qWaitForWindowExposed(&w)); QCOMPARE(lbl->winId(), lbl->windowHandle()->winId()); // simulate screen change and notification QWindow *win = w.windowHandle(); w.windowHandle()->destroy(); lbl->windowHandle()->destroy(); w.windowHandle()->create(); lbl->windowHandle()->create(); QWindowPrivate *p = qt_window_private(win); p->emitScreenChangedRecursion(win->screen()); QCOMPARE(lbl->winId(), lbl->windowHandle()->winId()); }
Bit_ly_Config::Bit_ly_Config(QWidget *parent, const QVariantList &): KCModule(KAboutData::pluginData(QLatin1String("kcm_choqok_bit_ly")), parent) { QVBoxLayout *layout = new QVBoxLayout(this); QWidget *wd = new QWidget(this); wd->setObjectName(QLatin1String("mBitLYCtl")); wd->setMinimumWidth(400); ui.setupUi(wd); addConfig(Bit_ly_Settings::self(), wd); layout->addWidget(wd); QRegExp rx(QLatin1String("([a-z0-9_]){4,32}"), Qt::CaseInsensitive); QValidator *val0 = new QRegExpValidator(rx, 0); ui.kcfg_login->setValidator(val0); rx.setPattern(QLatin1String("([a-z0-9_]){1,40}")); QValidator *val1 = new QRegExpValidator(rx, 0); ui.kcfg_api_key->setValidator(val1); ui.help_label->setTextFormat(Qt::RichText); ui.help_label->setText(i18nc("The your_api_key part of the URL is a fixed part of the URL " "and should probably not be changed in localization.", "You can find your API key <a href=\"http://bit.ly/a/your_api_key\">here</a>")); domains << QLatin1String("bit.ly") << QLatin1String("j.mp"); ui.kcfg_domain->addItems(domains); connect(ui.kcfg_login, SIGNAL(textChanged(QString)), SLOT(emitChanged())); connect(ui.kcfg_api_key, SIGNAL(textChanged(QString)), SLOT(emitChanged())); connect(ui.kcfg_domain, SIGNAL(currentIndexChanged(int)), SLOT(emitChanged())); connect(ui.validate_button, SIGNAL(clicked(bool)), SLOT(slotValidate())); }
window::window() : m_meshCalllist(0) { QWidget* central = new QWidget(); setCentralWidget(central); QHBoxLayout* mainLayout = new QHBoxLayout(central); m_viewport = new viewport(this); mainLayout->addWidget(m_viewport, 1); QWidget* panel = new QWidget(); panel->setMinimumWidth(200); mainLayout->addWidget(panel); QVBoxLayout* panelLayout = new QVBoxLayout(panel); panelLayout->addWidget(new QLabel("Display levels:")); m_slider = new QSlider(Qt::Horizontal); m_slider->setMinimum(0); m_slider->setMaximum(1); panelLayout->addWidget(m_slider); m_mesh = new QCheckBox("display mesh"); panelLayout->addWidget(m_mesh); m_bbox = new QCheckBox("display bbox"); m_bbox->setChecked(true); panelLayout->addWidget(m_bbox); panelLayout->addWidget(new QWidget(), 1); connect(m_viewport, SIGNAL(render(float)), this, SLOT(render(float))); }
QWidget *QgsAttributeTableDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const { Q_UNUSED( option ); QgsVectorLayer *vl = layer( index.model() ); if ( !vl ) return NULL; int fieldIdx = index.model()->data( index, QgsAttributeTableModel::FieldIndexRole ).toInt(); QWidget *w = QgsAttributeEditor::createAttributeEditor( parent, 0, vl, fieldIdx, index.model()->data( index, Qt::EditRole ) ); if ( parent ) { QgsAttributeTableView *tv = dynamic_cast<QgsAttributeTableView *>( parent->parentWidget() ); w->setMinimumWidth( tv->columnWidth( index.column() ) ); if ( vl->editType( fieldIdx ) == QgsVectorLayer::FileName || vl->editType( fieldIdx ) == QgsVectorLayer::Calendar ) { QLineEdit *le = w->findChild<QLineEdit*>(); le->adjustSize(); w->setMinimumHeight( le->height()*2 ); // FIXME: there must be a better way to do this } } return w; }
MenuItemWidget::MenuItemWidget(QString id, QString title, QWidget *parent) : QWidget(parent), itemId(id) //isChildrenCollapsed(false), { this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); mainLayout = new QHBoxLayout; this->setLayout(mainLayout); itemTitleLabel = new QLabel; itemTitleLabel->setText(title); mainLayout->addWidget(itemTitleLabel); #if 0 QWidget *spacerWidget = new QWidget; spacerWidget->setMinimumWidth(10); spacerWidget->setMaximumWidth(10); mainLayout->addWidget(spacerWidget); spacerWidget->setStyleSheet("background:#bbccbb"); QWidget *contentWidget = new QWidget; QVBoxLayout *contentLayout = new QVBoxLayout; contentWidget->setLayout(contentLayout); mainLayout->addWidget(contentWidget); QWidget *childContainerWidget = new QWidget; childLayout = new QVBoxLayout; childContainerWidget->setLayout(childLayout); contentLayout->addWidget(childContainerWidget); spacerWidget->setContentsMargins(0, 0, 0, 0); contentLayout->setContentsMargins(0, 0, 0, 0); contentLayout->setSpacing(0); contentWidget->setContentsMargins(0, 0, 0, 0); mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); childLayout->setContentsMargins(0, 0, 0, 0); childLayout->setSpacing(0); childContainerWidget->setContentsMargins(0, 0, 0, 0); this->setContentsMargins(0, 0, 0, 0); #endif /* #if 0 this->setMinimumSize(200, 50); this->setMaximumSize(200, 50); #else this->setMinimumSize(0, 0); this->setMaximumSize(0, 0); #endif */ #if 0 // TEST this->setAttribute(Qt::WA_NoSystemBackground, true); #endif }
void GroupSelWidget::sceneChanged() { QSet<QString> groupSet = _scene->getAllGroups(); if(groupSet == _prevGroupSet) return; _prevGroupSet = groupSet; QList<QString> groups = groupSet.toList(); qSort(groups); for(int i = 0; i < (int)_checkBoxes.size(); ++i) delete _checkBoxes[i]; _checkBoxes.clear(); int childWidth = 0; for(int i = 0; i < (int)groups.size(); ++i) { QCheckBox *box = new QCheckBox(groups[i], this); QFont font = box->font(); font.setPointSize(14); box->setFont(font); box->setCheckState(_scene->isGroupVisible(groups[i]) ? Qt::Checked : Qt::Unchecked); new VisibilitySetter(box, _scene, groups[i]); layout()->addWidget(box); childWidth = max(childWidth, box->sizeHint().width()); _checkBoxes.push_back(box); } setMinimumWidth(150); QWidget *scrollArea = parentWidget()->parentWidget()->parentWidget(); scrollArea->setMinimumWidth(childWidth + 20); }
NewsItemWidget::NewsItemWidget(const NewsItemData& Data,QWidget *Parent) : QWidget(Parent), ui(new Ui::NewsItemWidget) { ui->setupUi(this); ui->TitleLabel->setStyleSheet(QString("color : %1;").arg(BUILDER_NEWSLINE_TEXTCOLOR)); ui->DateLabel->setStyleSheet(QString("color : %1;").arg(BUILDER_NEWSLINE_TEXTCOLOR)); ui->TextLabel->setStyleSheet(QString("color : %1;").arg(BUILDER_NEWSLINE_TEXTCOLOR)); ui->TitleLabel->setText(QString("<b>%1</b>").arg(Data.Title)); QDateTime DT = QDateTime::fromString(Data.ISODate,"yyyy-MM-dd'T'hh:mm:ss"); ui->DateLabel->setText(m_Locale.toString(DT)); QString HTMLText = Data.Text; HTMLText.replace(">",">"); HTMLText.replace("<","<"); ui->TextLabel->setText(HTMLText); // to change the color of links, uncomment and use this instead /*ui->TextLabel->setText(QString("<html><head><style type=text/css>" "a:link {color:%1;}" "</style></head><body>%2</body></html>").arg(BUILDER_NEWSLINE_LINKSCOLOR,HTMLText));*/ for (QString Tag : Data.Tags) { QWidget* TagWidget = new QWidget(this); TagWidget->setMinimumWidth(75); QHBoxLayout* TagLayout = new QHBoxLayout(); TagLayout->setSpacing(5); TagLayout->setContentsMargins(0,0,0,0); QString TagLabelText = Tag; TagLabelText.replace(" ","\n"); QLabel* TagLabel = new QLabel(TagLabelText,TagWidget); TagLabel->setWordWrap(true); TagLabel->setStyleSheet(QString("qproperty-alignment: AlignCenter; color : %1; " "background-color : %2 ; border-radius: 4px; padding : 4px; font-size : 9pt;") .arg("white",getCSSColorFromTag(Tag))); TagLayout->addStretch(); TagLayout->addWidget(TagLabel); TagWidget->setLayout(TagLayout); TagWidget->setContentsMargins(0,0,0,0); ui->TagsLayout->addWidget(TagWidget); } ui->TagsLayout->addStretch(); }
TemplateWidget::TemplateWidget(Editor* edit, QWidget *parent) : QWidget(parent) { layout = new QHBoxLayout; stack = new QStackedLayout; label = new QLabel; labelEdit = new QLineEdit; editor = edit; QVBoxLayout *labelLayout = new QVBoxLayout; labelLayout->addWidget(label); labelLayout->addStretch(); QWidget *labelContainer = new QWidget; labelLayout->setContentsMargins(0,MARGIN,0,0); labelContainer->setLayout(labelLayout); QVBoxLayout *editLayout = new QVBoxLayout; editLayout->setContentsMargins(0,0,0,0); editLayout->addWidget(labelEdit); editLayout->addStretch(); QWidget *editContainer = new QWidget; editContainer->setLayout(editLayout); stack->setContentsMargins(0,0,0,0); stack->addWidget(labelContainer); stack->addWidget(editContainer); QWidget *widget = new QWidget; widget->setMaximumWidth(100); widget->setMinimumWidth(100); widget->setLayout(stack); layout->addWidget(widget); edit->setMargins(0, 0, 0, 0); layout->addWidget(edit); layout->setContentsMargins(5,MARGIN,5,0); QWidget::setLayout(layout); setFocusProxy(editor); //edit->configurationAction(toolbar); connect(labelEdit, SIGNAL(textChanged(const QString&)), this, SLOT(updateLabel(const QString&))); isEditing = false; }
// Description: Calculates and sets the geometry of each item in the layout, // based on its set position and the layout's settings and/or width. // void KxGridLayout::doLayout(const QRect &rect) { int x = rect.x(); int y = rect.y(); int currentRow = 1; int currentColumn = 0; for(int i = 0; i < fNumPositions; i++) { currentColumn++; int nextX = x + fCellWidth; // If columnsResizable is set to true, go to the next row if we can't fit the control within the layout's width. // If columnsResizable is set to false, go to the next row if we have reached the specified max number of columns. if((fColumnsResizable && nextX > rect.right() + 1) || (!fColumnsResizable && currentColumn > fNumberOfColumns)) { x = rect.x(); y = y + fCellHeight; nextX = x + fCellWidth; currentRow++; currentColumn = 1; } if(fPositionToItem.contains(i)) { QLayoutItem *item = fPositionToItem[i]; QWidget *w = NULL; if(item && (w = item->widget())) { // We must make sure the widget can actually fit within the allotted cell size. if(w->minimumWidth() > fCellWidth) { w->setMinimumWidth(fCellWidth); } if(w->minimumHeight() > fCellHeight) { w->setMinimumHeight(fCellHeight); } w->setGeometry(QRect(QPoint(x, y), QSize(fCellWidth, fCellHeight))); // Hide the controls that exceed the specified max number of rows // (we've already made sure the max number of columns won't be // exceeded where it matters). if(currentRow > fNumberOfRows) { w->setVisible(false); } else { w->setVisible(true); } } } x = nextX; } }
//esta função centraliza o widget na tela void Funcoes::centralizarWidget(QWidget &widget, bool deixarRedimensionar) { QRect rect = QApplication::desktop()->availableGeometry( &widget ); widget.move( rect.center() - widget.rect().center() ); if( !deixarRedimensionar ) { QRect tamanhoAtual = widget.geometry(); widget.setMaximumHeight( tamanhoAtual.height() ); widget.setMinimumHeight( tamanhoAtual.height() ); widget.setMaximumWidth( tamanhoAtual.width() ); widget.setMinimumWidth( tamanhoAtual.width() ); } }
void RosterScreen::removeUser(QString userID) { bool contains = this->pointerMap.contains(userID); if (contains) { QPushButton* p = (QPushButton*) this->pointerMap.value(userID); this->signalMap->removeMappings(p); p->disconnect(); this->layout->removeWidget(p); delete p; this->pointerMap.remove(userID); this->jabberMap.remove(userID); for (int i = 0; i < this->layout->count(); i++) { QWidget* w = this->layout->itemAt(i)->widget(); w->setMinimumWidth(this->parentWidget()->width()); } } }
SyncView::SyncView(QWidget *parent) :SIView(parent) { setObjectName(QString().sprintf("SyncView%p", parent)); QWidget *centralWidget = new QWidget(this); centralWidget->setObjectName(QString().sprintf("%p", centralWidget)); resize(QApplication::desktop()->width(), QApplication::desktop()->height()); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); setMinimumWidth(QApplication::desktop()->width()); setMinimumHeight(QApplication::desktop()->height()); centralWidget->setStyleSheet(QString("QWidget#%1 { background-image: url(:/images/res/sync_base2.png); }").arg(centralWidget->objectName())); centralWidget->resize(size()); centralWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); centralWidget->setMinimumWidth(QApplication::desktop()->width()); centralWidget->setMinimumHeight(QApplication::desktop()->height()); QWidget *syncTextWidget = new QWidget(centralWidget); syncTextWidget->setObjectName(QString().sprintf("syncTextWidget%p", syncTextWidget)); syncTextWidget->setGeometry(62, 200, 237, 34); syncTextWidget->setStyleSheet(QString("QWidget#%1 { image: url(:/images/res/sync_txt.png); }").arg(syncTextWidget->objectName())); syncTextWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); /* SIButton *skipButton = new SIButton(centralWidget); skipButton->setObjectName(QString().sprintf("skipButton%p", skipButton)); skipButton->setGeometry(150, 565, 171, 52); skipButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); skipButton->setNormalStatePix(":/images/res/test_skip.png"); skipButton->setPressedStatePix(":/images/res/test_skip_on.png"); connect(skipButton, SIGNAL(clicked()), this, SLOT(skipPressed())); */ SIActivityIndicator *spinner = new SIActivityIndicator(":/images/res/general_spinner.gif", centralWidget); spinner->move(164, 334); spinner->start(); /* QTimer *timer = new QTimer(); timer->setInterval(60000); timer->setSingleShot(true); timer->start(); connect(timer, SIGNAL(timeout()), this, SLOT(timeoutSync())); */ connect(&Network::instanceA(), SIGNAL(finished()), this, SLOT(skipPressed())); }
LogoBar::LogoBar(SigSession &session, QWidget *parent) : QToolBar("File Bar", parent), _enable(true), _session(session), _logo_button(this) { setMovable(false); _about = new QAction(this); _about->setText(QApplication::translate( "File", "&About...", 0)); _about->setIcon(QIcon::fromTheme("file", QIcon(":/icons/about.png"))); _about->setObjectName(QString::fromUtf8("actionAbout")); _logo_button.addAction(_about); connect(_about, SIGNAL(triggered()), this, SLOT(on_actionAbout_triggered())); _manual = new QAction(this); _manual->setText(QApplication::translate( "File", "&Manual", 0)); _manual->setIcon(QIcon::fromTheme("file", QIcon(":/icons/manual.png"))); _manual->setObjectName(QString::fromUtf8("actionManual")); _logo_button.addAction(_manual); connect(_manual, SIGNAL(triggered()), this, SLOT(on_actionManual_triggered())); _issue = new QAction(this); _issue->setText(QApplication::translate( "File", "&Bug Report", 0)); _issue->setIcon(QIcon::fromTheme("file", QIcon(":/icons/bug.png"))); _issue->setObjectName(QString::fromUtf8("actionManual")); _logo_button.addAction(_issue); connect(_issue, SIGNAL(triggered()), this, SLOT(on_actionIssue_triggered())); _logo_button.setPopupMode(QToolButton::InstantPopup); _logo_button.setIcon(QIcon(":/icons/logo_noColor.png")); QWidget *spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); addWidget(spacer); addWidget(&_logo_button); QWidget *margin = new QWidget(this); margin->setMinimumWidth(20); addWidget(margin); }
ActionOptionWidget::ActionOptionWidget(CellToolBase* cellTool, const QDomElement& e, QWidget *parent) : QWidget(parent) { QString name = e.attribute("name"); setObjectName(name); setWindowTitle(i18n(name.toLatin1())); QLayout* layout = new GroupFlowLayout(this);//QBoxLayout(QBoxLayout::TopToBottom, this); for (QDomElement group = e.firstChildElement("group"); !group.isNull(); group = group.nextSiblingElement("group")) { QHBoxLayout *groupLayout = new QHBoxLayout(); layout->addItem(groupLayout); // In each group there are a number of actions that will be layouted together. for (QDomElement action = group.firstChildElement("action"); !action.isNull(); action = action.nextSiblingElement("action")) { QString actionName = action.attribute("name"); QAction* a = cellTool->action(actionName); if (!a) { kWarning() << "unknown action" << actionName << "in CellToolOptionWidgets.xml"; continue; } QWidget* w = qobject_cast<QWidgetAction*>(a) ? qobject_cast<QWidgetAction*>(a)->requestWidget(this) : 0; if (w && w->inherits("QFontComboBox")) { w->setMinimumWidth(w->minimumWidth() / 2); } if (!w) { QToolButton* b = new QToolButton(this); b->setFocusPolicy(Qt::NoFocus); b->setDefaultAction(a); w = b; } if (w) { groupLayout->addWidget(w); } } } // The following widget activates a special feature in the // ToolOptionsDocker that makes the components of the widget align // to the top if there is extra space. QWidget *specialSpacer = new QWidget(this); specialSpacer->setObjectName("SpecialSpacer"); layout->addWidget(specialSpacer); }
void RosterScreen::addUser(QString userID, QString userName) { bool contains = this->pointerMap.contains(userID); if (!contains) { QPushButton* b = new QPushButton(); b->setText(userName); connect(b, SIGNAL(clicked()), this->signalMap, SLOT(map())); QString userData = userID + "|" + userName; this->signalMap->setMapping(b, userData); connect(this->signalMap, SIGNAL(mapped(QString)), this, SLOT(monitorUser(QString))); this->layout->addWidget(b); this->pointerMap.insert(userID, b); this->jabberMap.insert(userID, userName); for (int i = 0; i < this->layout->count(); i++) { QWidget* w = this->layout->itemAt(i)->widget(); w->setMinimumWidth(this->parentWidget()->width()); } } }
void ItemView::OnActionSelected(int i) { QWidget *elem; switch(i) { case 1: clear(); elem = new QComboBox(); for(auto building : UnitTypes::Buildings) { ((QComboBox*)elem)->addItem(QString(UnitTypes::ToString(building))); } _elements.push_back(elem); connect(elem, SIGNAL(currentIndexChanged(int)), this, SLOT(OnItemChanged())); elem = new QSpinBox(); _elements.push_back(elem); connect(elem, SIGNAL(valueChanged(int)), this, SLOT(OnItemChanged())); draw(); break; case 2: clear(); elem = new QComboBox(); for(auto unit : UnitTypes::Units) { ((QComboBox*)elem)->addItem(QString(UnitTypes::ToString(unit))); } _elements.push_back(elem); connect(elem, SIGNAL(currentIndexChanged(int)), this, SLOT(OnItemChanged()));\ elem->setMinimumWidth(148); elem = new QSpinBox(); _elements.push_back(elem); connect(elem, SIGNAL(valueChanged(int)), this, SLOT(OnItemChanged())); draw(); break; default: clear(); draw(); break; } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QPushButton *btn1 = new QPushButton("添加"); QPushButton *btn2 = new QPushButton("删除"); QHBoxLayout *btnLayout = new QHBoxLayout; btnLayout->addWidget(btn1); btnLayout->addWidget(btn2); /*添加一个项列表并把它放置于一个DockWidget中*/ m_ListView = new ListView; QVBoxLayout *DWLayout = new QVBoxLayout; DWLayout->setContentsMargins(0,0,0,2); DWLayout->setSpacing(2); DWLayout->addWidget(m_ListView); DWLayout->addLayout(btnLayout); QWidget *DWWidget = new QWidget; DWWidget->setMinimumWidth(250); DWWidget->setLayout(DWLayout); m_indexDWidget = new QDockWidget; m_indexDWidget->setWidget(DWWidget); this->addDockWidget(Qt::LeftDockWidgetArea,m_indexDWidget); /*主布局管理器.*/ QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->setContentsMargins(0,0,0,0); /*主widget*/ QWidget *centerWidget = new QWidget; centerWidget->setContentsMargins(0,0,0,0); centerWidget->setLayout(mainLayout); this->setCentralWidget(centerWidget); this->resize(1280,720); }
KileAbbrevInputDialog::KileAbbrevInputDialog(KileAbbrevView *listview, KListViewItem *item, int mode, const char *name ) : KDialogBase(listview,name, true, i18n("Add Abbreviation"), KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, true), m_listview(listview), m_abbrevItem(item), m_mode(mode) { QWidget *page = new QWidget(this); setMainWidget(page); QVBoxLayout *vl = new QVBoxLayout(page, 0, spacingHint()); if ( m_mode == KileAbbrevView::ALVedit ) { setCaption( i18n("Edit Abbreviation") ); m_abbrev = m_abbrevItem->text(KileAbbrevView::ALVabbrev); m_expansion = m_abbrevItem->text(KileAbbrevView::ALVexpansion); } QLabel *abbrev = new QLabel(i18n("&Abbreviation:"),page); QLabel *expansion = new QLabel(i18n("&Expanded Text:"),page); m_leAbbrev = new KLineEdit(m_abbrev,page); m_leExpansion = new KLineEdit(m_expansion,page); vl->addWidget(abbrev); vl->addWidget(m_leAbbrev); vl->addWidget(expansion); vl->addWidget(m_leExpansion); vl->addSpacing(8); abbrev->setBuddy(m_leAbbrev); expansion->setBuddy(m_leExpansion); QRegExp reg("[a-zA-Z0-9]+"); QRegExpValidator *abbrevValidator = new QRegExpValidator(reg,this); m_leAbbrev->setValidator(abbrevValidator); connect(m_leAbbrev,SIGNAL(textChanged(const QString &)), this,SLOT(slotTextChanged(const QString &))); connect(m_leExpansion,SIGNAL(textChanged(const QString &)), this,SLOT(slotTextChanged(const QString &))); slotTextChanged(QString::null); m_leAbbrev->setFocus(); page->setMinimumWidth(350); }
int main(int argc, char **argv) { QApplication app(argc, argv); Window *d3dw = new Window; QWidget w; QVBoxLayout *vl = new QVBoxLayout; vl->addWidget(new QPushButton("Widgets + a native child window with D3D12")); vl->addWidget(new QLabel("Like hellotexture but this time the mipmaps are generated via a compute shader")); QWidget *ww = QWidget::createWindowContainer(d3dw); ww->setMinimumWidth(200); ww->setMinimumHeight(200); vl->addWidget(ww); vl->setStretchFactor(ww, 1.0f); w.resize(800, 800); w.setLayout(vl); w.show(); return app.exec(); }
// Grid layout of color swatches SeExprEdColorSwatchWidget::SeExprEdColorSwatchWidget(bool indexLabel, QWidget* parent) : QWidget(parent), _columns(8), _indexLabel(indexLabel) { QHBoxLayout *hboxLayout = new QHBoxLayout(); hboxLayout->setContentsMargins(0,0,0,0); setLayout(hboxLayout); QPushButton *addBtn = new QPushButton("+"); addBtn->setFixedWidth(16); addBtn->setFixedHeight(16); QVBoxLayout *swatchControlLayout = new QVBoxLayout(); swatchControlLayout->setContentsMargins(0,0,0,0); QHBoxLayout *addRemoveBtnLayout = new QHBoxLayout(); addRemoveBtnLayout->setContentsMargins(0,0,0,0); addRemoveBtnLayout->setSpacing(0); addRemoveBtnLayout->addWidget(addBtn); swatchControlLayout->addLayout(addRemoveBtnLayout); swatchControlLayout->addStretch(); QHBoxLayout *paletteLayout = new QHBoxLayout(); paletteLayout->setContentsMargins(0,0,0,0); QWidget *colorGrid = new QWidget(); colorGrid->setMinimumWidth(256); _gridLayout = new QGridLayout(); _gridLayout->setContentsMargins(0,0,0,0); _gridLayout->setSpacing(0); paletteLayout->addLayout(_gridLayout); paletteLayout->addStretch(); colorGrid->setLayout(paletteLayout); hboxLayout->addWidget(colorGrid); hboxLayout->addLayout(swatchControlLayout); hboxLayout->addStretch(); // SIGNALS connect(addBtn, SIGNAL(clicked()), this, SLOT(addNewColor())); }
GroupTab::GroupTab(QWidget *parent) : Tab(parent){ // Populate online list container QWidget *onlineContainer = new QWidget; QLayout *onlineContainerLayout = new QVBoxLayout(); online = new QListWidget; online->setSortingEnabled(true); onlineContainer->setMinimumWidth(50); onlineContainer->setMaximumWidth(175); onlineContainerLayout->addWidget(new QLabel("Online:")); onlineContainerLayout->addWidget(online); onlineContainerLayout->setMargin(0); onlineContainerLayout->setSpacing(2); onlineContainer->setLayout(onlineContainerLayout); // Enable double clicking on list items to message peer connect(online,SIGNAL(itemDoubleClicked(QListWidgetItem*)),parent,SLOT(startPeerChat(QListWidgetItem*))); outputSplitter->addWidget(onlineContainer); outputSplitter->setStretchFactor(0,7); outputSplitter->setStretchFactor(1,3); // Set base hue hueSeed = 0; }
int Dialog::showDialog(const QString& view, QObject* viewModel, int type) { QDialog* dialog = NULL; QMainWindow* mainWindow = NULL; QWidget* windowWidget = NULL; QWidget* layoutWidget = NULL; switch (type) { case Dialog::MainWindow: mainWindow = new QMainWindow(); windowWidget = mainWindow; layoutWidget = new QWidget(windowWidget); mainWindow->setCentralWidget(layoutWidget); break; case Dialog::ModalDialog: dialog = new QDialog(QApplication::activeWindow()); windowWidget = dialog; layoutWidget = dialog; break; default: dialog = new QDialog(); windowWidget = dialog; layoutWidget = dialog; break; } QGridLayout* layout = new QGridLayout(layoutWidget); // Create view QDeclarativeView* v = new QDeclarativeView(layoutWidget); if (viewModel) { int count = viewModel->metaObject()->propertyCount(); for (int i = 0; i < count; ++i) { QMetaProperty p = viewModel->metaObject()->property(i); if (p.isReadable() && p.typeName() == QString("QDeclarativeImageProvider*")) { QString name = p.name(); QDeclarativeImageProvider* value = p.read(viewModel).value<QDeclarativeImageProvider*>(); v->engine()->addImageProvider(name.toLatin1(), new ProxyImageProvider(value)); } } v->rootContext()->setContextProperty("dataContext", viewModel); } QString path; foreach (path, importPaths) v->engine()->addImportPath(path); foreach (path, pluginPaths) v->engine()->addPluginPath(path); v->setSource(QUrl(view)); v->setResizeMode(QDeclarativeView::SizeRootObjectToView); // Initialize dialog QGraphicsObject* root = v->rootObject(); QVariant property = root->property("dialogTitle"); if (property.isValid()) windowWidget->setWindowTitle(property.toString()); property = root->property("dialogMinWidth"); if (property.isValid()) layoutWidget->setMinimumWidth(property.toInt()); property = root->property("dialogMinHeight"); if (property.isValid()) layoutWidget->setMinimumHeight(property.toInt()); property = root->property("dialogMaxWidth"); if (property.isValid()) layoutWidget->setMaximumWidth(property.toInt()); property = root->property("dialogMaxHeight"); if (property.isValid()) layoutWidget->setMaximumHeight(property.toInt()); property = root->property("dialogResizable"); if (property.isValid() && !property.toBool()) layout->setSizeConstraint(QLayout::SetFixedSize); Qt::WindowStates states = windowWidget->windowState(); Qt::WindowFlags flags = windowWidget->windowFlags(); property = root->property("dialogMinimizeButton"); if (property.isValid()) flags = property.toBool() ? flags | Qt::WindowMinimizeButtonHint : flags & ~Qt::WindowMinimizeButtonHint; property = root->property("dialogMaximizeButton"); if (property.isValid()) flags = property.toBool() ? flags | Qt::WindowMaximizeButtonHint : flags & ~Qt::WindowMaximizeButtonHint; property = root->property("dialogCloseButton"); if (property.isValid()) flags = property.toBool() ? flags | Qt::WindowCloseButtonHint : flags & ~Qt::WindowCloseButtonHint; property = root->property("dialogFullScreen"); if (property.isValid()) states = property.toBool() ? states | Qt::WindowFullScreen : states & ~Qt::WindowFullScreen; flags = flags & ~Qt::WindowContextHelpButtonHint; windowWidget->setWindowFlags(flags); windowWidget->setWindowState(states); property = root->property("dialogToolBar"); if (type == Dialog::MainWindow && property.isValid() && property.typeName() == QString("QDeclarativeListProperty<QDeclarativeItem>")) { QToolBar* toolbar = new QToolBar(mainWindow); toolbar->setMovable(false); toolbar->setFloatable(false); toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); toolbar->setAllowedAreas(Qt::TopToolBarArea); QDeclarativeListProperty<QDeclarativeItem> btnList = property.value< QDeclarativeListProperty<QDeclarativeItem> >(); int btnCount = btnList.count(&btnList); for (int i = 0; i < btnCount; ++i) { QDeclarativeItem* item = btnList.at(&btnList, i); if (!item->property("text").isValid()) continue; QString itemText = item->property("text").toString(); QString itemTooltip = item->property("tooltip").isValid() ? item->property("tooltip").toString() : ""; QString itemIconSource = item->property("iconSource").isValid() ? item->property("iconSource").toString() : ""; int itemIconSize = item->property("iconSize").isValid() ? item->property("iconSize").toInt() : -1; if (itemText == "|") { toolbar->addSeparator(); } else if (itemText == "-") { QWidget* spacer = new QWidget(); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); toolbar->addWidget(spacer); } else { QAction* action = new QAction(mainWindow); action->setText(itemText); action->setToolTip(itemTooltip); action->setIcon(QIcon(itemIconSource)); QObject::connect(action, SIGNAL(triggered()), item, SLOT(trigger())); if (item->property("enabled").isValid()) new PropertyBinding(action, "enabled", item, "enabled", PropertyBinding::OneWay, NULL, this); if (item->property("visible").isValid()) new PropertyBinding(action, "visible", item, "visible", PropertyBinding::OneWay, NULL, this); toolbar->addAction(action); } if (itemIconSize != -1) toolbar->setIconSize(QSize(itemIconSize, itemIconSize)); } mainWindow->setUnifiedTitleAndToolBarOnMac(true); mainWindow->addToolBar(toolbar); } property = root->property("dialogMenu"); if (type == Dialog::MainWindow && property.isValid() && property.typeName() == QString("QDeclarativeListProperty<QDeclarativeItem>")) { QDeclarativeListProperty<QDeclarativeItem> list = property.value< QDeclarativeListProperty<QDeclarativeItem> >(); int count = list.count(&list); for (int i = 0; i < count; ++i) { QDeclarativeItem* item = list.at(&list, i); if (!item->property("text").isValid()) continue; QString itemText = item->property("text").toString(); QMenu * menuItem = mainWindow->menuBar()->addMenu(itemText); if (!item->property("submenu").isValid() || item->property("submenu").typeName() != QString("QDeclarativeListProperty<QDeclarativeItem>")) continue; QDeclarativeListProperty<QDeclarativeItem> innerList = item->property("submenu").value< QDeclarativeListProperty<QDeclarativeItem> >(); int innerCount = innerList.count(&innerList); for (int j = 0; j < innerCount; ++j) { QDeclarativeItem* innerItem = innerList.at(&innerList, j); if (!innerItem->property("text").isValid()) continue; QString innerItemText = innerItem->property("text").toString(); QString innerItemShortcut = innerItem->property("shortcut").isValid() ? innerItem->property("shortcut").toString() : ""; QString innerItemIconSource = innerItem->property("iconSource").isValid() ? innerItem->property("iconSource").toString() : ""; if (innerItemText == "-") { menuItem->addSeparator(); } else { QAction * action = menuItem->addAction(QIcon(innerItemIconSource), innerItemText); action->setShortcut(QKeySequence(innerItemShortcut)); QObject::connect(action, SIGNAL(triggered()), innerItem, SLOT(trigger())); if (innerItem->property("enabled").isValid()) new PropertyBinding(action, "enabled", innerItem, "enabled", PropertyBinding::OneWay, NULL, this); if (innerItem->property("visible").isValid()) new PropertyBinding(action, "visible", innerItem, "visible", PropertyBinding::OneWay, NULL, this); } } } } new DialogCallbacks(windowWidget, v, root); // Initialize layout layout->setMargin(0); layout->addWidget(v, 0, 0); // Execute switch (type) { case Dialog::ModalDialog: dialog->exec(); break; case Dialog::MainWindow: { if (mainWindowGeometry.isEmpty()) { mainWindow->adjustSize(); mainWindow->move(QApplication::desktop()->screen()->rect().center() - mainWindow->rect().center()); } else mainWindow->restoreGeometry(mainWindowGeometry); } default: windowWidget->setAttribute(Qt::WA_DeleteOnClose); windowWidget->show(); break; } int result = 0; property = root->property("dialogResult"); if (property.isValid()) result = property.toInt(); if (type == Dialog::ModalDialog) delete dialog; return result; }
void ChartDialog::createControls() { logMessage("ChartDialog::createControls()"); chart = new Chart(this); // controls QWidget *controls = new QWidget(this); QPushButton *btnPlot = new QPushButton(controls); btnPlot->setText(tr("Plot")); connect(btnPlot, SIGNAL(clicked()), this, SLOT(doPlot())); QPushButton *btnSaveImage = new QPushButton(controls); btnSaveImage->setText(tr("Save image")); connect(btnSaveImage, SIGNAL(clicked()), SLOT(doSaveImage())); QPushButton *btnExportData = new QPushButton(controls); btnExportData->setText(tr("Export")); connect(btnExportData, SIGNAL(clicked()), SLOT(doExportData())); // geometry lblStartX = new QLabel("X:"); lblStartY = new QLabel("Y:"); lblEndX = new QLabel("X:"); lblEndY = new QLabel("Y:"); txtStartX = new ValueLineEdit(); txtStartY = new ValueLineEdit(); txtEndX = new ValueLineEdit(); txtEndY = new ValueLineEdit(); connect(txtStartX, SIGNAL(editingFinished()), this, SLOT(doChartLine())); connect(txtStartY, SIGNAL(editingFinished()), this, SLOT(doChartLine())); connect(txtEndX, SIGNAL(editingFinished()), this, SLOT(doChartLine())); connect(txtEndY, SIGNAL(editingFinished()), this, SLOT(doChartLine())); // start QGridLayout *layoutStart = new QGridLayout(); layoutStart->addWidget(lblStartX, 0, 0); layoutStart->addWidget(txtStartX, 0, 1); layoutStart->addWidget(lblStartY, 1, 0); layoutStart->addWidget(txtStartY, 1, 1); QGroupBox *grpStart = new QGroupBox(tr("Start"), this); grpStart->setLayout(layoutStart); // end QGridLayout *layoutEnd = new QGridLayout(); layoutEnd->addWidget(lblEndX, 0, 0); layoutEnd->addWidget(txtEndX, 0, 1); layoutEnd->addWidget(lblEndY, 1, 0); layoutEnd->addWidget(txtEndY, 1, 1); QGroupBox *grpEnd = new QGroupBox(tr("End"), this); grpEnd->setLayout(layoutEnd); // angle txtAngle = new ValueLineEdit(); connect(txtAngle, SIGNAL(editingFinished()), this, SLOT(doChartLine())); QHBoxLayout *layoutAngle = new QHBoxLayout(); layoutAngle->addWidget(new QLabel("Angle")); layoutAngle->addWidget(txtAngle); QGroupBox *grpAngle = new QGroupBox(tr("Angle"), this); grpAngle->setLayout(layoutAngle); // x - axis radAxisLength = new QRadioButton(tr("Length"), this); radAxisLength->setChecked(true); radAxisX = new QRadioButton("X", this); radAxisY = new QRadioButton("Y", this); QButtonGroup *axisGroup = new QButtonGroup(this); axisGroup->addButton(radAxisLength); axisGroup->addButton(radAxisX); axisGroup->addButton(radAxisY); connect(radAxisLength, SIGNAL(clicked()), this, SLOT(doPlot())); connect(radAxisX, SIGNAL(clicked()), this, SLOT(doPlot())); connect(radAxisY, SIGNAL(clicked()), this, SLOT(doPlot())); // axis QHBoxLayout *layoutAxis = new QHBoxLayout(this); layoutAxis->addWidget(radAxisLength); layoutAxis->addWidget(radAxisX); layoutAxis->addWidget(radAxisY); QGroupBox *grpAxis = new QGroupBox(tr("Horizontal axis"), this); grpAxis->setLayout(layoutAxis); // axis points and time step txtAxisPoints = new QSpinBox(this); txtAxisPoints->setMinimum(2); txtAxisPoints->setMaximum(500); txtAxisPoints->setValue(200); chkAxisPointsReverse = new QCheckBox(tr("Reverse")); connect(chkAxisPointsReverse, SIGNAL(clicked()), this, SLOT(doPlot())); // timestep cmbTimeStep = new QComboBox(this); connect(cmbTimeStep, SIGNAL(currentIndexChanged(int)), this, SLOT(doTimeStepChanged(int))); QGridLayout *layoutAxisPointsAndTimeStep = new QGridLayout(); layoutAxisPointsAndTimeStep->addWidget(new QLabel(tr("Points:")), 0, 0); layoutAxisPointsAndTimeStep->addWidget(txtAxisPoints, 0, 1); layoutAxisPointsAndTimeStep->addWidget(chkAxisPointsReverse, 0, 2); layoutAxisPointsAndTimeStep->addWidget(new QLabel(tr("Time step:")), 1, 0); layoutAxisPointsAndTimeStep->addWidget(cmbTimeStep, 1, 1, 1, 2); QGroupBox *grpAxisPointsAndTimeStep = new QGroupBox(tr("Points and time step"), this); grpAxisPointsAndTimeStep->setLayout(layoutAxisPointsAndTimeStep); // time lblPointX = new QLabel("X:"); lblPointY = new QLabel("Y:"); txtPointX = new ValueLineEdit(); txtPointY = new ValueLineEdit(); QGridLayout *layoutTime = new QGridLayout(); layoutTime->addWidget(lblPointX, 0, 0); layoutTime->addWidget(txtPointX, 0, 1); layoutTime->addWidget(lblPointY, 1, 0); layoutTime->addWidget(txtPointY, 1, 1); QGroupBox *grpTime = new QGroupBox(tr("Point"), this); grpTime->setLayout(layoutTime); // plot // variable cmbFieldVariable = new QComboBox(this); connect(cmbFieldVariable, SIGNAL(currentIndexChanged(int)), this, SLOT(doFieldVariable(int))); // component cmbFieldVariableComp = new QComboBox(this); connect(cmbFieldVariableComp, SIGNAL(currentIndexChanged(int)), this, SLOT(doFieldVariableComp(int))); doFieldVariable(cmbFieldVariable->currentIndex()); QFormLayout *layoutVariable = new QFormLayout(this); layoutVariable->addRow(tr("Variable:"), cmbFieldVariable); layoutVariable->addRow(tr("Component:"), cmbFieldVariableComp); QWidget *grpVariable = new QWidget(this); grpVariable->setLayout(layoutVariable); // table trvTable = new QTableWidget(this); // button bar QHBoxLayout *layoutButton = new QHBoxLayout(); layoutButton->addStretch(); layoutButton->addWidget(btnPlot); layoutButton->addWidget(btnSaveImage); layoutButton->addWidget(btnExportData); QWidget *widButton = new QWidget(this); widButton->setLayout(layoutButton); // controls geometry widGeometry = new QWidget(this); QVBoxLayout *controlsGeometryLayout = new QVBoxLayout(); widGeometry->setLayout(controlsGeometryLayout); controlsGeometryLayout->addWidget(grpStart); controlsGeometryLayout->addWidget(grpEnd); controlsGeometryLayout->addWidget(grpAngle); controlsGeometryLayout->addWidget(grpAxis); controlsGeometryLayout->addWidget(grpAxisPointsAndTimeStep); controlsGeometryLayout->addStretch(); // controls time widTime = new QWidget(this); QVBoxLayout *controlsTimeLayout = new QVBoxLayout(); widTime->setLayout(controlsTimeLayout); controlsTimeLayout->addWidget(grpTime); controlsTimeLayout->addStretch(); tabAnalysisType = new QTabWidget(this); tabAnalysisType->addTab(widGeometry, icon(""), tr("Geometry")); tabAnalysisType->addTab(widTime, icon(""), tr("Time")); // controls QVBoxLayout *controlsLayout = new QVBoxLayout(); controls->setLayout(controlsLayout); controls->setMinimumWidth(280); controlsLayout->addWidget(tabAnalysisType); controlsLayout->addWidget(grpVariable); controlsLayout->addStretch(); controlsLayout->addWidget(widButton); // tab data widget tabOutput = new QTabWidget(this); tabOutput->addTab(chart, icon(""), tr("Chart")); tabOutput->addTab(trvTable, icon(""), tr("Table")); // main layout QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(controls); layout->addWidget(tabOutput, 1); // chart picker picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPicker::PointSelection | QwtPicker::DragSelection, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, chart->canvas()); picker->setRubberBandPen(QColor(Qt::green)); picker->setRubberBand(QwtPicker::CrossRubberBand); picker->setTrackerMode(QwtPicker::ActiveOnly); picker->setTrackerPen(QColor(Qt::black)); connect(picker, SIGNAL(moved(const QPoint &)), SLOT(doMoved(const QPoint &))); setLayout(layout); }
ToolInstance::ToolInstance(QString filename, ToolInformation information, mcrl2::gui::qt::PersistentFileDialog* fileDialog, QWidget *parent) : QWidget(parent), m_filename(filename), m_info(information), m_fileDialog(fileDialog) { m_ui.setupUi(this); connect(this, SIGNAL(colorChanged(QColor)), this, SLOT(onColorChanged(QColor))); connect(&m_process, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(onStateChange(QProcess::ProcessState))); connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(onStandardOutput())); connect(&m_process, SIGNAL(readyReadStandardError()), this, SLOT(onStandardError())); connect(m_ui.btnRun, SIGNAL(clicked()), this, SLOT(onRun())); connect(m_ui.btnAbort, SIGNAL(clicked()), this, SLOT(onAbort())); connect(m_ui.btnSave, SIGNAL(clicked()), this, SLOT(onSave())); connect(m_ui.btnClear, SIGNAL(clicked()), m_ui.edtOutput, SLOT(clear())); QFileInfo fileInfo(filename); m_process.setWorkingDirectory(fileInfo.absoluteDir().absolutePath()); m_ui.lblDirectoryValue->setText(fileInfo.absoluteDir().absolutePath()); m_ui.lblFileValue->setText(fileInfo.fileName()); if (m_info.hasOutput()) { QDir dir = fileInfo.absoluteDir(); QString newfile = fileInfo.baseName().append(".%1").arg(m_info.output); int filenr = 0; while(dir.exists(newfile)) { filenr++; newfile = fileInfo.baseName().append("_%1.%2").arg(filenr).arg(m_info.output); } m_pckFileOut = new FilePicker(m_fileDialog, m_ui.pckFileOut); m_ui.pckFileOut->layout()->addWidget(m_pckFileOut); m_pckFileOut->setText(newfile); } else { m_pckFileOut = NULL; m_ui.lblFileOut->setVisible(false); m_ui.pckFileOut->setVisible(false); } if (m_info.hasSecondInput()) { m_pckFileIn = new FilePicker(m_fileDialog, m_ui.pckFileIn, false); m_ui.pckFileIn->layout()->addWidget(m_pckFileIn); } else { m_pckFileIn = NULL; m_ui.lblFileIn->setVisible(false); m_ui.pckFileIn->setVisible(false); } QFormLayout *formLayout = new QFormLayout(); formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); for (int i = 0; i < m_info.options.count(); i++) { ToolOption option = m_info.options.at(i); QWidget *nameOpt = NULL; QCheckBox* cbOpt = NULL; QVBoxLayout *lytOpt = new QVBoxLayout(); if (option.argument.type == EnumArgument) { nameOpt = new QLabel("<b>"+option.nameLong+": </b>"); } else { cbOpt = new QCheckBox(option.nameLong + ": ", this); cbOpt->setChecked(option.standard); QFont font(cbOpt->font()); font.setBold(true); cbOpt->setFont(font); nameOpt = cbOpt; } formLayout->addRow(nameOpt, lytOpt); QLabel *lblOpt = new QLabel(option.description, this); lblOpt->setAlignment(Qt::AlignJustify | Qt::AlignTop); lblOpt->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); lblOpt->setWordWrap(true); lytOpt->addWidget(lblOpt); if (!option.hasArgument()) { m_optionValues.append(new OptionValue(option, cbOpt)); } else { switch (option.argument.type) { case StringArgument: case LevelArgument: case IntegerArgument: case RealArgument: case BooleanArgument: { QHBoxLayout *lytArg = new QHBoxLayout(); lytArg->setSpacing(6); QWidget *edtArg = NULL; switch (option.argument.type) { case LevelArgument: { QLineEdit *edtLdt = new QLineEdit("verbose", this); m_optionValues.append(new OptionValue(option, cbOpt, edtLdt)); edtArg = edtLdt; } break; case IntegerArgument: { QSpinBox *edtSpb = new QSpinBox(this); edtSpb->setRange(std::numeric_limits<int>::min(), std::numeric_limits<int>::max()); if (option.argument.optional) { QCheckBox *cbOptional = new QCheckBox(this); lytArg->addWidget(cbOptional); m_optionValues.append(new OptionValue(option, cbOpt, edtSpb, cbOptional)); } else { m_optionValues.append(new OptionValue(option, cbOpt, edtSpb)); } edtArg = edtSpb; } break; case RealArgument: { QDoubleSpinBox *edtSpb = new QDoubleSpinBox(this); edtSpb->setRange(std::numeric_limits<double>::min(), std::numeric_limits<double>::max()); if (option.argument.optional) { QCheckBox *cbOptional = new QCheckBox(this); lytArg->addWidget(cbOptional); m_optionValues.append(new OptionValue(option, cbOpt, edtSpb, cbOptional)); } else { m_optionValues.append(new OptionValue(option, cbOpt, edtSpb)); } edtArg = edtSpb; } break; case BooleanArgument: { QCheckBox *edtChb = new QCheckBox("Yes", this); m_optionValues.append(new OptionValue(option, cbOpt, edtChb)); edtArg = edtChb; } break; case StringArgument: default: { QLineEdit *edtLdt = new QLineEdit(this); m_optionValues.append(new OptionValue(option, cbOpt, edtLdt)); edtArg = edtLdt; } break; } edtArg->setMinimumWidth(300); lytArg->addWidget(edtArg); if (!option.argument.optional && option.argument.type != BooleanArgument) { QLabel *lblReq = new QLabel("*", this); lytArg->addWidget(lblReq); } QSpacerItem *spacer = new QSpacerItem(100, 20, QSizePolicy::Expanding); lytArg->addItem(spacer); lytOpt->addLayout(lytArg); } break; case FileArgument: { QHBoxLayout *lytArg = new QHBoxLayout(); lytArg->setSpacing(6); FilePicker *edtArg = new FilePicker(m_fileDialog, this, false); lytArg->addWidget(edtArg); m_optionValues.append(new OptionValue(option, cbOpt, edtArg)); if (!option.argument.optional) { QLabel *lblReq = new QLabel("*", this); lytArg->addWidget(lblReq); } QSpacerItem *spacer = new QSpacerItem(100, 20, QSizePolicy::Expanding); lytArg->addItem(spacer); lytOpt->addLayout(lytArg); } break; case EnumArgument: { QFormLayout *lytValues = new QFormLayout(); lytValues->setSpacing(6); QButtonGroup *grpValues = new QButtonGroup(this); for (int j = 0; j < option.argument.values.count(); j++) { ToolValue val = option.argument.values.at(j); QRadioButton *rbVal = new QRadioButton(val.nameLong, this); rbVal->setChecked(val.standard); grpValues->addButton(rbVal); QLabel *lblVal = new QLabel(val.description, this); lblVal->setWordWrap(true); lytValues->addRow(rbVal, lblVal); } m_optionValues.append(new OptionValue(option, cbOpt, grpValues)); lytOpt->addLayout(lytValues); } break; default: break; } } } m_ui.scrollWidget->setLayout(formLayout); }
QLayout *ZWidgetsGroup::createLayout(QMainWindow *mainWin, bool createBasic) { switch (m_type) { case WIDGET: { QHBoxLayout *hbl = new QHBoxLayout; hbl->addWidget(m_widget); return hbl; } case PARAMETER: { QHBoxLayout *hbl = new QHBoxLayout; if (dynamic_cast<Z3DCameraParameter*>(m_parameter)) { QWidget* wg = m_parameter->createWidget(); hbl->addWidget(wg); return hbl; } m_parameter->setMainWindow(mainWin); QLabel *label = m_parameter->createNameLabel(); label->setMinimumWidth(125); label->setWordWrap(true); hbl->addWidget(label); QWidget* wg = m_parameter->createWidget(); wg->setMinimumWidth(125); wg->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); hbl->addWidget(wg); return hbl; } default: /*case GROUP:*/ { QVBoxLayout *vbl = new QVBoxLayout; if (!m_isSorted) sortChildGroups(); if (createBasic) { int i; for (i=0; i<m_childGroups.size() && m_childGroups[i]->m_visibleLevel <= m_cutOffbetweenBasicAndAdvancedLevel; i++) { QLayout *lw = m_childGroups[i]->createLayout(mainWin, true); if (m_childGroups[i]->isGroup()) { QGroupBox *groupBox = new QGroupBox(m_childGroups[i]->getGroupName()); groupBox->setLayout(lw); vbl->addWidget(groupBox); } else vbl->addLayout(lw); } if (i<m_childGroups.size()) { QPushButton *pb = new QPushButton("Advanced..."); pb->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); vbl->addWidget(pb, 0, Qt::AlignHCenter | Qt::AlignVCenter); connect(pb, SIGNAL(clicked()), this, SLOT(emitRequestAdvancedWidgetSignal())); } } else { for (int i=0; i<m_childGroups.size(); i++) { QLayout *lw = m_childGroups[i]->createLayout(mainWin, false); if (m_childGroups[i]->isGroup()) { QGroupBox *groupBox = new QGroupBox(m_childGroups[i]->getGroupName()); groupBox->setLayout(lw); vbl->addWidget(groupBox); } else vbl->addLayout(lw); } } return vbl; } } }
MusicPage::MusicPage(QWidget *parent) : QWidget(parent) { this->setAttribute(Qt::WA_TranslucentBackground, true);//设置透明:窗体标题栏不透明,背景透明 QHBoxLayout *controlLayout = new QHBoxLayout; addButton = new QPushButton("添加"); addButton->setFixedHeight(22); controlLayout->addWidget(addButton); controlLayout->setSpacing(1); controlLayout->setMargin(0); connect(addButton, SIGNAL(clicked(bool)), this, SIGNAL(addMusics())); QWidget *controlBar = new QWidget; controlBar->setStyleSheet("background:rgba(244,244,244,40%);"); //controlBar->setAttribute(Qt::WA_TranslucentBackground, true); controlBar->setFixedHeight(22); controlBar->setLayout(controlLayout); QPushButton *addList = new QPushButton("+创建列表"); addList->setStyleSheet("background:rgba(244,244,244,40%);"); listList = new ListList; connect(addList, SIGNAL(clicked(bool)), listList, SLOT(wantToCreateList())); connect(listList, SIGNAL(tryToCreateList(QString)), this, SIGNAL(tryToCreateList(QString))); connect(this, SIGNAL(createList(QString)), listList, SLOT(createList(QString))); connect(this, SIGNAL(createList(QString)), this, SLOT(createList())); connect(listList, SIGNAL(changeList(int)), this, SLOT(changeMusicList(int))); connect(listList, SIGNAL(deleteList(QString)), this, SIGNAL(deleteList(QString))); connect(listList, SIGNAL(deleteList(int)), this, SLOT(deleteList(int))); QVBoxLayout *leftLayout = new QVBoxLayout; leftLayout->addWidget(addList); leftLayout->addWidget(listList); leftLayout->setSpacing(1); leftLayout->setMargin(0); QWidget *leftWidget = new QWidget; leftWidget->setLayout(leftLayout); //leftWidget->setFixedWidth(80); leftWidget->setMinimumWidth(80); leftWidget->setMaximumWidth(120); musicLists = new QStackedWidget; musicLists->setMinimumWidth(80); musicLists->setMaximumWidth(420); QSplitter *splitter = new QSplitter(Qt::Horizontal, this); splitter->setOpaqueResize(true); splitter->setChildrenCollapsible(false); splitter->addWidget(leftWidget); splitter->addWidget(musicLists); splitter->setStretchFactor(0, 2); splitter->setStretchFactor(1, 5); splitter->setStyleSheet("QSplitter::handle { background-color: rgba(0,0,0,0%) }"); splitter->setHandleWidth(1); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(controlBar); //mainLayout->addLayout(midLayout); mainLayout->addWidget(splitter); mainLayout->setSpacing(1); mainLayout->setMargin(1); this->setLayout(mainLayout); }
void DkGeneralPreference::createLayout() { // color settings DkColorChooser* highlightColorChooser = new DkColorChooser(QColor(0, 204, 255), tr("Highlight Color"), this); highlightColorChooser->setObjectName("highlightColor"); highlightColorChooser->setColor(&Settings::param().display().highlightColor); connect(highlightColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel())); DkColorChooser* iconColorChooser = new DkColorChooser(QColor(219, 89, 2, 255), tr("Icon Color"), this); iconColorChooser->setObjectName("iconColor"); iconColorChooser->setColor(&Settings::param().display().iconColor); connect(iconColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel())); DkColorChooser* bgColorChooser = new DkColorChooser(QColor(100, 100, 100, 255), tr("Background Color"), this); bgColorChooser->setObjectName("backgroundColor"); bgColorChooser->setColor(&Settings::param().display().bgColor); connect(bgColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel())); DkColorChooser* fullscreenColorChooser = new DkColorChooser(QColor(86,86,90), tr("Fullscreen Color"), this); fullscreenColorChooser->setObjectName("fullscreenColor"); fullscreenColorChooser->setColor(&Settings::param().slideShow().backgroundColor); connect(fullscreenColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel())); DkColorChooser* fgdHUDColorChooser = new DkColorChooser(QColor(255, 255, 255, 255), tr("HUD Foreground Color"), this); fgdHUDColorChooser->setObjectName("fgdHUDColor"); fgdHUDColorChooser->setColor(&Settings::param().display().hudFgdColor); connect(fgdHUDColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel())); DkColorChooser* bgHUDColorChooser = new DkColorChooser(QColor(0, 0, 0, 100), tr("HUD Background Color"), this); bgHUDColorChooser->setObjectName("bgHUDColor"); bgHUDColorChooser->setColor((Settings::param().app().appMode == DkSettings::mode_frameless) ? &Settings::param().display().bgColorFrameless : &Settings::param().display().hudBgColor); connect(bgHUDColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel())); DkGroupWidget* colorGroup = new DkGroupWidget(tr("Color Settings"), this); colorGroup->addWidget(highlightColorChooser); colorGroup->addWidget(iconColorChooser); colorGroup->addWidget(bgColorChooser); colorGroup->addWidget(fullscreenColorChooser); colorGroup->addWidget(fgdHUDColorChooser); colorGroup->addWidget(bgHUDColorChooser); // default pushbutton QPushButton* defaultSettings = new QPushButton(tr("Reset All Settings")); defaultSettings->setObjectName("defaultSettings"); defaultSettings->setMaximumWidth(300); DkGroupWidget* defaultGroup = new DkGroupWidget(tr("Default Settings"), this); defaultGroup->addWidget(defaultSettings); // the left column (holding all color settings) QWidget* leftColumn = new QWidget(this); leftColumn->setMinimumWidth(400); QVBoxLayout* leftColumnLayout = new QVBoxLayout(leftColumn); leftColumnLayout->setAlignment(Qt::AlignTop); leftColumnLayout->addWidget(colorGroup); leftColumnLayout->addWidget(defaultGroup); // checkboxes QCheckBox* cbRecentFiles = new QCheckBox(tr("Show Recent Files on Start-Up"), this); cbRecentFiles->setObjectName("showRecentFiles"); cbRecentFiles->setToolTip(tr("Show the History Panel on Start-Up")); cbRecentFiles->setChecked(Settings::param().app().showRecentFiles); QCheckBox* cbLogRecentFiles = new QCheckBox(tr("Log Recent Files"), this); cbLogRecentFiles->setObjectName("logRecentFiles"); cbLogRecentFiles->setToolTip(tr("If checked, recent files will be saved.")); cbLogRecentFiles->setChecked(Settings::param().global().logRecentFiles); QCheckBox* cbLoopImages = new QCheckBox(tr("Loop Images"), this); cbLoopImages->setObjectName("loopImages"); cbLoopImages->setToolTip(tr("Start with the first image in a folder after showing the last.")); cbLoopImages->setChecked(Settings::param().global().loop); QCheckBox* cbZoomOnWheel = new QCheckBox(tr("Mouse Wheel Zooms"), this); cbZoomOnWheel->setObjectName("zoomOnWheel"); cbZoomOnWheel->setToolTip(tr("If checked, the mouse wheel zooms - otherwise it is used to switch between images.")); cbZoomOnWheel->setChecked(Settings::param().global().zoomOnWheel); QCheckBox* cbDoubleClickForFullscreen = new QCheckBox(tr("Double Click Opens Fullscreen"), this); cbDoubleClickForFullscreen->setObjectName("doubleClickForFullscreen"); cbDoubleClickForFullscreen->setToolTip(tr("If checked, a double click on the canvas opens the fullscreen mode.")); cbDoubleClickForFullscreen->setChecked(Settings::param().global().doubleClickForFullscreen); QCheckBox* cbShowBgImage = new QCheckBox(tr("Show Background Image"), this); cbShowBgImage->setObjectName("showBgImage"); cbShowBgImage->setToolTip(tr("If checked, the nomacs logo is shown in the bottom right corner.")); cbShowBgImage->setChecked(Settings::param().global().showBgImage); QCheckBox* cbSwitchModifier = new QCheckBox(tr("Switch CTRL with ALT"), this); cbSwitchModifier->setObjectName("switchModifier"); cbSwitchModifier->setToolTip(tr("If checked, CTRL + Mouse is switched with ALT + Mouse.")); cbSwitchModifier->setChecked(Settings::param().sync().switchModifier); QCheckBox* cbEnableNetworkSync = new QCheckBox(tr("Enable LAN Sync"), this); cbEnableNetworkSync->setObjectName("networkSync"); cbEnableNetworkSync->setToolTip(tr("If checked, syncing in your LAN is enabled.")); cbEnableNetworkSync->setChecked(Settings::param().sync().enableNetworkSync); QCheckBox* cbCloseOnEsc = new QCheckBox(tr("Close on ESC"), this); cbCloseOnEsc->setObjectName("closeOnEsc"); cbCloseOnEsc->setToolTip(tr("Close nomacs if ESC is pressed.")); cbCloseOnEsc->setChecked(Settings::param().app().closeOnEsc); QCheckBox* cbCheckForUpdates = new QCheckBox(tr("Check For Updates"), this); cbCheckForUpdates->setObjectName("checkForUpdates"); cbCheckForUpdates->setToolTip(tr("Check for updates on start-up.")); cbCheckForUpdates->setChecked(Settings::param().sync().checkForUpdates); DkGroupWidget* generalGroup = new DkGroupWidget(tr("General"), this); generalGroup->addWidget(cbRecentFiles); generalGroup->addWidget(cbLogRecentFiles); generalGroup->addWidget(cbLoopImages); generalGroup->addWidget(cbZoomOnWheel); generalGroup->addWidget(cbDoubleClickForFullscreen); generalGroup->addWidget(cbSwitchModifier); generalGroup->addWidget(cbEnableNetworkSync); generalGroup->addWidget(cbCloseOnEsc); generalGroup->addWidget(cbCheckForUpdates); generalGroup->addWidget(cbShowBgImage); // language QComboBox* languageCombo = new QComboBox(this); languageCombo->setObjectName("languageCombo"); languageCombo->setToolTip(tr("Choose your preferred language.")); DkUtils::addLanguages(languageCombo, mLanguages); languageCombo->setCurrentIndex(mLanguages.indexOf(Settings::param().global().language)); QLabel* translateLabel = new QLabel("<a href=\"http://www.nomacs.org/how-to-translate-nomacs/\">How-to translate nomacs</a>", this); translateLabel->setToolTip(tr("Info on how to translate nomacs.")); translateLabel->setOpenExternalLinks(true); DkGroupWidget* languageGroup = new DkGroupWidget(tr("Language"), this); languageGroup->addWidget(languageCombo); languageGroup->addWidget(translateLabel); // the right column (holding all checkboxes) QWidget* cbWidget = new QWidget(this); QVBoxLayout* cbLayout = new QVBoxLayout(cbWidget); cbLayout->setAlignment(Qt::AlignTop); cbLayout->addWidget(generalGroup); // add language cbLayout->addWidget(languageGroup); QHBoxLayout* contentLayout = new QHBoxLayout(this); contentLayout->setAlignment(Qt::AlignLeft); contentLayout->addWidget(leftColumn); contentLayout->addWidget(cbWidget); }
BioXASSSRLMonochromatorConfigurationView::BioXASSSRLMonochromatorConfigurationView(BioXASSSRLMonochromator *mono, QWidget *parent) : QWidget(parent) { // Initialize member variables. mono_ = 0; // Create motors column contents. maskView_ = new BioXASSSRLMonochromatorMaskView(0); QVBoxLayout *maskBoxLayout = new QVBoxLayout(); maskBoxLayout->addWidget(maskView_); QGroupBox *maskBox = new QGroupBox(); maskBox->setTitle("Mask"); maskBox->setLayout(maskBoxLayout); heightEditor_ = new CLSControlEditor(0); heightEditor_->setTitle("Height"); heightEditor_->setFormat('f'); heightEditor_->setPrecision(5); lateralEditor_ = new CLSControlEditor(0); lateralEditor_->setTitle("Lateral"); lateralEditor_->setFormat('f'); lateralEditor_->setPrecision(5); paddleEditor_ = new CLSControlEditor(0); paddleEditor_->setTitle("Paddle"); QVBoxLayout *motorsBoxLayout = new QVBoxLayout(); motorsBoxLayout->setMargin(0); motorsBoxLayout->addWidget(maskBox); motorsBoxLayout->addWidget(heightEditor_); motorsBoxLayout->addWidget(lateralEditor_); motorsBoxLayout->addWidget(paddleEditor_); QWidget *motorsBox = new QWidget(); motorsBox->setLayout(motorsBoxLayout); motorsBox->setMinimumWidth(BIOXASSSRLMONOCHROMATORCONFIGURATIONVIEW_COLUMN_WIDTH_MIN); // Create energy column contents. energyView_ = new BioXASSSRLMonochromatorEnergyView(0); QVBoxLayout *energyBoxLayout = new QVBoxLayout(); energyBoxLayout->addWidget(energyView_); QGroupBox *energyBox = new QGroupBox(); energyBox->setTitle("Energy"); energyBox->setLayout(energyBoxLayout); energyBox->setMinimumWidth(BIOXASSSRLMONOCHROMATORCONFIGURATIONVIEW_COLUMN_WIDTH_MIN); // Create crystals column contents. regionEditor_ = new BioXASSSRLMonochromatorRegionControlEditor(0); regionEditor_->setTitle("Region"); regionStatusWidget_ = new BioXASSSRLMonochromatorRegionControlView(0); crystalsView_ = new BioXASSSRLMonochromatorCrystalsView(0); QVBoxLayout *regionStatusViewLayout = new QVBoxLayout(); regionStatusViewLayout->setMargin(0); regionStatusViewLayout->addWidget(regionStatusWidget_); QGroupBox *regionStatusView = new QGroupBox("Region Status"); regionStatusView->setFlat(true); regionStatusView->setLayout(regionStatusViewLayout); QVBoxLayout *crystalsBoxLayout = new QVBoxLayout(); crystalsBoxLayout->addWidget(regionEditor_); crystalsBoxLayout->addWidget(regionStatusView); crystalsBoxLayout->addWidget(crystalsView_); crystalsBoxLayout->addStretch(); QGroupBox *crystalsBox = new QGroupBox("Crystals"); crystalsBox->setLayout(crystalsBoxLayout); crystalsBox->setMinimumWidth(BIOXASSSRLMONOCHROMATORCONFIGURATIONVIEW_COLUMN_WIDTH_MIN); // Create and set main layouts. QVBoxLayout *motorsColumnLayout = new QVBoxLayout(); motorsColumnLayout->addWidget(motorsBox); motorsColumnLayout->addStretch(); QVBoxLayout *energyColumnLayout = new QVBoxLayout(); energyColumnLayout->addWidget(energyBox); energyColumnLayout->addStretch(); QVBoxLayout *crystalsColumnLayout = new QVBoxLayout(); crystalsColumnLayout->addWidget(crystalsBox); crystalsColumnLayout->addStretch(); QHBoxLayout *layout = new QHBoxLayout(); layout->addLayout(motorsColumnLayout); layout->addLayout(energyColumnLayout); layout->addLayout(crystalsColumnLayout); setLayout(layout); // Current settings setMono(mono); refresh(); }
DesignAlternativesTabView::DesignAlternativesTabView() : PatMainTabView() { setTitle("Select Measures and Create Design Alternatives"); QSplitter * splitter = new QSplitter(Qt::Horizontal); viewSwitcher->setView(splitter); // Left content QWidget * leftContent = new QWidget(); leftContent->setMinimumWidth(270); splitter->addWidget(leftContent); QVBoxLayout * mainLeftContentVLayout = new QVBoxLayout(); mainLeftContentVLayout->setContentsMargins(0,0,0,0); mainLeftContentVLayout->setSpacing(0); mainLeftContentVLayout->setAlignment(Qt::AlignTop); leftContent->setLayout(mainLeftContentVLayout); QWidget * header = new QWidget(); header->setObjectName("Header"); header->setStyleSheet("QWidget#Header { background: #D5D5D5; border-bottom: 1px solid #8C8C8C;}"); QVBoxLayout * headerVLayout = new QVBoxLayout(); headerVLayout->setContentsMargins(5,5,5,5); headerVLayout->setSpacing(5); header->setLayout(headerVLayout); mainLeftContentVLayout->addWidget(header); QLabel * leftTitleLabel = new QLabel("Select Measure(s) from Project Measures"); leftTitleLabel->setObjectName("H2"); headerVLayout->addWidget(leftTitleLabel); QHBoxLayout * selectionButtonLayout = new QHBoxLayout(); selectionButtonLayout->setContentsMargins(0,0,0,0); selectionButtonLayout->setSpacing(5); selectionButtonLayout->setAlignment(Qt::AlignLeft); headerVLayout->addLayout(selectionButtonLayout); selectAllButton = new GrayButton(); selectAllButton->setText("Select All"); selectAllButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); selectionButtonLayout->addWidget(selectAllButton); clearSelectionsButton = new GrayButton(); clearSelectionsButton->setText("Clear Selection"); clearSelectionsButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); selectionButtonLayout->addWidget(clearSelectionsButton); clearSelectionsButton->setEnabled(false); measuresListView = new OSListView(true); measuresListView->setContentsMargins(0,0,0,0); mainLeftContentVLayout->addWidget(measuresListView); // Right content designAltsView = new altstab::DesignAltsView(); splitter->addWidget(designAltsView); splitter->setStretchFactor(1,100); }