~ubuntu-branches/ubuntu/oneiric/arora/oneiric

« back to all changes in this revision

Viewing changes to src/browsermainwindow.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sune Vuorela
  • Date: 2008-06-29 22:41:06 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080629224106-71n3f1419hlrp5of
Tags: 0.2-1
* Finally a upstream release.
* Use make install instead of handpicking files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
            m_navigationBar, SLOT(setVisible(bool)));
158
158
    connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)),
159
159
            m_bookmarksToolbar, SLOT(setVisible(bool)));
160
 
#if defined(Q_WS_MAC)
161
160
    connect(m_tabWidget, SIGNAL(lastTabClosed()),
162
161
            this, SLOT(close()));
163
 
#else
164
 
    connect(m_tabWidget, SIGNAL(lastTabClosed()),
165
 
            m_tabWidget, SLOT(newTab()));
166
 
#endif
167
162
 
168
163
    slotUpdateWindowTitle();
169
164
    loadDefaultState();
171
166
 
172
167
    int size = m_tabWidget->lineEditStack()->sizeHint().height();
173
168
    m_navigationBar->setIconSize(QSize(size, size));
 
169
 
 
170
    // Add each item in the menu bar to the main window so
 
171
    // if the menu bar is hidden the shortcuts still work.
 
172
    QList<QAction *> actions = menuBar()->actions();
 
173
    foreach (QAction *action, actions) {
 
174
        if (action->menu())
 
175
            actions += action->menu()->actions();
 
176
        addAction(action);
 
177
    }
174
178
}
175
179
 
176
180
BrowserMainWindow::~BrowserMainWindow()
282
286
    return true;
283
287
}
284
288
 
 
289
QAction *BrowserMainWindow::showMenuBarAction() const
 
290
{
 
291
    return m_showMenuBarAction;
 
292
}
 
293
 
285
294
void BrowserMainWindow::setupMenu()
286
295
{
287
296
    new QShortcut(QKeySequence(Qt::Key_F6), this, SLOT(slotSwapFocus()));
355
364
 
356
365
    // View
357
366
    QMenu *viewMenu = menuBar()->addMenu(tr("&View"));
358
 
    new QShortcut(QKeySequence("Ctrl+m"), this, SLOT(slotViewMenuBar()));
 
367
    m_showMenuBarAction = new QAction("Show Menu Bar", this);
 
368
    m_showMenuBarAction->setShortcut(QKeySequence("Ctrl+m"));
 
369
    connect(m_showMenuBarAction, SIGNAL(triggered()), this, SLOT(slotViewMenuBar()));
 
370
    addAction(m_showMenuBarAction);
359
371
 
360
372
    m_viewToolbar = new QAction(this);
361
373
    updateToolbarActionText(true);
512
524
    m_navigationSplitter->addWidget(m_tabWidget->lineEditStack());
513
525
    m_toolbarSearch = new ToolbarSearch(m_navigationBar);
514
526
    m_navigationSplitter->addWidget(m_toolbarSearch);
515
 
    connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&)));
 
527
    connect(m_toolbarSearch, SIGNAL(search(const QUrl&)),
 
528
            m_tabWidget, SLOT(loadUrl(const QUrl&)));
516
529
    m_navigationSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
517
530
    m_tabWidget->lineEditStack()->setMinimumWidth(120);
518
531
    m_navigationSplitter->setCollapsible(0, false);
581
594
 
582
595
void BrowserMainWindow::updateBookmarksToolbarActionText(bool visible)
583
596
{
584
 
    m_viewBookmarkBar->setText(!visible ? tr("Show Bookmarks bar") : tr("Hide Bookmarks bar"));
 
597
    m_viewBookmarkBar->setText(!visible ? tr("Show Bookmarks Bar") : tr("Hide Bookmarks Bar"));
585
598
}
586
599
 
587
600
void BrowserMainWindow::slotViewStatusbar()
604
617
    // Check if it looks like a qualified URL. Try parsing it and see.
605
618
    bool hasSchema = test.exactMatch(urlStr);
606
619
    if (hasSchema) {
607
 
        QUrl url(urlStr, QUrl::TolerantMode);
 
620
        bool isAscii = true;
 
621
        foreach (QChar c, urlStr) {
 
622
            if (c >= 0x80) {
 
623
                isAscii = false;
 
624
                break;
 
625
            }
 
626
        }
 
627
 
 
628
        QUrl url;
 
629
        if (isAscii) {
 
630
            url = QUrl::fromEncoded(urlStr.toAscii(), QUrl::TolerantMode);
 
631
        } else {
 
632
            url = QUrl(urlStr, QUrl::TolerantMode);
 
633
        }
608
634
        if (url.isValid())
609
635
            return url;
610
636
    }
636
662
    return url;
637
663
}
638
664
 
639
 
void BrowserMainWindow::loadUrl(const QUrl &url)
640
 
{
641
 
    loadPage(url.toString());
642
 
}
643
 
 
644
665
void BrowserMainWindow::slotDownloadManager()
645
666
{
646
667
    BrowserApplication::downloadManager()->show();
775
796
        if (confirm) {
776
797
            int ret = QMessageBox::warning(this, QString(),
777
798
                                           tr("Are you sure you want to close the window?"
778
 
                                              "  There are %1 tab open").arg(m_tabWidget->count()),
 
799
                                              "  There are %1 tabs open").arg(m_tabWidget->count()),
779
800
                                           QMessageBox::Yes | QMessageBox::No,
780
801
                                           QMessageBox::No);
781
802
            if (ret == QMessageBox::No) {