1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 12:46:35 +01:00

[win] Don't check for default browser on startup.

Also cleanup in #ifdefs in RegisterQappAssociation
This commit is contained in:
nowrep 2013-01-29 20:34:14 +01:00
parent b415df3395
commit 95445738ef
6 changed files with 33 additions and 206 deletions

View File

@ -50,6 +50,7 @@
#include "useragentmanager.h"
#include "restoremanager.h"
#include "proxystyle.h"
#include "checkboxdialog.h"
#include "registerqappassociation.h"
#include "html5permissions/html5permissionsmanager.h"
@ -95,7 +96,9 @@ MainApplication::MainApplication(int &argc, char** argv)
, m_isRestoring(false)
, m_startingAfterCrash(false)
, m_databaseConnected(false)
#ifdef Q_OS_WIN
, m_registerQAppAssociation(0)
#endif
{
#if defined(QZ_WS_X11) && !defined(NO_SYSTEM_DATAPATH)
DATADIR = USE_DATADIR;
@ -836,22 +839,29 @@ void MainApplication::reloadUserStyleSheet()
bool MainApplication::checkDefaultWebBrowser()
{
#ifdef Q_OS_WIN
bool showAgain = true;
if (!associationManager()->isDefaultForAllCapabilities()) {
CheckMessageBox notDefaultDialog(&showAgain, getWindow());
notDefaultDialog.setWindowTitle(tr("Default Browser"));
notDefaultDialog.setMessage(tr("QupZilla is not currently your default browser. Would you like to make it your default browser?"));
notDefaultDialog.setPixmap(style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(32, 32));
notDefaultDialog.setShowAgainText(tr("Always perform this check when starting QupZilla."));
CheckBoxDialog dialog(QDialogButtonBox::Yes | QDialogButtonBox::No, this);
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.setWindowTitle(tr("Default Browser"));
dialog.setIcon(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning));
if (notDefaultDialog.exec() == QDialog::Accepted) {
if (dialog.exec() == QDialog::Accepted) {
associationManager()->registerAllAssociation();
}
showAgain = dialog.isChecked();
}
return showAgain;
#else
return false;
#endif
}
#ifdef Q_OS_WIN
RegisterQAppAssociation* MainApplication::associationManager()
{
if (!m_registerQAppAssociation) {
@ -867,6 +877,7 @@ RegisterQAppAssociation* MainApplication::associationManager()
}
return m_registerQAppAssociation;
}
#endif
QUrl MainApplication::userStyleSheet(const QString &filePath) const
{

View File

@ -111,7 +111,10 @@ public:
DatabaseWriter* dbWriter() { return m_dbWriter; }
UserAgentManager* uaManager() { return m_uaManager; }
RestoreManager* restoreManager() { return m_restoreManager; }
#ifdef Q_OS_WIN
RegisterQAppAssociation* associationManager();
#endif
#ifdef Q_OS_MAC
bool event(QEvent* e);
@ -182,7 +185,9 @@ private:
bool m_databaseConnected;
QList<PostLaunchAction> m_postLaunchActions;
#ifdef Q_OS_WIN
RegisterQAppAssociation* m_registerQAppAssociation;
#endif
};
#endif // MAINAPPLICATION_H

View File

@ -104,12 +104,12 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qz::NewTabPositionFlags)
#ifdef Q_OS_WIN
#define DEFAULT_CHECK_UPDATES true
#define DEFAULT_CHECK_DEFAULTBROWSER true
#else
#define DEFAULT_CHECK_UPDATES false
#define DEFAULT_CHECK_DEFAULTBROWSER false
#endif
#define DEFAULT_CHECK_DEFAULTBROWSER false
#ifdef Q_OS_WIN
#define DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG false
#else

View File

@ -468,8 +468,8 @@ void DownloadItem::updateDownload()
#ifdef DOWNMANAGER_DEBUG
qDebug() << __FUNCTION__ ;
#endif
// after caling stop() (from readyRead()) m_reply will be a dangling pointer,
// thus it should be checked after m_outputFile.isOpen()
// after caling stop() (from readyRead()) m_reply will be a dangling pointer,
// thus it should be checked after m_outputFile.isOpen()
if (ui->progressBar->maximum() == 0 && m_outputFile.isOpen() &&
((m_reply && m_reply->isFinished()) || (m_ftpDownloader && m_ftpDownloader->isFinished()))) {
downloadProgress(0, 0);

View File

@ -1,5 +1,5 @@
/* ============================================================
* Copyright (C) 2012 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
* Copyright (C) 2012-2013 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
* This file is part of QupZilla - WebKit based browser 2010-2012
* by David Rosca <nowrep@gmail.com>
*
@ -22,8 +22,6 @@
#ifdef Q_OS_WIN
#include "ShlObj.h"
#include <QMessageBox>
#endif
#include <QStringList>
#include <QSettings>
#include <QDir>
@ -80,28 +78,19 @@ void RegisterQAppAssociation::setAppInfo(const QString &appRegisteredName, const
bool RegisterQAppAssociation::isPerMachineRegisteration()
{
#ifdef Q_OS_WIN
return (_UserRootKey == "HKEY_LOCAL_MACHINE");
#else
return false;
#endif
}
void RegisterQAppAssociation::setPerMachineRegisteration(bool enable)
{
#ifdef Q_OS_WIN
if (enable) {
_UserRootKey = "HKEY_LOCAL_MACHINE";
}
else {
_UserRootKey = "HKEY_CURRENT_USER";
}
#else
Q_UNUSED(enable)
#endif
}
#ifdef Q_OS_WIN
bool RegisterQAppAssociation::registerAppCapabilities()
{
if (!isVistaOrNewer()) {
@ -157,11 +146,9 @@ bool RegisterQAppAssociation::isVistaOrNewer()
return (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA &&
QSysInfo::windowsVersion() <= QSysInfo::WV_NT_based);
}
#endif
void RegisterQAppAssociation::registerAssociation(const QString &assocName, AssociationType type)
{
#ifdef Q_OS_WIN
if (isVistaOrNewer()) { // Vista and newer
IApplicationAssociationRegistration* pAAR;
@ -239,19 +226,13 @@ void RegisterQAppAssociation::registerAssociation(const QString &assocName, Asso
}
regUserRoot.endGroup();
}
#else
Q_UNUSED(assocName)
Q_UNUSED(type)
#endif
}
void RegisterQAppAssociation::registerAllAssociation()
{
#ifdef Q_OS_WIN
if (isVistaOrNewer() && !registerAppCapabilities()) {
return;
}
#endif
QHash<QString, QString>::const_iterator i = _fileAssocHash.constBegin();
while (i != _fileAssocHash.constEnd()) {
@ -265,18 +246,15 @@ void RegisterQAppAssociation::registerAllAssociation()
++i;
}
#ifdef Q_OS_WIN
if (!isVistaOrNewer()) {
// On Windows Vista or newer for updating icons 'pAAR->SetAppAsDefault()'
// calls 'SHChangeNotify()'. Thus, we just need care about older Windows.
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSHNOWAIT, 0 , 0);
}
#endif
}
void RegisterQAppAssociation::createProgId(const QString &progId)
{
#ifdef Q_OS_WIN
QSettings regUserRoot(_UserRootKey, QSettings::NativeFormat);
regUserRoot.beginGroup("Software/Classes");
QPair<QString, QString> pair = _assocDescHash.value(progId);
@ -285,14 +263,10 @@ void RegisterQAppAssociation::createProgId(const QString &progId)
regUserRoot.setValue(progId + "/DefaultIcon/.", pair.second);
regUserRoot.setValue(progId + "/shell/open/command/.", QString("\"" + _appPath + "\" \"%1\""));
regUserRoot.endGroup();
#else
Q_UNUSED(progId)
#endif
}
bool RegisterQAppAssociation::isDefaultApp(const QString &assocName, AssociationType type)
{
#ifdef Q_OS_WIN
if (isVistaOrNewer()) {
QSettings regCurrentUserRoot("HKEY_CURRENT_USER", QSettings::NativeFormat);
switch (type) {
@ -351,10 +325,7 @@ bool RegisterQAppAssociation::isDefaultApp(const QString &assocName, Association
break;
}
}
#else
Q_UNUSED(assocName)
Q_UNUSED(type)
#endif
return false;
}
@ -376,124 +347,4 @@ bool RegisterQAppAssociation::isDefaultForAllCapabilities()
}
return result;
}
/***************************************/
/******** CheckMessageBox Class ********/
/***************************************/
CheckMessageBox::CheckMessageBox(bool* defaultShowAgainState, QWidget* parent, Qt::WindowFlags f)
: QDialog(parent, f | Qt::MSWindowsFixedSizeDialogHint),
_showAgainState(defaultShowAgainState)
{
setupUi();
if (defaultShowAgainState) {
showAgainCheckBox->setChecked(*defaultShowAgainState);
}
else {
showAgainCheckBox->hide();
disconnect(showAgainCheckBox, SIGNAL(toggled(bool)), this, SLOT(showAgainStateChanged(bool)));
}
}
CheckMessageBox::CheckMessageBox(const QString &msg, const QPixmap &pixmap,
const QString &str, bool* defaultShowAgainState,
QWidget* parent, Qt::WindowFlags f)
: QDialog(parent, f | Qt::MSWindowsFixedSizeDialogHint),
_showAgainState(defaultShowAgainState)
{
setupUi();
setMessage(msg);
setPixmap(pixmap);
if (defaultShowAgainState) {
setShowAgainText(str);
}
}
CheckMessageBox::~CheckMessageBox()
{
}
void CheckMessageBox::setMessage(const QString &msg)
{
messageLabel->setText(msg);
}
void CheckMessageBox::setShowAgainText(const QString &str)
{
showAgainCheckBox->setText(str);
}
void CheckMessageBox::setPixmap(const QPixmap &pixmap)
{
pixmapLabel->setPixmap(pixmap);
}
void CheckMessageBox::setupUi()
{
setObjectName(QString::fromUtf8("CheckMessageBox"));
gridLayout = new QGridLayout(this);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
horizontalLayout = new QHBoxLayout();
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
verticalLayout_2 = new QVBoxLayout();
verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
pixmapLabel = new QLabel(this);
pixmapLabel->setObjectName(QString::fromUtf8("pixmapLabel"));
verticalLayout_2->addWidget(pixmapLabel);
verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
verticalLayout_2->addItem(verticalSpacer);
horizontalLayout->addLayout(verticalLayout_2);
verticalLayout = new QVBoxLayout();
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
messageLabel = new QLabel(this);
messageLabel->setObjectName(QString::fromUtf8("messageLabel"));
messageLabel->setWordWrap(true);
verticalLayout->addWidget(messageLabel);
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
verticalLayout->addItem(horizontalSpacer);
showAgainCheckBox = new QCheckBox(this);
showAgainCheckBox->setObjectName(QString::fromUtf8("showAgainCheckBox"));
verticalLayout->addWidget(showAgainCheckBox);
horizontalLayout->addLayout(verticalLayout);
gridLayout->addLayout(horizontalLayout, 0, 0, 1, 1);
buttonBox = new QDialogButtonBox(this);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::No | QDialogButtonBox::Yes);
gridLayout->addWidget(buttonBox, 1, 0, 1, 1);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
if (_showAgainState) {
showAgainCheckBox->setChecked(*_showAgainState);
connect(showAgainCheckBox, SIGNAL(toggled(bool)), this, SLOT(showAgainStateChanged(bool)));
}
else {
showAgainCheckBox->hide();
}
}
void CheckMessageBox::showAgainStateChanged(bool checked)
{
if (_showAgainState) {
*_showAgainState = checked;
}
}
#endif

View File

@ -1,5 +1,5 @@
/* ============================================================
* Copyright (C) 2012 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
* Copyright (C) 2012-2013 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
* This file is part of QupZilla - WebKit based browser 2010-2012
* by David Rosca <nowrep@gmail.com>
*
@ -25,6 +25,8 @@
#include "qz_namespace.h"
#ifdef Q_OS_WIN
class QT_QUPZILLA_EXPORT RegisterQAppAssociation : public QObject
{
Q_OBJECT
@ -48,10 +50,8 @@ public:
bool isPerMachineRegisteration();
void setPerMachineRegisteration(bool enable);
#ifdef Q_OS_WIN
bool registerAppCapabilities();
bool isVistaOrNewer();
#endif
void registerAssociation(const QString &assocName, AssociationType type);
void createProgId(const QString &progId);
@ -65,52 +65,12 @@ private:
QString _appPath;
QString _appIcon;
QString _appDesc;
#ifdef Q_OS_WIN
QString _UserRootKey;
#endif
QHash<QString, QString> _fileAssocHash; // (extention, progId)
QHash<QString, QString> _urlAssocHash; // (protocol, progId)
QHash<QString, QPair<QString, QString> > _assocDescHash; // (progId, (desc, icon))
};
#endif
#include <QDialog>
#include <QLabel>
#include <QGridLayout>
#include <QCheckBox>
#include <QDialogButtonBox>
class QT_QUPZILLA_EXPORT CheckMessageBox : public QDialog
{
Q_OBJECT
public:
CheckMessageBox(bool* defaultShowAgainState = 0, QWidget* parent = 0, Qt::WindowFlags f = 0);
CheckMessageBox(const QString &msg, const QPixmap &pixmap,
const QString &str, bool* defaultShowAgainState,
QWidget* parent = 0, Qt::WindowFlags f = 0);
~CheckMessageBox();
void setMessage(const QString &msg);
void setShowAgainText(const QString &str);
void setPixmap(const QPixmap &pixmap);
private:
void setupUi();
bool* _showAgainState;
QGridLayout* gridLayout;
QHBoxLayout* horizontalLayout;
QVBoxLayout* verticalLayout_2;
QLabel* pixmapLabel;
QSpacerItem* verticalSpacer;
QVBoxLayout* verticalLayout;
QLabel* messageLabel;
QSpacerItem* horizontalSpacer;
QCheckBox* showAgainCheckBox;
QDialogButtonBox* buttonBox;
private slots:
void showAgainStateChanged(bool checked);
};
#endif // REGISTERQAPPASSOCIATION_H