Coding standards

This commit is contained in:
Brad Davis 2015-04-25 16:46:05 -07:00
parent 7c16fd05c1
commit 0afe8c0e32
7 changed files with 41 additions and 39 deletions

View file

@ -1,3 +1,13 @@
//
// HifiMenu.cpp
//
// Created by Bradley Austin Davis on 2015/04/21
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "HifiMenu.h"
#include <QtQml>

View file

@ -1,5 +1,5 @@
//
// MenuConstants.h
// HifiMenu.h
//
// Created by Bradley Austin Davis on 2015/04/21
// Copyright 2015 High Fidelity, Inc.
@ -9,8 +9,8 @@
//
#pragma once
#ifndef hifi_MenuContants_h
#define hifi_MenuConstants_h
#ifndef hifi_HifiMenu_h
#define hifi_HifiMenu_h
#include <QQuickItem>
#include <QHash>
@ -76,7 +76,7 @@ protected:
QSignalMapper _toggleMapper;
};
#endif // hifi_MenuConstants_h
#endif // hifi_HifiMenu_h

View file

@ -1,5 +1,4 @@
//
//
// MessageDialog.cpp
//
// Created by Bradley Austin Davis on 2015/04/14
@ -12,7 +11,7 @@
HIFI_QML_DEF(MessageDialog)
MessageDialog::MessageDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) {
MessageDialog::MessageDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) {
_buttons = StandardButtons(Ok | Cancel);
}
@ -39,21 +38,21 @@ void MessageDialog::setVisible(bool v) {
OffscreenQmlDialog::setVisible(v);
}
void MessageDialog::setText(const QString &arg) {
void MessageDialog::setText(const QString& arg) {
if (arg != _text) {
_text = arg;
emit textChanged();
}
}
void MessageDialog::setInformativeText(const QString &arg) {
void MessageDialog::setInformativeText(const QString& arg) {
if (arg != _informativeText) {
_informativeText = arg;
emit informativeTextChanged();
}
}
void MessageDialog::setDetailedText(const QString &arg) {
void MessageDialog::setDetailedText(const QString& arg) {
if (arg != _detailedText) {
_detailedText = arg;
emit detailedTextChanged();

View file

@ -47,7 +47,7 @@ public:
NRoles
};
MessageDialog(QQuickItem *parent = 0);
MessageDialog(QQuickItem* parent = 0);
virtual ~MessageDialog();
QString text() const;
@ -57,9 +57,9 @@ public:
public slots:
virtual void setVisible(bool v);
void setText(const QString &arg);
void setInformativeText(const QString &arg);
void setDetailedText(const QString &arg);
void setText(const QString& arg);
void setInformativeText(const QString& arg);
void setDetailedText(const QString& arg);
void setIcon(Icon icon);
void setStandardButtons(StandardButtons buttons);
void setResultCallback(OffscreenUi::ButtonCallback callback);
@ -98,7 +98,3 @@ private:
};
#endif // hifi_MessageDialog_h

View file

@ -24,9 +24,9 @@ QString OffscreenQmlDialog::title() const {
return _title;
}
void OffscreenQmlDialog::setTitle(const QString &arg) {
if (arg != _title) {
_title = arg;
void OffscreenQmlDialog::setTitle(const QString& title) {
if (title != _title) {
_title = title;
emit titleChanged();
}
}

View file

@ -59,7 +59,7 @@ protected:
public:
QString title() const;
void setTitle(const QString &arg);
void setTitle(const QString& title);
signals:
void accepted();

View file

@ -140,13 +140,6 @@ QQuickItem* OffscreenUi::getRootItem() {
return _rootItem;
}
//QQmlContext* OffscreenUi::qmlContext() {
// if (nullptr == _rootItem) {
// return _qmlComponent->creationContext();
// }
// return QQmlEngine::contextForObject(_rootItem);
//}
void OffscreenUi::setBaseUrl(const QUrl& baseUrl) {
_qmlEngine->setBaseUrl(baseUrl);
}
@ -188,7 +181,7 @@ QObject* OffscreenUi::finishQmlLoad(std::function<void(QQmlContext*, QObject*)>
return nullptr;
}
QQmlContext * newContext = new QQmlContext(_qmlEngine, qApp);
QQmlContext* newContext = new QQmlContext(_qmlEngine, qApp);
QObject* newObject = _qmlComponent->beginCreate(newContext);
if (_qmlComponent->isError()) {
QList<QQmlError> errorList = _qmlComponent->errors();
@ -294,9 +287,9 @@ QPointF OffscreenUi::mapWindowToUi(const QPointF& sourcePosition, QObject* sourc
//
// However, the problem may go away once we switch to the new menu system,
// so I think it's OK for the time being.
bool OffscreenUi::shouldSwallowShortcut(QEvent * event) {
bool OffscreenUi::shouldSwallowShortcut(QEvent* event) {
Q_ASSERT(event->type() == QEvent::ShortcutOverride);
QObject * focusObject = _quickWindow->focusObject();
QObject* focusObject = _quickWindow->focusObject();
if (focusObject != _quickWindow && focusObject != _rootItem) {
//qDebug() << "Swallowed shortcut " << static_cast<QKeyEvent*>(event)->key();
event->accept();
@ -319,7 +312,7 @@ bool OffscreenUi::eventFilter(QObject* originalDestination, QEvent* event) {
#ifdef DEBUG
// Don't intercept our own events, or we enter an infinite recursion
QObject * recurseTest = originalDestination;
QObject* recurseTest = originalDestination;
while (recurseTest) {
Q_ASSERT(recurseTest != _rootItem && recurseTest != _quickWindow);
recurseTest = recurseTest->parent();
@ -438,13 +431,13 @@ void OffscreenUi::messageBox(const QString& title, const QString& text,
ButtonCallback callback,
QMessageBox::Icon icon,
QMessageBox::StandardButtons buttons) {
MessageDialog * pDialog{ nullptr };
MessageDialog::show([&](QQmlContext*ctx, QObject*item) {
MessageDialog* pDialog{ nullptr };
MessageDialog::show([&](QQmlContext* ctx, QObject* item) {
pDialog = item->findChild<MessageDialog*>();
pDialog->setIcon((MessageDialog::Icon)icon);
pDialog->setTitle(title);
pDialog->setText(text);
pDialog->setStandardButtons(MessageDialog::StandardButtons((int)buttons));
pDialog->setStandardButtons(MessageDialog::StandardButtons(static_cast<int>(buttons)));
pDialog->setResultCallback(callback);
});
pDialog->setEnabled(true);
@ -453,25 +446,29 @@ void OffscreenUi::messageBox(const QString& title, const QString& text,
void OffscreenUi::information(const QString& title, const QString& text,
ButtonCallback callback,
QMessageBox::StandardButtons buttons) {
messageBox(title, text, callback, (QMessageBox::Icon)MessageDialog::Information, buttons);
messageBox(title, text, callback,
static_cast<QMessageBox::Icon>(MessageDialog::Information), buttons);
}
void OffscreenUi::question(const QString& title, const QString& text,
ButtonCallback callback,
QMessageBox::StandardButtons buttons) {
messageBox(title, text, callback, (QMessageBox::Icon)MessageDialog::Question, buttons);
messageBox(title, text, callback,
static_cast<QMessageBox::Icon>(MessageDialog::Question), buttons);
}
void OffscreenUi::warning(const QString& title, const QString& text,
ButtonCallback callback,
QMessageBox::StandardButtons buttons) {
messageBox(title, text, callback, (QMessageBox::Icon)MessageDialog::Warning, buttons);
messageBox(title, text, callback,
static_cast<QMessageBox::Icon>(MessageDialog::Warning), buttons);
}
void OffscreenUi::critical(const QString& title, const QString& text,
ButtonCallback callback,
QMessageBox::StandardButtons buttons) {
messageBox(title, text, callback, (QMessageBox::Icon)MessageDialog::Critical, buttons);
messageBox(title, text, callback,
static_cast<QMessageBox::Icon>(MessageDialog::Critical), buttons);
}