20
20
*
21
21
* Contributor(s):
22
22
* Anton Rogaynis <[email protected] >
23
+ * Tatiana Meshkova <[email protected] >
23
24
*
24
25
* Alternatively, the contents of this file may be used under the terms of
25
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
36
37
* ***** END LICENSE BLOCK ***** */
37
38
38
39
#include < QApplication>
39
- #include < QWidget>
40
- #include < QVBoxLayout>
41
- #include < QLineEdit>
42
- #include < QLabel>
43
- #include < QUrl>
44
40
#include < QDebug>
41
+ #include < QPushButton>
42
+ #include < QGraphicsProxyWidget>
45
43
46
44
#include " test.h"
47
- #include " QMozApp.h"
48
45
49
- MyQMozView::MyQMozView (QWidget *parent, unsigned int flags)
50
- : QMozView(parent, flags)
51
- {}
52
-
53
- QMozView* MyQMozView::openWindow (unsigned int flags)
46
+ MyQGraphicsView::MyQGraphicsView (QGraphicsScene* scene, QWidget* parent)
47
+ : QGraphicsView(scene, parent)
54
48
{
55
- MyBrowser* newBrowser = new MyBrowser (0 , flags);
56
- newBrowser->resize (400 , 400 );
57
- newBrowser->show ();
58
- newBrowser->setAttribute (Qt::WA_DeleteOnClose);
59
- return newBrowser->getQMozView ();
60
- }
49
+ setAlignment (Qt::AlignLeft | Qt::AlignTop);
50
+ setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
51
+ setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
61
52
62
- MyBrowser::MyBrowser (QWidget *parent, unsigned int flags)
63
- : QDialog(parent)
64
- {
65
- QVBoxLayout* layout = new QVBoxLayout (this );
53
+ mLayout = new QGraphicsGridLayout;
66
54
67
- location = new QLineEdit (this );
68
- layout->addWidget (location);
55
+ mTitle = new MyTextWidget (" title" );
56
+ mLayout ->addItem (mTitle , 0 , 0 , 1 , 2 );
57
+ mLayout ->setRowMaximumHeight (0 , 20 );
69
58
70
- mozView = new MyQMozView (this , flags);
71
- layout->addWidget (mozView, 1 );
59
+ mLocation = new MyTextWidget (" location" );
60
+ mLayout ->addItem (mLocation , 1 , 0 , 1 , 2 );
61
+ mLayout ->setRowMaximumHeight (1 , 20 );
72
62
73
- status = new QLabel (this );
74
- layout->addWidget (status);
63
+ mForm = new QGraphicsWidget;
64
+ mForm ->setLayout (mLayout );
65
+ scene->addItem (mForm );
75
66
76
- connect ( mozView, SIGNAL ( locationChanged ( const QString&)),
77
- location, SLOT ( setText ( const QString&)) );
67
+ mozView = new QMozView ( mForm );
68
+ mLayout -> addItem (mozView, 2 , 0 , 1 , 2 );
78
69
79
- connect (mozView, SIGNAL (titleChanged (const QString&)),
80
- this , SLOT (setWindowTitle (const QString&)));
70
+ mStatus = new MyTextWidget (" status" );
71
+ mLayout ->addItem (mStatus , 3 , 0 );
72
+ mLayout ->setRowMaximumHeight (3 , 20 );
81
73
82
- connect (mozView, SIGNAL (statusChanged (const QString&)),
83
- status, SLOT (setText (const QString&)));
74
+ QWidget* exitButton = new QPushButton (" Exit" );
75
+ mLayout ->addItem (scene->addWidget (exitButton), 3 , 1 );
76
+ mLayout ->setColumnMaximumWidth (1 , 50 );
84
77
85
- connect (mozView, SIGNAL (startModal ( )),
86
- this , SLOT (startModal ( )));
78
+ connect (mozView, SIGNAL (locationChanged ( const QString& )),
79
+ mLocation , SLOT (setText ( const QString& )));
87
80
88
- connect (mozView, SIGNAL (exitModal ( )),
89
- this , SLOT (exitModal ( )));
81
+ connect (mozView, SIGNAL (titleChanged ( const QString& )),
82
+ mTitle , SLOT (setText ( const QString& )));
90
83
91
- connect (location , SIGNAL (returnPressed ( )),
92
- this , SLOT (go ( )));
84
+ connect (mozView , SIGNAL (statusChanged ( const QString& )),
85
+ mStatus , SLOT (setText ( const QString& )));
93
86
94
- connect (mozView, SIGNAL (consoleMessage (const QString &)),
95
- this , SLOT (consoleMessage (const QString &)));
96
- }
87
+ connect (mozView, SIGNAL (consoleMessage (const QString&)),
88
+ this , SLOT (consoleMessage (const QString&)));
97
89
98
- void MyBrowser::loadUri (const QString& uri)
99
- {
100
- location->setText (uri);
101
- mozView->loadUri (uri);
90
+ connect (exitButton, SIGNAL (clicked ()), this , SLOT (close ()));
102
91
}
103
92
104
- void MyBrowser::go ()
93
+ MyQGraphicsView::~MyQGraphicsView ()
105
94
{
106
- mozView->loadUri (location->text ());
107
95
}
108
96
109
- void MyBrowser::startModal ( )
97
+ void MyQGraphicsView::resizeEvent (QResizeEvent* event )
110
98
{
111
- hide ( );
112
- exec ( );
99
+ mForm -> resize (event-> size () );
100
+ QGraphicsView::resizeEvent (event );
113
101
}
114
102
115
- void MyBrowser::exitModal ( )
103
+ void MyQGraphicsView::loadUri ( const QString& uri )
116
104
{
117
- done (0 );
118
- // have to delete mozView now to avoid JS context assertions
119
- delete mozView;
105
+ mozView->loadUri (uri);
120
106
}
121
107
122
- void MyBrowser ::consoleMessage (const QString& message)
108
+ void MyQGraphicsView ::consoleMessage (const QString& message)
123
109
{
124
110
qDebug () << " CONSOLE:" << message;
125
111
}
@@ -128,15 +114,14 @@ int main(int argc, char *argv[])
128
114
{
129
115
QApplication app (argc, argv);
130
116
131
- MyBrowser window;
132
-
133
- window.resize (400 , 400 );
134
- window.show ();
135
-
117
+ QGraphicsScene scene;
118
+ MyQGraphicsView view (&scene);
136
119
if (argc > 1 )
137
- window .loadUri (argv[argc - 1 ]);
120
+ view .loadUri (argv[argc - 1 ]);
138
121
else
139
- window.loadUri (" http://mozilla.org" );
122
+ view.loadUri (" http://mozilla.org" );
123
+
124
+ view.showFullScreen ();
140
125
141
126
return app.exec ();
142
127
}
0 commit comments