# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'demo.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.
from utils import *
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import QStringListModel

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(320, 440)
        MainWindow.setMinimumSize(QtCore.QSize(320, 440))
        MainWindow.setMaximumSize(QtCore.QSize(320, 440))
        font = QtGui.QFont()
        font.setFamily("Arial Black")
        MainWindow.setFont(font)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label_ip = QtWidgets.QLabel(self.centralwidget)
        self.label_ip.setAutoFillBackground(False)
        self.label_ip.setObjectName("label_ip")
        self.horizontalLayout.addWidget(self.label_ip)
        self.btn_refresh = QtWidgets.QPushButton(self.centralwidget)
        self.btn_refresh.setObjectName("btn_refresh")
        self.btn_refresh.clicked.connect(self.queryIP)
        self.horizontalLayout.addWidget(self.btn_refresh)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.appList = QtWidgets.QListView(self.centralwidget)
        self.appList.setObjectName("appList")
        actionList = ['action1', 'action2', 'action3']
        slm = QStringListModel();
        slm.setStringList(actionList)
        self.appList.setModel(slm)
        self.appList.clicked.connect(self.clickedlist)
        self.verticalLayout.addWidget(self.appList)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.btn_exit = QtWidgets.QPushButton(self.centralwidget)
        self.btn_exit.setObjectName("btn_exit")
        self.btn_exit.clicked.connect(self.close)
        self.horizontalLayout_2.addWidget(self.btn_exit)
        self.btn_shutdown = QtWidgets.QPushButton(self.centralwidget)
        self.btn_shutdown.setObjectName("btn_shutdown")
        self.horizontalLayout_2.addWidget(self.btn_shutdown)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label_ip.setText(_translate("MainWindow", "IP Address"))
        self.queryIP()
        self.btn_refresh.setText(_translate("MainWindow", "Refresh"))
        self.btn_exit.setText(_translate("MainWindow", "Exit"))
        self.btn_shutdown.setText(_translate("MainWindow", "ShutDown"))

    def queryIP(self):
        ipAddr = getIPAddress()
        self.label_ip.setText(ipAddr)

    def clickedlist(self, qModelIndex):
        print("点击的是：" + str(qModelIndex.row()))