00001 #include "mythtv/mythcontext.h"
00002
00003
00004 #include <unistd.h>
00005
00006
00007 #include <qfile.h>
00008 #include <qdialog.h>
00009 #include <qcursor.h>
00010 #include <qdir.h>
00011 #include <qimage.h>
00012 #include <qstringlist.h>
00013 #include <qprocess.h>
00014 #include <qapplication.h>
00015 #include <qobject.h>
00016
00017
00018 #include <mythtv/util.h>
00019 #include <mythtv/compat.h>
00020
00021
00022 #include "globalsettings.h"
00023 #include "mainvisual.h"
00024
00025
00026
00027 static HostLineEdit *SetMusicDirectory()
00028 {
00029 HostLineEdit *gc = new HostLineEdit("MusicLocation");
00030 gc->setLabel(QObject::tr("Directory to hold music"));
00031 #ifdef Q_WS_MACX
00032 gc->setValue(QDir::homeDirPath() + "/Music");
00033 #else
00034 gc->setValue("/mnt/store/music/");
00035 #endif
00036 gc->setHelpText(QObject::tr("This directory must exist, and the user "
00037 "running MythMusic needs to have write permission "
00038 "to the directory."));
00039 return gc;
00040 };
00041
00042 static HostComboBox *MusicAudioDevice()
00043 {
00044 HostComboBox *gc = new HostComboBox("MusicAudioDevice", true);
00045 gc->setLabel(QObject::tr("Audio device"));
00046 gc->addSelection(QObject::tr("default"), "default");
00047 QDir dev("/dev", "dsp*", QDir::Name, QDir::System);
00048 gc->fillSelectionsFromDir(dev);
00049 dev.setNameFilter("adsp*");
00050 gc->fillSelectionsFromDir(dev);
00051
00052 dev.setNameFilter("dsp*");
00053 dev.setPath("/dev/sound");
00054 gc->fillSelectionsFromDir(dev);
00055 dev.setNameFilter("adsp*");
00056 gc->fillSelectionsFromDir(dev);
00057 gc->setHelpText(QObject::tr("Audio Device used for playback. 'default' will use the device specified in MythTV"));
00058 return gc;
00059 };
00060
00061 static HostLineEdit *CDDevice()
00062 {
00063 HostLineEdit *gc = new HostLineEdit("CDDevice", true);
00064 gc->setLabel(QObject::tr("CD device"));
00065 gc->setValue("default");
00066 gc->setHelpText(QObject::tr("CDRom device used for ripping/playback."));
00067 return gc;
00068 };
00069
00070 static HostLineEdit *TreeLevels()
00071 {
00072 HostLineEdit *gc = new HostLineEdit("TreeLevels", true);
00073 gc->setLabel(QObject::tr("Tree Sorting"));
00074 gc->setValue("splitartist artist album title");
00075 gc->setHelpText(QObject::tr("Order in which to sort the Music "
00076 "Tree. Possible values are a space-separated list of "
00077 "genre, splitartist, splitartist1, artist, album, and "
00078 "title OR the keyword \"directory\" to indicate that "
00079 "the onscreen tree mirrors the filesystem."));
00080 return gc;
00081 };
00082
00083 static HostLineEdit *PostCDRipScript()
00084 {
00085 HostLineEdit *gc = new HostLineEdit("PostCDRipScript");
00086 gc->setLabel(QObject::tr("Script Path"));
00087 gc->setValue("");
00088 gc->setHelpText(QObject::tr("If present this script will be executed "
00089 "after a CD Rip is completed."));
00090 return gc;
00091 };
00092
00093 static HostLineEdit *NonID3FileNameFormat()
00094 {
00095 HostLineEdit *gc = new HostLineEdit("NonID3FileNameFormat");
00096 gc->setLabel(QObject::tr("Filename Format"));
00097 gc->setValue("GENRE/ARTIST/ALBUM/TRACK_TITLE");
00098 gc->setHelpText(QObject::tr("Directory and filename Format used to grab "
00099 "information if no ID3 information is found. Accepts "
00100 "GENRE, ARTIST, ALBUM, TITLE, ARTIST_TITLE and "
00101 "TRACK_TITLE."));
00102 return gc;
00103 };
00104
00105
00106 static HostCheckBox *IgnoreID3Tags()
00107 {
00108 HostCheckBox *gc = new HostCheckBox("Ignore_ID3");
00109 gc->setLabel(QObject::tr("Ignore ID3 Tags"));
00110 gc->setValue(false);
00111 gc->setHelpText(QObject::tr("If set, MythMusic will skip checking ID3 tags "
00112 "in files and just try to determine Genre, Artist, "
00113 "Album, and Track number and title from the "
00114 "filename."));
00115 return gc;
00116 };
00117
00118 static HostComboBox *TagEncoding()
00119 {
00120 HostComboBox *gc = new HostComboBox("MusicTagEncoding");
00121 gc->setLabel(QObject::tr("Tag Encoding"));
00122 gc->addSelection(QObject::tr("UTF-16"), "utf16");
00123 gc->addSelection(QObject::tr("UTF-8"), "utf8");
00124 gc->addSelection(QObject::tr("Ascii"), "ascii");
00125 gc->setHelpText(QObject::tr("Some mp3 players don't understand tags encoded in UTF8 or UTF16, this setting allows you to change the encoding format used. Currently applies only to ID3 tags."));
00126 return gc;
00127 };
00128
00129 static HostCheckBox *AutoLookupCD()
00130 {
00131 HostCheckBox *gc = new HostCheckBox("AutoLookupCD");
00132 gc->setLabel(QObject::tr("Automatically lookup CDs"));
00133 gc->setValue(true);
00134 gc->setHelpText(QObject::tr("Automatically lookup an audio CD if it is "
00135 "present and show its information in the "
00136 "Music Selection Tree."));
00137 return gc;
00138 };
00139
00140 static HostCheckBox *AutoPlayCD()
00141 {
00142 HostCheckBox *gc = new HostCheckBox("AutoPlayCD");
00143 gc->setLabel(QObject::tr("Automatically play CDs"));
00144 gc->setValue(false);
00145 gc->setHelpText(QObject::tr("Automatically put a new CD on the "
00146 "playlist and start playing the CD."));
00147 return gc;
00148 };
00149
00150 static HostCheckBox *KeyboardAccelerators()
00151 {
00152 HostCheckBox *gc = new HostCheckBox("KeyboardAccelerators");
00153 gc->setLabel(QObject::tr("Use Keyboard/Remote Accelerated Buttons"));
00154 gc->setValue(true);
00155 gc->setHelpText(QObject::tr("If this is not set, you will need "
00156 "to use arrow keys to select and activate "
00157 "various functions."));
00158 return gc;
00159 };
00160
00161
00162
00163 static HostComboBox *EncoderType()
00164 {
00165 HostComboBox *gc = new HostComboBox("EncoderType");
00166 gc->setLabel(QObject::tr("Encoding"));
00167 gc->addSelection(QObject::tr("Ogg Vorbis"), "ogg");
00168 gc->addSelection(QObject::tr("Lame (MP3)"), "mp3");
00169 gc->setHelpText(QObject::tr("Audio encoder to use for CD ripping. "
00170 "Note that the quality level 'Perfect' will use the "
00171 "FLAC encoder."));
00172 return gc;
00173 };
00174
00175 static HostComboBox *DefaultRipQuality()
00176 {
00177 HostComboBox *gc = new HostComboBox("DefaultRipQuality");
00178 gc->setLabel(QObject::tr("Default Rip Quality"));
00179 gc->addSelection(QObject::tr("Low"), "0");
00180 gc->addSelection(QObject::tr("Medium"), "1");
00181 gc->addSelection(QObject::tr("High"), "2");
00182 gc->addSelection(QObject::tr("Perfect"), "3");
00183 gc->setHelpText(QObject::tr("Default quality for new CD rips."));
00184 return gc;
00185 };
00186
00187 static HostCheckBox *Mp3UseVBR()
00188 {
00189 HostCheckBox *gc = new HostCheckBox("Mp3UseVBR");
00190 gc->setLabel(QObject::tr("Use variable bitrates"));
00191 gc->setValue(false);
00192 gc->setHelpText(QObject::tr("If set, the MP3 encoder will use variable "
00193 "bitrates (VBR) except for the low quality setting. "
00194 "The Ogg encoder will always use variable bitrates."));
00195 return gc;
00196 };
00197
00198 static HostLineEdit *FilenameTemplate()
00199 {
00200 HostLineEdit *gc = new HostLineEdit("FilenameTemplate");
00201 gc->setLabel(QObject::tr("File storage location"));
00202 gc->setValue("ARTIST/ALBUM/TRACK-TITLE");
00203 gc->setHelpText(QObject::tr("Defines the location/name for new songs. "
00204 "Valid tokens are: GENRE, ARTIST, ALBUM, "
00205 "TRACK, TITLE, YEAR"));
00206 return gc;
00207 };
00208
00209 static HostCheckBox *NoWhitespace()
00210 {
00211 HostCheckBox *gc = new HostCheckBox("NoWhitespace");
00212 gc->setLabel(QObject::tr("Replace ' ' with '_'"));
00213 gc->setValue(false);
00214 gc->setHelpText(QObject::tr("If set, whitespace characters in filenames "
00215 "will be replaced with underscore characters."));
00216 return gc;
00217 };
00218
00219 static HostComboBox *ParanoiaLevel()
00220 {
00221 HostComboBox *gc = new HostComboBox("ParanoiaLevel");
00222 gc->setLabel(QObject::tr("Paranoia Level"));
00223 gc->addSelection(QObject::tr("Full"), "Full");
00224 gc->addSelection(QObject::tr("Faster"), "Faster");
00225 gc->setHelpText(QObject::tr("Paranoia level of the CD ripper. Set to "
00226 "faster if you're not concerned about "
00227 "possible errors in the audio."));
00228 return gc;
00229 };
00230
00231 static HostCheckBox *EjectCD()
00232 {
00233 HostCheckBox *gc = new HostCheckBox("EjectCDAfterRipping");
00234 gc->setLabel(QObject::tr("Automatically eject CDs after ripping"));
00235 gc->setValue(true);
00236 gc->setHelpText(QObject::tr("If set, the CD tray will automatically open "
00237 "after the CD has been ripped."));
00238 return gc;
00239 };
00240
00241 static HostSpinBox *SetRatingWeight()
00242 {
00243 HostSpinBox *gc = new HostSpinBox("IntelliRatingWeight", 0, 100, 1);
00244 gc->setLabel(QObject::tr("Rating Weight"));
00245 gc->setValue(35);
00246 gc->setHelpText(QObject::tr("Used in \"Smart\" Shuffle mode. "
00247 "This weighting affects how much strength is "
00248 "given to your rating of a given track when "
00249 "ordering a group of songs."));
00250 return gc;
00251 };
00252
00253 static HostSpinBox *SetPlayCountWeight()
00254 {
00255 HostSpinBox *gc = new HostSpinBox("IntelliPlayCountWeight", 0, 100, 1);
00256 gc->setLabel(QObject::tr("Play Count Weight"));
00257 gc->setValue(25);
00258 gc->setHelpText(QObject::tr("Used in \"Smart\" Shuffle mode. "
00259 "This weighting affects how much strength is "
00260 "given to how many times a given track has been "
00261 "played when ordering a group of songs."));
00262 return gc;
00263 };
00264
00265 static HostSpinBox *SetLastPlayWeight()
00266 {
00267 HostSpinBox *gc = new HostSpinBox("IntelliLastPlayWeight", 0, 100, 1);
00268 gc->setLabel(QObject::tr("Last Play Weight"));
00269 gc->setValue(25);
00270 gc->setHelpText(QObject::tr("Used in \"Smart\" Shuffle mode. "
00271 "This weighting affects how much strength is "
00272 "given to how long it has been since a given "
00273 "track was played when ordering a group of songs."));
00274 return gc;
00275 };
00276
00277 static HostSpinBox *SetRandomWeight()
00278 {
00279 HostSpinBox *gc = new HostSpinBox("IntelliRandomWeight", 0, 100, 1);
00280 gc->setLabel(QObject::tr("Random Weight"));
00281 gc->setValue(15);
00282 gc->setHelpText(QObject::tr("Used in \"Smart\" Shuffle mode. "
00283 "This weighting affects how much strength is "
00284 "given to good old (peudo-)randomness "
00285 "when ordering a group of songs."));
00286 return gc;
00287 };
00288
00289 static HostSpinBox *SetSearchMaxResultsReturned()
00290 {
00291 HostSpinBox *gc = new HostSpinBox("MaxSearchResults", 0, 20000, 100);
00292 gc->setLabel(QObject::tr("Maximum Search Results"));
00293 gc->setValue(300);
00294 gc->setHelpText(QObject::tr("Used to limit the number of results "
00295 "returned when using the search feature."));
00296 return gc;
00297 };
00298
00299 static HostComboBox *ArtistTreeGroups()
00300 {
00301 HostComboBox *gc = new HostComboBox("ArtistTreeGroups");
00302 gc->setLabel(QObject::tr("Number of Artists Tree Groups"));
00303 gc->addSelection(QObject::tr("Few"), "0");
00304 gc->addSelection(QObject::tr("Average"), "1");
00305 gc->addSelection(QObject::tr("Many"), "2");
00306 gc->setHelpText(QObject::tr("Determines how many groups we have in the artist"
00307 " tree. Few gives 'A B C D' as per the old behaviour,"
00308 " average gives two letters per group, many gives one"
00309 " letter per group."));
00310 return gc;
00311 };
00312
00313 static HostCheckBox *UseShowRatings()
00314 {
00315 HostCheckBox *gc = new HostCheckBox("MusicShowRatings");
00316 gc->setLabel(QObject::tr("Show Song Ratings"));
00317 gc->setValue(false);
00318 gc->setHelpText(QObject::tr("Show song ratings on the playback screen."));
00319 return gc;
00320 };
00321
00322 static HostCheckBox *UseListShuffled()
00323 {
00324 HostCheckBox *gc = new HostCheckBox("ListAsShuffled");
00325 gc->setLabel(QObject::tr("List as Shuffled"));
00326 gc->setValue(false);
00327 gc->setHelpText(QObject::tr("List songs on the playback screen "
00328 "in the order they will be played."));
00329 return gc;
00330 };
00331
00332 static HostCheckBox *UseShowWholeTree()
00333 {
00334 HostCheckBox *gc = new HostCheckBox("ShowWholeTree");
00335 gc->setLabel(QObject::tr("Show entire music tree"));
00336 gc->setValue(false);
00337 gc->setHelpText(QObject::tr("If selected, you can navigate your entire "
00338 "music tree from the playing screen. N.B. Does not work "
00339 "with accelerated buttons disabled"));
00340 return gc;
00341 };
00342
00343
00344
00345 static HostComboBox *PlayMode()
00346 {
00347 HostComboBox *gc = new HostComboBox("PlayMode");
00348 gc->setLabel(QObject::tr("Play mode"));
00349 gc->addSelection(QObject::tr("Normal"), "normal");
00350 gc->addSelection(QObject::tr("Random"), "random");
00351 gc->addSelection(QObject::tr("Intelligent"), "intelligent");
00352 gc->addSelection(QObject::tr("Album"), "album");
00353 gc->setHelpText(QObject::tr("Starting shuffle mode for the player. Can be "
00354 "either normal, random, intelligent (random), or Album."));
00355 return gc;
00356 };
00357
00358 static HostComboBox *ResumeMode()
00359 {
00360 HostComboBox *gc = new HostComboBox("ResumeMode");
00361 gc->setLabel(QObject::tr("Resume mode"));
00362 gc->addSelection(QObject::tr("Off"), "off");
00363 gc->addSelection(QObject::tr("Track"), "track");
00364 gc->addSelection(QObject::tr("Exact"), "exact");
00365 gc->setHelpText(QObject::tr("Resume playback at either the beginning of the "
00366 "active play queue, the beginning of the last track, an exact point within "
00367 "the last track."));
00368 return gc;
00369 };
00370
00371 static HostSlider *VisualModeDelay()
00372 {
00373 HostSlider *gc = new HostSlider("VisualModeDelay", 0, 100, 1);
00374 gc->setLabel(QObject::tr("Delay before Visualizations start (seconds)"));
00375 gc->setValue(0);
00376 gc->setHelpText(QObject::tr("If set to 0, visualizations will never "
00377 "automatically start."));
00378 return gc;
00379 };
00380
00381 static HostCheckBox *VisualCycleOnSongChange()
00382 {
00383 HostCheckBox *gc = new HostCheckBox("VisualCycleOnSongChange");
00384 gc->setLabel(QObject::tr("Change Visualizer on each song"));
00385 gc->setValue(false);
00386 gc->setHelpText(QObject::tr("Change the visualizer when the song "
00387 "changes."));
00388 return gc;
00389 };
00390
00391 static HostCheckBox *ShowAlbumArtOnSongChange()
00392 {
00393 HostCheckBox *gc = new HostCheckBox("VisualAlbumArtOnSongChange");
00394 gc->setLabel(QObject::tr("Show Album Art at the start of each song"));
00395 gc->setValue(false);
00396 gc->setHelpText(QObject::tr("When the song changes and the new song has an album art "
00397 "image display it in the visualizer for a short period."));
00398 return gc;
00399 };
00400
00401 static HostCheckBox *VisualRandomize()
00402 {
00403 HostCheckBox *gc = new HostCheckBox("VisualRandomize");
00404 gc->setLabel(QObject::tr("Randomize Visualizer order"));
00405 gc->setValue(false);
00406 gc->setHelpText(QObject::tr("On changing the visualizer pick "
00407 "a new one at random."));
00408 return gc;
00409 };
00410
00411 static HostSpinBox *VisualScaleWidth()
00412 {
00413 HostSpinBox *gc = new HostSpinBox("VisualScaleWidth", 1, 2, 1);
00414 gc->setLabel(QObject::tr("Width for Visual Scaling"));
00415 gc->setValue(1);
00416 gc->setHelpText(QObject::tr("If set to \"2\", visualizations will be "
00417 "scaled in half. Currently only used by "
00418 "the goom visualization. Reduces CPU load "
00419 "on slower machines."));
00420 return gc;
00421 };
00422
00423 static HostSpinBox *VisualScaleHeight()
00424 {
00425 HostSpinBox *gc = new HostSpinBox("VisualScaleHeight", 1, 2, 1);
00426 gc->setLabel(QObject::tr("Height for Visual Scaling"));
00427 gc->setValue(1);
00428 gc->setHelpText(QObject::tr("If set to \"2\", visualizations will be "
00429 "scaled in half. Currently only used by "
00430 "the goom visualization. Reduces CPU load "
00431 "on slower machines."));
00432 return gc;
00433 };
00434
00435 static HostLineEdit *VisualizationMode()
00436 {
00437 HostLineEdit *gc = new HostLineEdit("VisualMode");
00438 gc->setLabel(QObject::tr("Visualizations"));
00439 gc->setRO();
00440 gc->setValue("Blank");
00441 gc->setHelpText(QObject::tr("List of visualizations to use during playback. "
00442 "Click the button below to edit this list"));
00443
00444 return gc;
00445 };
00446
00447 static TransButtonSetting *EditVisualizationModes()
00448 {
00449 TransButtonSetting *gc = new TransButtonSetting();
00450 gc->setLabel(QObject::tr("Edit Visualizations"));
00451 gc->setHelpText(QObject::tr("Edit the list of visualizations to use during playback."));
00452
00453 return gc;
00454 }
00455
00456
00457 static HostCheckBox *CDWriterEnabled()
00458 {
00459 HostCheckBox *gc = new HostCheckBox("CDWriterEnabled");
00460 gc->setLabel(QObject::tr("Enable CD Writing."));
00461 gc->setValue(true);
00462 gc->setHelpText(QObject::tr("Requires a SCSI or an IDE-SCSI CD Writer."));
00463 return gc;
00464 };
00465
00466 static HostLineEdit *CDWriterDevice()
00467 {
00468 HostLineEdit *gc = new HostLineEdit("CDWriterDevice");
00469 gc->setValue("default");
00470 gc->setLabel(QObject::tr("CD-Writer Device"));
00471 gc->setHelpText(QObject::tr("Select the SCSI or IDE Device for CD Writing.")
00472 + QObject::tr(" 'default' will let the "
00473 "MediaMonitor choose a device."));
00474 return gc;
00475 };
00476
00477 static HostComboBox *CDDiskSize()
00478 {
00479 HostComboBox *gc = new HostComboBox("CDDiskSize");
00480 gc->setLabel(QObject::tr("Disk Size"));
00481 gc->addSelection(QObject::tr("650MB/75min"), "1");
00482 gc->addSelection(QObject::tr("700MB/80min"), "2");
00483 gc->setHelpText(QObject::tr("Default CD Capacity."));
00484 return gc;
00485 };
00486
00487 static HostCheckBox *CDCreateDir()
00488 {
00489 HostCheckBox *gc = new HostCheckBox("CDCreateDir");
00490 gc->setLabel(QObject::tr("Enable directories on MP3 Creation"));
00491 gc->setValue(true);
00492 gc->setHelpText("");
00493 return gc;
00494 };
00495
00496 static HostComboBox *CDWriteSpeed()
00497 {
00498 HostComboBox *gc = new HostComboBox("CDWriteSpeed");
00499 gc->setLabel(QObject::tr("CD Write Speed"));
00500 gc->addSelection(QObject::tr("Auto"), "0");
00501 gc->addSelection("1x", "1");
00502 gc->addSelection("2x", "2");
00503 gc->addSelection("4x", "4");
00504 gc->addSelection("8x", "8");
00505 gc->addSelection("16x", "16");
00506 gc->setHelpText(QObject::tr("CD Writer speed. Auto will use the recomended "
00507 "speed."));
00508 return gc;
00509 };
00510
00511 static HostComboBox *CDBlankType()
00512 {
00513 HostComboBox *gc = new HostComboBox("CDBlankType");
00514 gc->setLabel(QObject::tr("CD Blanking Type"));
00515 gc->addSelection(QObject::tr("Fast"), "fast");
00516 gc->addSelection(QObject::tr("Complete"), "all");
00517 gc->setHelpText(QObject::tr("Blanking Method. Fast takes 1 minute. "
00518 "Complete can take up to 20 minutes."));
00519 return gc;
00520 };
00521
00522 MusicGeneralSettings::MusicGeneralSettings(void)
00523 {
00524 VerticalConfigurationGroup* general = new VerticalConfigurationGroup(false);
00525 general->setLabel(QObject::tr("General Settings (1)"));
00526 general->addChild(SetMusicDirectory());
00527 general->addChild(MusicAudioDevice());
00528 general->addChild(CDDevice());
00529 general->addChild(AutoLookupCD());
00530 general->addChild(AutoPlayCD());
00531 general->addChild(KeyboardAccelerators());
00532 addChild(general);
00533
00534 VerticalConfigurationGroup* general2 = new VerticalConfigurationGroup(false);
00535 general2->setLabel(QObject::tr("General Settings (2)"));
00536 general2->addChild(TreeLevels());
00537 general2->addChild(ArtistTreeGroups());
00538 general2->addChild(NonID3FileNameFormat());
00539 general2->addChild(IgnoreID3Tags());
00540 general2->addChild(TagEncoding());
00541 addChild(general2);
00542
00543 VerticalConfigurationGroup* general3 = new VerticalConfigurationGroup(false);
00544 general3->setLabel(QObject::tr("CD Recording Settings"));
00545 general3->addChild(CDWriterEnabled());
00546 general3->addChild(CDWriterDevice());
00547 general3->addChild(CDDiskSize());
00548 general3->addChild(CDCreateDir());
00549 general3->addChild(CDWriteSpeed());
00550 general3->addChild(CDBlankType());
00551 addChild(general3);
00552 }
00553
00554 MusicPlayerSettings::MusicPlayerSettings(void)
00555 {
00556 VerticalConfigurationGroup* playersettings = new VerticalConfigurationGroup(false);
00557 playersettings->setLabel(QObject::tr("Playback Settings"));
00558 playersettings->addChild(PlayMode());
00559 playersettings->addChild(ResumeMode());
00560 playersettings->addChild(SetSearchMaxResultsReturned());
00561 playersettings->addChild(UseShowRatings());
00562 playersettings->addChild(UseShowWholeTree());
00563 playersettings->addChild(UseListShuffled());
00564 addChild(playersettings);
00565
00566 VerticalConfigurationGroup* playersettings2 = new VerticalConfigurationGroup(false);
00567 playersettings2->setLabel(QObject::tr("Playback Settings (2)"));
00568 playersettings2->addChild(SetRatingWeight());
00569 playersettings2->addChild(SetPlayCountWeight());
00570 playersettings2->addChild(SetLastPlayWeight());
00571 playersettings2->addChild(SetRandomWeight());
00572 addChild(playersettings2);
00573
00574 VerticalConfigurationGroup* playersettings3 = new VerticalConfigurationGroup(false);
00575 playersettings3->setLabel(QObject::tr("Visualization Settings"));
00576
00577 visModesEdit = VisualizationMode();
00578 playersettings3->addChild(visModesEdit);
00579
00580 TransButtonSetting *button = EditVisualizationModes();
00581 playersettings3->addChild(button);
00582 connect(button, SIGNAL(pressed()), SLOT(showVisEditor()));
00583
00584 playersettings3->addChild(VisualCycleOnSongChange());
00585 playersettings3->addChild(ShowAlbumArtOnSongChange());
00586 playersettings3->addChild(VisualRandomize());
00587 playersettings3->addChild(VisualModeDelay());
00588 playersettings3->addChild(VisualScaleWidth());
00589 playersettings3->addChild(VisualScaleHeight());
00590 addChild(playersettings3);
00591 }
00592
00593 void MusicPlayerSettings::showVisEditor(void)
00594 {
00595 VisualizationsEditor *dialog = new VisualizationsEditor(visModesEdit->getValue(),
00596 gContext->GetMainWindow(), "viseditor");
00597 if (kDialogCodeAccepted == dialog->exec())
00598 visModesEdit->setValue(dialog->getSelectedModes());
00599
00600 delete dialog;
00601 }
00602
00603
00604 MusicRipperSettings::MusicRipperSettings(void)
00605 {
00606 VerticalConfigurationGroup* rippersettings = new VerticalConfigurationGroup(false);
00607 rippersettings->setLabel(QObject::tr("CD Ripper Settings"));
00608 rippersettings->addChild(ParanoiaLevel());
00609 rippersettings->addChild(FilenameTemplate());
00610 rippersettings->addChild(NoWhitespace());
00611 rippersettings->addChild(PostCDRipScript());
00612 rippersettings->addChild(EjectCD());
00613 addChild(rippersettings);
00614
00615 VerticalConfigurationGroup* encodersettings = new VerticalConfigurationGroup(false);
00616 encodersettings->setLabel(QObject::tr("CD Ripper Settings (part 2)"));
00617 encodersettings->addChild(EncoderType());
00618 encodersettings->addChild(DefaultRipQuality());
00619 encodersettings->addChild(Mp3UseVBR());
00620 addChild(encodersettings);
00621 }
00622
00623
00624
00625
00626
00627 VisualizationsEditor::VisualizationsEditor(const QString ¤tSelection,
00628 MythMainWindow *parent, const char *name)
00629 : MythDialog(parent, name)
00630 {
00631 QVBoxLayout *vbox = new QVBoxLayout(this, (int)(20 * wmult));
00632 QHBoxLayout *hbox = new QHBoxLayout(vbox, (int)(10 * wmult));
00633
00634
00635 QString message = tr("Visualizations");
00636 QLabel *label = new QLabel(message, this);
00637 label->setBackgroundOrigin(WindowOrigin);
00638 QFont font = label->font();
00639 font.setPointSize(int (font.pointSize() * 1.5));
00640 font.setBold(true);
00641 label->setFont(font);
00642 label->setPaletteForegroundColor(QColor("yellow"));
00643 label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
00644 hbox->addWidget(label);
00645
00646 hbox = new QHBoxLayout(vbox, (int)(10 * wmult));
00647 label = new QLabel(tr("Selected Visualizations"), this);
00648 label->setBackgroundOrigin(WindowOrigin);
00649 label->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
00650 hbox->addWidget(label);
00651
00652 label = new QLabel(tr("Available Visualizations"), this);
00653 label->setBackgroundOrigin(WindowOrigin);
00654 label->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
00655 hbox->addWidget(label);
00656
00657
00658 hbox = new QHBoxLayout(vbox, (int)(10 * wmult));
00659 selectedList = new MythListView(this);
00660 selectedList->addColumn(tr("Name"));
00661 selectedList->addColumn(tr("Provider"));
00662 selectedList->setSorting(-1);
00663 selectedList->setSelectionMode(QListView::Single);
00664 connect(selectedList, SIGNAL(currentChanged(QListViewItem *)),
00665 this, SLOT(selectedChanged(QListViewItem *)));
00666 connect(selectedList, SIGNAL(spacePressed(QListViewItem *)),
00667 this, SLOT(selectedOnSelect(QListViewItem *)));
00668 connect(selectedList, SIGNAL(returnPressed(QListViewItem *)),
00669 this, SLOT(selectedOnSelect(QListViewItem *)));
00670 selectedList->installEventFilter(this);
00671 hbox->addWidget(selectedList);
00672
00673
00674 availableList = new MythListView(this);
00675 availableList->addColumn(tr("Name"));
00676 availableList->addColumn(tr("Provider"));
00677 availableList->setSorting(0);
00678 connect(availableList, SIGNAL(currentChanged(QListViewItem *)),
00679 this, SLOT(availableChanged(QListViewItem *)));
00680 connect(availableList, SIGNAL(spacePressed(QListViewItem *)),
00681 this, SLOT(availableOnSelect(QListViewItem *)));
00682 connect(availableList, SIGNAL(returnPressed(QListViewItem *)),
00683 this, SLOT(availableOnSelect(QListViewItem *)));
00684 availableList->installEventFilter(this);
00685
00686 hbox->addWidget(availableList);
00687
00688
00689 hbox = new QHBoxLayout(vbox, (int)(10 * wmult));
00690 MythPushButton *button = new MythPushButton( this, "Program" );
00691 button->setBackgroundOrigin(WindowOrigin);
00692 button->setText( tr( "Move Up" ) );
00693 button->setEnabled(true);
00694 connect(button, SIGNAL(clicked()), this, SLOT(upClicked()));
00695 hbox->addWidget(button);
00696
00697 button = new MythPushButton( this, "Program" );
00698 button->setBackgroundOrigin(WindowOrigin);
00699 button->setText( tr( "Move Down" ) );
00700 button->setEnabled(true);
00701 connect(button, SIGNAL(clicked()), this, SLOT(downClicked()));
00702 hbox->addWidget(button);
00703
00704
00705 label = new QLabel(" ", this);
00706 label->setBackgroundOrigin(WindowOrigin);
00707 hbox->addWidget(label);
00708
00709 label = new QLabel(" ", this);
00710 label->setBackgroundOrigin(WindowOrigin);
00711 hbox->addWidget(label);
00712
00713
00714
00715 hbox = new QHBoxLayout(vbox, (int)(10 * wmult));
00716 button = new MythPushButton( this, "Program" );
00717 button->setBackgroundOrigin(WindowOrigin);
00718 button->setText( tr( "OK" ) );
00719 button->setEnabled(true);
00720 hbox->addWidget(button);
00721 connect(button, SIGNAL(clicked()), this, SLOT(okClicked()));
00722
00723
00724 button = new MythPushButton( this, "Program" );
00725 button->setBackgroundOrigin(WindowOrigin);
00726 button->setText( tr( "Cancel" ) );
00727 button->setEnabled(true);
00728 hbox->addWidget(button);
00729 connect(button, SIGNAL(clicked()), this, SLOT(cancelClicked()));
00730
00731 availableList->setFocus();
00732
00733 fillWidgets(currentSelection);
00734 }
00735
00736 void VisualizationsEditor::fillWidgets(const QString ¤tSelection)
00737 {
00738 QListViewItem *item;
00739 QStringList currentList = QStringList::split(";", currentSelection);
00740 QStringList visualizations = MainVisual::Visualizations();
00741 visualizations.sort();
00742
00743 item = NULL;
00744 for (uint i = 0; i < currentList.size(); i++)
00745 {
00746
00747 if (visualizations.find(currentList[i]) != visualizations.end())
00748 {
00749 QString visName, pluginName;
00750
00751 if (currentList[i].contains("-"))
00752 {
00753 pluginName = currentList[i].section('-', 0, 0);
00754 visName = currentList[i].section('-', 1, 1);
00755 }
00756 else
00757 {
00758 visName = currentList[i];
00759 pluginName = "MythMusic";
00760 }
00761
00762 item = new QListViewItem(selectedList, item, visName, pluginName);
00763 }
00764 else
00765 VERBOSE(VB_IMPORTANT, QString("'%1' is not in the list of supported visualizers")
00766 .arg(currentList[i]));
00767 }
00768
00769 item = NULL;
00770 for (uint i = 0; i < visualizations.size(); i++)
00771 {
00772 if (currentList.find(visualizations[i]) == currentList.end())
00773 {
00774 QString visName, pluginName;
00775
00776 if (visualizations[i].contains("-"))
00777 {
00778 pluginName = visualizations[i].section('-', 0, 0);
00779 visName = visualizations[i].section('-', 1, 1);
00780 }
00781 else
00782 {
00783 visName = visualizations[i];
00784 pluginName = "MythMusic";
00785 }
00786
00787 item = new QListViewItem(availableList, item, visName, pluginName);
00788 }
00789 }
00790
00791 if (selectedList->lastItem())
00792 {
00793 selectedList->setCurrentItem(selectedList->lastItem());
00794 selectedList->setSelected(selectedList->lastItem(), true);
00795 }
00796
00797 if (availableList->firstChild())
00798 {
00799 availableList->setCurrentItem(availableList->firstChild());
00800 availableList->setSelected(availableList->firstChild(), true);
00801 }
00802 }
00803
00804 VisualizationsEditor::~VisualizationsEditor()
00805 {
00806 }
00807
00808 void VisualizationsEditor::okClicked(void)
00809 {
00810 accept();
00811 }
00812
00813 void VisualizationsEditor::cancelClicked(void)
00814 {
00815 reject();
00816 }
00817
00818 void VisualizationsEditor::upClicked(void)
00819 {
00820 QListViewItem *item = selectedList->currentItem();
00821
00822 if (item)
00823 {
00824 QListViewItem *itemAbove = item->itemAbove();
00825 if (itemAbove)
00826 itemAbove = itemAbove->itemAbove();
00827
00828 if (itemAbove)
00829 item->moveItem(itemAbove);
00830 else
00831 {
00832 selectedList->takeItem(item);
00833 selectedList->insertItem(item);
00834 selectedList->setSelected(item, true);
00835 }
00836
00837 selectedList->ensureItemVisible(item);
00838 }
00839 }
00840
00841 void VisualizationsEditor::downClicked(void)
00842 {
00843 QListViewItem *item = selectedList->currentItem();
00844
00845 if (item)
00846 {
00847 QListViewItem *itemBelow = item->itemBelow();
00848 if (itemBelow)
00849 {
00850 item->moveItem(itemBelow);
00851 selectedList->ensureItemVisible(item);
00852 }
00853 }
00854 }
00855
00856 QString VisualizationsEditor::getSelectedModes(void)
00857 {
00858 QString res = "";
00859
00860 QListViewItem *item = selectedList->firstChild();
00861
00862 while (item)
00863 {
00864 if (res != "")
00865 res += ";";
00866
00867 if (item->text(1) == "MythMusic")
00868 res += item->text(0);
00869 else
00870 res += item->text(1) + "-" + item->text(0);
00871
00872 item = item->nextSibling();
00873 }
00874
00875 return res;
00876 }
00877
00878 void VisualizationsEditor::selectedChanged(QListViewItem *item)
00879 {
00880 if (item)
00881 item->setSelected(true);
00882 }
00883
00884 void VisualizationsEditor::availableChanged(QListViewItem *item)
00885 {
00886 if (item)
00887 item->setSelected(true);
00888 }
00889
00890 void VisualizationsEditor::availableOnSelect(QListViewItem *item)
00891 {
00892 if (item)
00893 {
00894 QListViewItem *currItem = selectedList->currentItem();
00895 if (!currItem)
00896 currItem = selectedList->lastItem();
00897
00898 availableList->takeItem(item);
00899 selectedList->insertItem(item);
00900 if (currItem)
00901 item->moveItem(currItem);
00902 selectedList->setSelected(item, true);
00903 selectedList->ensureItemVisible(item);
00904 }
00905 }
00906
00907 void VisualizationsEditor::selectedOnSelect(QListViewItem *item)
00908 {
00909 if (item)
00910 {
00911 selectedList->takeItem(item);
00912 availableList->insertItem(item);
00913 }
00914 }
00915
00916 bool VisualizationsEditor::eventFilter(QObject *obj, QEvent *e)
00917 {
00918 if (obj == selectedList || obj == availableList)
00919 {
00920 if (e->type() == QEvent::KeyPress)
00921 {
00922 QKeyEvent *k = (QKeyEvent *) e;
00923 if (handleKeyPress(k))
00924 return true;
00925 }
00926 }
00927
00928 return false;
00929 }
00930
00931 bool VisualizationsEditor::handleKeyPress(QKeyEvent *e)
00932 {
00933 bool handled = false;
00934 QStringList actions;
00935 if (gContext->GetMainWindow()->TranslateKeyPress("qt", e, actions))
00936 {
00937 for (unsigned int i = 0; i < actions.size() && !handled; i++)
00938 {
00939 QString action = actions[i];
00940
00941 if (action == "LEFT")
00942 {
00943 handled = true;
00944 focusNextPrevChild(false);
00945 }
00946 else if (action == "RIGHT")
00947 {
00948 handled = true;
00949 focusNextPrevChild(true);
00950 }
00951 }
00952 }
00953
00954 return handled;
00955 }