Merge pull request #3341 from huffman/19967

Code Review for Job #19967
This commit is contained in:
AndrewMeadows 2014-09-03 16:51:19 -07:00
commit 8223481ecb
6 changed files with 268 additions and 406 deletions

View file

@ -3856,14 +3856,17 @@ void Application::manageRunningScriptsWidgetVisibility(bool shown) {
}
void Application::toggleRunningScriptsWidget() {
if (_runningScriptsWidgetWasVisible) {
_runningScriptsWidget->hide();
_runningScriptsWidgetWasVisible = false;
if (_runningScriptsWidget->isVisible()) {
if (_runningScriptsWidget->hasFocus()) {
_runningScriptsWidget->hide();
} else {
_runningScriptsWidget->raise();
setActiveWindow(_runningScriptsWidget);
_runningScriptsWidget->setFocus();
}
} else {
_runningScriptsWidget->setBoundary(QRect(_window->geometry().topLeft(),
_window->size()));
_runningScriptsWidget->show();
_runningScriptsWidgetWasVisible = true;
_runningScriptsWidget->setFocus();
}
}

View file

@ -22,9 +22,11 @@
#include "Application.h"
#include "Menu.h"
#include "ScriptsModel.h"
#include "UIUtil.h"
RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
FramelessDialog(parent, 0, POSITION_LEFT),
QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
Qt::WindowCloseButtonHint),
ui(new Ui::RunningScriptsWidget),
_signalMapper(this),
_proxyModel(this),
@ -33,15 +35,6 @@ RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
setAttribute(Qt::WA_DeleteOnClose, false);
setAllowResize(false);
ui->hideWidgetButton->setIcon(QIcon(Application::resourcesPath() + "images/close.svg"));
ui->reloadAllButton->setIcon(QIcon(Application::resourcesPath() + "images/reload.svg"));
ui->stopAllButton->setIcon(QIcon(Application::resourcesPath() + "images/stop.svg"));
ui->loadScriptButton->setIcon(QIcon(Application::resourcesPath() + "images/plus-white.svg"));
ui->recentlyLoadedScriptsArea->hide();
ui->filterLineEdit->installEventFilter(this);
connect(&_proxyModel, &QSortFilterProxyModel::modelReset,
@ -55,12 +48,6 @@ RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
connect(ui->filterLineEdit, &QLineEdit::textChanged, this, &RunningScriptsWidget::updateFileFilter);
connect(ui->scriptListView, &QListView::doubleClicked, this, &RunningScriptsWidget::loadScriptFromList);
_recentlyLoadedScriptsTable = new ScriptsTableWidget(ui->recentlyLoadedScriptsTableWidget);
_recentlyLoadedScriptsTable->setColumnCount(1);
_recentlyLoadedScriptsTable->setColumnWidth(0, 265);
connect(ui->hideWidgetButton, &QPushButton::clicked,
Application::getInstance(), &Application::toggleRunningScriptsWidget);
connect(ui->reloadAllButton, &QPushButton::clicked,
Application::getInstance(), &Application::reloadAllScripts);
connect(ui->stopAllButton, &QPushButton::clicked,
@ -163,7 +150,15 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) {
ui->filterLineEdit->setFocus();
}
FramelessDialog::showEvent(event);
const QRect parentGeometry = parentWidget()->geometry();
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
int menuBarHeight = Menu::getInstance()->geometry().height();
int topMargin = titleBarHeight + menuBarHeight;
setGeometry(parentGeometry.topLeft().x(), parentGeometry.topLeft().y() + topMargin,
size().width(), parentWidget()->height() - topMargin);
QWidget::showEvent(event);
}
void RunningScriptsWidget::selectFirstInList() {
@ -189,19 +184,18 @@ bool RunningScriptsWidget::eventFilter(QObject* sender, QEvent* event) {
return false;
}
return FramelessDialog::eventFilter(sender, event);
return QWidget::eventFilter(sender, event);
}
void RunningScriptsWidget::keyPressEvent(QKeyEvent *keyEvent) {
if (keyEvent->key() == Qt::Key_Escape) {
return;
} else {
FramelessDialog::keyPressEvent(keyEvent);
QWidget::keyPressEvent(keyEvent);
}
}
void RunningScriptsWidget::scriptStopped(const QString& scriptName) {
// _recentlyLoadedScripts.prepend(scriptName);
}
void RunningScriptsWidget::allScriptsStopped() {

View file

@ -25,8 +25,7 @@ namespace Ui {
class RunningScriptsWidget;
}
class RunningScriptsWidget : public FramelessDialog
{
class RunningScriptsWidget : public QWidget {
Q_OBJECT
public:
explicit RunningScriptsWidget(QWidget* parent = NULL);

View file

@ -7,29 +7,24 @@
<x>0</x>
<y>0</y>
<width>324</width>
<height>971</height>
<height>643</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string>Running Scripts</string>
</property>
<property name="styleSheet">
<string notr="true">* {
font-family: Helvetica, Arial, sans-serif;
}
QWidget {
background: #f7f7f7;
}</string>
<string notr="true">* { font-family: Helvetica, Arial, sans-serif; }</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>20</number>
<number>14</number>
</property>
<property name="topMargin">
<number>20</number>
</property>
<property name="rightMargin">
<number>20</number>
<number>14</number>
</property>
<property name="bottomMargin">
<number>20</number>
@ -38,23 +33,22 @@ QWidget {
<widget class="QWidget" name="header" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
<number>6</number>
</property>
<item>
<widget class="QLabel" name="widgetTitle">
<property name="styleSheet">
<string notr="true">color: #0e7077;
font-size: 20px;
background: transparent;</string>
font-size: 20px;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:18px;&quot;&gt;Running Scripts&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Running Scripts</string>
</property>
<property name="margin">
<number>0</number>
@ -77,28 +71,6 @@ background: transparent;</string>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="hideWidgetButton">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">border: 0</string>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -133,24 +105,45 @@ background: transparent;</string>
<number>0</number>
</property>
<item>
<widget class="QLabel" name="currentlyRunningLabel">
<property name="font">
<font>
<family>Helvetica,Arial,sans-serif</family>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: #0e7077;
<widget class="QWidget" name="widget_3" native="true">
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="currentlyRunningLabel">
<property name="font">
<font>
<family>Helvetica,Arial,sans-serif</family>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: #0e7077;
font: bold 16px;
background: transparent;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Currently running&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</string>
</property>
<property name="text">
<string>Currently Running</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
@ -177,49 +170,24 @@ background: transparent;</string>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">reloadStopButtonArea { padding: 0 }</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>24</number>
</property>
<property name="leftMargin">
<number>0</number>
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="reloadAllButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>111</width>
<height>35</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background: #0e7077;
color: #fff;
border-radius: 4px;
font: bold 14px;
padding-top: 3px;</string>
</property>
<property name="text">
<string>Reload all</string>
</property>
@ -227,28 +195,6 @@ padding-top: 3px;</string>
</item>
<item>
<widget class="QPushButton" name="stopAllButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>111</width>
<height>35</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">background: #0e7077;
color: #fff;
border-radius: 4px;
font: bold 14px;
padding-top: 3px;</string>
</property>
<property name="text">
<string>Stop all</string>
</property>
@ -261,8 +207,8 @@ padding-top: 3px;</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
@ -271,192 +217,104 @@ padding-top: 3px;</string>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="noRunningScriptsLabel">
<property name="styleSheet">
<string notr="true">font: 14px;</string>
</property>
<property name="text">
<string>There are no scripts currently running.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QScrollArea" name="runningScriptsList">
<property name="font">
<font>
<family>Helvetica,Arial,sans-serif</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>284</width>
<height>16</height>
</rect>
<widget class="QWidget" name="widget_4" native="true">
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="spacing">
<number>0</number>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="leftMargin">
<number>6</number>
</property>
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
<property name="topMargin">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="recentlyLoadedScriptsArea" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="recentlyLoadedLabel">
<property name="styleSheet">
<string notr="true">color: #0e7077;
font: bold 16px;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Recently loaded&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="noRecentlyLoadedLabel">
<property name="styleSheet">
<string notr="true">font: 14px;</string>
</property>
<property name="text">
<string>There are no recently loaded scripts.</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="recentlyLoadedScriptsTableWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>284</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background: transparent;
font-size: 14px;</string>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="runningScriptsList">
<property name="font">
<font>
<family>Helvetica,Arial,sans-serif</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>284</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="noRunningScriptsLabel">
<property name="styleSheet">
<string notr="true">font: 14px;</string>
</property>
<property name="text">
<string>There are no scripts currently running.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
@ -476,9 +334,6 @@ font-size: 14px;</string>
<height>300</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
@ -502,16 +357,16 @@ font-size: 14px;</string>
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
<number>6</number>
</property>
<property name="rightMargin">
<number>0</number>
<number>6</number>
</property>
<property name="bottomMargin">
<number>15</number>
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label">
@ -539,28 +394,6 @@ font: bold 16px;</string>
</item>
<item>
<widget class="QPushButton" name="loadScriptButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>111</width>
<height>35</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">background: #0e7077;
color: #fff;
border-radius: 4px;
font: bold 14px;
padding-top: 3px;</string>
</property>
<property name="text">
<string>Load script</string>
</property>
@ -570,64 +403,44 @@ padding-top: 3px;</string>
</widget>
</item>
<item>
<widget class="QLineEdit" name="filterLineEdit">
<property name="styleSheet">
<string notr="true">border: 1px solid rgb(128, 128, 128);
border-radius: 2px;
padding: 4px;
background-color: white;</string>
</property>
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>filter</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QListView" name="scriptListView">
<property name="styleSheet">
<string notr="true">QListView {
border: 1px solid rgb(128, 128, 128);
border-radius: 2px;
}
QListView::item {
padding-top: 2px;
padding-bottom: 2px;
}</string>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="filterLineEdit">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>filter</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="scriptListView">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>

View file

@ -0,0 +1,29 @@
//
// UIUtil.cpp
// library/shared/src
//
// Created by Ryan Huffman on 09/02/2014.
// Copyright 2014 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 <QStyle>
#include <QStyleOptionTitleBar>
#include "UIUtil.h"
int UIUtil::getWindowTitleBarHeight(const QWidget* window) {
QStyleOptionTitleBar options;
options.titleBarState = 1;
options.titleBarFlags = Qt::Window;
int titleBarHeight = window->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, window);
#if defined(Q_OS_MAC)
// The height on OSX is 4 pixels too tall
titleBarHeight -= 4;
#endif
return titleBarHeight;
}

View file

@ -0,0 +1,24 @@
//
// UIUtil.h
// library/shared/src
//
// Created by Ryan Huffman on 09/02/2014.
// Copyright 2014 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
//
#ifndef hifi_UIUtil_h
#define hifi_UIUtil_h
#include <QWidget>
class UIUtil {
public:
static int getWindowTitleBarHeight(const QWidget* window);
};
#endif // hifi_UIUtil_h