From: Jens Steinhauser Date: Mon, 12 Oct 2015 01:39:38 +0000 (+0200) Subject: Move menu to left side, allow acquisition to be paused. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=68348e5abaa05fbbde7f3e6b0b28c2d12a7a2601;p=sigrok-meter.git Move menu to left side, allow acquisition to be paused. --- diff --git a/.gitignore b/.gitignore index 0d20b64..e947a5b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.pyc +resources.py diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e5fb32c --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +## +## This file is part of the sigrok-meter project. +## +## Copyright (C) 2015 Jens Steinhauser +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## + +ifneq ($(MAKECMDGOALS),clean) + ifeq (0,$(shell which pyrcc4 >/dev/null 2>&1; echo $$?)) + RCC = pyrcc4 + else + ifeq (0,$(shell which pyside-rcc >/dev/null 2>&1; echo $$?)) + RCC = pyside-rcc + else + $(error "resource compiler not found") + endif + endif +endif + +resources.py: resources.qrc + $(RCC) -py3 -o $@ $< + +.PHONY: clean +clean: + rm -f resources.py diff --git a/README b/README index 3bc2c11..ac5a3bf 100644 --- a/README +++ b/README @@ -40,6 +40,7 @@ In order to get the sigrok-meter source code and build it, run: $ git clone git://sigrok.org/sigrok-meter $ cd sigrok-meter + $ make $ ./sigrok-meter For installing sigrok-meter: @@ -64,6 +65,9 @@ due to the fact that it links against GPLv3+ libraries). Please see the individual source files for the full list of copyright holders. +The sigrok logo is licensed under the CC-BY-SA 3.0 license, the icons from the +Adwaita icon set are dual licenced under CC-BY-SA 3.0 and LGPLv3. + Mailing list ------------ diff --git a/datamodel.py b/datamodel.py index d54f429..a90cbc7 100644 --- a/datamodel.py +++ b/datamodel.py @@ -169,6 +169,13 @@ class MeasurementDataModel(QtGui.QStandardItemModel): item.setData(traces, MeasurementDataModel.tracesRole) + def clear_samples(self): + '''Removes all old samples from the model.''' + for row in range(self.rowCount()): + idx = self.index(row, 0) + self.setData(idx, {}, + MeasurementDataModel.tracesRole) + class MultimeterDelegate(QtGui.QStyledItemDelegate): '''Delegate to show the data items from a MeasurementDataModel.''' diff --git a/icons.py b/icons.py new file mode 100644 index 0000000..ad91dbb --- /dev/null +++ b/icons.py @@ -0,0 +1,50 @@ +## +## This file is part of the sigrok-meter project. +## +## Copyright (C) 2015 Jens Steinhauser +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## + +import qtcompat +import resources + +QtCore = qtcompat.QtCore +QtGui = qtcompat.QtGui + +def _load_icon(name): + icon = QtGui.QIcon() + + nameFilters = ['{}-*'.format(name)] + it = QtCore.QDirIterator(':/icons/', nameFilters) + while it.hasNext(): + filename = it.next() + icon.addFile(filename) + + globals()[name] = icon + +def load_icons(): + '''Loads all available icons in all sizes from the resource file. + + A QApplication must have been created before this function can be called. + ''' + _load_icon('about') + _load_icon('add') + _load_icon('exit') + _load_icon('graph') + _load_icon('log') + _load_icon('preferences') + _load_icon('start') + _load_icon('stop') diff --git a/icons/adwaita-icon-theme-3.18.0/16x16/actions/application-exit.png b/icons/adwaita-icon-theme-3.18.0/16x16/actions/application-exit.png new file mode 100644 index 0000000..1c6ddf0 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/16x16/actions/application-exit.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/16x16/actions/help-about.png b/icons/adwaita-icon-theme-3.18.0/16x16/actions/help-about.png new file mode 100644 index 0000000..3d9d4da Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/16x16/actions/help-about.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/16x16/actions/list-add.png b/icons/adwaita-icon-theme-3.18.0/16x16/actions/list-add.png new file mode 100644 index 0000000..3f1347e Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/16x16/actions/list-add.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/16x16/actions/media-playback-start.png b/icons/adwaita-icon-theme-3.18.0/16x16/actions/media-playback-start.png new file mode 100644 index 0000000..7d39b2f Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/16x16/actions/media-playback-start.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/16x16/actions/media-playback-stop.png b/icons/adwaita-icon-theme-3.18.0/16x16/actions/media-playback-stop.png new file mode 100644 index 0000000..740bed0 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/16x16/actions/media-playback-stop.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/16x16/apps/accessories-text-editor.png b/icons/adwaita-icon-theme-3.18.0/16x16/apps/accessories-text-editor.png new file mode 100644 index 0000000..31c1aa6 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/16x16/apps/accessories-text-editor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/16x16/apps/utilities-system-monitor.png b/icons/adwaita-icon-theme-3.18.0/16x16/apps/utilities-system-monitor.png new file mode 100644 index 0000000..1b0c236 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/16x16/apps/utilities-system-monitor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/16x16/categories/preferences-system.png b/icons/adwaita-icon-theme-3.18.0/16x16/categories/preferences-system.png new file mode 100644 index 0000000..ab65d2b Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/16x16/categories/preferences-system.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/22x22/actions/application-exit.png b/icons/adwaita-icon-theme-3.18.0/22x22/actions/application-exit.png new file mode 100644 index 0000000..c6c81f6 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/22x22/actions/application-exit.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/22x22/actions/help-about.png b/icons/adwaita-icon-theme-3.18.0/22x22/actions/help-about.png new file mode 100644 index 0000000..435ea0e Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/22x22/actions/help-about.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/22x22/actions/list-add.png b/icons/adwaita-icon-theme-3.18.0/22x22/actions/list-add.png new file mode 100644 index 0000000..0dd5d82 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/22x22/actions/list-add.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/22x22/actions/media-playback-start.png b/icons/adwaita-icon-theme-3.18.0/22x22/actions/media-playback-start.png new file mode 100644 index 0000000..309087b Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/22x22/actions/media-playback-start.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/22x22/actions/media-playback-stop.png b/icons/adwaita-icon-theme-3.18.0/22x22/actions/media-playback-stop.png new file mode 100644 index 0000000..73294be Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/22x22/actions/media-playback-stop.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/22x22/apps/accessories-text-editor.png b/icons/adwaita-icon-theme-3.18.0/22x22/apps/accessories-text-editor.png new file mode 100644 index 0000000..4d8cc5a Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/22x22/apps/accessories-text-editor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/22x22/apps/utilities-system-monitor.png b/icons/adwaita-icon-theme-3.18.0/22x22/apps/utilities-system-monitor.png new file mode 100644 index 0000000..3112836 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/22x22/apps/utilities-system-monitor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/22x22/categories/preferences-system.png b/icons/adwaita-icon-theme-3.18.0/22x22/categories/preferences-system.png new file mode 100644 index 0000000..3afa038 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/22x22/categories/preferences-system.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/24x24/actions/application-exit.png b/icons/adwaita-icon-theme-3.18.0/24x24/actions/application-exit.png new file mode 100644 index 0000000..9251cda Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/24x24/actions/application-exit.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/24x24/actions/help-about.png b/icons/adwaita-icon-theme-3.18.0/24x24/actions/help-about.png new file mode 100644 index 0000000..b7df851 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/24x24/actions/help-about.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/24x24/actions/list-add.png b/icons/adwaita-icon-theme-3.18.0/24x24/actions/list-add.png new file mode 100644 index 0000000..28e11b7 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/24x24/actions/list-add.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/24x24/actions/media-playback-start.png b/icons/adwaita-icon-theme-3.18.0/24x24/actions/media-playback-start.png new file mode 100644 index 0000000..3e56b1d Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/24x24/actions/media-playback-start.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/24x24/actions/media-playback-stop.png b/icons/adwaita-icon-theme-3.18.0/24x24/actions/media-playback-stop.png new file mode 100644 index 0000000..0f42de2 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/24x24/actions/media-playback-stop.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/24x24/apps/accessories-text-editor.png b/icons/adwaita-icon-theme-3.18.0/24x24/apps/accessories-text-editor.png new file mode 100644 index 0000000..9b781a8 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/24x24/apps/accessories-text-editor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/24x24/apps/utilities-system-monitor.png b/icons/adwaita-icon-theme-3.18.0/24x24/apps/utilities-system-monitor.png new file mode 100644 index 0000000..1787eed Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/24x24/apps/utilities-system-monitor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/24x24/categories/preferences-system.png b/icons/adwaita-icon-theme-3.18.0/24x24/categories/preferences-system.png new file mode 100644 index 0000000..52cb289 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/24x24/categories/preferences-system.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/256x256/apps/accessories-text-editor.png b/icons/adwaita-icon-theme-3.18.0/256x256/apps/accessories-text-editor.png new file mode 100644 index 0000000..7ed05c4 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/256x256/apps/accessories-text-editor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/256x256/apps/utilities-system-monitor.png b/icons/adwaita-icon-theme-3.18.0/256x256/apps/utilities-system-monitor.png new file mode 100644 index 0000000..9f2f113 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/256x256/apps/utilities-system-monitor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/256x256/categories/preferences-system.png b/icons/adwaita-icon-theme-3.18.0/256x256/categories/preferences-system.png new file mode 100644 index 0000000..af2bcb9 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/256x256/categories/preferences-system.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/32x32/actions/application-exit.png b/icons/adwaita-icon-theme-3.18.0/32x32/actions/application-exit.png new file mode 100644 index 0000000..c3f905e Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/32x32/actions/application-exit.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/32x32/actions/help-about.png b/icons/adwaita-icon-theme-3.18.0/32x32/actions/help-about.png new file mode 100644 index 0000000..399d484 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/32x32/actions/help-about.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/32x32/actions/list-add.png b/icons/adwaita-icon-theme-3.18.0/32x32/actions/list-add.png new file mode 100644 index 0000000..184afa8 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/32x32/actions/list-add.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/32x32/actions/media-playback-start.png b/icons/adwaita-icon-theme-3.18.0/32x32/actions/media-playback-start.png new file mode 100644 index 0000000..6992d7a Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/32x32/actions/media-playback-start.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/32x32/actions/media-playback-stop.png b/icons/adwaita-icon-theme-3.18.0/32x32/actions/media-playback-stop.png new file mode 100644 index 0000000..bfd56f8 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/32x32/actions/media-playback-stop.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/32x32/apps/accessories-text-editor.png b/icons/adwaita-icon-theme-3.18.0/32x32/apps/accessories-text-editor.png new file mode 100644 index 0000000..5eaf6fc Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/32x32/apps/accessories-text-editor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/32x32/apps/utilities-system-monitor.png b/icons/adwaita-icon-theme-3.18.0/32x32/apps/utilities-system-monitor.png new file mode 100644 index 0000000..43641db Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/32x32/apps/utilities-system-monitor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/32x32/categories/preferences-system.png b/icons/adwaita-icon-theme-3.18.0/32x32/categories/preferences-system.png new file mode 100644 index 0000000..c473518 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/32x32/categories/preferences-system.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/48x48/actions/application-exit.png b/icons/adwaita-icon-theme-3.18.0/48x48/actions/application-exit.png new file mode 100644 index 0000000..2d0cd61 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/48x48/actions/application-exit.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/48x48/actions/help-about.png b/icons/adwaita-icon-theme-3.18.0/48x48/actions/help-about.png new file mode 100644 index 0000000..45b5d62 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/48x48/actions/help-about.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/48x48/actions/list-add.png b/icons/adwaita-icon-theme-3.18.0/48x48/actions/list-add.png new file mode 100644 index 0000000..cb01af6 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/48x48/actions/list-add.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/48x48/actions/media-playback-start.png b/icons/adwaita-icon-theme-3.18.0/48x48/actions/media-playback-start.png new file mode 100644 index 0000000..5f0128d Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/48x48/actions/media-playback-start.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/48x48/actions/media-playback-stop.png b/icons/adwaita-icon-theme-3.18.0/48x48/actions/media-playback-stop.png new file mode 100644 index 0000000..bbc6065 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/48x48/actions/media-playback-stop.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/48x48/apps/accessories-text-editor.png b/icons/adwaita-icon-theme-3.18.0/48x48/apps/accessories-text-editor.png new file mode 100644 index 0000000..602a275 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/48x48/apps/accessories-text-editor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/48x48/apps/utilities-system-monitor.png b/icons/adwaita-icon-theme-3.18.0/48x48/apps/utilities-system-monitor.png new file mode 100644 index 0000000..bc9fbf0 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/48x48/apps/utilities-system-monitor.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/48x48/categories/preferences-system.png b/icons/adwaita-icon-theme-3.18.0/48x48/categories/preferences-system.png new file mode 100644 index 0000000..6cab758 Binary files /dev/null and b/icons/adwaita-icon-theme-3.18.0/48x48/categories/preferences-system.png differ diff --git a/icons/adwaita-icon-theme-3.18.0/COPYING b/icons/adwaita-icon-theme-3.18.0/COPYING new file mode 100644 index 0000000..c2e0168 --- /dev/null +++ b/icons/adwaita-icon-theme-3.18.0/COPYING @@ -0,0 +1,10 @@ +This work is licenced under the terms of either the GNU LGPL v3 or +Creative Commons Attribution-Share Alike 3.0 United States License. + +To view a copy of the CC-BY-SA licence, visit +http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative +Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. + +When attributing the artwork, using "GNOME Project" is enough. +Please link to http://www.gnome.org where available. + diff --git a/icons/adwaita-icon-theme-3.18.0/COPYING_CCBYSA3 b/icons/adwaita-icon-theme-3.18.0/COPYING_CCBYSA3 new file mode 100644 index 0000000..fc45d78 --- /dev/null +++ b/icons/adwaita-icon-theme-3.18.0/COPYING_CCBYSA3 @@ -0,0 +1,7 @@ +This work is licenced under the Creative Commons Attribution-Share Alike 3.0 +United States License. To view a copy of this licence, visit +http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative +Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. + +When attributing the artwork, using "GNOME Project" is enough. +Please link to http://www.gnome.org where available. diff --git a/icons/adwaita-icon-theme-3.18.0/COPYING_LGPL b/icons/adwaita-icon-theme-3.18.0/COPYING_LGPL new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/icons/adwaita-icon-theme-3.18.0/COPYING_LGPL @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/icons/copy_icons.py b/icons/copy_icons.py new file mode 100755 index 0000000..9edcbba --- /dev/null +++ b/icons/copy_icons.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 + +## +## This file is part of the sigrok-meter project. +## +## Copyright (C) 2015 Jens Steinhauser +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## + +# This scripts copies the icons that sigrok-meter uses from the icon pack, +# and outputs the matching entries for a Qt resource file. + +import os +import shutil + +ICONDIR = '../adwaita-icon-theme-3.18.0/Adwaita' +OUTDIR = 'icons/adwaita-icon-theme-3.18.0' + +def find(iconname): + result = [] + for root, dirs, files in os.walk(ICONDIR): + if iconname in files: + result.append(os.path.join(root[len(ICONDIR)+1:], iconname)) + return result + +def copy(alias, iconname): + for fn in sorted(find(iconname)): + inputfile = os.path.join(ICONDIR, fn) + outputfile = os.path.join(OUTDIR, fn) + outputpath = os.path.dirname(outputfile) + size = fn.split(os.sep)[0] + + if not os.path.exists(outputpath): + os.makedirs(outputpath) + + shutil.copy(inputfile, outputpath) + + template = '{}' + print(template.format(alias, size, outputfile)) + +copy('about', 'help-about.png') +copy('add', 'list-add.png') +copy('exit', 'application-exit.png') +copy('graph', 'utilities-system-monitor.png') +copy('log', 'accessories-text-editor.png') +copy('preferences', 'preferences-system.png') +copy('start', 'media-playback-start.png') +copy('stop', 'media-playback-stop.png') diff --git a/icons/sigrok-logo-notext.png b/icons/sigrok-logo-notext.png new file mode 100644 index 0000000..a3ca65f Binary files /dev/null and b/icons/sigrok-logo-notext.png differ diff --git a/mainwindow.py b/mainwindow.py index 315d805..058fe5f 100644 --- a/mainwindow.py +++ b/mainwindow.py @@ -21,6 +21,7 @@ import acquisition import datamodel +import icons import multiplotwidget import os.path import qtcompat @@ -70,9 +71,17 @@ class MainWindow(QtGui.QMainWindow): self.delegate = datamodel.MultimeterDelegate(self, self.font()) self.model = datamodel.MeasurementDataModel(self) - self.model.rowsInserted.connect(self.modelRowsInserted) - self.setup_ui() + # Maps from 'unit' to the corresponding plot. + self._plots = {} + # Maps from '(plot, device)' to the corresponding curve. + self._curves = {} + + self._setup_ui() + + self._plot_update_timer = QtCore.QTimer() + self._plot_update_timer.setInterval(MainWindow.UPDATEINTERVAL) + self._plot_update_timer.timeout.connect(self._updatePlots) QtCore.QTimer.singleShot(0, self._start_acquisition) @@ -89,70 +98,177 @@ class MainWindow(QtGui.QMainWindow): self.close() return - self.acquisition.start() + self.start_stop_acquisition() - def setup_ui(self): + def _setup_ui(self): self.setWindowTitle('sigrok-meter') # Resizing the listView below will increase this again. self.resize(350, 10) - p = os.path.abspath(os.path.dirname(__file__)) - p = os.path.join(p, 'sigrok-logo-notext.png') - self.setWindowIcon(QtGui.QIcon(p)) + self.setWindowIcon(QtGui.QIcon(':/logo.png')) - actionQuit = QtGui.QAction(self) - actionQuit.setText('&Quit') - actionQuit.setIcon(QtGui.QIcon.fromTheme('application-exit')) - actionQuit.setShortcut('Ctrl+Q') - actionQuit.triggered.connect(self.close) + self._setup_graphPage() + self._setup_addDevicePage() + self._setup_logPage() + self._setup_preferencesPage() - actionAbout = QtGui.QAction(self) - actionAbout.setText('&About') - actionAbout.setIcon(QtGui.QIcon.fromTheme('help-about')) - actionAbout.triggered.connect(self.show_about) + self._pages = [ + self.graphPage, + self.addDevicePage, + self.logPage, + self.preferencesPage + ] - menubar = self.menuBar() - menuFile = menubar.addMenu('&File') - menuFile.addAction(actionQuit) - menuHelp = menubar.addMenu('&Help') - menuHelp.addAction(actionAbout) - - self.listView = EmptyMessageListView('waiting for data...') - self.listView.setFrameShape(QtGui.QFrame.NoFrame) - self.listView.viewport().setBackgroundRole(QtGui.QPalette.Window) - self.listView.viewport().setAutoFillBackground(True) - self.listView.setMinimumWidth(260) - self.listView.setSelectionMode(QtGui.QAbstractItemView.NoSelection) - self.listView.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) - self.listView.setVerticalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel) - self.listView.setItemDelegate(self.delegate) - self.listView.setModel(self.model) - self.listView.setUniformItemSizes(True) - self.listView.setMinimumSize(self.delegate.sizeHint()) + self.stackedWidget = QtGui.QStackedWidget(self) + for page in self._pages: + self.stackedWidget.addWidget(page) - self.plotwidget = multiplotwidget.MultiPlotWidget(self) - self.plotwidget.plotHidden.connect(self._on_plotHidden) + self._setup_sidebar() - # Maps from 'unit' to the corresponding plot. - self._plots = {} - # Maps from '(plot, device)' to the corresponding curve. - self._curves = {} + self.setCentralWidget(QtGui.QWidget()) + self.centralWidget().setContentsMargins(0, 0, 0, 0) - self.splitter = QtGui.QSplitter(QtCore.Qt.Horizontal); - self.splitter.addWidget(self.listView) - self.splitter.addWidget(self.plotwidget) - self.splitter.setStretchFactor(0, 0) - self.splitter.setStretchFactor(1, 1) + layout = QtGui.QHBoxLayout(self.centralWidget()) + layout.addWidget(self.sideBar) + layout.addWidget(self.stackedWidget) + layout.setSpacing(0) + layout.setContentsMargins(0, 0, 0, 0) + + self.resize(900, 550) + + def _setup_sidebar(self): + self.sideBar = QtGui.QToolBar(self) + self.sideBar.setOrientation(QtCore.Qt.Vertical) + + actionGraph = self.sideBar.addAction('Instantaneous Values and Graphs') + actionGraph.setCheckable(True) + actionGraph.setIcon(icons.graph) + actionGraph.triggered.connect(self.showGraphPage) + + #actionAdd = self.sideBar.addAction('Add Device') + #actionAdd.setCheckable(True) + #actionAdd.setIcon(icons.add) + #actionAdd.triggered.connect(self.showAddDevicePage) + + #actionLog = self.sideBar.addAction('Logs') + #actionLog.setCheckable(True) + #actionLog.setIcon(icons.log) + #actionLog.triggered.connect(self.showLogPage) + + #actionPreferences = self.sideBar.addAction('Preferences') + #actionPreferences.setCheckable(True) + #actionPreferences.setIcon(icons.preferences) + #actionPreferences.triggered.connect(self.showPreferencesPage) + + # make the buttons at the top exclusive + self.actionGroup = QtGui.QActionGroup(self) + self.actionGroup.addAction(actionGraph) + #self.actionGroup.addAction(actionAdd) + #self.actionGroup.addAction(actionLog) + #self.actionGroup.addAction(actionPreferences) + + # show graph at startup + actionGraph.setChecked(True) + + # fill space between buttons on the top and on the bottom + fill = QtGui.QWidget(self) + fill.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) + self.sideBar.addWidget(fill) + + self.actionStartStop = self.sideBar.addAction('Start Acquisition') + self.actionStartStop.setIcon(icons.start) + self.actionStartStop.triggered.connect(self.start_stop_acquisition) + + actionAbout = self.sideBar.addAction('About') + actionAbout.setIcon(icons.about) + actionAbout.triggered.connect(self.show_about) - self.setCentralWidget(self.splitter) - self.centralWidget().setContentsMargins(0, 0, 0, 0) - self.resize(800, 500) + actionQuit = self.sideBar.addAction('Quit') + actionQuit.setIcon(icons.exit) + actionQuit.triggered.connect(self.close) + + s = self.style().pixelMetric(QtGui.QStyle.PM_LargeIconSize) + self.sideBar.setIconSize(QtCore.QSize(s, s)) + + self.sideBar.setStyleSheet(''' + QToolBar { + background-color: white; + margin: 0px; + border: 0px; + border-right: 1px solid black; + } + + QToolButton { + padding: 10px; + border: 0px; + border-right: 1px solid black; + } + + QToolButton:checked, + QToolButton[checkable="false"]:hover { + background-color: #c0d0e8; + } + ''') + + def _setup_graphPage(self): + listView = EmptyMessageListView('waiting for data...') + listView.setFrameShape(QtGui.QFrame.NoFrame) + listView.viewport().setBackgroundRole(QtGui.QPalette.Window) + listView.viewport().setAutoFillBackground(True) + listView.setMinimumWidth(260) + listView.setSelectionMode(QtGui.QAbstractItemView.NoSelection) + listView.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + listView.setVerticalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel) + listView.setItemDelegate(self.delegate) + listView.setModel(self.model) + listView.setUniformItemSizes(True) + listView.setMinimumSize(self.delegate.sizeHint()) - self.startTimer(MainWindow.UPDATEINTERVAL) + self.plotwidget = multiplotwidget.MultiPlotWidget(self) + self.plotwidget.plotHidden.connect(self._on_plotHidden) - def stop(self): - self.acquisition.stop() - print(self.acquisition.is_running()) + self.graphPage = QtGui.QSplitter(QtCore.Qt.Horizontal, self) + self.graphPage.addWidget(listView) + self.graphPage.addWidget(self.plotwidget) + self.graphPage.setStretchFactor(0, 0) + self.graphPage.setStretchFactor(1, 1) + + def _setup_addDevicePage(self): + self.addDevicePage = QtGui.QWidget(self) + layout = QtGui.QVBoxLayout(self.addDevicePage) + label = QtGui.QLabel('add device page') + layout.addWidget(label) + + def _setup_logPage(self): + self.logPage = QtGui.QWidget(self) + layout = QtGui.QVBoxLayout(self.logPage) + label = QtGui.QLabel('log page') + layout.addWidget(label) + + def _setup_preferencesPage(self): + self.preferencesPage = QtGui.QWidget(self) + layout = QtGui.QVBoxLayout(self.preferencesPage) + label = QtGui.QLabel('preferences page') + layout.addWidget(label) + + def showPage(self, page): + self.stackedWidget.setCurrentIndex(self._pages.index(page)) + + @QtCore.Slot(bool) + def showGraphPage(self): + self.showPage(self.graphPage) + + @QtCore.Slot(bool) + def showAddDevicePage(self): + self.showPage(self.addDevicePage) + + @QtCore.Slot(bool) + def showLogPage(self): + self.showPage(self.logPage) + + @QtCore.Slot(bool) + def showPreferencesPage(self): + self.showPage(self.preferencesPage) def _getPlot(self, unit): '''Looks up or creates a new plot for 'unit'.''' @@ -177,7 +293,7 @@ class MainWindow(QtGui.QMainWindow): def _getCurve(self, plot, deviceID): '''Looks up or creates a new curve for '(plot, deviceID)'.''' - key = (id(plot), deviceID) + key = (plot, deviceID) if key in self._curves: return self._curves[key] @@ -193,11 +309,6 @@ class MainWindow(QtGui.QMainWindow): self._curves[key] = curve return curve - def timerEvent(self, event): - '''Periodically updates all graphs.''' - - self._updatePlots() - def _updatePlots(self): '''Updates all plots.''' @@ -252,16 +363,41 @@ class MainWindow(QtGui.QMainWindow): @QtCore.Slot() def _stopped(self): if self._closing: + # The acquisition was stopped by the 'closeEvent()', close the + # window again now that the acquisition has stopped. self.close() def closeEvent(self, event): if self.acquisition.is_running(): + # Stop the acquisition before closing the window. self._closing = True - self.acquisition.stop() + self.start_stop_acquisition() event.ignore() else: event.accept() + @QtCore.Slot() + def start_stop_acquisition(self): + if self.acquisition.is_running(): + self.acquisition.stop() + self._plot_update_timer.stop() + self.actionStartStop.setText('Start Acquisition') + self.actionStartStop.setIcon(icons.start) + else: + # before starting (again), remove all old samples and old curves + self.model.clear_samples() + + for key in self._curves: + plot, _ = key + curve = self._curves[key] + plot.view.removeItem(curve) + self._curves = {} + + self.acquisition.start() + self._plot_update_timer.start() + self.actionStartStop.setText('Stop Acquisition') + self.actionStartStop.setIcon(icons.stop) + @QtCore.Slot() def show_about(self): text = textwrap.dedent('''\ @@ -276,15 +412,11 @@ class MainWindow(QtGui.QMainWindow): This program comes with ABSOLUTELY NO WARRANTY;
for details visit - http://www.gnu.org/licenses/gpl.html + http://www.gnu.org/licenses/gpl.html
+
+ Some icons by + the GNOME project '''.format(self.context.package_version, self.context.lib_version)) QtGui.QMessageBox.about(self, 'About sigrok-meter', text) - - @QtCore.Slot(object, int, int) - def modelRowsInserted(self, parent, start, end): - '''Resize the list view to the size of the content.''' - rows = self.model.rowCount() - dh = self.delegate.sizeHint().height() - self.listView.setMinimumHeight(dh * rows) diff --git a/multiplotwidget.py b/multiplotwidget.py index 1d257bd..f7c3de9 100755 --- a/multiplotwidget.py +++ b/multiplotwidget.py @@ -173,6 +173,7 @@ class MultiPlotWidget(pyqtgraph.GraphicsView): for m in [ 'addPlot', + 'hidePlot', 'showPlot' ]: setattr(self, m, getattr(self.multiPlotItem, m)) diff --git a/resources.qrc b/resources.qrc new file mode 100644 index 0000000..531e28a --- /dev/null +++ b/resources.qrc @@ -0,0 +1,50 @@ + + +icons/sigrok-logo-notext.png + + +icons/adwaita-icon-theme-3.18.0/16x16/actions/help-about.png +icons/adwaita-icon-theme-3.18.0/22x22/actions/help-about.png +icons/adwaita-icon-theme-3.18.0/24x24/actions/help-about.png +icons/adwaita-icon-theme-3.18.0/32x32/actions/help-about.png +icons/adwaita-icon-theme-3.18.0/48x48/actions/help-about.png +icons/adwaita-icon-theme-3.18.0/16x16/actions/list-add.png +icons/adwaita-icon-theme-3.18.0/22x22/actions/list-add.png +icons/adwaita-icon-theme-3.18.0/24x24/actions/list-add.png +icons/adwaita-icon-theme-3.18.0/32x32/actions/list-add.png +icons/adwaita-icon-theme-3.18.0/48x48/actions/list-add.png +icons/adwaita-icon-theme-3.18.0/16x16/actions/application-exit.png +icons/adwaita-icon-theme-3.18.0/22x22/actions/application-exit.png +icons/adwaita-icon-theme-3.18.0/24x24/actions/application-exit.png +icons/adwaita-icon-theme-3.18.0/32x32/actions/application-exit.png +icons/adwaita-icon-theme-3.18.0/48x48/actions/application-exit.png +icons/adwaita-icon-theme-3.18.0/16x16/apps/utilities-system-monitor.png +icons/adwaita-icon-theme-3.18.0/22x22/apps/utilities-system-monitor.png +icons/adwaita-icon-theme-3.18.0/24x24/apps/utilities-system-monitor.png +icons/adwaita-icon-theme-3.18.0/256x256/apps/utilities-system-monitor.png +icons/adwaita-icon-theme-3.18.0/32x32/apps/utilities-system-monitor.png +icons/adwaita-icon-theme-3.18.0/48x48/apps/utilities-system-monitor.png +icons/adwaita-icon-theme-3.18.0/16x16/apps/accessories-text-editor.png +icons/adwaita-icon-theme-3.18.0/22x22/apps/accessories-text-editor.png +icons/adwaita-icon-theme-3.18.0/24x24/apps/accessories-text-editor.png +icons/adwaita-icon-theme-3.18.0/256x256/apps/accessories-text-editor.png +icons/adwaita-icon-theme-3.18.0/32x32/apps/accessories-text-editor.png +icons/adwaita-icon-theme-3.18.0/48x48/apps/accessories-text-editor.png +icons/adwaita-icon-theme-3.18.0/16x16/categories/preferences-system.png +icons/adwaita-icon-theme-3.18.0/22x22/categories/preferences-system.png +icons/adwaita-icon-theme-3.18.0/24x24/categories/preferences-system.png +icons/adwaita-icon-theme-3.18.0/256x256/categories/preferences-system.png +icons/adwaita-icon-theme-3.18.0/32x32/categories/preferences-system.png +icons/adwaita-icon-theme-3.18.0/48x48/categories/preferences-system.png +icons/adwaita-icon-theme-3.18.0/16x16/actions/media-playback-start.png +icons/adwaita-icon-theme-3.18.0/22x22/actions/media-playback-start.png +icons/adwaita-icon-theme-3.18.0/24x24/actions/media-playback-start.png +icons/adwaita-icon-theme-3.18.0/32x32/actions/media-playback-start.png +icons/adwaita-icon-theme-3.18.0/48x48/actions/media-playback-start.png +icons/adwaita-icon-theme-3.18.0/16x16/actions/media-playback-stop.png +icons/adwaita-icon-theme-3.18.0/22x22/actions/media-playback-stop.png +icons/adwaita-icon-theme-3.18.0/24x24/actions/media-playback-stop.png +icons/adwaita-icon-theme-3.18.0/32x32/actions/media-playback-stop.png +icons/adwaita-icon-theme-3.18.0/48x48/actions/media-playback-stop.png + + diff --git a/sigrok-logo-notext.png b/sigrok-logo-notext.png deleted file mode 100644 index a3ca65f..0000000 Binary files a/sigrok-logo-notext.png and /dev/null differ diff --git a/sigrok-meter b/sigrok-meter index 4722feb..7ded286 100755 --- a/sigrok-meter +++ b/sigrok-meter @@ -106,6 +106,10 @@ if __name__ == '__main__': sys.exit('Error: invalid log level.') app = QtGui.QApplication([]) + + import icons + icons.load_icons() + s = mainwindow.MainWindow(context, args.drivers) s.show()