示例#1
0
void SjMyMusicConfigPage::OnDelSource(wxCommandEvent& event)
{
	SjSettingsSourceItem* source = GetSelFromDialog();
	if( source )
	{
		SJ_WINDOW_DISABLER(SjDialog::FindTopLevel(this));
		if( source->GetScannerModule()->DeleteSource(source->GetIndex(), SjDialog::FindTopLevel(this)) )
		{
			InitPage("");
			m_idxChanged = TRUE;
			UpdateButtons();
		}
	}
}
示例#2
0
void SjMyMusicConfigPage::OnAddSources(wxCommandEvent& event)
{
	SjModuleList* list = g_mainFrame->m_moduleSystem.GetModules(SJ_MODULETYPE_SCANNER);
	wxASSERT(list);

	// find the correct module
	SjModuleList::Node* moduleNode = list->GetFirst();
	SjScannerModule*    scannerModule = NULL;
	int                 typeCount = 0, typeIndex = -1;
	while( moduleNode && typeIndex == -1 )
	{
		scannerModule = (SjScannerModule*)moduleNode->GetData();
		wxASSERT(scannerModule);
		wxASSERT(scannerModule->IsLoaded());

		size_t i;
		for( i = 0; i < scannerModule->m_addSourceTypes_.GetCount(); i++ )
		{
			if( IDC_MODULE00+typeCount == event.GetId() )
			{
				typeIndex = i; // exit outer loop
				break;
			}

			typeCount++;
		}

		// next
		moduleNode = moduleNode->GetNext();
	}

	// add by module
	if( typeIndex != -1 && scannerModule )
	{
		long newIndex;

		{
			wxWindow* topLevelWindow = SjDialog::FindTopLevel(this);
			SJ_WINDOW_DISABLER(topLevelWindow);
			newIndex = scannerModule->AddSources(typeIndex, topLevelWindow);
		}

		if( newIndex != -1 )
		{
			InitPage(scannerModule->GetSourceUrl(newIndex));
			m_idxChanged = TRUE;
			UpdateButtons();
		}
	}
}
示例#3
0
// pass an uninitialized file object, the function will ask the user for the
// filename and try to open it, returns true on success (file was opened),
// false if file couldn't be opened/created and -1 if the file selection
// dialog was cancelled
int SjLogDialog::OpenLogFile(wxFile& file, wxString& retFilename)
{
	SJ_WINDOW_DISABLER(this);

	// get the file name
	// -----------------
	SjExtList extList; extList.AddExt(wxT("txt"));
	wxFileDialog dlg(this, _("Save"), wxT(""), wxT("log.txt"), extList.GetFileDlgStr(wxFD_SAVE), wxFD_SAVE|wxFD_CHANGE_DIR);
	if( dlg.ShowModal() != wxID_OK ) { return -1; }
	wxString filename = dlg.GetPath();

	// open file
	// ---------
	bool bOk wxDUMMY_INITIALIZE(false);
	if ( wxFile::Exists(filename) )
	{
		wxASSERT( wxYES != wxCANCEL );
		wxASSERT( wxNO != wxCANCEL );
		bool bAppend = false;
		switch( SjMessageBox(wxString::Format(_("Overwrite \"%s\"?"), filename.c_str()), SJ_PROGRAM_NAME,
		                     wxICON_QUESTION | wxYES_NO | wxCANCEL, this, NULL, NULL, _("Yes"), _("Append")) )
		{
			case wxYES:
				bAppend = false;
				break;

			case wxNO:
				bAppend = true;
				break;

			default:
				return -1;
		}

		if ( bAppend ) {
			bOk = file.Open(filename, wxFile::write_append);
		}
		else {
			bOk = file.Create(filename, true /* overwrite */);
		}
	}
	else {
		bOk = file.Create(filename);
	}

	retFilename = filename;

	return bOk;
}
示例#4
0
void SjMyMusicConfigPage::OnConfigSource(wxCommandEvent& event)
{
	SjSettingsSourceItem* source = GetSelFromDialog();
	if( source )
	{
		SJ_WINDOW_DISABLER(SjDialog::FindTopLevel(this));

		wxString sourceUrl = source->GetUrl(); // save as source gets invalid on InitPage()

		bool needsUpdate = source->GetScannerModule()->ConfigSource(source->GetIndex(), SjDialog::FindTopLevel(this));

		InitPage(sourceUrl);

		if( needsUpdate )
		{
			m_idxChanged = TRUE;
			UpdateButtons();
		}
	}
}
示例#5
0
void SjKaraokeModule::OnMenuOption(int i)
{
	switch( i )
	{
		case IDC_BG_BLACK:
			m_bgType = SJ_KARAOKE_BG_BLACK;
			WriteKarConfig();
			UpdateBg();
			break;

		case IDC_BG_USERDEF_DIR_USE:
		case IDC_BG_DEFAULT_IMAGES:
			m_bgType = (i==IDC_BG_USERDEF_DIR_USE)? SJ_KARAOKE_BG_USERDEF_DIR : SJ_KARAOKE_BG_DEFAULT_IMAGES;
			WriteKarConfig();
			InitBgFiles();
			UpdateBg();
			break;

		case IDC_BG_USERDEF_DIR_CHANGE:
			g_visModule->SetModal(true);
			{
				SJ_WINDOW_DISABLER(m_impl);

				::wxBeginBusyCursor(wxHOURGLASS_CURSOR);
				wxDirDialog dirDialog(m_impl,
				                      _("Please select a directory with images"),
				                      m_bgUserDefDir);
				::wxEndBusyCursor();

				if( dirDialog.ShowModal() == wxID_OK )
				{
					wxFileName fn(dirDialog.GetPath());
					fn.Normalize();

					m_bgUserDefDir = SjLittleDirSel::NormalizeDir(fn.GetFullPath());
					m_bgType = SJ_KARAOKE_BG_USERDEF_DIR;
					WriteKarConfig();
					InitBgFiles();
					UpdateBg();
				}
			}
			g_visModule->SetModal(false);
			break;

		case IDC_BG_SMOOTH:
			SjTools::ToggleFlag(m_karFlags, SJ_KAR_SMOOTH);
			WriteKarConfig();
			UpdateBg(true/*keepImage*/);
			break;

		case IDC_BG_KEEPASPECT:
			SjTools::ToggleFlag(m_karFlags, SJ_KAR_KEEPASPECT);
			WriteKarConfig();
			UpdateBg(true/*keepImage*/);
			break;

		case IDC_BG_GRAYSCALE:
			SjTools::ToggleFlag(m_karFlags, SJ_KAR_GRAYSCALE);
			WriteKarConfig();
			UpdateBg(true/*keepImage*/);
			break;

		case IDC_BG_USEBGJPG:
			SjTools::ToggleFlag(m_karFlags, SJ_KAR_USEBGJPG);
			WriteKarConfig();
			UpdateBg();
			break;
	}
}