CommandBar Example

import sys

from DevMachines import __pyside2__, __pyside6__
from DevMachines import QtitanBase
from DevMachines.QtitanBase import Qtitan
from DevMachines.QtitanStyle import ColorizedStyle
from DevMachines.QtitanNavigationDesignUI import (NavigationMainWindow, NavigationBar, NavigationBackstageMenu,
                                  NavigationMainMenu, NavigationSearchWidget, NavigationSidePane, WindowsColor)

if __pyside2__:
    from PySide2 import QtCore
    from PySide2.QtCore import Qt, QUrl
    from PySide2.QtGui import QPainter, QPixmap, QIcon, QColor, QDesktopServices
    from PySide2.QtWidgets import QApplication, QLabel, QMessageBox

if __pyside6__:
    from PySide6 import QtCore
    from PySide6.QtCore import Qt, QUrl
    from PySide6.QtGui import QPainter, QPixmap, QIcon, QColor, QDesktopServices
    from PySide6.QtWidgets import QApplication, QLabel, QMessageBox

from settings import SettingsWidget

import CommandBar_rc

class Window(NavigationMainWindow):
    def __init__(self):
        NavigationMainWindow.__init__(self)
        self.setWindowTitle("NavigationBar Application")
        self.setGeometry(100, 100, 1500, 600)

        #navigationStatusBar = self.statusBar()

        action = self.navigationBar().addSystemButton()
        self.connect(action, QtCore.SIGNAL("triggered()"), self.systemButtonClicked)

        action = self.navigationBar().addLogoButton(QIcon(":res/logo_50.png"))
        button = self.navigationBar().buttonByAction(action)
        button.setDescription("Logo", self.tr("CRM - Navigation menu example."))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.showCompanyWebSite)
        self.navigationBar().addSeparator()

        mainMenu = NavigationMainMenu(self.navigationBar())
        action = self.navigationBar().addMainMenuButton(mainMenu)
        button = self.navigationBar().buttonByAction(action)
        button.setDescription("Main", self.tr("Show work areas."));

        projectServiceMenu = self.createProjectServiceMenu()

        mainMenu.addItem(QIcon(":res/tile_icon_service_85x71.png"), self.tr("Project Service"), QColor("#2D74EA"), projectServiceMenu)
        mainMenu.addItem(QIcon(":res/tile_icon_settings_85x71.png"), self.tr("Settings"))
        mainMenu.addItem(QIcon(":res/tile_icon_help_85x71.png"), self.tr("Help Center"))

        action = self.navigationBar().addAction(QIcon(), self.tr("Project Service"), projectServiceMenu)
        self.connect(action, QtCore.SIGNAL("triggered()"), self.toolButtonClicked)

        menu2 = NavigationBackstageMenu(self.navigationBar())
        action = self.navigationBar().addAction(QIcon(), self.tr("Dashboards"), menu2)
        self.connect(action, QtCore.SIGNAL("triggered()"), self.toolButtonClicked)

        action = self.navigationBar().addAction(NavigationBar.MRU)
        self.connect(action, QtCore.SIGNAL("triggered()"), self.toolButtonClicked)
        button = self.navigationBar().buttonByAction(action)
        button.setAlignment(Qt.AlignRight)

        action = self.navigationBar().addAction(NavigationBar.New)
        self.connect(action, QtCore.SIGNAL("triggered()"), self.toolButtonClicked)
        button = self.navigationBar().buttonByAction(action)
        button.setAlignment(Qt.AlignRight)

        searchWidget = NavigationSearchWidget()
        action = self.navigationBar().addWidget(searchWidget, QPixmap(":res/users_icon_off.png"))
        button = self.navigationBar().buttonByAction(action)
        button.setAlignment(Qt.AlignRight)

        action = self.navigationBar().addAction(NavigationBar.Question)
        self.connect(action, QtCore.SIGNAL("triggered()"), self.toolButtonClicked)

        action.setCheckable(True)
        button = self.navigationBar().buttonByAction(action)
        button.setAlignment(Qt.AlignRight)

        label = QLabel()
        label.setTextFormat(Qt.RichText)
        label.setText("Jim <b>Glynn</b>")
        action = self.navigationBar().addWidget(label, QPixmap(":res/user_icon.png"))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.toolButtonClicked)
        button = self.navigationBar().buttonByAction(action)
        button.setAlignment(Qt.AlignRight)

        settingsPane = NavigationSidePane(self.navigationBar())
        settingsPane.setWidget(SettingsWidget(self))

        action = self.navigationBar().addAction(NavigationBar.Settings, "", settingsPane)
        action.setCheckable(True)
        button = self.navigationBar().buttonByAction(action)
        button.setAlignment(Qt.AlignRight)
        button.setDescription("Settings", self.tr("Customize the application."))

        helpPane = NavigationSidePane(self.navigationBar())
        helpPane.setWidget(self.createHelpWidget())
        action = self.navigationBar().addHelpButton(helpPane)
        button = self.navigationBar().buttonByAction(action)
        button.setDescription("Help", self.tr("Find help and training."))

        self.titleBar().setSysButtonKind(QtitanBase.WindowTitleBar.SysButtonHidden)
        self.titleBar().setBlurBehindWindowEnabled(True)
        #self.titleBar().setExtendViewIntoTitleBar(True)
        self.titleBar().setVisible(True)

    def createProjectServiceMenu(self):
        projectServiceMenu = NavigationBackstageMenu(self.navigationBar())

        action = projectServiceMenu.addAction(self.tr("My Work"), QPixmap(":res/menu_item_icon_18.png"), self.tr("Dashboards"), WindowsColor(WindowsColor.MetroUI_KleinBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("My Work"), QPixmap(":res/menu_item_icon_2.png"), self.tr("Booking and Tasks"), WindowsColor(WindowsColor.MetroUI_Cardinal))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("My Work"), QPixmap(":res/menu_item_icon_1.png"), self.tr("Time Entries"), WindowsColor(WindowsColor.MetroUI_Chocolate))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("My Work"), QPixmap(":res/menu_item_icon_8.png"), self.tr("Expenses"), WindowsColor(WindowsColor.MetroUI_Chocolate))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("My Work"), QPixmap(":res/menu_item_icon_13.png"), self.tr("Project Approvals"), WindowsColor(WindowsColor.MetroUI_Chocolate))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)

        action = projectServiceMenu.addAction(self.tr("Customers"), QPixmap(":res/menu_item_icon_19.png"), self.tr("Customers"));
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Customers"), QPixmap(":res/menu_item_icon_20.png"), self.tr("Contacts"));
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)

        action = projectServiceMenu.addAction(self.tr("Sales"), QPixmap(":res/menu_item_icon_21.png"), self.tr("Leads"), WindowsColor(WindowsColor.MetroUI_NavyBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Sales"), QPixmap(":res/menu_item_icon_22.png"), self.tr("Opportunities"), WindowsColor(WindowsColor.MetroUI_GreenHouse))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Sales"), QPixmap(":res/menu_item_icon_8.png"), self.tr("Quotes"), WindowsColor(WindowsColor.MetroUI_KleinBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)

        action = projectServiceMenu.addAction(self.tr("Planning and Delivery"), QPixmap(":res/menu_item_icon_23.png"), self.tr("Projects"), WindowsColor(WindowsColor.MetroUI_VidaLoca))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Planning and Delivery"), QPixmap(":res/menu_item_icon_23.png"), self.tr("Project Templates"), WindowsColor(WindowsColor.MetroUI_VidaLoca))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Planning and Delivery"), QPixmap(":res/menu_item_icon_12.png"), self.tr("Project Contracts"), WindowsColor(WindowsColor.MetroUI_KleinBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Planning and Delivery"), QPixmap(":res/menu_item_icon_12.png"), self.tr("Project Contract Milestones"), WindowsColor(WindowsColor.MetroUI_VidaLoca))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)

        action = projectServiceMenu.addAction(self.tr("Billing"), QPixmap(":res/menu_item_icon_5.png"), self.tr("Invoices"), WindowsColor(WindowsColor.MetroUI_Chocolate))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Billing"), QPixmap(":res/menu_item_icon_12.png"), self.tr("Actuals"), WindowsColor(WindowsColor.MetroUI_Chocolate))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Billing"), QPixmap(":res/menu_item_icon_10.png"), self.tr("Journals"), WindowsColor(WindowsColor.MetroUI_Chocolate))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)

        action = projectServiceMenu.addAction(self.tr("Resources"), QPixmap(":res/menu_item_icon_4.png"), self.tr("Resource Availability"), WindowsColor(WindowsColor.MetroUI_NavyBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Resources"), QPixmap(":res/menu_item_icon_4.png"), self.tr("Resource Utilization"), WindowsColor(WindowsColor.MetroUI_NavyBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Resources"), QPixmap(":res/menu_item_icon_4.png"), self.tr("Resource Requests"), WindowsColor(WindowsColor.MetroUI_NavyBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Resources"), QPixmap(":res/menu_item_icon_14.png"), self.tr("Resources"), WindowsColor(WindowsColor.MetroUI_KleinBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)

        action = projectServiceMenu.addAction(self.tr("Tools"), QPixmap(":res/menu_item_icon_24.png"), self.tr("Reports"), WindowsColor(WindowsColor.MetroUI_KleinBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Tools"), QPixmap(":res/menu_item_icon_25.png"), self.tr("Data Exports"), WindowsColor(WindowsColor.MetroUI_Watercourse))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)

        action = projectServiceMenu.addAction(self.tr("Settings"), QPixmap(":res/menu_item_icon_3.png"), self.tr("Organizational Utils"), WindowsColor(WindowsColor.MetroUI_Watercourse))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Settings"), QPixmap(":res/menu_item_icon_15.png"), self.tr("Resource Roles"), WindowsColor(WindowsColor.MetroUI_KleinBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Settings"), QPixmap(":res/menu_item_icon_16.png"), self.tr("Resource Skills"), WindowsColor(WindowsColor.MetroUI_KleinBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Settings"), QPixmap(":res/menu_item_icon_17.png"), self.tr("Proficiency Models"), WindowsColor(WindowsColor.MetroUI_KleinBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Settings"), QPixmap(":res/menu_item_icon_7.png"), self.tr("Work Hours Tempates"), WindowsColor(WindowsColor.MetroUI_VidaLoca))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr("Settings"), QPixmap(":res/menu_item_icon_6.png"), self.tr("Parameters"), WindowsColor(WindowsColor.MetroUI_Matterhorn))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)

        action = projectServiceMenu.addAction(self.tr(""), QPixmap(":res/menu_item_icon_6.png"), self.tr("Transaction Categories"), WindowsColor(WindowsColor.MetroUI_Matterhorn))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr(""), QPixmap(":res/menu_item_icon_6.png"), self.tr("Expense Categories"), WindowsColor(WindowsColor.MetroUI_Matterhorn))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr(""), QPixmap(":res/menu_item_icon_5.png"), self.tr("Invoice Frequencies"), WindowsColor(WindowsColor.MetroUI_Chocolate))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr(""), QPixmap(":res/menu_item_icon_11.png"), self.tr("Price Lists"), WindowsColor(WindowsColor.MetroUI_KleinBlue))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        action = projectServiceMenu.addAction(self.tr(""), QPixmap(":res/menu_item_icon_25.png"), self.tr("Batch Jobs"), WindowsColor(WindowsColor.MetroUI_Watercourse))
        self.connect(action, QtCore.SIGNAL("triggered()"), self.projectServiceMenuItemClicked)
        return projectServiceMenu

    def create_link(self, link, text):
        ret = "<a style=\"text-decoration:underline;\" href=\"" + link + "\">" + text + "</a>"
        return ret

    def createHelpWidget(self):
        label = QLabel()
        html = self.create_link("#", "Help Topics")
        html += "<br><br>"
        html += self.create_link("#", "Feedback")
        html += "<br><br>"
        html += self.create_link("#", "Community")
        html += "<br><br>"
        html += self.create_link("#", "Legal Information")
        html += "<br><br>"
        html += self.create_link("#", "Privacy and cookie")
        html += "<br><br>"
        label.setText(html)
        return label

    def paintEvent(self, event):
        NavigationMainWindow.paintEvent(self, event)

    @QtCore.Slot()
    def systemButtonClicked(self):
        QMessageBox.information(self, self.tr("NavigationBar"), self.tr("Navigation System Button clicked"))

    @QtCore.Slot()
    def toolButtonClicked(self):
        action = self.sender()
        QMessageBox.information(self, self.tr("NavigationBar"), self.tr("NavigationToolButton clicked: ") + action.text())

    @QtCore.Slot()
    def showCompanyWebSite(self):
        QDesktopServices.openUrl(QUrl("https://www.devmachines.com"))

    @QtCore.Slot()
    def projectServiceMenuItemClicked(self):
        action = self.sender()
        QMessageBox.information(self, self.tr("NavigationBarMenu"), self.tr("NavigationMenuItem clicked: ") + action.text())

if __name__ == "__main__":
    app = QApplication(sys.argv)
    style = ColorizedStyle()
    app.setStyle(style)
    w = Window()
    w.show()
    sys.exit(app.exec_())