mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Fix code not compliant with coding standards
This commit is contained in:
parent
edcff0b67f
commit
e0ec0f681f
8 changed files with 88 additions and 92 deletions
|
@ -3335,8 +3335,7 @@ void Application::reloadAllScripts() {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::manageRunningScriptsWidgetVisibility(bool shown)
|
||||
{
|
||||
void Application::manageRunningScriptsWidgetVisibility(bool shown) {
|
||||
if (_runningScriptsWidgetWasVisible && shown) {
|
||||
_runningScriptsWidget->show();
|
||||
} else if (_runningScriptsWidgetWasVisible && !shown) {
|
||||
|
@ -3344,8 +3343,7 @@ void Application::manageRunningScriptsWidgetVisibility(bool shown)
|
|||
}
|
||||
}
|
||||
|
||||
void Application::toggleRunningScriptsWidget()
|
||||
{
|
||||
void Application::toggleRunningScriptsWidget() {
|
||||
qDebug() << "RS";
|
||||
if (_runningScriptsWidgetWasVisible) {
|
||||
_runningScriptsWidget->hide();
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
//
|
||||
// Created by Mohammed Nafees on 04/06/2014.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
|
@ -14,56 +18,50 @@
|
|||
#include <QHideEvent>
|
||||
#include <QWindowStateChangeEvent>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent)
|
||||
{
|
||||
MainWindow::MainWindow(QWidget* parent) :
|
||||
QMainWindow(parent) {
|
||||
}
|
||||
|
||||
void MainWindow::moveEvent(QMoveEvent *e)
|
||||
{
|
||||
emit windowGeometryChanged(QRect(e->pos(), size()));
|
||||
QMainWindow::moveEvent(e);
|
||||
void MainWindow::moveEvent(QMoveEvent* event) {
|
||||
emit windowGeometryChanged(QRect(event->pos(), size()));
|
||||
QMainWindow::moveEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
emit windowGeometryChanged(QRect(QPoint(x(), y()), e->size()));
|
||||
QMainWindow::resizeEvent(e);
|
||||
void MainWindow::resizeEvent(QResizeEvent* event) {
|
||||
emit windowGeometryChanged(QRect(QPoint(x(), y()), event->size()));
|
||||
QMainWindow::resizeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::showEvent(QShowEvent *e)
|
||||
{
|
||||
if (e->spontaneous()) {
|
||||
void MainWindow::showEvent(QShowEvent* event) {
|
||||
if (event->spontaneous()) {
|
||||
emit windowShown(true);
|
||||
}
|
||||
QMainWindow::showEvent(e);
|
||||
QMainWindow::showEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::hideEvent(QHideEvent *e)
|
||||
{
|
||||
if (e->spontaneous()) {
|
||||
void MainWindow::hideEvent(QHideEvent* event) {
|
||||
if (event->spontaneous()) {
|
||||
emit windowShown(false);
|
||||
}
|
||||
QMainWindow::hideEvent(e);
|
||||
QMainWindow::hideEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::WindowStateChange) {
|
||||
QWindowStateChangeEvent *event = static_cast<QWindowStateChangeEvent*>(e);
|
||||
if ((event->oldState() == Qt::WindowNoState ||
|
||||
event->oldState() == Qt::WindowMaximized) &&
|
||||
void MainWindow::changeEvent(QEvent* event) {
|
||||
if (event->type() == QEvent::WindowStateChange) {
|
||||
QWindowStateChangeEvent* stateChangeEvent = static_cast<QWindowStateChangeEvent*>(event);
|
||||
if ((stateChangeEvent->oldState() == Qt::WindowNoState ||
|
||||
stateChangeEvent->oldState() == Qt::WindowMaximized) &&
|
||||
windowState() == Qt::WindowMinimized) {
|
||||
emit windowShown(false);
|
||||
} else {
|
||||
emit windowShown(true);
|
||||
}
|
||||
} else if (e->type() == QEvent::ActivationChange) {
|
||||
} else if (event->type() == QEvent::ActivationChange) {
|
||||
if (isActiveWindow()) {
|
||||
emit windowShown(true);
|
||||
} else {
|
||||
emit windowShown(false);
|
||||
}
|
||||
}
|
||||
QMainWindow::changeEvent(e);
|
||||
QMainWindow::changeEvent(event);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
//
|
||||
// Created by Mohammed Nafees on 04/06/2014.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef __hifi__MainWindow__
|
||||
#define __hifi__MainWindow__
|
||||
|
@ -14,18 +18,18 @@ class MainWindow : public QMainWindow
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
explicit MainWindow(QWidget* parent = NULL);
|
||||
|
||||
signals:
|
||||
void windowGeometryChanged(QRect geometry);
|
||||
void windowShown(bool shown);
|
||||
|
||||
protected:
|
||||
virtual void moveEvent(QMoveEvent *e);
|
||||
virtual void resizeEvent(QResizeEvent *e);
|
||||
virtual void showEvent(QShowEvent *e);
|
||||
virtual void hideEvent(QHideEvent *e);
|
||||
virtual void changeEvent(QEvent *e);
|
||||
virtual void moveEvent(QMoveEvent* event);
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
virtual void showEvent(QShowEvent* event);
|
||||
virtual void hideEvent(QHideEvent* event);
|
||||
virtual void changeEvent(QEvent* event);
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__MainWindow__) */
|
||||
|
|
|
@ -23,10 +23,10 @@ public:
|
|||
|
||||
FramelessDialog(QWidget* parent, Qt::WindowFlags flags = 0, Position position = POSITION_LEFT);
|
||||
void setStyleSheetFile(const QString& fileName);
|
||||
void setAllowResize(bool allowResize) { _allowResize = allowResize; };
|
||||
bool getAllowResize() { return _allowResize; };
|
||||
void setHideOnBlur(bool hideOnBlur) { _hideOnBlur = hideOnBlur; };
|
||||
bool getHideOnBlur() { return _hideOnBlur; };
|
||||
void setAllowResize(bool allowResize) { _allowResize = allowResize; }
|
||||
bool getAllowResize() { return _allowResize; }
|
||||
void setHideOnBlur(bool hideOnBlur) { _hideOnBlur = hideOnBlur; }
|
||||
bool getHideOnBlur() { return _hideOnBlur; }
|
||||
void resizeAndPosition(bool resizeParent = true);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -12,17 +12,16 @@
|
|||
#include "ui_runningScriptsWidget.h"
|
||||
#include "RunningScriptsWidget.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QFileInfo>
|
||||
#include <QKeyEvent>
|
||||
#include <QPainter>
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
RunningScriptsWidget::RunningScriptsWidget(QWidget *parent) :
|
||||
RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
|
||||
FramelessDialog(parent, 0, POSITION_LEFT),
|
||||
ui(new Ui::RunningScriptsWidget)
|
||||
{
|
||||
ui(new Ui::RunningScriptsWidget) {
|
||||
ui->setupUi(this);
|
||||
|
||||
setAllowResize(false);
|
||||
|
@ -54,18 +53,15 @@ RunningScriptsWidget::RunningScriptsWidget(QWidget *parent) :
|
|||
Application::getInstance(), &Application::loadDialog);
|
||||
}
|
||||
|
||||
RunningScriptsWidget::~RunningScriptsWidget()
|
||||
{
|
||||
RunningScriptsWidget::~RunningScriptsWidget() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void RunningScriptsWidget::setBoundary(const QRect &rect)
|
||||
{
|
||||
void RunningScriptsWidget::setBoundary(const QRect& rect) {
|
||||
_boundary = rect;
|
||||
}
|
||||
|
||||
void RunningScriptsWidget::setRunningScripts(const QStringList& list)
|
||||
{
|
||||
void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
|
||||
_runningScriptsTable->setRowCount(list.size());
|
||||
|
||||
ui->noRunningScriptsLabel->setVisible(list.isEmpty());
|
||||
|
@ -104,10 +100,10 @@ void RunningScriptsWidget::setRunningScripts(const QStringList& list)
|
|||
createRecentlyLoadedScriptsTable();
|
||||
}
|
||||
|
||||
void RunningScriptsWidget::keyPressEvent(QKeyEvent *e)
|
||||
void RunningScriptsWidget::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
int loadScriptNumber = -1;
|
||||
switch(e->key()) {
|
||||
switch(event->key()) {
|
||||
case Qt::Key_Escape:
|
||||
Application::getInstance()->toggleRunningScriptsWidget();
|
||||
break;
|
||||
|
@ -156,11 +152,10 @@ void RunningScriptsWidget::keyPressEvent(QKeyEvent *e)
|
|||
}
|
||||
}
|
||||
|
||||
FramelessDialog::keyPressEvent(e);
|
||||
FramelessDialog::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void RunningScriptsWidget::paintEvent(QPaintEvent *)
|
||||
{
|
||||
void RunningScriptsWidget::paintEvent(QPaintEvent* event) {
|
||||
QPainter painter(this);
|
||||
painter.setPen(QColor::fromRgb(225, 225, 225)); // #e1e1e1
|
||||
|
||||
|
@ -179,21 +174,18 @@ void RunningScriptsWidget::paintEvent(QPaintEvent *)
|
|||
painter.end();
|
||||
}
|
||||
|
||||
void RunningScriptsWidget::stopScript(int row, int column)
|
||||
{
|
||||
void RunningScriptsWidget::stopScript(int row, int column) {
|
||||
if (column == 1) { // make sure the user has clicked on the close icon
|
||||
_lastStoppedScript = _runningScriptsTable->item(row, 0)->toolTip();
|
||||
emit stopScriptName(_runningScriptsTable->item(row, 0)->toolTip());
|
||||
}
|
||||
}
|
||||
|
||||
void RunningScriptsWidget::loadScript(int row, int column)
|
||||
{
|
||||
void RunningScriptsWidget::loadScript(int row, int column) {
|
||||
Application::getInstance()->loadScript(_recentlyLoadedScriptsTable->item(row, column)->toolTip());
|
||||
}
|
||||
|
||||
void RunningScriptsWidget::allScriptsStopped()
|
||||
{
|
||||
void RunningScriptsWidget::allScriptsStopped() {
|
||||
QStringList list = Application::getInstance()->getRunningScripts();
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
_recentlyLoadedScripts.prepend(list.at(i));
|
||||
|
@ -202,8 +194,7 @@ void RunningScriptsWidget::allScriptsStopped()
|
|||
Application::getInstance()->stopAllScripts();
|
||||
}
|
||||
|
||||
void RunningScriptsWidget::createRecentlyLoadedScriptsTable()
|
||||
{
|
||||
void RunningScriptsWidget::createRecentlyLoadedScriptsTable() {
|
||||
if (!_recentlyLoadedScripts.contains(_lastStoppedScript) && !_lastStoppedScript.isEmpty()) {
|
||||
_recentlyLoadedScripts.prepend(_lastStoppedScript);
|
||||
_lastStoppedScript = "";
|
||||
|
@ -221,9 +212,9 @@ void RunningScriptsWidget::createRecentlyLoadedScriptsTable()
|
|||
|
||||
int limit = _recentlyLoadedScripts.size() > 9 ? 9 : _recentlyLoadedScripts.size();
|
||||
_recentlyLoadedScriptsTable->setRowCount(limit);
|
||||
for (int i = 0; i < limit; ++i) {
|
||||
for (int i = 0; i < limit; i++) {
|
||||
QTableWidgetItem *scriptName = new QTableWidgetItem;
|
||||
scriptName->setText(QString::number(i+1) + ". " +QFileInfo(_recentlyLoadedScripts.at(i)).fileName());
|
||||
scriptName->setText(QString::number(i + 1) + ". " + QFileInfo(_recentlyLoadedScripts.at(i)).fileName());
|
||||
scriptName->setToolTip(_recentlyLoadedScripts.at(i));
|
||||
scriptName->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class RunningScriptsWidget : public FramelessDialog
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RunningScriptsWidget(QWidget *parent = 0);
|
||||
explicit RunningScriptsWidget(QWidget* parent = NULL);
|
||||
~RunningScriptsWidget();
|
||||
|
||||
void setRunningScripts(const QStringList& list);
|
||||
|
@ -32,8 +32,8 @@ signals:
|
|||
void stopScriptName(const QString& name);
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *e);
|
||||
virtual void paintEvent(QPaintEvent *);
|
||||
virtual void keyPressEvent(QKeyEvent* event);
|
||||
virtual void paintEvent(QPaintEvent* event);
|
||||
|
||||
public slots:
|
||||
void setBoundary(const QRect& rect);
|
||||
|
@ -44,9 +44,9 @@ private slots:
|
|||
void allScriptsStopped();
|
||||
|
||||
private:
|
||||
Ui::RunningScriptsWidget *ui;
|
||||
ScriptsTableWidget *_runningScriptsTable;
|
||||
ScriptsTableWidget *_recentlyLoadedScriptsTable;
|
||||
Ui::RunningScriptsWidget* ui;
|
||||
ScriptsTableWidget* _runningScriptsTable;
|
||||
ScriptsTableWidget* _recentlyLoadedScriptsTable;
|
||||
QStringList _recentlyLoadedScripts;
|
||||
QString _lastStoppedScript;
|
||||
QRect _boundary;
|
||||
|
|
|
@ -4,17 +4,20 @@
|
|||
//
|
||||
// Created by Mohammed Nafees on 04/03/2014.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QDebug>
|
||||
#include <QHeaderView>
|
||||
#include <QKeyEvent>
|
||||
#include <QPainter>
|
||||
|
||||
#include "ScriptsTableWidget.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
#include <QKeyEvent>
|
||||
|
||||
ScriptsTableWidget::ScriptsTableWidget(QWidget *parent) :
|
||||
QTableWidget(parent)
|
||||
{
|
||||
ScriptsTableWidget::ScriptsTableWidget(QWidget* parent) :
|
||||
QTableWidget(parent) {
|
||||
verticalHeader()->setVisible(false);
|
||||
horizontalHeader()->setVisible(false);
|
||||
setShowGrid(false);
|
||||
|
@ -26,13 +29,12 @@ ScriptsTableWidget::ScriptsTableWidget(QWidget *parent) :
|
|||
setGeometry(0, 0, parent->width(), parent->height());
|
||||
}
|
||||
|
||||
void ScriptsTableWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
void ScriptsTableWidget::paintEvent(QPaintEvent* event) {
|
||||
QPainter painter(viewport());
|
||||
painter.setPen(QColor::fromRgb(225, 225, 225)); // #e1e1e1
|
||||
|
||||
int y = 0;
|
||||
for (int i = 0; i < rowCount(); ++i) {
|
||||
for (int i = 0; i < rowCount(); i++) {
|
||||
painter.drawLine(5, rowHeight(i) + y, width(), rowHeight(i) + y);
|
||||
y += rowHeight(i);
|
||||
}
|
||||
|
@ -41,7 +43,7 @@ void ScriptsTableWidget::paintEvent(QPaintEvent *event)
|
|||
QTableWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
void ScriptsTableWidget::keyPressEvent(QKeyEvent *event) {
|
||||
void ScriptsTableWidget::keyPressEvent(QKeyEvent* event) {
|
||||
// Ignore keys so they will propagate correctly
|
||||
event->ignore();
|
||||
}
|
||||
|
|
|
@ -4,22 +4,25 @@
|
|||
//
|
||||
// Created by Mohammed Nafees on 04/03/2014.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef __hifi__ScriptsTableWidget__
|
||||
#define __hifi__ScriptsTableWidget__
|
||||
#ifndef hifi__ScriptsTableWidget_h
|
||||
#define hifi__ScriptsTableWidget_h
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTableWidget>
|
||||
|
||||
class ScriptsTableWidget : public QTableWidget
|
||||
{
|
||||
class ScriptsTableWidget : public QTableWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ScriptsTableWidget(QWidget *parent);
|
||||
explicit ScriptsTableWidget(QWidget* parent);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
virtual void keyPressEvent(QKeyEvent *event);
|
||||
virtual void paintEvent(QPaintEvent* event);
|
||||
virtual void keyPressEvent(QKeyEvent* event);
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__ScriptsTableWidget__) */
|
||||
#endif // hifi__ScriptsTableWidget_h
|
||||
|
|
Loading…
Reference in a new issue