Update runningScripts layout and add tip message

This commit is contained in:
Ryan Huffman 2014-10-02 16:27:02 -07:00
parent fe8909ff0e
commit 1976d1f1e2
2 changed files with 67 additions and 45 deletions

View file

@ -40,6 +40,9 @@ RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
connect(&_proxyModel, &QSortFilterProxyModel::modelReset,
this, &RunningScriptsWidget::selectFirstInList);
QString shortcutText = Menu::getInstance()->getActionForOption(MenuOption::ReloadAllScripts)->shortcut().toString(QKeySequence::NativeText);
ui->tipLabel->setText("Tip: Use " + shortcutText + " to reload all scripts.");
_proxyModel.setSourceModel(&_scriptsModel);
_proxyModel.sort(0, Qt::AscendingOrder);
_proxyModel.setDynamicSortFilter(true);
@ -86,7 +89,7 @@ void RunningScriptsWidget::setBoundary(const QRect& rect) {
void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
setUpdatesEnabled(false);
QLayoutItem* widget;
while ((widget = ui->scrollAreaWidgetContents->layout()->takeAt(0)) != NULL) {
while ((widget = ui->scriptListWidget->layout()->takeAt(0)) != NULL) {
delete widget->widget();
delete widget;
}
@ -96,7 +99,7 @@ void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
if (!hash.contains(list.at(i))) {
hash.insert(list.at(i), 1);
}
QWidget* row = new QWidget(ui->scrollAreaWidgetContents);
QWidget* row = new QWidget(ui->scriptListWidget);
row->setLayout(new QHBoxLayout(row));
QUrl url = QUrl(list.at(i));
@ -130,17 +133,17 @@ void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
line->setFrameShape(QFrame::HLine);
line->setStyleSheet("color: #E1E1E1; margin-left: 6px; margin-right: 6px;");
ui->scrollAreaWidgetContents->layout()->addWidget(row);
ui->scrollAreaWidgetContents->layout()->addWidget(line);
ui->scriptListWidget->layout()->addWidget(row);
ui->scriptListWidget->layout()->addWidget(line);
}
ui->noRunningScriptsLabel->setVisible(list.isEmpty());
ui->runningScriptsList->setVisible(!list.isEmpty());
ui->runningScriptsList->setVisible(true);//!list.isEmpty());
ui->reloadAllButton->setVisible(!list.isEmpty());
ui->stopAllButton->setVisible(!list.isEmpty());
ui->scrollAreaWidgetContents->updateGeometry();
ui->scriptListWidget->updateGeometry();
setUpdatesEnabled(true);
Application::processEvents();
repaint();

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>319</width>
<height>481</height>
<width>364</width>
<height>728</height>
</rect>
</property>
<property name="windowTitle">
@ -16,19 +16,7 @@
<property name="styleSheet">
<string notr="true">* { font-family: Helvetica, Arial, sans-serif; }</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>14</number>
</property>
<property name="topMargin">
<number>20</number>
</property>
<property name="rightMargin">
<number>14</number>
</property>
<property name="bottomMargin">
<number>20</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="3,2">
<item>
<widget class="QWidget" name="runningScriptsArea" native="true">
<property name="sizePolicy">
@ -195,6 +183,25 @@ font: bold 16px;
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="noRunningScriptsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font: 14px; color: #5f5f5f; margin: 2px;</string>
</property>
<property name="text">
<string>There are no scripts running.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="runningScriptsList">
<property name="sizePolicy">
@ -219,10 +226,10 @@ font: bold 16px;
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
@ -238,8 +245,8 @@ font: bold 16px;
<rect>
<x>0</x>
<y>0</y>
<width>264</width>
<height>16</height>
<width>328</width>
<height>18</height>
</rect>
</property>
<property name="sizePolicy">
@ -254,7 +261,7 @@ font: bold 16px;
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
@ -270,29 +277,41 @@ font: bold 16px;
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="scriptListWidget" native="true">
<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>
</item>
<item>
<widget class="QLabel" name="tipLabel">
<property name="styleSheet">
<string notr="true">font: 14px; color: #5f5f5f; margin: 2px;</string>
</property>
<property name="text">
<string>Tip</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="noRunningScriptsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font: 14px; color: #5f5f5f;</string>
</property>
<property name="text">
<string>There are no scripts running.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>