Skip to content

Commit

Permalink
Mobile: use a normal widget instead of a QGraphicsProxyWidget for pro…
Browse files Browse the repository at this point in the history
…perties
  • Loading branch information
enricoros committed Jun 10, 2010
1 parent ee2ab18 commit 7694148
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 4 deletions.
9 changes: 9 additions & 0 deletions App/PictureSearchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Shared/PictureServices/FlickrPictureService.h"
#include "Shared/PictureServices/GoogleImagesPictureService.h"
#include "App.h"
#include <QApplication>
#include <QBasicTimer>
#include <QGraphicsScene>
#include <QGraphicsLinearLayout>
Expand Down Expand Up @@ -156,6 +157,14 @@ class DottedLineEdit : public QLineEdit
normalMode();
QLineEdit::mousePressEvent(event);
}
#if defined(MOBILE_UI)
void mouseReleaseEvent(QMouseEvent *)
{
//QLineEdit::mouseReleaseEvent(event);
QEvent event(QEvent::RequestSoftwareInputPanel);
QApplication::sendEvent(this, &event);
}
#endif

private:
void normalMode()
Expand Down
23 changes: 23 additions & 0 deletions Canvas/AbstractConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@
#include <QPropertyAnimation>
#endif

#if !defined(MOBILE_UI)
AbstractConfig::AbstractConfig(AbstractContent * content, QGraphicsItem * parent)
: QGraphicsProxyWidget(parent)
#else
AbstractConfig::AbstractConfig(AbstractContent * content, QWidget * parent)
: QWidget(parent)
#endif
, 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()));
Expand All @@ -54,6 +62,9 @@ AbstractConfig::AbstractConfig(AbstractContent * content, QGraphicsItem * parent
widget->setPalette(pal);
pal.setBrush(QPalette::Window, oldColor);
m_commonUi->tab->setPalette(pal);
#else
m_commonUi->setupUi(this);
#endif

populateFrameList();

Expand Down Expand Up @@ -85,10 +96,12 @@ AbstractConfig::AbstractConfig(AbstractContent * content, QGraphicsItem * parent
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
Expand Down Expand Up @@ -130,11 +143,15 @@ AbstractContent * AbstractConfig::content() const

void AbstractConfig::keepInBoundaries(const QRectF & rect)
{
#if !defined(MOBILE_UI)
QRectF r = mapToScene(boundingRect()).boundingRect();
r.setLeft(qBound(rect.left(), r.left(), rect.right() - r.width()));
r.setTop(qBound(rect.top(), r.top(), rect.bottom() - r.height()));
// CHECK SUBPIXELS
setPos(r.topLeft().toPoint());
#else
Q_UNUSED(rect);
#endif
}

void AbstractConfig::addTab(QWidget * widget, const QString & label, bool front, bool setCurrent)
Expand All @@ -153,6 +170,7 @@ void AbstractConfig::addTab(QWidget * widget, const QString & label, bool front,

void AbstractConfig::showOkButton(bool show)
{
#if !defined(MOBILE_UI)
if (show) {
if (!m_okButton) {
m_okButton = new StyledButtonItem(tr("ok"), font(), this);
Expand All @@ -162,8 +180,10 @@ void AbstractConfig::showOkButton(bool show)
m_okButton->show();
} else if (m_okButton)
m_okButton->hide();
#endif
}

#if !defined(MOBILE_UI)
void AbstractConfig::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
QGraphicsProxyWidget::mousePressEvent(event);
Expand Down Expand Up @@ -203,6 +223,7 @@ void AbstractConfig::resizeEvent(QGraphicsSceneResizeEvent * event)
layoutButtons();
QGraphicsProxyWidget::resizeEvent(event);
}
#endif

void AbstractConfig::populateFrameList()
{
Expand Down Expand Up @@ -235,6 +256,7 @@ void AbstractConfig::populateFrameList()

void AbstractConfig::layoutButtons()
{
#if !defined(MOBILE_UI)
// layout the close button
QRect cRect = boundingRect().toRect().adjusted(12, 12, -12, -12);
if (QApplication::isLeftToRight()) {
Expand All @@ -246,6 +268,7 @@ void AbstractConfig::layoutButtons()
if (m_okButton)
m_okButton->setPos(cRect.left() + m_closeButton->boundingRect().width() + 8, cRect.top());
}
#endif
}

void AbstractConfig::slotAddFrame()
Expand Down
18 changes: 15 additions & 3 deletions Canvas/AbstractConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,28 @@
#ifndef __AbstractConfig_h__
#define __AbstractConfig_h__

#include <QGraphicsProxyWidget>
#include <QBasicTimer>
#include <QGraphicsProxyWidget>
#include <QWidget>
class AbstractContent;
class Frame;
class QAbstractButton;
class QListWidgetItem;
class StyledButtonItem;
namespace Ui { class AbstractConfig; }


#if !defined(MOBILE_UI)
class AbstractConfig : public QGraphicsProxyWidget {
#else
class AbstractConfig : public QWidget {
#endif
Q_OBJECT
public:
#if !defined(MOBILE_UI)
AbstractConfig(AbstractContent * content, QGraphicsItem * parent = 0);
#else
AbstractConfig(AbstractContent * content, QWidget * parent = 0);
#endif
virtual ~AbstractConfig();

void dispose();
Expand All @@ -50,22 +58,26 @@ class AbstractConfig : public QGraphicsProxyWidget {
void showOkButton(bool show);

// ::QGraphicsProxyWidget
#if !defined(MOBILE_UI)
void mousePressEvent(QGraphicsSceneMouseEvent * event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event);
void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
void resizeEvent(QGraphicsSceneResizeEvent * event);
#endif

protected Q_SLOTS:
virtual void slotOkClicked() {};
virtual void slotOkClicked() {}

private:
void populateFrameList();
void layoutButtons();
QPixmap m_backPixmap;
AbstractContent * m_content;
Ui::AbstractConfig * m_commonUi;
#if !defined(MOBILE_UI)
StyledButtonItem * m_closeButton;
StyledButtonItem * m_okButton;
#endif
Frame * m_frame;

private Q_SLOTS:
Expand Down
10 changes: 10 additions & 0 deletions Canvas/Canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,9 @@ void Canvas::slotBackgroundContent()

void Canvas::slotConfigureContent(const QPoint & scenePoint)
{
#if defined(MOBILE_UI)
Q_UNUSED(scenePoint)
#endif
// get the content and ensure it hasn't already a property window
AbstractContent * content = dynamic_cast<AbstractContent *>(sender());
foreach (AbstractConfig * config, m_configs) {
Expand All @@ -1309,11 +1312,18 @@ void Canvas::slotConfigureContent(const QPoint & scenePoint)

// common links
m_configs.append(p);
#if !defined(MOBILE_UI)
addItem(p);
#endif
connect(p, SIGNAL(requestClose()), this, SLOT(slotDeleteConfig()));
connect(p, SIGNAL(applyLook(quint32,bool,bool)), this, SLOT(slotApplyLook(quint32,bool,bool)));
#if !defined(MOBILE_UI)
p->show();
p->setPos(scenePoint - QPoint(10, 10));
#else
p->show();
//p->showFullScreen();
#endif
QGraphicsView * mainView = mainGraphicsView();
if (mainView) {
QRect bounds = mainView->mapToScene(mainView->viewport()->rect()).boundingRect().toRect();
Expand Down
3 changes: 3 additions & 0 deletions Canvas/ContentProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ ContentProperties::ContentProperties(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
#if defined(MOBILE_UI)
cHS1->setStyleSheet(QString());
#endif
#if QT_VERSION < 0x040600
cFxCombo->hide();
#endif
Expand Down
2 changes: 1 addition & 1 deletion Canvas/ContentProperties.ui
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<item>
<widget class="QToolButton" name="cConfigure">
<property name="toolTip">
<string>Delete</string>
<string>Configure</string>
</property>
<property name="icon">
<iconset resource="../fotowall.qrc">
Expand Down
4 changes: 4 additions & 0 deletions Canvas/PictureConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
#include <QInputDialog>
#include <QListWidgetItem>

#if !defined(MOBILE_UI)
PictureConfig::PictureConfig(PictureContent * pictureContent, QGraphicsItem * parent)
#else
PictureConfig::PictureConfig(PictureContent * pictureContent, QWidget * parent)
#endif
: AbstractConfig(pictureContent, parent)
, m_pictureUi(new Ui::PictureConfig())
, m_pictureContent(pictureContent)
Expand Down
4 changes: 4 additions & 0 deletions Canvas/PictureConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ namespace Ui { class PictureConfig; }
class PictureConfig : public AbstractConfig {
Q_OBJECT
public:
#if !defined(MOBILE_UI)
PictureConfig(PictureContent * pictureContent, QGraphicsItem * parent = 0);
#else
PictureConfig(PictureContent * pictureContent, QWidget * parent = 0);
#endif
~PictureConfig();

Q_SIGNALS:
Expand Down
3 changes: 3 additions & 0 deletions Canvas/PictureContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ void PictureContent::crop()
if (!m_photo)
return;
CroppingDialog dial(m_photo);
#if defined(MOBILE_UI)
dial.showFullScreen();
#endif
if (dial.exec() != QDialog::Accepted)
return;
QRect cropRect = dial.getCroppingRect();
Expand Down
4 changes: 4 additions & 0 deletions Canvas/TextConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#include "3rdparty/richtextedit/richtexteditor_p.h"
#include "TextContent.h"

#if !defined(MOBILE_UI)
TextConfig::TextConfig(TextContent * textContent, QGraphicsItem * parent)
#else
TextConfig::TextConfig(TextContent * textContent, QWidget * parent)
#endif
: AbstractConfig(textContent, parent)
, m_textContent(textContent)
{
Expand Down
4 changes: 4 additions & 0 deletions Canvas/TextConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ class TextConfig : public AbstractConfig
{
Q_OBJECT
public:
#if !defined(MOBILE_UI)
TextConfig(TextContent * textContent, QGraphicsItem * parent = 0);
#else
TextConfig(TextContent * textContent, QWidget * parent = 0);
#endif

private:
// ::AbstractConfig
Expand Down

0 comments on commit 7694148

Please sign in to comment.