Skip to content

Commit

Permalink
Merge pull request bitcraze#415 from victorhook/issue_405
Browse files Browse the repository at this point in the history
Improved log-config functionality regarding bitcraze#405
  • Loading branch information
krichardsson authored Jul 28, 2020
2 parents 37592f5 + 4f14b08 commit be73b72
Show file tree
Hide file tree
Showing 9 changed files with 688 additions and 135 deletions.
389 changes: 351 additions & 38 deletions src/cfclient/ui/dialogs/logconfigdialogue.py

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions src/cfclient/ui/dialogs/logconfigdialogue.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>925</width>
<height>447</height>
<width>1179</width>
<height>558</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -43,12 +43,36 @@
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QTreeWidget" name="categoryTree">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="1" column="1">
<widget class="QTreeWidget" name="logTree">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>4</number>
</property>
<attribute name="headerDefaultSectionSize">
<number>100</number>
<attribute name="headerMinimumSectionSize">
<number>57</number>
</attribute>
<column>
<property name="text">
Expand All @@ -72,7 +96,7 @@
</column>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="addButton">
Expand All @@ -90,7 +114,7 @@
</item>
</layout>
</item>
<item row="1" column="2">
<item row="1" column="3">
<widget class="QTreeWidget" name="varTree">
<property name="columnCount">
<number>4</number>
Expand Down Expand Up @@ -125,12 +149,39 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_2">
<widget class="QPushButton" name="createCategoryBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Create category</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="createConfigBtn">
<property name="text">
<string>Create config</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteBtn">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -140,7 +191,7 @@
</property>
</spacer>
</item>
<item alignment="Qt::AlignTop">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Logging period</string>
Expand All @@ -165,7 +216,7 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -177,29 +228,28 @@
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QProgressBar" name="packetSize">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QLabel" name="label_16">
<item>
<widget class="QLabel" name="statusText">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="closeOnSave">
<property name="text">
<string>Config name</string>
<string>Close window on save</string>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer_9">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
Expand All @@ -208,52 +258,7 @@
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="deleteButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="configNameCombo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="6">
<item>
<widget class="QPushButton" name="saveButton">
<property name="enabled">
<bool>false</bool>
Expand All @@ -263,18 +268,18 @@
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="loadButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QProgressBar" name="packetSize">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2"/>
</item>
</layout>
</item>
</layout>
Expand Down
Binary file added src/cfclient/ui/icons/create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/cfclient/ui/icons/delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
7 changes: 6 additions & 1 deletion src/cfclient/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
from .dialogs.inputconfigdialogue import InputConfigDialogue
from .dialogs.logconfigdialogue import LogConfigDialogue


__author__ = 'Bitcraze AB'
__all__ = ['MainUI']

Expand Down Expand Up @@ -315,11 +316,15 @@ def __init__(self, *args):
self.tabsMenuItem = QMenu("Tabs", self.menuView, enabled=True)
self.menuView.addMenu(self.tabsMenuItem)

# self.tabsMenuItem.setMenu(QtWidgets.QMenu())
tabItems = {}
self.loadedTabs = []
for tabClass in cfclient.ui.tabs.available:
tab = tabClass(self.tabs, cfclient.ui.pluginhelper)

# Set reference for plot-tab.
if isinstance(tab, cfclient.ui.tabs.PlotTab):
cfclient.ui.pluginhelper.plotTab = tab

item = QtWidgets.QAction(tab.getMenuName(), self, checkable=True)
item.toggled.connect(tab.toggleVisibility)
self.tabsMenuItem.addAction(item)
Expand Down
1 change: 1 addition & 0 deletions src/cfclient/ui/pluginhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ def __init__(self):
self.menu = None
self.logConfigReader = None
self.mainUI = None
self.plotTab = None
6 changes: 5 additions & 1 deletion src/cfclient/ui/tabs/PlotTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ def __init__(self, parent=None):
def add_block(self, block):
self._nodes.append(block)
self.layoutChanged.emit()
self._nodes.sort(key=lambda conf: conf.name.lower())

def parent(self, index):
"""Re-implemented method to get the parent of the given index"""
return QModelIndex()

def remove_block(self, block):
"""Remove a block from the view"""
raise NotImplementedError()
self._nodes.remove(block)

def columnCount(self, parent):
"""Re-implemented method to get the number of columns"""
Expand Down Expand Up @@ -245,6 +246,9 @@ def _config_added(self, logconfig):
logger.debug("Callback for new config [%s]", logconfig.name)
self._model.add_block(logconfig)

def remove_config(self, logconfig):
self._model.remove_block(logconfig)

def _logging_error(self, log_conf, msg):
"""Callback from the log layer when an error occurs"""
QMessageBox.about(
Expand Down
Loading

0 comments on commit be73b72

Please sign in to comment.