Skip to content

Commit

Permalink
Add webui menu to systray, update menus
Browse files Browse the repository at this point in the history
Ref #269 Set WebUI default to None
  • Loading branch information
algorys committed Mar 8, 2018
1 parent 492d36a commit b17f3f4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
32 changes: 31 additions & 1 deletion alignak_app/qobjects/systray/tray_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

from PyQt5.Qt import QMenu, QSystemTrayIcon, QTimer, QAction, QIcon

from alignak_app.utils.config import settings
from alignak_app.utils.config import settings, open_url
from alignak_app.backend.backend import app_backend

from alignak_app.qobjects.app_main import AppQMainWindow
Expand Down Expand Up @@ -59,6 +59,7 @@ def __init__(self, icon, parent=None):
self.connection_nb = 3
self.tray_actions = {
'app': QAction(),
'webui': QAction(),
'reload': QAction(),
'about': QAction(),
'exit': QAction(),
Expand All @@ -78,13 +79,15 @@ def build_menu(self):

# Create actions
self.add_alignak_menu()
self.add_webui_menu()
self.menu.addSeparator()
self.add_reload_menu()
self.add_about_menu()
self.menu.addSeparator()
self.add_quit_menu()

self.setContextMenu(self.menu)
self.refresh_menus()

def check_connection(self):
"""
Expand All @@ -107,6 +110,7 @@ def check_connection(self):
pass

self.app_main.dock.status_widget.update_status()
self.refresh_menus()

def add_alignak_menu(self):
"""
Expand All @@ -123,6 +127,32 @@ def add_alignak_menu(self):

self.menu.addAction(self.tray_actions['app'])

def add_webui_menu(self):
"""
Create and add to menu "webui" QAction
"""

self.tray_actions['webui'].setIcon(QIcon(settings.get_image('web')))
self.tray_actions['webui'].setText(_('Go to WebUI'))
self.tray_actions['webui'].setToolTip(_('Go to Alignak WebUI'))
self.tray_actions['webui'].triggered.connect(
lambda: open_url('livestate')
)

self.menu.addAction(self.tray_actions['webui'])

def refresh_menus(self):
"""
Refresh menu if needed
"""

if settings.get_config('Alignak', 'webui'):
self.tray_actions['webui'].setEnabled(True)
else:
self.tray_actions['webui'].setEnabled(False)

def add_reload_menu(self):
"""
Create and add to menu "reload" QAction
Expand Down
2 changes: 1 addition & 1 deletion alignak_app/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Settings(object):
'password': '',
'backend': 'http://127.0.0.1:5000',
'url': 'http://127.0.0.1',
'webui': 'http://127.0.0.1:80',
'webui': '',
'processes': '1'

},
Expand Down

0 comments on commit b17f3f4

Please sign in to comment.