The following code is a snipped of a larger codebase from a video capture and evaluating code. It is using PyQt6 for its UI. Take it step by step and extract all code from the MainWindow class that is needed for a Toolbar Class and a Action class. So it is clean up and is using common programming principles.
```python
class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        # Create a custom QLabel to display the video stream and handle mouse events
        self.video_label = VideoLabel(self)
        self.setCentralWidget(self.video_label)

        self.filepath = ""
        self.video_buffer = deque(maxlen=5)
        self.trigger_event = False
        self.remove_roi = False
        self.recording = False
        self.frame_counter = 0
        self.trigger_timestamp = 0
        self.fps_counter = FPSCounter()

        # Set up the video capture using OpenCV
        # cv2.VideoCapture(1) for real Capture card
        # TODO: add a read camerea button and list them in a dropdown box.
        self.cap = cv2.VideoCapture(
            "F:/NAME_1/FuE/FuE_E3/E32/E322/TBWILDTA/_/capture/example_video/2023-05-23 10-55-22.mkv"
        )
        # cv2.VideoCapture(1)
        if not self.cap.isOpened():
            raise RuntimeError("Failed to open the camera")

        # Set up a QTimer to update the video stream
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.update_frame)
        self.timer.start(int(1000 / 30))  # Update at 30 FPS

        toolbar = self.addToolBar("Video Tools")

        # Add Button for activate Painting rectangles
        self.paint_button = QAction(QIcon("./icons/paint.png"), "Painting Mode", self)
        self.paint_button.setShortcut("Ctrl+P")
        self.paint_button.setCheckable(True)
        self.paint_button.triggered.connect(self.video_label.toggle_drawing)
        toolbar.addAction(self.paint_button)

        # Add Remove ROI Button
        self.remove_button = QAction(QIcon("./icons/remove.png"), "Remove ROIs", self)
        self.remove_button.setShortcut("Ctrl+D")
        self.remove_button.setCheckable(True)
        self.remove_button.triggered.connect(self.video_label.toggle_remove_roi)
        toolbar.addAction(self.remove_button)

        # Add Button for start / end recording
        self.record_button = QAction(
            QIcon("./icons/record.png"), "Start Recording", self
        )
        self.record_button.setShortcut("Ctrl+R")
        self.record_button.setCheckable(True)
        self.record_button.triggered.connect( Please use JSON format in your answer.
user