void WWidgetGroup::setup(QDomNode node) { setContentsMargins(0, 0, 0, 0); // Set background pixmap if available if (!WWidget::selectNode(node, "BackPath").isNull()) { setPixmapBackground(WWidget::getPath(WWidget::selectNodeQString(node, "BackPath"))); } QLayout* pLayout = NULL; if (!XmlParse::selectNode(node, "Layout").isNull()) { QString layout = XmlParse::selectNodeQString(node, "Layout"); if (layout == "vertical") { pLayout = new QVBoxLayout(); pLayout->setSpacing(0); pLayout->setContentsMargins(0, 0, 0, 0); pLayout->setAlignment(Qt::AlignCenter); } else if (layout == "horizontal") { pLayout = new QHBoxLayout(); pLayout->setSpacing(0); pLayout->setContentsMargins(0, 0, 0, 0); pLayout->setAlignment(Qt::AlignCenter); } } if (pLayout) { setLayout(pLayout); } }
UBZoomPalette::UBZoomPalette(QWidget* parent) : UBFloatingPalette(Qt::BottomRightCorner, parent) , mIsExpanded(1) { mBoardController = UBApplication::boardController; QLayout* layout = new QVBoxLayout(this); mCurrentZoomButton = new QPushButton(parent); mCurrentZoomButton->setStyleSheet(QString("QPushButton { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }")); mCurrentZoomButton->setFocusPolicy(Qt::NoFocus); connect(mCurrentZoomButton, SIGNAL(clicked(bool)), this, SLOT(showHideExtraButton())); connect(mBoardController, SIGNAL(zoomChanged(qreal)), this, SLOT(refreshPalette())); connect(mBoardController, SIGNAL(activeSceneChanged()), this, SLOT(refreshPalette())); mHundredButton = new QPushButton(parent); mHundredButton->setStyleSheet(QString("QPushButton { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }")); mHundredButton->setFocusPolicy(Qt::NoFocus); mHundredButton->setIcon(QIcon(":/images/stylusPalette/restoreZoom.png")); mHundredButton->setIconSize(QSize(42,42)); connect(mHundredButton, SIGNAL(clicked(bool)), this, SLOT(goHundred())); layout->setContentsMargins(radius() + 15, 4, radius() + 15, 4); layout->addWidget(mHundredButton); layout->addWidget(mCurrentZoomButton); hide(); refreshPalette(); }
void ViewManager::insertViewStep( int before, ViewStep* step) { m_steps.insert( before, step ); QLayout* layout = step->widget()->layout(); if ( layout ) { layout->setContentsMargins( 0, 0, 0, 0 ); } m_stack->insertWidget( before, step->widget() ); connect( step, &ViewStep::nextStatusChanged, this, [this]( bool status ) { ViewStep* vs = qobject_cast< ViewStep* >( sender() ); if ( vs ) { if ( vs == m_steps.at( m_currentStep ) ) m_next->setEnabled( status ); } } ); m_stack->setCurrentIndex( 0 ); step->widget()->setFocus(); }
QgsAttributeFormEditorWidget::QgsAttributeFormEditorWidget( QgsEditorWidgetWrapper* editorWidget, QgsAttributeForm* form ) : QWidget( form ) , mWidget( editorWidget ) , mForm( form ) , mMode( DefaultMode ) , mMultiEditButton( new QgsMultiEditToolButton() ) , mBlockValueUpdate( false ) , mIsMixed( false ) , mIsChanged( false ) { if ( !mWidget || !mForm ) return; QLayout* l = new QHBoxLayout(); l->setMargin( 0 ); l->setContentsMargins( 0, 0, 0, 0 ); l->addWidget( mWidget->widget() ); if ( mWidget->widget() ) { mWidget->widget()->setObjectName( mWidget->field().name() ); } connect( mWidget, SIGNAL( valueChanged( const QVariant& ) ), this, SLOT( editorWidgetChanged( const QVariant & ) ) ); connect( mMultiEditButton, SIGNAL( resetFieldValueTriggered() ), this, SLOT( resetValue() ) ); connect( mMultiEditButton, SIGNAL( setFieldValueTriggered() ), this, SLOT( setFieldTriggered() ) ); mMultiEditButton->setField( mWidget->field() ); setLayout( l ); updateWidgets(); }
/*! \internal */ QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget) { // Is this a temporary layout widget used to represent QLayout hierarchies in Designer? // Set its margins to 0. bool layoutWidget = d->processingLayoutWidget(); QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget); if (layoutWidget) { const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); int left, top, right, bottom; left = top = right = bottom = 0; const DomPropertyHash properties = propertyMap(ui_layout->elementProperty()); if (DomProperty *prop = properties.value(strings.leftMarginProperty)) left = prop->elementNumber(); if (DomProperty *prop = properties.value(strings.topMarginProperty)) top = prop->elementNumber(); if (DomProperty *prop = properties.value(strings.rightMarginProperty)) right = prop->elementNumber(); if (DomProperty *prop = properties.value(strings.bottomMarginProperty)) bottom = prop->elementNumber(); l->setContentsMargins(left, top, right, bottom); d->setProcessingLayoutWidget(false); } return l; }
ItemSelectorWidget::ItemSelectorWidget( QWidget* parent ) :StylableWidget(parent), m_clearText( false ) { QLayout* layout = new FlowLayout( this, 0, 0, 0 ); layout->setContentsMargins( 0, 0, 0, 0 ); layout->setSpacing( 0 ); }
StickyNoteEditDialog::StickyNoteEditDialog() : QDialog(NULL, Qt::FramelessWindowHint|Qt::SubWindow) , _edit(NULL) , _noteInset(10) { // make this window a child of the BumpTop window to hide it in the task bar // HWND hwnd = WindowFromDC(getDC()); // SetParent(hwnd, winOS->GetWindowsHandle()); // resize and center the window resize(320, 320); move(winOS->GetWindowWidth() / 2 - width() / 2, winOS->GetWindowHeight() / 2 - height() / 2); setStyleSheet(QT_NT("QDialog {") QT_NT("border: 0px;") QT_NT("}")); setAttribute(Qt::WA_TranslucentBackground); // create the dialog content QLayout * layout = NULL; layout = new QHBoxLayout(this); layout->setContentsMargins(20, 20, 25, 30); _edit = new StickyNoteTextEdit(); _edit->setStyleSheet(QT_NT("QTextEdit {") QT_NT("background: rgb(0,0,0,0);") QT_NT("border: 0px;") QT_NT("selection-color: rgb(240,240,240);") QT_NT("selection-background-color: rgb(60,60,60);") QT_NT("}")); layout->addWidget(_edit); connect(_edit, SIGNAL(accept()), this, SLOT(onEditAccept())); // try and forward focus events to the edit field setFocusProxy(_edit); }
RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) , mRootNode(0) { osgViewer::CompositeViewer& viewer = CompositeViewer::get(); osg::DisplaySettings* ds = osg::DisplaySettings::instance().get(); //ds->setNumMultiSamples(8); osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; traits->windowName = ""; traits->windowDecoration = true; traits->x = 0; traits->y = 0; traits->width = width(); traits->height = height(); traits->doubleBuffer = true; traits->alpha = ds->getMinimumNumAlphaBits(); traits->stencil = ds->getMinimumNumStencilBits(); traits->sampleBuffers = ds->getMultiSamples(); traits->samples = ds->getNumMultiSamples(); // Doesn't make much sense as we're running on demand updates, and there seems to be a bug with the refresh rate when running multiple QGLWidgets traits->vsync = false; mView = new osgViewer::View; osg::ref_ptr<osgQt::GraphicsWindowQt> window = new osgQt::GraphicsWindowQt(traits.get()); QLayout* layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(window->getGLWidget()); setLayout(layout); // Pass events through this widget first window->getGLWidget()->installEventFilter(this); mView->getCamera()->setGraphicsContext(window); mView->getCamera()->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) ); mView->getCamera()->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) ); mView->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f ); SceneUtil::LightManager* lightMgr = new SceneUtil::LightManager; lightMgr->setStartLight(1); lightMgr->setLightingMask(Mask_Lighting); mRootNode = lightMgr; mView->getCamera()->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); mView->getCamera()->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON); mView->setSceneData(mRootNode); // Press S to reveal profiling stats mView->addEventHandler(new osgViewer::StatsHandler); mView->getCamera()->setCullMask(~(Mask_UpdateVisitor)); viewer.addView(mView); viewer.setDone(false); viewer.realize(); }
void BackgroundWidget::resetWidgetLayout(MainWidget &widget) { // If the widget has layout, remove its margins because main widgets layout has its own margins. QLayout *layout = widget.layout(); if (layout != nullptr) { layout->setContentsMargins(0, 0, 0, 0); } }
void WWidgetGroup::setup(QDomNode node, const SkinContext& context) { setContentsMargins(0, 0, 0, 0); // Set background pixmap if available if (context.hasNode(node, "BackPath")) { setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath"))); } QLayout* pLayout = NULL; if (context.hasNode(node, "Layout")) { QString layout = context.selectString(node, "Layout"); if (layout == "vertical") { pLayout = new QVBoxLayout(); pLayout->setSpacing(0); pLayout->setContentsMargins(0, 0, 0, 0); pLayout->setAlignment(Qt::AlignCenter); } else if (layout == "horizontal") { pLayout = new QHBoxLayout(); pLayout->setSpacing(0); pLayout->setContentsMargins(0, 0, 0, 0); pLayout->setAlignment(Qt::AlignCenter); } } if (pLayout && context.hasNode(node, "SizeConstraint")) { QMap<QString, QLayout::SizeConstraint> constraints; constraints["SetDefaultConstraint"] = QLayout::SetDefaultConstraint; constraints["SetFixedSize"] = QLayout::SetFixedSize; constraints["SetMinimumSize"] = QLayout::SetMinimumSize; constraints["SetMaximumSize"] = QLayout::SetMaximumSize; constraints["SetMinAndMaxSize"] = QLayout::SetMinAndMaxSize; constraints["SetNoConstraint"] = QLayout::SetNoConstraint; QString sizeConstraintStr = context.selectString(node, "SizeConstraint"); if (constraints.contains(sizeConstraintStr)) { pLayout->setSizeConstraint(constraints[sizeConstraintStr]); } else { qDebug() << "Could not parse SizeConstraint:" << sizeConstraintStr; } } if (pLayout) { setLayout(pLayout); } }
void CQGroupBox:: calculateFrame() { QLayout *l = layout(); if (! l) return; l->setContentsMargins(marginLeft(), spaceTop(), marginRight(), spaceBottom()); }
WLabel::WLabel(QWidget * parent) : WWidget(parent) { m_pLabel = new QLabel(this); QLayout* pLayout = new QVBoxLayout(this); pLayout->setContentsMargins(0, 0, 0, 0); pLayout->addWidget(m_pLabel); setLayout(pLayout); m_qsText = ""; }
// 设置 widget 的 padding 和 spacing void UiUtil::setWidgetPaddingAndSpacing(QWidget *widget, int padding, int spacing) { // 设置 Widget 的 padding 和 spacing QLayout *layout = widget->layout(); if (nullptr != layout) { layout->setContentsMargins(padding, padding, padding, padding); layout->setSpacing(spacing); } }
WNumber::WNumber(QWidget * parent) : WWidget(parent) { m_pLabel = new QLabel(this); QLayout* pLayout = new QVBoxLayout(this); pLayout->setContentsMargins(0, 0, 0, 0); pLayout->addWidget(m_pLabel); setLayout(pLayout); m_qsText = ""; m_dConstFactor = 0.; }
bool Drawer::eventFilter(QObject *obj, QEvent *event) { const QEvent::Type type = event->type(); if (QEvent::Move == type || QEvent::Resize == type) { QLayout *t = layout(); if (t && 16 != t->contentsMargins().right()) { t->setContentsMargins(0, 0, 16, 0); } } return OverlayWidget::eventFilter(obj, event); }
/*! \internal */ QLayout *QFormBuilder::createLayout(const QString &layoutName, QObject *parent, const QString &name) { QLayout *l = 0; QWidget *parentWidget = qobject_cast<QWidget*>(parent); QLayout *parentLayout = qobject_cast<QLayout*>(parent); Q_ASSERT(parentWidget || parentLayout); #define DECLARE_WIDGET(W, C) #define DECLARE_COMPAT_WIDGET(W, C) #define DECLARE_LAYOUT(L, C) \ if (layoutName == QLatin1String(#L)) { \ Q_ASSERT(l == 0); \ l = parentLayout \ ? new L() \ : new L(parentWidget); \ } #include "widgets.table" #undef DECLARE_LAYOUT #undef DECLARE_COMPAT_WIDGET #undef DECLARE_WIDGET if (l) { l->setObjectName(name); if (parentLayout) { QWidget *w = qobject_cast<QWidget *>(parentLayout->parent()); if (w && w->inherits("Q3GroupBox")) { l->setContentsMargins(w->style()->pixelMetric(QStyle::PM_LayoutLeftMargin), w->style()->pixelMetric(QStyle::PM_LayoutTopMargin), w->style()->pixelMetric(QStyle::PM_LayoutRightMargin), w->style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); QGridLayout *grid = qobject_cast<QGridLayout *>(l); if (grid) { grid->setHorizontalSpacing(-1); grid->setVerticalSpacing(-1); } else { l->setSpacing(-1); } l->setAlignment(Qt::AlignTop); } } } else { qWarning() << QCoreApplication::translate("QFormBuilder", "The layout type `%1' is not supported.").arg(layoutName); } return l; }
void TreeScreen::assembly(void) { treeScreenLayout=new QVBoxLayout(); treeScreenLayout->setObjectName("treescreen_QVBoxLayout"); treeScreenLayout->addWidget(toolsLine); treeScreenLayout->addWidget(knowTreeView); setLayout(treeScreenLayout); // Границы убираются, так как данный объект будет использоваться как виджет QLayout *lt; lt=layout(); lt->setContentsMargins(0,2,0,0); }
SubTableWidget::SubTableWidget(QWidget *parent) : QWidget(parent), ui(new Ui::SubTableWidget) { ui->setupUi(this); statusbar = new QStatusBar(this); movable = true; ui->label-> setVisible (true); ui->toolsframe->setVisible (true); ui->tableView-> setFocusPolicy(Qt::NoFocus); QLayout* layoutWidget = ui->gridLayout_2; layoutWidget->setContentsMargins(0,0,0,0); layoutWidget->setSpacing(0); layoutWidget->addWidget(statusbar); }
ConsoleOutput::ConsoleOutput(QWidget* parent) : QWidget(0/* cannot have parent because it will becode topmost*/, Qt::Dialog) , m_parent(parent) { setWindowTitle(tr("Console Output")); m_tabs = new QTabWidget(this); QLayout* layout = new QVBoxLayout(); layout->addWidget(m_tabs); layout->setContentsMargins(DEFAULT_MARGINS); layout->setSpacing(DEFAULT_SPACING); setLayout(layout); if (m_parent) { move(m_parent->x(), m_parent->frameGeometry().top()); } }
void WWidgetGroup::setLayoutContentsMargins(QRect rectMargins) { // qDebug() << "WWidgetGroup::setLayoutContentsMargins" << rectMargins.x() // << rectMargins.y() << rectMargins.width() << rectMargins.height(); if (rectMargins.x() < 0 || rectMargins.y() < 0 || rectMargins.width() < 0 || rectMargins.height() < 0) { qDebug() << "WWidgetGroup: Invalid ContentsMargins rectangle:" << rectMargins; return; } setContentsMargins(rectMargins.x(), rectMargins.y(), rectMargins.width(), rectMargins.height()); QLayout* pLayout = layout(); if (pLayout) { pLayout->setContentsMargins(rectMargins.x(), rectMargins.y(), rectMargins.width(), rectMargins.height()); } }
int drv_layout(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9) { handle_head* head = (handle_head*)a0; QLayout *self = (QLayout*)head->native; switch (drvid) { case LAYOUT_ADDLAYOUT: { self->addItem(drvGetLayout(a1)); break; } case LAYOUT_ADDWIDGET: { self->addWidget(drvGetWidget(a1)); break; } case LAYOUT_SETSPACING: { self->setSpacing(drvGetInt(a1)); break; } case LAYOUT_SPACING: { drvSetInt(a1,self->spacing()); break; } case LAYOUT_SETMARGINS: { self->setContentsMargins(drvGetMargins(a1)); break; } case LAYOUT_MARGINS: { drvSetMargins(a1,self->contentsMargins()); break; } case LAYOUT_SETMENUBAR: { self->setMenuBar(drvGetWidget(a1)); break; } case LAYOUT_MENUBAR: { drvSetHandle(a1,self->menuBar()); break; } default: return 0; } return 1; }
void PreferencesDialog::updatePreferencesWidget(const QModelIndex &pNewIndex, const QModelIndex &pOldIndex) { Q_UNUSED(pOldIndex) // Check whether we are dealing with a plugin category QStandardItem *item = mModel->itemFromIndex(pNewIndex); bool isPluginCategory = mCategoryItems.values().contains(item); mResetButton->setEnabled(!isPluginCategory); if (isPluginCategory) { // We are dealing with a plugin category, so retrieve and set its name // and description mPluginCategoryWidget->setCategory(item->text()); mPluginCategoryWidget->setDescription(tr("%1.").arg(formatMessage(pluginCategoryDescription(mItemCategories.value(item))))); mGui->stackedWidget->setCurrentWidget(mPluginCategoryWidget); } else { // We are dealing with our general or a plugin's preferences, so show // them mGui->stackedWidget->setCurrentWidget(mItemPreferencesWidgets.value(item)); } // Make sure that the current widget has no layout margin (so that not only // we don't waste space, but also developers don't have to worry about the // layout margin of their preferences widget, assuming it has a layout) QLayout *widgetLayout = mGui->stackedWidget->currentWidget()->layout(); if (widgetLayout != nullptr) { widgetLayout->setContentsMargins(QMargins()); } // Make sure that we are big enough to show our contents adjustWidgetSize(this); }
void RecordTableScreen::assembly(void) { recordTableToolsLayout=new QHBoxLayout(); recordTableToolsLayout->addWidget(toolsLine); recordTableToolsLayout->addStretch(); recordTableToolsLayout->addWidget(extraToolsLine); recordTableScreenLayout=new QVBoxLayout(); recordTableScreenLayout->setObjectName("recordtablescreen_QVBoxLayout"); recordTableScreenLayout->addLayout(recordTableToolsLayout); recordTableScreenLayout->addWidget(treePathLabel); recordTableScreenLayout->addWidget(recordTableController->getView()); setLayout(recordTableScreenLayout); // Границы убираются, так как данный объект будет использоваться как виджет QLayout *lt; lt=layout(); lt->setContentsMargins(0,2,0,0); }
/** * @brief * Updates the transfer function */ void DockWidgetVolumeTransferFunction::UpdateObject(PLCore::Object *pObject) { // Destroy previous transfer function Qt widget if (m_pTransferFunctionWidget) { delete m_pTransferFunctionWidget; m_pTransferFunctionWidget = nullptr; } if (m_pTransferFunctionResultWidget) { delete m_pTransferFunctionResultWidget; m_pTransferFunctionResultWidget = nullptr; } // Is there an selected object? if (pObject) { // Get encapsulated Qt dock widget QDockWidget *pQDockWidget = GetQDockWidget(); if (pQDockWidget) { // Get the used volume resource PLVolume::Volume *pVolume = static_cast<PLVolume::SNVolume&>(*pObject).GetVolume(); // If we're in here, we know the cast is valid if (pVolume) { // Transfer function result widget m_pTransferFunctionResultWidget = new QLabel(); m_pTransferFunctionResultWidget->setAlignment(Qt::AlignTop | Qt::AlignLeft); m_pTransferFunctionResultWidget->setToolTip(pQDockWidget->tr("Resulting 1D transfer function")); // Create transfer function Qt widget m_pTransferFunctionWidget = new TransferFunctionWidget(*this, *pVolume); QLayout *pQLayout = new QVBoxLayout(); pQLayout->setSpacing(0); pQLayout->setMargin(0); pQLayout->setContentsMargins(0, 0, 0, 0); pQLayout->addWidget(m_pTransferFunctionWidget); pQLayout->addWidget(m_pTransferFunctionResultWidget); QWidget *pQWidget = new QWidget(); pQWidget->setLayout(pQLayout); pQDockWidget->setWidget(pQWidget); } } } }
TimeDialog::TimeDialog(QWidget* parent) : QWidget(parent, Qt::WindowFlags(Qt::Dialog | Qt::Window)) { setupUi(this); setWindowTitle(tr("MuseScore: Time Signatures")); QLayout* l = new QVBoxLayout(); l->setContentsMargins(0, 0, 0, 0); frame->setLayout(l); sp = MuseScore::newTimePalette(); sp->setReadOnly(false); sp->setSelectable(true); connect(zNominal, SIGNAL(valueChanged(int)), SLOT(zChanged(int))); connect(nNominal, SIGNAL(currentIndexChanged(int)), SLOT(nChanged(int))); connect(sp, SIGNAL(boxClicked(int)), SLOT(paletteChanged(int))); connect(sp, SIGNAL(changed()), SLOT(setDirty())); connect(addButton, SIGNAL(clicked()), SLOT(addClicked())); _timePalette = new PaletteScrollArea(sp); QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); _timePalette->setSizePolicy(policy); _timePalette->setRestrictHeight(false); l->addWidget(_timePalette); _dirty = false; if (useFactorySettings || !sp->read(dataPath + "/" + "timesigs")) { Fraction sig(4,4); groups->setSig(sig, Groups::endings(sig)); } for (int i = 0; i < sp->size(); ++i) // cells can be changed sp->setCellReadOnly(i, false); sp->setSelected(2); paletteChanged(2); }
void PieceAppearanceWidget::setupUI() { QLayout * lay = new QGridLayout( this ); lay->setSpacing(0); lay->setContentsMargins(0,0,0,0); QGraphicsView * v = this->impl->gv = //new QGraphicsView( impl->gs.scene() ) new QBoardView( impl->gs ) ; v->setTransformationAnchor(QGraphicsView::NoAnchor); #if 0 v->setAlignment(Qt::AlignLeft | Qt::AlignTop); v->setInteractive(true); // required to get mouse events to the children v->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); v->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); v->setDragMode(QGraphicsView::RubberBandDrag); v->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); #endif v->setBackgroundBrush(QColor("#abb8fb")); v->viewport()->setObjectName( "PieceAppearanceWidget"); lay->addWidget( v ); QStringList tip; tip << "<html><body>These widgets are appearance templates for game pieces.\n" << "Edit them by right-clicking them.\n" << "Select a template by left-clicking it. " << "QBoard will use the selected template as the default look\n" << "for newly-added pieces which are loaded from image files.\n" << "This list will be saved automatically when QBoard exits,\n" << "and loaded when QBoard starts up.</body></html>" ; impl->gv->setToolTip( tip.join("") ); }
MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) { setObjectName("MicroProfile"); setWindowTitle(tr("MicroProfile")); resize(1000, 600); // Remove the "?" button from the titlebar and enable the maximize button setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::WindowMaximizeButtonHint); #if MICROPROFILE_ENABLED MicroProfileWidget* widget = new MicroProfileWidget(this); QLayout* layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(widget); setLayout(layout); // Configure focus so that widget is focusable and the dialog automatically forwards focus to it. setFocusProxy(widget); widget->setFocusPolicy(Qt::StrongFocus); widget->setFocus(); #endif }
void NLayoutPrototype::setContentsMargins(QMargins margins) { QLayout *layout = qscriptvalue_cast<QLayout *>(thisObject()); if (layout) layout->setContentsMargins(margins); }
void ContactAvatarWidget::cropAvatar() { QWidget *hostWidget = nullptr; QLayout *hostLayout = nullptr; QWidget *mainWidget = nullptr; QLayout *mainLayout = nullptr; if (imageCropHolder_) { hostWidget = new QWidget(this); hostLayout = new QHBoxLayout(hostWidget); hostWidget->setSizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Fixed); hostWidget->setFixedHeight(imageCropSize_.height()); hostLayout->setContentsMargins(Utils::scale_value(16), Utils::scale_value(12), Utils::scale_value(16), 0); mainWidget = new QWidget(hostWidget); mainLayout = Utils::emptyHLayout(mainWidget); mainWidget->setSizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Preferred); hostLayout->addWidget(mainWidget); } else { mainWidget = new QWidget(this); mainLayout = new QHBoxLayout(mainWidget); mainLayout->setContentsMargins(Utils::scale_value(16), Utils::scale_value(12), Utils::scale_value(16), 0); } auto avatarCropper = new Ui::ImageCropper(mainWidget, imageCropSize_); avatarCropper->setProportion(QSizeF(1.0, 1.0)); avatarCropper->setProportionFixed(true); avatarCropper->setBackgroundColor(CommonStyle::getFrameColor()); if (!infoForSetAvatar_.croppingRect.isNull()) { avatarCropper->setCroppingRect(infoForSetAvatar_.croppingRect); } avatarCropper->setImage(QPixmap::fromImage(infoForSetAvatar_.image)); mainLayout->addWidget(avatarCropper); if (!imageCropHolder_) { hostWidget = mainWidget; } GeneralDialog imageCropDialog(hostWidget, imageCropHolder_ ? imageCropHolder_ : Utils::InterConnector::instance().getMainWindow()); imageCropDialog.setObjectName(qsl("image.cropper")); if (imageCropHolder_) { imageCropDialog.setShadow(false); imageCropDialog.connect(&imageCropDialog, &GeneralDialog::moved, this, [=](QWidget *dlg) { emit Utils::InterConnector::instance().imageCropDialogMoved(dlg); }); imageCropDialog.connect(&imageCropDialog, &GeneralDialog::resized, this, [=](QWidget *dlg) { emit Utils::InterConnector::instance().imageCropDialogResized(dlg); }); imageCropDialog.connect(&imageCropDialog, &GeneralDialog::shown, this, [=](QWidget *dlg) { emit Utils::InterConnector::instance().imageCropDialogIsShown(dlg); }); imageCropDialog.connect(&imageCropDialog, &GeneralDialog::hidden, this, [=](QWidget *dlg) { emit Utils::InterConnector::instance().imageCropDialogIsHidden(dlg); }); } imageCropDialog.addHead(); imageCropDialog.addLabel(mode_ == Mode::CreateChat ? QT_TRANSLATE_NOOP("avatar_upload", "Edit photo") : QT_TRANSLATE_NOOP("avatar_upload", "Upload photo")); imageCropDialog.addButtonsPair(QT_TRANSLATE_NOOP("popup_window", "BACK"), QT_TRANSLATE_NOOP("popup_window", "CONTINUE"), true, false, false); imageCropDialog.setRightButtonDisableOnClicked(true); QObject::connect(&imageCropDialog, &GeneralDialog::leftButtonClicked, this, [=, &imageCropDialog]() { imageCropDialog.reject(); QTimer::singleShot(500, this, [=](){ emit summonSelectFileForAvatar(); }); }, Qt::QueuedConnection); QObject::connect(&imageCropDialog, &GeneralDialog::rightButtonClicked, this, [=, &imageCropDialog]() { auto croppedImage = avatarCropper->cropImage(); auto croppingRect = avatarCropper->getCroppingRect(); infoForSetAvatar_.croppedImage = croppedImage; infoForSetAvatar_.croppingRect = croppingRect; imageCropDialog.accept(); if (auto p = imageCropDialog.takeAcceptButton()) p->setEnabled(true); }, Qt::QueuedConnection); QObject::connect(&imageCropDialog, &GeneralDialog::shown, this, [=](QWidget *dlg) { // }, Qt::QueuedConnection); if (!imageCropDialog.showInPosition(-1, -1)) { return; } if (mode_ == Mode::CreateChat) { infoForSetAvatar_.roundedCroppedImage = QPixmap(); emit avatarDidEdit(); } else { openAvatarPreview(); } }
MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f) : QMainWindow(parent, f), Ui::MainWindow(), impl(new Impl) { setupUi(this); this->setWindowTitle( QString("QBoard v. %1").arg(qboard::versionString()) ); connect( this->actionSave, SIGNAL(triggered(bool)), this, SLOT(saveGame()) ); connect( this->actionLoad, SIGNAL(triggered(bool)), this, SLOT(loadGame()) ); connect( this->actionNewBoardView, SIGNAL(triggered(bool)), this, SLOT(launchNewBoardView()) ); connect( this->actionAboutQt, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt()) ); connect( this->actionAboutQBoard, SIGNAL(triggered(bool)), this, SLOT(aboutQBoard()) ); connect( this->actionPrint, SIGNAL(triggered(bool)), this, SLOT(printGame()) ); connect( this->actionHelp, SIGNAL(triggered(bool)), this, SLOT(launchHelp()) ); connect( this->actionClearBoard, SIGNAL(triggered(bool)), this, SLOT(clearBoard()) ); connect( this->actionQuickSave, SIGNAL(triggered(bool)), this, SLOT(quickSave()) ); connect( this->actionQuickLoad, SIGNAL(triggered(bool)), this, SLOT(quickLoad()) ); impl->gstate.enablePlacemarker(true); #if ! QBOARD_VERSION // For "end user builds" we won't show this action. connect( this->actionExperiment, SIGNAL(triggered(bool)), this, SLOT(doSomethingExperimental()) ); this->actionExperiment->setEnabled(true); #else this->actionExperiment->setEnabled(false); #endif connect( &S11nClipboard::instance(), SIGNAL(signalUpdated()), this, SLOT(clipboardUpdated()) ); this->actionClearClipboard->setEnabled( 0 != S11nClipboard::instance().contents() ); connect( this->actionClearClipboard, SIGNAL(triggered(bool)), this, SLOT( clearClipboard() ) ); QWidget * cli = this->clientArea; QLayout * lay = new QGridLayout( cli ); lay->setSpacing(0); lay->setContentsMargins(2,2,2,2); QSplitter * splitter = new QSplitter( Qt::Horizontal, cli ); lay->addWidget( splitter ); splitter->setHandleWidth(4); QSplitter * vsplit = new QSplitter( Qt::Vertical, cli ); impl->sidebar = vsplit; splitter->addWidget( vsplit ); vsplit->setHandleWidth(4); impl->tree = new QBoardHomeView(); vsplit->addWidget(impl->tree); connect( this->actionRefreshFileList, SIGNAL(triggered(bool)), impl->tree, SLOT(refresh()) ); connect( impl->tree, SIGNAL(itemActivated(QFileInfo const &)), this, SLOT(loadFile(QFileInfo const &)) ); connect( this->actionToggleBrowserView, SIGNAL(toggled(bool)), this, SLOT(toggleSidebarVisible(bool)) ); impl->gv = new QBoardView( impl->gstate ); //impl->gv->enablePlacemarker(true); connect( this->actionToggleBoardDragMode, SIGNAL(toggled(bool)), impl->gv, SLOT(setHandDragMode(bool)) ); this->actionToggleBoardDragMode->setChecked(false); connect( this->actionCopy, SIGNAL(triggered(bool)), impl->gv, SLOT(clipCopySelected()) ); connect( this->actionCut, SIGNAL(triggered(bool)), impl->gv, SLOT(clipCutSelected()) ); connect( this->actionPaste, SIGNAL(triggered(bool)), impl->gv, SLOT(clipPaste()) ); connect( this->actionSelectAll, SIGNAL(triggered(bool)), impl->gv, SLOT(selectAll()) ); connect( this->actionZoomIn, SIGNAL(triggered(bool)), impl->gv, SLOT(zoomIn()) ); connect( this->actionZoomOut, SIGNAL(triggered(bool)), impl->gv, SLOT(zoomOut()) ); connect( this->actionZoomReset, SIGNAL(triggered(bool)), impl->gv, SLOT(zoomReset()) ); #define BOGO(A) // this->action ## A->setParent(impl->gv); BOGO(Copy); BOGO(Cut); BOGO(Paste); BOGO(ZoomIn); BOGO(ZoomOut); BOGO(ZoomReset); #undef BOGO splitter->addWidget( impl->gv ); splitter->setStretchFactor(0,2); splitter->setStretchFactor(1,3); vsplit->addWidget( impl->paw ); vsplit->setStretchFactor(0,3); vsplit->setStretchFactor(1,1); if(1) { impl->gv->setObjectName("view"); QScriptEngine & js( impl->gstate.jsEngine() ); QScriptValue jo = js.newQObject( impl->gv, QScriptEngine::QtOwnership ); QScriptValue qb = js.globalObject().property("qboard"); qb.setProperty("view",jo); qb.setProperty("window",js.newQObject(this, QScriptEngine::QtOwnership ) ); } this->resize(760,600); }