code: def setup_options_button(self):
          
          if not self.options_button:
              self.options_button = create_toolbutton(
                  self, text=_('Options'), icon=ima.icon('tooloptions'))
  
              actions = self.actions + [MENU_SEPARATOR] + self.plugin_actions
              self.options_menu = QMenu(self)
              add_actions(self.options_menu, actions)
              self.options_button.setMenu(self.options_menu)
  
          if self.tools_layout.itemAt(self.tools_layout.count() - 1) is None:
              self.tools_layout.insertWidget(
                  self.tools_layout.count() - 1, self.options_button)
          else:
              self.tools_layout.addWidget(self.options_button)
docs: Add the cog menu button to the toolbar.