|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the demonstration applications of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "browsermainwindow.h" |
|
43 |
|
44 #include "autosaver.h" |
|
45 #include "bookmarks.h" |
|
46 #include "browserapplication.h" |
|
47 #include "chasewidget.h" |
|
48 #include "downloadmanager.h" |
|
49 #include "history.h" |
|
50 #include "settings.h" |
|
51 #include "tabwidget.h" |
|
52 #include "toolbarsearch.h" |
|
53 #include "ui_passworddialog.h" |
|
54 #include "webview.h" |
|
55 |
|
56 #include <QtCore/QSettings> |
|
57 |
|
58 #include <QtGui/QDesktopWidget> |
|
59 #include <QtGui/QFileDialog> |
|
60 #include <QtGui/QPlainTextEdit> |
|
61 #include <QtGui/QPrintDialog> |
|
62 #include <QtGui/QPrintPreviewDialog> |
|
63 #include <QtGui/QPrinter> |
|
64 #include <QtGui/QMenuBar> |
|
65 #include <QtGui/QMessageBox> |
|
66 #include <QtGui/QStatusBar> |
|
67 #include <QtGui/QToolBar> |
|
68 #include <QtGui/QInputDialog> |
|
69 |
|
70 #include <QtWebKit/QWebFrame> |
|
71 #include <QtWebKit/QWebHistory> |
|
72 |
|
73 #include <QtCore/QDebug> |
|
74 |
|
75 BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) |
|
76 : QMainWindow(parent, flags) |
|
77 , m_tabWidget(new TabWidget(this)) |
|
78 , m_autoSaver(new AutoSaver(this)) |
|
79 , m_historyBack(0) |
|
80 , m_historyForward(0) |
|
81 , m_stop(0) |
|
82 , m_reload(0) |
|
83 { |
|
84 setToolButtonStyle(Qt::ToolButtonFollowStyle); |
|
85 setAttribute(Qt::WA_DeleteOnClose, true); |
|
86 statusBar()->setSizeGripEnabled(true); |
|
87 setupMenu(); |
|
88 setupToolBar(); |
|
89 |
|
90 QWidget *centralWidget = new QWidget(this); |
|
91 BookmarksModel *boomarksModel = BrowserApplication::bookmarksManager()->bookmarksModel(); |
|
92 m_bookmarksToolbar = new BookmarksToolBar(boomarksModel, this); |
|
93 connect(m_bookmarksToolbar, SIGNAL(openUrl(const QUrl&)), |
|
94 m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); |
|
95 connect(m_bookmarksToolbar->toggleViewAction(), SIGNAL(toggled(bool)), |
|
96 this, SLOT(updateBookmarksToolbarActionText(bool))); |
|
97 |
|
98 QVBoxLayout *layout = new QVBoxLayout; |
|
99 layout->setSpacing(0); |
|
100 layout->setMargin(0); |
|
101 #if defined(Q_WS_MAC) |
|
102 layout->addWidget(m_bookmarksToolbar); |
|
103 layout->addWidget(new QWidget); // <- OS X tab widget style bug |
|
104 #else |
|
105 addToolBarBreak(); |
|
106 addToolBar(m_bookmarksToolbar); |
|
107 #endif |
|
108 layout->addWidget(m_tabWidget); |
|
109 centralWidget->setLayout(layout); |
|
110 setCentralWidget(centralWidget); |
|
111 |
|
112 connect(m_tabWidget, SIGNAL(loadPage(const QString &)), |
|
113 this, SLOT(loadPage(const QString &))); |
|
114 connect(m_tabWidget, SIGNAL(setCurrentTitle(const QString &)), |
|
115 this, SLOT(slotUpdateWindowTitle(const QString &))); |
|
116 connect(m_tabWidget, SIGNAL(showStatusBarMessage(const QString&)), |
|
117 statusBar(), SLOT(showMessage(const QString&))); |
|
118 connect(m_tabWidget, SIGNAL(linkHovered(const QString&)), |
|
119 statusBar(), SLOT(showMessage(const QString&))); |
|
120 connect(m_tabWidget, SIGNAL(loadProgress(int)), |
|
121 this, SLOT(slotLoadProgress(int))); |
|
122 connect(m_tabWidget, SIGNAL(tabsChanged()), |
|
123 m_autoSaver, SLOT(changeOccurred())); |
|
124 connect(m_tabWidget, SIGNAL(geometryChangeRequested(const QRect &)), |
|
125 this, SLOT(geometryChangeRequested(const QRect &))); |
|
126 connect(m_tabWidget, SIGNAL(printRequested(QWebFrame *)), |
|
127 this, SLOT(printRequested(QWebFrame *))); |
|
128 connect(m_tabWidget, SIGNAL(menuBarVisibilityChangeRequested(bool)), |
|
129 menuBar(), SLOT(setVisible(bool))); |
|
130 connect(m_tabWidget, SIGNAL(statusBarVisibilityChangeRequested(bool)), |
|
131 statusBar(), SLOT(setVisible(bool))); |
|
132 connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), |
|
133 m_navigationBar, SLOT(setVisible(bool))); |
|
134 connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), |
|
135 m_bookmarksToolbar, SLOT(setVisible(bool))); |
|
136 #if defined(Q_WS_MAC) |
|
137 connect(m_tabWidget, SIGNAL(lastTabClosed()), |
|
138 this, SLOT(close())); |
|
139 #else |
|
140 connect(m_tabWidget, SIGNAL(lastTabClosed()), |
|
141 m_tabWidget, SLOT(newTab())); |
|
142 #endif |
|
143 |
|
144 slotUpdateWindowTitle(); |
|
145 loadDefaultState(); |
|
146 m_tabWidget->newTab(); |
|
147 |
|
148 int size = m_tabWidget->lineEditStack()->sizeHint().height(); |
|
149 m_navigationBar->setIconSize(QSize(size, size)); |
|
150 |
|
151 } |
|
152 |
|
153 BrowserMainWindow::~BrowserMainWindow() |
|
154 { |
|
155 m_autoSaver->changeOccurred(); |
|
156 m_autoSaver->saveIfNeccessary(); |
|
157 } |
|
158 |
|
159 void BrowserMainWindow::loadDefaultState() |
|
160 { |
|
161 QSettings settings; |
|
162 settings.beginGroup(QLatin1String("BrowserMainWindow")); |
|
163 QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray(); |
|
164 restoreState(data); |
|
165 settings.endGroup(); |
|
166 } |
|
167 |
|
168 QSize BrowserMainWindow::sizeHint() const |
|
169 { |
|
170 QRect desktopRect = QApplication::desktop()->screenGeometry(); |
|
171 QSize size = desktopRect.size() * qreal(0.9); |
|
172 return size; |
|
173 } |
|
174 |
|
175 void BrowserMainWindow::save() |
|
176 { |
|
177 BrowserApplication::instance()->saveSession(); |
|
178 |
|
179 QSettings settings; |
|
180 settings.beginGroup(QLatin1String("BrowserMainWindow")); |
|
181 QByteArray data = saveState(false); |
|
182 settings.setValue(QLatin1String("defaultState"), data); |
|
183 settings.endGroup(); |
|
184 } |
|
185 |
|
186 static const qint32 BrowserMainWindowMagic = 0xba; |
|
187 |
|
188 QByteArray BrowserMainWindow::saveState(bool withTabs) const |
|
189 { |
|
190 int version = 2; |
|
191 QByteArray data; |
|
192 QDataStream stream(&data, QIODevice::WriteOnly); |
|
193 |
|
194 stream << qint32(BrowserMainWindowMagic); |
|
195 stream << qint32(version); |
|
196 |
|
197 stream << size(); |
|
198 stream << !m_navigationBar->isHidden(); |
|
199 stream << !m_bookmarksToolbar->isHidden(); |
|
200 stream << !statusBar()->isHidden(); |
|
201 if (withTabs) |
|
202 stream << tabWidget()->saveState(); |
|
203 else |
|
204 stream << QByteArray(); |
|
205 return data; |
|
206 } |
|
207 |
|
208 bool BrowserMainWindow::restoreState(const QByteArray &state) |
|
209 { |
|
210 int version = 2; |
|
211 QByteArray sd = state; |
|
212 QDataStream stream(&sd, QIODevice::ReadOnly); |
|
213 if (stream.atEnd()) |
|
214 return false; |
|
215 |
|
216 qint32 marker; |
|
217 qint32 v; |
|
218 stream >> marker; |
|
219 stream >> v; |
|
220 if (marker != BrowserMainWindowMagic || v != version) |
|
221 return false; |
|
222 |
|
223 QSize size; |
|
224 bool showToolbar; |
|
225 bool showBookmarksBar; |
|
226 bool showStatusbar; |
|
227 QByteArray tabState; |
|
228 |
|
229 stream >> size; |
|
230 stream >> showToolbar; |
|
231 stream >> showBookmarksBar; |
|
232 stream >> showStatusbar; |
|
233 stream >> tabState; |
|
234 |
|
235 resize(size); |
|
236 |
|
237 m_navigationBar->setVisible(showToolbar); |
|
238 updateToolbarActionText(showToolbar); |
|
239 |
|
240 m_bookmarksToolbar->setVisible(showBookmarksBar); |
|
241 updateBookmarksToolbarActionText(showBookmarksBar); |
|
242 |
|
243 statusBar()->setVisible(showStatusbar); |
|
244 updateStatusbarActionText(showStatusbar); |
|
245 |
|
246 if (!tabWidget()->restoreState(tabState)) |
|
247 return false; |
|
248 |
|
249 return true; |
|
250 } |
|
251 |
|
252 void BrowserMainWindow::setupMenu() |
|
253 { |
|
254 new QShortcut(QKeySequence(Qt::Key_F6), this, SLOT(slotSwapFocus())); |
|
255 |
|
256 // File |
|
257 QMenu *fileMenu = menuBar()->addMenu(tr("&File")); |
|
258 |
|
259 fileMenu->addAction(tr("&New Window"), this, SLOT(slotFileNew()), QKeySequence::New); |
|
260 fileMenu->addAction(m_tabWidget->newTabAction()); |
|
261 fileMenu->addAction(tr("&Open File..."), this, SLOT(slotFileOpen()), QKeySequence::Open); |
|
262 fileMenu->addAction(tr("Open &Location..."), this, |
|
263 SLOT(slotSelectLineEdit()), QKeySequence(Qt::ControlModifier + Qt::Key_L)); |
|
264 fileMenu->addSeparator(); |
|
265 fileMenu->addAction(m_tabWidget->closeTabAction()); |
|
266 fileMenu->addSeparator(); |
|
267 fileMenu->addAction(tr("&Save As..."), this, |
|
268 SLOT(slotFileSaveAs()), QKeySequence(QKeySequence::Save)); |
|
269 fileMenu->addSeparator(); |
|
270 BookmarksManager *bookmarksManager = BrowserApplication::bookmarksManager(); |
|
271 fileMenu->addAction(tr("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks())); |
|
272 fileMenu->addAction(tr("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks())); |
|
273 fileMenu->addSeparator(); |
|
274 fileMenu->addAction(tr("P&rint Preview..."), this, SLOT(slotFilePrintPreview())); |
|
275 fileMenu->addAction(tr("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print); |
|
276 fileMenu->addSeparator(); |
|
277 QAction *action = fileMenu->addAction(tr("Private &Browsing..."), this, SLOT(slotPrivateBrowsing())); |
|
278 action->setCheckable(true); |
|
279 fileMenu->addSeparator(); |
|
280 |
|
281 #if defined(Q_WS_MAC) |
|
282 fileMenu->addAction(tr("&Quit"), BrowserApplication::instance(), SLOT(quitBrowser()), QKeySequence(Qt::CTRL | Qt::Key_Q)); |
|
283 #else |
|
284 fileMenu->addAction(tr("&Quit"), this, SLOT(close()), QKeySequence(Qt::CTRL | Qt::Key_Q)); |
|
285 #endif |
|
286 |
|
287 // Edit |
|
288 QMenu *editMenu = menuBar()->addMenu(tr("&Edit")); |
|
289 QAction *m_undo = editMenu->addAction(tr("&Undo")); |
|
290 m_undo->setShortcuts(QKeySequence::Undo); |
|
291 m_tabWidget->addWebAction(m_undo, QWebPage::Undo); |
|
292 QAction *m_redo = editMenu->addAction(tr("&Redo")); |
|
293 m_redo->setShortcuts(QKeySequence::Redo); |
|
294 m_tabWidget->addWebAction(m_redo, QWebPage::Redo); |
|
295 editMenu->addSeparator(); |
|
296 QAction *m_cut = editMenu->addAction(tr("Cu&t")); |
|
297 m_cut->setShortcuts(QKeySequence::Cut); |
|
298 m_tabWidget->addWebAction(m_cut, QWebPage::Cut); |
|
299 QAction *m_copy = editMenu->addAction(tr("&Copy")); |
|
300 m_copy->setShortcuts(QKeySequence::Copy); |
|
301 m_tabWidget->addWebAction(m_copy, QWebPage::Copy); |
|
302 QAction *m_paste = editMenu->addAction(tr("&Paste")); |
|
303 m_paste->setShortcuts(QKeySequence::Paste); |
|
304 m_tabWidget->addWebAction(m_paste, QWebPage::Paste); |
|
305 editMenu->addSeparator(); |
|
306 |
|
307 QAction *m_find = editMenu->addAction(tr("&Find")); |
|
308 m_find->setShortcuts(QKeySequence::Find); |
|
309 connect(m_find, SIGNAL(triggered()), this, SLOT(slotEditFind())); |
|
310 new QShortcut(QKeySequence(Qt::Key_Slash), this, SLOT(slotEditFind())); |
|
311 |
|
312 QAction *m_findNext = editMenu->addAction(tr("&Find Next")); |
|
313 m_findNext->setShortcuts(QKeySequence::FindNext); |
|
314 connect(m_findNext, SIGNAL(triggered()), this, SLOT(slotEditFindNext())); |
|
315 |
|
316 QAction *m_findPrevious = editMenu->addAction(tr("&Find Previous")); |
|
317 m_findPrevious->setShortcuts(QKeySequence::FindPrevious); |
|
318 connect(m_findPrevious, SIGNAL(triggered()), this, SLOT(slotEditFindPrevious())); |
|
319 |
|
320 editMenu->addSeparator(); |
|
321 editMenu->addAction(tr("&Preferences"), this, SLOT(slotPreferences()), tr("Ctrl+,")); |
|
322 |
|
323 // View |
|
324 QMenu *viewMenu = menuBar()->addMenu(tr("&View")); |
|
325 |
|
326 m_viewBookmarkBar = new QAction(this); |
|
327 updateBookmarksToolbarActionText(true); |
|
328 m_viewBookmarkBar->setShortcut(tr("Shift+Ctrl+B")); |
|
329 connect(m_viewBookmarkBar, SIGNAL(triggered()), this, SLOT(slotViewBookmarksBar())); |
|
330 viewMenu->addAction(m_viewBookmarkBar); |
|
331 |
|
332 m_viewToolbar = new QAction(this); |
|
333 updateToolbarActionText(true); |
|
334 m_viewToolbar->setShortcut(tr("Ctrl+|")); |
|
335 connect(m_viewToolbar, SIGNAL(triggered()), this, SLOT(slotViewToolbar())); |
|
336 viewMenu->addAction(m_viewToolbar); |
|
337 |
|
338 m_viewStatusbar = new QAction(this); |
|
339 updateStatusbarActionText(true); |
|
340 m_viewStatusbar->setShortcut(tr("Ctrl+/")); |
|
341 connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar())); |
|
342 viewMenu->addAction(m_viewStatusbar); |
|
343 |
|
344 viewMenu->addSeparator(); |
|
345 |
|
346 m_stop = viewMenu->addAction(tr("&Stop")); |
|
347 QList<QKeySequence> shortcuts; |
|
348 shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); |
|
349 shortcuts.append(Qt::Key_Escape); |
|
350 m_stop->setShortcuts(shortcuts); |
|
351 m_tabWidget->addWebAction(m_stop, QWebPage::Stop); |
|
352 |
|
353 m_reload = viewMenu->addAction(tr("Reload Page")); |
|
354 m_reload->setShortcuts(QKeySequence::Refresh); |
|
355 m_tabWidget->addWebAction(m_reload, QWebPage::Reload); |
|
356 |
|
357 viewMenu->addAction(tr("Zoom &In"), this, SLOT(slotViewZoomIn()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); |
|
358 viewMenu->addAction(tr("Zoom &Out"), this, SLOT(slotViewZoomOut()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); |
|
359 viewMenu->addAction(tr("Reset &Zoom"), this, SLOT(slotViewResetZoom()), QKeySequence(Qt::CTRL | Qt::Key_0)); |
|
360 QAction *zoomTextOnlyAction = viewMenu->addAction(tr("Zoom &Text Only")); |
|
361 connect(zoomTextOnlyAction, SIGNAL(toggled(bool)), this, SLOT(slotViewZoomTextOnly(bool))); |
|
362 zoomTextOnlyAction->setCheckable(true); |
|
363 zoomTextOnlyAction->setChecked(false); |
|
364 |
|
365 viewMenu->addSeparator(); |
|
366 viewMenu->addAction(tr("Page S&ource"), this, SLOT(slotViewPageSource()), tr("Ctrl+Alt+U")); |
|
367 QAction *a = viewMenu->addAction(tr("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); |
|
368 a->setCheckable(true); |
|
369 |
|
370 // History |
|
371 HistoryMenu *historyMenu = new HistoryMenu(this); |
|
372 connect(historyMenu, SIGNAL(openUrl(const QUrl&)), |
|
373 m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); |
|
374 connect(historyMenu, SIGNAL(hovered(const QString&)), this, |
|
375 SLOT(slotUpdateStatusbar(const QString&))); |
|
376 historyMenu->setTitle(tr("Hi&story")); |
|
377 menuBar()->addMenu(historyMenu); |
|
378 QList<QAction*> historyActions; |
|
379 |
|
380 m_historyBack = new QAction(tr("Back"), this); |
|
381 m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); |
|
382 m_historyBack->setShortcuts(QKeySequence::Back); |
|
383 m_historyBack->setIconVisibleInMenu(false); |
|
384 |
|
385 m_historyForward = new QAction(tr("Forward"), this); |
|
386 m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward); |
|
387 m_historyForward->setShortcuts(QKeySequence::Forward); |
|
388 m_historyForward->setIconVisibleInMenu(false); |
|
389 |
|
390 QAction *m_historyHome = new QAction(tr("Home"), this); |
|
391 connect(m_historyHome, SIGNAL(triggered()), this, SLOT(slotHome())); |
|
392 m_historyHome->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_H)); |
|
393 |
|
394 m_restoreLastSession = new QAction(tr("Restore Last Session"), this); |
|
395 connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession())); |
|
396 m_restoreLastSession->setEnabled(BrowserApplication::instance()->canRestoreSession()); |
|
397 |
|
398 historyActions.append(m_historyBack); |
|
399 historyActions.append(m_historyForward); |
|
400 historyActions.append(m_historyHome); |
|
401 historyActions.append(m_tabWidget->recentlyClosedTabsAction()); |
|
402 historyActions.append(m_restoreLastSession); |
|
403 historyMenu->setInitialActions(historyActions); |
|
404 |
|
405 // Bookmarks |
|
406 BookmarksMenu *bookmarksMenu = new BookmarksMenu(this); |
|
407 connect(bookmarksMenu, SIGNAL(openUrl(const QUrl&)), |
|
408 m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); |
|
409 connect(bookmarksMenu, SIGNAL(hovered(const QString&)), |
|
410 this, SLOT(slotUpdateStatusbar(const QString&))); |
|
411 bookmarksMenu->setTitle(tr("&Bookmarks")); |
|
412 menuBar()->addMenu(bookmarksMenu); |
|
413 |
|
414 QList<QAction*> bookmarksActions; |
|
415 |
|
416 QAction *showAllBookmarksAction = new QAction(tr("Show All Bookmarks"), this); |
|
417 connect(showAllBookmarksAction, SIGNAL(triggered()), this, SLOT(slotShowBookmarksDialog())); |
|
418 m_addBookmark = new QAction(QIcon(QLatin1String(":addbookmark.png")), tr("Add Bookmark..."), this); |
|
419 m_addBookmark->setIconVisibleInMenu(false); |
|
420 |
|
421 connect(m_addBookmark, SIGNAL(triggered()), this, SLOT(slotAddBookmark())); |
|
422 m_addBookmark->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_D)); |
|
423 |
|
424 bookmarksActions.append(showAllBookmarksAction); |
|
425 bookmarksActions.append(m_addBookmark); |
|
426 bookmarksMenu->setInitialActions(bookmarksActions); |
|
427 |
|
428 // Window |
|
429 m_windowMenu = menuBar()->addMenu(tr("&Window")); |
|
430 connect(m_windowMenu, SIGNAL(aboutToShow()), |
|
431 this, SLOT(slotAboutToShowWindowMenu())); |
|
432 slotAboutToShowWindowMenu(); |
|
433 |
|
434 QMenu *toolsMenu = menuBar()->addMenu(tr("&Tools")); |
|
435 toolsMenu->addAction(tr("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence(tr("Ctrl+K", "Web Search"))); |
|
436 #ifndef Q_CC_MINGW |
|
437 a = toolsMenu->addAction(tr("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); |
|
438 a->setCheckable(true); |
|
439 #endif |
|
440 |
|
441 QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); |
|
442 helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); |
|
443 helpMenu->addAction(tr("About &Demo Browser"), this, SLOT(slotAboutApplication())); |
|
444 } |
|
445 |
|
446 void BrowserMainWindow::setupToolBar() |
|
447 { |
|
448 setUnifiedTitleAndToolBarOnMac(true); |
|
449 m_navigationBar = addToolBar(tr("Navigation")); |
|
450 connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), |
|
451 this, SLOT(updateToolbarActionText(bool))); |
|
452 |
|
453 m_historyBack->setIcon(style()->standardIcon(QStyle::SP_ArrowBack, 0, this)); |
|
454 m_historyBackMenu = new QMenu(this); |
|
455 m_historyBack->setMenu(m_historyBackMenu); |
|
456 connect(m_historyBackMenu, SIGNAL(aboutToShow()), |
|
457 this, SLOT(slotAboutToShowBackMenu())); |
|
458 connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), |
|
459 this, SLOT(slotOpenActionUrl(QAction *))); |
|
460 m_navigationBar->addAction(m_historyBack); |
|
461 |
|
462 m_historyForward->setIcon(style()->standardIcon(QStyle::SP_ArrowForward, 0, this)); |
|
463 m_historyForwardMenu = new QMenu(this); |
|
464 connect(m_historyForwardMenu, SIGNAL(aboutToShow()), |
|
465 this, SLOT(slotAboutToShowForwardMenu())); |
|
466 connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), |
|
467 this, SLOT(slotOpenActionUrl(QAction *))); |
|
468 m_historyForward->setMenu(m_historyForwardMenu); |
|
469 m_navigationBar->addAction(m_historyForward); |
|
470 |
|
471 m_stopReload = new QAction(this); |
|
472 m_reloadIcon = style()->standardIcon(QStyle::SP_BrowserReload); |
|
473 m_stopReload->setIcon(m_reloadIcon); |
|
474 |
|
475 m_navigationBar->addAction(m_stopReload); |
|
476 |
|
477 m_navigationBar->addWidget(m_tabWidget->lineEditStack()); |
|
478 |
|
479 m_toolbarSearch = new ToolbarSearch(m_navigationBar); |
|
480 m_navigationBar->addWidget(m_toolbarSearch); |
|
481 connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); |
|
482 |
|
483 m_chaseWidget = new ChaseWidget(this); |
|
484 m_navigationBar->addWidget(m_chaseWidget); |
|
485 } |
|
486 |
|
487 void BrowserMainWindow::slotShowBookmarksDialog() |
|
488 { |
|
489 BookmarksDialog *dialog = new BookmarksDialog(this); |
|
490 connect(dialog, SIGNAL(openUrl(const QUrl&)), |
|
491 m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); |
|
492 dialog->show(); |
|
493 } |
|
494 |
|
495 void BrowserMainWindow::slotAddBookmark() |
|
496 { |
|
497 WebView *webView = currentTab(); |
|
498 QString url = webView->url().toString(); |
|
499 QString title = webView->title(); |
|
500 AddBookmarkDialog dialog(url, title); |
|
501 dialog.exec(); |
|
502 } |
|
503 |
|
504 void BrowserMainWindow::slotViewToolbar() |
|
505 { |
|
506 if (m_navigationBar->isVisible()) { |
|
507 updateToolbarActionText(false); |
|
508 m_navigationBar->close(); |
|
509 } else { |
|
510 updateToolbarActionText(true); |
|
511 m_navigationBar->show(); |
|
512 } |
|
513 m_autoSaver->changeOccurred(); |
|
514 } |
|
515 |
|
516 void BrowserMainWindow::slotViewBookmarksBar() |
|
517 { |
|
518 if (m_bookmarksToolbar->isVisible()) { |
|
519 updateBookmarksToolbarActionText(false); |
|
520 m_bookmarksToolbar->close(); |
|
521 } else { |
|
522 updateBookmarksToolbarActionText(true); |
|
523 m_bookmarksToolbar->show(); |
|
524 } |
|
525 m_autoSaver->changeOccurred(); |
|
526 } |
|
527 |
|
528 void BrowserMainWindow::updateStatusbarActionText(bool visible) |
|
529 { |
|
530 m_viewStatusbar->setText(!visible ? tr("Show Status Bar") : tr("Hide Status Bar")); |
|
531 } |
|
532 |
|
533 void BrowserMainWindow::updateToolbarActionText(bool visible) |
|
534 { |
|
535 m_viewToolbar->setText(!visible ? tr("Show Toolbar") : tr("Hide Toolbar")); |
|
536 } |
|
537 |
|
538 void BrowserMainWindow::updateBookmarksToolbarActionText(bool visible) |
|
539 { |
|
540 m_viewBookmarkBar->setText(!visible ? tr("Show Bookmarks bar") : tr("Hide Bookmarks bar")); |
|
541 } |
|
542 |
|
543 void BrowserMainWindow::slotViewStatusbar() |
|
544 { |
|
545 if (statusBar()->isVisible()) { |
|
546 updateStatusbarActionText(false); |
|
547 statusBar()->close(); |
|
548 } else { |
|
549 updateStatusbarActionText(true); |
|
550 statusBar()->show(); |
|
551 } |
|
552 m_autoSaver->changeOccurred(); |
|
553 } |
|
554 |
|
555 QUrl BrowserMainWindow::guessUrlFromString(const QString &string) |
|
556 { |
|
557 QString urlStr = string.trimmed(); |
|
558 QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*")); |
|
559 |
|
560 // Check if it looks like a qualified URL. Try parsing it and see. |
|
561 bool hasSchema = test.exactMatch(urlStr); |
|
562 if (hasSchema) { |
|
563 QUrl url = QUrl::fromEncoded(urlStr.toUtf8(), QUrl::TolerantMode); |
|
564 if (url.isValid()) |
|
565 return url; |
|
566 } |
|
567 |
|
568 // Might be a file. |
|
569 if (QFile::exists(urlStr)) { |
|
570 QFileInfo info(urlStr); |
|
571 return QUrl::fromLocalFile(info.absoluteFilePath()); |
|
572 } |
|
573 |
|
574 // Might be a shorturl - try to detect the schema. |
|
575 if (!hasSchema) { |
|
576 int dotIndex = urlStr.indexOf(QLatin1Char('.')); |
|
577 if (dotIndex != -1) { |
|
578 QString prefix = urlStr.left(dotIndex).toLower(); |
|
579 QByteArray schema = (prefix == QLatin1String("ftp")) ? prefix.toLatin1() : QByteArray("http"); |
|
580 QUrl url = |
|
581 QUrl::fromEncoded(schema + "://" + urlStr.toUtf8(), QUrl::TolerantMode); |
|
582 if (url.isValid()) |
|
583 return url; |
|
584 } |
|
585 } |
|
586 |
|
587 // Fall back to QUrl's own tolerant parser. |
|
588 QUrl url = QUrl::fromEncoded(string.toUtf8(), QUrl::TolerantMode); |
|
589 |
|
590 // finally for cases where the user just types in a hostname add http |
|
591 if (url.scheme().isEmpty()) |
|
592 url = QUrl::fromEncoded("http://" + string.toUtf8(), QUrl::TolerantMode); |
|
593 return url; |
|
594 } |
|
595 |
|
596 void BrowserMainWindow::loadUrl(const QUrl &url) |
|
597 { |
|
598 if (!currentTab() || !url.isValid()) |
|
599 return; |
|
600 |
|
601 m_tabWidget->currentLineEdit()->setText(QString::fromUtf8(url.toEncoded())); |
|
602 m_tabWidget->loadUrlInCurrentTab(url); |
|
603 } |
|
604 |
|
605 void BrowserMainWindow::slotDownloadManager() |
|
606 { |
|
607 BrowserApplication::downloadManager()->show(); |
|
608 } |
|
609 |
|
610 void BrowserMainWindow::slotSelectLineEdit() |
|
611 { |
|
612 m_tabWidget->currentLineEdit()->selectAll(); |
|
613 m_tabWidget->currentLineEdit()->setFocus(); |
|
614 } |
|
615 |
|
616 void BrowserMainWindow::slotFileSaveAs() |
|
617 { |
|
618 BrowserApplication::downloadManager()->download(currentTab()->url(), true); |
|
619 } |
|
620 |
|
621 void BrowserMainWindow::slotPreferences() |
|
622 { |
|
623 SettingsDialog *s = new SettingsDialog(this); |
|
624 s->show(); |
|
625 } |
|
626 |
|
627 void BrowserMainWindow::slotUpdateStatusbar(const QString &string) |
|
628 { |
|
629 statusBar()->showMessage(string, 2000); |
|
630 } |
|
631 |
|
632 void BrowserMainWindow::slotUpdateWindowTitle(const QString &title) |
|
633 { |
|
634 if (title.isEmpty()) { |
|
635 setWindowTitle(tr("Qt Demo Browser")); |
|
636 } else { |
|
637 #if defined(Q_WS_MAC) |
|
638 setWindowTitle(title); |
|
639 #else |
|
640 setWindowTitle(tr("%1 - Qt Demo Browser", "Page title and Browser name").arg(title)); |
|
641 #endif |
|
642 } |
|
643 } |
|
644 |
|
645 void BrowserMainWindow::slotAboutApplication() |
|
646 { |
|
647 QMessageBox::about(this, tr("About"), tr( |
|
648 "Version %1" |
|
649 "<p>This demo demonstrates Qt's " |
|
650 "webkit facilities in action, providing an example " |
|
651 "browser for you to experiment with.<p>" |
|
652 "<p>QtWebKit is based on the Open Source WebKit Project developed at <a href=\"http://webkit.org/\">http://webkit.org/</a>." |
|
653 ).arg(QCoreApplication::applicationVersion())); |
|
654 } |
|
655 |
|
656 void BrowserMainWindow::slotFileNew() |
|
657 { |
|
658 BrowserApplication::instance()->newMainWindow(); |
|
659 BrowserMainWindow *mw = BrowserApplication::instance()->mainWindow(); |
|
660 mw->slotHome(); |
|
661 } |
|
662 |
|
663 void BrowserMainWindow::slotFileOpen() |
|
664 { |
|
665 QString file = QFileDialog::getOpenFileName(this, tr("Open Web Resource"), QString(), |
|
666 tr("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)")); |
|
667 |
|
668 if (file.isEmpty()) |
|
669 return; |
|
670 |
|
671 loadPage(file); |
|
672 } |
|
673 |
|
674 void BrowserMainWindow::slotFilePrintPreview() |
|
675 { |
|
676 #ifndef QT_NO_PRINTER |
|
677 if (!currentTab()) |
|
678 return; |
|
679 QPrintPreviewDialog *dialog = new QPrintPreviewDialog(this); |
|
680 connect(dialog, SIGNAL(paintRequested(QPrinter *)), |
|
681 currentTab(), SLOT(print(QPrinter *))); |
|
682 dialog->exec(); |
|
683 #endif |
|
684 } |
|
685 |
|
686 void BrowserMainWindow::slotFilePrint() |
|
687 { |
|
688 if (!currentTab()) |
|
689 return; |
|
690 printRequested(currentTab()->page()->mainFrame()); |
|
691 } |
|
692 |
|
693 void BrowserMainWindow::printRequested(QWebFrame *frame) |
|
694 { |
|
695 #ifndef QT_NO_PRINTER |
|
696 QPrinter printer; |
|
697 QPrintDialog *dialog = new QPrintDialog(&printer, this); |
|
698 dialog->setWindowTitle(tr("Print Document")); |
|
699 if (dialog->exec() != QDialog::Accepted) |
|
700 return; |
|
701 frame->print(&printer); |
|
702 #endif |
|
703 } |
|
704 |
|
705 void BrowserMainWindow::slotPrivateBrowsing() |
|
706 { |
|
707 QWebSettings *settings = QWebSettings::globalSettings(); |
|
708 bool pb = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); |
|
709 if (!pb) { |
|
710 QString title = tr("Are you sure you want to turn on private browsing?"); |
|
711 QString text = tr("<b>%1</b><br><br>When private browsing in turned on," |
|
712 " webpages are not added to the history," |
|
713 " items are automatically removed from the Downloads window," \ |
|
714 " new cookies are not stored, current cookies can't be accessed," \ |
|
715 " site icons wont be stored, session wont be saved, " \ |
|
716 " and searches are not addded to the pop-up menu in the Google search box." \ |
|
717 " Until you close the window, you can still click the Back and Forward buttons" \ |
|
718 " to return to the webpages you have opened.").arg(title); |
|
719 |
|
720 QMessageBox::StandardButton button = QMessageBox::question(this, QString(), text, |
|
721 QMessageBox::Ok | QMessageBox::Cancel, |
|
722 QMessageBox::Ok); |
|
723 if (button == QMessageBox::Ok) { |
|
724 settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); |
|
725 } |
|
726 } else { |
|
727 settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); |
|
728 |
|
729 QList<BrowserMainWindow*> windows = BrowserApplication::instance()->mainWindows(); |
|
730 for (int i = 0; i < windows.count(); ++i) { |
|
731 BrowserMainWindow *window = windows.at(i); |
|
732 window->m_lastSearch = QString::null; |
|
733 window->tabWidget()->clear(); |
|
734 } |
|
735 } |
|
736 } |
|
737 |
|
738 void BrowserMainWindow::closeEvent(QCloseEvent *event) |
|
739 { |
|
740 if (m_tabWidget->count() > 1) { |
|
741 int ret = QMessageBox::warning(this, QString(), |
|
742 tr("Are you sure you want to close the window?" |
|
743 " There are %1 tabs open").arg(m_tabWidget->count()), |
|
744 QMessageBox::Yes | QMessageBox::No, |
|
745 QMessageBox::No); |
|
746 if (ret == QMessageBox::No) { |
|
747 event->ignore(); |
|
748 return; |
|
749 } |
|
750 } |
|
751 event->accept(); |
|
752 deleteLater(); |
|
753 } |
|
754 |
|
755 void BrowserMainWindow::slotEditFind() |
|
756 { |
|
757 if (!currentTab()) |
|
758 return; |
|
759 bool ok; |
|
760 QString search = QInputDialog::getText(this, tr("Find"), |
|
761 tr("Text:"), QLineEdit::Normal, |
|
762 m_lastSearch, &ok); |
|
763 if (ok && !search.isEmpty()) { |
|
764 m_lastSearch = search; |
|
765 if (!currentTab()->findText(m_lastSearch)) |
|
766 slotUpdateStatusbar(tr("\"%1\" not found.").arg(m_lastSearch)); |
|
767 } |
|
768 } |
|
769 |
|
770 void BrowserMainWindow::slotEditFindNext() |
|
771 { |
|
772 if (!currentTab() && !m_lastSearch.isEmpty()) |
|
773 return; |
|
774 currentTab()->findText(m_lastSearch); |
|
775 } |
|
776 |
|
777 void BrowserMainWindow::slotEditFindPrevious() |
|
778 { |
|
779 if (!currentTab() && !m_lastSearch.isEmpty()) |
|
780 return; |
|
781 currentTab()->findText(m_lastSearch, QWebPage::FindBackward); |
|
782 } |
|
783 |
|
784 void BrowserMainWindow::slotViewZoomIn() |
|
785 { |
|
786 if (!currentTab()) |
|
787 return; |
|
788 currentTab()->setZoomFactor(currentTab()->zoomFactor() + 0.1); |
|
789 } |
|
790 |
|
791 void BrowserMainWindow::slotViewZoomOut() |
|
792 { |
|
793 if (!currentTab()) |
|
794 return; |
|
795 currentTab()->setZoomFactor(currentTab()->zoomFactor() - 0.1); |
|
796 } |
|
797 |
|
798 void BrowserMainWindow::slotViewResetZoom() |
|
799 { |
|
800 if (!currentTab()) |
|
801 return; |
|
802 currentTab()->setZoomFactor(1.0); |
|
803 } |
|
804 |
|
805 void BrowserMainWindow::slotViewZoomTextOnly(bool enable) |
|
806 { |
|
807 if (!currentTab()) |
|
808 return; |
|
809 currentTab()->page()->settings()->setAttribute(QWebSettings::ZoomTextOnly, enable); |
|
810 } |
|
811 |
|
812 void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen) |
|
813 { |
|
814 if (makeFullScreen) { |
|
815 showFullScreen(); |
|
816 } else { |
|
817 if (isMinimized()) |
|
818 showMinimized(); |
|
819 else if (isMaximized()) |
|
820 showMaximized(); |
|
821 else showNormal(); |
|
822 } |
|
823 } |
|
824 |
|
825 void BrowserMainWindow::slotViewPageSource() |
|
826 { |
|
827 if (!currentTab()) |
|
828 return; |
|
829 |
|
830 QString markup = currentTab()->page()->mainFrame()->toHtml(); |
|
831 QPlainTextEdit *view = new QPlainTextEdit(markup); |
|
832 view->setWindowTitle(tr("Page Source of %1").arg(currentTab()->title())); |
|
833 view->setMinimumWidth(640); |
|
834 view->setAttribute(Qt::WA_DeleteOnClose); |
|
835 view->show(); |
|
836 } |
|
837 |
|
838 void BrowserMainWindow::slotHome() |
|
839 { |
|
840 QSettings settings; |
|
841 settings.beginGroup(QLatin1String("MainWindow")); |
|
842 QString home = settings.value(QLatin1String("home"), QLatin1String("http://qt.nokia.com/")).toString(); |
|
843 loadPage(home); |
|
844 } |
|
845 |
|
846 void BrowserMainWindow::slotWebSearch() |
|
847 { |
|
848 m_toolbarSearch->lineEdit()->selectAll(); |
|
849 m_toolbarSearch->lineEdit()->setFocus(); |
|
850 } |
|
851 |
|
852 void BrowserMainWindow::slotToggleInspector(bool enable) |
|
853 { |
|
854 QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable); |
|
855 if (enable) { |
|
856 int result = QMessageBox::question(this, tr("Web Inspector"), |
|
857 tr("The web inspector will only work correctly for pages that were loaded after enabling.\n" |
|
858 "Do you want to reload all pages?"), |
|
859 QMessageBox::Yes | QMessageBox::No); |
|
860 if (result == QMessageBox::Yes) { |
|
861 m_tabWidget->reloadAllTabs(); |
|
862 } |
|
863 } |
|
864 } |
|
865 |
|
866 void BrowserMainWindow::slotSwapFocus() |
|
867 { |
|
868 if (currentTab()->hasFocus()) |
|
869 m_tabWidget->currentLineEdit()->setFocus(); |
|
870 else |
|
871 currentTab()->setFocus(); |
|
872 } |
|
873 |
|
874 void BrowserMainWindow::loadPage(const QString &page) |
|
875 { |
|
876 QUrl url = guessUrlFromString(page); |
|
877 loadUrl(url); |
|
878 } |
|
879 |
|
880 TabWidget *BrowserMainWindow::tabWidget() const |
|
881 { |
|
882 return m_tabWidget; |
|
883 } |
|
884 |
|
885 WebView *BrowserMainWindow::currentTab() const |
|
886 { |
|
887 return m_tabWidget->currentWebView(); |
|
888 } |
|
889 |
|
890 void BrowserMainWindow::slotLoadProgress(int progress) |
|
891 { |
|
892 if (progress < 100 && progress > 0) { |
|
893 m_chaseWidget->setAnimated(true); |
|
894 disconnect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); |
|
895 if (m_stopIcon.isNull()) |
|
896 m_stopIcon = style()->standardIcon(QStyle::SP_BrowserStop); |
|
897 m_stopReload->setIcon(m_stopIcon); |
|
898 connect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); |
|
899 m_stopReload->setToolTip(tr("Stop loading the current page")); |
|
900 } else { |
|
901 m_chaseWidget->setAnimated(false); |
|
902 disconnect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); |
|
903 m_stopReload->setIcon(m_reloadIcon); |
|
904 connect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); |
|
905 m_stopReload->setToolTip(tr("Reload the current page")); |
|
906 } |
|
907 } |
|
908 |
|
909 void BrowserMainWindow::slotAboutToShowBackMenu() |
|
910 { |
|
911 m_historyBackMenu->clear(); |
|
912 if (!currentTab()) |
|
913 return; |
|
914 QWebHistory *history = currentTab()->history(); |
|
915 int historyCount = history->count(); |
|
916 for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) { |
|
917 QWebHistoryItem item = history->backItems(history->count()).at(i); |
|
918 QAction *action = new QAction(this); |
|
919 action->setData(-1*(historyCount-i-1)); |
|
920 QIcon icon = BrowserApplication::instance()->icon(item.url()); |
|
921 action->setIcon(icon); |
|
922 action->setText(item.title()); |
|
923 m_historyBackMenu->addAction(action); |
|
924 } |
|
925 } |
|
926 |
|
927 void BrowserMainWindow::slotAboutToShowForwardMenu() |
|
928 { |
|
929 m_historyForwardMenu->clear(); |
|
930 if (!currentTab()) |
|
931 return; |
|
932 QWebHistory *history = currentTab()->history(); |
|
933 int historyCount = history->count(); |
|
934 for (int i = 0; i < history->forwardItems(history->count()).count(); ++i) { |
|
935 QWebHistoryItem item = history->forwardItems(historyCount).at(i); |
|
936 QAction *action = new QAction(this); |
|
937 action->setData(historyCount-i); |
|
938 QIcon icon = BrowserApplication::instance()->icon(item.url()); |
|
939 action->setIcon(icon); |
|
940 action->setText(item.title()); |
|
941 m_historyForwardMenu->addAction(action); |
|
942 } |
|
943 } |
|
944 |
|
945 void BrowserMainWindow::slotAboutToShowWindowMenu() |
|
946 { |
|
947 m_windowMenu->clear(); |
|
948 m_windowMenu->addAction(m_tabWidget->nextTabAction()); |
|
949 m_windowMenu->addAction(m_tabWidget->previousTabAction()); |
|
950 m_windowMenu->addSeparator(); |
|
951 m_windowMenu->addAction(tr("Downloads"), this, SLOT(slotDownloadManager()), QKeySequence(tr("Alt+Ctrl+L", "Download Manager"))); |
|
952 |
|
953 m_windowMenu->addSeparator(); |
|
954 QList<BrowserMainWindow*> windows = BrowserApplication::instance()->mainWindows(); |
|
955 for (int i = 0; i < windows.count(); ++i) { |
|
956 BrowserMainWindow *window = windows.at(i); |
|
957 QAction *action = m_windowMenu->addAction(window->windowTitle(), this, SLOT(slotShowWindow())); |
|
958 action->setData(i); |
|
959 action->setCheckable(true); |
|
960 if (window == this) |
|
961 action->setChecked(true); |
|
962 } |
|
963 } |
|
964 |
|
965 void BrowserMainWindow::slotShowWindow() |
|
966 { |
|
967 if (QAction *action = qobject_cast<QAction*>(sender())) { |
|
968 QVariant v = action->data(); |
|
969 if (v.canConvert<int>()) { |
|
970 int offset = qvariant_cast<int>(v); |
|
971 QList<BrowserMainWindow*> windows = BrowserApplication::instance()->mainWindows(); |
|
972 windows.at(offset)->activateWindow(); |
|
973 windows.at(offset)->currentTab()->setFocus(); |
|
974 } |
|
975 } |
|
976 } |
|
977 |
|
978 void BrowserMainWindow::slotOpenActionUrl(QAction *action) |
|
979 { |
|
980 int offset = action->data().toInt(); |
|
981 QWebHistory *history = currentTab()->history(); |
|
982 if (offset < 0) |
|
983 history->goToItem(history->backItems(-1*offset).first()); // back |
|
984 else if (offset > 0) |
|
985 history->goToItem(history->forwardItems(history->count() - offset + 1).back()); // forward |
|
986 } |
|
987 |
|
988 void BrowserMainWindow::geometryChangeRequested(const QRect &geometry) |
|
989 { |
|
990 setGeometry(geometry); |
|
991 } |
|
992 |