#coding:utf-8
from PyQt4 import QtGui
from PyQt4 import QtCore
from AppActivItems import AppActivItems
class AppActivScrollArea(QtGui.QScrollArea):
    """
    """
    def __init__(self,parent=None,activitiesDic={},top=0):
        QtGui.QScrollArea.__init__(self,parent)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setFrameStyle(QtGui.QFrame.NoFrame)
        self.vScrollBar=QtGui.QScrollBar(self)
        self.vScrollBar.setObjectName('activSBar')
        self.vScrollBar.setStyleSheet('#activSBar{background-color: rgba(255,255,255,43);width: 10px;}')
        self.setVerticalScrollBar(self.vScrollBar)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setObjectName('activScroll')
        self.setStyleSheet("#activScroll{background:transparent;}")
        # self.setStyleSheet("QScrollArea{border-image: url();}")
        self.top=top
        self.activDic=activitiesDic
        self.maxItems=8
        self.stripHeight=67
        activNo=len(self.activDic)
        if activNo <= self.maxItems:
            self.setGeometry(0,self.top,parent.geometry().width(),self.stripHeight*activNo)
        else:
            self.setGeometry(0,self.top,parent.geometry().width(),self.stripHeight*self.maxItems)
        # print self.geometry()
        self.activItems=AppActivItems(self)
        self.setWidget(self.activItems)
        # print self.activItems.geometry()
        self.alterSignal=QtCore.pyqtSignal()
        self.connect(self,QtCore.SIGNAL('alterSignal'),parent,QtCore.SIGNAL('alterSignal'))

    @QtCore.pyqtSlot()
    def alter(self,id,type):
        """
        切换或关闭应用窗口
        :param id:应用窗口
        :param type:切换或关闭
        :return:
        """
        self.emit(QtCore.SIGNAL('alterSignal'),id,type)

