Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
external
Qt
QtWebEngine
Commits
3c700fb3
Commit
3c700fb3
authored
11 years ago
by
Zeno Albisser
Committed by
Zeno Albisser
11 years ago
Browse files
Options
Download
Patches
Plain Diff
add an actual navigation bar
parent
6b0db2d9
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/lib.pro
+4
-2
lib/lib.pro
lib/shell_qt.cpp
+42
-22
lib/shell_qt.cpp
lib/signal_connector.cpp
+53
-0
lib/signal_connector.cpp
lib/signal_connector.h
+37
-0
lib/signal_connector.h
with
136 additions
and
24 deletions
lib/lib.pro
+
4
−
2
View file @
3c700fb3
...
@@ -21,11 +21,13 @@ SOURCES = \
...
@@ -21,11 +21,13 @@ SOURCES = \
blinqpage
.
cpp
\
blinqpage
.
cpp
\
raster_window
.
cpp
\
raster_window
.
cpp
\
render_widget_host_view_qt
.
cpp
\
render_widget_host_view_qt
.
cpp
\
shell_qt
.
cpp
shell_qt
.
cpp
\
signal_connector
.
cpp
HEADERS
=
\
HEADERS
=
\
backing_store_qt
.
h
\
backing_store_qt
.
h
\
blinqpage
.
h
\
blinqpage
.
h
\
raster_window
.
h
\
raster_window
.
h
\
render_widget_host_view_qt
.
h
render_widget_host_view_qt
.
h
\
signal_connector
.
h
This diff is collapsed.
Click to expand it.
lib/shell_qt.cpp
+
42
−
22
View file @
3c700fb3
...
@@ -17,11 +17,14 @@
...
@@ -17,11 +17,14 @@
#include
"content/public/common/renderer_preferences.h"
#include
"content/public/common/renderer_preferences.h"
#include
"content/shell/shell_browser_context.h"
#include
"content/shell/shell_browser_context.h"
#include
"content/shell/shell_content_browser_client.h"
#include
"content/shell/shell_content_browser_client.h"
#include
"signal_connector.h"
#include
<QWindow>
#include
<QWindow>
#include
<QLineEdit>
#include
<QLineEdit>
#include
<QWidget>
#include
<QWidget>
#include
<QVBoxLayout>
#include
<QVBoxLayout>
#include
<QHBoxLayout>
#include
<QToolButton>
namespace
content
{
namespace
content
{
...
@@ -62,7 +65,10 @@ void Shell::PlatformSetAddressBarURL(const GURL& url)
...
@@ -62,7 +65,10 @@ void Shell::PlatformSetAddressBarURL(const GURL& url)
if
(
headless_
)
if
(
headless_
)
return
;
return
;
gtk_entry_set_text
(
GTK_ENTRY
(
url_edit_view_
),
url
.
spec
().
c_str
());
fprintf
(
stderr
,
"Set Address to: %s
\n
"
,
url
.
spec
().
c_str
());
QLineEdit
*
addressLine
=
m_window
->
findChild
<
QLineEdit
*>
(
"AddressLineEdit"
);
addressLine
->
setText
(
QString
::
fromStdString
(
url
.
spec
()));
}
}
...
@@ -90,11 +96,41 @@ void Shell::PlatformCreateWindow(int width, int height) {
...
@@ -90,11 +96,41 @@ void Shell::PlatformCreateWindow(int width, int height) {
QVBoxLayout
*
layout
=
new
QVBoxLayout
;
QVBoxLayout
*
layout
=
new
QVBoxLayout
;
// Create a widget based address bar.
// Create a widget based address bar.
QHBoxLayout
*
addressBar
=
new
QHBoxLayout
;
int
buttonWidth
=
26
;
QToolButton
*
backButton
=
new
QToolButton
;
backButton
->
setIcon
(
QIcon
::
fromTheme
(
"go-previous"
));
backButton
->
setObjectName
(
"BackButton"
);
addressBar
->
addWidget
(
backButton
);
QToolButton
*
forwardButton
=
new
QToolButton
;
forwardButton
->
setIcon
(
QIcon
::
fromTheme
(
"go-next"
));
forwardButton
->
setObjectName
(
"ForwardButton"
);
addressBar
->
addWidget
(
forwardButton
);
QToolButton
*
reloadButton
=
new
QToolButton
;
reloadButton
->
setIcon
(
QIcon
::
fromTheme
(
"view-refresh"
));
reloadButton
->
setObjectName
(
"ReloadButton"
);
addressBar
->
addWidget
(
reloadButton
);
QLineEdit
*
lineEdit
=
new
QLineEdit
;
QLineEdit
*
lineEdit
=
new
QLineEdit
;
layout
->
addWidget
(
lineEdit
);
lineEdit
->
setObjectName
(
"AddressLineEdit"
);
addressBar
->
addWidget
(
lineEdit
);
layout
->
addLayout
(
addressBar
);
m_window
->
setLayout
(
layout
);
m_window
->
setLayout
(
layout
);
m_window
->
show
();
m_window
->
show
();
// SignalConnector will act as a proxy for the QObject signals received from
// m_window. m_window will take ownership of the SignalConnector.
// The SignalConnector will search the children list of m_window
// for back/forward/reload buttons and for the address line edit.
// Therefore the layout must be set and completed before the SignalConnector
// is created.
SignalConnector
*
signalConnector
=
new
SignalConnector
(
this
,
m_window
);
}
}
}
}
...
@@ -134,34 +170,18 @@ void Shell::Close()
...
@@ -134,34 +170,18 @@ void Shell::Close()
gtk_widget_destroy
(
GTK_WIDGET
(
window_
));
gtk_widget_destroy
(
GTK_WIDGET
(
window_
));
}
}
void
Shell
::
OnBackButtonClicked
(
GtkWidget
*
widget
)
void
Shell
::
OnBackButtonClicked
(
GtkWidget
*
widget
)
{
}
{
GoBackOrForward
(
-
1
);
}
void
Shell
::
OnForwardButtonClicked
(
GtkWidget
*
widget
)
void
Shell
::
OnForwardButtonClicked
(
GtkWidget
*
widget
)
{
}
{
GoBackOrForward
(
1
);
}
void
Shell
::
OnReloadButtonClicked
(
GtkWidget
*
widget
)
void
Shell
::
OnReloadButtonClicked
(
GtkWidget
*
widget
)
{
}
{
Reload
();
}
void
Shell
::
OnStopButtonClicked
(
GtkWidget
*
widget
)
void
Shell
::
OnStopButtonClicked
(
GtkWidget
*
widget
)
{
{
Stop
();
Stop
();
}
}
void
Shell
::
OnURLEntryActivate
(
GtkWidget
*
entry
)
void
Shell
::
OnURLEntryActivate
(
GtkWidget
*
entry
)
{
}
{
const
gchar
*
str
=
gtk_entry_get_text
(
GTK_ENTRY
(
entry
));
GURL
url
(
str
);
if
(
!
url
.
has_scheme
())
url
=
GURL
(
std
::
string
(
"http://"
)
+
std
::
string
(
str
));
LoadURL
(
GURL
(
url
));
}
// Callback for when the main window is destroyed.
// Callback for when the main window is destroyed.
gboolean
Shell
::
OnWindowDestroyed
(
GtkWidget
*
window
)
gboolean
Shell
::
OnWindowDestroyed
(
GtkWidget
*
window
)
...
...
This diff is collapsed.
Click to expand it.
lib/signal_connector.cpp
0 → 100644
+
53
−
0
View file @
3c700fb3
#include
"signal_connector.h"
#include
"content/shell/shell.h"
#include
<QObject>
#include
<QWidget>
#include
<QLineEdit>
#include
<QToolButton>
#include
<QDebug>
SignalConnector
::
SignalConnector
(
content
::
Shell
*
shell
,
QWidget
*
window
)
:
m_shell
(
shell
)
,
m_window
(
window
)
{
setParent
(
window
);
m_addressLineEdit
=
m_window
->
findChild
<
QLineEdit
*>
(
"AddressLineEdit"
);
m_backButton
=
m_window
->
findChild
<
QToolButton
*>
(
"BackButton"
);
m_forwardButton
=
m_window
->
findChild
<
QToolButton
*>
(
"ForwardButton"
);
m_reloadButton
=
m_window
->
findChild
<
QToolButton
*>
(
"ReloadButton"
);
connect
(
m_addressLineEdit
,
SIGNAL
(
returnPressed
()),
this
,
SLOT
(
loadAddressFromAddressBar
()));
connect
(
m_backButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
goBack
()));
connect
(
m_forwardButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
goForward
()));
connect
(
m_reloadButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reload
()));
}
void
SignalConnector
::
loadAddressFromAddressBar
()
{
load
(
m_addressLineEdit
->
text
());
}
void
SignalConnector
::
load
(
const
QString
&
url
)
const
{
GURL
gurl
(
url
.
toStdString
());
if
(
!
gurl
.
has_scheme
())
gurl
=
GURL
(
std
::
string
(
"http://"
)
+
url
.
toStdString
());
m_shell
->
LoadURL
(
gurl
);
}
void
SignalConnector
::
goBack
()
const
{
m_shell
->
GoBackOrForward
(
-
1
);
}
void
SignalConnector
::
goForward
()
const
{
m_shell
->
GoBackOrForward
(
1
);
}
void
SignalConnector
::
reload
()
const
{
m_shell
->
Reload
();
}
This diff is collapsed.
Click to expand it.
lib/signal_connector.h
0 → 100644
+
37
−
0
View file @
3c700fb3
#ifndef QT_SIGNAL_CONNECTOR_H
#define QT_SIGNAL_CONNECTOR_H
#include
<QObject>
class
QWidget
;
class
QToolButton
;
class
QLineEdit
;
namespace
content
{
class
Shell
;
}
class
SignalConnector
:
public
QObject
{
Q_OBJECT
public:
SignalConnector
(
content
::
Shell
*
shell
,
QWidget
*
window
);
public
Q_SLOTS
:
void
loadAddressFromAddressBar
();
void
load
(
const
QString
&
url
)
const
;
void
goBack
()
const
;
void
goForward
()
const
;
void
reload
()
const
;
private:
content
::
Shell
*
m_shell
;
QWidget
*
m_window
;
QLineEdit
*
m_addressLineEdit
;
QToolButton
*
m_forwardButton
;
QToolButton
*
m_backButton
;
QToolButton
*
m_reloadButton
;
};
#endif
This diff is collapsed.
Click to expand it.
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets