comparison demos/browser/tabwidget.d @ 77:0654fc9bac95

more porting
author mandel
date Sun, 24 May 2009 13:46:32 +0000
parents 37caa90ce503
children 85c59c4e5f19
comparison
equal deleted inserted replaced
76:454e4b4beb59 77:0654fc9bac95
81 super(parent); 81 super(parent);
82 setContextMenuPolicy(Qt.CustomContextMenu); 82 setContextMenuPolicy(Qt.CustomContextMenu);
83 setAcceptDrops(true); 83 setAcceptDrops(true);
84 this.customContextMenuRequested.connect(&this.contextMenuRequested); 84 this.customContextMenuRequested.connect(&this.contextMenuRequested);
85 85
86 QString alt = QLatin1String("Alt+%1"); 86 string alt = QLatin1String("Alt+%1");
87 for (int i = 1; i <= 10; ++i) { 87 for (int i = 1; i <= 10; ++i) {
88 int key = i; 88 int key = i;
89 if (key == 10) 89 if (key == 10)
90 key = 0; 90 key = 0;
91 QShortcut shortCut = new QShortcut(alt.arg(key), this); 91 QShortcut shortCut = new QShortcut(alt.arg(key), this);
92 m_tabShortcuts.append(shortCut); 92 m_tabShortcuts ~= shortCut;
93 shortCut.activated.connect(&this.selectTabAction); 93 shortCut.activated.connect(&this.selectTabAction);
94 } 94 }
95 setTabsClosable(true); 95 setTabsClosable(true);
96 this.tabCloseRequested.connect(&this.closeTab); 96 this.tabCloseRequested.connect(&this.closeTab);
97 setSelectionBehaviorOnRemove(QTabBar.SelectPreviousTab); 97 setSelectionBehaviorOnRemove(QTabBar.SelectPreviousTab);
113 int diffX = event.pos().x() - m_dragStartPos.x(); 113 int diffX = event.pos().x() - m_dragStartPos.x();
114 int diffY = event.pos().y() - m_dragStartPos.y(); 114 int diffY = event.pos().y() - m_dragStartPos.y();
115 if ((event.pos() - m_dragStartPos).manhattanLength() > QApplication.startDragDistance() && diffX < 3 && diffX > -3 && diffY < -10) { 115 if ((event.pos() - m_dragStartPos).manhattanLength() > QApplication.startDragDistance() && diffX < 3 && diffX > -3 && diffY < -10) {
116 QDrag drag = new QDrag(this); 116 QDrag drag = new QDrag(this);
117 QMimeData mimeData = new QMimeData; 117 QMimeData mimeData = new QMimeData;
118 QList<QUrl> urls; 118 QUrl[] urls;
119 int index = tabAt(event.pos()); 119 int index = tabAt(event.pos());
120 QUrl url = tabData(index).toUrl(); 120 QUrl url = tabData(index).toUrl();
121 urls.append(url); 121 urls ~= url;
122 mimeData.setUrls(urls); 122 mimeData.setUrls(urls);
123 mimeData.setText(tabText(index)); 123 mimeData.setText(tabText(index));
124 mimeData.setData(QLatin1String("action"), "tab-reordering"); 124 mimeData.setData(QLatin1String("action"), "tab-reordering");
125 drag.setMimeData(mimeData); 125 drag.setMimeData(mimeData);
126 drag.exec(); 126 drag.exec();
131 131
132 private: 132 private:
133 133
134 void selectTabAction() 134 void selectTabAction()
135 { 135 {
136 if (QShortcut shortCut = qobject_cast<QShortcut*>(sender())) { 136 if (QShortcut shortCut = cast(QShortcut) signalSender()) {
137 int index = m_tabShortcuts.indexOf(shortCut); 137 int index = m_tabShortcuts.indexOf(shortCut);
138 if (index == 0) 138 if (index == 0)
139 index = 10; 139 index = 10;
140 setCurrentIndex(index); 140 setCurrentIndex(index);
141 } 141 }
142 } 142 }
143 143
144 void cloneTab() 144 void cloneTab()
145 { 145 {
146 if (QAction action = qobject_cast<QAction>(sender())) { 146 if (QAction action = cast(QAction) signalSender()) {
147 int index = action.data().toInt(); 147 int index = action.data().toInt();
148 emit cloneTab(index); 148 cloneTab.emit(index);
149 } 149 }
150 } 150 }
151 151
152 void closeTab() 152 void closeTab()
153 { 153 {
154 if (QAction action = qobject_cast<QAction>(sender())) { 154 if (QAction action = cast(QAction) signalSender()) {
155 int index = action.data().toInt(); 155 int index = action.data().toInt();
156 emit closeTab(index); 156 closeTab.emit(index);
157 } 157 }
158 } 158 }
159 159
160 void closeOtherTabs() 160 void closeOtherTabs()
161 { 161 {
162 if (QAction action = qobject_cast<QAction>(sender())) { 162 if (QAction action = cast(QAction) signalSender()) {
163 int index = action.data().toInt(); 163 int index = action.data().toInt();
164 emit closeOtherTabs(index); 164 closeOtherTabs.emit(index);
165 } 165 }
166 } 166 }
167 167
168 void reloadTab() 168 void reloadTab()
169 { 169 {
170 if (QAction action = qobject_cast<QAction>(sender())) { 170 if (QAction action = cast(QAction) signalSender()) {
171 int index = action.data().toInt(); 171 int index = action.data().toInt();
172 emit reloadTab(index); 172 reloadTab.emit(index);
173 } 173 }
174 } 174 }
175 175
176 void contextMenuRequested(QPoint position) 176 void contextMenuRequested(QPoint position)
177 { 177 {
276 } 276 }
277 } 277 }
278 278
279 void childChanged() 279 void childChanged()
280 { 280 {
281 if (QAction source = qobject_cast<QAction>(sender())) { 281 if (QAction source = cast(QAction) signalSender()) {
282 if (m_root && m_currentParent && source.parent() == m_currentParent) { 282 if (m_root && m_currentParent && source.parent() == m_currentParent) {
283 m_root.setChecked(source.isChecked()); 283 m_root.setChecked(source.isChecked());
284 m_root.setEnabled(source.isEnabled()); 284 m_root.setEnabled(source.isEnabled());
285 } 285 }
286 } 286 }
315 to proxy the actions. 315 to proxy the actions.
316 */ 316 */
317 class TabWidget : public QTabWidget 317 class TabWidget : public QTabWidget
318 { 318 {
319 // tab widget signals 319 // tab widget signals
320 mixin Singal!("loadPage", QString /*url*/); 320 mixin Singal!("loadPage", string /*url*/);
321 mixin Singal!("tabsChanged"); 321 mixin Singal!("tabsChanged");
322 mixin Singal!("lastTabClosed"); 322 mixin Singal!("lastTabClosed");
323 323
324 // current tab signals 324 // current tab signals
325 mixin Singal!("setCurrentTitle", QString /*url*/); 325 mixin Singal!("setCurrentTitle", string /*url*/);
326 mixin Singal!("showStatusBarMessage", QString /*message*/); 326 mixin Singal!("showStatusBarMessage", string /*message*/);
327 mixin Singal!("linkHovered", QString /*link*/); 327 mixin Singal!("linkHovered", string /*link*/);
328 mixin Singal!("loadProgress", int /*progress*/); 328 mixin Singal!("loadProgress", int /*progress*/);
329 mixin Singal!("geometryChangeRequested", QRect /*geometry*/); 329 mixin Singal!("geometryChangeRequested", QRect /*geometry*/);
330 mixin Singal!("menuBarVisibilityChangeRequested", bool /*visible*/); 330 mixin Singal!("menuBarVisibilityChangeRequested", bool /*visible*/);
331 mixin Singal!("statusBarVisibilityChangeRequested", bool /*visible*/); 331 mixin Singal!("statusBarVisibilityChangeRequested", bool /*visible*/);
332 mixin Singal!("toolBarVisibilityChangeRequested", bool /*visible*/); 332 mixin Singal!("toolBarVisibilityChangeRequested", bool /*visible*/);
334 334
335 public: 335 public:
336 336
337 this(QWidget parent = null) 337 this(QWidget parent = null)
338 { 338 {
339 QTabWidget(parent) 339 super(parent);
340 m_recentlyClosedTabsAction = 0; 340 m_recentlyClosedTabsAction = 0;
341 m_newTabAction = 0; 341 m_newTabAction = 0;
342 m_closeTabAction = 0; 342 m_closeTabAction = 0;
343 m_nextTabAction = 0; 343 m_nextTabAction = 0;
344 m_previousTabAction = 0; 344 m_previousTabAction = 0;
348 m_tabBar = new TabBar(this); 348 m_tabBar = new TabBar(this);
349 349
350 setElideMode(Qt.ElideRight); 350 setElideMode(Qt.ElideRight);
351 351
352 m_tabBar.newTab.connect(&this.newTab); 352 m_tabBar.newTab.connect(&this.newTab);
353 m_tabBar.closeTab.connect(&this.closeTab(int))); 353 m_tabBar.closeTab.connect(&this.closeTab);
354 m_tabBar.cloneTab.connect(&this.cloneTab(int))); 354 m_tabBar.cloneTab.connect(&this.cloneTab);
355 m_tabBar.closeOtherTabs.connect(&this.closeOtherTabs(int))); 355 m_tabBar.closeOtherTabs.connect(&this.closeOtherTabs);
356 m_tabBar.reloadTab.connect(&this.reloadTab(int))); 356 m_tabBar.reloadTab.connect(&this.reloadTab);
357 m_tabBar.reloadAllTabs.connect(&this.reloadAllTabs())); 357 m_tabBar.reloadAllTabs.connect(&this.reloadAllTabs);
358 m_tabBar.tabMoved.connect(&this.moveTab(int, int))); 358 m_tabBar.tabMoved.connect(&this.moveTab);
359 setTabBar(m_tabBar); 359 setTabBar(m_tabBar);
360 setDocumentMode(true); 360 setDocumentMode(true);
361 361
362 // Actions 362 // Actions
363 m_newTabAction = new QAction(QIcon(QLatin1String(":addtab.png")), tr("New &Tab"), this); 363 m_newTabAction = new QAction(QIcon(QLatin1String(":addtab.png")), tr("New &Tab"), this);
369 m_closeTabAction.setShortcuts(QKeySequence.Close); 369 m_closeTabAction.setShortcuts(QKeySequence.Close);
370 m_closeTabAction.setIconVisibleInMenu(false); 370 m_closeTabAction.setIconVisibleInMenu(false);
371 m_closeTabAction.triggered.connect(&this.closeTab); 371 m_closeTabAction.triggered.connect(&this.closeTab);
372 372
373 m_nextTabAction = new QAction(tr("Show Next Tab"), this); 373 m_nextTabAction = new QAction(tr("Show Next Tab"), this);
374 QList<QKeySequence> shortcuts; 374 QKeySequence[] shortcuts;
375 shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BraceRight)); 375 shortcuts ~= QKeySequence(Qt.CTRL | Qt.Key_BraceRight);
376 shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_PageDown)); 376 shortcuts ~= QKeySequence(Qt.CTRL | Qt.Key_PageDown);
377 shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BracketRight)); 377 shortcuts ~= QKeySequence(Qt.CTRL | Qt.Key_BracketRight);
378 shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_Less)); 378 shortcuts ~= QKeySequence(Qt.CTRL | Qt.Key_Less);
379 m_nextTabAction.setShortcuts(shortcuts); 379 m_nextTabAction.setShortcuts(shortcuts);
380 m_nextTabAction.triggered.connect(&this.nextTab); 380 m_nextTabAction.triggered.connect(&this.nextTab);
381 381
382 m_previousTabAction = new QAction(tr("Show Previous Tab"), this); 382 m_previousTabAction = new QAction(tr("Show Previous Tab"), this);
383 shortcuts.clear(); 383 shortcuts.clear();
384 shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BraceLeft)); 384 shortcuts ~= QKeySequence(Qt.CTRL | Qt.Key_BraceLeft);
385 shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_PageUp)); 385 shortcuts ~= QKeySequence(Qt.CTRL | Qt.Key_PageUp);
386 shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BracketLeft)); 386 shortcuts ~= QKeySequence(Qt.CTRL | Qt.Key_BracketLeft);
387 shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_Greater)); 387 shortcuts ~= QKeySequence(Qt.CTRL | Qt.Key_Greater);
388 m_previousTabAction.setShortcuts(shortcuts); 388 m_previousTabAction.setShortcuts(shortcuts);
389 m_previousTabAction.triggered.connect(&this.previousTab); 389 m_previousTabAction.triggered.connect(&this.previousTab);
390 390
391 m_recentlyClosedTabsMenu = new QMenu(this); 391 m_recentlyClosedTabsMenu = new QMenu(this);
392 m_recentlyClosedTabsMenu.aboutToShow.connect(&this.aboutToShowRecentTabsMenu); 392 m_recentlyClosedTabsMenu.aboutToShow.connect(&this.aboutToShowRecentTabsMenu);
401 } 401 }
402 402
403 void clear() 403 void clear()
404 { 404 {
405 // clear the recently closed tabs 405 // clear the recently closed tabs
406 m_recentlyClosedTabs.clear(); 406 m_recentlyClosedTabs.length = 0;
407 // clear the line edit history 407 // clear the line edit history
408 for (int i = 0; i < m_lineEdits.count(); ++i) { 408 for (int i = 0; i < m_lineEdits.count(); ++i) {
409 QLineEdit qLineEdit = lineEdit(i); 409 QLineEdit qLineEdit = lineEdit(i);
410 qLineEdit.setText(qLineEdit.text()); 410 qLineEdit.setText(qLineEdit.text());
411 } 411 }
464 if (WebView webView = cast(WebView) widget) { 464 if (WebView webView = cast(WebView) widget) {
465 return webView; 465 return webView;
466 } else { 466 } else {
467 // optimization to delay creating the first webview 467 // optimization to delay creating the first webview
468 if (count() == 1) { 468 if (count() == 1) {
469 TabWidget that = const_cast<TabWidget>(this); 469 TabWidget that = cast(TabWidget) this;
470 that.setUpdatesEnabled(false); 470 that.setUpdatesEnabled(false);
471 that.newTab(); 471 that.newTab();
472 that.closeTab(0); 472 that.closeTab(0);
473 that.setUpdatesEnabled(true); 473 that.setUpdatesEnabled(true);
474 return currentWebView(); 474 return currentWebView();
477 return 0; 477 return 0;
478 } 478 }
479 479
480 QLineEdit lineEdit(int index) 480 QLineEdit lineEdit(int index)
481 { 481 {
482 UrlLineEdit urlLineEdit = qobject_cast<UrlLineEdit>(m_lineEdits.widget(index)); 482 UrlLineEdit urlLineEdit = cast(UrlLineEdit) m_lineEdits.widget(index);
483 if (urlLineEdit) 483 if (urlLineEdit)
484 return urlLineEdit.lineEdit(); 484 return urlLineEdit.lineEdit();
485 return 0; 485 return 0;
486 } 486 }
487 487
490 int index = indexOf(webView); 490 int index = indexOf(webView);
491 return index; 491 return index;
492 } 492 }
493 493
494 494
495 static const qint32 TabWidgetMagic = 0xaa; 495 static const int TabWidgetMagic = 0xaa;
496 496
497 QByteArray saveState() 497 QByteArray saveState()
498 { 498 {
499 int version = 1; 499 int version_ = 1;
500 QByteArray data; 500 QByteArray data;
501 QDataStream stream(data, QIODevice.WriteOnly); 501 QDataStream stream(data, QIODevice.WriteOnly);
502 502
503 stream << qint32(TabWidgetMagic); 503 stream << cast(int) TabWidgetMagic;
504 stream << qint32(version); 504 stream << cast(int) version_;
505 505
506 QStringList tabs; 506 string[] tabs;
507 for (int i = 0; i < count(); ++i) { 507 for (int i = 0; i < count(); ++i) {
508 if (WebView tab = cast(WebView) widget(i))) { 508 if (WebView tab = cast(WebView) widget(i)) {
509 tabs.append(tab.url().toString()); 509 tabs.append(tab.url().toString());
510 } else { 510 } else {
511 tabs.append(QString.null); 511 tabs.append(null); //QString.null);
512 } 512 }
513 } 513 }
514 stream << tabs; 514 stream << tabs;
515 stream << currentIndex(); 515 stream << currentIndex();
516 return data; 516 return data;
522 QByteArray sd = state; 522 QByteArray sd = state;
523 QDataStream stream(sd, QIODevice.ReadOnly); 523 QDataStream stream(sd, QIODevice.ReadOnly);
524 if (stream.atEnd()) 524 if (stream.atEnd())
525 return false; 525 return false;
526 526
527 qint32 marker; 527 int marker;
528 qint32 v; 528 int v;
529 stream >> marker; 529 stream >> marker;
530 stream >> v; 530 stream >> v;
531 if (marker != TabWidgetMagic || v != version_) 531 if (marker != TabWidgetMagic || v != version_)
532 return false; 532 return false;
533 533
534 QStringList openTabs; 534 string[] openTabs;
535 stream >> openTabs; 535 stream >> openTabs;
536 536
537 for (int i = 0; i < openTabs.count(); ++i) { 537 for (int i = 0; i < openTabs.length; ++i) {
538 if (i != 0) 538 if (i != 0)
539 newTab(); 539 newTab();
540 loadPage(openTabs.at(i)); 540 loadPage(openTabs[i]);
541 } 541 }
542 542
543 int currentTab; 543 int currentTab;
544 stream >> currentTab; 544 stream >> currentTab;
545 setCurrentIndex(currentTab); 545 setCurrentIndex(currentTab);
573 void mouseReleaseEvent(QMouseEvent event) 573 void mouseReleaseEvent(QMouseEvent event)
574 { 574 {
575 if (event.button() == Qt.MidButton && !childAt(event.pos()) 575 if (event.button() == Qt.MidButton && !childAt(event.pos())
576 // Remove the line below when QTabWidget does not have a one pixel frame 576 // Remove the line below when QTabWidget does not have a one pixel frame
577 && event.pos().y() < (tabBar().y() + tabBar().height())) { 577 && event.pos().y() < (tabBar().y() + tabBar().height())) {
578 QUrl url(QApplication.clipboard().text(QClipboard.Selection)); 578 auto url = new QUrl(QApplication.clipboard().text(QClipboard.Selection));
579 if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { 579 if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) {
580 WebView webView = newTab(); 580 WebView webView = newTab();
581 webView.setUrl(url); 581 webView.setUrl(url);
582 } 582 }
583 } 583 }
603 HistoryCompletionModel completionModel = new HistoryCompletionModel(this); 603 HistoryCompletionModel completionModel = new HistoryCompletionModel(this);
604 completionModel.setSourceModel(BrowserApplication.historyManager().historyFilterModel()); 604 completionModel.setSourceModel(BrowserApplication.historyManager().historyFilterModel());
605 m_lineEditCompleter = new QCompleter(completionModel, this); 605 m_lineEditCompleter = new QCompleter(completionModel, this);
606 // Should this be in Qt by default? 606 // Should this be in Qt by default?
607 QAbstractItemView popup = m_lineEditCompleter.popup(); 607 QAbstractItemView popup = m_lineEditCompleter.popup();
608 QListView listView = qobject_cast<QListView*>(popup); 608 QListView listView = cast(QListView) popup;
609 if (listView) 609 if (listView)
610 listView.setUniformItemSizes(true); 610 listView.setUniformItemSizes(true);
611 } 611 }
612 lineEdit.setCompleter(m_lineEditCompleter); 612 lineEdit.setCompleter(m_lineEditCompleter);
613 lineEdit.returnPressed.connect(&this.lineEditReturnPressed); 613 lineEdit.returnPressed.connect(&this.lineEditReturnPressed);
651 mapper.addChild(webView.page().action(mapper.webAction())); 651 mapper.addChild(webView.page().action(mapper.webAction()));
652 } 652 }
653 653
654 if (count() == 1) 654 if (count() == 1)
655 currentChanged(currentIndex()); 655 currentChanged(currentIndex());
656 emit tabsChanged(); 656 tabsChanged.emit();
657 return webView; 657 return webView;
658 } 658 }
659 659
660 // When index is -1 index chooses the current tab 660 // When index is -1 index chooses the current tab
661 void cloneTab(int index = -1) 661 void cloneTab(int index = -1)
692 return; 692 return;
693 } 693 }
694 hasFocus = tab.hasFocus(); 694 hasFocus = tab.hasFocus();
695 695
696 m_recentlyClosedTabsAction.setEnabled(true); 696 m_recentlyClosedTabsAction.setEnabled(true);
697 m_recentlyClosedTabs.prepend(tab.url()); 697 m_recentlyClosedTabs = [tab.url()] ~ m_recentlyClosedTabs;
698 if (m_recentlyClosedTabs.size() >= TabWidget.m_recentlyClosedTabsSize) 698 if (m_recentlyClosedTabs.length >= TabWidget.m_recentlyClosedTabsSize)
699 m_recentlyClosedTabs.removeLast(); 699 m_recentlyClosedTabs.removeLast();
700 } 700 }
701 QWidget lineEdit = m_lineEdits.widget(index); 701 QWidget lineEdit = m_lineEdits.widget(index);
702 m_lineEdits.removeWidget(lineEdit); 702 m_lineEdits.removeWidget(lineEdit);
703 lineEdit.deleteLater(); 703 lineEdit.deleteLater();
704 QWidget webView = widget(index); 704 QWidget webView = widget(index);
705 removeTab(index); 705 removeTab(index);
706 webView.deleteLater(); 706 webView.deleteLater();
707 emit tabsChanged(); 707 tabsChanged.emit();
708 if (hasFocus && count() > 0) 708 if (hasFocus && count() > 0)
709 currentWebView().setFocus(); 709 currentWebView().setFocus();
710 if (count() == 0) 710 if (count() == 0)
711 emit lastTabClosed(); 711 lastTabClosed.emit();
712 } 712 }
713 713
714 void closeOtherTabs(int index) 714 void closeOtherTabs(int index)
715 { 715 {
716 if (-1 == index) 716 if (-1 == index)
783 783
784 for (int i = 0; i < m_actions.count(); ++i) { 784 for (int i = 0; i < m_actions.count(); ++i) {
785 WebActionMapper mapper = m_actions[i]; 785 WebActionMapper mapper = m_actions[i];
786 mapper.updateCurrent(webView.page()); 786 mapper.updateCurrent(webView.page());
787 } 787 }
788 emit setCurrentTitle(webView.title()); 788 setCurrentTitle.emit(webView.title());
789 m_lineEdits.setCurrentIndex(index); 789 m_lineEdits.setCurrentIndex(index);
790 emit loadProgress(webView.progress()); 790 loadProgress.emit(webView.progress());
791 emit showStatusBarMessage(webView.lastStatusBarText()); 791 showStatusBarMessage.emit(webView.lastStatusBarText());
792 if (webView.url().isEmpty()) 792 if (webView.url().isEmpty())
793 m_lineEdits.currentWidget().setFocus(); 793 m_lineEdits.currentWidget().setFocus();
794 else 794 else
795 webView.setFocus(); 795 webView.setFocus();
796 } 796 }
797 797
798 void aboutToShowRecentTabsMenu() 798 void aboutToShowRecentTabsMenu()
799 { 799 {
800 m_recentlyClosedTabsMenu.clear(); 800 m_recentlyClosedTabsMenu.clear();
801 for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) { 801 for (int i = 0; i < m_recentlyClosedTabs.length; ++i) {
802 QAction action = new QAction(m_recentlyClosedTabsMenu); 802 QAction action = new QAction(m_recentlyClosedTabsMenu);
803 action.setData(m_recentlyClosedTabs.at(i)); 803 action.setData(m_recentlyClosedTabs[i]);
804 QIcon icon = BrowserApplication.instance().icon(m_recentlyClosedTabs.at(i)); 804 QIcon icon = BrowserApplication.instance().icon(m_recentlyClosedTabs[i]);
805 action.setIcon(icon); 805 action.setIcon(icon);
806 action.setText(m_recentlyClosedTabs.at(i).toString()); 806 action.setText(m_recentlyClosedTabs[i].toString());
807 m_recentlyClosedTabsMenu.addAction(action); 807 m_recentlyClosedTabsMenu.addAction(action);
808 } 808 }
809 } 809 }
810 810
811 void aboutToShowRecentTriggeredAction(QAction action) 811 void aboutToShowRecentTriggeredAction(QAction action)
814 loadUrlInCurrentTab(url); 814 loadUrlInCurrentTab(url);
815 } 815 }
816 816
817 void webViewLoadStarted() 817 void webViewLoadStarted()
818 { 818 {
819 WebView webView = cast(WebView) sender(); 819 WebView webView = cast(WebView) signalSender();
820 int index = webViewIndex(webView); 820 int index = webViewIndex(webView);
821 if (-1 != index) { 821 if (-1 != index) {
822 QIcon icon(QLatin1String(":loading.gif")); 822 auto icon = new QIcon(QLatin1String(":loading.gif"));
823 setTabIcon(index, icon); 823 setTabIcon(index, icon);
824 } 824 }
825 } 825 }
826 826
827 void webViewIconChanged() 827 void webViewIconChanged()
828 { 828 {
829 WebView webView = cast(WebView) sender(); 829 WebView webView = cast(WebView) signalSender();
830 int index = webViewIndex(webView); 830 int index = webViewIndex(webView);
831 if (-1 != index) { 831 if (-1 != index) {
832 QIcon icon = BrowserApplication.instance().icon(webView.url()); 832 QIcon icon = BrowserApplication.instance().icon(webView.url());
833 setTabIcon(index, icon); 833 setTabIcon(index, icon);
834 } 834 }
835 } 835 }
836 836
837 void webViewTitleChanged(QString title) 837 void webViewTitleChanged(string title)
838 { 838 {
839 WebView webView = cast(WebView) sender(); 839 WebView webView = cast(WebView) signalSender();
840 int index = webViewIndex(webView); 840 int index = webViewIndex(webView);
841 if (-1 != index) { 841 if (-1 != index) {
842 setTabText(index, title); 842 setTabText(index, title);
843 } 843 }
844 if (currentIndex() == index) 844 if (currentIndex() == index)
845 emit setCurrentTitle(title); 845 setCurrentTitle.emit(title);
846 BrowserApplication.historyManager().updateHistoryItem(webView.url(), title); 846 BrowserApplication.historyManager().updateHistoryItem(webView.url(), title);
847 } 847 }
848 848
849 void webViewUrlChanged(QUrl url) 849 void webViewUrlChanged(QUrl url)
850 { 850 {
851 WebView webView = cast(WebView) sender(); 851 WebView webView = cast(WebView) signalSender();
852 int index = webViewIndex(webView); 852 int index = webViewIndex(webView);
853 if (-1 != index) { 853 if (-1 != index) {
854 m_tabBar.setTabData(index, url); 854 m_tabBar.setTabData(index, url);
855 } 855 }
856 emit tabsChanged(); 856 tabsChanged.emit();
857 } 857 }
858 858
859 void lineEditReturnPressed() 859 void lineEditReturnPressed()
860 { 860 {
861 if (QLineEdit lineEdit = cast(QLineEdit) sender()) { 861 if (QLineEdit lineEdit = cast(QLineEdit) signalSender()) {
862 emit loadPage(lineEdit.text()); 862 loadPage.emit(lineEdit.text());
863 if (m_lineEdits.currentWidget() == lineEdit) 863 if (m_lineEdits.currentWidget() == lineEdit)
864 currentWebView().setFocus(); 864 currentWebView().setFocus();
865 } 865 }
866 } 866 }
867 867
868 void windowCloseRequested() 868 void windowCloseRequested()
869 { 869 {
870 WebPage webPage = cast(WebPage) sender(); 870 WebPage webPage = cast(WebPage) signalSender();
871 WebView webView = cast(WebView) webPage.view(); 871 WebView webView = cast(WebView) webPage.view();
872 int index = webViewIndex(webView); 872 int index = webViewIndex(webView);
873 if (index >= 0) { 873 if (index >= 0) {
874 if (count() == 1) 874 if (count() == 1)
875 webView.webPage().mainWindow().close(); 875 webView.webPage().mainWindow().close();