Browse Source

Removed QT interface, renamed interfaces to Kaylee

I'm a GTK man myself.  I don't know if I have Python QT bindings
installed on any of my computers.  It follows then that I would not
maintain the QT interface well, let alone use it at all.  It has
therefore been removed to avoid having someone try to use it only to
find that it's broken.
Clara Hobbs 8 years ago
parent
commit
2a641364bf
5 changed files with 34 additions and 137 deletions
  1. 0
    115
      QtUI.py
  2. 10
    9
      blather.py
  3. 18
    10
      gtktrayui.py
  4. 4
    2
      gtkui.py
  5. 2
    1
      recognizer.py

+ 0
- 115
QtUI.py View File

@@ -1,115 +0,0 @@
1
-#This is part of Blather
2
-# -- this code is licensed GPLv3
3
-# Copyright 2013 Jezra
4
-import sys
5
-import gobject
6
-# Qt stuff
7
-from PySide.QtCore import Signal, Qt
8
-from PySide.QtGui import QApplication, QWidget, QMainWindow, QVBoxLayout
9
-from PySide.QtGui import QLabel, QPushButton, QCheckBox, QIcon, QAction
10
-
11
-class UI(gobject.GObject):
12
-	__gsignals__ = {
13
-		'command' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,))
14
-	}
15
-
16
-	def __init__(self,args,continuous):
17
-		self.continuous = continuous
18
-		gobject.GObject.__init__(self)
19
-		#start by making our app
20
-		self.app = QApplication(args)
21
-		#make a window
22
-		self.window = QMainWindow()
23
-		#give the window a name
24
-		self.window.setWindowTitle("BlatherQt")
25
-		self.window.setMaximumSize(400,200)
26
-		center = QWidget()
27
-		self.window.setCentralWidget(center)
28
-
29
-		layout = QVBoxLayout()
30
-		center.setLayout(layout)
31
-		#make a listen/stop button
32
-		self.lsbutton = QPushButton("Listen")
33
-		layout.addWidget(self.lsbutton)
34
-		#make a continuous button
35
-		self.ccheckbox = QCheckBox("Continuous Listen")
36
-		layout.addWidget(self.ccheckbox)
37
-
38
-		#connect the buttons
39
-		self.lsbutton.clicked.connect(self.lsbutton_clicked)
40
-		self.ccheckbox.clicked.connect(self.ccheckbox_clicked)
41
-
42
-		#add a label to the UI to display the last command
43
-		self.label = QLabel()
44
-		layout.addWidget(self.label)
45
-
46
-		#add the actions for quiting
47
-		quit_action = QAction(self.window)
48
-		quit_action.setShortcut('Ctrl+Q')
49
-		quit_action.triggered.connect(self.accel_quit)
50
-		self.window.addAction(quit_action)
51
-
52
-	def accel_quit(self):
53
-		#emit the quit
54
-		self.emit("command", "quit")
55
-
56
-	def ccheckbox_clicked(self):
57
-		checked = self.ccheckbox.isChecked()
58
-		if checked:
59
-			#disable lsbutton
60
-			self.lsbutton.setEnabled(False)
61
-			self.lsbutton_stopped()
62
-			self.emit('command', "continuous_listen")
63
-			self.set_icon_active()
64
-		else:
65
-			self.lsbutton.setEnabled(True)
66
-			self.emit('command', "continuous_stop")
67
-			self.set_icon_inactive()
68
-
69
-	def lsbutton_stopped(self):
70
-		self.lsbutton.setText("Listen")
71
-
72
-	def lsbutton_clicked(self):
73
-		val = self.lsbutton.text()
74
-		if val == "Listen":
75
-			self.emit("command", "listen")
76
-			self.lsbutton.setText("Stop")
77
-			#clear the label
78
-			self.label.setText("")
79
-			self.set_icon_active()
80
-		else:
81
-			self.lsbutton_stopped()
82
-			self.emit("command", "stop")
83
-			self.set_icon_inactive()
84
-
85
-	def run(self):
86
-		self.set_icon_inactive()
87
-		self.window.show()
88
-		if self.continuous:
89
-			self.set_icon_active()
90
-			self.ccheckbox.setCheckState(Qt.Checked)
91
-			self.ccheckbox_clicked()
92
-		self.app.exec_()
93
-		self.emit("command", "quit")
94
-
95
-	def finished(self, text):
96
-		#if the continuous isn't pressed
97
-		if not self.ccheckbox.isChecked():
98
-			self.lsbutton_stopped()
99
-		self.label.setText(text)
100
-
101
-	def set_icon(self, icon):
102
-		self.window.setWindowIcon(QIcon(icon))
103
-
104
-	def set_icon_active_asset(self, i):
105
-		self.icon_active = i
106
-
107
-	def set_icon_inactive_asset(self, i):
108
-		self.icon_inactive = i
109
-
110
-	def set_icon_active(self):
111
-		self.window.setWindowIcon(QIcon(self.icon_active))
112
-
113
-	def set_icon_inactive(self):
114
-		self.window.setWindowIcon(QIcon(self.icon_inactive))
115
-

Blather.py → blather.py View File

@@ -1,7 +1,9 @@
1 1
 #!/usr/bin/env python2
2 2
 
3
+# This is part of Kaylee
3 4
 # -- this code is licensed GPLv3
4 5
 # Copyright 2013 Jezra
6
+# Copyright 2015 Clayton G. Hobbs
5 7
 
6 8
 import sys
7 9
 import signal
@@ -14,6 +16,8 @@ try:
14 16
 except:
15 17
     print "YAML is not supported. ~/.config/blather/options.yaml will not function"
16 18
 
19
+from recognizer import Recognizer
20
+
17 21
 # Where are the files?
18 22
 conf_dir = os.path.expanduser("~/.config/blather")
19 23
 lang_dir = os.path.join(conf_dir, "language")
@@ -31,7 +35,6 @@ class Blather:
31 35
 
32 36
     def __init__(self, opts):
33 37
         # Import the recognizer so Gst doesn't clobber our -h
34
-        from Recognizer import Recognizer
35 38
         self.ui = None
36 39
         self.options = {}
37 40
         ui_continuous_listen = False
@@ -51,23 +54,21 @@ class Blather:
51 54
                 self.options[k] = v
52 55
 
53 56
         if self.options['interface'] != None:
54
-            if self.options['interface'] == "q":
55
-                from QtUI import UI
56
-            elif self.options['interface'] == "g":
57
-                from GtkUI import UI
57
+            if self.options['interface'] == "g":
58
+                from gtkui import UI
58 59
             elif self.options['interface'] == "gt":
59
-                from GtkTrayUI import UI
60
+                from gtktrayui import UI
60 61
             else:
61 62
                 print "no GUI defined"
62 63
                 sys.exit()
63 64
 
64 65
             self.ui = UI(args, self.options['continuous'])
65 66
             self.ui.connect("command", self.process_command)
66
-            #can we load the icon resource?
67
+            # Can we load the icon resource?
67 68
             icon = self.load_resource("icon.png")
68 69
             if icon:
69 70
                 self.ui.set_icon_active_asset(icon)
70
-            #can we load the icon_inactive resource?
71
+            # Can we load the icon_inactive resource?
71 72
             icon_inactive = self.load_resource("icon_inactive.png")
72 73
             if icon_inactive:
73 74
                 self.ui.set_icon_inactive_asset(icon_inactive)
@@ -201,7 +202,7 @@ if __name__ == "__main__":
201 202
     parser = OptionParser()
202 203
     parser.add_option("-i", "--interface",  type="string", dest="interface",
203 204
             action='store',
204
-            help="Interface to use (if any). 'q' for Qt, 'g' for GTK, 'gt' for GTK system tray icon")
205
+            help="Interface to use (if any). 'g' for GTK or 'gt' for GTK system tray icon")
205 206
 
206 207
     parser.add_option("-c", "--continuous",
207 208
             action="store_true", dest="continuous", default=False,

GtkTrayUI.py → gtktrayui.py View File

@@ -1,3 +1,8 @@
1
+# This is part of Kaylee
2
+# -- this code is licensed GPLv3
3
+# Copyright 2013 Jezra
4
+# Copyright 2015 Clayton G. Hobbs
5
+
1 6
 import sys
2 7
 from gi.repository import GObject
3 8
 # Gtk
@@ -7,15 +12,17 @@ class UI(GObject.GObject):
7 12
     __gsignals__ = {
8 13
         'command' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_STRING,))
9 14
     }
15
+    idle_text = "Kaylee - Idle"
16
+    listening_text = "Kaylee - Listening"
10 17
 
11 18
     def __init__(self, args, continuous):
12 19
         GObject.GObject.__init__(self)
13 20
         self.continuous = continuous
14 21
 
15 22
         self.statusicon = Gtk.StatusIcon()
16
-        self.statusicon.set_title("Blather")
17
-        self.statusicon.set_name("Blather")
18
-        self.statusicon.set_tooltip_text("Blather - Idle")
23
+        self.statusicon.set_title("Kaylee")
24
+        self.statusicon.set_name("Kaylee")
25
+        self.statusicon.set_tooltip_text(self.idle_text)
19 26
         self.statusicon.set_has_tooltip(True)
20 27
         self.statusicon.connect("activate", self.continuous_toggle)
21 28
         self.statusicon.connect("popup-menu", self.popup_menu)
@@ -42,24 +49,25 @@ class UI(GObject.GObject):
42 49
         if checked:
43 50
             self.menu_listen.set_label("Listen")
44 51
             self.emit('command', "continuous_listen")
45
-            self.statusicon.set_tooltip_text("Blather - Listening")
52
+            self.statusicon.set_tooltip_text(self.listening_text)
46 53
             self.set_icon_active()
47 54
         else:
48 55
             self.set_icon_inactive()
49
-            self.statusicon.set_tooltip_text("Blather - Idle")
56
+            self.statusicon.set_tooltip_text(self.idle_text)
50 57
             self.emit('command', "continuous_stop")
51 58
 
52 59
     def toggle_listen(self, item):
53 60
         val = self.menu_listen.get_label()
54 61
         if val == "Listen":
62
+            self.set_icon_active()
55 63
             self.emit("command", "listen")
56 64
             self.menu_listen.set_label("Stop")
57
-            self.statusicon.set_tooltip_text("Blather - Listening")
65
+            self.statusicon.set_tooltip_text(self.listening_text)
58 66
         else:
59
-            self.icon_inactive()
67
+            self.set_icon_inactive()
60 68
             self.menu_listen.set_label("Listen")
61 69
             self.emit("command", "stop")
62
-            self.statusicon.set_tooltip_text("Blather - Idle")
70
+            self.statusicon.set_tooltip_text(self.idle_text)
63 71
 
64 72
     def popup_menu(self, item, button, time):
65 73
         self.menu.popup(None, None, Gtk.StatusIcon.position_menu, item, button, time)
@@ -81,8 +89,8 @@ class UI(GObject.GObject):
81 89
     def finished(self, text):
82 90
         if not self.menu_continuous.get_active():
83 91
             self.menu_listen.set_label("Listen")
84
-            self.statusicon.set_from_icon_name("blather_stopped")
85
-            self.statusicon.set_tooltip_text("Blather - Idle")
92
+            self.set_icon_inactive()
93
+            self.statusicon.set_tooltip_text(self.idle_text)
86 94
 
87 95
     def set_icon_active_asset(self, i):
88 96
         self.icon_active = i

GtkUI.py → gtkui.py View File

@@ -1,6 +1,8 @@
1
-# This is part of Blather
1
+# This is part of Kaylee
2 2
 # -- this code is licensed GPLv3
3 3
 # Copyright 2013 Jezra
4
+# Copyright 2015 Clayton G. Hobbs
5
+
4 6
 import sys
5 7
 from gi.repository import GObject
6 8
 # Gtk
@@ -18,7 +20,7 @@ class UI(GObject.GObject):
18 20
         self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
19 21
         self.window.connect("delete_event", self.delete_event)
20 22
         # Give the window a name
21
-        self.window.set_title("BlatherGtk")
23
+        self.window.set_title("Kaylee")
22 24
         self.window.set_resizable(False)
23 25
 
24 26
         layout = Gtk.VBox()

Recognizer.py → recognizer.py View File

@@ -1,6 +1,7 @@
1
-# This is part of Blather
1
+# This is part of Kaylee
2 2
 # -- this code is licensed GPLv3
3 3
 # Copyright 2013 Jezra
4
+# Copyright 2015 Clayton G. Hobbs
4 5
 
5 6
 import gi
6 7
 gi.require_version('Gst', '1.0')

Loading…
Cancel
Save