DelegateConfigWrapper::DelegateConfigWrapper( Tomahawk::Accounts::Account* account, QWidget* parent, Qt::WindowFlags flags ) : QDialog( parent, flags ) , m_account( account ) , m_widget( account->configurationWidget() ) , m_aboutW( account->aboutWidget() ) , m_buttons( nullptr ) , m_okButton( nullptr ) , m_deleteButton( nullptr ) , m_errorLabel( new QLabel( this ) ) , m_deleted( false ) { setWindowTitle( tr("%1 Config", "Window title for account config windows" ).arg( account->accountFriendlyName() ) ); QVBoxLayout* v = new QVBoxLayout( this ); v->setContentsMargins( 0, 0, 0, 0 ); v->addWidget( m_widget ); v->addStretch(); QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Ok | QDialogButtonBox::Cancel; if ( m_aboutW ) { m_aboutW->hide(); buttons |= QDialogButtonBox::Help; } m_buttons = new QDialogButtonBox( buttons, Qt::Horizontal, this ); m_okButton = m_buttons->button( QDialogButtonBox::Ok ); connect( m_buttons, SIGNAL( clicked( QAbstractButton*) ), this, SLOT( closed( QAbstractButton* ) ) ); connect( this, SIGNAL( rejected() ), this, SLOT( rejected() ) ); if ( m_aboutW ) { connect( m_buttons->button( QDialogButtonBox::Help ), SIGNAL( clicked( bool ) ), this, SLOT( aboutClicked( bool ) ) ); m_buttons->button( QDialogButtonBox::Help )->setText( tr( "About" ) ); } QHBoxLayout* h = new QHBoxLayout( this ); h->addWidget( m_buttons ); if ( m_widget && m_widget->layout() ) h->setContentsMargins( m_widget->layout()->contentsMargins() ); else if ( m_widget ) h->setContentsMargins( m_widget->contentsMargins() ); m_errorLabel->setAlignment( Qt::AlignCenter ); m_errorLabel->setWordWrap( true ); v->addWidget( m_errorLabel ); v->addLayout( h ); setLayout( v ); m_widget->setVisible( true ); setSizeGripEnabled( false ); updateSizeHint(); if ( m_widget->metaObject()->indexOfSignal( "sizeHintChanged()" ) > -1 ) connect( m_widget, SIGNAL( sizeHintChanged() ), this, SLOT( updateSizeHint() ) ); connect( m_account, SIGNAL( configTestResult( Tomahawk::Accounts::ConfigTestResultType ) ), SLOT( onConfigTestResult( Tomahawk::Accounts::ConfigTestResultType ) ) ); }
void DependenciesView::setModel(QAbstractItemModel *newModel) { if (QAbstractItemModel *oldModel = model()) { disconnect(oldModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(updateSizeHint())); disconnect(oldModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(updateSizeHint())); disconnect(oldModel, SIGNAL(modelReset()), this, SLOT(updateSizeHint())); disconnect(oldModel, SIGNAL(layoutChanged()), this, SLOT(updateSizeHint())); }
DelegateConfigWrapper::DelegateConfigWrapper( QWidget* conf, const QString& title, QWidget* parent, Qt::WindowFlags flags ) : QDialog( parent, flags ) , m_widget( conf ) , m_deleted( false ) { m_widget->setWindowFlags( Qt::Sheet ); #ifdef Q_WS_MAC m_widget->setVisible( true ); #endif setWindowTitle( title ); QVBoxLayout* v = new QVBoxLayout( this ); v->setContentsMargins( 0, 0, 0, 0 ); v->addWidget( m_widget ); m_buttons = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this ); m_okButton = m_buttons->button( QDialogButtonBox::Ok ); connect( m_buttons, SIGNAL( clicked( QAbstractButton*) ), this, SLOT( closed( QAbstractButton* ) ) ); connect( this, SIGNAL( rejected() ), this, SLOT( rejected() ) ); v->addWidget( m_buttons ); setLayout( v ); #ifdef Q_WS_MAC setSizeGripEnabled( false ); setMinimumSize( sizeHint() ); setMaximumSize( sizeHint() ); // to remove the resize grip on osx this is the only way if( conf->metaObject()->indexOfSignal( "sizeHintChanged()" ) > -1 ) connect( conf, SIGNAL( sizeHintChanged() ), this, SLOT( updateSizeHint() ) ); #else m_widget->setVisible( true ); #endif }
void DependenciesView::setModel(QAbstractItemModel *newModel) { if (QAbstractItemModel *oldModel = model()) { disconnect(oldModel, &QAbstractItemModel::rowsInserted, this, &DependenciesView::updateSizeHint); disconnect(oldModel, &QAbstractItemModel::rowsRemoved, this, &DependenciesView::updateSizeHint); disconnect(oldModel, &QAbstractItemModel::modelReset, this, &DependenciesView::updateSizeHint); disconnect(oldModel, &QAbstractItemModel::layoutChanged, this, &DependenciesView::updateSizeHint); } QTreeView::setModel(newModel); if (newModel) { connect(newModel, &QAbstractItemModel::rowsInserted, this, &DependenciesView::updateSizeHint); connect(newModel, &QAbstractItemModel::rowsRemoved, this, &DependenciesView::updateSizeHint); connect(newModel, &QAbstractItemModel::modelReset, this, &DependenciesView::updateSizeHint); connect(newModel, &QAbstractItemModel::layoutChanged, this, &DependenciesView::updateSizeHint); } updateSizeHint(); }
void MultiLineEdit::setMaxHeight(int lines) { if (lines == _maxHeight) return; _maxHeight = lines; updateSizeHint(); }
void UIPopupPaneTextPane::prepare() { /* Prepare content: */ prepareContent(); /* Prepare animation: */ prepareAnimation(); /* Update size-hint: */ updateSizeHint(); }
QStyleItem::QStyleItem(QQuickPaintedItem *parent) : QQuickPaintedItem(parent), m_styleoption(0), m_itemType(Undefined), m_sunken(false), m_raised(false), m_active(true), m_selected(false), m_focus(false), m_hover(false), m_on(false), m_horizontal(true), m_sharedWidget(false), m_minimum(0), m_maximum(100), m_value(0), m_step(0), m_paintMargins(0), m_contentWidth(0), m_contentHeight(0) { if (!qApp->style()) { qWarning("\nError: No widget style available. \n\nQt Desktop Components " "currently depend on the widget module to function. \n" "Use QApplication when creating standalone executables.\n\n"); exit(-1); } m_font = qApp->font(); setFlag(QQuickItem::ItemHasContents, true); setSmooth(false); connect(this, SIGNAL(enabledChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(infoChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(onChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(selectedChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(textChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(raisedChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(sunkenChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(hoverChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(maximumChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(minimumChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(valueChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(horizontalChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(hasFocusChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(elementTypeChanged()), this, SLOT(updateItem())); connect(this, SIGNAL(textChanged()), this, SLOT(updateSizeHint())); connect(this, SIGNAL(contentWidthChanged(int)), this, SLOT(updateSizeHint())); connect(this, SIGNAL(contentHeightChanged(int)), this, SLOT(updateSizeHint())); }
void UIPopupStackViewport::sltAdjustGeometry() { /* Update size-hint: */ updateSizeHint(); /* Layout content: */ layoutContent(); /* Notify parent popup-stack: */ emit sigSizeHintChanged(); }
void UIPopupPaneTextPane::sltHandleProposalForWidth(int iWidth) { /* Make sure the desired-width has changed: */ if (m_iDesiredLabelWidth == iWidth) return; /* Fetch new desired-width: */ m_iDesiredLabelWidth = iWidth; /* Update size-hint: */ updateSizeHint(); }
void UIPopupPaneTextPane::setText(const QString &strText) { /* Make sure the text has changed: */ if (m_pLabel->text() == strText) return; /* Fetch new text: */ m_strText = strText; m_pLabel->setText(m_strText); /* Update size-hint: */ updateSizeHint(); }
void UIGDetailsGroup::updateLayout() { /* Update size-hints for all the items: */ foreach (UIGDetailsItem *pItem, items()) pItem->updateSizeHint(); /* Update size-hint for this item: */ updateSizeHint(); /* Update layout finally: */ m_pMainLayout->activate(); m_pLayout->activate(); foreach (UIGDetailsItem *pItem, items()) pItem->updateLayout(); }
void QStyleItem::setHint(const QStringList &str) { if (m_hint != str) { m_hint = str; initStyleOption(); updateSizeHint(); if (m_styleoption->state & QStyle::State_Mini) { m_font.setPointSize(9.); emit fontChanged(); } else if (m_styleoption->state & QStyle::State_Small) { m_font.setPointSize(11.); emit fontChanged(); } } }
void StyledLabel::layout() { qreal h = 0; qreal w = contentsRect().width(); _layout.beginLayout(); forever { QTextLine line = _layout.createLine(); if (!line.isValid()) break; line.setLineWidth(w); line.setPosition(QPointF(0, h)); h += line.height(); } _layout.endLayout(); updateSizeHint(); updateToolTip(); update(); }
void FalseColorDock::initUi() { // initialize scaled view view->installEventFilter(this); // needed for leave event view->init(); scene = new ScaledView(); view->setScene(scene); connect(scene, SIGNAL(newContentRect(QRect)), view, SLOT(fitContentRect(QRect))); // initialize selection widget sel = new AutohideWidget(); uisel = new Ui::FalsecolorDockSelUI(); uisel->setupUi(sel); scene->offTop = AutohideWidget::OutOffset; view->addWidget(AutohideWidget::TOP, sel); // setup source box uisel->sourceBox->setAHView(view); uisel->sourceBox->addItem(prettyFalseColorNames[FalseColoring::CMF], FalseColoring::CMF); uisel->sourceBox->addItem(prettyFalseColorNames[FalseColoring::PCA], FalseColoring::PCA); uisel->sourceBox->addItem(prettyFalseColorNames[FalseColoring::PCAGRAD], FalseColoring::PCAGRAD); #ifdef WITH_SOM uisel->sourceBox->addItem(prettyFalseColorNames[FalseColoring::SOM], FalseColoring::SOM); uisel->sourceBox->addItem(prettyFalseColorNames[FalseColoring::SOMGRAD], FalseColoring::SOMGRAD); #endif // WITH_SOM uisel->sourceBox->setCurrentIndex(0); updateTheButton(); updateProgressBar(); connect(scene, SIGNAL(newSizeHint(QSize)), view, SLOT(updateSizeHint(QSize))); connect(scene, SIGNAL(updateScrolling(bool)), view, SLOT(suppressScrolling(bool))); connect(scene, SIGNAL(requestCursor(Qt::CursorShape)), view, SLOT(applyCursor(Qt::CursorShape))); connect(scene, SIGNAL(pixelOverlay(int,int)), this, SIGNAL(pixelOverlay(int,int))); connect(scene, SIGNAL(requestSpecSim(int,int)), this, SLOT(requestSpecSim(int,int))); connect(uisel->sourceBox, SIGNAL(currentIndexChanged(int)), this, SLOT(processSelectedColoring())); connect(uisel->theButton, SIGNAL(clicked()), this, SLOT(processApplyClicked())); connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(processVisibilityChanged(bool))); connect(uisel->screenshotButton, SIGNAL(released()), this, SLOT(screenshot())); // add similarity widget sw = new SimilarityWidget(view); scene->offBottom = AutohideWidget::OutOffset; view->addWidget(AutohideWidget::BOTTOM, sw); connect(sw->doneAction(), SIGNAL(triggered()), this, SLOT(restoreFalseColorFunction())); connect(sw->doneAction(), SIGNAL(triggered()), scene, SLOT(updateInputMode())); connect(sw->targetAction(), SIGNAL(triggered()), scene, SLOT(updateInputMode())); scene->setActionTarget(sw->targetAction()); }
void MultiLineEdit::resizeEvent(QResizeEvent* event) { QTextEdit::resizeEvent(event); updateSizeHint(); updateScrollBars(); }
void UIGDetailsSet::updateLayout() { /* Update size-hints for all the items: */ foreach (UIGDetailsItem *pItem, items()) pItem->updateSizeHint(); /* Update size-hint for this item: */ updateSizeHint(); /* Prepare variables: */ int iMargin = data(SetData_Margin).toInt(); int iSpacing = data(SetData_Spacing).toInt(); int iMaximumWidth = geometry().size().toSize().width(); int iVerticalIndent = iMargin; /* Layout all the elements: */ foreach (UIGDetailsItem *pItem, items()) { /* Get particular element: */ UIGDetailsElement *pElement = pItem->toElement(); if (!pElement->isVisible()) continue; /* For each particular element: */ switch (pElement->elementType()) { case DetailsElementType_General: case DetailsElementType_System: { UIGDetailsElement *pPreviewElement = element(DetailsElementType_Preview); int iPreviewWidth = pPreviewElement && pPreviewElement->isVisible() ? pPreviewElement->minimumWidthHint() : 0; int iWidth = iPreviewWidth == 0 ? iMaximumWidth - 2 * iMargin : iMaximumWidth - 2 * iMargin - iSpacing - iPreviewWidth; pElement->setPos(iMargin, iVerticalIndent); /* Resize to required width: */ int iHeight = pElement->minimumHeightHint(); pElement->resize(iWidth, iHeight); /* Update minimum height hint: */ pItem->updateSizeHint(); /* Resize to required height: */ iHeight = pElement->minimumHeightHint(); pElement->resize(iWidth, iHeight); pItem->updateLayout(); iVerticalIndent += (iHeight + iSpacing); break; } case DetailsElementType_Preview: { int iWidth = pElement->minimumWidthHint(); int iHeight = pElement->minimumHeightHint(); pElement->setPos(iMaximumWidth - iMargin - iWidth, iMargin); pElement->resize(iWidth, iHeight); pItem->updateLayout(); iVerticalIndent = qMax(iVerticalIndent, iHeight + iSpacing); break; } case DetailsElementType_Display: case DetailsElementType_Storage: case DetailsElementType_Audio: case DetailsElementType_Network: case DetailsElementType_Serial: #ifdef VBOX_WITH_PARALLEL_PORTS case DetailsElementType_Parallel: #endif /* VBOX_WITH_PARALLEL_PORTS */ case DetailsElementType_USB: case DetailsElementType_SF: case DetailsElementType_Description: { int iWidth = iMaximumWidth - 2 * iMargin; pElement->setPos(iMargin, iVerticalIndent); /* Resize to required width: */ int iHeight = pElement->minimumHeightHint(); pElement->resize(iWidth, iHeight); /* Update minimum height hint: */ pItem->updateSizeHint(); /* Resize to required height: */ iHeight = pElement->minimumHeightHint(); pElement->resize(iWidth, iHeight); pItem->updateLayout(); iVerticalIndent += (iHeight + iSpacing); break; } } }
void MultiLineEdit::setLineWrapEnabled(bool enable) { setLineWrapMode(enable ? WidgetWidth : NoWrap); updateSizeHint(); }
void MultiLineEdit::setCustomFont(const QFont& font) { setFont(font); updateSizeHint(); }
void QStyleItem::setElementType(const QString &str) { if (m_type == str) return; m_type = str; emit elementTypeChanged(); if (m_styleoption) { delete m_styleoption; m_styleoption = 0; } // Only enable visible if the widget can animate if (str == "menu" || str == "menuitem") { m_itemType = (str == "menu") ? Menu : MenuItem; } else if (str == "item" || str == "itemrow" || str == "header") { #ifdef Q_OS_MAC m_font.setPointSize(11.0); emit fontChanged(); #endif if (str == "header") { m_itemType = Header; } else { m_itemType = (str == "item") ? Item : ItemRow; } } else if (str == "groupbox") { m_itemType = GroupBox; } else if (str == "tab") { m_itemType = Tab; } else if (str == "tabframe") { m_itemType = TabFrame; } else if (str == "comboboxitem") { // Gtk uses qobject cast, hence we need to separate this from menuitem // On mac, we temporarily use the menu item because it has more accurate // palette. m_itemType = ComboBoxItem; } else if (str == "toolbar") { m_itemType = ToolBar; } else if (str == "toolbutton") { m_itemType = ToolButton; } else if (str == "slider") { m_itemType = Slider; } else if (str == "frame") { m_itemType = Frame; } else if (str == "combobox") { m_itemType = ComboBox; } else if (str == "splitter") { m_itemType = Splitter; } else if (str == "progressbar") { m_itemType = ProgressBar; } else if (str == "button") { m_itemType = Button; } else if (str == "checkbox") { m_itemType = CheckBox; } else if (str == "radiobutton") { m_itemType = RadioButton; } else if (str == "edit") { m_itemType = Edit; } else if (str == "spinbox") { m_itemType = SpinBox; } else if (str == "scrollbar") { m_itemType = ScrollBar; } else if (str == "widget") { m_itemType = Widget; } else if (str == "focusframe") { m_itemType = FocusFrame; } else if (str == "dial") { m_itemType = Dial; } else if (str == "statusbar") { m_itemType = StatusBar; } else if (str == "machelpbutton") { m_itemType = MacHelpButton; } else if (str == "scrollareacorner") { m_itemType = ScrollAreaCorner; } else if (str == "menubar") { m_itemType = MenuBar; } else if (str == "menubaritem") { m_itemType = MenuBarItem; } else { m_itemType = Undefined; } updateSizeHint(); }