1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Merge pull request #807 from srazi/Mac_work

Fixed some Mac/Windows issues.
This commit is contained in:
David Rosca 2013-03-16 11:39:59 -07:00
commit 98d4725c18
9 changed files with 86 additions and 31 deletions

View File

@ -62,6 +62,7 @@
#ifdef Q_OS_MAC
#include "macmenureceiver.h"
#include <QFileOpenEvent>
#include <QMenu>
#endif
#include <QNetworkDiskCache>
#include <QDesktopServices>
@ -114,6 +115,7 @@ MainApplication::MainApplication(int &argc, char** argv)
#endif
#ifdef Q_OS_MAC
, m_macMenuReceiver(0)
, m_macDockMenu(0)
#endif
{
#if defined(QZ_WS_X11) && !defined(NO_SYSTEM_DATAPATH)
@ -284,14 +286,6 @@ MainApplication::MainApplication(int &argc, char** argv)
int afterLaunch = settings.value("Web-URL-Settings/afterLaunch", 1).toInt();
settings.setValue("SessionRestore/isRunning", true);
#ifndef PORTABLE_BUILD
bool alwaysCheckDefaultBrowser = settings.value("Web-Browser-Settings/CheckDefaultBrowser", DEFAULT_CHECK_DEFAULTBROWSER).toBool();
if (alwaysCheckDefaultBrowser) {
alwaysCheckDefaultBrowser = checkDefaultWebBrowser();
settings.setValue("Web-Browser-Settings/CheckDefaultBrowser", alwaysCheckDefaultBrowser);
}
#endif
if (checkUpdates) {
new Updater(qupzilla);
}
@ -327,6 +321,15 @@ void MainApplication::postLaunch()
connect(this, SIGNAL(messageReceived(QString)), this, SLOT(receiveAppMessage(QString)));
connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveSettings()));
#ifndef PORTABLE_BUILD
Settings settings;
bool alwaysCheckDefaultBrowser = settings.value("Web-Browser-Settings/CheckDefaultBrowser", DEFAULT_CHECK_DEFAULTBROWSER).toBool();
if (alwaysCheckDefaultBrowser) {
alwaysCheckDefaultBrowser = checkDefaultWebBrowser();
settings.setValue("Web-Browser-Settings/CheckDefaultBrowser", alwaysCheckDefaultBrowser);
}
#endif
}
void MainApplication::loadSettings()
@ -639,6 +642,17 @@ QupZilla* MainApplication::makeNewWindow(Qz::BrowserWindow type, const QUrl &sta
}
#ifdef Q_OS_MAC
extern void qt_mac_set_dock_menu(QMenu* menu);
QMenu* MainApplication::macDockMenu()
{
if (!m_macDockMenu) {
m_macDockMenu = new QMenu(0);
qt_mac_set_dock_menu(m_macDockMenu);
}
return m_macDockMenu;
}
MacMenuReceiver* MainApplication::macMenuReceiver()
{
if (!m_macMenuReceiver) {
@ -938,9 +952,10 @@ bool MainApplication::checkDefaultWebBrowser()
#ifdef Q_OS_WIN
bool showAgain = true;
if (!associationManager()->isDefaultForAllCapabilities()) {
CheckBoxDialog dialog(QDialogButtonBox::Yes | QDialogButtonBox::No);
CheckBoxDialog dialog(QDialogButtonBox::Yes | QDialogButtonBox::No, getWindow());
dialog.setText(tr("QupZilla is not currently your default browser. Would you like to make it your default browser?"));
dialog.setCheckBoxText(tr("Always perform this check when starting QupZilla."));
dialog.setDefaultCheckState(Qt::Checked);
dialog.setWindowTitle(tr("Default Browser"));
dialog.setIcon(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning));
@ -1213,4 +1228,7 @@ QString MainApplication::tempPath() const
MainApplication::~MainApplication()
{
delete m_uaManager;
#ifdef Q_OS_MAC
delete m_macDockMenu;
#endif
}

View File

@ -54,6 +54,7 @@ class HTML5PermissionsManager;
class Speller;
#ifdef Q_OS_MAC
class MacMenuReceiver;
class QMenu;
#endif
class QT_QUPZILLA_EXPORT MainApplication : public QtSingleApplication
@ -130,6 +131,7 @@ public:
#ifdef Q_OS_MAC
MacMenuReceiver* macMenuReceiver();
QMenu* macDockMenu();
bool event(QEvent* e);
#endif
@ -205,6 +207,7 @@ private:
#endif
#ifdef Q_OS_MAC
MacMenuReceiver* m_macMenuReceiver;
QMenu* m_macDockMenu;
#endif
};

View File

@ -192,7 +192,10 @@ void QupZilla::postLaunch()
}
break;
#ifdef Q_OS_MAC
case Qz::BW_MacFirstWindow:
QTimer::singleShot(0, this, SLOT(refreshStateOfAllActions()));
#endif
case Qz::BW_NewWindow:
addTab = true;
break;
@ -247,6 +250,8 @@ void QupZilla::postLaunch()
QMainWindow::setWindowTitle(m_lastWindowTitle);
setUpdatesEnabled(true);
raise();
activateWindow();
}
void QupZilla::setupUi()
@ -623,6 +628,12 @@ void QupZilla::setupMenu()
m_superMenu->addSeparator();
m_superMenu->addAction(new ActionCopy(m_actionQuit, this));
#else
ActionCopy* copyActionPrivateBrowsing = new ActionCopy(m_actionPrivateBrowsing);
copyActionPrivateBrowsing->setText(copyActionPrivateBrowsing->text().remove(QLatin1Char('&')));
mApp->macDockMenu()->addAction(copyActionPrivateBrowsing);
mApp->macDockMenu()->addAction(m_menuFile->actions().at(1));
mApp->macDockMenu()->addAction(m_menuFile->actions().at(0));
#endif
}
@ -701,6 +712,16 @@ void QupZilla::setupMacMenu()
m_actionPageInfo = m_menuTools->actions().at(1);
m_actionPrivateBrowsing = m_menuTools->actions().at(9);
}
void QupZilla::refreshStateOfAllActions()
{
mApp->macMenuReceiver()->aboutToShowFileMenu(m_menuFile);
mApp->macMenuReceiver()->aboutToShowHistoryMenu(m_menuHistory);
mApp->macMenuReceiver()->aboutToShowBookmarksMenu(m_menuBookmarks);
mApp->macMenuReceiver()->aboutToShowViewMenu(m_menuView);
mApp->macMenuReceiver()->aboutToShowEditMenu(m_menuEdit);
mApp->macMenuReceiver()->aboutToShowToolsMenu(m_menuTools);
}
#endif
void QupZilla::loadSettings()
@ -2122,6 +2143,8 @@ void QupZilla::closeEvent(QCloseEvent* event)
return;
}
#else
QTimer::singleShot(0, this, SLOT(refreshStateOfAllActions()));
#endif
mApp->aboutToCloseWindow(this);

View File

@ -209,6 +209,9 @@ private slots:
void restoreAllClosedTabs();
void clearClosedTabsList();
void hideNavigationSlot();
#ifdef Q_OS_MAC
void refreshStateOfAllActions();
#endif
private:
bool event(QEvent* event);
@ -232,12 +235,12 @@ private:
#if (QT_VERSION < 0x050000)
bool winEvent(MSG* message, long* result);
#else
void paintEvent(QPaintEvent* event);
bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
#endif
void applyBlurToMainWindow(bool force = false);
void paintEvent(QPaintEvent* event);
bool eventFilter(QObject* object, QEvent* event);
#endif

View File

@ -279,7 +279,7 @@ void NetworkManager::authentication(QNetworkReply* reply, QAuthenticator* auth)
connect(box, SIGNAL(accepted()), dialog, SLOT(accept()));
label->setText(tr("A username and password are being requested by %1. "
"The site says: \"%2\"").arg(reply->url().toEncoded(), QzTools::escape(auth->realm())));
"The site says: \"%2\"").arg(reply->url().host(), QzTools::escape(auth->realm())));
formLa->addRow(label);
formLa->addRow(userLab, user);

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -48,6 +48,11 @@ bool CheckBoxDialog::isChecked() const
return ui->checkBox->isChecked();
}
void CheckBoxDialog::setDefaultCheckState(Qt::CheckState state)
{
ui->checkBox->setChecked(state == Qt::Checked);
}
int CheckBoxDialog::exec()
{
ui->buttonBox->setFocus();

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -40,6 +40,7 @@ public:
void setCheckBoxText(const QString &text);
bool isChecked() const;
void setDefaultCheckState(Qt::CheckState state);
public slots:
int exec();

View File

@ -426,9 +426,9 @@ void MacMenuReceiver::loadActionUrlInNewNotSelectedTab(QObject* obj)
}
// about to show/hide slots
void MacMenuReceiver::aboutToShowFileMenu()
void MacMenuReceiver::aboutToShowFileMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
setEnabledSelectedMenuActions(menu);
if (!callSlot("aboutToShowFileMenu")) {
setDisabledSelectedMenuActions(menu, QList<int>()
@ -441,9 +441,9 @@ void MacMenuReceiver::aboutToHideFileMenu()
callSlot("aboutToHideFileMenu");
}
void MacMenuReceiver::aboutToShowHistoryMenu()
void MacMenuReceiver::aboutToShowHistoryMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
// 2=Home, 3=Show all History, 7=Closed Tabs
setEnabledSelectedMenuActions(menu, QList<int>() << 2 << 3 << 7);
if (!callSlot("aboutToShowHistoryMenu")) {
@ -462,18 +462,18 @@ void MacMenuReceiver::aboutToShowClosedTabsMenu()
callSlot("aboutToShowClosedTabsMenu");
}
void MacMenuReceiver::aboutToShowBookmarksMenu()
void MacMenuReceiver::aboutToShowBookmarksMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
setEnabledSelectedMenuActions(menu, QList<int>() << 0 << 1 << 2);
if (!callSlot("aboutToShowBookmarksMenu")) {
setDisabledSelectedMenuActions(menu, QList<int>() << 0 << 1 << 2);
}
}
void MacMenuReceiver::aboutToShowViewMenu()
void MacMenuReceiver::aboutToShowViewMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
// 7,8,9=Zoom actions, 12=Character Encoding, 15=Fullscreen
setEnabledSelectedMenuActions(menu, QList<int>()
<< 0 << 1 << 2 << 7 << 8 << 9 << 11 << 12 << 15);
@ -492,9 +492,9 @@ void MacMenuReceiver::aboutToHideViewMenu()
callSlot("aboutToHideViewMenu");
}
void MacMenuReceiver::aboutToShowEditMenu()
void MacMenuReceiver::aboutToShowEditMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
// 8=Find
setEnabledSelectedMenuActions(menu, QList<int>() << 8);
if (!callSlot("aboutToShowEditMenu")) {
@ -507,9 +507,9 @@ void MacMenuReceiver::aboutToHideEditMenu()
callSlot("aboutToHideEditMenu");
}
void MacMenuReceiver::aboutToShowToolsMenu()
void MacMenuReceiver::aboutToShowToolsMenu(QMenu* menu)
{
QMenu* menu = qobject_cast<QMenu*>(sender());
menu = menu ? menu : qobject_cast<QMenu*>(sender());
// enable all
setEnabledSelectedMenuActions(menu);
if (!callSlot("aboutToShowToolsMenu")) {

View File

@ -44,6 +44,14 @@ public:
inline QAction* menuBookmarksAction() { return m_menuBookmarksAction; }
inline void setMenuBookmarksAction(QAction* action) { m_menuBookmarksAction = action; }
public slots:
void aboutToShowFileMenu(QMenu* menu = 0);
void aboutToShowEditMenu(QMenu* menu = 0);
void aboutToShowViewMenu(QMenu* menu = 0);
void aboutToShowHistoryMenu(QMenu* menu = 0);
void aboutToShowBookmarksMenu(QMenu* menu = 0);
void aboutToShowToolsMenu(QMenu* menu = 0);
private:
void setEnabledSelectedMenuActions(QMenu* menu, const QList<int> indexList = QList<int>());
void setDisabledSelectedMenuActions(QMenu* menu, const QList<int> indexList = QList<int>());
@ -66,17 +74,11 @@ private slots:
void addTab();
void savePageScreen();
void aboutToShowFileMenu();
void aboutToHideFileMenu();
void aboutToShowHistoryMenu();
void aboutToHideHistoryMenu();
void aboutToShowClosedTabsMenu();
void aboutToShowBookmarksMenu();
void aboutToShowViewMenu();
void aboutToHideViewMenu();
void aboutToShowEditMenu();
void aboutToHideEditMenu();
void aboutToShowToolsMenu();
void aboutToHideToolsMenu();
void aboutToShowEncodingMenu();