| 1 | /* fre:ac - free audio converter |
| 2 | * Copyright (C) 2001-2024 Robert Kausch <[email protected]> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation, either version 2 of |
| 7 | * the License, or (at your option) any later version. |
| 8 | * |
| 9 | * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
| 10 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 11 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ |
| 12 | |
| 13 | #include <gui/main_joblist.h> |
| 14 | |
| 15 | #include <startgui.h> |
| 16 | #include <joblist.h> |
| 17 | #include <config.h> |
| 18 | #include <utilities.h> |
| 19 | |
| 20 | #include <jobs/job.h> |
| 21 | #include <jobs/engine/convert.h> |
| 22 | |
| 23 | #include <gui/playback.h> |
| 24 | #include <gui/edit_folder.h> |
| 25 | |
| 26 | #include <dialogs/config/configcomponent.h> |
| 27 | |
| 28 | #include <dialogs/charset.h> |
| 29 | |
| 30 | using namespace smooth::GUI::Dialogs; |
| 31 | |
| 32 | using namespace BoCA; |
| 33 | using namespace BoCA::AS; |
| 34 | |
| 35 | freac::LayerJoblist::LayerJoblist() : Layer("Joblist") |
| 36 | { |
| 37 | BoCA::Config *config = BoCA::Config::Get(); |
| 38 | |
| 39 | dontUpdateInfo = False; |
| 40 | |
| 41 | clicked_charset = -1; |
| 42 | clicked_case = -1; |
| 43 | |
| 44 | activePopup = 0; |
| 45 | |
| 46 | previousTrackSeconds = 0; |
| 47 | previousTotalSeconds = 0; |
| 48 | |
| 49 | Point pos; |
| 50 | Size size; |
| 51 | |
| 52 | pos.x = 7; |
| 53 | pos.y = 96; |
| 54 | |
| 55 | txt_filename = new Text(NIL, pos); |
| 56 | txt_filename->SetOrientation(OR_LOWERLEFT); |
| 57 | |
| 58 | txt_filters = new Text(NIL, pos); |
| 59 | txt_filters->SetOrientation(OR_LOWERLEFT); |
| 60 | |
| 61 | pos.y -= 24; |
| 62 | |
| 63 | txt_format = new Text(NIL, pos); |
| 64 | txt_format->SetOrientation(OR_LOWERLEFT); |
| 65 | |
| 66 | txt_encoder = new Text(NIL, pos); |
| 67 | txt_encoder->SetOrientation(OR_LOWERLEFT); |
| 68 | |
| 69 | pos.y -= 24; |
| 70 | |
| 71 | txt_progress = new Text(NIL, pos); |
| 72 | txt_progress->SetOrientation(OR_LOWERLEFT); |
| 73 | |
| 74 | txt_time = new Text(NIL, pos); |
| 75 | txt_time->SetOrientation(OR_LOWERRIGHT); |
| 76 | |
| 77 | pos.y -= 24; |
| 78 | |
| 79 | txt_outdir = new Text(NIL, pos); |
| 80 | txt_outdir->SetOrientation(OR_LOWERLEFT); |
| 81 | |
| 82 | pos.x = 16; |
| 83 | pos.y = 24; |
| 84 | size.cx = config->GetIntValue(Config::CategorySettingsID, Config::SettingsWindowSizeXID, Config::SettingsWindowSizeXDefault) - 29; |
| 85 | size.cy = config->GetIntValue(Config::CategorySettingsID, Config::SettingsWindowSizeYID, Config::SettingsWindowSizeYDefault) - 264 - (config->GetIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault) ? 68 : 0); |
| 86 | |
| 87 | joblist = new JobList(pos, size); |
| 88 | joblist->getContextMenu.Connect(&LayerJoblist::GetContextMenu, this); |
| 89 | |
| 90 | shortcut_previous = new Shortcut(0, Input::Keyboard::KeyUp, joblist); |
| 91 | shortcut_previous->onKeyDown.Connect(&LayerJoblist::OnShortcutPrevious, this); |
| 92 | |
| 93 | shortcut_next = new Shortcut(0, Input::Keyboard::KeyDown, joblist); |
| 94 | shortcut_next->onKeyDown.Connect(&LayerJoblist::OnShortcutNext, this); |
| 95 | |
| 96 | shortcut_first = new Shortcut(0, Input::Keyboard::KeyHome, joblist); |
| 97 | shortcut_first->onKeyDown.Connect(&LayerJoblist::OnShortcutFirst, this); |
| 98 | |
| 99 | shortcut_last = new Shortcut(0, Input::Keyboard::KeyEnd, joblist); |
| 100 | shortcut_last->onKeyDown.Connect(&LayerJoblist::OnShortcutLast, this); |
| 101 | |
| 102 | shortcut_move_up = new Shortcut(SC_SHIFT, Input::Keyboard::KeyUp, joblist); |
| 103 | shortcut_move_up->onKeyDown.Connect(&LayerJoblist::OnShortcutMoveUp, this); |
| 104 | |
| 105 | shortcut_move_down = new Shortcut(SC_SHIFT, Input::Keyboard::KeyDown, joblist); |
| 106 | shortcut_move_down->onKeyDown.Connect(&LayerJoblist::OnShortcutMoveDown, this); |
| 107 | |
| 108 | shortcut_move_top = new Shortcut(SC_SHIFT, Input::Keyboard::KeyHome, joblist); |
| 109 | shortcut_move_top->onKeyDown.Connect(&LayerJoblist::OnShortcutMoveTop, this); |
| 110 | |
| 111 | shortcut_move_bottom = new Shortcut(SC_SHIFT, Input::Keyboard::KeyEnd, joblist); |
| 112 | shortcut_move_bottom->onKeyDown.Connect(&LayerJoblist::OnShortcutMoveBottom, this); |
| 113 | |
| 114 | shortcut_toggle_mark = new Shortcut(0, Input::Keyboard::KeySpace, joblist); |
| 115 | shortcut_toggle_mark->onKeyDown.Connect(&LayerJoblist::OnShortcutToggleMark, this); |
| 116 | |
| 117 | shortcut_remove = new Shortcut(0, Input::Keyboard::KeyDelete, joblist); |
| 118 | shortcut_remove->onKeyDown.Connect(&LayerJoblist::OnShortcutRemove, this); |
| 119 | |
| 120 | pos.x = 200; |
| 121 | pos.y += size.cy + 4; |
| 122 | size.cx = 90; |
| 123 | size.cy = 0; |
| 124 | |
| 125 | check_single = new CheckBox(NIL, pos, size, (Bool *) &config->GetPersistentIntValue(Config::CategorySettingsID, Config::SettingsEncodeToSingleFileID, Config::SettingsEncodeToSingleFileDefault)); |
| 126 | check_single->SetOrientation(OR_UPPERRIGHT); |
| 127 | |
| 128 | pos.x -= 100; |
| 129 | |
| 130 | check_playlist = new CheckBox(NIL, pos, size, (Bool *) &config->GetPersistentIntValue(Config::CategoryPlaylistID, Config::PlaylistCreatePlaylistID, Config::PlaylistCreatePlaylistDefault)); |
| 131 | check_playlist->SetOrientation(OR_UPPERRIGHT); |
| 132 | |
| 133 | pos.x -= 100; |
| 134 | |
| 135 | check_cuesheet = new CheckBox(NIL, pos, size, (Bool *) &config->GetPersistentIntValue(Config::CategoryPlaylistID, Config::PlaylistCreateCueSheetID, Config::PlaylistCreateCueSheetDefault)); |
| 136 | check_cuesheet->SetOrientation(OR_UPPERRIGHT); |
| 137 | |
| 138 | Registry &boca = Registry::Get(); |
| 139 | |
| 140 | if (boca.GetNumberOfComponentsOfType(COMPONENT_TYPE_OUTPUT) > 0) |
| 141 | { |
| 142 | pos.x = 242; |
| 143 | pos.y = 0; |
| 144 | |
| 145 | player = new PlaybackWidget(freacGUI::Get()->GetPlayer(), joblist); |
| 146 | player->SetPosition(pos); |
| 147 | player->SetOrientation(OR_UPPERRIGHT); |
| 148 | } |
| 149 | else |
| 150 | { |
| 151 | player = NIL; |
| 152 | } |
| 153 | |
| 154 | info_divider = new Divider(113 + (config->GetIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault) ? 68 : 0), OR_HORZ | OR_BOTTOM); |
| 155 | info_bottom = new Divider(113, OR_HORZ | OR_BOTTOM); |
| 156 | |
| 157 | pos.y = 121 + (config->GetIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault) ? 68 : 0); |
| 158 | pos.x = 5; |
| 159 | size.cx = 90; |
| 160 | size.cy = 17; |
| 161 | |
| 162 | info_background = new Layer(); |
| 163 | info_background->SetMetrics(pos, size); |
| 164 | info_background->SetOrientation(OR_LOWERLEFT); |
| 165 | info_background->SetBackgroundColor(Setup::BackgroundColor); |
| 166 | |
| 167 | pos.y = 0; |
| 168 | pos.x = 2; |
| 169 | size.cx = 86; |
| 170 | size.cy = 0; |
| 171 | |
| 172 | info_checkbox = new CheckBox(NIL, pos, size, (Bool *) &config->GetPersistentIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault)); |
| 173 | info_checkbox->onAction.Connect(&LayerJoblist::ShowHideTitleInfo, this); |
| 174 | |
| 175 | info_area_artwork = new ActiveArea(Setup::BackgroundColor, Point(7, 167), Size(46, 46)); |
| 176 | info_area_artwork->SetOrientation(OR_LOWERLEFT); |
| 177 | info_area_artwork->SetColor(Setup::ClientColor); |
| 178 | info_area_artwork->Hide(); |
| 179 | |
| 180 | info_image_artwork = new Image(NIL, Point(8, 166), Size(44, 44)); |
| 181 | info_image_artwork->SetOrientation(OR_LOWERLEFT); |
| 182 | info_image_artwork->Hide(); |
| 183 | |
| 184 | Add(info_area_artwork); |
| 185 | Add(info_image_artwork); |
| 186 | |
| 187 | pos.x = 7; |
| 188 | pos.y = 164; |
| 189 | |
| 190 | info_text_artist = new Text(NIL, pos); |
| 191 | info_text_artist->SetOrientation(OR_LOWERLEFT); |
| 192 | |
| 193 | pos.y -= 27; |
| 194 | |
| 195 | info_text_album = new Text(NIL, pos); |
| 196 | info_text_album->SetOrientation(OR_LOWERLEFT); |
| 197 | |
| 198 | pos.x += (7 + (Int) Math::Max(info_text_album->GetUnscaledTextWidth(), info_text_artist->GetUnscaledTextWidth())); |
| 199 | pos.y += 30; |
| 200 | size.cx = 180; |
| 201 | size.cy = 0; |
| 202 | |
| 203 | info_edit_artist = new EditBox(pos, size, 0); |
| 204 | info_edit_artist->onInput.Connect(&LayerJoblist::UpdateTitleInfo, this); |
| 205 | info_edit_artist->onEnter.Connect(&LayerJoblist::OnEditBoxEnterArtist, this); |
| 206 | info_edit_artist->SetOrientation(OR_LOWERLEFT); |
| 207 | |
| 208 | menu_edit_artist = new MicroMenu(Point(13, -7), Size(), OR_VERT); |
| 209 | menu_edit_artist->SetOrientation(OR_UPPERRIGHT); |
| 210 | menu_edit_artist->Hide(); |
| 211 | menu_edit_artist->onOpenPopupMenu.Connect(&LayerJoblist::ToggleEditPopup, this); |
| 212 | menu_edit_artist->onClosePopupMenu.Connect(&LayerJoblist::ToggleEditPopup, this); |
| 213 | |
| 214 | htsp_edit_artist = new Hotspot(Point(0, -7), Size(info_edit_artist->GetWidth(), info_edit_artist->GetHeight() + 7)); |
| 215 | htsp_edit_artist->SetIndependent(True); |
| 216 | htsp_edit_artist->onMouseOver.Connect(&MicroMenu::Show, menu_edit_artist); |
| 217 | htsp_edit_artist->onMouseOut.Connect(&MicroMenu::Hide, menu_edit_artist); |
| 218 | htsp_edit_artist->onActivate.Connect(&MicroMenu::Hide, menu_edit_artist); |
| 219 | |
| 220 | pos.y -= 27; |
| 221 | |
| 222 | info_edit_album = new EditBox(pos, size, 0); |
| 223 | info_edit_album->onInput.Connect(&LayerJoblist::UpdateTitleInfo, this); |
| 224 | info_edit_album->onEnter.Connect(&LayerJoblist::OnEditBoxEnterAlbum, this); |
| 225 | info_edit_album->SetOrientation(OR_LOWERLEFT); |
| 226 | |
| 227 | menu_edit_album = new MicroMenu(Point(13, -7), Size(), OR_VERT); |
| 228 | menu_edit_album->SetOrientation(OR_UPPERRIGHT); |
| 229 | menu_edit_album->Hide(); |
| 230 | menu_edit_album->onOpenPopupMenu.Connect(&LayerJoblist::ToggleEditPopup, this); |
| 231 | menu_edit_album->onClosePopupMenu.Connect(&LayerJoblist::ToggleEditPopup, this); |
| 232 | |
| 233 | htsp_edit_album = new Hotspot(Point(0, -7), Size(info_edit_album->GetWidth(), info_edit_album->GetHeight() + 7)); |
| 234 | htsp_edit_album->SetIndependent(True); |
| 235 | htsp_edit_album->onMouseOver.Connect(&MicroMenu::Show, menu_edit_album); |
| 236 | htsp_edit_album->onMouseOut.Connect(&MicroMenu::Hide, menu_edit_album); |
| 237 | htsp_edit_album->onActivate.Connect(&MicroMenu::Hide, menu_edit_album); |
| 238 | |
| 239 | pos.x += (7 + size.cx); |
| 240 | pos.y += 24; |
| 241 | |
| 242 | info_text_title = new Text(NIL, pos); |
| 243 | info_text_title->SetOrientation(OR_LOWERLEFT); |
| 244 | |
| 245 | pos.y -= 27; |
| 246 | |
| 247 | info_text_track = new Text(NIL, pos); |
| 248 | info_text_track->SetOrientation(OR_LOWERLEFT); |
| 249 | |
| 250 | pos.x += (7 + (Int) Math::Max(info_text_title->GetUnscaledTextWidth(), info_text_track->GetUnscaledTextWidth())); |
| 251 | pos.y += 30; |
| 252 | size.cx = 100; |
| 253 | |
| 254 | info_edit_title = new EditBox(pos, size, 0); |
| 255 | info_edit_title->onInput.Connect(&LayerJoblist::UpdateTitleInfo, this); |
| 256 | info_edit_title->onEnter.Connect(&LayerJoblist::OnEditBoxEnterTitle, this); |
| 257 | info_edit_title->SetOrientation(OR_LOWERLEFT); |
| 258 | |
| 259 | menu_edit_title = new MicroMenu(Point(13, -7), Size(), OR_VERT); |
| 260 | menu_edit_title->SetOrientation(OR_UPPERRIGHT); |
| 261 | menu_edit_title->Hide(); |
| 262 | menu_edit_title->onOpenPopupMenu.Connect(&LayerJoblist::ToggleEditPopup, this); |
| 263 | menu_edit_title->onClosePopupMenu.Connect(&LayerJoblist::ToggleEditPopup, this); |
| 264 | |
| 265 | htsp_edit_title = new Hotspot(Point(0, -7), Size(info_edit_title->GetWidth(), info_edit_title->GetHeight() + 7)); |
| 266 | htsp_edit_title->SetIndependent(True); |
| 267 | htsp_edit_title->onMouseOver.Connect(&MicroMenu::Show, menu_edit_title); |
| 268 | htsp_edit_title->onMouseOut.Connect(&MicroMenu::Hide, menu_edit_title); |
| 269 | htsp_edit_title->onActivate.Connect(&MicroMenu::Hide, menu_edit_title); |
| 270 | |
| 271 | pos.y -= 27; |
| 272 | size.cx = Font().GetUnscaledTextSizeX("000") + 7; |
| 273 | |
| 274 | info_edit_track = new EditBox(pos, size, 3); |
| 275 | info_edit_track->SetFlags(EDB_NUMERIC); |
| 276 | info_edit_track->onInput.Connect(&LayerJoblist::UpdateTitleInfo, this); |
| 277 | info_edit_track->onEnter.Connect(&LayerJoblist::OnEditBoxEnterTrack, this); |
| 278 | info_edit_track->SetOrientation(OR_LOWERLEFT); |
| 279 | |
| 280 | pos.x += (7 + size.cx); |
| 281 | pos.y -= 3; |
| 282 | |
| 283 | info_text_year = new Text(NIL, pos); |
| 284 | info_text_year->SetOrientation(OR_LOWERLEFT); |
| 285 | |
| 286 | pos.x += (7 + info_text_year->GetUnscaledTextWidth()); |
| 287 | pos.y += 3; |
| 288 | size.cx = Font().GetUnscaledTextSizeX("0000") + 7; |
| 289 | |
| 290 | info_edit_year = new EditBox(pos, size, 4); |
| 291 | info_edit_year->SetFlags(EDB_NUMERIC); |
| 292 | info_edit_year->onInput.Connect(&LayerJoblist::UpdateTitleInfo, this); |
| 293 | info_edit_year->onEnter.Connect(&LayerJoblist::OnEditBoxEnterYear, this); |
| 294 | info_edit_year->SetOrientation(OR_LOWERLEFT); |
| 295 | |
| 296 | menu_edit_year = new MicroMenu(Point(13, -7), Size(), OR_VERT); |
| 297 | menu_edit_year->SetOrientation(OR_UPPERRIGHT); |
| 298 | menu_edit_year->Hide(); |
| 299 | menu_edit_year->onOpenPopupMenu.Connect(&LayerJoblist::ToggleEditPopup, this); |
| 300 | menu_edit_year->onClosePopupMenu.Connect(&LayerJoblist::ToggleEditPopup, this); |
| 301 | |
| 302 | htsp_edit_year = new Hotspot(Point(0, -7), Size(info_edit_year->GetWidth(), info_edit_year->GetHeight() + 7)); |
| 303 | htsp_edit_year->SetIndependent(True); |
| 304 | htsp_edit_year->onMouseOver.Connect(&MicroMenu::Show, menu_edit_year); |
| 305 | htsp_edit_year->onMouseOut.Connect(&MicroMenu::Hide, menu_edit_year); |
| 306 | htsp_edit_year->onActivate.Connect(&MicroMenu::Hide, menu_edit_year); |
| 307 | |
| 308 | pos.x += (7 + size.cx); |
| 309 | pos.y -= 3; |
| 310 | |
| 311 | info_text_genre = new Text(NIL, pos); |
| 312 | info_text_genre->SetOrientation(OR_LOWERLEFT); |
| 313 | |
| 314 | info_list_genre = new List(); |
| 315 | Utilities::FillGenreList(info_list_genre); |
| 316 | |
| 317 | pos.x += (7 + info_text_genre->GetUnscaledTextWidth()); |
| 318 | pos.y += 3; |
| 319 | size.cx = 135; |
| 320 | |
| 321 | info_edit_genre = new EditBox(pos, size, 0); |
| 322 | info_edit_genre->onInput.Connect(&LayerJoblist::UpdateTitleInfo, this); |
| 323 | info_edit_genre->onEnter.Connect(&LayerJoblist::OnEditBoxEnterGenre, this); |
| 324 | info_edit_genre->SetOrientation(OR_LOWERLEFT); |
| 325 | info_edit_genre->SetDropDownList(info_list_genre); |
| 326 | |
| 327 | menu_edit_genre = new MicroMenu(Point(13, -7), Size(), OR_VERT); |
| 328 | menu_edit_genre->SetOrientation(OR_UPPERRIGHT); |
| 329 | menu_edit_genre->Hide(); |
| 330 | menu_edit_genre->onOpenPopupMenu.Connect(&LayerJoblist::ToggleEditPopup, this); |
| 331 | menu_edit_genre->onClosePopupMenu.Connect(&LayerJoblist::ToggleEditPopup, this); |
| 332 | |
| 333 | menu_charsets = new PopupMenu(); |
| 334 | menu_charsets_all = new PopupMenu(); |
| 335 | menu_case = new PopupMenu(); |
| 336 | menu_case_all = new PopupMenu(); |
| 337 | |
| 338 | htsp_edit_genre = new Hotspot(Point(0, -7), Size(info_edit_genre->GetWidth(), info_edit_genre->GetHeight() + 7)); |
| 339 | htsp_edit_genre->SetIndependent(True); |
| 340 | htsp_edit_genre->onMouseOver.Connect(&MicroMenu::Show, menu_edit_genre); |
| 341 | htsp_edit_genre->onMouseOut.Connect(&MicroMenu::Hide, menu_edit_genre); |
| 342 | htsp_edit_genre->onActivate.Connect(&MicroMenu::Hide, menu_edit_genre); |
| 343 | |
| 344 | info_edit_artist->Deactivate(); |
| 345 | info_edit_title->Deactivate(); |
| 346 | info_edit_album->Deactivate(); |
| 347 | info_edit_track->Deactivate(); |
| 348 | info_edit_year->Deactivate(); |
| 349 | info_edit_genre->Deactivate(); |
| 350 | |
| 351 | edb_filename = new EditBox(Point(0, 99), Size(0, 0), 1024); |
| 352 | edb_filename->SetOrientation(OR_LOWERLEFT); |
| 353 | edb_filename->Deactivate(); |
| 354 | |
| 355 | btn_skip = new Button(Bitmap(), Point(0, 103), Size(27, 27)); |
| 356 | btn_skip->SetOrientation(OR_LOWERLEFT); |
| 357 | btn_skip->SetFlags(BF_NOFRAME); |
| 358 | btn_skip->onAction.Connect(&onRequestSkipTrack); |
| 359 | btn_skip->Deactivate(); |
| 360 | |
| 361 | edb_filters = new EditBox(Point(0, 99), Size(0, 0), 1024); |
| 362 | edb_filters->SetOrientation(OR_LOWERLEFT); |
| 363 | edb_filters->Deactivate(); |
| 364 | |
| 365 | btn_configure_dsp = new Button(ImageLoader::Load(String(Config::Get()->resourcesPath).Append("icons/settings/settings-dsp.png")), Point(30, 103), Size(27, 27)); |
| 366 | btn_configure_dsp->SetOrientation(OR_LOWERRIGHT); |
| 367 | btn_configure_dsp->SetFlags(BF_NOFRAME); |
| 368 | btn_configure_dsp->onAction.Connect(&freacGUI::ConfigureProcessing, freacGUI::Get()); |
| 369 | |
| 370 | edb_format = new EditBox(Point(0, 75), Size(0, 0), 4); |
| 371 | edb_format->SetOrientation(OR_LOWERLEFT); |
| 372 | edb_format->Deactivate(); |
| 373 | |
| 374 | combo_encoder = new ComboBox(Point(0, 75), Size(0, 0)); |
| 375 | combo_encoder->SetOrientation(OR_LOWERLEFT); |
| 376 | combo_encoder->onSelectEntry.Connect(&LayerJoblist::OnSelectEncoder, this); |
| 377 | |
| 378 | for (Int i = 0; i < boca.GetNumberOfComponents(); i++) |
| 379 | { |
| 380 | if (boca.GetComponentType(i) != BoCA::COMPONENT_TYPE_ENCODER) continue; |
| 381 | |
| 382 | combo_encoder->AddEntry(boca.GetComponentName(i)); |
| 383 | } |
| 384 | |
| 385 | UpdateEncoderText(); |
| 386 | |
| 387 | btn_configure_encoder = new Button(ImageLoader::Load(String(Config::Get()->resourcesPath).Append("icons/settings/settings-codec.png")), Point(30, 79), Size(27, 27)); |
| 388 | btn_configure_encoder->SetOrientation(OR_LOWERRIGHT); |
| 389 | btn_configure_encoder->SetFlags(BF_NOFRAME); |
| 390 | btn_configure_encoder->onAction.Connect(&freacGUI::ConfigureEncoder, freacGUI::Get()); |
| 391 | |
| 392 | edb_outdir = new FolderEditBox(Point(0, 27), Size(0, 0), 1024); |
| 393 | edb_outdir->SetOrientation(OR_LOWERLEFT); |
| 394 | edb_outdir->onSelectEntry.Connect(&LayerJoblist::OnSelectFolder, this); |
| 395 | list_outdir = new List(); |
| 396 | |
| 397 | UpdateOutputDir(); |
| 398 | |
| 399 | btn_open = new Button(String(), Point(173, 28), Size(0, 0)); |
| 400 | btn_open->SetOrientation(OR_LOWERRIGHT); |
| 401 | btn_open->onAction.Connect(&LayerJoblist::OnOpenFolder, this); |
| 402 | |
| 403 | btn_browse = new Button(String(), Point(87, 28), Size(0, 0)); |
| 404 | btn_browse->SetOrientation(OR_LOWERRIGHT); |
| 405 | btn_browse->onAction.Connect(&LayerJoblist::OnBrowseForFolder, this); |
| 406 | |
| 407 | progress = new Progressbar(Point(0, 51), Size(0, 10), OR_HORZ, PB_NOTEXT, 0, 1000, 0); |
| 408 | progress->SetOrientation(OR_LOWERLEFT); |
| 409 | progress->Deactivate(); |
| 410 | |
| 411 | progress_total = new Progressbar(Point(0, 42), Size(0, 10), OR_HORZ, PB_NOTEXT, 0, 1000, 0); |
| 412 | progress_total->SetOrientation(OR_LOWERLEFT); |
| 413 | progress_total->Deactivate(); |
| 414 | |
| 415 | edb_trackPercent = new EditBox(Point(0, 51), Size(33, 0), 4); |
| 416 | edb_trackPercent->SetOrientation(OR_LOWERLEFT); |
| 417 | edb_trackPercent->Deactivate(); |
| 418 | |
| 419 | txt_splitPercent = new Text("/", Point(0, 48)); |
| 420 | txt_splitPercent->SetOrientation(OR_LOWERLEFT); |
| 421 | |
| 422 | edb_totalPercent = new EditBox(Point(0, 51), Size(33, 0), 4); |
| 423 | edb_totalPercent->SetOrientation(OR_LOWERLEFT); |
| 424 | edb_totalPercent->Deactivate(); |
| 425 | |
| 426 | edb_trackTime = new EditBox("00:00", Point(87, 51), Size(34, 0), 5); |
| 427 | edb_trackTime->SetWidth(Math::Max(34, edb_trackTime->GetUnscaledTextWidth() + 6)); |
| 428 | edb_trackTime->SetOrientation(OR_LOWERRIGHT); |
| 429 | edb_trackTime->Deactivate(); |
| 430 | |
| 431 | txt_splitTime = new Text("/", Point(50, 48)); |
| 432 | txt_splitTime->SetOrientation(OR_LOWERRIGHT); |
| 433 | |
| 434 | edb_totalTime = new EditBox("00:00", Point(41, 51), Size(34, 0), 5); |
| 435 | edb_totalTime->SetWidth(Math::Max(34, edb_totalTime->GetUnscaledTextWidth() + 6)); |
| 436 | edb_totalTime->SetOrientation(OR_LOWERRIGHT); |
| 437 | edb_totalTime->Deactivate(); |
| 438 | |
| 439 | menu_trackmenu = new PopupMenu(); |
| 440 | |
| 441 | Add(joblist); |
| 442 | |
| 443 | Add(shortcut_previous); |
| 444 | Add(shortcut_next); |
| 445 | Add(shortcut_move_up); |
| 446 | Add(shortcut_move_down); |
| 447 | |
| 448 | Add(check_single); |
| 449 | |
| 450 | if (boca.ComponentExists("cuesheet-playlist")) Add(check_cuesheet); |
| 451 | |
| 452 | if ( boca.GetNumberOfComponentsOfType(COMPONENT_TYPE_PLAYLIST) > 1 || |
| 453 | (boca.GetNumberOfComponentsOfType(COMPONENT_TYPE_PLAYLIST) > 0 && !boca.ComponentExists("cuesheet-playlist"))) Add(check_playlist); |
| 454 | |
| 455 | if (player != NIL) Add(player); |
| 456 | |
| 457 | Add(info_divider); |
| 458 | Add(info_bottom); |
| 459 | Add(info_background); |
| 460 | Add(info_text_artist); |
| 461 | Add(info_edit_artist); |
| 462 | Add(info_text_title); |
| 463 | Add(info_edit_title); |
| 464 | Add(info_text_album); |
| 465 | Add(info_edit_album); |
| 466 | Add(info_text_track); |
| 467 | Add(info_edit_track); |
| 468 | Add(info_text_year); |
| 469 | Add(info_edit_year); |
| 470 | Add(info_text_genre); |
| 471 | Add(info_edit_genre); |
| 472 | |
| 473 | Add(txt_filename); |
| 474 | Add(edb_filename); |
| 475 | Add(btn_skip); |
| 476 | |
| 477 | Add(txt_filters); |
| 478 | Add(edb_filters); |
| 479 | Add(btn_configure_dsp); |
| 480 | |
| 481 | Add(txt_format); |
| 482 | Add(edb_format); |
| 483 | |
| 484 | Add(txt_encoder); |
| 485 | Add(combo_encoder); |
| 486 | Add(btn_configure_encoder); |
| 487 | |
| 488 | Add(txt_progress); |
| 489 | Add(progress_total); |
| 490 | Add(progress); |
| 491 | Add(edb_trackPercent); |
| 492 | Add(txt_splitPercent); |
| 493 | Add(edb_totalPercent); |
| 494 | |
| 495 | Add(txt_time); |
| 496 | Add(edb_trackTime); |
| 497 | Add(txt_splitTime); |
| 498 | Add(edb_totalTime); |
| 499 | |
| 500 | Add(txt_outdir); |
| 501 | Add(edb_outdir); |
| 502 | Add(btn_open); |
| 503 | Add(btn_browse); |
| 504 | |
| 505 | Add(shortcut_first); |
| 506 | Add(shortcut_last); |
| 507 | Add(shortcut_move_top); |
| 508 | Add(shortcut_move_bottom); |
| 509 | Add(shortcut_toggle_mark); |
| 510 | Add(shortcut_remove); |
| 511 | |
| 512 | info_edit_artist->Add(menu_edit_artist); |
| 513 | info_edit_artist->Add(htsp_edit_artist); |
| 514 | info_edit_title->Add(menu_edit_title); |
| 515 | info_edit_title->Add(htsp_edit_title); |
| 516 | info_edit_album->Add(menu_edit_album); |
| 517 | info_edit_album->Add(htsp_edit_album); |
| 518 | info_edit_year->Add(menu_edit_year); |
| 519 | info_edit_year->Add(htsp_edit_year); |
| 520 | info_edit_genre->Add(menu_edit_genre); |
| 521 | info_edit_genre->Add(htsp_edit_genre); |
| 522 | |
| 523 | info_background->Add(info_checkbox); |
| 524 | |
| 525 | if (!config->GetIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault)) |
| 526 | { |
| 527 | info_bottom->Hide(); |
| 528 | info_text_artist->Hide(); |
| 529 | info_edit_artist->Hide(); |
| 530 | info_text_title->Hide(); |
| 531 | info_edit_title->Hide(); |
| 532 | info_text_album->Hide(); |
| 533 | info_edit_album->Hide(); |
| 534 | info_text_track->Hide(); |
| 535 | info_edit_track->Hide(); |
| 536 | info_text_year->Hide(); |
| 537 | info_edit_year->Hide(); |
| 538 | info_text_genre->Hide(); |
| 539 | info_edit_genre->Hide(); |
| 540 | } |
| 541 | |
| 542 | OnChangeConfigurationSettings(); |
| 543 | |
| 544 | /* Listen to configuration changes. |
| 545 | */ |
| 546 | BoCA::Settings::Get()->onChangeConfigurationSettings.Connect(&LayerJoblist::OnChangeConfigurationSettings, this); |
| 547 | BoCA::Settings::Get()->onChangeLanguageSettings.Connect(&LayerJoblist::OnChangeLanguageSettings, this); |
| 548 | |
| 549 | /* Listen to joblist changes. |
| 550 | */ |
| 551 | BoCA::JobList::Get()->onApplicationModifyTrack.Connect(&LayerJoblist::OnJoblistModifyTrack, this); |
| 552 | BoCA::JobList::Get()->onApplicationRemoveTrack.Connect(&LayerJoblist::OnJoblistRemoveTrack, this); |
| 553 | BoCA::JobList::Get()->onApplicationSelectTrack.Connect(&LayerJoblist::OnJoblistSelectTrack, this); |
| 554 | |
| 555 | BoCA::JobList::Get()->onApplicationRemoveAllTracks.Connect(&LayerJoblist::OnJoblistRemoveAllTracks, this); |
| 556 | |
| 557 | /* Listen to conversion progress updates. |
| 558 | */ |
| 559 | JobConvert::onStartEncoding.Connect(&LayerJoblist::OnEncoderStartEncoding, this); |
| 560 | JobConvert::onFinishEncoding.Connect(&LayerJoblist::OnEncoderFinishEncoding, this); |
| 561 | |
| 562 | JobConvert::onEncodeTrack.Connect(&LayerJoblist::OnEncoderEncodeTrack, this); |
| 563 | JobConvert::onReportProgress.Connect(&LayerJoblist::OnEncoderReportProgress, this); |
| 564 | |
| 565 | /* Connect other slots. |
| 566 | */ |
| 567 | onChangeSize.Connect(&LayerJoblist::OnChangeSize, this); |
| 568 | } |
| 569 | |
| 570 | freac::LayerJoblist::~LayerJoblist() |
| 571 | { |
| 572 | /* Disconnect configuration change slots. |
| 573 | */ |
| 574 | BoCA::Settings::Get()->onChangeConfigurationSettings.Disconnect(&LayerJoblist::OnChangeConfigurationSettings, this); |
| 575 | BoCA::Settings::Get()->onChangeLanguageSettings.Disconnect(&LayerJoblist::OnChangeLanguageSettings, this); |
| 576 | |
| 577 | /* Disconnect joblist change slots. |
| 578 | */ |
| 579 | BoCA::JobList::Get()->onApplicationModifyTrack.Disconnect(&LayerJoblist::OnJoblistModifyTrack, this); |
| 580 | BoCA::JobList::Get()->onApplicationRemoveTrack.Disconnect(&LayerJoblist::OnJoblistRemoveTrack, this); |
| 581 | BoCA::JobList::Get()->onApplicationSelectTrack.Disconnect(&LayerJoblist::OnJoblistSelectTrack, this); |
| 582 | |
| 583 | BoCA::JobList::Get()->onApplicationRemoveAllTracks.Disconnect(&LayerJoblist::OnJoblistRemoveAllTracks, this); |
| 584 | |
| 585 | /* Disconnect conversion progress update slots. |
| 586 | */ |
| 587 | JobConvert::onStartEncoding.Disconnect(&LayerJoblist::OnEncoderStartEncoding, this); |
| 588 | JobConvert::onFinishEncoding.Disconnect(&LayerJoblist::OnEncoderFinishEncoding, this); |
| 589 | |
| 590 | JobConvert::onEncodeTrack.Disconnect(&LayerJoblist::OnEncoderEncodeTrack, this); |
| 591 | JobConvert::onReportProgress.Disconnect(&LayerJoblist::OnEncoderReportProgress, this); |
| 592 | |
| 593 | /* Clear tracks. |
| 594 | */ |
| 595 | joblist->RemoveAllTracks(); |
| 596 | |
| 597 | /* Delete widgets. |
| 598 | */ |
| 599 | if (player != NIL) DeleteObject(player); |
| 600 | |
| 601 | DeleteObject(joblist); |
| 602 | |
| 603 | DeleteObject(shortcut_previous); |
| 604 | DeleteObject(shortcut_next); |
| 605 | DeleteObject(shortcut_first); |
| 606 | DeleteObject(shortcut_last); |
| 607 | DeleteObject(shortcut_move_up); |
| 608 | DeleteObject(shortcut_move_down); |
| 609 | DeleteObject(shortcut_move_top); |
| 610 | DeleteObject(shortcut_move_bottom); |
| 611 | DeleteObject(shortcut_toggle_mark); |
| 612 | DeleteObject(shortcut_remove); |
| 613 | |
| 614 | DeleteObject(check_single); |
| 615 | DeleteObject(check_cuesheet); |
| 616 | DeleteObject(check_playlist); |
| 617 | |
| 618 | DeleteObject(info_divider); |
| 619 | DeleteObject(info_bottom); |
| 620 | DeleteObject(info_background); |
| 621 | DeleteObject(info_checkbox); |
| 622 | DeleteObject(info_area_artwork); |
| 623 | DeleteObject(info_image_artwork); |
| 624 | DeleteObject(info_text_artist); |
| 625 | DeleteObject(info_edit_artist); |
| 626 | DeleteObject(info_text_title); |
| 627 | DeleteObject(info_edit_title); |
| 628 | DeleteObject(info_text_album); |
| 629 | DeleteObject(info_edit_album); |
| 630 | DeleteObject(info_text_track); |
| 631 | DeleteObject(info_edit_track); |
| 632 | DeleteObject(info_text_year); |
| 633 | DeleteObject(info_edit_year); |
| 634 | DeleteObject(info_text_genre); |
| 635 | DeleteObject(info_edit_genre); |
| 636 | DeleteObject(info_list_genre); |
| 637 | |
| 638 | DeleteObject(txt_filename); |
| 639 | DeleteObject(edb_filename); |
| 640 | DeleteObject(btn_skip); |
| 641 | |
| 642 | DeleteObject(txt_filters); |
| 643 | DeleteObject(edb_filters); |
| 644 | DeleteObject(btn_configure_dsp); |
| 645 | |
| 646 | DeleteObject(txt_format); |
| 647 | DeleteObject(edb_format); |
| 648 | |
| 649 | DeleteObject(txt_encoder); |
| 650 | DeleteObject(combo_encoder); |
| 651 | DeleteObject(btn_configure_encoder); |
| 652 | |
| 653 | DeleteObject(txt_progress); |
| 654 | DeleteObject(progress_total); |
| 655 | DeleteObject(progress); |
| 656 | DeleteObject(edb_trackPercent); |
| 657 | DeleteObject(txt_splitPercent); |
| 658 | DeleteObject(edb_totalPercent); |
| 659 | |
| 660 | DeleteObject(txt_time); |
| 661 | DeleteObject(edb_trackTime); |
| 662 | DeleteObject(txt_splitTime); |
| 663 | DeleteObject(edb_totalTime); |
| 664 | |
| 665 | DeleteObject(txt_outdir); |
| 666 | DeleteObject(edb_outdir); |
| 667 | DeleteObject(list_outdir); |
| 668 | DeleteObject(btn_open); |
| 669 | DeleteObject(btn_browse); |
| 670 | |
| 671 | DeleteObject(menu_edit_artist); |
| 672 | DeleteObject(htsp_edit_artist); |
| 673 | DeleteObject(menu_edit_title); |
| 674 | DeleteObject(htsp_edit_title); |
| 675 | DeleteObject(menu_edit_album); |
| 676 | DeleteObject(htsp_edit_album); |
| 677 | DeleteObject(menu_edit_year); |
| 678 | DeleteObject(htsp_edit_year); |
| 679 | DeleteObject(menu_edit_genre); |
| 680 | DeleteObject(htsp_edit_genre); |
| 681 | |
| 682 | DeleteObject(menu_trackmenu); |
| 683 | |
| 684 | DeleteObject(menu_charsets); |
| 685 | DeleteObject(menu_charsets_all); |
| 686 | DeleteObject(menu_case); |
| 687 | DeleteObject(menu_case_all); |
| 688 | } |
| 689 | |
| 690 | Void freac::LayerJoblist::OnChangeSize(const Size &nSize) |
| 691 | { |
| 692 | BoCA::Config *config = BoCA::Config::Get(); |
| 693 | |
| 694 | Rect clientRect = Rect(GetPosition(), GetSize()); |
| 695 | Size clientSize = Size(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); |
| 696 | |
| 697 | /* Update title info checkbox. |
| 698 | */ |
| 699 | Surface *surface = GetDrawSurface(); |
| 700 | |
| 701 | surface->StartPaint(Rect(info_background->GetRealPosition(), info_background->GetRealSize())); |
| 702 | |
| 703 | info_background->Hide(); |
| 704 | info_divider->SetPos(113 + (config->GetIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault) ? 68 : 0)); |
| 705 | info_background->SetY(121 + (config->GetIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault) ? 68 : 0)); |
| 706 | info_background->Show(); |
| 707 | |
| 708 | surface->EndPaint(); |
| 709 | |
| 710 | /* Update title info area. |
| 711 | */ |
| 712 | info_edit_title->SetX(Math::Min(clientSize.cx / 2 + 10 + (Int) Math::Max(info_text_title->GetUnscaledTextWidth(), info_text_track->GetUnscaledTextWidth()), clientSize.cx - 170 - info_text_genre->GetUnscaledTextWidth() - info_text_year->GetUnscaledTextWidth() - info_edit_year->GetWidth() - info_edit_track->GetWidth())); |
| 713 | info_edit_title->SetWidth(clientSize.cx - info_edit_title->GetX() - 7); |
| 714 | info_edit_track->SetX(info_edit_title->GetX()); |
| 715 | info_text_year->SetX(info_edit_track->GetX() + info_edit_track->GetWidth() + 7); |
| 716 | info_edit_year->SetX(info_text_year->GetX() + info_text_year->GetUnscaledTextWidth() + 7); |
| 717 | info_text_genre->SetX(info_edit_year->GetX() + info_edit_year->GetWidth() + 7); |
| 718 | info_text_title->SetX(info_edit_title->GetX() - (Int) Math::Max(info_text_title->GetUnscaledTextWidth(), info_text_track->GetUnscaledTextWidth()) - 7); |
| 719 | info_text_track->SetX(info_text_title->GetX()); |
| 720 | info_edit_artist->SetWidth(info_text_title->GetX() - info_edit_artist->GetX() - 7); |
| 721 | info_edit_album->SetWidth(info_edit_artist->GetWidth()); |
| 722 | info_edit_genre->SetX(info_text_genre->GetX() + info_text_genre->GetWidth() + 7); |
| 723 | info_edit_genre->SetWidth(clientSize.cx - info_edit_genre->GetX() - 7); |
| 724 | |
| 725 | htsp_edit_title->SetWidth(info_edit_title->GetWidth()); |
| 726 | htsp_edit_artist->SetWidth(info_edit_artist->GetWidth()); |
| 727 | htsp_edit_album->SetWidth(info_edit_album->GetWidth()); |
| 728 | htsp_edit_genre->SetWidth(info_edit_genre->GetWidth()); |
| 729 | |
| 730 | /* Update status area. |
| 731 | */ |
| 732 | Int maxTextSize = (Int) Math::Max(Math::Max(txt_progress->GetUnscaledTextWidth(), txt_outdir->GetUnscaledTextWidth()), Math::Max(txt_filename->GetUnscaledTextWidth(), txt_format->GetUnscaledTextWidth())); |
| 733 | Int maxTextSize2 = (Int) Math::Max(txt_filters->GetUnscaledTextWidth(), txt_encoder->GetUnscaledTextWidth()); |
| 734 | |
| 735 | txt_filters->SetX(clientSize.cx / 2 + maxTextSize2 - txt_filters->GetUnscaledTextWidth() + 3); |
| 736 | edb_filters->SetX(clientSize.cx / 2 + maxTextSize2 + 10); |
| 737 | |
| 738 | txt_encoder->SetX(clientSize.cx / 2 + maxTextSize2 - txt_encoder->GetUnscaledTextWidth() + 3); |
| 739 | combo_encoder->SetX(clientSize.cx / 2 + maxTextSize2 + 10); |
| 740 | |
| 741 | edb_filename->SetWidth(clientSize.cx / 2 - 14 - maxTextSize - btn_skip->GetWidth()); |
| 742 | edb_format->SetWidth(clientSize.cx / 2 - 18 - maxTextSize); |
| 743 | edb_filters->SetWidth(clientSize.cx - edb_filters->GetX() - btn_configure_dsp->GetWidth() - 3); |
| 744 | combo_encoder->SetWidth(edb_filters->GetWidth()); |
| 745 | edb_outdir->SetWidth(clientSize.cx - 33 - maxTextSize - btn_browse->GetWidth() - btn_open->GetWidth()); |
| 746 | |
| 747 | btn_skip->SetX(edb_filename->GetX() + edb_filename->GetWidth()); |
| 748 | |
| 749 | /* Update progress bar and time-left display. |
| 750 | */ |
| 751 | surface->StartPaint(Rect::EncloseRect(progress->GetVisibleArea(), edb_totalTime->GetVisibleArea())); |
| 752 | |
| 753 | progress->Hide(); |
| 754 | progress_total->Hide(); |
| 755 | |
| 756 | edb_trackPercent->Hide(); |
| 757 | txt_splitPercent->Hide(); |
| 758 | edb_totalPercent->Hide(); |
| 759 | |
| 760 | txt_time->Hide(); |
| 761 | edb_trackTime->Hide(); |
| 762 | txt_splitTime->Hide(); |
| 763 | edb_totalTime->Hide(); |
| 764 | |
| 765 | edb_totalTime->SetX(edb_totalTime->GetWidth() + 7); |
| 766 | txt_splitTime->SetX(edb_totalTime->GetX() + 9); |
| 767 | edb_trackTime->SetX(txt_splitTime->GetX() + edb_trackTime->GetWidth() + 3); |
| 768 | txt_time->SetX(edb_trackTime->GetX() + txt_time->GetUnscaledTextWidth() + 7); |
| 769 | |
| 770 | progress->SetWidth(clientSize.cx - 125 - maxTextSize - txt_time->GetUnscaledTextWidth() - edb_trackTime->GetWidth() - edb_totalTime->GetWidth()); |
| 771 | progress_total->SetWidth(clientSize.cx - 125 - maxTextSize - txt_time->GetUnscaledTextWidth() - edb_trackTime->GetWidth() - edb_totalTime->GetWidth()); |
| 772 | |
| 773 | edb_trackPercent->SetX(progress->GetX() + progress->GetWidth()); |
| 774 | txt_splitPercent->SetX(progress->GetX() + progress->GetWidth() + 36); |
| 775 | edb_totalPercent->SetX(progress->GetX() + progress->GetWidth() + 45); |
| 776 | |
| 777 | progress_total->Show(); |
| 778 | progress->Show(); |
| 779 | |
| 780 | edb_trackPercent->Show(); |
| 781 | txt_splitPercent->Show(); |
| 782 | edb_totalPercent->Show(); |
| 783 | |
| 784 | txt_time->Show(); |
| 785 | edb_trackTime->Show(); |
| 786 | txt_splitTime->Show(); |
| 787 | edb_totalTime->Show(); |
| 788 | |
| 789 | surface->EndPaint(); |
| 790 | |
| 791 | /* Update joblist size and checkbox positions. |
| 792 | */ |
| 793 | joblist->SetSize(Size(clientSize.cx - 23, clientSize.cy - 162 - (config->GetIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault) ? 68 : 0))); |
| 794 | |
| 795 | check_single->SetMetrics(Point(check_single->GetUnscaledTextWidth() + 28, joblist->GetY() + joblist->GetHeight() + 4), Size(check_single->GetUnscaledTextWidth() + 21, check_single->GetHeight())); |
| 796 | check_cuesheet->SetMetrics(Point(check_single->GetUnscaledTextWidth() + check_cuesheet->GetUnscaledTextWidth() + 53, joblist->GetY() + joblist->GetHeight() + 4), Size(check_cuesheet->GetUnscaledTextWidth() + 21, check_cuesheet->GetHeight())); |
| 797 | |
| 798 | if (Registry::Get().ComponentExists("cuesheet-playlist")) check_playlist->SetMetrics(Point(check_single->GetUnscaledTextWidth() + check_cuesheet->GetUnscaledTextWidth() + check_playlist->GetUnscaledTextWidth() + 78, joblist->GetY() + joblist->GetHeight() + 4), Size(check_playlist->GetUnscaledTextWidth() + 21, check_playlist->GetHeight())); |
| 799 | else check_playlist->SetMetrics(Point(check_single->GetUnscaledTextWidth() + check_playlist->GetUnscaledTextWidth() + 53, joblist->GetY() + joblist->GetHeight() + 4), Size(check_playlist->GetUnscaledTextWidth() + 21, check_playlist->GetHeight())); |
| 800 | } |
| 801 | |
| 802 | Void freac::LayerJoblist::OnChangeConfigurationSettings() |
| 803 | { |
| 804 | /* Get configuration. |
| 805 | */ |
| 806 | BoCA::Config *config = BoCA::Config::Get(); |
| 807 | |
| 808 | Bool enableProcessing = config->GetIntValue(Config::CategoryProcessingID, Config::ProcessingEnableProcessingID, Config::ProcessingEnableProcessingDefault); |
| 809 | String selectedFilters = config->GetStringValue(Config::CategoryProcessingID, Config::ProcessingComponentsID, Config::ProcessingComponentsDefault); |
| 810 | |
| 811 | /* Update title info area state. |
| 812 | */ |
| 813 | ShowHideTitleInfo(); |
| 814 | |
| 815 | /* Update list of filters in status area. |
| 816 | */ |
| 817 | BoCA::I18n *i18n = BoCA::I18n::Get(); |
| 818 | |
| 819 | i18n->SetContext("Joblist::Filters"); |
| 820 | |
| 821 | String componentNames = i18n->TranslateString("disabled"); |
| 822 | |
| 823 | if (enableProcessing) |
| 824 | { |
| 825 | componentNames = i18n->TranslateString("none"); |
| 826 | |
| 827 | if (selectedFilters != NIL) |
| 828 | { |
| 829 | Registry &boca = Registry::Get(); |
| 830 | |
| 831 | componentNames = NIL; |
| 832 | |
| 833 | const Array<String> &components = selectedFilters.Explode(","); |
| 834 | |
| 835 | foreach (const String &component, components) |
| 836 | { |
| 837 | AS::Component *dsp = boca.CreateComponentByID(component); |
| 838 | |
| 839 | if (dsp == NIL) continue; |
| 840 | |
| 841 | componentNames.Append(componentNames != NIL ? ", " : NIL).Append(dsp->GetName()); |
| 842 | |
| 843 | boca.DeleteComponent(dsp); |
| 844 | } |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | edb_filters->SetText(componentNames); |
| 849 | } |
| 850 | |
| 851 | Void freac::LayerJoblist::OnChangeLanguageSettings() |
| 852 | { |
| 853 | BoCA::I18n *i18n = BoCA::I18n::Get(); |
| 854 | |
| 855 | i18n->SetContext("Joblist"); |
| 856 | |
| 857 | SetText(i18n->TranslateString("Joblist")); |
| 858 | |
| 859 | /* Hide all affected widgets prior to changing |
| 860 | * labels to avoid flickering. |
| 861 | */ |
| 862 | Bool prevVisible = IsVisible(); |
| 863 | |
| 864 | if (prevVisible) Hide(); |
| 865 | |
| 866 | /* Change labels of joblist widgets. |
| 867 | */ |
| 868 | txt_filename->SetText(i18n->AddColon(i18n->TranslateString("Current file", "Joblist::File"))); |
| 869 | txt_filters->SetText(i18n->AddColon(i18n->TranslateString("Selected filters", "Joblist::Filters"))); |
| 870 | txt_format->SetText(i18n->AddColon(i18n->TranslateString("Active decoder", "Joblist::Decoder"))); |
| 871 | txt_encoder->SetText(i18n->AddColon(i18n->TranslateString("Selected encoder", "Joblist::Encoder"))); |
| 872 | txt_progress->SetText(i18n->AddColon(i18n->TranslateString("File progress"))); |
| 873 | txt_time->SetText(i18n->AddColon(i18n->TranslateString("Time left"))); |
| 874 | txt_outdir->SetText(i18n->AddColon(i18n->TranslateString("Output folder"))); |
| 875 | |
| 876 | edb_filename->SetText(i18n->TranslateString("none", "Joblist::File")); |
| 877 | edb_format->SetText(i18n->TranslateString("none", "Joblist::Decoder")); |
| 878 | |
| 879 | btn_skip->SetTooltipText(i18n->TranslateString("Skip current file", "Joblist::File")); |
| 880 | |
| 881 | btn_configure_dsp->SetTooltipText(i18n->TranslateString("Configure signal processing", "Joblist::Filters")); |
| 882 | btn_configure_encoder->SetTooltipText(i18n->TranslateString("Configure selected encoder", "Joblist::Encoder")); |
| 883 | |
| 884 | btn_open->SetText(i18n->TranslateString("Open")); |
| 885 | btn_browse->SetText(i18n->TranslateString("Select")); |
| 886 | |
| 887 | check_single->SetText(i18n->TranslateString("Encode to a single file")); |
| 888 | check_cuesheet->SetText(i18n->TranslateString("Create cue sheet")); |
| 889 | check_playlist->SetText(i18n->TranslateString("Create playlist")); |
| 890 | |
| 891 | info_text_artist->SetText(i18n->AddColon(i18n->TranslateString("Artist"))); |
| 892 | info_text_album->SetText(i18n->AddColon(i18n->TranslateString("Album"))); |
| 893 | info_text_title->SetText(i18n->AddColon(i18n->TranslateString("Title"))); |
| 894 | info_text_track->SetText(i18n->AddColon(i18n->TranslateString("Track"))); |
| 895 | info_text_year->SetText(i18n->AddColon(i18n->TranslateString("Year"))); |
| 896 | info_text_genre->SetText(i18n->AddColon(i18n->TranslateString("Genre"))); |
| 897 | |
| 898 | /* Now correct position and size of affected widgets. |
| 899 | */ |
| 900 | Int maxTextSize = (Int) Math::Max(Math::Max(txt_progress->GetUnscaledTextWidth(), txt_outdir->GetUnscaledTextWidth()), Math::Max(txt_filename->GetUnscaledTextWidth(), txt_format->GetUnscaledTextWidth())); |
| 901 | |
| 902 | txt_progress->SetX(maxTextSize + 7 - txt_progress->GetUnscaledTextWidth()); |
| 903 | txt_outdir->SetX(maxTextSize + 7 - txt_outdir->GetUnscaledTextWidth()); |
| 904 | txt_filename->SetX(maxTextSize + 7 - txt_filename->GetUnscaledTextWidth()); |
| 905 | txt_format->SetX(maxTextSize + 7 - txt_format->GetUnscaledTextWidth()); |
| 906 | txt_time->SetX(edb_trackTime->GetX() + txt_time->GetUnscaledTextWidth() + 7); |
| 907 | |
| 908 | edb_filename->SetX(maxTextSize + 14); |
| 909 | edb_format->SetX(maxTextSize + 14); |
| 910 | edb_outdir->SetX(maxTextSize + 14); |
| 911 | |
| 912 | edb_trackPercent->SetText(i18n->TranslateString("%1%", "Technical").Replace("%1", "0")); |
| 913 | edb_totalPercent->SetText(i18n->TranslateString("%1%", "Technical").Replace("%1", "0")); |
| 914 | |
| 915 | progress->SetX(maxTextSize + 14); |
| 916 | progress_total->SetX(maxTextSize + 14); |
| 917 | |
| 918 | btn_browse->SetWidth(Math::Max(80, btn_browse->GetUnscaledTextWidth() + 13)); |
| 919 | |
| 920 | Bitmap skipIcon = ImageLoader::Load(String(Config::Get()->resourcesPath).Append("icons/other/skip.png")); |
| 921 | |
| 922 | if (i18n->IsActiveLanguageRightToLeft()) Utilities::MirrorBitmap(skipIcon); |
| 923 | |
| 924 | btn_skip->SetBitmap(skipIcon); |
| 925 | btn_skip->SetX(btn_skip->GetWidth() + 7); |
| 926 | btn_browse->SetX(btn_browse->GetWidth() + 7); |
| 927 | |
| 928 | btn_open->SetWidth(Math::Max(80, btn_open->GetUnscaledTextWidth() + 13)); |
| 929 | btn_open->SetX(btn_browse->GetWidth() + btn_open->GetWidth() + 13); |
| 930 | |
| 931 | if (progress_total->GetRealPosition().y < progress->GetRealPosition().y + progress->GetRealSize().cy - 1) progress_total->SetMetrics(progress_total->GetPosition() - Point(0, 1), progress_total->GetSize() - Size(0, 1)); |
| 932 | |
| 933 | info_checkbox->SetText(i18n->TranslateString("Show title info")); |
| 934 | info_checkbox->SetWidth(info_checkbox->GetUnscaledTextWidth() + 20); |
| 935 | |
| 936 | info_background->Hide(); |
| 937 | info_divider->Paint(SP_PAINT); |
| 938 | info_background->SetWidth(info_checkbox->GetUnscaledTextWidth() + 24); |
| 939 | info_background->Show(); |
| 940 | |
| 941 | info_edit_artist->SetX(info_text_artist->GetX() + (Int) Math::Max(info_text_artist->GetUnscaledTextWidth(), info_text_album->GetUnscaledTextWidth()) + 7); |
| 942 | info_edit_album->SetX(info_edit_artist->GetX()); |
| 943 | |
| 944 | /* OnChangeSize will correct sizes of any other widgets. |
| 945 | */ |
| 946 | OnChangeSize(GetSize()); |
| 947 | |
| 948 | /* Show all widgets again. |
| 949 | */ |
| 950 | if (prevVisible) Show(); |
| 951 | |
| 952 | FillMenus(); |
| 953 | } |
| 954 | |
| 955 | Void freac::LayerJoblist::FillMenus() |
| 956 | { |
| 957 | BoCA::I18n *i18n = BoCA::I18n::Get(); |
| 958 | |
| 959 | i18n->SetContext("Joblist"); |
| 960 | |
| 961 | /* Fill track context menu. |
| 962 | */ |
| 963 | menu_trackmenu->RemoveAllEntries(); |
| 964 | |
| 965 | if (Registry::Get().GetNumberOfComponentsOfType(COMPONENT_TYPE_OUTPUT) > 0) |
| 966 | { |
| 967 | menu_trackmenu->AddEntry(i18n->TranslateString("Play"))->onAction.Connect(&PlaybackWidget::PlaySelectedItem, player); |
| 968 | menu_trackmenu->AddEntry(i18n->TranslateString("Stop"))->onAction.Connect(&PlaybackWidget::StopPlayback, player); |
| 969 | menu_trackmenu->AddEntry(); |
| 970 | } |
| 971 | |
| 972 | menu_trackmenu->AddEntry(i18n->TranslateString("Remove"))->onAction.Connect(&JobList::RemoveSelectedTrack, joblist); |
| 973 | menu_trackmenu->AddEntry(); |
| 974 | menu_trackmenu->AddEntry(i18n->TranslateString("Clear joblist"))->onAction.Connect(&JobList::StartJobRemoveAllTracks, joblist); |
| 975 | menu_trackmenu->AddEntry(); |
| 976 | menu_trackmenu->AddEntry(i18n->TranslateString("Select all"))->onAction.Connect(&JobList::SelectAll, joblist); |
| 977 | menu_trackmenu->AddEntry(i18n->TranslateString("Select none"))->onAction.Connect(&JobList::SelectNone, joblist); |
| 978 | menu_trackmenu->AddEntry(i18n->TranslateString("Toggle selection"))->onAction.Connect(&JobList::ToggleSelection, joblist); |
| 979 | |
| 980 | /* Emit overlay signal. |
| 981 | */ |
| 982 | BoCA::Menu *menu = BoCA::Menu::Get(); |
| 983 | |
| 984 | menu->doContextMenuOverlay.Emit(menu_trackmenu); |
| 985 | |
| 986 | /* Fill character sets menu. |
| 987 | */ |
| 988 | menu_charsets->RemoveAllEntries(); |
| 989 | menu_charsets_all->RemoveAllEntries(); |
| 990 | |
| 991 | menu_charsets->AddEntry("UTF-8", &clicked_charset, CHARSET_UTF_8)->onAction.Connect(&LayerJoblist::InterpretStringAs, this); |
| 992 | menu_charsets->AddEntry(); |
| 993 | menu_charsets->AddEntry("ISO-8859-1", &clicked_charset, CHARSET_ISO_8859_1)->onAction.Connect(&LayerJoblist::InterpretStringAs, this); |
| 994 | menu_charsets->AddEntry("ISO-8859-2", &clicked_charset, CHARSET_ISO_8859_2)->onAction.Connect(&LayerJoblist::InterpretStringAs, this); |
| 995 | menu_charsets->AddEntry("ISO-8859-5", &clicked_charset, CHARSET_ISO_8859_5)->onAction.Connect(&LayerJoblist::InterpretStringAs, this); |
| 996 | menu_charsets->AddEntry("ISO-8859-7", &clicked_charset, CHARSET_ISO_8859_7)->onAction.Connect(&LayerJoblist::InterpretStringAs, this); |
| 997 | menu_charsets->AddEntry(); |
| 998 | menu_charsets->AddEntry("CP1251", &clicked_charset, CHARSET_CP1251)->onAction.Connect(&LayerJoblist::InterpretStringAs, this); |
| 999 | menu_charsets->AddEntry(); |
| 1000 | menu_charsets->AddEntry("SHIFT-JIS", &clicked_charset, CHARSET_SHIFT_JIS)->onAction.Connect(&LayerJoblist::InterpretStringAs, this); |
| 1001 | menu_charsets->AddEntry("GBK", &clicked_charset, CHARSET_GBK)->onAction.Connect(&LayerJoblist::InterpretStringAs, this); |
| 1002 | menu_charsets->AddEntry("BIG-5", &clicked_charset, CHARSET_BIG_5)->onAction.Connect(&LayerJoblist::InterpretStringAs, this); |
| 1003 | menu_charsets->AddEntry(); |
| 1004 | menu_charsets->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Other")), &clicked_charset, CHARSET_OTHER)->onAction.Connect(&LayerJoblist::InterpretStringAs, this); |
| 1005 | |
| 1006 | menu_charsets_all->AddEntry("UTF-8", &clicked_charset, CHARSET_UTF_8)->onAction.Connect(&LayerJoblist::InterpretStringAsAll, this); |
| 1007 | menu_charsets_all->AddEntry(); |
| 1008 | menu_charsets_all->AddEntry("ISO-8859-1", &clicked_charset, CHARSET_ISO_8859_1)->onAction.Connect(&LayerJoblist::InterpretStringAsAll, this); |
| 1009 | menu_charsets_all->AddEntry("ISO-8859-2", &clicked_charset, CHARSET_ISO_8859_2)->onAction.Connect(&LayerJoblist::InterpretStringAsAll, this); |
| 1010 | menu_charsets_all->AddEntry("ISO-8859-5", &clicked_charset, CHARSET_ISO_8859_5)->onAction.Connect(&LayerJoblist::InterpretStringAsAll, this); |
| 1011 | menu_charsets_all->AddEntry("ISO-8859-7", &clicked_charset, CHARSET_ISO_8859_7)->onAction.Connect(&LayerJoblist::InterpretStringAsAll, this); |
| 1012 | menu_charsets_all->AddEntry(); |
| 1013 | menu_charsets_all->AddEntry("CP1251", &clicked_charset, CHARSET_CP1251)->onAction.Connect(&LayerJoblist::InterpretStringAsAll, this); |
| 1014 | menu_charsets_all->AddEntry(); |
| 1015 | menu_charsets_all->AddEntry("SHIFT-JIS", &clicked_charset, CHARSET_SHIFT_JIS)->onAction.Connect(&LayerJoblist::InterpretStringAsAll, this); |
| 1016 | menu_charsets_all->AddEntry("GBK", &clicked_charset, CHARSET_GBK)->onAction.Connect(&LayerJoblist::InterpretStringAsAll, this); |
| 1017 | menu_charsets_all->AddEntry("BIG-5", &clicked_charset, CHARSET_BIG_5)->onAction.Connect(&LayerJoblist::InterpretStringAsAll, this); |
| 1018 | menu_charsets_all->AddEntry(); |
| 1019 | menu_charsets_all->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Other")), &clicked_charset, CHARSET_OTHER)->onAction.Connect(&LayerJoblist::InterpretStringAsAll, this); |
| 1020 | |
| 1021 | /* Fill metadata edit menus. |
| 1022 | */ |
| 1023 | menu_edit_artist->RemoveAllEntries(); |
| 1024 | menu_edit_title->RemoveAllEntries(); |
| 1025 | menu_edit_album->RemoveAllEntries(); |
| 1026 | menu_edit_year->RemoveAllEntries(); |
| 1027 | menu_edit_genre->RemoveAllEntries(); |
| 1028 | |
| 1029 | menu_edit_artist->AddEntry(i18n->TranslateString("Use for all selected tracks"))->onAction.Connect(&LayerJoblist::UseStringForSelectedTracks, this); |
| 1030 | menu_edit_artist->AddEntry(); |
| 1031 | menu_edit_artist->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Adjust upper/lower case")), menu_case); |
| 1032 | menu_edit_artist->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Adjust upper/lower case")).Append(" (").Append(i18n->TranslateString("selected tracks")).Append(")"), NIL, menu_case_all); |
| 1033 | menu_edit_artist->AddEntry(); |
| 1034 | menu_edit_artist->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Interpret string as")), menu_charsets); |
| 1035 | menu_edit_artist->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Interpret string as")).Append(" (").Append(i18n->TranslateString("selected tracks")).Append(")"), NIL, menu_charsets_all); |
| 1036 | |
| 1037 | menu_edit_title->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Adjust upper/lower case")), menu_case); |
| 1038 | menu_edit_title->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Adjust upper/lower case")).Append(" (").Append(i18n->TranslateString("selected tracks")).Append(")"), NIL, menu_case_all); |
| 1039 | menu_edit_title->AddEntry(); |
| 1040 | menu_edit_title->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Interpret string as")), menu_charsets); |
| 1041 | menu_edit_title->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Interpret string as")).Append(" (").Append(i18n->TranslateString("selected tracks")).Append(")"), NIL, menu_charsets_all); |
| 1042 | |
| 1043 | menu_edit_album->AddEntry(i18n->TranslateString("Use for all selected tracks"))->onAction.Connect(&LayerJoblist::UseStringForSelectedTracks, this); |
| 1044 | menu_edit_album->AddEntry(); |
| 1045 | menu_edit_album->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Adjust upper/lower case")), menu_case); |
| 1046 | menu_edit_album->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Adjust upper/lower case")).Append(" (").Append(i18n->TranslateString("selected tracks")).Append(")"), NIL, menu_case_all); |
| 1047 | menu_edit_album->AddEntry(); |
| 1048 | menu_edit_album->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Interpret string as")), menu_charsets); |
| 1049 | menu_edit_album->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Interpret string as")).Append(" (").Append(i18n->TranslateString("selected tracks")).Append(")"), NIL, menu_charsets_all); |
| 1050 | |
| 1051 | menu_edit_genre->AddEntry(i18n->TranslateString("Use for all selected tracks"))->onAction.Connect(&LayerJoblist::UseStringForSelectedTracks, this); |
| 1052 | menu_edit_genre->AddEntry(); |
| 1053 | menu_edit_genre->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Interpret string as")), menu_charsets); |
| 1054 | menu_edit_genre->AddEntry(i18n->AddEllipsis(i18n->TranslateString("Interpret string as")).Append(" (").Append(i18n->TranslateString("selected tracks")).Append(")"), NIL, menu_charsets_all); |
| 1055 | |
| 1056 | menu_edit_year->AddEntry(i18n->TranslateString("Use for all selected tracks"))->onAction.Connect(&LayerJoblist::UseStringForSelectedTracks, this); |
| 1057 | } |
| 1058 | |
| 1059 | Void freac::LayerJoblist::UpdateEncoderText() |
| 1060 | { |
| 1061 | if (!combo_encoder->IsActive()) return; |
| 1062 | |
| 1063 | BoCA::Config *config = BoCA::Config::Get(); |
| 1064 | Registry &boca = Registry::Get(); |
| 1065 | Component *component = boca.CreateComponentByID(config->GetStringValue(Config::CategorySettingsID, Config::SettingsEncoderID, Config::SettingsEncoderDefault)); |
| 1066 | |
| 1067 | if (component == NIL) component = boca.CreateComponentByID(Config::SettingsEncoderDefault); |
| 1068 | |
| 1069 | if (component != NIL) |
| 1070 | { |
| 1071 | combo_encoder->SelectEntry(component->GetName()); |
| 1072 | |
| 1073 | boca.DeleteComponent(component); |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | Void freac::LayerJoblist::OnJoblistSelectTrack(const Track &track) |
| 1078 | { |
| 1079 | Surface *surface = GetDrawSurface(); |
| 1080 | |
| 1081 | surface->StartPaint(GetVisibleArea()); |
| 1082 | |
| 1083 | if (track.pictures.Length() > 0) ShowArtworkArea(); |
| 1084 | else HideArtworkArea(); |
| 1085 | |
| 1086 | info_edit_artist->Activate(); |
| 1087 | info_edit_title->Activate(); |
| 1088 | info_edit_album->Activate(); |
| 1089 | info_edit_track->Activate(); |
| 1090 | info_edit_year->Activate(); |
| 1091 | info_edit_genre->Activate(); |
| 1092 | |
| 1093 | OnJoblistModifyTrack(track); |
| 1094 | |
| 1095 | surface->EndPaint(); |
| 1096 | } |
| 1097 | |
| 1098 | Void freac::LayerJoblist::OnJoblistModifyTrack(const Track &track) |
| 1099 | { |
| 1100 | if (joblist->GetSelectedTrack().GetTrackID() != track.GetTrackID()) return; |
| 1101 | |
| 1102 | const Info &info = track.GetInfo(); |
| 1103 | |
| 1104 | dontUpdateInfo = True; |
| 1105 | |
| 1106 | if (track.pictures.Length() > 0) |
| 1107 | { |
| 1108 | if (currentArtwork != track.pictures.GetFirst()) |
| 1109 | { |
| 1110 | currentArtwork = track.pictures.GetFirst(); |
| 1111 | |
| 1112 | info_image_artwork->SetBitmap(currentArtwork.GetBitmap()); |
| 1113 | } |
| 1114 | |
| 1115 | ShowArtworkArea(); |
| 1116 | } |
| 1117 | else |
| 1118 | { |
| 1119 | HideArtworkArea(); |
| 1120 | } |
| 1121 | |
| 1122 | info_edit_artist->SetText(info.artist); |
| 1123 | info_edit_title->SetText(info.title); |
| 1124 | info_edit_album->SetText(info.album); |
| 1125 | |
| 1126 | if (info.track <= 0) info_edit_track->SetText(NIL); |
| 1127 | else if (info.track < 10) info_edit_track->SetText(String("0").Append(String::FromInt(info.track))); |
| 1128 | else info_edit_track->SetText(String::FromInt(info.track)); |
| 1129 | |
| 1130 | if (info.year <= 0) info_edit_year->SetText(NIL); |
| 1131 | else info_edit_year->SetText(String::FromInt(info.year)); |
| 1132 | |
| 1133 | info_edit_genre->SetText(info.genre); |
| 1134 | |
| 1135 | dontUpdateInfo = False; |
| 1136 | } |
| 1137 | |
| 1138 | Void freac::LayerJoblist::OnJoblistRemoveTrack(const Track &track) |
| 1139 | { |
| 1140 | /* Clear and deactivate edit boxes if the selected track is removed. |
| 1141 | */ |
| 1142 | if (joblist->GetSelectedTrack().GetTrackID() == track.GetTrackID()) |
| 1143 | { |
| 1144 | dontUpdateInfo = True; |
| 1145 | |
| 1146 | Surface *surface = GetDrawSurface(); |
| 1147 | |
| 1148 | surface->StartPaint(GetVisibleArea()); |
| 1149 | |
| 1150 | HideArtworkArea(); |
| 1151 | |
| 1152 | info_edit_artist->SetText(NIL); |
| 1153 | info_edit_title->SetText(NIL); |
| 1154 | info_edit_album->SetText(NIL); |
| 1155 | info_edit_track->SetText(NIL); |
| 1156 | info_edit_year->SetText(NIL); |
| 1157 | info_edit_genre->SetText(NIL); |
| 1158 | |
| 1159 | info_edit_artist->Deactivate(); |
| 1160 | info_edit_title->Deactivate(); |
| 1161 | info_edit_album->Deactivate(); |
| 1162 | info_edit_track->Deactivate(); |
| 1163 | info_edit_year->Deactivate(); |
| 1164 | info_edit_genre->Deactivate(); |
| 1165 | |
| 1166 | surface->EndPaint(); |
| 1167 | |
| 1168 | dontUpdateInfo = False; |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | Void freac::LayerJoblist::OnJoblistRemoveAllTracks() |
| 1173 | { |
| 1174 | /* Clear and deactivate edit boxes. |
| 1175 | */ |
| 1176 | dontUpdateInfo = True; |
| 1177 | |
| 1178 | Surface *surface = GetDrawSurface(); |
| 1179 | |
| 1180 | surface->StartPaint(GetVisibleArea()); |
| 1181 | |
| 1182 | HideArtworkArea(); |
| 1183 | |
| 1184 | info_edit_artist->SetText(NIL); |
| 1185 | info_edit_title->SetText(NIL); |
| 1186 | info_edit_album->SetText(NIL); |
| 1187 | info_edit_track->SetText(NIL); |
| 1188 | info_edit_year->SetText(NIL); |
| 1189 | info_edit_genre->SetText(NIL); |
| 1190 | |
| 1191 | info_edit_artist->Deactivate(); |
| 1192 | info_edit_title->Deactivate(); |
| 1193 | info_edit_album->Deactivate(); |
| 1194 | info_edit_track->Deactivate(); |
| 1195 | info_edit_year->Deactivate(); |
| 1196 | info_edit_genre->Deactivate(); |
| 1197 | |
| 1198 | surface->EndPaint(); |
| 1199 | |
| 1200 | dontUpdateInfo = False; |
| 1201 | } |
| 1202 | |
| 1203 | EditBox *freac::LayerJoblist::GetActiveEditBox() |
| 1204 | { |
| 1205 | if (info_edit_artist->IsFocussed()) return info_edit_artist; |
| 1206 | else if (info_edit_title->IsFocussed()) return info_edit_title; |
| 1207 | else if (info_edit_album->IsFocussed()) return info_edit_album; |
| 1208 | else if (info_edit_track->IsFocussed()) return info_edit_track; |
| 1209 | else if (info_edit_year->IsFocussed()) return info_edit_year; |
| 1210 | else if (info_edit_genre->IsFocussed()) return info_edit_genre; |
| 1211 | |
| 1212 | return NIL; |
| 1213 | } |
| 1214 | |
| 1215 | Void freac::LayerJoblist::FocusEditBox(EditBox *editBox) |
| 1216 | { |
| 1217 | editBox->SetFocus(); |
| 1218 | editBox->MarkAll(); |
| 1219 | } |
| 1220 | |
| 1221 | Void freac::LayerJoblist::ShowArtworkArea() |
| 1222 | { |
| 1223 | if (info_text_artist->GetX() > 7) return; |
| 1224 | |
| 1225 | htsp_edit_artist->SetWidth(htsp_edit_artist->GetWidth() - 54); |
| 1226 | htsp_edit_album->SetWidth(htsp_edit_album->GetWidth() - 54); |
| 1227 | |
| 1228 | info_edit_artist->SetWidth(info_edit_artist->GetWidth() - 54); |
| 1229 | info_edit_album->SetWidth(info_edit_album->GetWidth() - 54); |
| 1230 | |
| 1231 | info_edit_artist->SetX(info_edit_artist->GetX() + 54); |
| 1232 | info_edit_album->SetX(info_edit_album->GetX() + 54); |
| 1233 | |
| 1234 | info_text_artist->SetX(info_text_artist->GetX() + 54); |
| 1235 | info_text_album->SetX(info_text_album->GetX() + 54); |
| 1236 | |
| 1237 | BoCA::Config *config = BoCA::Config::Get(); |
| 1238 | |
| 1239 | if (config->GetIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault)) |
| 1240 | { |
| 1241 | info_area_artwork->Show(); |
| 1242 | info_image_artwork->Show(); |
| 1243 | } |
| 1244 | } |
| 1245 | |
| 1246 | Void freac::LayerJoblist::HideArtworkArea() |
| 1247 | { |
| 1248 | if (info_text_artist->GetX() == 7) return; |
| 1249 | |
| 1250 | BoCA::Config *config = BoCA::Config::Get(); |
| 1251 | |
| 1252 | if (config->GetIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault)) |
| 1253 | { |
| 1254 | info_area_artwork->Hide(); |
| 1255 | info_image_artwork->Hide(); |
| 1256 | } |
| 1257 | |
| 1258 | info_text_artist->SetX(info_text_artist->GetX() - 54); |
| 1259 | info_text_album->SetX(info_text_album->GetX() - 54); |
| 1260 | |
| 1261 | info_edit_artist->SetX(info_edit_artist->GetX() - 54); |
| 1262 | info_edit_album->SetX(info_edit_album->GetX() - 54); |
| 1263 | |
| 1264 | info_edit_artist->SetWidth(info_edit_artist->GetWidth() + 54); |
| 1265 | info_edit_album->SetWidth(info_edit_album->GetWidth() + 54); |
| 1266 | |
| 1267 | htsp_edit_artist->SetWidth(htsp_edit_artist->GetWidth() + 54); |
| 1268 | htsp_edit_album->SetWidth(htsp_edit_album->GetWidth() + 54); |
| 1269 | } |
| 1270 | |
| 1271 | Void freac::LayerJoblist::OnShortcutPrevious() |
| 1272 | { |
| 1273 | if (!IsVisible()) return; |
| 1274 | |
| 1275 | EditBox *activeEditBox = GetActiveEditBox(); |
| 1276 | |
| 1277 | if (joblist->GetSelectedEntryNumber() == -1) joblist->SelectNthEntry(joblist->Length() - 1); |
| 1278 | else joblist->SelectNthEntry(joblist->GetSelectedEntryNumber() - 1); |
| 1279 | |
| 1280 | if (activeEditBox != NIL) FocusEditBox(activeEditBox); |
| 1281 | else FocusEditBox(info_edit_artist); |
| 1282 | } |
| 1283 | |
| 1284 | Void freac::LayerJoblist::OnShortcutNext() |
| 1285 | { |
| 1286 | if (!IsVisible()) return; |
| 1287 | |
| 1288 | EditBox *activeEditBox = GetActiveEditBox(); |
| 1289 | |
| 1290 | joblist->SelectNthEntry(joblist->GetSelectedEntryNumber() + 1); |
| 1291 | |
| 1292 | if (activeEditBox != NIL) FocusEditBox(activeEditBox); |
| 1293 | else FocusEditBox(info_edit_artist); |
| 1294 | } |
| 1295 | |
| 1296 | Void freac::LayerJoblist::OnShortcutFirst() |
| 1297 | { |
| 1298 | if (!IsVisible() || GetActiveEditBox() != NIL) return; |
| 1299 | |
| 1300 | EditBox *activeEditBox = GetActiveEditBox(); |
| 1301 | |
| 1302 | joblist->SelectNthEntry(0); |
| 1303 | |
| 1304 | if (activeEditBox != NIL) FocusEditBox(activeEditBox); |
| 1305 | else FocusEditBox(info_edit_artist); |
| 1306 | } |
| 1307 | |
| 1308 | Void freac::LayerJoblist::OnShortcutLast() |
| 1309 | { |
| 1310 | if (!IsVisible() || GetActiveEditBox() != NIL) return; |
| 1311 | |
| 1312 | EditBox *activeEditBox = GetActiveEditBox(); |
| 1313 | |
| 1314 | joblist->SelectNthEntry(joblist->Length() - 1); |
| 1315 | |
| 1316 | if (activeEditBox != NIL) FocusEditBox(activeEditBox); |
| 1317 | else FocusEditBox(info_edit_artist); |
| 1318 | } |
| 1319 | |
| 1320 | Void freac::LayerJoblist::OnShortcutMoveUp() |
| 1321 | { |
| 1322 | if (!IsVisible() || joblist->GetSelectedEntryNumber() == -1) return; |
| 1323 | |
| 1324 | if (joblist->GetSelectedEntryNumber() > 0) |
| 1325 | { |
| 1326 | Surface *surface = GetDrawSurface(); |
| 1327 | |
| 1328 | surface->StartPaint(Rect(joblist->GetRealPosition(), joblist->GetRealSize())); |
| 1329 | |
| 1330 | joblist->MoveEntry(joblist->GetSelectedEntryNumber(), joblist->GetSelectedEntryNumber() - 1); |
| 1331 | joblist->Paint(SP_PAINT); |
| 1332 | |
| 1333 | while (joblist->GetSelectedEntry()->GetVisibleArea().GetHeight() < joblist->GetSelectedEntry()->GetRealSize().cy) joblist->ScrollUp(1); |
| 1334 | |
| 1335 | surface->EndPaint(); |
| 1336 | } |
| 1337 | } |
| 1338 | |
| 1339 | Void freac::LayerJoblist::OnShortcutMoveDown() |
| 1340 | { |
| 1341 | if (!IsVisible() || joblist->GetSelectedEntryNumber() == -1) return; |
| 1342 | |
| 1343 | if (joblist->GetSelectedEntryNumber() < joblist->Length() - 1) |
| 1344 | { |
| 1345 | Surface *surface = GetDrawSurface(); |
| 1346 | |
| 1347 | surface->StartPaint(Rect(joblist->GetRealPosition(), joblist->GetRealSize())); |
| 1348 | |
| 1349 | joblist->MoveEntry(joblist->GetSelectedEntryNumber(), joblist->GetSelectedEntryNumber() + 1); |
| 1350 | joblist->Paint(SP_PAINT); |
| 1351 | |
| 1352 | while (joblist->GetSelectedEntry()->GetVisibleArea().GetHeight() < joblist->GetSelectedEntry()->GetRealSize().cy) joblist->ScrollDown(1); |
| 1353 | |
| 1354 | surface->EndPaint(); |
| 1355 | } |
| 1356 | } |
| 1357 | |
| 1358 | Void freac::LayerJoblist::OnShortcutMoveTop() |
| 1359 | { |
| 1360 | if (!IsVisible() || GetActiveEditBox() != NIL || joblist->GetSelectedEntryNumber() == -1) return; |
| 1361 | |
| 1362 | if (joblist->GetSelectedEntryNumber() > 0) |
| 1363 | { |
| 1364 | Surface *surface = GetDrawSurface(); |
| 1365 | |
| 1366 | surface->StartPaint(Rect(joblist->GetRealPosition(), joblist->GetRealSize())); |
| 1367 | |
| 1368 | joblist->MoveEntry(joblist->GetSelectedEntryNumber(), 0); |
| 1369 | joblist->ScrollUp(); |
| 1370 | joblist->Paint(SP_PAINT); |
| 1371 | |
| 1372 | surface->EndPaint(); |
| 1373 | } |
| 1374 | } |
| 1375 | |
| 1376 | Void freac::LayerJoblist::OnShortcutMoveBottom() |
| 1377 | { |
| 1378 | if (!IsVisible() || GetActiveEditBox() != NIL || joblist->GetSelectedEntryNumber() == -1) return; |
| 1379 | |
| 1380 | if (joblist->GetSelectedEntryNumber() < joblist->Length() - 1) |
| 1381 | { |
| 1382 | Surface *surface = GetDrawSurface(); |
| 1383 | |
| 1384 | surface->StartPaint(Rect(joblist->GetRealPosition(), joblist->GetRealSize())); |
| 1385 | |
| 1386 | joblist->MoveEntry(joblist->GetSelectedEntryNumber(), joblist->Length() - 1); |
| 1387 | joblist->ScrollDown(); |
| 1388 | joblist->Paint(SP_PAINT); |
| 1389 | |
| 1390 | surface->EndPaint(); |
| 1391 | } |
| 1392 | } |
| 1393 | |
| 1394 | Void freac::LayerJoblist::OnShortcutToggleMark() |
| 1395 | { |
| 1396 | if (!IsVisible() || GetActiveEditBox() != NIL) return; |
| 1397 | |
| 1398 | ListEntry *entry = joblist->GetSelectedEntry(); |
| 1399 | |
| 1400 | if (entry != NIL) |
| 1401 | { |
| 1402 | entry->SetMark(!entry->IsMarked()); |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | Void freac::LayerJoblist::OnShortcutRemove() |
| 1407 | { |
| 1408 | if (!IsVisible() || GetActiveEditBox() != NIL) return; |
| 1409 | |
| 1410 | Int entryNumber = joblist->GetSelectedEntryNumber(); |
| 1411 | |
| 1412 | if (entryNumber >= 0) |
| 1413 | { |
| 1414 | joblist->RemoveSelectedTrack(); |
| 1415 | joblist->SelectNthEntry(entryNumber); |
| 1416 | } |
| 1417 | } |
| 1418 | |
| 1419 | Void freac::LayerJoblist::OnEditBoxEnter(EditBox *activeEditBox) |
| 1420 | { |
| 1421 | joblist->SelectNthEntry(joblist->GetSelectedEntryNumber() + 1); |
| 1422 | |
| 1423 | if (activeEditBox != NIL) FocusEditBox(activeEditBox); |
| 1424 | } |
| 1425 | |
| 1426 | Void freac::LayerJoblist::UpdateTitleInfo() |
| 1427 | { |
| 1428 | if (dontUpdateInfo) return; |
| 1429 | |
| 1430 | Track track = joblist->GetSelectedTrack(); |
| 1431 | Info info = track.GetInfo(); |
| 1432 | |
| 1433 | if (track == NIL) return; |
| 1434 | |
| 1435 | if (info.genre != info_edit_genre->GetText() && info_list_genre->GetEntry(info_edit_genre->GetText()) != NIL) |
| 1436 | { |
| 1437 | Utilities::UpdateGenreList(info_list_genre, info_edit_genre->GetText()); |
| 1438 | |
| 1439 | info_edit_genre->SetDropDownList(info_list_genre); |
| 1440 | } |
| 1441 | |
| 1442 | info.artist = info_edit_artist->GetText(); |
| 1443 | info.title = info_edit_title->GetText(); |
| 1444 | info.album = info_edit_album->GetText(); |
| 1445 | info.track = info_edit_track->GetText().ToInt(); |
| 1446 | info.year = info_edit_year->GetText().ToInt(); |
| 1447 | info.genre = info_edit_genre->GetText(); |
| 1448 | |
| 1449 | track.SetInfo(info); |
| 1450 | |
| 1451 | BoCA::JobList::Get()->onComponentModifyTrack.Emit(track); |
| 1452 | } |
| 1453 | |
| 1454 | PopupMenu *freac::LayerJoblist::GetContextMenu() |
| 1455 | { |
| 1456 | /* Select the entry under the cursor before opening the context menu. |
| 1457 | */ |
| 1458 | Process(SM_LBUTTONDOWN, 0, 0); |
| 1459 | Process(SM_LBUTTONUP, 0, 0); |
| 1460 | |
| 1461 | if (joblist->GetSelectedTrack() != NIL) return menu_trackmenu; |
| 1462 | |
| 1463 | return NIL; |
| 1464 | } |
| 1465 | |
| 1466 | Void freac::LayerJoblist::OnEncoderStartEncoding() |
| 1467 | { |
| 1468 | OnEncoderFinishEncoding(True); |
| 1469 | |
| 1470 | BoCA::Config *config = BoCA::Config::Get(); |
| 1471 | |
| 1472 | if (!config->GetIntValue(Config::CategorySettingsID, Config::SettingsEncodeToSingleFileID, Config::SettingsEncodeToSingleFileDefault)) btn_skip->Activate(); |
| 1473 | |
| 1474 | combo_encoder->Deactivate(); |
| 1475 | } |
| 1476 | |
| 1477 | Void freac::LayerJoblist::OnEncoderFinishEncoding(Bool success) |
| 1478 | { |
| 1479 | BoCA::I18n *i18n = BoCA::I18n::Get(); |
| 1480 | |
| 1481 | i18n->SetContext("Joblist"); |
| 1482 | |
| 1483 | edb_trackPercent->SetText(i18n->TranslateString("%1%", "Technical").Replace("%1", "0")); |
| 1484 | edb_trackTime->SetText("00:00"); |
| 1485 | |
| 1486 | edb_totalPercent->SetText(i18n->TranslateString("%1%", "Technical").Replace("%1", "0")); |
| 1487 | edb_totalTime->SetText("00:00"); |
| 1488 | |
| 1489 | if (edb_trackTime->GetWidth() != Math::Max(34, edb_trackTime->GetUnscaledTextWidth() + 6) || |
| 1490 | edb_totalTime->GetWidth() != Math::Max(34, edb_totalTime->GetUnscaledTextWidth() + 6)) |
| 1491 | { |
| 1492 | edb_trackTime->SetWidth(Math::Max(34, edb_trackTime->GetUnscaledTextWidth() + 6)); |
| 1493 | edb_totalTime->SetWidth(Math::Max(34, edb_totalTime->GetUnscaledTextWidth() + 6)); |
| 1494 | |
| 1495 | OnChangeSize(GetSize()); |
| 1496 | } |
| 1497 | |
| 1498 | progress->SetValue(0); |
| 1499 | progress_total->SetValue(0); |
| 1500 | |
| 1501 | previousTrackSeconds = -10; |
| 1502 | previousTotalSeconds = -10; |
| 1503 | |
| 1504 | if (JobConvert::IsConverting()) return; |
| 1505 | |
| 1506 | edb_filename->SetText(i18n->TranslateString("none", "Joblist::File")); |
| 1507 | edb_format->SetText(i18n->TranslateString("none", "Joblist::Decoder")); |
| 1508 | |
| 1509 | btn_skip->Deactivate(); |
| 1510 | |
| 1511 | combo_encoder->Activate(); |
| 1512 | |
| 1513 | UpdateEncoderText(); |
| 1514 | |
| 1515 | /* Shutdown system if requested. |
| 1516 | */ |
| 1517 | BoCA::Config *config = BoCA::Config::Get(); |
| 1518 | |
| 1519 | if (success && Job::GetPlannedJobs().Length() == 0 && config->GetIntValue(Config::CategoryInternalID, Config::InternalShutdownAfterEncodingID, False)) S::System::System::Shutdown(); |
| 1520 | } |
| 1521 | |
| 1522 | Void freac::LayerJoblist::OnEncoderEncodeTrack(const Track &track, const String &decoderName, const String &encoderName, ConversionStep mode) |
| 1523 | { |
| 1524 | BoCA::I18n *i18n = BoCA::I18n::Get(); |
| 1525 | |
| 1526 | i18n->SetContext("Joblist"); |
| 1527 | |
| 1528 | Surface *surface = GetDrawSurface(); |
| 1529 | |
| 1530 | surface->StartPaint(Rect::EncloseRect(edb_filename->GetVisibleArea(), edb_totalTime->GetVisibleArea())); |
| 1531 | |
| 1532 | edb_trackPercent->SetText(i18n->TranslateString("%1%", "Technical").Replace("%1", "0")); |
| 1533 | edb_trackTime->SetText("00:00"); |
| 1534 | |
| 1535 | if (edb_trackTime->GetWidth() != Math::Max(34, edb_trackTime->GetUnscaledTextWidth() + 6)) |
| 1536 | { |
| 1537 | edb_trackTime->SetWidth(Math::Max(34, edb_trackTime->GetUnscaledTextWidth() + 6)); |
| 1538 | |
| 1539 | OnChangeSize(GetSize()); |
| 1540 | } |
| 1541 | |
| 1542 | progress->SetValue(0); |
| 1543 | |
| 1544 | previousTrackSeconds = -10; |
| 1545 | |
| 1546 | const Info &info = track.GetInfo(); |
| 1547 | String fileInfo = track.fileName; |
| 1548 | |
| 1549 | if (info.artist.Length() > 0 || |
| 1550 | info.title.Length() > 0) fileInfo = String(info.artist.Length() > 0 ? info.artist : i18n->TranslateString("unknown artist")).Append(" - ").Append(info.title.Length() > 0 ? info.title : i18n->TranslateString("unknown title")); |
| 1551 | |
| 1552 | switch (mode) |
| 1553 | { |
| 1554 | default: |
| 1555 | case ConversionStepOnTheFly: |
| 1556 | // nothing special in this case |
| 1557 | break; |
| 1558 | case ConversionStepDecode: |
| 1559 | fileInfo = fileInfo.Append(" (").Append(i18n->TranslateString("ripping/decoding")).Append(")"); |
| 1560 | break; |
| 1561 | case ConversionStepEncode: |
| 1562 | fileInfo = fileInfo.Append(" (").Append(i18n->TranslateString("encoding")).Append(")"); |
| 1563 | break; |
| 1564 | case ConversionStepVerify: |
| 1565 | fileInfo = fileInfo.Append(" (").Append(i18n->TranslateString("verifying")).Append(")"); |
| 1566 | break; |
| 1567 | } |
| 1568 | |
| 1569 | edb_filename->SetText(fileInfo); |
| 1570 | edb_format->SetText(decoderName); |
| 1571 | |
| 1572 | combo_encoder->SelectEntry(encoderName); |
| 1573 | |
| 1574 | surface->EndPaint(); |
| 1575 | } |
| 1576 | |
| 1577 | Void freac::LayerJoblist::OnEncoderReportProgress(Int trackProgressValue, Int trackSecondsLeft, Int totalProgressValue, Int totalSecondsLeft) |
| 1578 | { |
| 1579 | Surface *surface = GetDrawSurface(); |
| 1580 | |
| 1581 | surface->StartPaint(Rect::EncloseRect(progress->GetVisibleArea(), edb_totalTime->GetVisibleArea())); |
| 1582 | |
| 1583 | /* Update seconds only if estimate is less or |
| 1584 | * at least two seconds more than before. |
| 1585 | */ |
| 1586 | if (trackSecondsLeft < previousTrackSeconds || trackSecondsLeft >= previousTrackSeconds + 2 || previousTrackSeconds == 0) |
| 1587 | { |
| 1588 | /* Set track time string. |
| 1589 | */ |
| 1590 | String secondsString = Job::SecondsToString(trackSecondsLeft); |
| 1591 | |
| 1592 | edb_trackTime->SetText(secondsString); |
| 1593 | |
| 1594 | if (edb_trackTime->GetWidth() != Math::Max(34, edb_trackTime->GetUnscaledTextWidth() + 6)) |
| 1595 | { |
| 1596 | edb_trackTime->SetWidth(Math::Max(34, edb_trackTime->GetUnscaledTextWidth() + 6)); |
| 1597 | |
| 1598 | OnChangeSize(GetSize()); |
| 1599 | } |
| 1600 | |
| 1601 | previousTrackSeconds = trackSecondsLeft; |
| 1602 | } |
| 1603 | |
| 1604 | if (totalSecondsLeft < previousTotalSeconds || totalSecondsLeft >= previousTotalSeconds + 2 || previousTotalSeconds == 0) |
| 1605 | { |
| 1606 | /* Set total time string. |
| 1607 | */ |
| 1608 | String secondsString = Job::SecondsToString(totalSecondsLeft); |
| 1609 | |
| 1610 | edb_totalTime->SetText(secondsString); |
| 1611 | |
| 1612 | if (edb_totalTime->GetWidth() != Math::Max(34, edb_totalTime->GetUnscaledTextWidth() + 6)) |
| 1613 | { |
| 1614 | edb_totalTime->SetWidth(Math::Max(34, edb_totalTime->GetUnscaledTextWidth() + 6)); |
| 1615 | |
| 1616 | OnChangeSize(GetSize()); |
| 1617 | } |
| 1618 | |
| 1619 | previousTotalSeconds = totalSecondsLeft; |
| 1620 | } |
| 1621 | |
| 1622 | /* Set percent values. |
| 1623 | */ |
| 1624 | if (trackProgressValue > progress->GetValue()) |
| 1625 | { |
| 1626 | edb_trackPercent->SetText(BoCA::I18n::Get()->TranslateString("%1%", "Technical").Replace("%1", String::FromInt(Math::Round(trackProgressValue / 10.0)))); |
| 1627 | |
| 1628 | progress->SetValue(trackProgressValue); |
| 1629 | } |
| 1630 | |
| 1631 | if (totalProgressValue > progress_total->GetValue()) |
| 1632 | { |
| 1633 | edb_totalPercent->SetText(BoCA::I18n::Get()->TranslateString("%1%", "Technical").Replace("%1", String::FromInt(Math::Round(totalProgressValue / 10.0)))); |
| 1634 | |
| 1635 | progress_total->SetValue(totalProgressValue); |
| 1636 | } |
| 1637 | |
| 1638 | surface->EndPaint(); |
| 1639 | } |
| 1640 | |
| 1641 | Void freac::LayerJoblist::ShowHideTitleInfo() |
| 1642 | { |
| 1643 | BoCA::Config *config = BoCA::Config::Get(); |
| 1644 | |
| 1645 | Bool showTitleInfo = config->GetIntValue(Config::CategorySettingsID, Config::SettingsShowTitleInfoID, Config::SettingsShowTitleInfoDefault); |
| 1646 | |
| 1647 | /* Check if visibility state actually changed. |
| 1648 | */ |
| 1649 | if (( showTitleInfo && info_divider->GetPos() != 113) || |
| 1650 | (!showTitleInfo && info_divider->GetPos() == 113)) return; |
| 1651 | |
| 1652 | /* Toggle info area visibility state. |
| 1653 | */ |
| 1654 | Surface *surface = GetDrawSurface(); |
| 1655 | |
| 1656 | surface->StartPaint(GetVisibleArea()); |
| 1657 | |
| 1658 | if (!showTitleInfo) |
| 1659 | { |
| 1660 | info_bottom->Hide(); |
| 1661 | |
| 1662 | if (info_text_artist->GetX() > 7) |
| 1663 | { |
| 1664 | info_area_artwork->Hide(); |
| 1665 | info_image_artwork->Hide(); |
| 1666 | } |
| 1667 | |
| 1668 | info_text_artist->Hide(); |
| 1669 | info_edit_artist->Hide(); |
| 1670 | info_text_title->Hide(); |
| 1671 | info_edit_title->Hide(); |
| 1672 | info_text_album->Hide(); |
| 1673 | info_edit_album->Hide(); |
| 1674 | info_text_track->Hide(); |
| 1675 | info_edit_track->Hide(); |
| 1676 | info_text_year->Hide(); |
| 1677 | info_edit_year->Hide(); |
| 1678 | info_text_genre->Hide(); |
| 1679 | info_edit_genre->Hide(); |
| 1680 | } |
| 1681 | |
| 1682 | Rect clientRect = Rect(GetPosition(), GetSize()); |
| 1683 | Size clientSize = Size(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); |
| 1684 | |
| 1685 | joblist->SetSize(Size(clientSize.cx - 23, clientSize.cy - 162 - (showTitleInfo ? 68 : 0))); |
| 1686 | |
| 1687 | check_single->SetMetrics(Point(check_single->GetUnscaledTextWidth() + 28, joblist->GetY() + joblist->GetHeight() + 4), Size(check_single->GetUnscaledTextWidth() + 21, check_single->GetHeight())); |
| 1688 | check_cuesheet->SetMetrics(Point(check_single->GetUnscaledTextWidth() + check_cuesheet->GetUnscaledTextWidth() + 53, joblist->GetY() + joblist->GetHeight() + 4), Size(check_cuesheet->GetUnscaledTextWidth() + 21, check_cuesheet->GetHeight())); |
| 1689 | check_playlist->SetMetrics(Point(check_single->GetUnscaledTextWidth() + check_cuesheet->GetUnscaledTextWidth() + check_playlist->GetUnscaledTextWidth() + 78, joblist->GetY() + joblist->GetHeight() + 4), Size(check_playlist->GetUnscaledTextWidth() + 21, check_playlist->GetHeight())); |
| 1690 | |
| 1691 | info_divider->SetPos(113 + (showTitleInfo ? 68 : 0)); |
| 1692 | info_background->SetY(121 + (showTitleInfo ? 68 : 0)); |
| 1693 | |
| 1694 | joblist->Paint(SP_PAINT); |
| 1695 | |
| 1696 | if (showTitleInfo) |
| 1697 | { |
| 1698 | info_bottom->Show(); |
| 1699 | |
| 1700 | if (info_text_artist->GetX() > 7) |
| 1701 | { |
| 1702 | info_area_artwork->Show(); |
| 1703 | info_image_artwork->Show(); |
| 1704 | } |
| 1705 | |
| 1706 | info_text_artist->Show(); |
| 1707 | info_edit_artist->Show(); |
| 1708 | info_text_title->Show(); |
| 1709 | info_edit_title->Show(); |
| 1710 | info_text_album->Show(); |
| 1711 | info_edit_album->Show(); |
| 1712 | info_text_track->Show(); |
| 1713 | info_edit_track->Show(); |
| 1714 | info_text_year->Show(); |
| 1715 | info_edit_year->Show(); |
| 1716 | info_text_genre->Show(); |
| 1717 | info_edit_genre->Show(); |
| 1718 | } |
| 1719 | |
| 1720 | surface->EndPaint(); |
| 1721 | } |
| 1722 | |
| 1723 | Void freac::LayerJoblist::UpdateOutputDir() |
| 1724 | { |
| 1725 | BoCA::Config *config = BoCA::Config::Get(); |
| 1726 | |
| 1727 | edb_outdir->SetText(BoCA::Utilities::GetAbsolutePathName(config->GetStringValue(Config::CategorySettingsID, Config::SettingsEncoderOutputDirectoryID, Config::SettingsEncoderOutputDirectoryDefault))); |
| 1728 | |
| 1729 | /* Update combo box. |
| 1730 | */ |
| 1731 | list_outdir->RemoveAllEntries(); |
| 1732 | |
| 1733 | for (Int i = 1; i <= 5; i++) |
| 1734 | { |
| 1735 | if (config->GetStringValue(Config::CategorySettingsID, String(Config::SettingsLastOutputDirectoryID).Append(String::FromInt(i)), NIL) != NIL) |
| 1736 | { |
| 1737 | list_outdir->AddEntry(config->GetStringValue(Config::CategorySettingsID, String(Config::SettingsLastOutputDirectoryID).Append(String::FromInt(i)), NIL)); |
| 1738 | } |
| 1739 | } |
| 1740 | |
| 1741 | edb_outdir->SetDropDownList(list_outdir); |
| 1742 | } |
| 1743 | |
| 1744 | Void freac::LayerJoblist::OnOpenFolder() |
| 1745 | { |
| 1746 | Directory outputDirectory(BoCA::Utilities::GetAbsolutePathName(edb_outdir->GetText())); |
| 1747 | |
| 1748 | if (!outputDirectory.Exists()) |
| 1749 | { |
| 1750 | BoCA::Utilities::ErrorMessage("The selected folder does not exist anymore!"); |
| 1751 | |
| 1752 | return; |
| 1753 | } |
| 1754 | |
| 1755 | S::System::System::OpenURL(edb_outdir->GetText()); |
| 1756 | } |
| 1757 | |
| 1758 | Void freac::LayerJoblist::OnBrowseForFolder() |
| 1759 | { |
| 1760 | BoCA::Config *config = BoCA::Config::Get(); |
| 1761 | BoCA::I18n *i18n = BoCA::I18n::Get(); |
| 1762 | |
| 1763 | i18n->SetContext("Joblist"); |
| 1764 | |
| 1765 | /* Find main window and create dialog. |
| 1766 | */ |
| 1767 | Window *mainWnd = Window::GetNthWindow(0); |
| 1768 | DirSelection dialog; |
| 1769 | |
| 1770 | dialog.SetParentWindow(mainWnd); |
| 1771 | dialog.SetCaption(i18n->AddColon(i18n->TranslateString("Select the folder in which the encoded files will be placed"))); |
| 1772 | dialog.SetDirName(BoCA::Utilities::GetAbsolutePathName(config->GetStringValue(Config::CategorySettingsID, Config::SettingsEncoderOutputDirectoryID, Config::SettingsEncoderOutputDirectoryDefault))); |
| 1773 | |
| 1774 | if (dialog.ShowDialog() == Success()) |
| 1775 | { |
| 1776 | edb_outdir->SetText(dialog.GetDirName()); |
| 1777 | |
| 1778 | OnSelectFolder(); |
| 1779 | } |
| 1780 | } |
| 1781 | |
| 1782 | Void freac::LayerJoblist::OnSelectFolder() |
| 1783 | { |
| 1784 | BoCA::Config *config = BoCA::Config::Get(); |
| 1785 | BoCA::I18n *i18n = BoCA::I18n::Get(); |
| 1786 | |
| 1787 | i18n->SetContext("Configuration::Encoders::Errors"); |
| 1788 | |
| 1789 | /* Check if output folder exists. |
| 1790 | */ |
| 1791 | Directory outputDirectory(BoCA::Utilities::GetAbsolutePathName(edb_outdir->GetText())); |
| 1792 | |
| 1793 | if (!outputDirectory.Exists()) |
| 1794 | { |
| 1795 | Int selection = QuickMessage(i18n->TranslateString("The output folder does not exist! Do you want to create it?"), i18n->TranslateString("Error"), Message::Buttons::YesNoCancel, Message::Icon::Question); |
| 1796 | |
| 1797 | if (selection == Message::Button::Yes) outputDirectory.Create(); |
| 1798 | else if (selection == Message::Button::Cancel) { UpdateOutputDir(); return; } |
| 1799 | } |
| 1800 | |
| 1801 | /* Save output directory and list of last used folders. |
| 1802 | */ |
| 1803 | Int outputDirNumber = 5; |
| 1804 | |
| 1805 | for (Int i = 1; i <= 5; i++) |
| 1806 | { |
| 1807 | if (config->GetStringValue(Config::CategorySettingsID, String(Config::SettingsLastOutputDirectoryID).Append(String::FromInt(i)), NIL) == edb_outdir->GetText()) |
| 1808 | { |
| 1809 | outputDirNumber = i; |
| 1810 | |
| 1811 | break; |
| 1812 | } |
| 1813 | } |
| 1814 | |
| 1815 | for (Int i = outputDirNumber; i > 1; i--) |
| 1816 | { |
| 1817 | config->SetStringValue(Config::CategorySettingsID, String(Config::SettingsLastOutputDirectoryID).Append(String::FromInt(i)), config->GetStringValue(Config::CategorySettingsID, String(Config::SettingsLastOutputDirectoryID).Append(String::FromInt(i - 1)), NIL)); |
| 1818 | } |
| 1819 | |
| 1820 | config->SetStringValue(Config::CategorySettingsID, String(Config::SettingsLastOutputDirectoryID).Append(String::FromInt(1)), edb_outdir->GetText()); |
| 1821 | config->SetStringValue(Config::CategorySettingsID, Config::SettingsEncoderOutputDirectoryID, edb_outdir->GetText()); |
| 1822 | |
| 1823 | /* Update combo box. |
| 1824 | */ |
| 1825 | UpdateOutputDir(); |
| 1826 | } |
| 1827 | |
| 1828 | Void freac::LayerJoblist::OnSelectEncoder() |
| 1829 | { |
| 1830 | BoCA::Config *config = BoCA::Config::Get(); |
| 1831 | Registry &boca = Registry::Get(); |
| 1832 | |
| 1833 | for (Int i = 0, n = 0; i < boca.GetNumberOfComponents(); i++) |
| 1834 | { |
| 1835 | if (boca.GetComponentType(i) != BoCA::COMPONENT_TYPE_ENCODER) continue; |
| 1836 | |
| 1837 | if (combo_encoder->GetSelectedEntryNumber() == n++) |
| 1838 | { |
| 1839 | config->SetStringValue(Config::CategorySettingsID, Config::SettingsEncoderID, boca.GetComponentID(i)); |
| 1840 | |
| 1841 | break; |
| 1842 | } |
| 1843 | } |
| 1844 | |
| 1845 | /* Update joblist entries if output file name might need to be changed. |
| 1846 | */ |
| 1847 | if (config->GetStringValue(Config::CategoryJoblistID, Config::JoblistFieldsID, Config::JoblistFieldsDefault).Contains("<outputfile>")) joblist->OnChangeHeaderColumns(); |
| 1848 | } |
| 1849 | |
| 1850 | Void freac::LayerJoblist::ToggleEditPopup() |
| 1851 | { |
| 1852 | String string; |
| 1853 | |
| 1854 | if (menu_edit_artist->IsVisible()) |
| 1855 | { |
| 1856 | activePopup = menu_edit_artist->GetHandle(); |
| 1857 | |
| 1858 | if (htsp_edit_artist->IsActive()) { htsp_edit_artist->Deactivate(); string = info_edit_artist->GetText(); } |
| 1859 | else htsp_edit_artist->Activate(); |
| 1860 | } |
| 1861 | else if (menu_edit_title->IsVisible()) |
| 1862 | { |
| 1863 | activePopup = menu_edit_title->GetHandle(); |
| 1864 | |
| 1865 | if (htsp_edit_title->IsActive()) { htsp_edit_title->Deactivate(); string = info_edit_title->GetText(); } |
| 1866 | else htsp_edit_title->Activate(); |
| 1867 | } |
| 1868 | else if (menu_edit_album->IsVisible()) |
| 1869 | { |
| 1870 | activePopup = menu_edit_album->GetHandle(); |
| 1871 | |
| 1872 | if (htsp_edit_album->IsActive()) { htsp_edit_album->Deactivate(); string = info_edit_album->GetText(); } |
| 1873 | else htsp_edit_album->Activate(); |
| 1874 | } |
| 1875 | else if (menu_edit_genre->IsVisible()) |
| 1876 | { |
| 1877 | activePopup = menu_edit_genre->GetHandle(); |
| 1878 | |
| 1879 | if (htsp_edit_genre->IsActive()) htsp_edit_genre->Deactivate(); |
| 1880 | else htsp_edit_genre->Activate(); |
| 1881 | } |
| 1882 | else if (menu_edit_year->IsVisible()) |
| 1883 | { |
| 1884 | activePopup = menu_edit_year->GetHandle(); |
| 1885 | |
| 1886 | if (htsp_edit_year->IsActive()) htsp_edit_year->Deactivate(); |
| 1887 | else htsp_edit_year->Activate(); |
| 1888 | } |
| 1889 | else |
| 1890 | { |
| 1891 | return; |
| 1892 | } |
| 1893 | |
| 1894 | if (string == NIL) string = "?"; |
| 1895 | |
| 1896 | BoCA::I18n *i18n = BoCA::I18n::Get(); |
| 1897 | |
| 1898 | i18n->SetContext("Joblist"); |
| 1899 | |
| 1900 | menu_case->RemoveAllEntries(); |
| 1901 | menu_case_all->RemoveAllEntries(); |
| 1902 | |
| 1903 | menu_case->AddEntry(AdjustCaseWordsFirstCapital(string).Append(" (").Append(i18n->TranslateString("all words upper case")).Append(")"), &clicked_case, 0)->onAction.Connect(&LayerJoblist::AdjustStringCase, this); |
| 1904 | menu_case->AddEntry(AdjustCaseLongWordsFirstCapital(string).Append(" (").Append(i18n->TranslateString("long words upper case")).Append(")"), &clicked_case, 1)->onAction.Connect(&LayerJoblist::AdjustStringCase, this); |
| 1905 | menu_case->AddEntry(AdjustCaseFirstCapital(string).Append(" (").Append(i18n->TranslateString("first letter upper case")).Append(")"), &clicked_case, 2)->onAction.Connect(&LayerJoblist::AdjustStringCase, this); |
| 1906 | menu_case->AddEntry(string.ToLower().Append(" (").Append(i18n->TranslateString("all lower case")).Append(")"), &clicked_case, 3)->onAction.Connect(&LayerJoblist::AdjustStringCase, this); |
| 1907 | menu_case->AddEntry(string.ToUpper().Append(" (").Append(i18n->TranslateString("all upper case")).Append(")"), &clicked_case, 4)->onAction.Connect(&LayerJoblist::AdjustStringCase, this); |
| 1908 | |
| 1909 | menu_case_all->AddEntry(AdjustCaseWordsFirstCapital(string).Append(" (").Append(i18n->TranslateString("all words upper case")).Append(")"), &clicked_case, 0)->onAction.Connect(&LayerJoblist::AdjustStringCaseAll, this); |
| 1910 | menu_case_all->AddEntry(AdjustCaseLongWordsFirstCapital(string).Append(" (").Append(i18n->TranslateString("long words upper case")).Append(")"), &clicked_case, 1)->onAction.Connect(&LayerJoblist::AdjustStringCaseAll, this); |
| 1911 | menu_case_all->AddEntry(AdjustCaseFirstCapital(string).Append(" (").Append(i18n->TranslateString("first letter upper case")).Append(")"), &clicked_case, 2)->onAction.Connect(&LayerJoblist::AdjustStringCaseAll, this); |
| 1912 | menu_case_all->AddEntry(string.ToLower().Append(" (").Append(i18n->TranslateString("all lower case")).Append(")"), &clicked_case, 3)->onAction.Connect(&LayerJoblist::AdjustStringCaseAll, this); |
| 1913 | menu_case_all->AddEntry(string.ToUpper().Append(" (").Append(i18n->TranslateString("all upper case")).Append(")"), &clicked_case, 4)->onAction.Connect(&LayerJoblist::AdjustStringCaseAll, this); |
| 1914 | } |
| 1915 | |
| 1916 | Bool freac::LayerJoblist::IsWordBreakingCharacter(Int character) |
| 1917 | { |
| 1918 | if (character == 0 || |
| 1919 | character == ' ' || |
| 1920 | character == '(' || character == ')' || |
| 1921 | character == '[' || character == ']' || |
| 1922 | character == '<' || character == '>' || |
| 1923 | character == '?' || character == 0xBF || // inverted question mark |
| 1924 | character == '!' || character == 0xA1 || // inverted exclamation mark |
| 1925 | character == '-' || |
| 1926 | character == '+' || |
| 1927 | character == '&' || |
| 1928 | character == '.' || |
| 1929 | character == ',' || |
| 1930 | character == ':' || |
| 1931 | character == ';' || |
| 1932 | character == '\"') return True; |
| 1933 | |
| 1934 | return False; |
| 1935 | } |
| 1936 | |
| 1937 | String freac::LayerJoblist::AdjustCaseFirstCapital(const String &string) |
| 1938 | { |
| 1939 | String value = String(string).ToLower(); |
| 1940 | String character; |
| 1941 | |
| 1942 | for (Int i = 0; i < value.Length(); i++) |
| 1943 | { |
| 1944 | if (IsWordBreakingCharacter(value[i]) || value[i] == '\'') continue; |
| 1945 | |
| 1946 | character[0] = value[i]; |
| 1947 | value[i] = character.ToTitle()[0]; |
| 1948 | |
| 1949 | break; |
| 1950 | } |
| 1951 | |
| 1952 | return value; |
| 1953 | } |
| 1954 | |
| 1955 | String freac::LayerJoblist::AdjustCaseWordsFirstCapital(const String &string) |
| 1956 | { |
| 1957 | String value = String(string).ToLower(); |
| 1958 | String character; |
| 1959 | |
| 1960 | for (Int i = 0; i < value.Length(); i++) |
| 1961 | { |
| 1962 | character[0] = value[i]; |
| 1963 | |
| 1964 | if ( IsWordBreakingCharacter(value[i - 1]) || (value[i - 1] == '\'' && |
| 1965 | (IsWordBreakingCharacter(value[i - 2]) || value[i - 2] == '\''))) value[i] = character.ToTitle()[0]; |
| 1966 | } |
| 1967 | |
| 1968 | return value; |
| 1969 | } |
| 1970 | |
| 1971 | String freac::LayerJoblist::AdjustCaseLongWordsFirstCapital(const String &string) |
| 1972 | { |
| 1973 | String value = AdjustCaseWordsFirstCapital(string); |
| 1974 | String character; |
| 1975 | |
| 1976 | for (Int i = 0; i < value.Length(); i++) |
| 1977 | { |
| 1978 | if (IsWordBreakingCharacter(value[i]) || value[i] == '\'') continue; |
| 1979 | |
| 1980 | for (Int j = i + 1; j < value.Length(); j++) |
| 1981 | { |
| 1982 | character[0] = value[j]; |
| 1983 | |
| 1984 | if ((IsWordBreakingCharacter(value[j + 1]) || |
| 1985 | IsWordBreakingCharacter(value[j + 2]) || |
| 1986 | IsWordBreakingCharacter(value[j + 3])) && |
| 1987 | ( IsWordBreakingCharacter(value[j - 1]) || (value[j - 1] == '\'' && |
| 1988 | (IsWordBreakingCharacter(value[j - 2]) || value[j - 2] == '\'')))) value[j] = character.ToLower()[0]; |
| 1989 | } |
| 1990 | |
| 1991 | break; |
| 1992 | } |
| 1993 | |
| 1994 | return value; |
| 1995 | } |
| 1996 | |
| 1997 | Void freac::LayerJoblist::UseStringForSelectedTracks() |
| 1998 | { |
| 1999 | for (Int i = 0; i < joblist->GetNOfTracks(); i++) |
| 2000 | { |
| 2001 | ListEntry *entry = joblist->GetNthEntry(i); |
| 2002 | |
| 2003 | if (entry->IsMarked()) |
| 2004 | { |
| 2005 | Track track = joblist->GetNthTrack(i); |
| 2006 | Info info = track.GetInfo(); |
| 2007 | |
| 2008 | if (activePopup == menu_edit_artist->GetHandle()) info.artist = info_edit_artist->GetText(); |
| 2009 | else if (activePopup == menu_edit_album->GetHandle()) info.album = info_edit_album->GetText(); |
| 2010 | else if (activePopup == menu_edit_genre->GetHandle()) info.genre = info_edit_genre->GetText(); |
| 2011 | else if (activePopup == menu_edit_year->GetHandle()) info.year = info_edit_year->GetText().ToInt(); |
| 2012 | |
| 2013 | track.SetInfo(info); |
| 2014 | |
| 2015 | BoCA::JobList::Get()->onComponentModifyTrack.Emit(track); |
| 2016 | } |
| 2017 | } |
| 2018 | } |
| 2019 | |
| 2020 | Void freac::LayerJoblist::InterpretStringAs() |
| 2021 | { |
| 2022 | String charset; |
| 2023 | |
| 2024 | switch (clicked_charset) |
| 2025 | { |
| 2026 | case CHARSET_UTF_8: charset = "UTF-8"; break; |
| 2027 | case CHARSET_ISO_8859_1: charset = "ISO-8859-1"; break; |
| 2028 | case CHARSET_ISO_8859_2: charset = "ISO-8859-2"; break; |
| 2029 | case CHARSET_ISO_8859_5: charset = "ISO-8859-5"; break; |
| 2030 | case CHARSET_ISO_8859_7: charset = "ISO-8859-7"; break; |
| 2031 | case CHARSET_CP1251: charset = "CP1251"; break; |
| 2032 | case CHARSET_SHIFT_JIS: charset = "SHIFT-JIS"; break; |
| 2033 | case CHARSET_GBK: charset = "GBK"; break; |
| 2034 | case CHARSET_BIG_5: charset = "BIG-5"; break; |
| 2035 | |
| 2036 | case CHARSET_OTHER: |
| 2037 | { |
| 2038 | ChooseCharsetDialog dialog; |
| 2039 | |
| 2040 | if (dialog.ShowDialog() == Success()) charset = dialog.GetCharset(); |
| 2041 | } |
| 2042 | |
| 2043 | break; |
| 2044 | } |
| 2045 | |
| 2046 | if (charset == NIL) return; |
| 2047 | |
| 2048 | Track track = joblist->GetSelectedTrack(); |
| 2049 | Info info = track.GetInfo(); |
| 2050 | const Info &oInfo = track.GetOriginalInfo(); |
| 2051 | |
| 2052 | if (activePopup == menu_edit_artist->GetHandle()) info.artist.ImportFrom(charset, oInfo.artist.ConvertTo("ISO-8859-1")); |
| 2053 | else if (activePopup == menu_edit_title->GetHandle()) info.title.ImportFrom(charset, oInfo.title.ConvertTo("ISO-8859-1")); |
| 2054 | else if (activePopup == menu_edit_album->GetHandle()) info.album.ImportFrom(charset, oInfo.album.ConvertTo("ISO-8859-1")); |
| 2055 | else if (activePopup == menu_edit_genre->GetHandle()) info.genre.ImportFrom(charset, oInfo.genre.ConvertTo("ISO-8859-1")); |
| 2056 | |
| 2057 | track.SetInfo(info); |
| 2058 | |
| 2059 | BoCA::JobList::Get()->onComponentModifyTrack.Emit(track); |
| 2060 | |
| 2061 | clicked_charset = -1; |
| 2062 | } |
| 2063 | |
| 2064 | Void freac::LayerJoblist::InterpretStringAsAll() |
| 2065 | { |
| 2066 | String charset; |
| 2067 | |
| 2068 | switch (clicked_charset) |
| 2069 | { |
| 2070 | case CHARSET_UTF_8: charset = "UTF-8"; break; |
| 2071 | case CHARSET_ISO_8859_1: charset = "ISO-8859-1"; break; |
| 2072 | case CHARSET_ISO_8859_2: charset = "ISO-8859-2"; break; |
| 2073 | case CHARSET_ISO_8859_5: charset = "ISO-8859-5"; break; |
| 2074 | case CHARSET_ISO_8859_7: charset = "ISO-8859-7"; break; |
| 2075 | case CHARSET_CP1251: charset = "CP1251"; break; |
| 2076 | case CHARSET_SHIFT_JIS: charset = "SHIFT-JIS"; break; |
| 2077 | case CHARSET_GBK: charset = "GBK"; break; |
| 2078 | case CHARSET_BIG_5: charset = "BIG-5"; break; |
| 2079 | |
| 2080 | case CHARSET_OTHER: |
| 2081 | { |
| 2082 | ChooseCharsetDialog dialog; |
| 2083 | |
| 2084 | if (dialog.ShowDialog() == Success()) charset = dialog.GetCharset(); |
| 2085 | } |
| 2086 | |
| 2087 | break; |
| 2088 | } |
| 2089 | |
| 2090 | if (charset == NIL) return; |
| 2091 | |
| 2092 | for (Int i = 0; i < joblist->GetNOfTracks(); i++) |
| 2093 | { |
| 2094 | ListEntry *entry = joblist->GetNthEntry(i); |
| 2095 | |
| 2096 | if (entry->IsMarked()) |
| 2097 | { |
| 2098 | Track track = joblist->GetNthTrack(i); |
| 2099 | Info info = track.GetInfo(); |
| 2100 | const Info &oInfo = track.GetOriginalInfo(); |
| 2101 | |
| 2102 | if (activePopup == menu_edit_artist->GetHandle()) info.artist.ImportFrom(charset, oInfo.artist.ConvertTo("ISO-8859-1")); |
| 2103 | else if (activePopup == menu_edit_title->GetHandle()) info.title.ImportFrom(charset, oInfo.title.ConvertTo("ISO-8859-1")); |
| 2104 | else if (activePopup == menu_edit_album->GetHandle()) info.album.ImportFrom(charset, oInfo.album.ConvertTo("ISO-8859-1")); |
| 2105 | else if (activePopup == menu_edit_genre->GetHandle()) info.genre.ImportFrom(charset, oInfo.genre.ConvertTo("ISO-8859-1")); |
| 2106 | |
| 2107 | track.SetInfo(info); |
| 2108 | |
| 2109 | BoCA::JobList::Get()->onComponentModifyTrack.Emit(track); |
| 2110 | } |
| 2111 | } |
| 2112 | |
| 2113 | clicked_charset = -1; |
| 2114 | } |
| 2115 | |
| 2116 | Void freac::LayerJoblist::AdjustStringCase() |
| 2117 | { |
| 2118 | String string; |
| 2119 | |
| 2120 | if (activePopup == menu_edit_artist->GetHandle()) string = info_edit_artist->GetText(); |
| 2121 | else if (activePopup == menu_edit_title->GetHandle()) string = info_edit_title->GetText(); |
| 2122 | else if (activePopup == menu_edit_album->GetHandle()) string = info_edit_album->GetText(); |
| 2123 | |
| 2124 | switch (clicked_case) |
| 2125 | { |
| 2126 | case 0: string = AdjustCaseWordsFirstCapital(string); break; |
| 2127 | case 1: string = AdjustCaseLongWordsFirstCapital(string); break; |
| 2128 | case 2: string = AdjustCaseFirstCapital(string); break; |
| 2129 | case 3: string = string.ToLower(); break; |
| 2130 | case 4: string = string.ToUpper(); break; |
| 2131 | } |
| 2132 | |
| 2133 | Track track = joblist->GetSelectedTrack(); |
| 2134 | Info info = track.GetInfo(); |
| 2135 | |
| 2136 | if (activePopup == menu_edit_artist->GetHandle()) info.artist = string; |
| 2137 | else if (activePopup == menu_edit_title->GetHandle()) info.title = string; |
| 2138 | else if (activePopup == menu_edit_album->GetHandle()) info.album = string; |
| 2139 | |
| 2140 | track.SetInfo(info); |
| 2141 | |
| 2142 | BoCA::JobList::Get()->onComponentModifyTrack.Emit(track); |
| 2143 | |
| 2144 | clicked_case = -1; |
| 2145 | } |
| 2146 | |
| 2147 | Void freac::LayerJoblist::AdjustStringCaseAll() |
| 2148 | { |
| 2149 | for (Int i = 0; i < joblist->GetNOfTracks(); i++) |
| 2150 | { |
| 2151 | ListEntry *entry = joblist->GetNthEntry(i); |
| 2152 | |
| 2153 | if (entry->IsMarked()) |
| 2154 | { |
| 2155 | String string; |
| 2156 | Track track = joblist->GetNthTrack(i); |
| 2157 | Info info = track.GetInfo(); |
| 2158 | |
| 2159 | if (activePopup == menu_edit_artist->GetHandle()) string = info.artist; |
| 2160 | else if (activePopup == menu_edit_title->GetHandle()) string = info.title; |
| 2161 | else if (activePopup == menu_edit_album->GetHandle()) string = info.album; |
| 2162 | |
| 2163 | switch (clicked_case) |
| 2164 | { |
| 2165 | case 0: string = AdjustCaseWordsFirstCapital(string); break; |
| 2166 | case 1: string = AdjustCaseLongWordsFirstCapital(string); break; |
| 2167 | case 2: string = AdjustCaseFirstCapital(string); break; |
| 2168 | case 3: string = string.ToLower(); break; |
| 2169 | case 4: string = string.ToUpper(); break; |
| 2170 | } |
| 2171 | |
| 2172 | if (activePopup == menu_edit_artist->GetHandle()) info.artist = string; |
| 2173 | else if (activePopup == menu_edit_title->GetHandle()) info.title = string; |
| 2174 | else if (activePopup == menu_edit_album->GetHandle()) info.album = string; |
| 2175 | |
| 2176 | track.SetInfo(info); |
| 2177 | |
| 2178 | BoCA::JobList::Get()->onComponentModifyTrack.Emit(track); |
| 2179 | } |
| 2180 | } |
| 2181 | |
| 2182 | clicked_case = -1; |
| 2183 | } |