Example #1
0
def paste(type):
    """typeにリストオブジェクトを受け取る。"""
    # clipBoardモジュールを使って貼り付けるファイルリストを取得
    c = clipboard.ClipboardFile()
    pasteList = c.GetFileList()
    # ファイルの追加
    listManager.addItems(pasteList, type)
    return
Example #2
0
def loadM3u(path=None, playlist=2):
    rtn = []  #ファイルパスリスト
    f = False  #ファイル
    if path == None:
        fd = wx.FileDialog(None,
                           _("プレイリストファイル選択"),
                           wildcard=_("プレイリストファイル (.m3u8/.m3u)") +
                           "|*.m3u8*;*.m3u")
        c = fd.ShowModal()
        if c == wx.ID_CANCEL: return rtn
        path = fd.GetPath()
    if os.path.isfile(path) and os.path.splitext(path)[1] == ".m3u":
        f = open(path, "r", encoding="shift-jis")
    elif os.path.isfile(path) and os.path.splitext(path)[1] == ".m3u8":
        f = open(path, "r", encoding="utf-8")
    if f != False:  #ファイルの読み込み
        for s in f.readlines():
            s = s.strip()
            if os.path.isfile(s):
                rtn.append(s)
        f.close()
    else:
        ed = mkDialog.Dialog("m3uLoadErrorDialog")
        ed.Initialize(_("読み込みエラー"),
                      _("プレイリストファイルの読み込みに失敗しました。"), ("OK", ),
                      sound=False)
        fxManager.error()
        return ed.Show()
    if playlist == 2:  #REPLACE
        if closeM3u() == False: return rtn  #closeがキャンセルされたら中止
        listManager.addItems(rtn, globalVars.app.hMainView.playlistView)
        globalVars.listInfo.playlistFile = path
        globalVars.m3uHistory.add(path)
        globalVars.app.hMainView.menu.hFileMenu.Enable(
            menuItemsStore.getRef("M3U_OPEN"), True)
        globalVars.app.hMainView.menu.hFileMenu.Enable(
            menuItemsStore.getRef("M3U_CLOSE"), True)
    elif playlist == 1:  #ADD
        listManager.addItems(rtn, globalVars.app.hMainView.playlistView)
        globalVars.listInfo.playlistFile = path
        globalVars.m3uHistory.add(path)
    if os.path.splitext(globalVars.listInfo.playlistFile)[1] == ".m3u":
        if playlist == 2:
            globalVars.app.hMainView.menu.hFileMenu.SetLabel(
                menuItemsStore.getRef("M3U8_SAVE"), _("UTF-8プレイリストに変換"))
            globalVars.app.hMainView.menu.hFileMenu.Enable(
                menuItemsStore.getRef("M3U8_SAVE"), True)
            globalVars.app.hMainView.menu.hPlaylistMenu.Enable(
                menuItemsStore.getRef("SET_STARTUPLIST"), True)
    elif os.path.splitext(globalVars.listInfo.playlistFile)[1] == ".m3u8":
        if playlist == 2:
            globalVars.app.hMainView.menu.hFileMenu.SetLabel(
                menuItemsStore.getRef("M3U8_SAVE"), _("プレイリストを上書き保存"))
            globalVars.app.hMainView.menu.hFileMenu.Enable(
                menuItemsStore.getRef("M3U8_SAVE"), True)
            globalVars.app.hMainView.menu.hPlaylistMenu.Enable(
                menuItemsStore.getRef("SET_STARTUPLIST"), True)
    return rtn
Example #3
0
    def OnMenuSelect(self, event):
        """メニュー項目が選択されたときのイベントハンドら。"""
        selected = event.GetId()  #メニュー識別しの数値が出る

        if selected == menuItemsStore.getRef("POPUP_PLAY"):
            if self.parent.GetSelectedItemCount() == 1:
                globalVars.eventProcess.listSelection(self.parent)
        elif selected == menuItemsStore.getRef("POPUP_ADD_QUEUE_HEAD"):
            if self.parent.GetSelectedItemCount() != 0:
                t = []
                for i in self.parent.getItemSelections():
                    t.append(self.parent[i][0])
                listManager.addItems(t, globalVars.app.hMainView.queueView, 0)
        elif selected == menuItemsStore.getRef("POPUP_ADD_QUEUE"):
            if self.parent.GetSelectedItemCount() != 0:
                t = []
                for i in self.parent.getItemSelections():
                    t.append(self.parent[i][0])
                listManager.addItems(t, globalVars.app.hMainView.queueView)
        elif selected == menuItemsStore.getRef("POPUP_ADD_PLAYLIST"):
            if self.parent.GetSelectedItemCount() != 0:
                t = []
                for i in self.parent.getItemSelections():
                    t.append(self.parent[i][0])
                listManager.addItems(t, globalVars.app.hMainView.playlistView)
        elif selected == menuItemsStore.getRef("POPUP_COPY"):
            if self.parent.GetSelectedItemCount() != 0:
                fList = []
                i = self.parent.GetFirstSelected()
                if i >= 0:
                    fList.append(self.parent[i][0])
                    while True:
                        i = self.parent.GetNextSelected(i)
                        if i >= 0: fList.append(self.parent[i][0])
                        else: break
                lampClipBoardCtrl.copy(fList)
        elif selected == menuItemsStore.getRef("POPUP_PASTE"):
            lampClipBoardCtrl.paste(self.parent)
        elif selected == menuItemsStore.getRef("POPUP_DELETE"):
            if self.parent.GetSelectedItemCount() != 0:
                globalVars.eventProcess.delete(self.parent)
        elif selected == menuItemsStore.getRef("POPUP_SELECT_ALL"):
            for i in range(self.parent.GetItemCount()):
                self.parent.Select(i - 1)
        elif selected == menuItemsStore.getRef("POPUP_ABOUT"):
            if self.parent.GetSelectedItemCount() == 1:
                index = self.parent.GetFirstSelected()
                t = self.parent[index]
                tag = listManager.getTags([t])
                self.parent[index] = tag[0]
                t = self.parent[index]
                listManager.infoDialog(t)
Example #4
0
    def OnMenuSelect(self, event):
        """メニュー項目が選択されたときのイベントハンドら。"""
        #ショートカットキーが無効状態のときは何もしない
        if not self.parent.shortcutEnable:
            event.Skip()
            return

        selected = event.GetId()  #メニュー識別しの数値が出る

        if selected == menuItemsStore.getRef("FILE_OPEN"):
            d = views.mkOpenDialog.Dialog("fileOpenDialog")
            d.Initialize(0)  #0=ファイルダイアログ
            rtnCode = d.Show()
            if rtnCode == d.PLAYLIST:
                listManager.addItems([d.GetValue()],
                                     globalVars.app.hMainView.playlistView)
            elif rtnCode == d.QUEUE:
                listManager.addItems([d.GetValue()],
                                     globalVars.app.hMainView.queueView)
            else:
                return
        elif selected == menuItemsStore.getRef("DIR_OPEN"):
            d = views.mkOpenDialog.Dialog("directoryOpenDialog")
            d.Initialize(1)  #1=フォルダダイアログ
            rtnCode = d.Show()
            if rtnCode == d.PLAYLIST:
                listManager.addItems([d.GetValue()],
                                     globalVars.app.hMainView.playlistView)
            elif rtnCode == d.QUEUE:
                listManager.addItems([d.GetValue()],
                                     globalVars.app.hMainView.queueView)
            else:
                return
        elif selected == menuItemsStore.getRef("URL_OPEN"):
            d = views.mkOpenDialog.Dialog("urlOpenDialog")
            d.Initialize(2)  #2=URLダイアログ
            rtnCode = d.Show()
            if rtnCode == d.PLAYLIST:
                listManager.addItems([d.GetValue()],
                                     globalVars.app.hMainView.playlistView)
            elif rtnCode == d.QUEUE:
                listManager.addItems([d.GetValue()],
                                     globalVars.app.hMainView.queueView)
            else:
                return
        elif selected == menuItemsStore.getRef("M3U_OPEN"):
            m3uManager.loadM3u()
        elif selected == menuItemsStore.getRef("NEW_M3U8_SAVE"):
            m3uManager.saveM3u8()
        elif selected == menuItemsStore.getRef("M3U8_SAVE"):
            m3uManager.saveM3u8(globalVars.listInfo.playlistFile)
        elif selected == menuItemsStore.getRef("M3U_ADD"):
            m3uManager.loadM3u(None, m3uManager.ADD)
        elif selected == menuItemsStore.getRef("M3U_CLOSE"):
            m3uManager.closeM3u()
        elif selected == menuItemsStore.getRef("EXIT"):
            self.parent.hFrame.Close()
        #機能メニューのイベント
        elif selected >= constants.FILTER_LIST_MENU and selected < constants.FILTER_LIST_MENU + 500:
            globalVars.filter.get(selected -
                                  constants.FILTER_LIST_MENU).setEnable(
                                      event.IsChecked())
        elif selected == menuItemsStore.getRef("FILTER_SETTING"):
            d = filterSettingDialog.Dialog(*globalVars.filter.getDic())
            d.Initialize()
            if d.Show() == wx.ID_CANCEL:
                return
            globalVars.filter.loadDic(*d.GetValue())
        elif selected == menuItemsStore.getRef("SET_SLEEPTIMER"):
            globalVars.sleepTimer.set()
        elif selected == menuItemsStore.getRef("SET_EFFECTOR"):
            effector.effector()
        elif selected == menuItemsStore.getRef("SET_CURSOR_PLAYING"):
            if globalVars.eventProcess.playingList == constants.PLAYLIST:
                p = self.parent.playlistView
                p.Focus(p.getPointer())
                p.Select(-1, 0)
                p.Select(p.getPointer())
            else:
                globalVars.app.hMainView.notification.show(
                    _("プレイリスト上の項目を再生していません。"), 2)
        elif selected == menuItemsStore.getRef("ABOUT_PLAYING"):
            if globalVars.eventProcess.playingList == constants.PLAYLIST:
                listManager.infoDialog(listManager.getTuple(
                    constants.PLAYLIST))
            else:
                listManager.infoDialog(globalVars.listInfo.playingTmp)
        elif selected == menuItemsStore.getRef("SHOW_NET_CONTROLLER"):
            globalVars.lampController.showController()
        elif selected == menuItemsStore.getRef("SHOW_NET_FILE_MANAGER"):
            netFileManager.run()
        # 操作メニューのイベント
        elif selected == menuItemsStore.getRef("PLAY_PAUSE"):
            globalVars.eventProcess.playButtonControl()
        elif selected == menuItemsStore.getRef("STOP"):
            globalVars.eventProcess.stop()
        elif selected == menuItemsStore.getRef("PREVIOUS_TRACK"):
            globalVars.eventProcess.previousBtn()
        elif selected == menuItemsStore.getRef("NEXT_TRACK"):
            globalVars.eventProcess.nextFile(button=True)
        elif selected == menuItemsStore.getRef("VOLUME_100"):
            globalVars.eventProcess.changeVolume(vol=100)
        elif selected == menuItemsStore.getRef("VOLUME_UP"):
            globalVars.eventProcess.changeVolume(+1)
        elif selected == menuItemsStore.getRef("VOLUME_DOWN"):
            globalVars.eventProcess.changeVolume(-1)
        elif selected == menuItemsStore.getRef("MUTE"):
            globalVars.eventProcess.mute()
        elif selected == menuItemsStore.getRef("FAST_FORWARD"):
            globalVars.play.fastForward()
        elif selected == menuItemsStore.getRef("REWIND"):
            globalVars.play.rewind()
        elif selected == menuItemsStore.getRef("SAY_TIME"):
            pos = globalVars.play.getPosition()
            if pos == -1: time = _("情報がありません")
            else:
                hour = pos // 3600
                min = (pos - hour * 3600) // 60
                sec = int(pos - hour * 3600 - min * 60)
                if hour == 0: sHour = ""
                else: sHour = str(int(hour)) + _("時間") + " "
                if min == 0: sMin = ""
                else: sMin = str(int(min)) + _("分") + " "
                time = sHour + sMin + str(int(sec)) + _("秒")
            globalVars.app.say(time)
        elif selected == menuItemsStore.getRef("SKIP"):
            globalVars.eventProcess.skip(settings.getSkipInterval()[0])
        elif selected == menuItemsStore.getRef("REVERSE_SKIP"):
            globalVars.eventProcess.skip(settings.getSkipInterval()[0], False)
        elif selected == menuItemsStore.getRef("SKIP_INTERVAL_INCREASE"):
            globalVars.eventProcess.setSkipInterval()
        elif selected == menuItemsStore.getRef("SKIP_INTERVAL_DECREASE"):
            globalVars.eventProcess.setSkipInterval(False)
        elif selected == menuItemsStore.getRef("REPEAT_LOOP"):
            globalVars.eventProcess.repeatLoopCtrl()
        elif selected == menuItemsStore.getRef("REPEAT_LOOP_NONE"):
            globalVars.eventProcess.repeatLoopCtrl(0)
        elif selected == menuItemsStore.getRef("RL_REPEAT"):
            globalVars.eventProcess.repeatLoopCtrl(1)
        elif selected == menuItemsStore.getRef("RL_LOOP"):
            globalVars.eventProcess.repeatLoopCtrl(2)
        elif selected == menuItemsStore.getRef("SHUFFLE"):
            globalVars.eventProcess.shuffleSw()
        elif selected == menuItemsStore.getRef("MANUAL_SONG_FEED"):
            globalVars.eventProcess.setSongFeed()
        elif selected >= constants.DEVICE_LIST_MENU and selected < constants.DEVICE_LIST_MENU + 500:
            if selected == constants.DEVICE_LIST_MENU:
                globalVars.play.setDevice(PLAYER_DEFAULT_SPEAKER)
            else:
                globalVars.play.setDevice(selected -
                                          constants.DEVICE_LIST_MENU)
        elif selected >= constants.PLAYLIST_HISTORY and selected < constants.PLAYLIST_HISTORY + 20:
            m3uManager.loadM3u(
                globalVars.m3uHistory.getList()[selected -
                                                constants.PLAYLIST_HISTORY])
        elif selected == menuItemsStore.getRef("SET_STARTUPLIST"):
            startupListSetter.run()
        elif selected == menuItemsStore.getRef("FILE_ASSOCIATE"):
            fileAssocDialog.assocDialog()
        elif selected == menuItemsStore.getRef("SET_SENDTO"):
            sendToManager.sendToCtrl("LAMP")
        elif selected == menuItemsStore.getRef("SET_KEYMAP"):
            if self.setKeymap("MainView",
                              _("ショートカットキーの設定"),
                              filter=keymap.KeyFilter().SetDefault(
                                  False, False)):
                #ショートカットキーの変更適用とメニューバーの再描画
                self.parent.menu.InitShortcut()
                self.parent.menu.ApplyShortcut(self.parent.hFrame)
                self.parent.menu.Apply(self.parent.hFrame)
        elif selected == menuItemsStore.getRef("SET_HOTKEY"):
            if self.setKeymap("HOTKEY",
                              _("グローバルホットキーの設定"),
                              self.parent.hotkey,
                              filter=self.parent.hotkey.filter):
                #変更適用
                self.parent.hotkey.UnSet("HOTKEY", self.parent.hFrame)
                self.parent.applyHotKey()
        elif selected == menuItemsStore.getRef("ENVIRONMENT"):
            d = setting_dialog.settingDialog("environment_dialog")
            d.Initialize()
            d.Show()
        elif selected == menuItemsStore.getRef("HELP"):
            if os.path.exists("./readme.txt"):
                subprocess.Popen("start ./readme.txt", shell=True)
            else:
                dialog(_("ヘルプ"), _("ヘルプファイルが見つかりません。"))
        elif selected == menuItemsStore.getRef("CHECK_UPDATE"):
            update.checkUpdate()
        elif selected == menuItemsStore.getRef("VERSION_INFO"):
            versionDialog.versionDialog()
Example #5
0
	def OnDropFiles(self, x, y, files):
		if self.window == globalVars.app.hMainView.playlistView or self.window == globalVars.app.hMainView.queueView:
			listManager.addItems(files, self.window)
		return True