|  | @@ -6,6 +6,7 @@ import logging
 | 
	
		
			
			| 6 | 6 |  import os
 | 
	
		
			
			| 7 | 7 |  import sys
 | 
	
		
			
			| 8 | 8 |  
 | 
	
		
			
			|  | 9 | +import qdarkstyle
 | 
	
		
			
			| 9 | 10 |  # pylint: disable=E0611
 | 
	
		
			
			| 10 | 11 |  from PySide2.QtWidgets import (
 | 
	
		
			
			| 11 | 12 |      QAction,
 | 
	
	
		
			
			|  | @@ -147,6 +148,7 @@ class PiketMainWindow(QMainWindow):
 | 
	
		
			
			| 147 | 148 |          super().__init__()
 | 
	
		
			
			| 148 | 149 |  
 | 
	
		
			
			| 149 | 150 |          self.main_widget = None
 | 
	
		
			
			|  | 151 | +        self.dark_theme = True
 | 
	
		
			
			| 150 | 152 |          self.toolbar = None
 | 
	
		
			
			| 151 | 153 |          self.osk = None
 | 
	
		
			
			| 152 | 154 |          self.undo_action = None
 | 
	
	
		
			
			|  | @@ -171,7 +173,7 @@ class PiketMainWindow(QMainWindow):
 | 
	
		
			
			| 171 | 173 |          self.setWindowState(Qt.WindowActive | Qt.WindowFullScreen)
 | 
	
		
			
			| 172 | 174 |  
 | 
	
		
			
			| 173 | 175 |          font_metrics = self.fontMetrics()
 | 
	
		
			
			| 174 |  | -        icon_size = font_metrics.height() * 2
 | 
	
		
			
			|  | 176 | +        icon_size = font_metrics.height() * 1.45
 | 
	
		
			
			| 175 | 177 |  
 | 
	
		
			
			| 176 | 178 |          # Initialize toolbar
 | 
	
		
			
			| 177 | 179 |          self.toolbar = QToolBar()
 | 
	
	
		
			
			|  | @@ -180,8 +182,11 @@ class PiketMainWindow(QMainWindow):
 | 
	
		
			
			| 180 | 182 |  
 | 
	
		
			
			| 181 | 183 |          # Left
 | 
	
		
			
			| 182 | 184 |          self.toolbar.addAction(
 | 
	
		
			
			| 183 |  | -            self.load_icon("add_person.svg"), "Nieuw persoon", self.add_person
 | 
	
		
			
			|  | 185 | +            self.load_icon("add_person.svg"), "+ Naam", self.add_person
 | 
	
		
			
			| 184 | 186 |          )
 | 
	
		
			
			|  | 187 | +        self.toolbar.addAction(
 | 
	
		
			
			|  | 188 | +            self.load_icon("add_consumption_type.svg"), "+ Lijst",
 | 
	
		
			
			|  | 189 | +            self.add_consumption_type)
 | 
	
		
			
			| 185 | 190 |          self.undo_action = self.toolbar.addAction(
 | 
	
		
			
			| 186 | 191 |              self.load_icon("undo.svg"), "Oeps", self.do_undo
 | 
	
		
			
			| 187 | 192 |          )
 | 
	
	
		
			
			|  | @@ -194,8 +199,8 @@ class PiketMainWindow(QMainWindow):
 | 
	
		
			
			| 194 | 199 |          self.toolbar.addWidget(self.create_spacer())
 | 
	
		
			
			| 195 | 200 |  
 | 
	
		
			
			| 196 | 201 |          # Right
 | 
	
		
			
			| 197 |  | -        ag = QActionGroup(self.toolbar)
 | 
	
		
			
			| 198 |  | -        ag.setExclusive(True)
 | 
	
		
			
			|  | 202 | +        self.ct_ag = QActionGroup(self.toolbar)
 | 
	
		
			
			|  | 203 | +        self.ct_ag.setExclusive(True)
 | 
	
		
			
			| 199 | 204 |  
 | 
	
		
			
			| 200 | 205 |          cts = ConsumptionType.get_all()
 | 
	
		
			
			| 201 | 206 |          if not cts:
 | 
	
	
		
			
			|  | @@ -231,18 +236,19 @@ class PiketMainWindow(QMainWindow):
 | 
	
		
			
			| 231 | 236 |                  sys.exit()
 | 
	
		
			
			| 232 | 237 |  
 | 
	
		
			
			| 233 | 238 |          for ct in cts:
 | 
	
		
			
			| 234 |  | -            action = QAction(self.load_icon(ct.icon or "beer_bottle.svg"), ct.name, ag)
 | 
	
		
			
			|  | 239 | +            action = QAction(self.load_icon(ct.icon or "beer_bottle.svg"),
 | 
	
		
			
			|  | 240 | +                    ct.name, self.ct_ag)
 | 
	
		
			
			| 235 | 241 |              action.setCheckable(True)
 | 
	
		
			
			| 236 | 242 |              action.setData(str(ct.consumption_type_id))
 | 
	
		
			
			| 237 | 243 |  
 | 
	
		
			
			| 238 |  | -        ag.actions()[0].setChecked(True)
 | 
	
		
			
			| 239 |  | -        [self.toolbar.addAction(a) for a in ag.actions()]
 | 
	
		
			
			| 240 |  | -        ag.triggered.connect(self.consumption_type_change)
 | 
	
		
			
			|  | 244 | +        self.ct_ag.actions()[0].setChecked(True)
 | 
	
		
			
			|  | 245 | +        [self.toolbar.addAction(a) for a in self.ct_ag.actions()]
 | 
	
		
			
			|  | 246 | +        self.ct_ag.triggered.connect(self.consumption_type_change)
 | 
	
		
			
			| 241 | 247 |  
 | 
	
		
			
			| 242 | 248 |          self.addToolBar(self.toolbar)
 | 
	
		
			
			| 243 | 249 |  
 | 
	
		
			
			| 244 | 250 |          # Initialize main widget
 | 
	
		
			
			| 245 |  | -        self.main_widget = NameButtons(ag.actions()[0].data(), self)
 | 
	
		
			
			|  | 251 | +        self.main_widget = NameButtons(self.ct_ag.actions()[0].data(), self)
 | 
	
		
			
			| 246 | 252 |          self.consumption_type_changed.connect(self.main_widget.consumption_type_changed)
 | 
	
		
			
			| 247 | 253 |          self.setCentralWidget(self.main_widget)
 | 
	
		
			
			| 248 | 254 |  
 | 
	
	
		
			
			|  | @@ -289,6 +295,30 @@ class PiketMainWindow(QMainWindow):
 | 
	
		
			
			| 289 | 295 |  
 | 
	
		
			
			| 290 | 296 |              self.main_widget.init_ui()
 | 
	
		
			
			| 291 | 297 |  
 | 
	
		
			
			|  | 298 | +    def add_consumption_type(self) -> None:
 | 
	
		
			
			|  | 299 | +        self.show_keyboard()
 | 
	
		
			
			|  | 300 | +        name, ok = QInputDialog.getItem(
 | 
	
		
			
			|  | 301 | +            self,
 | 
	
		
			
			|  | 302 | +            "Lijst toevoegen",
 | 
	
		
			
			|  | 303 | +            "Wat wil je strepen?",
 | 
	
		
			
			|  | 304 | +            ["Wijn", "Radler"]
 | 
	
		
			
			|  | 305 | +        )
 | 
	
		
			
			|  | 306 | +        self.hide_keyboard()
 | 
	
		
			
			|  | 307 | +
 | 
	
		
			
			|  | 308 | +        if ok and name:
 | 
	
		
			
			|  | 309 | +            ct = ConsumptionType(name=name)
 | 
	
		
			
			|  | 310 | +            ct = ct.create()
 | 
	
		
			
			|  | 311 | +
 | 
	
		
			
			|  | 312 | +            action = QAction(
 | 
	
		
			
			|  | 313 | +                self.load_icon(ct.icon or "beer_bottle.svg"),
 | 
	
		
			
			|  | 314 | +                ct.name,
 | 
	
		
			
			|  | 315 | +                self.ct_ag
 | 
	
		
			
			|  | 316 | +            )
 | 
	
		
			
			|  | 317 | +            action.setCheckable(True)
 | 
	
		
			
			|  | 318 | +            action.setData(str(ct.consumption_type_id))
 | 
	
		
			
			|  | 319 | +
 | 
	
		
			
			|  | 320 | +            self.toolbar.addAction(action)
 | 
	
		
			
			|  | 321 | +
 | 
	
		
			
			| 292 | 322 |      def confirm_quit(self) -> None:
 | 
	
		
			
			| 293 | 323 |          """ Ask for confirmation that the user wishes to quit, then do so. """
 | 
	
		
			
			| 294 | 324 |          ok = QMessageBox.warning(
 | 
	
	
		
			
			|  | @@ -328,6 +358,7 @@ class PiketMainWindow(QMainWindow):
 | 
	
		
			
			| 328 | 358 |          self.undo_queue.append(consumption)
 | 
	
		
			
			| 329 | 359 |          self.undo_action.setDisabled(False)
 | 
	
		
			
			| 330 | 360 |  
 | 
	
		
			
			|  | 361 | +
 | 
	
		
			
			| 331 | 362 |      @staticmethod
 | 
	
		
			
			| 332 | 363 |      def create_spacer() -> QWidget:
 | 
	
		
			
			| 333 | 364 |          """ Return an empty QWidget that automatically expands. """
 | 
	
	
		
			
			|  | @@ -337,17 +368,21 @@ class PiketMainWindow(QMainWindow):
 | 
	
		
			
			| 337 | 368 |  
 | 
	
		
			
			| 338 | 369 |      icons_dir = os.path.join(os.path.dirname(__file__), "icons")
 | 
	
		
			
			| 339 | 370 |  
 | 
	
		
			
			| 340 |  | -    @classmethod
 | 
	
		
			
			| 341 |  | -    def load_icon(cls, filename: str) -> QIcon:
 | 
	
		
			
			|  | 371 | +    def load_icon(self, filename: str) -> QIcon:
 | 
	
		
			
			| 342 | 372 |          """ Return a QtIcon loaded from the given `filename` in the icons
 | 
	
		
			
			| 343 | 373 |          directory. """
 | 
	
		
			
			| 344 | 374 |  
 | 
	
		
			
			| 345 |  | -        return QIcon(os.path.join(cls.icons_dir, filename))
 | 
	
		
			
			|  | 375 | +        if self.dark_theme:
 | 
	
		
			
			|  | 376 | +            filename = 'white_' + filename
 | 
	
		
			
			|  | 377 | +
 | 
	
		
			
			|  | 378 | +        icon = QIcon(os.path.join(self.icons_dir, filename))
 | 
	
		
			
			|  | 379 | +        return icon
 | 
	
		
			
			| 346 | 380 |  
 | 
	
		
			
			| 347 | 381 |  
 | 
	
		
			
			| 348 | 382 |  def main() -> None:
 | 
	
		
			
			| 349 | 383 |      """ Main entry point of GUI client. """
 | 
	
		
			
			| 350 | 384 |      app = QApplication(sys.argv)
 | 
	
		
			
			|  | 385 | +    app.setStyleSheet(qdarkstyle.load_stylesheet_pyside2())
 | 
	
		
			
			| 351 | 386 |      font = app.font()
 | 
	
		
			
			| 352 | 387 |      size = font.pointSize()
 | 
	
		
			
			| 353 | 388 |      font.setPointSize(size * 1.75)
 |