void MainWindow::focusInsideDockWidget(QObject *dockWidget) { if (!dockWidget) return; // CX_LOG_CHANNEL_DEBUG("HELP_DB") << QString(" try mw::focus [%1](%2)") // .arg(dockWidget->objectName()) // .arg(dockWidget->metaObject()->className()); // focusing to docked widgets is required by the help system // Assume structure: QDockWidget->QScrollArea->QWidget, // as defined in MainWindow::addAsDockWidget() QDockWidget* dw = dynamic_cast<QDockWidget*>(dockWidget); if (!dw) return; if (dw->parent()!=this) // avoid events from other mainwindows return; QScrollArea* sa = dynamic_cast<QScrollArea*>(dw->widget()); if (!sa) return; if (!sa->widget()) return; // CX_LOG_CHANNEL_DEBUG("HELP_DB") << QString(" do mw::focus [%1](%2)") // .arg(sa->widget()->objectName()) // .arg(sa->widget()->metaObject()->className()); QTimer::singleShot(0, sa->widget(), SLOT(setFocus())); // avoid loops etc by send async event. }
void ShareUserGroupWidget::slotAdjustScrollWidgetSize() { QScrollArea *scrollArea = _ui->scrollArea; if (scrollArea->findChildren<ShareWidget*>().count() <= 3) { auto minimumSize = scrollArea->widget()->sizeHint(); auto spacing = scrollArea->widget()->layout()->spacing(); minimumSize.rwidth() += spacing; minimumSize.rheight() += spacing; scrollArea->setMinimumSize(minimumSize); } }
void SettingsBottomView::resizeEvent(QResizeEvent* event) { int pages = stack->count(); for (int p = 0; p < pages; ++p) { QScrollArea* scrollArea = qobject_cast<QScrollArea*>(stack->widget(p)); QWidget* page = scrollArea->widget(); page->setFixedWidth(scrollArea->width()); } }
void ScrollAreaWidgetContainer::addWidget(QWidget *widget) { QScrollArea *scrollArea = extendedScrollArea(); if (scrollArea->widget()) { qmlInfo(scrollArea) << "Can not add multiple Widgets to ScrollArea"; } else { scrollArea->setWidget(widget); } }
ImageWidget* MainWindow::GetImageWidget(int index) const { QWidget* widget = ui->imagetab->widget(index); if (widget) { QScrollArea* area = qobject_cast<QScrollArea*>(widget); return qobject_cast<ImageWidget*>(area->widget()); } return nullptr; }
void ExpandingTextEdit::reallyEnsureCursorVisible() { QObject *ancestor = parent(); while (ancestor) { QScrollArea *scrollArea = qobject_cast<QScrollArea*>(ancestor); if (scrollArea && (scrollArea->verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff && scrollArea->horizontalScrollBarPolicy() != Qt::ScrollBarAlwaysOff)) { const QRect &r = cursorRect(); const QPoint &c = mapTo(scrollArea->widget(), r.center()); scrollArea->ensureVisible(c.x(), c.y()); break; } ancestor = ancestor->parent(); } }
void MainWindow::onSaveButton() { DataItem items; if (avatarWidget) { DataItem avatarItem = avatarWidget->item(); items.addSubitem(avatarItem); } for (int i = 0; i < ui.detailsStackedWidget->count(); ++i) { QWidget *widget = ui.detailsStackedWidget->widget(i); Q_ASSERT(qobject_cast<QScrollArea*>(widget)); QScrollArea *scrollArea = static_cast<QScrollArea*>(widget); AbstractDataForm *dataFrom = qobject_cast<AbstractDataForm*>(scrollArea->widget()); if (!dataFrom) continue; if (dataFrom->objectName() == "General") { foreach (const DataItem &item, dataFrom->item().subitems()) items.addSubitem(item); } else {
void SettingsBottomView::commit() { int pages = stack->count(); for (int p = 0; p < pages; ++p) { QScrollArea* scrollArea = qobject_cast<QScrollArea*>(stack->widget(p)); QWidget* page = scrollArea->widget(); QGridLayout* layout = qobject_cast<QGridLayout*>(page->layout()); QModelIndex pageIndex = model()->index(p, 0); for (int i = 0; i < layout->rowCount(); ++i) { QLayoutItem* item = layout->itemAtPosition(i, 1); if (!item) continue; // Prevent segfault for empty layout QWidget* editor = item->widget(); QModelIndex dataIndex = model()->index(i, 0, pageIndex); itemDelegate()->setModelData(editor, model(), dataIndex); } } }
void SettingsBottomView::dataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight) { QModelIndex parent = topLeft.parent(); // If modifying data for a group, don't do anything if (!parent.isValid()) return; // Don't allow modifying more than one data element if (topLeft != bottomRight) { qDebug() << "Warning: the settings view does not allow batch modification"; return; } QScrollArea* scrollArea = qobject_cast<QScrollArea*>(stack->widget(parent.row())); QWidget* page = scrollArea->widget(); QGridLayout* layout = qobject_cast<QGridLayout*>(page->layout()); QWidget* widget; QLayoutItem* item; // Setting description item = layout->itemAtPosition(topLeft.row(), 0); QString description = getSettingDescription(topLeft); if (!item) { widget = new QLabel(description, NULL); layout->addWidget(widget, topLeft.row(), 0); } else { widget = item->widget(); qobject_cast<QLabel*>(widget)->setText(description); } // Setting value item = layout->itemAtPosition(topLeft.row(), 1); if (!item) { widget = createEditorForIndex(topLeft); layout->addWidget(widget, topLeft.row(), 1); widget->show(); } else { widget = item->widget(); } QAbstractItemDelegate* delegate = itemDelegate(topLeft); delegate->setEditorData(widget, topLeft); }
bool SettingsBottomView::editorValuesChanged() { QScrollArea* scrollArea = qobject_cast<QScrollArea*>(stack->currentWidget()); QWidget* page = scrollArea->widget(); QGridLayout* layout = qobject_cast<QGridLayout*>(page->layout()); QModelIndex pageIndex = model()->index(stack->currentIndex(), 0); for (int i = 0; i < layout->rowCount(); ++i) { QLayoutItem* item = layout->itemAtPosition(i, 1); if (!item) continue; // Prevent segfault for empty layout QWidget* editor = item->widget(); QByteArray propertyName = editor->metaObject()->userProperty().name(); QVariant editorData = editor->property(propertyName); QModelIndex dataIndex = model()->index(i, 0, pageIndex); QVariant modelData = model()->data(dataIndex, Qt::EditRole); if (!variantsEqual(editorData, modelData)) return true; } return false; }
//----------------------------------------------------------------------------- // Function: RemapConditionDelegate::setModelData() //----------------------------------------------------------------------------- void RemapConditionDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, QModelIndex const& index) const { if (index.column() == RemapConditionColumns::NAME_COLUMN) { ReferenceSelector* referenceSelector = qobject_cast<ReferenceSelector*>(editor); QString text = referenceSelector->currentText(); model->setData(index, text, Qt::EditRole); } else if (index.column() == RemapConditionColumns::VALUE_COLUMN && valueIsArray(index)) { QScrollArea* scrollWidget = qobject_cast<QScrollArea*>(editor); ArrayView* arrayTable = qobject_cast<ArrayView*>(scrollWidget->widget()); ParameterArrayModel* arrayModel = qobject_cast<ParameterArrayModel*>(arrayTable->model()); QString arrayValue = arrayModel->getArrayData(); model->setData(index, arrayValue, Qt::EditRole); } else { ExpressionDelegate::setModelData(editor, model, index); } }
void ViewProviderFemConstraint::checkForWizard() { wizardWidget= NULL; wizardSubLayout = NULL; Gui::MainWindow* mw = Gui::getMainWindow(); if (mw == NULL) return; QDockWidget* dw = mw->findChild<QDockWidget*>(QObject::tr("Combo View")); if (dw == NULL) return; QWidget* cw = dw->findChild<QWidget*>(QObject::tr("Combo View")); if (cw == NULL) return; QTabWidget* tw = cw->findChild<QTabWidget*>(QObject::tr("combiTab")); if (tw == NULL) return; QStackedWidget* sw = tw->findChild<QStackedWidget*>(QObject::tr("qt_tabwidget_stackedwidget")); if (sw == NULL) return; QScrollArea* sa = sw->findChild<QScrollArea*>(); if (sa== NULL) return; QWidget* wd = sa->widget(); // This is the reason why we cannot use findChildByName() right away!!! if (wd == NULL) return; QObject* wiz = findChildByName(wd, QObject::tr("ShaftWizard")); // FIXME: Actually, we don't want to translate this... if (wiz != NULL) { wizardWidget = static_cast<QVBoxLayout*>(wiz); wizardSubLayout = wiz->findChild<QVBoxLayout*>(QObject::tr("ShaftWizardLayout")); } }
void Kleo::CryptoConfigModule::init( Layout layout ) { Kleo::CryptoConfig * const config = mConfig; const KPageView::FaceType type=determineJanusFace( config, layout ); setFaceType(type); QVBoxLayout * vlay = 0; QWidget * vbox = 0; if ( type == Plain ) { vbox = new QWidget(this); vlay = new QVBoxLayout( vbox ); vlay->setSpacing( KDialog::spacingHint() ); vlay->setMargin( 0 ); addPage( vbox, i18n("GpgConf Error") ); } const QStringList components = config->componentList(); for ( QStringList::const_iterator it = components.begin(); it != components.end(); ++it ) { //kDebug(5150) <<"Component" << (*it).toLocal8Bit() <<":"; Kleo::CryptoConfigComponent* comp = config->component( *it ); Q_ASSERT( comp ); if ( comp->groupList().empty() ) continue; if ( type != Plain ) { vbox = new QWidget(this); vlay = new QVBoxLayout( vbox ); vlay->setSpacing( KDialog::spacingHint() ); vlay->setMargin( 0 ); KPageWidgetItem *pageItem = new KPageWidgetItem( vbox, comp->description() ); if ( type != Tabbed ) pageItem->setIcon( loadIcon( comp->iconName() ) ); addPage(pageItem); } QScrollArea* scrollArea = type == Tabbed ? new QScrollArea( this ) : new ScrollArea( this ); scrollArea->setWidgetResizable( true ); vlay->addWidget( scrollArea ); CryptoConfigComponentGUI* compGUI = new CryptoConfigComponentGUI( this, comp, scrollArea ); compGUI->setObjectName( *it ); scrollArea->setWidget( compGUI ); scrollArea->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); // KJanusWidget doesn't seem to have iterators, so we store a copy... mComponentGUIs.append( compGUI ); // Set a nice startup size const int deskHeight = QApplication::desktop()->height(); int dialogHeight; if (deskHeight > 1000) // very big desktop ? dialogHeight = 800; else if (deskHeight > 650) // big desktop ? dialogHeight = 500; else // small (800x600, 640x480) desktop dialogHeight = 400; assert( scrollArea->widget() ); if ( type != Tabbed ) scrollArea->setMinimumHeight( qMin( compGUI->sizeHint().height(), dialogHeight ) ); } if ( mComponentGUIs.empty() ) { const QString msg = i18n("The gpgconf tool used to provide the information " "for this dialog does not seem to be installed " "properly. It did not return any components. " "Try running \"%1\" on the command line for more " "information.", components.empty() ? "gpgconf --list-components" : "gpgconf --list-options gpg" ); QLabel * label = new QLabel( msg, vbox ); label->setWordWrap( true); label->setMinimumHeight( fontMetrics().lineSpacing() * 5 ); vlay->addWidget( label ); } }
PFSViewMainWin::PFSViewMainWin( float window_min, float window_max ): QMainWindow( 0 ) { currentFrame = frameList.end(); QScrollArea *pfsViewArea = new PFSViewWidgetArea( this ); pfsView = (PFSViewWidget*)pfsViewArea->widget(); setCentralWidget( pfsViewArea ); setWindowIcon( QIcon( ":icons/appicon.png" ) ); QAction *nextFrameAct = new QAction( tr( "&Next frame" ), this ); nextFrameAct->setStatusTip( tr( "Load next frame" ) ); nextFrameAct->setShortcut( Qt::Key_PageDown ); connect( nextFrameAct, SIGNAL(triggered()), this, SLOT(gotoNextFrame()) ); QAction *previousFrameAct = new QAction( tr( "&Previous frame" ), this ); previousFrameAct->setStatusTip( tr( "Load previous frame" ) ); previousFrameAct->setShortcut( Qt::Key_PageUp ); connect( previousFrameAct, SIGNAL(triggered()), this, SLOT(gotoPreviousFrame()) ); QToolBar *toolBar = addToolBar( tr( "Navigation" ) ); // toolBar->setHorizontalStretchable( true ); QToolButton *previousFrameBt = new QToolButton( toolBar ); previousFrameBt->setArrowType( Qt::LeftArrow ); previousFrameBt->setMinimumWidth( 15 ); connect( previousFrameBt, SIGNAL(clicked()), this, SLOT(gotoPreviousFrame()) ); previousFrameBt->setToolTip( "Goto previous frame" ); toolBar->addWidget( previousFrameBt ); QToolButton *nextFrameBt = new QToolButton( toolBar ); nextFrameBt->setArrowType( Qt::RightArrow ); nextFrameBt->setMinimumWidth( 15 ); connect( nextFrameBt, SIGNAL(clicked()), this, SLOT(gotoNextFrame()) ); nextFrameBt->setToolTip( "Goto next frame" ); toolBar->addWidget( nextFrameBt ); QLabel *channelSelLabel = new QLabel( "&Channel", toolBar ); channelSelection = new QComboBox( toolBar ); channelSelLabel->setBuddy( channelSelection ); connect( channelSelection, SIGNAL( activated( int ) ), this, SLOT( setChannelSelection(int) ) ); toolBar->addWidget( channelSelLabel ); toolBar->addWidget( channelSelection ); toolBar->addSeparator(); QLabel *mappingMethodLabel = new QLabel( "&Mapping", toolBar ); mappingMethodLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); // | // Qt::TextExpandTabs | Qt::TextShowMnemonic ); mappingMethodCB = new QComboBox( toolBar ); mappingMethodLabel->setBuddy( mappingMethodCB ); mappingMethodCB->addItem( "Linear" ); mappingMethodCB->addItem( "Gamma 1.4" ); mappingMethodCB->addItem( "Gamma 1.8" ); mappingMethodCB->addItem( "Gamma 2.2" ); mappingMethodCB->addItem( "Gamma 2.6" ); mappingMethodCB->addItem( "Logarithmic" ); mappingMethodCB->setCurrentIndex( 3 ); connect( mappingMethodCB, SIGNAL( activated( int ) ), this, SLOT( setLumMappingMethod(int) ) ); toolBar->addWidget( mappingMethodLabel ); toolBar->addWidget( mappingMethodCB ); // addToolBar( Qt::BottomToolBarArea, toolBar ); QToolBar *toolBarLR = addToolBar( tr( "Histogram" ) ); lumRange = new LuminanceRangeWidget( toolBarLR ); connect( lumRange, SIGNAL( updateRangeWindow() ), this, SLOT( updateRangeWindow() ) ); toolBarLR->addWidget( lumRange ); // addToolBar( toolBar ); pointerPosAndVal = new QLabel( statusBar() ); statusBar()->addWidget( pointerPosAndVal ); // QFont fixedFont = QFont::defaultFont(); // fixedFont.setFixedPitch( true ); // pointerPosAndVal->setFont( fixedFont ); zoomValue = new QLabel( statusBar() ); statusBar()->addWidget( zoomValue ); exposureValue = new QLabel( statusBar() ); statusBar()->addWidget( exposureValue ); connect( pfsView, SIGNAL(updatePointerValue()), this, SLOT(updatePointerValue()) ); QMenu *frameMenu = menuBar()->addMenu( tr( "&Frame" ) ); frameMenu->addAction( nextFrameAct ); frameMenu->addAction( previousFrameAct ); frameMenu->addSeparator(); frameMenu->addAction( "&Save image...", this, SLOT(saveImage()), QKeySequence::Save ); frameMenu->addAction( "&Copy image to clipboard", this, SLOT(copyImage()), QKeySequence::Copy ); frameMenu->addSeparator(); frameMenu->addAction( "&Quit", qApp, SLOT(quit()), Qt::Key_Q ); //QKeySequence::Quit QShortcut *shortcut = new QShortcut( QKeySequence::Close, this ); connect( shortcut, SIGNAL(activated()), qApp, SLOT(quit()) ); QAction *act; QMenu *viewMenu = menuBar()->addMenu( tr( "&View" ) ); act = viewMenu->addAction( "&Zoom in", pfsView, SLOT(zoomIn()), Qt::Key_Period ); // QKeySequence::ZoomIn -- not doing it -- silly binding under Linux connect( act, SIGNAL(triggered()), this, SLOT(updateZoomValue()) ); act = viewMenu->addAction( "Zoom &out", pfsView, SLOT(zoomOut()), Qt::Key_Comma ); connect( act, SIGNAL(triggered()), this, SLOT(updateZoomValue()) ); act = viewMenu->addAction( "Zoom &1:1", pfsView, SLOT(zoomOriginal()), Qt::Key_N ); connect( act, SIGNAL(triggered()), this, SLOT(updateZoomValue()) ); viewMenu->addAction( "&Fit window to content", this, SLOT(updateViewSize()), Qt::Key_C ); viewMenu->addSeparator(); QMenu *infnanMenu = viewMenu->addMenu( "NaN and &Inf values" ); QActionGroup *infnanActGrp = new QActionGroup( this ); infnanActGrp->setExclusive( true ); QAction *infnanHideAct = new QAction( tr( "&Hide" ), this ); infnanHideAct->setCheckable(true); infnanHideAct->setData(0); infnanActGrp->addAction( infnanHideAct ); infnanMenu->addAction( infnanHideAct ); QAction *infnanMarkAct = new QAction( tr( "Mark with &red color" ), this ); infnanMarkAct->setCheckable(true); infnanMarkAct->setData(1); infnanActGrp->addAction( infnanMarkAct ); infnanMenu->addAction( infnanMarkAct ); infnanMarkAct->setChecked( true ); connect( infnanActGrp, SIGNAL(triggered(QAction*)), pfsView, SLOT(setInfNaNTreatment(QAction*)) ); QMenu *colorClipMenu = viewMenu->addMenu( "&Color clipping" ); QActionGroup *colorClipActGrp = new QActionGroup( this ); colorClipActGrp->setExclusive( true ); QAction *colorClipSimpleAct = new QAction( tr( "&Simple clipping" ), this ); colorClipSimpleAct->setCheckable(true); colorClipSimpleAct->setData(CLIP_SIMPLE); colorClipSimpleAct->setShortcut( Qt::CTRL + Qt::Key_H ); colorClipActGrp->addAction( colorClipSimpleAct ); colorClipMenu->addAction( colorClipSimpleAct ); QAction *colorClipCodedAct = new QAction( tr( "&Color-coded clipping" ), this ); colorClipCodedAct->setCheckable(true); colorClipCodedAct->setShortcut( Qt::CTRL + Qt::Key_J ); colorClipCodedAct->setData(CLIP_COLORCODED); colorClipActGrp->addAction( colorClipCodedAct ); colorClipMenu->addAction( colorClipCodedAct ); QAction *colorClipBriHueAct = new QAction( tr( "&Keep brightness and hue" ), this ); colorClipBriHueAct->setCheckable(true); colorClipBriHueAct->setShortcut( Qt::CTRL + Qt::Key_K ); colorClipBriHueAct->setData(CLIP_KEEP_BRI_HUE); colorClipActGrp->addAction( colorClipBriHueAct ); colorClipMenu->addAction( colorClipBriHueAct ); colorClipSimpleAct->setChecked( true ); connect( colorClipActGrp, SIGNAL(triggered(QAction*)), pfsView, SLOT(setRGBClippingMethod(QAction*)) ); QMenu *negativeMenu = viewMenu->addMenu( "&Negative values" ); QActionGroup *negativeActGrp = new QActionGroup( this ); negativeActGrp->setExclusive( true ); act = new QAction( tr( "&Black" ), this ); act->setCheckable(true); act->setData(NEGATIVE_BLACK); act->setShortcut( Qt::ALT + Qt::Key_B ); negativeActGrp->addAction( act ); negativeMenu->addAction( act ); act->setChecked( true ); act = new QAction( tr( "Mark with &red color" ), this ); act->setCheckable(true); act->setData(NEGATIVE_MARK_AS_RED); act->setShortcut( Qt::ALT + Qt::Key_R ); negativeActGrp->addAction( act ); negativeMenu->addAction( act ); act = new QAction( tr( "Use &green color scale" ), this ); act->setCheckable(true); act->setData(NEGATIVE_GREEN_SCALE); act->setShortcut( Qt::ALT + Qt::Key_G ); negativeActGrp->addAction( act ); negativeMenu->addAction( act ); act = new QAction( tr( "Use &absolute values" ), this ); act->setCheckable(true); act->setData(NEGATIVE_ABSOLUTE); act->setShortcut( Qt::ALT + Qt::Key_A ); negativeActGrp->addAction( act ); negativeMenu->addAction( act ); connect( negativeActGrp, SIGNAL(triggered(QAction*)), pfsView, SLOT(setNegativeTreatment(QAction*)) ); viewMenu->addSeparator(); QMenu *colorCoordMenu = viewMenu->addMenu( "Color coo&rdinates" ); QActionGroup *colorCoordActGrp = new QActionGroup( this ); colorCoordActGrp->setExclusive( true ); act = new QAction( tr( "&RGB" ), this ); act->setCheckable(true); act->setData(CC_RGB); act->setShortcut( Qt::SHIFT + Qt::ALT + Qt::Key_R ); colorCoordActGrp->addAction( act ); colorCoordMenu->addAction( act ); act->setChecked( true ); act = new QAction( tr( "&XYZ" ), this ); act->setCheckable(true); act->setData(CC_XYZ); act->setShortcut( Qt::SHIFT + Qt::ALT + Qt::Key_X ); colorCoordActGrp->addAction( act ); colorCoordMenu->addAction( act ); act = new QAction( tr( "Y&u'v'" ), this ); act->setCheckable(true); act->setData(CC_Yupvp); act->setShortcut( Qt::SHIFT + Qt::ALT + Qt::Key_U ); colorCoordActGrp->addAction( act ); colorCoordMenu->addAction( act ); act = new QAction( tr( "Yx&y" ), this ); act->setCheckable(true); act->setData(CC_Yxy); act->setShortcut( Qt::SHIFT + Qt::ALT + Qt::Key_Y ); colorCoordActGrp->addAction( act ); colorCoordMenu->addAction( act ); connect( colorCoordActGrp, SIGNAL(triggered(QAction*)), this, SLOT(setColorCoord(QAction*)) ); QMenu *mappingMenu = menuBar()->addMenu( tr( "&Tone mapping" ) ); mappingMenu->addAction( "Increase exposure", lumRange, SLOT(increaseExposure()), Qt::Key_Minus ); mappingMenu->addAction( "Decrease exposure", lumRange, SLOT(decreaseExposure()), Qt::Key_Equal ); mappingMenu->addAction( "Extend dynamic range", lumRange, SLOT(extendRange()), Qt::Key_BracketRight ); mappingMenu->addAction( "Shrink dynamic range", lumRange, SLOT(shrinkRange()), Qt::Key_BracketLeft ); mappingMenu->addAction( "Fit to dynamic range", lumRange, SLOT(fitToDynamicRange()), Qt::Key_Backslash ); mappingMenu->addAction( "Low dynamic range", lumRange, SLOT(lowDynamicRange()), Qt::ALT + Qt::Key_L ); QMenu *mapfuncMenu = mappingMenu->addMenu( "&Mapping function" ); QActionGroup *mapfuncActGrp = new QActionGroup( this ); mapfuncActGrp->setExclusive( true ); mappingAct[0] = act = new QAction( tr( "&Linear" ), this ); act->setCheckable(true); act->setData(0); act->setShortcut( Qt::Key_L ); mapfuncActGrp->addAction( act ); mapfuncMenu->addAction( act ); mappingAct[1] = act = new QAction( tr( "Gamma 1.&4" ), this ); act->setCheckable(true); act->setData(1); act->setShortcut( Qt::Key_1 ); mapfuncActGrp->addAction( act ); mapfuncMenu->addAction( act ); mappingAct[2] = act = new QAction( tr( "Gamma 1.&8" ), this ); act->setCheckable(true); act->setData(2); act->setShortcut( Qt::Key_2 ); mapfuncActGrp->addAction( act ); mapfuncMenu->addAction( act ); mappingAct[3] = act = new QAction( tr( "Gamma 2.&2" ), this ); act->setCheckable(true); act->setData(3); act->setChecked( true ); act->setShortcut( Qt::Key_3 ); mapfuncActGrp->addAction( act ); mapfuncMenu->addAction( act ); mappingAct[4] = act = new QAction( tr( "Gamma 2.&6" ), this ); act->setCheckable(true); act->setData(4); act->setShortcut( Qt::Key_4 ); mapfuncActGrp->addAction( act ); mapfuncMenu->addAction( act ); mappingAct[5] = act = new QAction( tr( "L&ogarithmic" ), this ); act->setCheckable(true); act->setData(5); act->setShortcut( Qt::Key_O ); mapfuncActGrp->addAction( act ); mapfuncMenu->addAction( act ); connect( mapfuncActGrp, SIGNAL(triggered(QAction*)), this, SLOT(setLumMappingMethod(QAction*)) ); QMenu *helpMenu = menuBar()->addMenu( tr( "&Help" ) ); helpMenu->addAction( "&About", this, SLOT(showAboutdialog()) ); colorCoord = CC_RGB; //Window should not be larger than desktop // TODO: how to find desktop size - gnome taksbars // setMaximumSize( QApplication::desktop()->width(), QApplication::desktop()->height() ); try { if( !readNextFrame() ) throw PFSViewException(); if( window_min < window_max ) lumRange->setRangeWindowMinMax( window_min, window_max ); } catch( pfs::Exception ex ) { QMessageBox::critical( this, "pfsview error", ex.getMessage() ); throw PFSViewException(); } }
// Setup widget void MyWidget::setup(int layoutMargin, QString borderColor, QString backgroundColor) { // Some styling visibleArea = QSize(600,400); this->borderColor = borderColor; this->backgroundColor = (backgroundColor == "" ? "rgba(0,0,0,200)" : backgroundColor); borderLeftRight = -1; borderTopDown = -1; fullscreen = false; // The different QRects rectShown = QRect(); rectHidden = QRect(0,-10,10,10); rectAni = QRect(); // The current geometry and position isShown = false; this->setGeometry(rectHidden); // Fading backOpacityShow = 0.5; backOpacityCur = 0; centerOpacityCur = 0; fade = new QTimeLine; fadeIN = true; fadeEffectCenter = new QGraphicsOpacityEffect; connect(fade, SIGNAL(valueChanged(qreal)), this, SLOT(fadeStep())); connect(fade, SIGNAL(finished()), this, SLOT(aniFinished())); // The current widget look this->setStyleSheet(QString("background: rgba(0,0,0,%1);").arg(255*backOpacityShow)); // the central widget containing all the information center = new QWidget(this); center->setGraphicsEffect(fadeEffectCenter); center->setObjectName("center"); // For some reason, if the border is not defined right here at the beginning, it wont be visible... if(borderColor == "") center->setStyleSheet(QString("#center { background: %1; border-radius: 10px; font-size: 12pt; }").arg(this->backgroundColor)); else center->setStyleSheet(QString("#center {background: %1; border-radius: 15px; font-size: 12pt; border: 2px solid %2; }").arg(this->backgroundColor).arg(borderColor)); // Create and set the scrollarea with main layout QVBoxLayout *central = new QVBoxLayout; central->setMargin(layoutMargin); QScrollArea *scroll = new QScrollArea(this); scroll->setObjectName("scrollWidget"); scroll->setStyleSheet("QWidget#scrollWidget { background: transparent; padding-bottom: 3px; border-radius: 0px; }"); QWidget *scrollWidget = new QWidget(scroll->widget()); scrollWidget->setStyleSheet("background: transparent;"); scroll->setWidgetResizable(true); scroll->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); scrollWidget->setLayout(central); scroll->setWidget(scrollWidget); mainlayout = new QVBoxLayout; if(layoutMargin == 0) mainlayout->setMargin(0); center->setLayout(mainlayout); mainlayout->addWidget(scroll); // This widget gets the main layout set to centralWidget = new QWidget; central->addWidget(centralWidget); // And set the custom scrollbar scrollbar = new CustomScrollbar; scroll->setVerticalScrollBar(scrollbar); // And in case the monitor resolution is so small, that the horizontal scrollbar is visible: CustomScrollbar *scrollbarHor = new CustomScrollbar; scroll->setHorizontalScrollBar(scrollbarHor); }
void TilesetItemBox::makeSelectedTileset(int tabIndex) { if(lockTilesetBox) return; QGraphicsScene *scene = NULL; LevelEdit *lvlEdit = mw()->activeLvlEditWin(); WorldEdit *wldEdit = mw()->activeWldEditWin(); if((lvlEdit) && (lvlEdit->sceneCreated)) scene = lvlEdit->scene; else if((wldEdit) && (wldEdit->sceneCreated)) scene = wldEdit->scene; QTabWidget *cat = ui->TileSetsCategories; if(!(cat->tabText(tabIndex) == "Custom")) { QWidget *current = cat->widget(tabIndex); if(!current) return; QString category = cat->tabText(tabIndex); #ifdef _DEBUG_ DevConsole::log(QString("Category %1").arg(cat->tabText(cat->currentIndex())), "Debug"); #endif QScrollArea *currentFrame = getFrameTilesetOfTab(current); QComboBox *currentCombo = getGroupComboboxOfTab(current); if(!currentFrame || !currentCombo) return; QWidget *scrollWid = currentFrame->widget(); if(!scrollWid) return; qDeleteAll(scrollWid->findChildren<QGroupBox *>()); if(scrollWid->layout() == 0) scrollWid->setLayout(new FlowLayout()); currentFrame->setWidgetResizable(true); #ifdef _DEBUG_ DevConsole::log(QString("size %1 %2") .arg(scrollWid->layout()->geometry().width()) .arg(scrollWid->layout()->geometry().height()) , "Debug"); #endif QString currentGroup = currentCombo->currentText(); for(int i = 0; i < mw()->configs.main_tilesets_grp.size(); i++) { if((mw()->configs.main_tilesets_grp[i].groupCat == category) && (mw()->configs.main_tilesets_grp[i].groupName == currentGroup)) //category { #ifdef _DEBUG_ DevConsole::log(QString("Group %1").arg(configs.main_tilesets_grp[i].groupName), "Debug"); DevConsole::log(QString("Tilesets %1").arg(configs.main_tilesets_grp[i].tilesets.size()), "Debug"); #endif QStringList l = mw()->configs.main_tilesets_grp[i].tilesets; foreach(QString s, l) { for(int j = 0; j < mw()->configs.main_tilesets.size(); j++) { if(s == mw()->configs.main_tilesets[j].fileName) { SimpleTileset &s = mw()->configs.main_tilesets[j]; QGroupBox *tilesetNameWrapper = new QGroupBox(s.tileSetName, scrollWid); ((FlowLayout *)scrollWid->layout())->addWidget(tilesetNameWrapper); QGridLayout *l = new QGridLayout(tilesetNameWrapper); l->setContentsMargins(4, 4, 4, 4); l->setSpacing(2); for(int k = 0; k < s.items.size(); k++) { SimpleTilesetItem &item = s.items[k]; TilesetItemButton *tbutton = new TilesetItemButton(&mw()->configs, scene, tilesetNameWrapper); tbutton->applySize(32, 32); tbutton->applyItem(s.type, item.id); l->addWidget(tbutton, item.row, item.col); connect(tbutton, SIGNAL(clicked(int, ulong)), mw(), SLOT(SwitchPlacingItem(int, ulong))); } break; } } } break; } }