Esempio n. 1
0
class UserImageController(QtCore.QObject):
    def __init__(self, window, layout=None, imageform=None):
        QtCore.QObject.__init__(self)
        self.window = window
        self.links = ""
        self.manager = Manager()
        if layout == None:
            self.layout = self.window.CategoryContainerLayout
        else:
            self.layout = layout
        if imageform == None:
            self.imageform = self.window.category_ImageContainer
        else:
            self.imageform = imageform

    def setList(self, mylist, rc=None, view=None):
        if view == None:
            view = self.window.imagelistview
        if rc == None:
            rc = self.window.imagelistview_rc
        self.mylist = [UserImageWapper(thing) for thing in mylist]
        self.clounm_list = UserImageListModel(self.mylist)
        rc.setContextProperty('datamodel', self.clounm_list)

    def setImageForm(self, imageform):
        self.imageform = imageform

    def setFatherLayout(self, layout):
        self.layout = layout

    def Prepare(self):
        files = Manager().prepareFiles()
        fileslist = []
        num = 0
        for myfile in files:

            fileslist.append(Image(num, myfile.decode("utf-8")))
            num = num + 1
        return fileslist

    @QtCore.Slot(str)
    def setWallpaper(self, url):

        if self.manager.puresetWallpaper(url):
            print "done"
            try:
                n = pynotify.Notification(" 爱壁纸HD", "设置完成啦",
                                          "./source/notify.png")
                n.set_urgency(pynotify.URGENCY_CRITICAL)
                n.set_timeout(10000)  # 10 seconds
                n.set_category("device")
                n.show()
            except:
                print "done"

    @QtCore.Slot(str)
    def deleteWallapper(self, url):
        os.system("rm %s " % (url))
        self.window.userimage_clicked()

    @QtCore.Slot(str)
    def lookit(self, url):
        pass

    @QtCore.Slot(int, str)
    def thingSelected(self, myindex, url):

        picture_clicked = UserImageWapper(Image(myindex, url))

        self.imageform.imagerc.setContextProperty('myimage', picture_clicked)
        self.imageform.image_controller.setIndex(myindex)
        self.imageform.image_controller.setList(self.mylist)

        self.window.MasterContainerLayout.setCurrentWidget(self.imageform)
class UserImageController(QtCore.QObject):


    def __init__(self,window,layout = None, imageform = None):
        QtCore.QObject.__init__(self)
        self.window = window
        self.links = ""
        self.manager = Manager()
        if layout == None:
            self.layout = self.window.CategoryContainerLayout
        else:
            self.layout = layout
        if imageform == None:
            self.imageform =  self.window.category_ImageContainer
        else:
            self.imageform = imageform

    def setList(self, mylist,rc = None, view = None):
        if view == None:
            view = self.window.imagelistview
        if rc == None:
            rc = self.window.imagelistview_rc
        self.mylist = [UserImageWapper(thing) for thing in mylist ]
        self.clounm_list  = UserImageListModel(self.mylist)
        rc.setContextProperty('datamodel', self.clounm_list)



    def setImageForm(self, imageform):
        self.imageform = imageform
        
    def setFatherLayout(self, layout):
        self.layout = layout

    def Prepare(self):
        files = Manager().prepareFiles()
        fileslist = []
        num = 0
        for myfile in files:
          
            fileslist.append(Image(num, myfile.decode("utf-8")))
            num = num + 1
        return fileslist

    @QtCore.Slot(str)
    def setWallpaper(self, url):

        if self.manager.puresetWallpaper(url):
            print "done"
            try:
                n = pynotify.Notification(" 爱壁纸HD", "设置完成啦",  "./source/notify.png")
                n.set_urgency(pynotify.URGENCY_CRITICAL)
                n.set_timeout(10000) # 10 seconds
                n.set_category("device")
                n.show()
            except:
                print "done"

    @QtCore.Slot(str)
    def deleteWallapper(self, url):
        os.system( "rm %s "%(url))
        self.window.userimage_clicked()

    @QtCore.Slot(str)
    def lookit(self, url):
        pass

    @QtCore.Slot(int,str)
    def thingSelected(self, myindex, url):
     
        picture_clicked = UserImageWapper(Image(myindex,url))

        self.imageform.imagerc.setContextProperty('myimage', picture_clicked)
        self.imageform.image_controller.setIndex(myindex)
        self.imageform.image_controller.setList(self.mylist)

        self.window.MasterContainerLayout.setCurrentWidget(self.imageform)
Esempio n. 3
0
class ImageController(QtCore.QObject):
    showdetail = QtCore.Signal()
                                                                               

    def __init__(self,window,rc,form,layout,backto):
        try:
            pynotify.init("LoveWallpaperHD")
        except:
            print "No model"
        QtCore.QObject.__init__(self)
        self.window = window
        self.rc = rc
        self.form =  form

        self.father_layout = layout
        self.backto = backto
        self.manager = Manager()

    def setList(self, mylist):
        self.mylist = mylist
        self.limit_count = len(mylist) + 1


    def setIndex(self,myindex):
        self.myindex =  myindex
    
    @QtCore.Slot(str,str)
    def download(self, key,url):
        """docstring for download"""
        if self.manager.download(key,url):
            print "done"
            try:
                n = pynotify.Notification(" 爱壁纸HD", "下载完成!")
                n.show()
            except:
                print "done"
    @QtCore.Slot(str,str)
    def setWallpaper(self, key,url):

        if self.manager.setWallpaper(key,url):
            print "done"
            try:
                n = pynotify.Notification(" 爱壁纸HD", "设置完成啦")
                n.show()
            except:
                print "done"


    @QtCore.Slot(str)
    def showDetail(self, url):
        detail = self.window.My_JsonMan.getDetail(url)

        detailtag = [ImageTagWrapper(kv) for kv in detail.tags]
        detailtag_model = ImageTagListModel(detailtag)

        detaildata = [PropertyWrapper(kv) for kv in detail.data]
        detaildata_model = PropertyListModel(detaildata)
        self.rc.setContextProperty('kvmodel', detaildata_model)
        self.rc.setContextProperty('detailtitle', detail.name)
        self.rc.setContextProperty('tagsmodel', detailtag_model)
    
    @QtCore.Slot(str)
    def puresetWallpaper(self, url):
        if self.manager.puresetWallpaper(url):
            print "done"
            try:
                n = pynotify.Notification(" 爱壁纸HD", "设置完成啦")
                n.show()
            except:
                print "done"

    @QtCore.Slot(str)
    def deleteWallapper(self, url):
        os.system( "rm %s "%(url))
        self.go_back()
        self.window.userimage_clicked()

    @QtCore.Slot(str)
    def lookit(self, url):
        self.form.fullscreen()

    @QtCore.Slot(str,str)
    def toTag(self,name,url):
        
        my_choose_tag_clounm = self.window.My_JsonMan.getTag(url)
        
        self.window.tag_detailimagelistview.controller.setList(my_choose_tag_clounm.data, self.window.tag_detailimagelistview.rc)
        self.window.tag_detailimagelistview.setTitle(name)
        self.window.tag_detailimagelistview.controller.setLinks(my_choose_tag_clounm.link)
        
        self.window.tag_detailimagelistview.setBackToView(self.form)
        
        self.window.Imagedetail_LayoutContainer.setBackToView(self.window.tag_detailimagelistview)
       
        self.window.MasterContainerLayout.setCurrentWidget(self.window.tag_detailimagelistview)

    @QtCore.Slot()
    def go_back(self):
        self.window.showNormal()
        self.father_layout.setCurrentWidget(self.backto)

    @QtCore.Slot()
    def prevPicture(self):
        try:
            if self.myindex - 1 > -1:
                self.rc.setContextProperty('myimage', self.mylist[self.myindex-1])
                self.myindex = self.myindex - 1
        except Exception, e:
            print "No More"
            try:
                n = pynotify.Notification("爱壁纸HD", "这是第一张啦!")
                n.show()
            except:
                print "done"
Esempio n. 4
0
class ImageController(QtCore.QObject):
    showdetail = QtCore.Signal()

    def __init__(self, window, rc, form, layout, backto):
        try:
            pynotify.init("LoveWallpaperHD")
        except:
            print "No model"
        QtCore.QObject.__init__(self)
        self.window = window
        self.rc = rc
        self.form = form

        self.father_layout = layout
        self.backto = backto
        self.manager = Manager()

    def setList(self, mylist):
        self.mylist = mylist
        self.limit_count = len(mylist) + 1

    def setIndex(self, myindex):
        self.myindex = myindex

    @QtCore.Slot(str, str)
    def download(self, key, url):
        """docstring for download"""
        if self.manager.download(key, url):
            print "done"
            try:
                n = pynotify.Notification(" 爱壁纸HD", "下载完成!")
                n.show()
            except:
                print "done"

    @QtCore.Slot(str, str)
    def setWallpaper(self, key, url):

        if self.manager.setWallpaper(key, url):
            print "done"
            try:
                n = pynotify.Notification(" 爱壁纸HD", "设置完成啦")
                n.show()
            except:
                print "done"

    @QtCore.Slot(str)
    def showDetail(self, url):
        detail = self.window.My_JsonMan.getDetail(url)

        detailtag = [ImageTagWrapper(kv) for kv in detail.tags]
        detailtag_model = ImageTagListModel(detailtag)

        detaildata = [PropertyWrapper(kv) for kv in detail.data]
        detaildata_model = PropertyListModel(detaildata)
        self.rc.setContextProperty('kvmodel', detaildata_model)
        self.rc.setContextProperty('detailtitle', detail.name)
        self.rc.setContextProperty('tagsmodel', detailtag_model)

    @QtCore.Slot(str)
    def puresetWallpaper(self, url):
        if self.manager.puresetWallpaper(url):
            print "Set down"
            try:
                n = pynotify.Notification(" 爱壁纸HD", "设置完成啦")
                n.show()
            except:
                print "Notify False"

    @QtCore.Slot(str)
    def deleteWallapper(self, url):
        os.system("rm %s " % (url))
        self.go_back()
        self.window.userimage_clicked()

    @QtCore.Slot(str)
    def lookit(self, url):
        self.form.fullscreen()

    @QtCore.Slot(str, str)
    def toTag(self, name, url):

        my_choose_tag_clounm = self.window.My_JsonMan.getTag(url)

        self.window.tag_detailimagelistview.controller.setList(
            my_choose_tag_clounm.data, self.window.tag_detailimagelistview.rc)
        self.window.tag_detailimagelistview.setTitle(name)
        self.window.tag_detailimagelistview.controller.setLinks(
            my_choose_tag_clounm.link)

        self.window.tag_detailimagelistview.setBackToView(self.form)

        self.window.Imagedetail_LayoutContainer.setBackToView(
            self.window.tag_detailimagelistview)

        self.window.MasterContainerLayout.setCurrentWidget(
            self.window.tag_detailimagelistview)

    @QtCore.Slot()
    def go_back(self):
        self.window.showNormal()
        self.father_layout.setCurrentWidget(self.backto)

    @QtCore.Slot()
    def prevPicture(self):
        try:
            if self.myindex - 1 > -1:
                self.rc.setContextProperty('myimage',
                                           self.mylist[self.myindex - 1])
                self.myindex = self.myindex - 1
        except Exception, e:
            print "No More"
            try:
                n = pynotify.Notification("爱壁纸HD", "这是第一张啦!")
                n.show()
            except:
                print "done"