From eb0d24efd3020dfac444e79defb0c2d6ab6a33f5 Mon Sep 17 00:00:00 2001 From: nowrep Date: Mon, 9 Jan 2012 22:14:02 +0100 Subject: [PATCH] Edited Menu behaviour on Mac, should hopefully close #129 - also improved visible clicks on ToolButtons --- src/app/qupzilla.cpp | 18 ++++++++++++++--- src/app/qupzilla.h | 5 +++++ src/other/aboutdialog.cpp | 42 ++++++++++++++++++++++----------------- src/tools/toolbutton.cpp | 6 ++++++ 4 files changed, 50 insertions(+), 21 deletions(-) diff --git a/src/app/qupzilla.cpp b/src/app/qupzilla.cpp index d9905b41d..c9d74ce2c 100644 --- a/src/app/qupzilla.cpp +++ b/src/app/qupzilla.cpp @@ -90,6 +90,9 @@ QupZilla::QupZilla(StartBehaviour behaviour, QUrl startUrl) , m_startingUrl(startUrl) , m_startBehaviour(behaviour) , m_menuBookmarksAction(0) + #ifdef Q_WS_MAC + , m_macMenuBar(new QMenuBar()) + #endif , m_actionPrivateBrowsing(0) , m_statusBarMessage(new StatusBarMessage(this)) , m_sideBarWidth(0) @@ -261,19 +264,28 @@ void QupZilla::setupUi() statusBar()->insertPermanentWidget(3, m_adblockIcon); } +QMenuBar* QupZilla::menuBar() const +{ +#ifdef Q_WS_MAC + return m_macMenuBar; +#else + return QMainWindow::menuBar(); +#endif +} + void QupZilla::setupMenu() { // Standard actions - needed on Mac to be placed correctly in "application" menu - m_actionAbout = new QAction(QIcon(":/icons/qupzilla.png"), tr("&About QupZilla"), this); + m_actionAbout = new QAction(QIcon(":/icons/qupzilla.png"), tr("&About QupZilla"), 0); m_actionAbout->setMenuRole(QAction::AboutRole); connect(m_actionAbout, SIGNAL(triggered()), this, SLOT(aboutQupZilla())); - m_actionPreferences = new QAction(QIcon(":/icons/faenza/settings.png"), tr("Pr&eferences"), this); + m_actionPreferences = new QAction(QIcon(":/icons/faenza/settings.png"), tr("Pr&eferences"), 0); m_actionPreferences->setMenuRole(QAction::PreferencesRole); m_actionPreferences->setShortcut(QKeySequence("Ctrl+P")); connect(m_actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences())); - m_actionQuit = new QAction(QIcon::fromTheme("application-exit"), tr("Quit"), this); + m_actionQuit = new QAction(QIcon::fromTheme("application-exit"), tr("Quit"), 0); m_actionQuit->setMenuRole(QAction::QuitRole); m_actionQuit->setShortcut(QKeySequence("Ctrl+Q")); connect(m_actionQuit, SIGNAL(triggered()), this, SLOT(quitApp())); diff --git a/src/app/qupzilla.h b/src/app/qupzilla.h index 3ac4210d6..6354b4efe 100644 --- a/src/app/qupzilla.h +++ b/src/app/qupzilla.h @@ -91,6 +91,8 @@ public: void showNavigationWithFullscreen(); void saveSideBarWidth(); + virtual QMenuBar* menuBar() const; + inline WebView* weView() const { WebTab* webTab = qobject_cast(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); } inline WebView* weView(int index) const { WebTab* webTab = qobject_cast(m_tabWidget->widget(index)); if (!webTab) return 0; return webTab->view(); } inline LocationBar* locationBar() { return qobject_cast(m_tabWidget->locationBars()->currentWidget()); } @@ -232,6 +234,9 @@ private: QMenu* m_menuClosedTabs; QMenu* m_menuEncoding; QAction* m_menuBookmarksAction; +#ifdef Q_WS_MAC + QMenuBar* m_macMenuBar; +#endif QAction* m_actionAbout; QAction* m_actionPreferences; diff --git a/src/other/aboutdialog.cpp b/src/other/aboutdialog.cpp index e1a2b628e..7eabf3484 100644 --- a/src/other/aboutdialog.cpp +++ b/src/other/aboutdialog.cpp @@ -76,24 +76,30 @@ void AboutDialog::showAuthors() if (m_authorsHtml.isEmpty()) { m_authorsHtml.append("
"); m_authorsHtml.append(tr("

Main developer:
%1 <%2>

").arg(QupZilla::AUTHOR, "nowrep@gmail.com")); - m_authorsHtml.append(tr("

Contributors:
%1

").arg("Mladen Pejaković
Bryan M Dunsmore
Jan Rajnoha
Daniele Cocca")); - m_authorsHtml.append(tr("

Translators:
%1

").arg("Heimen Stoffels (Dutch)
" - "Peter Vacula (Slovakia)
" - "Ján Ďanovský (Slovakia)
" - "Jonathan Hooverman (German)
" - "Unink-Lio (Chinese)
" - "Federico Fabiani (Italy)
" - "Francesco Marinucci (Italy)
" - "Jorge Sevilla (Spanish)
" - "Michał Szymanowski (Polish)
" - "Jérôme Giry (French)
" - "Nicolas Ourceau (French)
" - "Vasilis Tsivikis (Greek)
" - "Alexander Maslov (Russian)
" - "Oleg Brezhnev (Russian)
" - "Sérgio Marques (Portuguese)
" - "Mladen Pejaković (Serbian)" - )); + m_authorsHtml.append(tr("

Contributors:
%1

").arg( + "Mladen Pejaković
" + "Bryan M Dunsmore
" + "Jan Rajnoha
" + "Daniele Cocca" + )); + m_authorsHtml.append(tr("

Translators:
%1

").arg( + "Heimen Stoffels (Dutch)
" + "Peter Vacula (Slovakia)
" + "Ján Ďanovský (Slovakia)
" + "Jonathan Hooverman (German)
" + "Unink-Lio (Chinese)
" + "Federico Fabiani (Italy)
" + "Francesco Marinucci (Italy)
" + "Jorge Sevilla (Spanish)
" + "Michał Szymanowski (Polish)
" + "Jérôme Giry (French)
" + "Nicolas Ourceau (French)
" + "Vasilis Tsivikis (Greek)
" + "Alexander Maslov (Russian)
" + "Oleg Brezhnev (Russian)
" + "Sérgio Marques (Portuguese)
" + "Mladen Pejaković (Serbian)" + )); m_authorsHtml.append("
"); } ui->textBrowser->setHtml(m_authorsHtml); diff --git a/src/tools/toolbutton.cpp b/src/tools/toolbutton.cpp index 01df0ae1a..2cb0ea2ad 100644 --- a/src/tools/toolbutton.cpp +++ b/src/tools/toolbutton.cpp @@ -82,11 +82,17 @@ void ToolButton::mousePressEvent(QMouseEvent* e) return; } + if (e->button() == Qt::MiddleButton) { + setDown(true); + } + QToolButton::mousePressEvent(e); } void ToolButton::mouseReleaseEvent(QMouseEvent* e) { + setDown(false); + if (e->button() == Qt::MiddleButton && rect().contains(e->pos())) { emit middleMouseClicked(); return;