void AbstractContent::keyPressEvent(QKeyEvent * event) { // discard key events for unselectable items if (!(flags() & ItemIsSelectable)) { event->ignore(); return; } event->accept(); int step = (event->modifiers() & Qt::ShiftModifier) ? 50 : (event->modifiers() & Qt::ControlModifier ? 1 : 10); switch (event->key()) { // cursor keys: 10px, 50 if Shift pressed, 1 if Control pressed case Qt::Key_Left: setPos(pos() - QPointF(step, 0)); break; case Qt::Key_Up: setPos(pos() - QPointF(0, step)); break; case Qt::Key_Right: setPos(pos() + QPointF(step, 0)); break; case Qt::Key_Down: setPos(pos() + QPointF(0, step)); break; // deletion case Qt::Key_Delete: emit requestRemoval(); break; // editing case Qt::Key_Return: emit requestEditing(); break; // ignore unhandled key default: event->ignore(); } }
RoutingInputWidget::RoutingInputWidget( MarbleModel* model, int index, QWidget *parent ) : QWidget( parent ), d( new RoutingInputWidgetPrivate( model, index, this ) ) { QHBoxLayout *layout = new QHBoxLayout( this ); layout->setSizeConstraint( QLayout::SetMinimumSize ); layout->setSpacing( 0 ); layout->setMargin( 0 ); layout->addWidget( d->m_lineEdit ); layout->addWidget( d->m_removeButton ); bool const smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen; if ( smallScreen ) { connect( d->m_lineEdit, SIGNAL(decoratorButtonClicked()), this, SLOT(openTargetSelectionDialog()) ); } else { d->createMenu( this ); connect(d->m_lineEdit, SIGNAL(decoratorButtonClicked()), this, SLOT(showMenu())); } connect( d->m_removeButton, SIGNAL(clicked()), this, SLOT(requestRemoval()) ); connect( d->m_marbleModel->bookmarkManager(), SIGNAL(bookmarksChanged()), this, SLOT(reloadBookmarks()) ); connect( d->m_marbleModel->positionTracking(), SIGNAL(statusChanged(PositionProviderStatus)), this, SLOT(updateCurrentLocationButton(PositionProviderStatus)) ); connect( &d->m_placemarkRunnerManager, SIGNAL(searchResultChanged(QAbstractItemModel*)), this, SLOT(setPlacemarkModel(QAbstractItemModel*)) ); connect( &d->m_reverseGeocodingRunnerManager, SIGNAL(reverseGeocodingFinished(GeoDataCoordinates,GeoDataPlacemark)), this, SLOT(retrieveReverseGeocodingResult(GeoDataCoordinates,GeoDataPlacemark)) ); connect( d->m_lineEdit, SIGNAL(returnPressed()), this, SLOT(findPlacemarks()) ); connect( d->m_lineEdit, SIGNAL(textEdited(QString)), this, SLOT(setInvalid()) ); connect( &d->m_placemarkRunnerManager, SIGNAL(searchFinished(QString)), this, SLOT(finishSearch()) ); connect( d->m_marbleModel->routingManager()->routeRequest(), SIGNAL(positionChanged(int,GeoDataCoordinates)), this, SLOT(updatePosition(int,GeoDataCoordinates)) ); connect( &d->m_nominatimTimer, SIGNAL(timeout()), this, SLOT(reverseGeocoding()) ); connect( this, SIGNAL(targetValidityChanged(bool)), this, SLOT(updateCenterButton(bool)) ); updateCenterButton( hasTargetPosition() ); d->adjustText(); }
AbstractConfig::AbstractConfig(AbstractContent * content, AbstractConfig_PARENT * parent) : AbstractConfig_TYPE(parent) , m_content(content) , m_commonUi(new Ui::AbstractConfig()) #if !defined(MOBILE_UI) , m_closeButton(0) , m_okButton(0) #endif , m_frame(FrameFactory::defaultPanelFrame()) { #if !defined(MOBILE_UI) // close button m_closeButton = new StyledButtonItem(tr(" x "), font(), this);//this, ":/data/button-close.png", ":/data/button-close-hovered.png", ":/data/button-close-pressed.png"); connect(m_closeButton, SIGNAL(clicked()), this, SIGNAL(requestClose())); // WIDGET setup (populate contents and set base palette (only) to transparent) QWidget * widget = new QWidget(); m_commonUi->setupUi(widget); QPalette pal; QColor oldColor = pal.window().color(); pal.setBrush(QPalette::Window, Qt::transparent); widget->setPalette(pal); pal.setBrush(QPalette::Window, oldColor); m_commonUi->tab->setPalette(pal); #else m_commonUi->setupUi(this); #endif populateFrameList(); // select the frame quint32 frameClass = m_content->frameClass(); if (frameClass != Frame::NoFrame) { for (int i = 0; i < m_commonUi->framesList->count(); ++i) { QListWidgetItem * item = m_commonUi->framesList->item(i); if (item->data(Qt::UserRole).toUInt() == frameClass) { item->setSelected(true); break; } } } // read other properties m_commonUi->reflection->setChecked(m_content->mirrored()); m_commonUi->contentLocked->setChecked(m_content->locked()); m_commonUi->fixedPosition->setChecked(m_content->fixedPosition()); m_commonUi->fixedRotation->setChecked(m_content->fixedRotation()); m_commonUi->fixedPerspective->setChecked(m_content->fixedPerspective()); connect(m_commonUi->front, SIGNAL(clicked()), m_content, SLOT(slotStackFront())); connect(m_commonUi->raise, SIGNAL(clicked()), m_content, SLOT(slotStackRaise())); connect(m_commonUi->lower, SIGNAL(clicked()), m_content, SLOT(slotStackLower())); connect(m_commonUi->back, SIGNAL(clicked()), m_content, SLOT(slotStackBack())); connect(m_commonUi->save, SIGNAL(clicked()), m_content, SLOT(slotSaveAs())); connect(m_commonUi->background, SIGNAL(clicked()), m_content, SIGNAL(requestBackgrounding())); connect(m_commonUi->del, SIGNAL(clicked()), m_content, SIGNAL(requestRemoval())); connect(m_commonUi->contentLocked, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetLocked(int))); connect(m_commonUi->fixedPosition, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedPosition(int))); connect(m_commonUi->fixedRotation, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedRotation(int))); connect(m_commonUi->fixedPerspective, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedPerspective(int))); connect(m_commonUi->newFrame, SIGNAL(clicked()), this, SLOT(slotAddFrame())); connect(m_commonUi->removeFrame, SIGNAL(clicked()), this, SLOT(slotRemoveFrame())); connect(m_commonUi->lookApplyAll, SIGNAL(clicked()), this, SLOT(slotLookApplyAll())); connect(m_commonUi->framesList, SIGNAL(itemSelectionChanged()), this, SLOT(slotFrameSelectionChanged())); connect(m_commonUi->reflection, SIGNAL(toggled(bool)), this, SLOT(slotReflectionToggled(bool))); // ITEM setup #if !defined(MOBILE_UI) setFlag(QGraphicsItem::ItemIgnoresTransformations, true); setWidget(widget); static qreal s_propZBase = 99999; setZValue(s_propZBase++); #endif #if !defined(MOBILE_UI) && QT_VERSION >= 0x040600 // fade in animation QPropertyAnimation * ani = new QPropertyAnimation(this, "opacity"); ani->setEasingCurve(QEasingCurve::OutCubic); ani->setDuration(400); ani->setStartValue(0.0); ani->setEndValue(1.0); ani->start(QPropertyAnimation::DeleteWhenStopped); #endif }
AbstractContent::AbstractContent(QGraphicsScene *scene, bool fadeIn, bool noRescale, QGraphicsItem * parent) : AbstractDisposeable(fadeIn, parent) , m_contentRect(-100, -75, 200, 150) , m_frame(0) , m_frameTextItem(0) , m_controlsVisible(false) , m_dirtyTransforming(false) , m_transformRefreshTimer(0) , m_gfxChangeTimer(0) , m_mirrorItem(0) #if QT_VERSION < 0x040600 , m_rotationAngle(0) #endif , m_fxIndex(0) { // the buffered graphics changes timer m_gfxChangeTimer = new QTimer(this); m_gfxChangeTimer->setInterval(0); m_gfxChangeTimer->setSingleShot(true); // customize item's behavior setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsSelectable); #if QT_VERSION >= 0x040600 setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); #endif // allow some items (eg. the shape controls for text) to be shown setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); setAcceptHoverEvents(true); // create child controls createCorner(Qt::TopLeftCorner, noRescale); createCorner(Qt::TopRightCorner, noRescale); createCorner(Qt::BottomLeftCorner, noRescale); createCorner(Qt::BottomRightCorner, noRescale); //ButtonItem * bFront = new ButtonItem(ButtonItem::Control, Qt::blue, QIcon(":/data/action-order-front.png"), this); //bFront->setToolTip(tr("Raise")); //connect(bFront, SIGNAL(clicked()), this, SLOT(slotStackRaise())); //addButtonItem(bFront); ButtonItem * bConf = new ButtonItem(ButtonItem::Control, Qt::green, QIcon(":/data/action-configure.png"), this); bConf->setToolTip(tr("Change properties...")); connect(bConf, SIGNAL(clicked()), this, SLOT(slotConfigure())); addButtonItem(bConf); ButtonItem * bPersp = new ButtonItem(ButtonItem::Control, Qt::red, QIcon(":/data/action-perspective.png"), this); bPersp->setToolTip(tr("Drag around to change the perspective.\nHold SHIFT to move faster.\nUse CTRL to cancel the transformations.")); connect(bPersp, SIGNAL(dragging(const QPointF&,Qt::KeyboardModifiers)), this, SLOT(slotSetPerspective(const QPointF&,Qt::KeyboardModifiers))); connect(bPersp, SIGNAL(doubleClicked()), this, SLOT(slotClearPerspective())); addButtonItem(bPersp); ButtonItem * bDelete = new ButtonItem(ButtonItem::Control, Qt::red, QIcon(":/data/action-delete.png"), this); bDelete->setSelectsParent(false); bDelete->setToolTip(tr("Remove")); connect(bDelete, SIGNAL(clicked()), this, SIGNAL(requestRemoval())); addButtonItem(bDelete); // create default frame Frame * frame = FrameFactory::defaultPictureFrame(); setFrame(frame); // hide and layoutChildren buttons layoutChildren(); // add to the scene scene->addItem(this); // display mirror #if QT_VERSION >= 0x040600 // WORKAROUND with Qt 4.6-tp1 there are crashes activating a mirror before setting the scene // need to rethink this anyway setMirrored(false); #else setMirrored(RenderOpts::LastMirrored); #endif }
void TableItem::onRemoveTriggered() { if (checkLock()) return; //Can't remove locked items QSound::play("Sound/itemRemove.wav"); emit requestRemoval(this); }