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

Coding style

This commit is contained in:
nowrep 2012-12-01 11:16:49 +01:00
parent 82faa94de3
commit 60792f3762
4 changed files with 45 additions and 51 deletions

View File

@ -50,6 +50,7 @@
#include "useragentmanager.h"
#include "restoremanager.h"
#include "proxystyle.h"
#include "registerqappassociation.h"
#ifdef Q_OS_MAC
#include <QFileOpenEvent>
@ -823,7 +824,7 @@ bool MainApplication::checkDefaultWebBrowser()
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.setPixmap(style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(32, 32));
notDefaultDialog.setShowAgainText(tr("Always perform this check when starting QupZilla."));
if (notDefaultDialog.exec() == QDialog::Accepted) {

View File

@ -24,7 +24,6 @@
#include <QUrl>
#include <QWeakPointer>
#include "registerqappassociation.h"
#include "restoremanager.h"
#include "qtsingleapplication.h"
#include "qz_namespace.h"
@ -50,6 +49,7 @@ class SearchEnginesManager;
class DatabaseWriter;
class UserAgentManager;
class ProxyStyle;
class RegisterQAppAssociation;
class QT_QUPZILLA_EXPORT MainApplication : public QtSingleApplication
{

View File

@ -28,14 +28,14 @@
#include <QSettings>
#include <QDir>
RegisterQAppAssociation::RegisterQAppAssociation(QObject *parent) :
RegisterQAppAssociation::RegisterQAppAssociation(QObject* parent) :
QObject(parent)
{
setPerMachineRegisteration(false);
}
RegisterQAppAssociation::RegisterQAppAssociation(const QString &appRegisteredName, const QString &appPath, const QString &appIcon,
const QString &appDesc, QObject *parent)
const QString &appDesc, QObject* parent)
: QObject(parent)
{
setPerMachineRegisteration(false);
@ -47,12 +47,12 @@ RegisterQAppAssociation::~RegisterQAppAssociation()
}
void RegisterQAppAssociation::addCapability(const QString &assocName, const QString &progId,
const QString &desc, const QString &iconPath, AssociationType type)
const QString &desc, const QString &iconPath, AssociationType type)
{
_assocDescHash.insert(progId, QPair<QString, QString>(desc, QDir::toNativeSeparators(iconPath)));
switch (type) {
case FileAssociation:
_fileAssocHash.insert(assocName, progId);
_fileAssocHash.insert(assocName, progId);
break;
case UrlAssociation:
_urlAssocHash.insert(assocName, progId);
@ -70,7 +70,7 @@ void RegisterQAppAssociation::removeCapability(const QString &assocName)
}
void RegisterQAppAssociation::setAppInfo(const QString &appRegisteredName, const QString &appPath,
const QString &appIcon, const QString &appDesc)
const QString &appIcon, const QString &appDesc)
{
_appRegisteredName = appRegisteredName;
_appPath = QDir::toNativeSeparators(appPath);
@ -177,12 +177,11 @@ void RegisterQAppAssociation::registerAssociation(const QString &assocName, Asso
assocName.toStdWString().c_str(),
AT_FILEEXTENSION);
break;
case UrlAssociation:
{
case UrlAssociation: {
QSettings regCurrentUserRoot("HKEY_CURRENT_USER", QSettings::NativeFormat);
QString currentUrlDefault =
regCurrentUserRoot.value("Software/Microsoft/Windows/Shell/Associations/UrlAssociations/"
+ assocName + "/UserChoice/Progid").toString();
regCurrentUserRoot.value("Software/Microsoft/Windows/Shell/Associations/UrlAssociations/"
+ assocName + "/UserChoice/Progid").toString();
hr = pAAR->SetAppAsDefault(_appRegisteredName.toStdWString().c_str(),
assocName.toStdWString().c_str(),
AT_URLPROTOCOL);
@ -194,7 +193,7 @@ void RegisterQAppAssociation::registerAssociation(const QString &assocName, Asso
+ "/shell/open/command/backup_progid", currentUrlDefault);
}
}
break;
break;
default:
break;
@ -208,8 +207,7 @@ void RegisterQAppAssociation::registerAssociation(const QString &assocName, Asso
regUserRoot.beginGroup("Software/Classes");
QSettings regClassesRoot("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
switch (type) {
case FileAssociation:
{
case FileAssociation: {
QString progId = _fileAssocHash.value(assocName);
createProgId(progId);
QString currentDefault = regClassesRoot.value(assocName + "/Default").toString();
@ -220,13 +218,12 @@ void RegisterQAppAssociation::registerAssociation(const QString &assocName, Asso
}
regUserRoot.setValue(assocName + "/.", progId);
}
break;
case UrlAssociation:
{
break;
case UrlAssociation: {
QString progId = _urlAssocHash.value(assocName);
createProgId(progId);
QString currentDefault = regClassesRoot.value(assocName + "/shell/open/command/Default").toString();
QString command = "\""+_appPath+"\" \"%1\"";
QString command = "\"" + _appPath + "\" \"%1\"";
if (!currentDefault.isEmpty()
&& currentDefault != command
&& regUserRoot.value(assocName + "/shell/open/command/backup_val").toString() != command) {
@ -272,7 +269,7 @@ void RegisterQAppAssociation::registerAllAssociation()
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);
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSHNOWAIT, 0 , 0);
}
#endif
}
@ -286,7 +283,7 @@ void RegisterQAppAssociation::createProgId(const QString &progId)
regUserRoot.setValue(progId + "/.", pair.first);
regUserRoot.setValue(progId + "/shell/.", "open");
regUserRoot.setValue(progId + "/DefaultIcon/.", pair.second);
regUserRoot.setValue(progId + "/shell/open/command/.", QString("\""+_appPath+"\" \"%1\""));
regUserRoot.setValue(progId + "/shell/open/command/.", QString("\"" + _appPath + "\" \"%1\""));
regUserRoot.endGroup();
#else
Q_UNUSED(progId)
@ -299,8 +296,7 @@ bool RegisterQAppAssociation::isDefaultApp(const QString &assocName, Association
if (isVistaOrNewer()) {
QSettings regCurrentUserRoot("HKEY_CURRENT_USER", QSettings::NativeFormat);
switch (type) {
case FileAssociation:
{
case FileAssociation: {
regCurrentUserRoot.beginGroup("Software/Microsoft/Windows/CurrentVersion/Explorer/FileExts");
if (regCurrentUserRoot.childGroups().contains(assocName, Qt::CaseInsensitive)) {
return (_fileAssocHash.value(assocName)
@ -312,8 +308,7 @@ bool RegisterQAppAssociation::isDefaultApp(const QString &assocName, Association
}
break;
}
case UrlAssociation:
{
case UrlAssociation: {
regCurrentUserRoot.beginGroup("Software/Microsoft/Windows/Shell/Associations/UrlAssociations");
if (regCurrentUserRoot.childGroups().contains(assocName, Qt::CaseInsensitive)) {
return (_urlAssocHash.value(assocName)
@ -324,7 +319,7 @@ bool RegisterQAppAssociation::isDefaultApp(const QString &assocName, Association
return false;
}
}
break;
break;
default:
break;
@ -338,21 +333,19 @@ bool RegisterQAppAssociation::isDefaultApp(const QString &assocName, Association
}
}
switch (type) {
case FileAssociation:
{
case FileAssociation: {
return (_fileAssocHash.value(assocName)
== regClassesRoot.value(assocName + "/Default"));
}
break;
case UrlAssociation:
{
break;
case UrlAssociation: {
QString currentDefault = regClassesRoot.value(assocName + "/shell/open/command/Default").toString();
currentDefault.remove("\"");
currentDefault.remove("%1");
currentDefault = currentDefault.trimmed();
return (_appPath == currentDefault);
}
break;
break;
default:
break;
@ -388,9 +381,9 @@ bool RegisterQAppAssociation::isDefaultForAllCapabilities()
/******** CheckMessageBox Class ********/
/***************************************/
CheckMessageBox::CheckMessageBox(bool *defaultShowAgainState, QWidget *parent, Qt::WindowFlags f)
CheckMessageBox::CheckMessageBox(bool* defaultShowAgainState, QWidget* parent, Qt::WindowFlags f)
: QDialog(parent, f | Qt::MSWindowsFixedSizeDialogHint),
_showAgainState(defaultShowAgainState)
_showAgainState(defaultShowAgainState)
{
setupUi();
if (defaultShowAgainState) {
@ -403,8 +396,8 @@ CheckMessageBox::CheckMessageBox(bool *defaultShowAgainState, QWidget *parent, Q
}
CheckMessageBox::CheckMessageBox(const QString &msg, const QPixmap &pixmap,
const QString &str, bool *defaultShowAgainState,
QWidget *parent, Qt::WindowFlags f)
const QString &str, bool* defaultShowAgainState,
QWidget* parent, Qt::WindowFlags f)
: QDialog(parent, f | Qt::MSWindowsFixedSizeDialogHint),
_showAgainState(defaultShowAgainState)
{
@ -482,7 +475,7 @@ void CheckMessageBox::setupUi()
buttonBox = new QDialogButtonBox(this);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::No|QDialogButtonBox::Yes);
buttonBox->setStandardButtons(QDialogButtonBox::No | QDialogButtonBox::Yes);
gridLayout->addWidget(buttonBox, 1, 0, 1, 1);

View File

@ -30,7 +30,7 @@ class QT_QUPZILLA_EXPORT RegisterQAppAssociation : public QObject
public:
explicit RegisterQAppAssociation(QObject* parent = 0);
explicit RegisterQAppAssociation(const QString &appRegisteredName, const QString &appPath,
const QString &appIcon = "", const QString &appDesc = "", QObject* parent = 0);
const QString &appIcon = "", const QString &appDesc = "", QObject* parent = 0);
~RegisterQAppAssociation();
enum AssociationType {
@ -84,10 +84,10 @@ class QT_QUPZILLA_EXPORT CheckMessageBox : public QDialog
Q_OBJECT
public:
CheckMessageBox(bool *defaultShowAgainState = 0, QWidget *parent = 0, Qt::WindowFlags f = 0);
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);
const QString &str, bool* defaultShowAgainState,
QWidget* parent = 0, Qt::WindowFlags f = 0);
~CheckMessageBox();
void setMessage(const QString &msg);
@ -97,17 +97,17 @@ public:
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;
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);