bool CGUIControl::OnMessage(CGUIMessage& message) { if ( message.GetControlId() == GetID() ) { switch (message.GetMessage() ) { case GUI_MSG_SETFOCUS: // if control is disabled then move 2 the next control if ( !CanFocus() ) { CLog::Log(LOGERROR, "Control %u in window %u has been asked to focus, " "but it can't", GetID(), GetParentID()); return false; } SetFocus(true); { // inform our parent window that this has happened CGUIMessage message(GUI_MSG_FOCUSED, GetParentID(), GetID()); if (m_parentControl) m_parentControl->OnMessage(message); } return true; break; case GUI_MSG_LOSTFOCUS: { SetFocus(false); // and tell our parent so it can unfocus if (m_parentControl) m_parentControl->OnMessage(message); return true; } break; case GUI_MSG_VISIBLE: SetVisible(true, true); return true; break; case GUI_MSG_HIDDEN: SetVisible(false); return true; // Note that the skin <enable> tag will override these messages case GUI_MSG_ENABLED: SetEnabled(true); return true; case GUI_MSG_DISABLED: SetEnabled(false); return true; case GUI_MSG_WINDOW_RESIZE: // invalidate controls to get them to recalculate sizing information SetInvalid(); return true; } } return false; }
bool CGUIControllerWindow::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_INIT: { //! @todo Process parameter //std::string strParam = message.GetStringParam(); break; } case GUI_MSG_CLICKED: { int controlId = message.GetSenderId(); if (controlId == CONTROL_CLOSE_BUTTON) { Close(); return true; } else if (controlId == CONTROL_GET_MORE) { GetMoreControllers(); return true; } else if (controlId == CONTROL_RESET_BUTTON) { ResetController(); return true; } else if (controlId == CONTROL_HELP_BUTTON) { ShowHelp(); return true; } else if (CONTROL_CONTROLLER_BUTTONS_START <= controlId && controlId < CONTROL_CONTROLLER_BUTTONS_END) { OnControllerSelected(controlId - CONTROL_CONTROLLER_BUTTONS_START); return true; } else if (CONTROL_FEATURE_BUTTONS_START <= controlId && controlId < CONTROL_FEATURE_BUTTONS_END) { OnFeatureSelected(controlId - CONTROL_FEATURE_BUTTONS_START); return true; } break; } case GUI_MSG_FOCUSED: { int controlId = message.GetControlId(); if (CONTROL_CONTROLLER_BUTTONS_START <= controlId && controlId < CONTROL_CONTROLLER_BUTTONS_END) { OnControllerFocused(controlId - CONTROL_CONTROLLER_BUTTONS_START); } else if (CONTROL_FEATURE_BUTTONS_START <= controlId && controlId < CONTROL_FEATURE_BUTTONS_END) { OnFeatureFocused(controlId - CONTROL_FEATURE_BUTTONS_START); } break; } case GUI_MSG_SETFOCUS: { int controlId = message.GetControlId(); if (CONTROL_CONTROLLER_BUTTONS_START <= controlId && controlId < CONTROL_CONTROLLER_BUTTONS_END) { OnControllerFocused(controlId - CONTROL_CONTROLLER_BUTTONS_START); } else if (CONTROL_FEATURE_BUTTONS_START <= controlId && controlId < CONTROL_FEATURE_BUTTONS_END) { OnFeatureFocused(controlId - CONTROL_FEATURE_BUTTONS_START); } break; } case GUI_MSG_REFRESH_LIST: { int controlId = message.GetControlId(); if (controlId == CONTROL_CONTROLLER_LIST) { if (m_controllerList && m_controllerList->Refresh()) { CGUIDialog::OnMessage(message); return true; } } break; } default: break; } return CGUIDialog::OnMessage(message); }
bool CGUIDialogVideoBookmarks::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { CUtil::DeleteVideoDatabaseDirectoryCache(); Clear(); } break; case GUI_MSG_WINDOW_INIT: { CGUIWindow::OnMessage(message); Update(); return true; } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_ADD_BOOKMARK) { AddBookmark(); } else if (iControl == CONTROL_CLEAR_BOOKMARKS) { ClearBookmarks(); } else if (iControl == CONTROL_ADD_EPISODE_BOOKMARK) { AddEpisodeBookmark(); } else if (m_viewControl.HasControl(iControl)) // list/thumb control { int iItem = m_viewControl.GetSelectedItem(); int iAction = message.GetParam1(); if (iAction == ACTION_DELETE_ITEM) { if( (unsigned)iItem < m_bookmarks.size() ) { CVideoDatabase videoDatabase; videoDatabase.Open(); videoDatabase.ClearBookMarkOfFile(g_application.CurrentFile(),m_bookmarks[iItem],m_bookmarks[iItem].type); videoDatabase.Close(); CUtil::DeleteVideoDatabaseDirectoryCache(); } Update(); } else if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK) { GotoBookmark(iItem); } } } break; case GUI_MSG_SETFOCUS: { if (m_viewControl.HasControl(message.GetControlId()) && m_viewControl.GetCurrentControl() != message.GetControlId()) { m_viewControl.SetFocused(); return true; } } break; } return CGUIDialog::OnMessage(message); }
bool CGUIDialogAddonInfo::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { if (m_jobid) CJobManager::GetInstance().CancelJob(m_jobid); } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BTN_UPDATE) { OnUpdate(); return true; } if (iControl == CONTROL_BTN_INSTALL) { if (!m_localAddon) { OnInstall(); return true; } else { OnUninstall(); return true; } } else if (iControl == CONTROL_BTN_SELECT) { OnLaunch(); return true; } else if (iControl == CONTROL_BTN_ENABLE) { OnEnable(!m_item->GetProperty("Addon.Enabled").asBoolean()); return true; } else if (iControl == CONTROL_BTN_SETTINGS) { OnSettings(); return true; } else if (iControl == CONTROL_BTN_CHANGELOG) { OnChangeLog(); return true; } else if (iControl == CONTROL_BTN_ROLLBACK) { OnRollback(); return true; } } break; default: break; } return CGUIDialog::OnMessage(message); }
bool CGUIDialogMusicInfo::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { CGUIMessage message(GUI_MSG_LABEL_RESET, GetID(), CONTROL_LIST); OnMessage(message); m_albumSongs->Clear(); } break; case GUI_MSG_WINDOW_INIT: { CGUIDialog::OnMessage(message); m_bViewReview = true; m_bRefresh = false; Update(); return true; } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BTN_REFRESH) { m_bRefresh = true; Close(); return true; } else if (iControl == CONTROL_BTN_GET_THUMB) { OnGetThumb(); } else if (iControl == CONTROL_BTN_TRACKS) { m_bViewReview = !m_bViewReview; Update(); } else if (iControl == CONTROL_LIST) { int iAction = message.GetParam1(); if (m_bArtistInfo && (ACTION_SELECT_ITEM == iAction || ACTION_MOUSE_LEFT_CLICK == iAction)) { CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl); g_windowManager.SendMessage(msg); int iItem = msg.GetParam1(); if (iItem < 0 || iItem >= (int)m_albumSongs->Size()) break; CFileItemPtr item = m_albumSongs->Get(iItem); OnSearch(item.get()); return true; } } else if (iControl == CONTROL_BTN_GET_FANART) { OnGetFanart(); } } break; } return CGUIDialog::OnMessage(message); }
bool CGUIWindowManager::SendMessage(CGUIMessage& message) { bool handled = false; // CLog::Log(LOGDEBUG,"SendMessage: mess=%d send=%d control=%d param1=%d", message.GetMessage(), message.GetSenderId(), message.GetControlId(), message.GetParam1()); // Send the message to all none window targets for (int i = 0; i < (int) m_vecMsgTargets.size(); i++) { IMsgTargetCallback* pMsgTarget = m_vecMsgTargets[i]; if (pMsgTarget) { if (pMsgTarget->OnMessage( message )) handled = true; } } // A GUI_MSG_NOTIFY_ALL is send to any active modal dialog // and all windows whether they are active or not if (message.GetMessage()==GUI_MSG_NOTIFY_ALL) { CSingleLock lock(g_graphicsContext); for (rDialog it = m_activeDialogs.rbegin(); it != m_activeDialogs.rend(); ++it) { CGUIWindow *dialog = *it; dialog->OnMessage(message); } for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); ++it) { CGUIWindow *pWindow = (*it).second; pWindow->OnMessage(message); } return true; } // Normal messages are sent to: // 1. All active modeless dialogs // 2. The topmost dialog that accepts the message // 3. The underlying window (only if it is the sender or receiver if a modal dialog is active) bool hasModalDialog(false); bool modalAcceptedMessage(false); // don't use an iterator for this loop, as some messages mean that m_activeDialogs is altered, // which will invalidate any iterator CSingleLock lock(g_graphicsContext); unsigned int topWindow = m_activeDialogs.size(); while (topWindow) { CGUIWindow* dialog = m_activeDialogs[--topWindow]; lock.Leave(); if (!modalAcceptedMessage && dialog->IsModalDialog()) { // modal window hasModalDialog = true; if (!modalAcceptedMessage && dialog->OnMessage( message )) { modalAcceptedMessage = handled = true; } } else if (!dialog->IsModalDialog()) { // modeless if (dialog->OnMessage( message )) handled = true; } lock.Enter(); if (topWindow > m_activeDialogs.size()) topWindow = m_activeDialogs.size(); } lock.Leave(); // now send to the underlying window CGUIWindow* window = GetWindow(GetActiveWindow()); if (window) { if (hasModalDialog) { // only send the message to the underlying window if it's the recipient // or sender (or we have no sender) if (message.GetSenderId() == window->GetID() || message.GetControlId() == window->GetID() || message.GetSenderId() == 0 ) { if (window->OnMessage(message)) handled = true; } } else { if (window->OnMessage(message)) handled = true; } } return handled; }
bool CGUIControlGroupList::OnMessage(CGUIMessage& message) { switch (message.GetMessage() ) { case GUI_MSG_FOCUSED: { // a control has been focused // scroll if we need to and update our page control ValidateOffset(); float offset = 0; for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; if (!control->IsVisible()) continue; if (control->HasID(message.GetControlId())) { // find out whether this is the first or last control if (IsFirstFocusableControl(control)) ScrollTo(0); else if (IsLastFocusableControl(control)) ScrollTo(m_totalSize - Size()); else if (offset < m_scroller.GetValue()) ScrollTo(offset); else if (offset + Size(control) > m_scroller.GetValue() + Size()) ScrollTo(offset + Size(control) - Size()); break; } offset += Size(control) + m_itemGap; } } break; case GUI_MSG_SETFOCUS: { // we've been asked to focus. We focus the last control if it's on this page, // else we'll focus the first focusable control from our offset (after verifying it) ValidateOffset(); // now check the focusControl's offset float offset = 0; for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; if (!control->IsVisible()) continue; if (control->HasID(m_focusedControl)) { if (offset >= m_scroller.GetValue() && offset + Size(control) <= m_scroller.GetValue() + Size()) return CGUIControlGroup::OnMessage(message); break; } offset += Size(control) + m_itemGap; } // find the first control on this page offset = 0; for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; if (!control->IsVisible()) continue; if (control->CanFocus() && offset >= m_scroller.GetValue() && offset + Size(control) <= m_scroller.GetValue() + Size()) { m_focusedControl = control->GetID(); break; } offset += Size(control) + m_itemGap; } } break; case GUI_MSG_PAGE_CHANGE: { if (message.GetSenderId() == m_pageControl) { // it's from our page control ScrollTo((float)message.GetParam1()); return true; } } break; } return CGUIControlGroup::OnMessage(message); }
bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_INIT: { m_delayedSetting.reset(); m_currentSetting.reset(); if (message.GetParam1() != WINDOW_INVALID && !m_returningFromSkinLoad) { // coming to this window first time (ie not returning back from some other window) // so we reset our section and control states m_iCategory = 0; ResetControlStates(); } m_iSection = (int)message.GetParam2() - (int)CGUIWindow::GetID(); CGUIWindow::OnMessage(message); m_returningFromSkinLoad = false; return true; } case GUI_MSG_WINDOW_DEINIT: { // cancel any delayed changes if (m_delayedSetting != NULL) { m_delayedTimer.Stop(); CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), GetID()); OnMessage(message); } CGUIWindow::OnMessage(message); FreeControls(); return true; } case GUI_MSG_FOCUSED: { CGUIWindow::OnMessage(message); if (!m_returningFromSkinLoad) { // cancel any delayed changes if (m_delayedSetting != NULL) { m_delayedTimer.Stop(); CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), GetID(), 1); // param1 = 1 for "reset the control if it's invalid" OnMessage(message); } int focusedControl = GetFocusedControlID(); // check if we have changed the category and need to create new setting controls if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size()) && focusedControl - CONTROL_START_BUTTONS != m_iCategory) { if (!m_categories[focusedControl - CONTROL_START_BUTTONS]->CanAccess()) { // unable to go to this category - focus the previous one SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iCategory, 0); return false; } m_iCategory = focusedControl - CONTROL_START_BUTTONS; CreateSettings(); } else if (focusedControl >= CONTROL_START_CONTROL && focusedControl < (int)(CONTROL_START_CONTROL + m_settingControls.size())) m_currentSetting = GetSettingControl(focusedControl); } return true; } case GUI_MSG_CLICKED: { BaseSettingControlPtr control = GetSettingControl(message.GetSenderId()); if (control != NULL) OnClick(control); break; } case GUI_MSG_LOAD_SKIN: { if (IsActive()) m_returningFromSkinLoad = true; break; } case GUI_MSG_UPDATE_ITEM: { if (m_delayedSetting != NULL) { // if updating the setting fails and param1 has been specifically set // we need to call OnSettingChanged() to restore a valid value in the // setting control if (!m_delayedSetting->OnClick() && message.GetParam1() != 0) OnSettingChanged(m_delayedSetting->GetSetting()); m_delayedSetting.reset(); return true; } break; } case GUI_MSG_UPDATE: { if (IsActive() && HasID(message.GetSenderId())) { int focusedControl = GetFocusedControlID(); CreateSettings(); SET_CONTROL_FOCUS(focusedControl, 0); } break; } case GUI_MSG_NOTIFY_ALL: { if (message.GetParam1() == GUI_MSG_WINDOW_RESIZE) { if (IsActive() && CDisplaySettings::Get().GetCurrentResolution() != g_graphicsContext.GetVideoResolution()) { CDisplaySettings::Get().SetCurrentResolution(g_graphicsContext.GetVideoResolution(), true); CreateSettings(); } } break; } } return CGUIWindow::OnMessage(message); }
bool CGUIEditControl::OnMessage(CGUIMessage &message) { if (message.GetMessage() == GUI_MSG_SET_TYPE) { SetInputType((INPUT_TYPE)message.GetParam1(), (int)message.GetParam2()); return true; } else if (message.GetMessage() == GUI_MSG_ITEM_SELECTED) { message.SetLabel(GetLabel2()); return true; } else if (message.GetMessage() == GUI_MSG_SET_TEXT && ((message.GetControlId() <= 0 && HasFocus()) || (message.GetControlId() == GetID()))) { SetLabel2(message.GetLabel()); UpdateText(); } else if (message.GetMessage() == GUI_MSG_INPUT_TEXT_EDIT && HasFocus()) { g_charsetConverter.utf8ToW(message.GetLabel(), m_edit); m_editOffset = message.GetParam1(); m_editLength = message.GetParam2(); UpdateText(false); return true; } return CGUIButtonControl::OnMessage(message); }
bool CGUIDialogPVRChannelsOSD::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_DEINIT: { if (m_group) { g_PVRManager.SetPlayingGroup(m_group); SetLastSelectedItem(m_group->GroupID()); } Clear(); } break; case GUI_MSG_WINDOW_INIT: { /* Close dialog immediately if now TV or radio channel is playing */ if (!g_PVRManager.IsPlaying()) { Close(); return true; } m_group = GetPlayingGroup(); CGUIWindow::OnMessage(message); Update(true); return true; } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (m_viewControl.HasControl(iControl)) // list/thumb control { int iItem = m_viewControl.GetSelectedItem(); int iAction = message.GetParam1(); if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK) { /* Switch to channel */ GotoChannel(iItem); return true; } else if (iAction == ACTION_SHOW_INFO || iAction == ACTION_MOUSE_RIGHT_CLICK) { /* Show information Dialog */ ShowInfo(iItem); return true; } } } break; case GUI_MSG_MOVE: { int iAction = message.GetParam1(); if (iAction == ACTION_MOVE_RIGHT || iAction == ACTION_MOVE_LEFT) { CPVRChannelGroupPtr group = GetPlayingGroup(); CPVRChannelGroupPtr nextGroup = iAction == ACTION_MOVE_RIGHT ? group->GetNextGroup() : group->GetPreviousGroup(); g_PVRManager.SetPlayingGroup(nextGroup); SetLastSelectedItem(group->GroupID()); Update(); return true; } } break; } return CGUIDialog::OnMessage(message); }
bool CGUIWindow::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_INIT: { CLog::Log(LOGDEBUG, "------ Window Init (%s) ------", GetProperty("xmlfile").c_str()); if (m_dynamicResourceAlloc || !m_bAllocated) AllocResources(); OnInitWindow(); return true; } break; case GUI_MSG_WINDOW_DEINIT: { CLog::Log(LOGDEBUG, "------ Window Deinit (%s) ------", GetProperty("xmlfile").c_str()); OnDeinitWindow(message.GetParam1()); // now free the window if (m_dynamicResourceAlloc) FreeResources(); return true; } break; case GUI_MSG_CLICKED: { // a specific control was clicked CLICK_EVENT clickEvent = m_mapClickEvents[ message.GetSenderId() ]; // determine if there are any handlers for this event if (clickEvent.HasAHandler()) { // fire the message to all handlers clickEvent.Fire(message); } break; } case GUI_MSG_SELCHANGED: { // a selection within a specific control has changed SELECTED_EVENT selectedEvent = m_mapSelectedEvents[ message.GetSenderId() ]; // determine if there are any handlers for this event if (selectedEvent.HasAHandler()) { // fire the message to all handlers selectedEvent.Fire(message); } break; } case GUI_MSG_FOCUSED: { // a control has been focused if (HasID(message.GetSenderId())) { m_focusedControl = message.GetControlId(); return true; } break; } case GUI_MSG_LOSTFOCUS: { // nothing to do at the window level when we lose focus return true; } case GUI_MSG_MOVE: { if (HasID(message.GetSenderId())) return OnMove(message.GetControlId(), message.GetParam1()); break; } case GUI_MSG_SETFOCUS: { // CLog::Log(LOGDEBUG,"set focus to control:%i window:%i (%i)\n", message.GetControlId(),message.GetSenderId(), GetID()); if ( message.GetControlId() ) { // first unfocus the current control CGUIControl *control = GetFocusedControl(); if (control) { CGUIMessage msgLostFocus(GUI_MSG_LOSTFOCUS, GetID(), control->GetID(), message.GetControlId()); control->OnMessage(msgLostFocus); } // get the control to focus CGUIControl* pFocusedControl = GetFirstFocusableControl(message.GetControlId()); if (!pFocusedControl) pFocusedControl = (CGUIControl *)GetControl(message.GetControlId()); // and focus it if (pFocusedControl) return pFocusedControl->OnMessage(message); } return true; } break; case GUI_MSG_EXCLUSIVE_MOUSE: { m_exclusiveMouseControl = message.GetSenderId(); return true; } break; case GUI_MSG_GESTURE_NOTIFY: { CAction action(ACTION_GESTURE_NOTIFY, 0, (float)message.GetParam1(), (float)message.GetParam2(), 0, 0); EVENT_RESULT result = OnMouseAction(action); message.SetParam1(result); return result != EVENT_RESULT_UNHANDLED; } case GUI_MSG_NOTIFY_ALL: { // only process those notifications that come from this window, or those intended for every window if (HasID(message.GetSenderId()) || !message.GetSenderId()) { if (message.GetParam1() == GUI_MSG_PAGE_CHANGE || message.GetParam1() == GUI_MSG_REFRESH_THUMBS || message.GetParam1() == GUI_MSG_REFRESH_LIST || message.GetParam1() == GUI_MSG_WINDOW_RESIZE) { // alter the message accordingly, and send to all controls for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; CGUIMessage msg(message.GetParam1(), message.GetControlId(), control->GetID(), message.GetParam2()); control->OnMessage(msg); } } } } break; } return SendControlMessage(message); }
bool CGUIDialogSongInfo::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_DEINIT: { if (m_startUserrating != m_song->GetMusicInfoTag()->GetUserrating()) { CMusicDatabase db; if (db.Open()) { m_needsUpdate = true; db.SetSongUserrating(m_song->GetPath(), m_song->GetMusicInfoTag()->GetUserrating()); db.Close(); } } CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_LIST); OnMessage(msg); break; } case GUI_MSG_WINDOW_INIT: CGUIDialog::OnMessage(message); Update(); m_cancelled = false; break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_USERRATING) { OnSetUserrating(); } else if (iControl == CONTROL_ALBUMINFO) { CGUIWindowMusicBase *window = (CGUIWindowMusicBase *)g_windowManager.GetWindow(WINDOW_MUSIC_NAV); if (window) { CFileItem item(*m_song); std::string path = StringUtils::Format("musicdb://albums/%li",m_albumId); item.SetPath(path); item.m_bIsFolder = true; window->OnItemInfo(&item, true); } return true; } else if (iControl == CONTROL_BTN_GET_THUMB) { OnGetThumb(); return true; } else if (iControl == CONTROL_LIST) { int iAction = message.GetParam1(); if ((ACTION_SELECT_ITEM == iAction || ACTION_MOUSE_LEFT_CLICK == iAction)) { CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl); g_windowManager.SendMessage(msg); int iItem = msg.GetParam1(); if (iItem < 0 || iItem >= static_cast<int>(m_song->GetMusicInfoTag()->GetContributors().size())) break; int idArtist = m_song->GetMusicInfoTag()->GetContributors()[iItem].GetArtistId(); if (idArtist > 0) { CGUIWindowMusicBase *window = (CGUIWindowMusicBase *)g_windowManager.GetWindow(WINDOW_MUSIC_NAV); if (window) { CFileItem item(*m_song); std::string path = StringUtils::Format("musicdb://artists/%li", idArtist); item.SetPath(path); item.m_bIsFolder = true; window->OnItemInfo(&item, true); } } return true; } } } break; } return CGUIDialog::OnMessage(message); }
/*! \brief Handle messages on window. \param message GUI Message that can be reacted on. \return if a message can't be processed, return \e false On these messages this class reacts.\n When retrieving... - #GUI_MSG_WINDOW_DEINIT\n ...the last focused control is saved to m_iLastControl. - #GUI_MSG_WINDOW_INIT\n ...the musicdatabase is opend and the music extensions and shares are set. The last focused control is set. - #GUI_MSG_CLICKED\n ... the base class reacts on the following controls:\n Buttons:\n - #CONTROL_BTNVIEWASICONS - switch between list, thumb and with large items - #CONTROL_BTNSEARCH - Search for items\n Other Controls: - The container controls\n Have the following actions in message them clicking on them. - #ACTION_QUEUE_ITEM - add selected item to playlist - #ACTION_SHOW_INFO - retrieve album info from the internet - #ACTION_SELECT_ITEM - Item has been selected. Overwrite OnClick() to react on it */ bool CGUIWindowMusicBase::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { if (m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); m_musicdatabase.Close(); } break; case GUI_MSG_WINDOW_INIT: { m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); m_musicdatabase.Open(); if (!CGUIMediaWindow::OnMessage(message)) return false; return true; } break; case GUI_MSG_DIRECTORY_SCANNED: { CFileItem directory(message.GetStringParam(), true); // Only update thumb on a local drive if (directory.IsHD()) { std::string strParent; URIUtils::GetParentPath(directory.GetPath(), strParent); if (directory.GetPath() == m_vecItems->GetPath() || strParent == m_vecItems->GetPath()) Refresh(); } } break; // update the display case GUI_MSG_SCAN_FINISHED: case GUI_MSG_REFRESH_THUMBS: Refresh(); break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BTNRIP) { OnRipCD(); } else if (iControl == CONTROL_BTNPLAYLISTS) { if (!m_vecItems->IsPath("special://musicplaylists/")) Update("special://musicplaylists/"); } else if (iControl == CONTROL_BTNSCAN) { OnScan(-1); } else if (iControl == CONTROL_BTNREC) { if (g_application.m_pPlayer->IsPlayingAudio() ) { if (g_application.m_pPlayer->CanRecord() ) { bool bIsRecording = g_application.m_pPlayer->IsRecording(); g_application.m_pPlayer->Record(!bIsRecording); UpdateButtons(); } } } else if (m_viewControl.HasControl(iControl)) // list/thumb control { int iItem = m_viewControl.GetSelectedItem(); int iAction = message.GetParam1(); // iItem is checked for validity inside these routines if (iAction == ACTION_QUEUE_ITEM || iAction == ACTION_MOUSE_MIDDLE_CLICK) { OnQueueItem(iItem); } else if (iAction == ACTION_SHOW_INFO) { OnItemInfo(iItem); } else if (iAction == ACTION_DELETE_ITEM) { // is delete allowed? // must be at the playlists directory if (m_vecItems->IsPath("special://musicplaylists/")) OnDeleteItem(iItem); else return false; } // use play button to add folders of items to temp playlist else if (iAction == ACTION_PLAYER_PLAY) { // if playback is paused or playback speed != 1, return if (g_application.m_pPlayer->IsPlayingAudio()) { if (g_application.m_pPlayer->IsPausedPlayback()) return false; if (g_application.m_pPlayer->GetPlaySpeed() != 1) return false; } // not playing audio, or playback speed == 1 PlayItem(iItem); return true; } } } break; case GUI_MSG_NOTIFY_ALL: { if (message.GetParam1()==GUI_MSG_REMOVED_MEDIA) CUtil::DeleteDirectoryCache("r-"); } break; } return CGUIMediaWindow::OnMessage(message); }
bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_RESET: m_vecItems->SetPath(""); break; case GUI_MSG_WINDOW_DEINIT: if (m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); break; case GUI_MSG_WINDOW_INIT: { /* We don't want to show Autosourced items (ie removable pendrives, memorycards) in Library mode */ m_rootDir.AllowNonLocalSources(false); SetProperty("flattened", CSettings::Get().GetBool("myvideos.flatten")); if (message.GetNumStringParams() && message.GetStringParam(0).Equals("Files") && CMediaSourceSettings::Get().GetSources("video")->empty()) { message.SetStringParam(""); } if (!CGUIWindowVideoBase::OnMessage(message)) return false; return true; } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BTNPARTYMODE) { if (g_partyModeManager.IsEnabled()) g_partyModeManager.Disable(); else { if (!g_partyModeManager.Enable(PARTYMODECONTEXT_VIDEO)) { SET_CONTROL_SELECTED(GetID(),CONTROL_BTNPARTYMODE,false); return false; } // Playlist directory is the root of the playlist window if (m_guiState.get()) m_guiState->SetPlaylistDirectory("playlistvideo://"); return true; } UpdateButtons(); } if (iControl == CONTROL_BTNSEARCH) { OnSearch(); } else if (iControl == CONTROL_BTNSHOWMODE) { CMediaSettings::Get().CycleWatchedMode(m_vecItems->GetContent()); CSettings::Get().Save(); OnFilterItems(GetProperty("filter").asString()); return true; } else if (iControl == CONTROL_BTNSHOWALL) { if (CMediaSettings::Get().GetWatchedMode(m_vecItems->GetContent()) == WatchedModeAll) CMediaSettings::Get().SetWatchedMode(m_vecItems->GetContent(), WatchedModeUnwatched); else CMediaSettings::Get().SetWatchedMode(m_vecItems->GetContent(), WatchedModeAll); CSettings::Get().Save(); OnFilterItems(GetProperty("filter").asString()); return true; } else if (iControl == CONTROL_UPDATE_LIBRARY) { if (!g_application.IsVideoScanning()) OnScan(""); else g_application.StopVideoScan(); return true; } } break; // update the display case GUI_MSG_SCAN_FINISHED: case GUI_MSG_REFRESH_THUMBS: Refresh(); break; } return CGUIWindowVideoBase::OnMessage(message); }
bool CGUIDialogMusicInfo::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { CGUIMessage message(GUI_MSG_LABEL_RESET, GetID(), CONTROL_LIST); OnMessage(message); m_albumSongs->Clear(); } break; case GUI_MSG_WINDOW_INIT: { CGUIDialog::OnMessage(message); m_bViewReview = true; m_bRefresh = false; RefreshThumb(); Update(); return true; } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BTN_REFRESH) { m_bRefresh = true; Close(); return true; } else if (iControl == CONTROL_BTN_GET_THUMB) { OnGetThumb(); } else if (iControl == CONTROL_BTN_TRACKS) { m_bViewReview = !m_bViewReview; Update(); } else if (iControl == CONTROL_LIST) { int iAction = message.GetParam1(); if (m_bArtistInfo && (ACTION_SELECT_ITEM == iAction || ACTION_MOUSE_LEFT_CLICK == iAction)) { CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl); g_windowManager.SendMessage(msg); int iItem = msg.GetParam1(); if (iItem < 0 || iItem >= (int)m_albumSongs->Size()) break; CFileItemPtr item = m_albumSongs->Get(iItem); OnSearch(item.get()); return true; } } else if (iControl == CONTROL_BTN_LASTFM) { CStdString strArtist = m_album.strArtist; CURL::Encode(strArtist); CStdString strLink; strLink.Format("lastfm://artist/%s/similarartists", strArtist.c_str()); CURL url(strLink); CLastFmManager::GetInstance()->ChangeStation(url); } else if (iControl == CONTROL_BTN_GET_FANART) { OnGetFanart(); } } break; } return CGUIDialog::OnMessage(message); }
bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_INIT: { // check whether we've come back here from a window during which time we've actually // stopped playing videos if (message.GetParam1() == WINDOW_INVALID && !g_application.m_pPlayer->IsPlayingVideo()) { // why are we here if nothing is playing??? g_windowManager.PreviousWindow(); return true; } g_infoManager.SetShowInfo(false); g_infoManager.SetShowCodec(false); m_bShowCurrentTime = false; m_bGroupSelectShow = false; g_infoManager.SetDisplayAfterSeek(0); // Make sure display after seek is off. // switch resolution g_graphicsContext.SetFullScreenVideo(true); #ifdef HAS_VIDEO_PLAYBACK // make sure renderer is uptospeed g_renderManager.Update(); #endif // now call the base class to load our windows CGUIWindow::OnMessage(message); m_bShowViewModeInfo = false; return true; } case GUI_MSG_WINDOW_DEINIT: { CGUIDialog *pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_OSD_TELETEXT); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_SLIDER); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_OSD); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_GUIDE); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_DIRECTOR); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_CUTTER); if (pDialog) pDialog->Close(true); CGUIWindow::OnMessage(message); CSettings::Get().Save(); CSingleLock lock (g_graphicsContext); g_graphicsContext.SetFullScreenVideo(false); lock.Leave(); #ifdef HAS_VIDEO_PLAYBACK // make sure renderer is uptospeed g_renderManager.Update(); #endif return true; } case GUI_MSG_CLICKED: { unsigned int iControl = message.GetSenderId(); if (iControl == CONTROL_GROUP_CHOOSER && g_PVRManager.IsStarted()) { // Get the currently selected label of the Select button CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl); OnMessage(msg); CStdString strLabel = msg.GetLabel(); CPVRChannelPtr playingChannel; if (g_PVRManager.GetCurrentChannel(playingChannel)) { CPVRChannelGroupPtr selectedGroup = g_PVRChannelGroups->Get(playingChannel->IsRadio())->GetByName(strLabel); if (selectedGroup) { g_PVRManager.SetPlayingGroup(selectedGroup); CLog::Log(LOGDEBUG, "%s - switched to group '%s'", __FUNCTION__, selectedGroup->GroupName().c_str()); if (!selectedGroup->IsGroupMember(*playingChannel)) { CLog::Log(LOGDEBUG, "%s - channel '%s' is not a member of '%s', switching to channel 1 of the new group", __FUNCTION__, playingChannel->ChannelName().c_str(), selectedGroup->GroupName().c_str()); CFileItemPtr switchChannel = selectedGroup->GetByChannelNumber(1); if (switchChannel && switchChannel->HasPVRChannelInfoTag()) g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float) switchChannel->GetPVRChannelInfoTag()->ChannelNumber())); else { CLog::Log(LOGERROR, "%s - cannot find channel '1' in group %s", __FUNCTION__, selectedGroup->GroupName().c_str()); CApplicationMessenger::Get().MediaStop(false); } } } else { CLog::Log(LOGERROR, "%s - could not switch to group '%s'", __FUNCTION__, selectedGroup->GroupName().c_str()); CApplicationMessenger::Get().MediaStop(false); } } else { CLog::Log(LOGERROR, "%s - cannot find the current channel", __FUNCTION__); CApplicationMessenger::Get().MediaStop(false); } // hide the control and reset focus m_bGroupSelectShow = false; SET_CONTROL_HIDDEN(CONTROL_GROUP_CHOOSER); // SET_CONTROL_FOCUS(0, 0); return true; } break; } case GUI_MSG_SETFOCUS: case GUI_MSG_LOSTFOCUS: if (message.GetSenderId() != WINDOW_FULLSCREEN_VIDEO) return true; break; } return CGUIWindow::OnMessage(message); }
bool CGUIDialogSongInfo::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_DEINIT: { if (!m_cancelled && m_startRating != m_song->GetMusicInfoTag()->GetRating()) { CMusicDatabase db; if (db.Open()) // OpenForWrite() ? { db.SetSongRating(m_song->GetPath(), m_song->GetMusicInfoTag()->GetRating()); db.Close(); } m_needsUpdate = true; } else { // cancelled - reset the song rating SetRating(m_startRating); m_needsUpdate = false; } break; } case GUI_MSG_WINDOW_INIT: m_cancelled = false; break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_CANCEL) { m_cancelled = true; Close(); return true; } else if (iControl == CONTROL_OK) { m_cancelled = false; Close(); return true; } else if (iControl == CONTROL_ALBUMINFO) { CGUIWindowMusicBase *window = (CGUIWindowMusicBase *)g_windowManager.GetWindow(WINDOW_MUSIC_NAV); if (window) { CFileItem item(*m_song); std::string path = StringUtils::Format("musicdb://albums/%li",m_albumId); item.SetPath(path); item.m_bIsFolder = true; window->OnInfo(&item, true); } return true; } else if (iControl == CONTROL_GETTHUMB) { OnGetThumb(); return true; } } break; } return CGUIDialog::OnMessage(message); }
bool CGUIControl::OnMessage(CGUIMessage& message) { if ( message.GetControlId() == GetID() ) { switch (message.GetMessage() ) { case GUI_MSG_SETFOCUS: // if control is disabled then move 2 the next control if ( !CanFocus() ) { CLog::Log(LOGERROR, "Control %u in window %u has been asked to focus, " "but it can't", GetID(), GetParentID()); return false; } SetFocus(true); { // inform our parent window that this has happened CGUIMessage message(GUI_MSG_FOCUSED, GetParentID(), GetID()); if (m_parentControl) m_parentControl->OnMessage(message); } return true; break; case GUI_MSG_LOSTFOCUS: { SetFocus(false); // and tell our parent so it can unfocus if (m_parentControl) m_parentControl->OnMessage(message); return true; } break; case GUI_MSG_VISIBLE: if (m_visibleCondition) m_visible = g_infoManager.GetBool(m_visibleCondition, m_parentID) ? VISIBLE : HIDDEN; else m_visible = VISIBLE; m_forceHidden = false; return true; break; case GUI_MSG_HIDDEN: m_forceHidden = true; CLog::Log(LOGNOTICE, "Efren Message Hidden received\n"); // reset any visible animations that are in process if (IsAnimating(ANIM_TYPE_VISIBLE)) { // CLog::DebugLog("Resetting visible animation on control %i (we are %s)", m_controlID, m_visible ? "visible" : "hidden"); CAnimation *visibleAnim = GetAnimation(ANIM_TYPE_VISIBLE); if (visibleAnim) visibleAnim->ResetAnimation(); } return true; // Note that the skin <enable> tag will override these messages case GUI_MSG_ENABLED: SetEnabled(true); return true; case GUI_MSG_DISABLED: SetEnabled(false); return true; } } return false; }
bool CGUIBaseContainer::OnMessage(CGUIMessage& message) { if (message.GetControlId() == GetID() ) { if (!m_staticContent) { if (message.GetMessage() == GUI_MSG_LABEL_BIND && message.GetPointer()) { // bind our items Reset(); CFileItemList *items = (CFileItemList *)message.GetPointer(); for (int i = 0; i < items->Size(); i++) m_items.push_back(items->Get(i)); UpdateLayout(true); // true to refresh all items UpdateScrollByLetter(); SelectItem(message.GetParam1()); return true; } else if (message.GetMessage() == GUI_MSG_LABEL_RESET) { Reset(); SetPageControlRange(); return true; } } if (message.GetMessage() == GUI_MSG_ITEM_SELECT) { SelectItem(message.GetParam1()); return true; } else if (message.GetMessage() == GUI_MSG_ITEM_SELECTED) { message.SetParam1(GetSelectedItem()); return true; } else if (message.GetMessage() == GUI_MSG_PAGE_CHANGE) { if (message.GetSenderId() == m_pageControl && IsVisible()) { // update our page if we're visible - not much point otherwise if ((int)message.GetParam1() != GetOffset()) m_pageChangeTimer.StartZero(); ScrollToOffset(message.GetParam1()); return true; } } else if (message.GetMessage() == GUI_MSG_REFRESH_LIST) { // update our list contents for (unsigned int i = 0; i < m_items.size(); ++i) m_items[i]->SetInvalid(); } else if (message.GetMessage() == GUI_MSG_MOVE_OFFSET) { int count = (int)message.GetParam1(); while (count < 0) { MoveUp(true); count++; } while (count > 0) { MoveDown(true); count--; } return true; } } return CGUIControl::OnMessage(message); }
bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_INIT: { // check whether we've come back here from a window during which time we've actually // stopped playing videos if (message.GetParam1() == WINDOW_INVALID && !g_application.IsPlayingVideo()) { // why are we here if nothing is playing??? g_windowManager.PreviousWindow(); return true; } g_infoManager.SetShowInfo(false); g_infoManager.SetShowCodec(false); m_bShowCurrentTime = false; g_infoManager.SetDisplayAfterSeek(0); // Make sure display after seek is off. // switch resolution g_graphicsContext.SetFullScreenVideo(true); #ifdef HAS_VIDEO_PLAYBACK // make sure renderer is uptospeed g_renderManager.Update(false); #endif // now call the base class to load our windows CGUIWindow::OnMessage(message); m_bShowViewModeInfo = false; if (CUtil::IsUsingTTFSubtitles()) { CSingleLock lock (m_fontLock); CStdString fontPath = "special://root/media/Fonts/"; fontPath += g_guiSettings.GetString("subtitles.font"); // We scale based on PAL4x3 - this at least ensures all sizing is constant across resolutions. RESOLUTION_INFO pal(720, 576, 0); CGUIFont *subFont = g_fontManager.LoadTTF("__subtitle__", fontPath, color[g_guiSettings.GetInt("subtitles.color")], 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), false, 1.0f, 1.0f, &pal, true); CGUIFont *borderFont = g_fontManager.LoadTTF("__subtitleborder__", fontPath, 0xFF000000, 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), true, 1.0f, 1.0f, &pal, true); if (!subFont || !borderFont) CLog::Log(LOGERROR, "CGUIWindowFullScreen::OnMessage(WINDOW_INIT) - Unable to load subtitle font"); else m_subsLayout = new CGUITextLayout(subFont, true, 0, borderFont); } else m_subsLayout = NULL; return true; } case GUI_MSG_WINDOW_DEINIT: { CGUIWindow::OnMessage(message); CGUIDialog *pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_OSD_TELETEXT); if (pDialog) pDialog->Close(true); CGUIDialogSlider *slider = (CGUIDialogSlider *)g_windowManager.GetWindow(WINDOW_DIALOG_SLIDER); if (slider) slider->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_OSD); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO); if (pDialog) pDialog->Close(true); FreeResources(true); CSingleLock lock (g_graphicsContext); g_graphicsContext.SetFullScreenVideo(false); lock.Leave(); #ifdef HAS_VIDEO_PLAYBACK // make sure renderer is uptospeed g_renderManager.Update(false); #endif CSingleLock lockFont(m_fontLock); if (m_subsLayout) { g_fontManager.Unload("__subtitle__"); g_fontManager.Unload("__subtitleborder__"); delete m_subsLayout; m_subsLayout = NULL; } return true; } case GUI_MSG_SETFOCUS: case GUI_MSG_LOSTFOCUS: if (message.GetSenderId() != WINDOW_FULLSCREEN_VIDEO) return true; break; } return CGUIWindow::OnMessage(message); }
bool CGUIDialogSmartPlaylistEditor::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); int iAction = message.GetParam1(); if (iControl == CONTROL_RULE_LIST && (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK)) OnRuleList(GetSelectedItem()); else if (iControl == CONTROL_RULE_ADD) OnRuleAdd(); else if (iControl == CONTROL_RULE_EDIT) OnRuleList(GetSelectedItem()); else if (iControl == CONTROL_RULE_REMOVE) OnRuleRemove(GetSelectedItem()); else if (iControl == CONTROL_NAME) OnEditChanged(iControl, m_playlist.m_playlistName); else if (iControl == CONTROL_OK) OnOK(); else if (iControl == CONTROL_CANCEL) OnCancel(); else if (iControl == CONTROL_MATCH) OnMatch(); else if (iControl == CONTROL_LIMIT) OnLimit(); else if (iControl == CONTROL_ORDER_FIELD) OnOrder(); else if (iControl == CONTROL_ORDER_DIRECTION) OnOrderDirection(); else if (iControl == CONTROL_TYPE) OnType(); else return CGUIDialog::OnMessage(message); return true; } break; case GUI_MSG_WINDOW_INIT: { m_cancelled = false; UpdateButtons(); } break; case GUI_MSG_WINDOW_DEINIT: { CGUIDialog::OnMessage(message); // clear the rule list CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_RULE_LIST); OnMessage(msg); m_ruleLabels->Clear(); } break; case GUI_MSG_FOCUSED: if (message.GetControlId() == CONTROL_RULE_REMOVE || message.GetControlId() == CONTROL_RULE_EDIT) HighlightItem(GetSelectedItem()); else HighlightItem(-1); break; } return CGUIDialog::OnMessage(message); }
bool CGUIDialogFileBrowser::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { if (m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); CGUIDialog::OnMessage(message); ClearFileItems(); m_addNetworkShareEnabled = false; return true; } break; case GUI_MSG_WINDOW_INIT: { m_bConfirmed = false; m_bFlip = false; bool bIsDir = false; // this code allows two different selection modes for directories // end the path with a slash to start inside the directory if (URIUtils::HasSlashAtEnd(m_selectedPath)) { bIsDir = true; bool bFool; int iSource = CUtil::GetMatchingSource(m_selectedPath,m_shares,bFool); bFool = true; if (iSource > -1 && iSource < (int)m_shares.size()) { if (URIUtils::PathEquals(m_shares[iSource].strPath, m_selectedPath)) bFool = false; } if (bFool && !CDirectory::Exists(m_selectedPath)) m_selectedPath.clear(); } else { if (!CFile::Exists(m_selectedPath) && !CDirectory::Exists(m_selectedPath)) m_selectedPath.clear(); } // find the parent folder if we are a file browser (don't do this for folders) m_Directory->SetPath(m_selectedPath); if (!m_browsingForFolders && !bIsDir) m_Directory->SetPath(URIUtils::GetParentPath(m_selectedPath)); Update(m_Directory->GetPath()); m_viewControl.SetSelectedItem(m_selectedPath); return CGUIDialog::OnMessage(message); } break; case GUI_MSG_CLICKED: { if (m_viewControl.HasControl(message.GetSenderId())) // list control { int iItem = m_viewControl.GetSelectedItem(); int iAction = message.GetParam1(); if (iItem < 0) break; if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK) { OnClick(iItem); return true; } else if (iAction == ACTION_HIGHLIGHT_ITEM && m_multipleSelection) { CFileItemPtr pItem = (*m_vecItems)[iItem]; if (!pItem->m_bIsShareOrDrive && !pItem->m_bIsFolder) { pItem->Select(!pItem->IsSelected()); CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), message.GetSenderId(), iItem + 1); OnMessage(msg); } } } else if (message.GetSenderId() == CONTROL_OK) { if (m_browsingForFolders == 2) { int iItem = m_viewControl.GetSelectedItem(); std::string strPath; if (iItem == 0) strPath = m_selectedPath; else strPath = (*m_vecItems)[iItem]->GetPath(); std::string strTest = URIUtils::AddFileToFolder(strPath, "1"); CFile file; if (file.OpenForWrite(strTest,true)) { file.Close(); CFile::Delete(strTest); m_bConfirmed = true; Close(); } else CGUIDialogOK::ShowAndGetInput(CVariant{257}, CVariant{20072}); } else { if (m_multipleSelection) { for (int iItem = 0; iItem < m_vecItems->Size(); ++iItem) { CFileItemPtr pItem = (*m_vecItems)[iItem]; if (pItem->IsSelected()) m_markedPath.push_back(pItem->GetPath()); } } m_bConfirmed = true; Close(); } return true; } else if (message.GetSenderId() == CONTROL_CANCEL) { Close(); return true; } else if (message.GetSenderId() == CONTROL_NEWFOLDER) { std::string strInput; if (CGUIKeyboardFactory::ShowAndGetInput(strInput, CVariant{g_localizeStrings.Get(119)}, false)) { std::string strPath = URIUtils::AddFileToFolder(m_vecItems->GetPath(), strInput); if (CDirectory::Create(strPath)) Update(m_vecItems->GetPath()); else CGUIDialogOK::ShowAndGetInput(CVariant{20069}, CVariant{20072}); } } else if (message.GetSenderId() == CONTROL_FLIP) m_bFlip = !m_bFlip; } break; case GUI_MSG_SETFOCUS: { if (m_viewControl.HasControl(message.GetControlId()) && m_viewControl.GetCurrentControl() != message.GetControlId()) { m_viewControl.SetFocused(); return true; } } break; case GUI_MSG_NOTIFY_ALL: { // Message is received only if this window is active if (message.GetParam1() == GUI_MSG_REMOVED_MEDIA) { if (m_Directory->IsVirtualDirectoryRoot() && IsActive()) { int iItem = m_viewControl.GetSelectedItem(); Update(m_Directory->GetPath()); m_viewControl.SetSelectedItem(iItem); } else if (m_Directory->IsRemovable()) { // check that we have this removable share still if (!m_rootDir.IsInSource(m_Directory->GetPath())) { // don't have this share any more if (IsActive()) Update(""); else { m_history.ClearPathHistory(); m_Directory->SetPath(""); } } } return true; } else if (message.GetParam1()==GUI_MSG_UPDATE_SOURCES) { // State of the sources changed, so update our view if (m_Directory->IsVirtualDirectoryRoot() && IsActive()) { int iItem = m_viewControl.GetSelectedItem(); Update(m_Directory->GetPath()); m_viewControl.SetSelectedItem(iItem); } return true; } else if (message.GetParam1()==GUI_MSG_UPDATE_PATH) { if (IsActive()) { if((message.GetStringParam() == m_Directory->GetPath()) || (m_Directory->IsMultiPath() && XFILE::CMultiPathDirectory::HasPath(m_Directory->GetPath(), message.GetStringParam()))) { int iItem = m_viewControl.GetSelectedItem(); Update(m_Directory->GetPath()); m_viewControl.SetSelectedItem(iItem); } } } } break; } return CGUIDialog::OnMessage(message); }
bool CGUIDialogSettingsBase::OnMessage(CGUIMessage &message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_INIT: { m_delayedSetting.reset(); if (message.GetParam1() != WINDOW_INVALID) { // coming to this window first time (ie not returning back from some other window) // so we reset our section and control states m_iCategory = 0; ResetControlStates(); } if (AllowResettingSettings()) { m_resetSetting = new CSettingAction(SETTINGS_RESET_SETTING_ID); m_resetSetting->SetLabel(10041); m_resetSetting->SetHelp(10045); m_resetSetting->SetControl(CreateControl("button")); } m_dummyCategory = new CSettingCategory(SETTINGS_EMPTY_CATEGORY_ID); m_dummyCategory->SetLabel(10046); m_dummyCategory->SetHelp(10047); break; } case GUI_MSG_WINDOW_DEINIT: { // cancel any delayed changes if (m_delayedSetting != NULL) { m_delayedTimer.Stop(); CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID()); OnMessage(message); } CGUIDialog::OnMessage(message); FreeControls(); return true; } case GUI_MSG_FOCUSED: { CGUIDialog::OnMessage(message); int focusedControl = GetFocusedControlID(); // cancel any delayed changes if (m_delayedSetting != NULL && m_delayedSetting->GetID() != focusedControl) { m_delayedTimer.Stop(); CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID(), 1); // param1 = 1 for "reset the control if it's invalid" g_windowManager.SendThreadMessage(message, GetID()); } // update the value of the previous setting (in case it was invalid) else if (m_iSetting >= CONTROL_SETTINGS_START_CONTROL && m_iSetting < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size())) { BaseSettingControlPtr control = GetSettingControl(m_iSetting); if (control != NULL && control->GetSetting() != NULL && !control->IsValid()) { CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_iSetting, 1); // param1 = 1 for "reset the control if it's invalid" g_windowManager.SendThreadMessage(message, GetID()); } } CVariant description; // check if we have changed the category and need to create new setting controls if (focusedControl >= CONTROL_SETTINGS_START_BUTTONS && focusedControl < (int)(CONTROL_SETTINGS_START_BUTTONS + m_categories.size())) { int categoryIndex = focusedControl - CONTROL_SETTINGS_START_BUTTONS; const CSettingCategory* category = m_categories.at(categoryIndex); if (categoryIndex != m_iCategory) { if (!category->CanAccess()) { // unable to go to this category - focus the previous one SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + m_iCategory, 0); return false; } m_iCategory = categoryIndex; CreateSettings(); } description = category->GetHelp(); } else if (focusedControl >= CONTROL_SETTINGS_START_CONTROL && focusedControl < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size())) { m_iSetting = focusedControl; CSetting *setting = GetSettingControl(focusedControl)->GetSetting(); if (setting != NULL) description = setting->GetHelp(); } // set the description of the currently focused category/setting if (description.isInteger() || (description.isString() && !description.empty())) SetDescription(description); return true; } case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_SETTINGS_OKAY_BUTTON) { OnOkay(); Close(); return true; } if (iControl == CONTROL_SETTINGS_CANCEL_BUTTON) { OnCancel(); Close(); return true; } BaseSettingControlPtr control = GetSettingControl(iControl); if (control != NULL) OnClick(control); break; } case GUI_MSG_UPDATE_ITEM: { if (m_delayedSetting != NULL && m_delayedSetting->GetID() == message.GetControlId()) { // first get the delayed setting and reset its member variable // to avoid handling the delayed setting twice in case the OnClick() // performed later causes the window to be deinitialized (e.g. when // changing the language) BaseSettingControlPtr delayedSetting = m_delayedSetting; m_delayedSetting.reset(); // if updating the setting fails and param1 has been specifically set // we need to call OnSettingChanged() to restore a valid value in the // setting control if (!delayedSetting->OnClick() && message.GetParam1() != 0) OnSettingChanged(delayedSetting->GetSetting()); return true; } if (message.GetControlId() >= CONTROL_SETTINGS_START_CONTROL && message.GetControlId() < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size())) { BaseSettingControlPtr settingControl = GetSettingControl(message.GetControlId()); if (settingControl.get() != NULL && settingControl->GetSetting() != NULL) { settingControl->Update(); return true; } } break; } case GUI_MSG_UPDATE: { if (IsActive() && HasID(message.GetSenderId())) { int focusedControl = GetFocusedControlID(); CreateSettings(); SET_CONTROL_FOCUS(focusedControl, 0); } break; } default: break; } return CGUIDialog::OnMessage(message); }
bool CGUIWindowPrograms::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { if (m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); m_database.Close(); } break; case GUI_MSG_WINDOW_INIT: { m_iRegionSet = 0; m_dlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS); // check for a passed destination path CStdString strDestination = message.GetStringParam(); if (!strDestination.IsEmpty()) { message.SetStringParam(""); CLog::Log(LOGINFO, "Attempting to quickpath to: %s", strDestination.c_str()); // reset directory path, as we have effectively cleared it here m_history.ClearPathHistory(); } // is this the first time accessing this window? // a quickpath overrides the a default parameter if (m_vecItems->m_strPath == "?" && strDestination.IsEmpty()) { m_vecItems->m_strPath = strDestination = g_settings.m_defaultProgramSource; CLog::Log(LOGINFO, "Attempting to default to: %s", strDestination.c_str()); } m_database.Open(); // try to open the destination path if (!strDestination.IsEmpty()) { // open root if (strDestination.Equals("$ROOT")) { m_vecItems->m_strPath = ""; CLog::Log(LOGINFO, " Success! Opening root listing."); } else { // default parameters if the jump fails m_vecItems->m_strPath = ""; bool bIsSourceName = false; SetupShares(); VECSOURCES shares; m_rootDir.GetSources(shares); int iIndex = CUtil::GetMatchingSource(strDestination, shares, bIsSourceName); if (iIndex > -1) { bool bDoStuff = true; if (iIndex < (int)shares.size() && shares[iIndex].m_iHasLock == 2) { CFileItem item(shares[iIndex]); if (!g_passwordManager.IsItemUnlocked(&item,"programs")) { m_vecItems->m_strPath = ""; // no u don't bDoStuff = false; CLog::Log(LOGINFO, " Failure! Failed to unlock destination path: %s", strDestination.c_str()); } } // set current directory to matching share if (bDoStuff) { if (bIsSourceName) m_vecItems->m_strPath=shares[iIndex].strPath; else m_vecItems->m_strPath=strDestination; CLog::Log(LOGINFO, " Success! Opened destination path: %s", strDestination.c_str()); } } else { CLog::Log(LOGERROR, " Failed! Destination parameter (%s) does not match a valid source!", strDestination.c_str()); } } SetHistoryForPath(m_vecItems->m_strPath); } return CGUIMediaWindow::OnMessage(message); } break; case GUI_MSG_CLICKED: { if (message.GetSenderId() == CONTROL_BTNSORTBY) { // need to update shortcuts manually if (CGUIMediaWindow::OnMessage(message)) { LABEL_MASKS labelMasks; m_guiState->GetSortMethodLabelMasks(labelMasks); CLabelFormatter formatter("", labelMasks.m_strLabel2File); for (int i=0;i<m_vecItems->Size();++i) { CFileItemPtr item = m_vecItems->Get(i); if (item->IsShortCut()) formatter.FormatLabel2(item.get()); } return true; } else return false; } if (m_viewControl.HasControl(message.GetSenderId())) // list/thumb control { if (message.GetParam1() == ACTION_PLAYER_PLAY) { OnPlayMedia(m_viewControl.GetSelectedItem()); return true; } } } break; } return CGUIMediaWindow::OnMessage(message); }
bool CGUIDialogAddonInfo::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { if (m_jobid) CJobManager::GetInstance().CancelJob(m_jobid); } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BTN_UPDATE) { OnUpdate(); return true; } if (iControl == CONTROL_BTN_INSTALL) { if (m_localAddon) { if (m_localAddon->Type() == ADDON_ADSPDLL && ActiveAE::CActiveAEDSP::GetInstance().IsProcessing()) { CGUIDialogOK::ShowAndGetInput(24137, 0, 24138, 0); return true; } } if (!m_localAddon) { OnInstall(); return true; } else { OnUninstall(); return true; } } else if (iControl == CONTROL_BTN_SELECT) { OnSelect(); return true; } else if (iControl == CONTROL_BTN_ENABLE) { //FIXME: should be moved to somewhere appropriate (e.g CAddonMgs::CanAddonBeDisabled or IsInUse) and button should be disabled if (m_localAddon) { if (m_localAddon->Type() == ADDON_ADSPDLL && ActiveAE::CActiveAEDSP::GetInstance().IsProcessing()) { CGUIDialogOK::ShowAndGetInput(24137, 0, 24138, 0); return true; } } OnEnableDisable(); return true; } else if (iControl == CONTROL_BTN_SETTINGS) { OnSettings(); return true; } else if (iControl == CONTROL_BTN_CHANGELOG) { OnChangeLog(); return true; } else if (iControl == CONTROL_BTN_AUTOUPDATE) { OnToggleAutoUpdates(); return true; } } break; default: break; } return CGUIDialog::OnMessage(message); }
bool CGUIWindowMusicPlayList::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_PLAYLISTPLAYER_REPEAT: { UpdateButtons(); } break; case GUI_MSG_PLAYLISTPLAYER_RANDOM: case GUI_MSG_PLAYLIST_CHANGED: { // global playlist changed outside playlist window UpdateButtons(); Refresh(true); if (m_viewControl.HasControl(m_iLastControl) && m_vecItems->Size() <= 0) { m_iLastControl = CONTROL_BTNVIEWASICONS; SET_CONTROL_FOCUS(m_iLastControl, 0); } } break; case GUI_MSG_WINDOW_DEINIT: { if (m_musicInfoLoader.IsLoading()) m_musicInfoLoader.StopThread(); m_movingFrom = -1; } break; case GUI_MSG_WINDOW_INIT: { // Setup item cache for tagloader m_musicInfoLoader.UseCacheOnHD("special://temp/MusicPlaylist.fi"); m_vecItems->SetPath("playlistmusic://"); // updatebuttons is called in here if (!CGUIWindowMusicBase::OnMessage(message)) return false; if (m_vecItems->Size() <= 0) { m_iLastControl = CONTROL_BTNVIEWASICONS; SET_CONTROL_FOCUS(m_iLastControl, 0); } if (g_application.m_pPlayer->IsPlayingAudio() && g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC) { int iSong = g_playlistPlayer.GetCurrentSong(); if (iSong >= 0 && iSong <= m_vecItems->Size()) m_viewControl.SetSelectedItem(iSong); } return true; } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BTNSHUFFLE) { if (!g_partyModeManager.IsEnabled()) { g_playlistPlayer.SetShuffle(PLAYLIST_MUSIC, !(g_playlistPlayer.IsShuffled(PLAYLIST_MUSIC))); CMediaSettings::Get().SetMusicPlaylistShuffled(g_playlistPlayer.IsShuffled(PLAYLIST_MUSIC)); CSettings::Get().Save(); UpdateButtons(); Refresh(); } } else if (iControl == CONTROL_BTNSAVE) { if (m_musicInfoLoader.IsLoading()) // needed since we destroy m_vecitems to save memory m_musicInfoLoader.StopThread(); SavePlayList(); } else if (iControl == CONTROL_BTNCLEAR) { if (m_musicInfoLoader.IsLoading()) m_musicInfoLoader.StopThread(); ClearPlayList(); } else if (iControl == CONTROL_BTNPLAY) { m_guiState->SetPlaylistDirectory("playlistmusic://"); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_MUSIC); g_playlistPlayer.Reset(); g_playlistPlayer.Play(m_viewControl.GetSelectedItem()); UpdateButtons(); } else if (iControl == CONTROL_BTNNEXT) { g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_MUSIC); g_playlistPlayer.PlayNext(); } else if (iControl == CONTROL_BTNPREVIOUS) { g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_MUSIC); g_playlistPlayer.PlayPrevious(); } else if (iControl == CONTROL_BTNREPEAT) { // increment repeat state PLAYLIST::REPEAT_STATE state = g_playlistPlayer.GetRepeat(PLAYLIST_MUSIC); if (state == PLAYLIST::REPEAT_NONE) g_playlistPlayer.SetRepeat(PLAYLIST_MUSIC, PLAYLIST::REPEAT_ALL); else if (state == PLAYLIST::REPEAT_ALL) g_playlistPlayer.SetRepeat(PLAYLIST_MUSIC, PLAYLIST::REPEAT_ONE); else g_playlistPlayer.SetRepeat(PLAYLIST_MUSIC, PLAYLIST::REPEAT_NONE); // save settings CMediaSettings::Get().SetMusicPlaylistRepeat(g_playlistPlayer.GetRepeat(PLAYLIST_MUSIC) == PLAYLIST::REPEAT_ALL); CSettings::Get().Save(); UpdateButtons(); } else if (m_viewControl.HasControl(iControl)) { int iAction = message.GetParam1(); int iItem = m_viewControl.GetSelectedItem(); if (iAction == ACTION_DELETE_ITEM || iAction == ACTION_MOUSE_MIDDLE_CLICK) { RemovePlayListItem(iItem); MarkPlaying(); } } } break; } return CGUIWindowMusicBase::OnMessage(message); }
bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); switch (iControl) { case CTL_BUTTON_DONE: OnOK(); break; case CTL_BUTTON_CANCEL: Close(); break; case CTL_BUTTON_SHIFT: OnShift(); break; case CTL_BUTTON_CAPS: if (m_keyType == LOWER) m_keyType = CAPS; else if (m_keyType == CAPS) m_keyType = LOWER; UpdateButtons(); break; case CTL_BUTTON_LAYOUT: OnLayout(); break; case CTL_BUTTON_SYMBOLS: OnSymbols(); break; case CTL_BUTTON_LEFT: MoveCursor( -1); break; case CTL_BUTTON_RIGHT: MoveCursor(1); break; case CTL_BUTTON_IP_ADDRESS: OnIPAddress(); break; case CTL_BUTTON_CLEAR: SetEditText(""); break; case CTL_EDIT: { CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CTL_EDIT); OnMessage(msg); // update callback I guess? if (m_pCharCallback) { // we did _something_, so make sure our search message filter is reset m_pCharCallback(this, msg.GetLabel()); } m_text = msg.GetLabel(); return true; } default: OnClickButton(iControl); break; } } break; case GUI_MSG_SET_TEXT: case GUI_MSG_INPUT_TEXT_EDIT: { // the edit control only handles these messages if it is either focues // or its specific control ID is set in the message. As neither is the // case here (focus is on one of the keyboard buttons) we have to force // the control ID of the message to the control ID of the edit control // (unfortunately we have to create a whole copy of the message object for that) CGUIMessage messageCopy(message.GetMessage(), message.GetSenderId(), CTL_EDIT, message.GetParam1(), message.GetParam2(), message.GetItem()); messageCopy.SetLabel(message.GetLabel()); // ensure this goes to the edit control CGUIControl *edit = GetControl(CTL_EDIT); if (edit) edit->OnMessage(messageCopy); // close the dialog if requested if (message.GetMessage() == GUI_MSG_SET_TEXT && message.GetParam1() > 0) OnOK(); return true; } case GUI_MSG_CODINGTABLE_LOOKUP_COMPLETED: { std::string code = message.GetStringParam(); if (code == m_hzcode) { int response = message.GetParam1(); auto words = m_codingtable->GetResponse(response); m_words.insert(m_words.end(), words.begin(), words.end()); ShowWordList(0); } } } return CGUIDialog::OnMessage(message); }
/*! \brief Handle messages on window. \param message GUI Message that can be reacted on. \return if a message can't be processed, return \e false On these messages this class reacts.\n When retrieving... - #GUI_MSG_WINDOW_DEINIT\n ...the last focused control is saved to m_iLastControl. - #GUI_MSG_WINDOW_INIT\n ...the musicdatabase is opend and the music extensions and shares are set. The last focused control is set. - #GUI_MSG_CLICKED\n ... the base class reacts on the following controls:\n Buttons:\n - #CONTROL_BTNVIEWASICONS - switch between list, thumb and with large items - #CONTROL_BTNTYPE - switch between music windows - #CONTROL_BTNSEARCH - Search for items\n Other Controls: - The container controls\n Have the following actions in message them clicking on them. - #ACTION_QUEUE_ITEM - add selected item to playlist - #ACTION_SHOW_INFO - retrieve album info from the internet - #ACTION_SELECT_ITEM - Item has been selected. Overwrite OnClick() to react on it */ bool CGUIWindowMusicBase::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { m_musicdatabase.Close(); } break; case GUI_MSG_WINDOW_INIT: { m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); m_musicdatabase.Open(); if (!CGUIMediaWindow::OnMessage(message)) return false; // save current window, unless the current window is the music playlist window if (GetID() != WINDOW_MUSIC_PLAYLIST && g_settings.m_iMyMusicStartWindow != GetID()) { g_settings.m_iMyMusicStartWindow = GetID(); g_settings.Save(); } return true; } break; // update the display case GUI_MSG_SCAN_FINISHED: case GUI_MSG_REFRESH_THUMBS: { Update(m_vecItems->GetPath()); } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BTNTYPE) { CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_BTNTYPE); g_windowManager.SendMessage(msg); int nWindow = WINDOW_MUSIC_FILES + msg.GetParam1(); if (nWindow == GetID()) return true; g_settings.m_iMyMusicStartWindow = nWindow; g_settings.Save(); g_windowManager.ChangeActiveWindow(nWindow); CGUIMessage msg2(GUI_MSG_SETFOCUS, g_settings.m_iMyMusicStartWindow, CONTROL_BTNTYPE); g_windowManager.SendMessage(msg2); return true; } else if (m_viewControl.HasControl(iControl)) // list/thumb control { int iItem = m_viewControl.GetSelectedItem(); int iAction = message.GetParam1(); // iItem is checked for validity inside these routines if (iAction == ACTION_QUEUE_ITEM || iAction == ACTION_MOUSE_MIDDLE_CLICK) { OnQueueItem(iItem); } else if (iAction == ACTION_SHOW_INFO) { OnInfo(iItem); } else if (iAction == ACTION_DELETE_ITEM) { // is delete allowed? // must be at the playlists directory if (m_vecItems->GetPath().Equals("special://musicplaylists/")) OnDeleteItem(iItem); // or be at the files window and have file deletion enabled else if (GetID() == WINDOW_MUSIC_FILES && g_guiSettings.GetBool("filelists.allowfiledeletion")) { OnDeleteItem(iItem); } else return false; } // use play button to add folders of items to temp playlist else if (iAction == ACTION_PLAYER_PLAY) { // if playback is paused or playback speed != 1, return if (g_application.IsPlayingAudio()) { if (g_application.m_pPlayer->IsPaused()) return false; if (g_application.GetPlaySpeed() != 1) return false; } // not playing audio, or playback speed == 1 PlayItem(iItem); return true; } } } } return CGUIMediaWindow::OnMessage(message); }
bool CGUIWindowPictures::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { if (m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); if (message.GetParam1() != WINDOW_SLIDESHOW) { m_ImageLib.Unload(); } } break; case GUI_MSG_WINDOW_INIT: { // is this the first time accessing this window? if (m_vecItems->GetPath() == "?" && message.GetStringParam().IsEmpty()) message.SetStringParam(CMediaSourceSettings::Get().GetDefaultSource("pictures")); m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (message.GetParam1() != WINDOW_SLIDESHOW) { m_ImageLib.Load(); } if (!CGUIMediaWindow::OnMessage(message)) return false; return true; } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BTNSLIDESHOW) // Slide Show { OnSlideShow(); } else if (iControl == CONTROL_BTNSLIDESHOW_RECURSIVE) // Recursive Slide Show { OnSlideShowRecursive(); } else if (iControl == CONTROL_SHUFFLE) { CSettings::Get().ToggleBool("slideshow.shuffle"); CSettings::Get().Save(); } else if (m_viewControl.HasControl(iControl)) // list/thumb control { int iItem = m_viewControl.GetSelectedItem(); int iAction = message.GetParam1(); // iItem is checked for validity inside these routines if (iAction == ACTION_DELETE_ITEM) { // is delete allowed? if (CSettings::Get().GetBool("filelists.allowfiledeletion")) OnDeleteItem(iItem); else return false; } else if (iAction == ACTION_PLAYER_PLAY) { ShowPicture(iItem, true); return true; } else if (iAction == ACTION_SHOW_INFO) { OnInfo(iItem); return true; } } } break; } return CGUIMediaWindow::OnMessage(message); }
bool CGUIWindowLoginScreen::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { m_viewControl.Reset(); m_vecItems->Clear(); } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BIG_LIST) { int iAction = message.GetParam1(); // iItem is checked for validity inside these routines if (iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_RIGHT_CLICK) { int iItem = m_viewControl.GetSelectedItem(); bool bResult = OnPopupMenu(m_viewControl.GetSelectedItem()); if (bResult) { Update(); CGUIMessage msg(GUI_MSG_ITEM_SELECT,GetID(),CONTROL_BIG_LIST,iItem); OnMessage(msg); } return bResult; } else if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK) { int iItem = m_viewControl.GetSelectedItem(); bool bCanceled; bool bOkay = g_passwordManager.IsProfileLockUnlocked(iItem, bCanceled); if (bOkay) { LoadProfile(iItem); } else { if (!bCanceled && iItem != 0) CGUIDialogOK::ShowAndGetInput(20068,20117,20022,20022); } } } } break; case GUI_MSG_SETFOCUS: { if (m_viewControl.HasControl(message.GetControlId()) && m_viewControl.GetCurrentControl() != message.GetControlId()) { m_viewControl.SetFocused(); return true; } } default: break; } return CGUIWindow::OnMessage(message); }