📄 settings.cpp
字号:
/* * Copyright (C) 2008 mtrooper * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* $Id$ */#include "main.h"#if (C_HAVE_WXGUI)#include "Settings.h"#include "../resource/friptv.xpm"#include <wx/filedlg.h>#define USES_BASECLASS#include "video.h"Settings::Settings(wxWindow * parent, wxWindowID id, const wxString & title, const wxPoint & position, const wxSize & size, long style):wxDialog(parent, id, title, position, size, style){ CreateGUIControls();}Settings::~Settings(){}void Settings::CreateGUIControls(){ SetTitle(wxT("Settings")); SetIcon(wxIcon(friptv_xpm)); SetSize(8, 8, 385, 370); Center(); WxNotebook1 = new wxNotebook(this, ID_WXNOTEBOOK1, wxPoint(2, 0), wxSize(369, 300)); GeneralSettings = new wxPanel(WxNotebook1, ID_GENERALSETTINGS, wxPoint(4, 26), wxSize(361, 230)); WxNotebook1->AddPage(GeneralSettings, wxT("&General")); RememberChannel = new wxCheckBox(GeneralSettings, ID_REMEMBERCHANNEL, wxT("&Remember channel"), wxPoint(8, 8), wxSize(131, 17), 0, wxDefaultValidator, wxT("RememberChannel")); WxStaticText1 = new wxStaticText(GeneralSettings, ID_WXSTATICTEXT1, wxT("Start channel:"), wxPoint(8, 32), wxDefaultSize, 0, wxT("WxStaticText1")); WxStaticText2 = new wxStaticText(GeneralSettings, ID_WXSTATICTEXT2, wxT("Timer (quit after <n> min):"), wxPoint(8, 80), wxDefaultSize, 0, wxT("WxStaticText2")); StartChannel = new wxSpinCtrl(GeneralSettings, ID_STARTCHANNEL, wxT("0"), wxPoint(8, 48), wxSize(121, 24), wxSP_ARROW_KEYS, 0, 100, 0); Timer = new wxSpinCtrl(GeneralSettings, ID_TIMER, wxT("0"), wxPoint(8, 96), wxSize(121, 24), wxSP_ARROW_KEYS, 0, 100, 0); WxStaticText4 = new wxStaticText(GeneralSettings, ID_WXSTATICTEXT4, wxT("Channel list:"), wxPoint(8, 124), wxDefaultSize, 0, wxT("WxStaticText4")); ChannelList = new wxTextCtrl(GeneralSettings, ID_CHANNELLIST, wxT("ChannelList"), wxPoint(8, 140), wxSize(121, 19), 0, wxDefaultValidator, wxT("ChannelList")); BrowseChannelList = new wxButton(GeneralSettings, ID_BROWSECHANNELLIST, wxT("&Browse"), wxPoint(136, 137), wxSize(75, 25), 0, wxDefaultValidator, wxT("BrowseChannelList")); WxStaticText10 = new wxStaticText(GeneralSettings, ID_WXSTATICTEXT10, wxT("Channel surfing delay"), wxPoint(8, 163), wxDefaultSize, 0, wxT("wxStaticText10")); ChannelSurfingDelay = new wxSpinCtrl(GeneralSettings, ID_CHANNELSURFINGDELAY, wxT("0"), wxPoint(8, 179), wxSize(121, 24), wxSP_ARROW_KEYS, 0, 100, 0); WxStaticText11 = new wxStaticText(GeneralSettings, ID_WXSTATICTEXT11, wxT("Hide mouse in fullscreen after (-1 is never):"), wxPoint(8, 207), wxDefaultSize, 0, wxT("WxStaticText11")); HideMouseInFullscreenDelay = new wxSpinCtrl(GeneralSettings, ID_HIDEMOUSEINFULLSCREENDELAY, wxT("0"), wxPoint(8, 223), wxSize(121, 24), wxSP_ARROW_KEYS, 0, 100, 0); NetworkSettings = new wxPanel(WxNotebook1, ID_NETWORKSETTINGS, wxPoint(4, 26), wxSize(361, 230)); WxNotebook1->AddPage(NetworkSettings, wxT("&Network")); WxStaticText3 = new wxStaticText(NetworkSettings, ID_WXSTATICTEXT3, wxT("UDP delay:"), wxPoint(8, 51), wxDefaultSize, 0, wxT("WxStaticText3")); Delay = new wxSpinCtrl(NetworkSettings, ID_DELAY, wxT("0"), wxPoint(8, 67), wxSize(121, 24), wxSP_ARROW_KEYS, 0, 100, 0); WxStaticText5 = new wxStaticText(NetworkSettings, ID_WXSTATICTEXT5, wxT("Listen on address:"), wxPoint(8, 8), wxDefaultSize, 0, wxT("WxStaticText5")); Interface = new wxTextCtrl(NetworkSettings, ID_INTERFACE, wxT("Interface"), wxPoint(8, 24), wxSize(121, 19), 0, wxDefaultValidator, wxT("Interface")); OutputSettings = new wxPanel(WxNotebook1, ID_OUTPUTSETTINGS, wxPoint(4, 26), wxSize(361, 230)); WxNotebook1->AddPage(OutputSettings, wxT("&Output")); Fullscreen = new wxCheckBox(OutputSettings, ID_FULLSCREEN, wxT("Fullscreen"), wxPoint(8, 8), wxSize(97, 17), 0, wxDefaultValidator, wxT("Fullscreen")); Silent = new wxCheckBox(OutputSettings, ID_SILENT, wxT("Silent"), wxPoint(8, 32), wxSize(97, 17), 0, wxDefaultValidator, wxT("Silent")); Winfast = new wxCheckBox(OutputSettings, ID_WINFAST, wxT("Winfast hack"), wxPoint(8, 56), wxSize(97, 17), 0, wxDefaultValidator, wxT("Winfast"));#ifdef WIN32 Winfast->Enable(true);#else Winfast->Enable(false);#endif Record = new wxCheckBox(OutputSettings, ID_RECORD, wxT("Output to file:"), wxPoint(8, 80), wxSize(97, 17), 0, wxDefaultValidator, wxT("Record")); File = new wxTextCtrl(OutputSettings, ID_FILE, wxT("File"), wxPoint(8, 104), wxSize(121, 19), 0, wxDefaultValidator, wxT("File")); BrowseOutputFile = new wxButton(OutputSettings, ID_BROWSEOUTPUTFILE, wxT("&Browse"), wxPoint(136, 101), wxSize(75, 25), 0, wxDefaultValidator, wxT("BrowseOutputFile")); WxStaticText6 = new wxStaticText(OutputSettings, ID_WXSTATICTEXT6, wxT("&Output mode:"), wxPoint(8, 128), wxDefaultSize, 0, wxT("WxStaticText6")); wxArrayString modes; modes.Add(wxT("overlay"));#ifdef WIN32 modes.Add(wxT("GDI"));#endif // WIN32#if (HAVE_DDRAW_H) modes.Add(wxT("DDraw"));#endif#if (C_OPENGL) modes.Add(wxT("OpenGL"));#endif Mode = new wxComboBox(OutputSettings, ID_MODE, wxT("Mode"), wxPoint(8, 144), wxSize(145, 23), modes, wxCB_READONLY, wxDefaultValidator, wxT("Mode")); WxStaticText7 = new wxStaticText(OutputSettings, ID_WXSTATICTEXT7, wxT("Deinterlace:"), wxPoint(8, 168), wxDefaultSize, 0, wxT("WxStaticText7")); wxArrayString deinterlacers; deinterlacers.Add(wxT("weave")); deinterlacers.Add(wxT("discard")); deinterlacers.Add(wxT("mean")); deinterlacers.Add(wxT("blend")); Deinterlace = new wxComboBox(OutputSettings, ID_DEINTERLACE, wxT("Deinterlace"), wxPoint(8, 184), wxSize(145, 23), deinterlacers, wxCB_READONLY, wxDefaultValidator, wxT("Deinterlace")); WxStaticText9 = new wxStaticText(OutputSettings, ID_WXSTATICTEXT9, wxT("Recording directory:"), wxPoint(8, 210), wxDefaultSize, 0, wxT("WxStaticText9")); RecordingDir = new wxTextCtrl(OutputSettings, ID_RECORDINGDIR, wxT("RecordingDir"), wxPoint(8, 226), wxSize(121, 19), 0, wxDefaultValidator, wxT("RecordingDir")); BrowseRecordingDir = new wxButton(OutputSettings, ID_BROWSERECORDINGDIR, wxT("B&rowse"), wxPoint(136,223), wxSize(75, 25), 0, wxDefaultValidator, wxT("BrowseRecordingDir"));#if (C_HAS_LIBPOSTPROC) Postprocessing = new wxPanel(WxNotebook1, ID_POSTPROCESSING, wxPoint(4, 26), wxSize(361, 230)); WxNotebook1->AddPage(Postprocessing, wxT("&Postprocessing")); PPEnable = new wxCheckBox(Postprocessing, ID_PPENABLE, wxT("Enable &postprocessing"), wxPoint(8, 8), wxSize(131, 17), 0, wxDefaultValidator, wxT("PPEnable")); WxStaticText8 = new wxStaticText(Postprocessing, ID_WXSTATICTEXT8, wxT("Postprocessing mode:"), wxPoint(8, 32), wxDefaultSize, 0, wxT("WxStaticText8")); PPMode = new wxTextCtrl(Postprocessing, ID_PPMODE, wxT("PPMode"), wxPoint(8, 48), wxSize(121, 19), 0, wxDefaultValidator, wxT("PPMOde")); PPEnable->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Settings::OnPPEnableClick), NULL, this);#endif OKButton = new wxButton(this, ID_OKBUTTON, wxT("&OK"), wxPoint(96, 308), wxSize(75, 25), 0, wxDefaultValidator, wxT("OKButton")); CancelButton = new wxButton(this, ID_CANCELBUTTON, wxT("&Cancel"), wxPoint(192, 308), wxSize(75, 25), 0, wxDefaultValidator, wxT("CancelButton")); Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(Settings::OnClose)); OKButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Settings::OnOKButtonClick), NULL, this); CancelButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Settings::OnCancelButtonClick), NULL, this); BrowseChannelList->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Settings::OnBrowseChannelListClick), NULL, this); BrowseOutputFile->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Settings::OnBrowseOutputFileClick), NULL, this); BrowseRecordingDir->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Settings::OnBrowseRecordingDirClick), NULL, this); Record->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(Settings::OnRecordClick), NULL, this);}void Settings::OnClose(wxCloseEvent & event){ Show(false);}void Settings::OnOKButtonClick(wxCommandEvent & event){ sdl.rememberChannel = RememberChannel->GetValue(); sdl.ch_num = StartChannel->GetValue(); sdl.time = Timer->GetValue(); sdl.delay = Delay->GetValue(); sdl.channel_list = ChannelList->GetValue(); sdl.iface = Interface->GetValue(); sdl.screen.fullscreen = Fullscreen->GetValue(); sdl.silent = Silent->GetValue();#ifdef WIN32 sdl.winfast = Winfast->GetValue();#endif sdl.recording = Record->GetValue(); sdl.filename.assign(File->GetValue()); if(strcasecmp(Mode->GetValue().c_str(), "overlay") == 0) sdl.output_mode = OVERLAY;#ifdef WIN32 else if(strcasecmp(Mode->GetValue().c_str(), "GDI") == 0) sdl.output_mode = GDI;#endif // WIN32#if (HAVE_DDRAW_H) else if(strcasecmp(Mode->GetValue().c_str(), "DDraw") == 0) sdl.output_mode = DDRAW;#endif#if (C_OPENGL) else if(strcasecmp(Mode->GetValue().c_str(), "OpenGL") == 0) sdl.output_mode = OPENGL;#endif if(strcasecmp(Deinterlace->GetValue().c_str(), "weave") == 0) sdl.deint_mode = 0; else if(strcasecmp(Deinterlace->GetValue().c_str(), "discard") == 0) sdl.deint_mode = 1; else if(strcasecmp(Deinterlace->GetValue().c_str(), "mean") == 0) sdl.deint_mode = 2; else if(strcasecmp(Deinterlace->GetValue().c_str(), "blend") == 0) sdl.deint_mode = 3; sdl.recordingDir = RecordingDir->GetValue(); sdl.channelSurfingDelay = ChannelSurfingDelay->GetValue() * 1000; if(HideMouseInFullscreenDelay->GetValue() != -1) { sdl.hideMouseInFullscreenDelay = HideMouseInFullscreenDelay->GetValue() * 1000; } else { sdl.hideMouseInFullscreenDelay = HideMouseInFullscreenDelay->GetValue(); } if(sdl.renderer) sdl.renderer->SetDeinterlace(sdl.deint_mode); sdl_bar.SetDeinterlace(sdl.deint_mode);#if (C_HAS_LIBPOSTPROC) sdl.ppEnabled = PPEnable->GetValue(); sdl.ppMode.assign(PPMode->GetValue());#endif EndModal(1);}void Settings::OnCancelButtonClick(wxCommandEvent & event){ EndModal(0);}void Settings::OnBrowseOutputFileClick(wxCommandEvent & event){ wxString file = wxFileSelector(wxT("Choose output file"), wxT(""), File->GetValue(), wxT("ts"), wxT("MPEG transport stream (*.ts)|*.ts")); if(!file.empty()) { File->SetValue(file.c_str()); }}void Settings::OnBrowseChannelListClick(wxCommandEvent & event){ wxString file = wxFileSelector(wxT("Choose channel list file"), wxT(""), ChannelList->GetValue(), wxT("txt"), wxT("Text files (*.txt)|*.txt|Playlists (*.m3u)|*.m3u")); if(!file.empty()) { ChannelList->SetValue(file.c_str()); }}void Settings::OnRecordClick(wxCommandEvent & event){ File->Enable(event.IsChecked()); BrowseOutputFile->Enable(event.IsChecked());}void Settings::LoadSettings(){ RememberChannel->SetValue(sdl.rememberChannel); StartChannel->SetRange(1, sdl.channel->GetNum(true)); StartChannel->SetValue(sdl.ch_num); Timer->SetRange(0, INT_MAX); Timer->SetValue(sdl.time); Delay->SetRange(INT_MIN, INT_MAX); Delay->SetValue(sdl.delay); ChannelList->SetValue(wxT(sdl.channel_list.c_str())); Interface->SetValue(wxT(sdl.iface.c_str())); Fullscreen->SetValue(sdl.screen.fullscreen); Silent->SetValue(sdl.silent); ChannelSurfingDelay->SetRange(0, INT_MAX); ChannelSurfingDelay->SetValue(sdl.channelSurfingDelay / 1000); HideMouseInFullscreenDelay->SetRange(-1, INT_MAX); if(sdl.hideMouseInFullscreenDelay != -1) { HideMouseInFullscreenDelay->SetValue(sdl.hideMouseInFullscreenDelay / 1000); } else { HideMouseInFullscreenDelay->SetValue(-1); }#ifdef WIN32 Winfast->SetValue(sdl.winfast);#endif Record->SetValue(sdl.recording); File->SetValue(wxT(sdl.filename.c_str())); File->Enable(Record->GetValue()); BrowseOutputFile->Enable(Record->GetValue()); switch (sdl.output_mode) { case OVERLAY: Mode->SetValue(wxT("overlay")); break;#ifdef WIN32 case GDI: Mode->SetValue(wxT("GDI")); break;#endif // WIN32#if (HAVE_DDRAW_H) case DDRAW: Mode->SetValue(wxT("DDraw")); break;#endif#if (C_OPENGL) case OPENGL: Mode->SetValue(wxT("OpenGL")); break;#endif } Deinterlace->SetValue(Deinterlace->GetString(sdl.deint_mode)); RecordingDir->SetValue(sdl.recordingDir.c_str());#if (C_HAS_LIBPOSTPROC) PPEnable->SetValue(sdl.ppEnabled); PPMode->SetValue(wxT(sdl.ppMode.c_str())); PPMode->Enable(PPEnable->GetValue()); WxStaticText8->Enable(PPEnable->GetValue());#endif}void Settings::OnPPEnableClick(wxCommandEvent & event){#if (C_HAS_LIBPOSTPROC) PPMode->Enable(event.IsChecked()); WxStaticText8->Enable(event.IsChecked());#endif}void Settings::OnBrowseRecordingDirClick(wxCommandEvent & event){ wxString dir = wxDirSelector("Choose recording directory", wxT(RecordingDir->GetValue())); if(!dir.empty()) { RecordingDir->SetValue(dir); }}#endif // C_HAVE_WXGUI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -