def initialize(self, title, text): """ Initialize QDialog for UserNotesQDialog :param title: title of the QDialog :type title: str :param text: text to edit :type text: str """ self.old_text = text center_widget(self) # Main status_layout main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout) main_layout.addWidget(get_logo_widget(self, title)) text_title = QLabel(_("Edit your text:")) text_title.setObjectName('subtitle') main_layout.addWidget(text_title) main_layout.setAlignment(text_title, Qt.AlignCenter) main_layout.addWidget(self.get_text_widget())
def initialize(self): """ Initialize History QWidget """ main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) # Title Window main_layout.addWidget(get_logo_widget(self, _('History'))) # History QWidget history_widget = QWidget() history_layout = QVBoxLayout(history_widget) # History QTableWidget self.history_table.setObjectName('history') self.history_table.verticalHeader().hide() self.history_table.verticalHeader().setDefaultSectionSize(100) self.history_table.setColumnCount(len(self.table_headers)) self.history_table.setColumnWidth(0, 600) self.history_table.setSortingEnabled(True) self.history_table.setHorizontalScrollMode(QAbstractItemView.ScrollPerItem) self.history_table.setHorizontalHeaderLabels(self.table_headers) self.history_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.history_table.horizontalHeader().setStretchLastSection(True) self.history_table.horizontalHeader().setMinimumHeight(30) history_layout.addWidget(self.history_table) main_layout.addWidget(history_widget) center_widget(self)
def initialize(self, item_type, options): """ Initialize QDialog with App widget logo and options QWidget :param item_type: define item type for options: host or service :type item_type: str :param options: list of notification options :type options: list """ center_widget(self) # Main status_layout main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout) # QDialog title titles = { 'host': _('Host Notifications'), 'service': _('Service Notifications') } main_layout.addWidget(get_logo_widget(self, titles[item_type])) # Notification QWidget main_layout.addWidget(self.get_notifications_widget( item_type, options))
def initialize(self): """ Initialize User QWidget """ main_layout = QVBoxLayout(self) self.setLayout(main_layout) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(get_logo_widget(self, _('User View'))) user_widget = QWidget(self) user_layout = QGridLayout(user_widget) user_title = QLabel(_('User informations:')) user_title.setObjectName('itemtitle') user_layout.addWidget(user_title, 0, 0, 1, 2) user_layout.setAlignment(user_title, Qt.AlignCenter) # User QWidgets user_layout.addWidget(self.get_informations_widget(), 1, 0, 1, 1) user_layout.addWidget(self.get_notes_mail_widget(), 1, 1, 1, 1) user_layout.addWidget(self.get_notifications_widget(), 2, 0, 1, 2) main_layout.addWidget(user_widget) center_widget(self)
def test_center_widget(self): """Center QWidget""" under_test = LogoQWidget() old_pos = under_test.pos() center_widget(under_test) new_pos = under_test.pos() self.assertNotEqual(old_pos, new_pos)
def initialize_dialog(self): """ Initialize Server QDialog """ main_layout = QVBoxLayout() main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout) main_layout.addWidget(get_logo_widget(self, _('Alignak Settings'))) main_layout.addWidget(self.get_settings_widget()) center_widget(self)
def initialize_dialog(self): """ Initialize Proxy QDialog """ main_layout = QVBoxLayout() main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout) main_layout.addWidget(get_logo_widget(self, _('Proxy Settings'))) main_layout.addWidget(self.get_proxy_widget()) center_widget(self)
def initialize(self): """ Initialize QDialog for PasswordDialog """ center_widget(self) # Main status_layout main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout) main_layout.addWidget(get_logo_widget(self, _('Edit Password'))) pass_title = QLabel(_("Please type a new PASSWORD:"******"Your password must contain at least 5 characters.")) self.help_label.setWordWrap(True) pass_layout.addWidget(self.help_label) # Accept button accept_btn = QPushButton('Confirm', self) accept_btn.clicked.connect(self.handle_confirm) accept_btn.setObjectName('valid') accept_btn.setMinimumHeight(30) pass_layout.addWidget(accept_btn) main_layout.addWidget(pass_widget)
def initialize(self): """ Initialize QMainWindow for App """ logger.info('Display Alignak-App...') app_widget = QWidget() app_widget.setObjectName('dialog') app_layout = QGridLayout() app_layout.setContentsMargins(0, 0, 0, 0) app_widget.setLayout(app_layout) # Logo widget app_layout.addWidget(get_logo_widget(self, 'Alignak-App'), 0, 0, 1, 3) # Panel self.panel_widget.initialize() app_layout.addWidget(self.panel_widget, 1, 0, 1, 1) app_layout.addWidget(get_frame_separator(True), 1, 1, 1, 1) # Dock self.dock.initialize() app_layout.addWidget(self.dock, 1, 2, 1, 1) self.setCentralWidget(app_widget) self.setMinimumSize(1440, 900) center_widget(self) display = settings.get_config('Alignak-app', 'display') if "min" in display: self.show() elif "max" in display: self.showMaximized() else: pass if settings.get_config('Alignak-app', 'problems', boolean=True): self.panel_widget.tab_widget.setCurrentIndex( self.panel_widget.tab_widget.indexOf( self.panel_widget.problems_widget)) self.panel_widget.problems_widget.line_search.setFocus() else: self.panel_widget.synthesis_widget.line_search.setFocus()
def initialize(self): """ Initialize QMainWindow for App """ logger.info('Display Alignak-App...') app_widget = QWidget() app_widget.setObjectName('dialog') app_layout = QGridLayout() app_layout.setContentsMargins(0, 0, 0, 0) app_widget.setLayout(app_layout) # Logo widget app_layout.addWidget(get_logo_widget(self, 'Alignak-App'), 0, 0, 1, 3) # Panel self.panel_widget.initialize() app_layout.addWidget(self.panel_widget, 1, 0, 1, 1) app_layout.addWidget(get_frame_separator(True), 1, 1, 1, 1) # Dock self.dock.initialize() app_layout.addWidget(self.dock, 1, 2, 1, 1) self.setCentralWidget(app_widget) self.setMinimumSize(1440, 900) center_widget(self) display = settings.get_config('Alignak-app', 'display') if "min" in display: self.show() elif "max" in display: self.showMaximized() else: pass if settings.get_config('Alignak-app', 'problems', boolean=True): self.panel_widget.tab_widget.setCurrentIndex( self.panel_widget.tab_widget.indexOf(self.panel_widget.problems_widget) ) self.panel_widget.problems_widget.line_search.setFocus() else: self.panel_widget.synthesis_widget.line_search.setFocus()
def initialize(self): """ Initialize QDialog """ main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(get_logo_widget(self, _('User View'))) # Daemons QWidget daemons_widget = QWidget(self) daemons_widget.setLayout(self.daemons_layout) daemons = data_manager.database['alignakdaemon'] # Init QLabels self.init_daemons_labels(daemons) # Add daemons label line = 0 self.add_daemon_titles_labels(line) for daemon_item in daemons: line += 1 self.add_daemon_labels(daemon_item, line) line += 1 # Ok QPushButton ok_btn = QPushButton(_('OK')) ok_btn.setObjectName('ok') ok_btn.setFixedSize(120, 30) ok_btn.clicked.connect(self.accept) self.daemons_layout.addWidget(ok_btn, line, 0, 1, 7) self.daemons_layout.setAlignment(ok_btn, Qt.AlignCenter) main_layout.addWidget(daemons_widget) center_widget(self)
def initialize(self, widgettitle, dialog, title, text): """ Initialize QDialog for PasswordDialog :param widgettitle: title of the QDialog :type widgettitle: str :param dialog: type of dialog ('text' or 'error') :type dialog: str :param title: title of text to display :type title: str :param text: text to display :type text: str """ center_widget(self) # Main status_layout main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout) main_layout.addWidget(get_logo_widget(self, widgettitle)) main_layout.addWidget(self.get_message_widget(dialog, title, text))
def initialize(self, item_type, options): """ Initialize QDialog with App widget logo and options QWidget :param item_type: define item type for options: host or service :type item_type: str :param options: list of notification options :type options: list """ center_widget(self) # Main status_layout main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(main_layout) # QDialog title titles = {'host': _('Host Notifications'), 'service': _('Service Notifications')} main_layout.addWidget(get_logo_widget(self, titles[item_type])) # Notification QWidget main_layout.addWidget(self.get_notifications_widget(item_type, options))
def initialize(self, item_type, item_name, comment): # pylint: disable=too-many-locals """ Initialize Acknowledge QDialog :param item_type: type of item to acknowledge : host | service :type item_type: str :param item_name: name of the item to acknowledge :type item_name: str :param comment: the default comment of action :type comment: str """ logger.debug("Create Acknowledge QDialog...") # Main status_layout center_widget(self) main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(get_logo_widget(self, _('Request Acknowledge'))) ack_widget = QWidget() ack_widget.setObjectName('dialog') ack_layout = QGridLayout(ack_widget) ack_title = QLabel(_('Request an acknowledge')) ack_title.setObjectName('itemtitle') ack_layout.addWidget(ack_title, 0, 0, 1, 2) host_label = QLabel('<b>%s:</b> %s' % (item_type.capitalize(), item_name)) ack_layout.addWidget(host_label, 1, 0, 1, 1) sticky_label = QLabel(_('Acknowledge is sticky:')) sticky_label.setObjectName('subtitle') ack_layout.addWidget(sticky_label, 2, 0, 1, 1) self.sticky_toggle_btn.initialize() self.sticky_toggle_btn.update_btn_state(self.sticky) ack_layout.addWidget(self.sticky_toggle_btn, 2, 1, 1, 1) sticky_info = QLabel( _( 'If checked, ' 'the acknowledge will remain until the element returns to an "OK" state.' ) ) sticky_info.setWordWrap(True) ack_layout.addWidget(sticky_info, 3, 0, 1, 2) notify_label = QLabel(_('Acknowledge notifies:')) notify_label.setObjectName('subtitle') ack_layout.addWidget(notify_label, 4, 0, 1, 1) self.notify_toggle_btn.initialize() self.notify_toggle_btn.update_btn_state(self.notify) ack_layout.addWidget(self.notify_toggle_btn, 4, 1, 1, 1) notify_info = QLabel( _('If checked, a notification will be sent out to the concerned contacts.') ) notify_info.setWordWrap(True) ack_layout.addWidget(notify_info, 5, 0, 1, 2) ack_comment = QLabel(_('Acknowledge comment:')) ack_comment.setObjectName('subtitle') ack_layout.addWidget(ack_comment, 6, 0, 1, 1) self.ack_comment_edit = QTextEdit() self.ack_comment_edit.setText(comment) self.ack_comment_edit.setMaximumHeight(60) ack_layout.addWidget(self.ack_comment_edit, 7, 0, 1, 2) request_btn = QPushButton(_('REQUEST ACKNOWLEDGE'), self) request_btn.clicked.connect(self.accept) request_btn.setObjectName('valid') request_btn.setMinimumHeight(30) request_btn.setDefault(True) ack_layout.addWidget(request_btn, 8, 0, 1, 2) main_layout.addWidget(ack_widget)
def initialize(self, item_type, item_name, comment): # pylint: disable=too-many-locals """ Initialize Acknowledge QDialog :param item_type: type of item to acknowledge : host | service :type item_type: str :param item_name: name of the item to acknowledge :type item_name: str :param comment: the default comment of action :type comment: str """ logger.debug("Create Acknowledge QDialog...") # Main status_layout center_widget(self) main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(get_logo_widget(self, _('Request Acknowledge'))) ack_widget = QWidget() ack_widget.setObjectName('dialog') ack_layout = QGridLayout(ack_widget) ack_title = QLabel(_('Request an acknowledge')) ack_title.setObjectName('itemtitle') ack_layout.addWidget(ack_title, 0, 0, 1, 2) host_label = QLabel('<b>%s:</b> %s' % (item_type.capitalize(), item_name)) ack_layout.addWidget(host_label, 1, 0, 1, 1) sticky_label = QLabel(_('Acknowledge is sticky:')) sticky_label.setObjectName('subtitle') ack_layout.addWidget(sticky_label, 2, 0, 1, 1) self.sticky_toggle_btn.initialize() self.sticky_toggle_btn.update_btn_state(self.sticky) ack_layout.addWidget(self.sticky_toggle_btn, 2, 1, 1, 1) sticky_info = QLabel( _('If checked, ' 'the acknowledge will remain until the element returns to an "OK" state.' )) sticky_info.setWordWrap(True) ack_layout.addWidget(sticky_info, 3, 0, 1, 2) notify_label = QLabel(_('Acknowledge notifies:')) notify_label.setObjectName('subtitle') ack_layout.addWidget(notify_label, 4, 0, 1, 1) self.notify_toggle_btn.initialize() self.notify_toggle_btn.update_btn_state(self.notify) ack_layout.addWidget(self.notify_toggle_btn, 4, 1, 1, 1) notify_info = QLabel( _('If checked, a notification will be sent out to the concerned contacts.' )) notify_info.setWordWrap(True) ack_layout.addWidget(notify_info, 5, 0, 1, 2) ack_comment = QLabel(_('Acknowledge comment:')) ack_comment.setObjectName('subtitle') ack_layout.addWidget(ack_comment, 6, 0, 1, 1) self.ack_comment_edit = QTextEdit() self.ack_comment_edit.setText(comment) self.ack_comment_edit.setMaximumHeight(60) ack_layout.addWidget(self.ack_comment_edit, 7, 0, 1, 2) request_btn = QPushButton(_('REQUEST ACKNOWLEDGE'), self) request_btn.clicked.connect(self.accept) request_btn.setObjectName('valid') request_btn.setMinimumHeight(30) request_btn.setDefault(True) ack_layout.addWidget(request_btn, 8, 0, 1, 2) main_layout.addWidget(ack_widget)
def initialize(self, item_type, item_name, comment): # pylint: disable=too-many-locals """ Initialize Downtime QDialog :param item_type: type of item to acknowledge : host | service :type item_type: str :param item_name: name of the item to acknowledge :type item_name: str :param comment: the default comment of action :type comment: str """ logger.debug("Create Downtime QDialog...") # Main status_layout center_widget(self) main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(get_logo_widget(self, _('Request Downtime'))) downtime_widget = QWidget() downtime_widget.setObjectName('dialog') downtime_layout = QGridLayout(downtime_widget) downtime_title = QLabel(_('Request a downtime')) downtime_title.setObjectName('itemtitle') downtime_layout.addWidget(downtime_title, 0, 0, 1, 3) host_label = QLabel('<b>%s:</b> %s' % (item_type.capitalize(), item_name)) downtime_layout.addWidget(host_label, 1, 0, 1, 1) options_label = QLabel(_('Downtime options:')) options_label.setObjectName('subtitle') downtime_layout.addWidget(options_label, 2, 0, 1, 1) self.fixed_toggle_btn.initialize() self.fixed_toggle_btn.update_btn_state(self.fixed) downtime_layout.addWidget(self.fixed_toggle_btn, 2, 1, 1, 1) fixed_label = QLabel(_('Fixed')) downtime_layout.addWidget(fixed_label, 2, 2, 1, 1) fixed_info = QLabel( _('If checked, downtime will start and end at the times specified' ' by the “start time” and “end time” fields.')) fixed_info.setWordWrap(True) downtime_layout.addWidget(fixed_info, 3, 0, 1, 3) duration_label = QLabel(_('Duration')) duration_label.setObjectName('subtitle') downtime_layout.addWidget(duration_label, 4, 0, 1, 1) duration_clock = QLabel() duration_clock.setPixmap(QPixmap(settings.get_image('time'))) downtime_layout.addWidget(duration_clock, 4, 1, 1, 1) duration_clock.setFixedSize(16, 16) duration_clock.setScaledContents(True) self.duration.setTime(QTime(4, 00)) self.duration.setDisplayFormat("HH'h'mm") downtime_layout.addWidget(self.duration, 4, 2, 1, 1) duration_info = QLabel( _('Sets the duration if it is a non-fixed downtime.')) downtime_layout.addWidget(duration_info, 5, 0, 1, 3) date_range_label = QLabel(_('Downtime date range')) date_range_label.setObjectName('subtitle') downtime_layout.addWidget(date_range_label, 6, 0, 1, 1) calendar_label = QLabel() calendar_label.setPixmap(QPixmap(settings.get_image('calendar'))) calendar_label.setFixedSize(16, 16) calendar_label.setScaledContents(True) downtime_layout.addWidget(calendar_label, 6, 1, 1, 1) start_time_label = QLabel(_('Start time:')) downtime_layout.addWidget(start_time_label, 7, 0, 1, 1) self.start_time.setCalendarPopup(True) self.start_time.setDateTime(datetime.datetime.now()) self.start_time.setDisplayFormat("dd/MM/yyyy HH'h'mm") downtime_layout.addWidget(self.start_time, 7, 1, 1, 2) end_time_label = QLabel(_('End time:')) downtime_layout.addWidget(end_time_label, 8, 0, 1, 1) self.end_time.setCalendarPopup(True) self.end_time.setDateTime(datetime.datetime.now() + datetime.timedelta(hours=2)) self.end_time.setDisplayFormat("dd/MM/yyyy HH'h'mm") downtime_layout.addWidget(self.end_time, 8, 1, 1, 2) self.comment_edit.setText(comment) self.comment_edit.setMaximumHeight(60) downtime_layout.addWidget(self.comment_edit, 9, 0, 1, 3) request_btn = QPushButton(_('REQUEST DOWNTIME'), self) request_btn.clicked.connect(self.handle_accept) request_btn.setObjectName('valid') request_btn.setMinimumHeight(30) request_btn.setDefault(True) downtime_layout.addWidget(request_btn, 10, 0, 1, 3) main_layout.addWidget(downtime_widget)
def start(self, username=None, password=None): """ Start Alignak-app """ settings.init_config() settings.init_css() init_localization() # Logger global logger # pylint: disable=global-statement logger = create_logger() logger.name = 'alignak_app.app' if settings.get_config('Log', 'debug', boolean=True): logger.setLevel(DEBUG) else: logger.setLevel(INFO) logger.info('\n') logger.info('----- Alignak-App START -----') logger.info('- Running Version : "%s"', __version__) logger.info('- Alignak-App Env :') logger.info('[ALIGNAKAPP_APP_DIR] = %s', os.environ['ALIGNAKAPP_APP_DIR']) logger.info('[ALIGNAKAPP_USR_DIR] = %s', os.environ['ALIGNAKAPP_USR_DIR']) logger.info('[ALIGNAKAPP_LOG_DIR] = %s', os.environ['ALIGNAKAPP_LOG_DIR']) logger.info('- Config File : %s', settings.settings['settings']) logger.info('- Debug Activate : %s', settings.get_config('Log', 'debug', boolean=True)) logger.info('- Alignak Backend : %s', settings.get_config('Alignak', 'backend')) app = QApplication(sys.argv) app.setQuitOnLastWindowClosed(False) # Connection to Backend proxies = None if settings.get_config('Alignak', 'username') and not username and not password: username = settings.get_config('Alignak', 'username') password = settings.get_config('Alignak', 'password') if settings.get_config('Alignak', 'proxy'): try: # Model is: {'protocol': 'http://proxy:port'} proxies = { settings.get_config('Alignak', 'proxy').split(':')[0]: settings.get_config('Alignak', 'proxy') } except ValueError: self.show_login_window() # If Proxy user, display login window to let user enter password if settings.get_config('Alignak', 'proxy_user') and \ not settings.get_config('Alignak', 'proxy_password'): self.show_login_window() # Try login else display login window logger.info('- Proxy settings : %s', proxies) if not app_backend.login(username, password, proxies=proxies): self.show_login_window() # Create Progress Bar app_progress = AppProgressQWidget() app_progress.initialize() center_widget(app_progress) logger.info("Preparing DataManager...") while not data_manager.ready: thread_manager.launch_threads() app_progress.show() for _ in range(0, 100): t = time.time() while time.time() < t + 0.01: status = data_manager.is_ready() app_progress.progress_bar.set_text('%s' % status) app.processEvents() app_progress.close() init_event_widget() requests_interval = int( settings.get_config('Alignak-app', 'requests_interval')) * 1000 self.threadmanager_timer.setInterval(requests_interval) self.threadmanager_timer.start() self.threadmanager_timer.timeout.connect(self.check_threads) self.tray_icon = AppTrayIcon(QIcon(settings.get_image('icon'))) self.tray_icon.build_menu() self.tray_icon.show() sys.exit(app.exec_())
def initialize(self, item_type, item_name, comment): # pylint: disable=too-many-locals """ Initialize Downtime QDialog :param item_type: type of item to acknowledge : host | service :type item_type: str :param item_name: name of the item to acknowledge :type item_name: str :param comment: the default comment of action :type comment: str """ logger.debug("Create Downtime QDialog...") # Main status_layout center_widget(self) main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(get_logo_widget(self, _('Request Downtime'))) downtime_widget = QWidget() downtime_widget.setObjectName('dialog') downtime_layout = QGridLayout(downtime_widget) downtime_title = QLabel(_('Request a downtime')) downtime_title.setObjectName('itemtitle') downtime_layout.addWidget(downtime_title, 0, 0, 1, 3) host_label = QLabel('<b>%s:</b> %s' % (item_type.capitalize(), item_name)) downtime_layout.addWidget(host_label, 1, 0, 1, 1) options_label = QLabel(_('Downtime options:')) options_label.setObjectName('subtitle') downtime_layout.addWidget(options_label, 2, 0, 1, 1) self.fixed_toggle_btn.initialize() self.fixed_toggle_btn.update_btn_state(self.fixed) downtime_layout.addWidget(self.fixed_toggle_btn, 2, 1, 1, 1) fixed_label = QLabel(_('Fixed')) downtime_layout.addWidget(fixed_label, 2, 2, 1, 1) fixed_info = QLabel( _( 'If checked, downtime will start and end at the times specified' ' by the “start time” and “end time” fields.' ) ) fixed_info.setWordWrap(True) downtime_layout.addWidget(fixed_info, 3, 0, 1, 3) duration_label = QLabel(_('Duration')) duration_label.setObjectName('subtitle') downtime_layout.addWidget(duration_label, 4, 0, 1, 1) duration_clock = QLabel() duration_clock.setPixmap(QPixmap(settings.get_image('time'))) downtime_layout.addWidget(duration_clock, 4, 1, 1, 1) duration_clock.setFixedSize(16, 16) duration_clock.setScaledContents(True) self.duration.setTime(QTime(4, 00)) self.duration.setDisplayFormat("HH'h'mm") downtime_layout.addWidget(self.duration, 4, 2, 1, 1) duration_info = QLabel( _('Sets the duration if it is a non-fixed downtime.') ) downtime_layout.addWidget(duration_info, 5, 0, 1, 3) date_range_label = QLabel(_('Downtime date range')) date_range_label.setObjectName('subtitle') downtime_layout.addWidget(date_range_label, 6, 0, 1, 1) calendar_label = QLabel() calendar_label.setPixmap(QPixmap(settings.get_image('calendar'))) calendar_label.setFixedSize(16, 16) calendar_label.setScaledContents(True) downtime_layout.addWidget(calendar_label, 6, 1, 1, 1) start_time_label = QLabel(_('Start time:')) downtime_layout.addWidget(start_time_label, 7, 0, 1, 1) self.start_time.setCalendarPopup(True) self.start_time.setDateTime(datetime.datetime.now()) self.start_time.setDisplayFormat("dd/MM/yyyy HH'h'mm") downtime_layout.addWidget(self.start_time, 7, 1, 1, 2) end_time_label = QLabel(_('End time:')) downtime_layout.addWidget(end_time_label, 8, 0, 1, 1) self.end_time.setCalendarPopup(True) self.end_time.setDateTime(datetime.datetime.now() + datetime.timedelta(hours=2)) self.end_time.setDisplayFormat("dd/MM/yyyy HH'h'mm") downtime_layout.addWidget(self.end_time, 8, 1, 1, 2) self.comment_edit.setText(comment) self.comment_edit.setMaximumHeight(60) downtime_layout.addWidget(self.comment_edit, 9, 0, 1, 3) request_btn = QPushButton(_('REQUEST DOWNTIME'), self) request_btn.clicked.connect(self.handle_accept) request_btn.setObjectName('valid') request_btn.setMinimumHeight(30) request_btn.setDefault(True) downtime_layout.addWidget(request_btn, 10, 0, 1, 3) main_layout.addWidget(downtime_widget)
def create_widget(self): """ Create widget login """ # Main status_layout main_layout = QVBoxLayout(self) main_layout.setContentsMargins(0, 0, 0, 0) main_layout.addWidget(get_logo_widget(self, _('Login'), exitapp=True)) # Login QWidget login_widget = QWidget(self) login_widget.setObjectName('dialog') login_layout = QGridLayout() login_widget.setLayout(login_layout) # _ = init_localization() title = QLabel(_('Welcome to Alignak-app')) title.setObjectName('itemtitle') title.setContentsMargins(1, 1, 1, 1) login_layout.addWidget(title, 0, 0, 1, 2) login_layout.setAlignment(title, Qt.AlignCenter) version = QLabel(_('Version %s') % __version__) version.setObjectName('subtitle') login_layout.addWidget(version, 1, 0, 1, 2) login_layout.setAlignment(version, Qt.AlignCenter | Qt.AlignTop) # Alignak server login_label = QLabel(_('Configure Alignak server')) login_layout.addWidget(login_label, 2, 0, 1, 1) login_layout.setAlignment(login_label, Qt.AlignRight) server_btn = QPushButton() server_btn.clicked.connect(self.handle_server) server_btn.setFixedSize(35, 35) server_btn.setIcon(QIcon(settings.get_image('server_settings'))) server_btn.setToolTip(_('Configure Alignak Server')) login_layout.addWidget(server_btn, 2, 1, 1, 1) # Proxy settings proxy_lbl = QLabel(_('Configure Proxy')) login_layout.addWidget(proxy_lbl, 3, 0, 1, 1) login_layout.setAlignment(proxy_lbl, Qt.AlignRight) proxy_btn = QPushButton() proxy_btn.setIcon(QIcon(settings.get_image('password'))) proxy_btn.setToolTip(_('Configure your Proxy')) proxy_btn.setFixedSize(35, 35) proxy_btn.clicked.connect(self.handle_proxy) login_layout.addWidget(proxy_btn, 3, 1, 1, 1) # Connection label connection_lbl = QLabel() connection_lbl.setText(_('<b>Log-in</b> to use the application')) connection_lbl.setWordWrap(True) login_layout.addWidget(connection_lbl, 4, 0, 1, 2) # Username field self.username_line.setFixedHeight(25) self.username_line.setPlaceholderText(_('username...')) login_layout.addWidget(self.username_line, 5, 0, 1, 2) # Password field self.password_line.setFixedHeight(25) self.password_line.setPlaceholderText(_('password...')) self.password_line.setEchoMode(QLineEdit.Password) login_layout.addWidget(self.password_line, 6, 0, 1, 2) # Login button login_button = QPushButton(_('LOGIN'), self) login_button.clicked.connect(self.accept_login) login_button.setObjectName('valid') login_button.setMinimumHeight(30) login_button.setDefault(True) login_layout.addWidget(login_button, 7, 0, 1, 2) main_layout.addWidget(login_widget) self.setLayout(main_layout) center_widget(self) if settings.get_config('Alignak', 'proxy_user'): self.handle_proxy()