Changeset 127 for smplayer/vendor/current/src/basegui.cpp
- Timestamp:
- Mar 29, 2012, 3:09:42 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/vendor/current/src/basegui.cpp
r121 r127 67 67 #include "timedialog.h" 68 68 #include "clhelp.h" 69 #include "mplayerversion.h" 70 71 #ifdef FIND_SUBTITLES 69 72 #include "findsubtitleswindow.h" 73 #endif 74 75 #ifdef VIDEOPREVIEW 70 76 #include "videopreview.h" 71 # include "mplayerversion.h"77 #endif 72 78 73 79 #include "config.h" 74 80 #include "actionseditor.h" 75 76 #include "myserver.h"77 81 78 82 #include "tvlist.h" … … 102 106 using namespace Global; 103 107 104 BaseGui::BaseGui( bool use_server,QWidget* parent, Qt::WindowFlags flags )108 BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags ) 105 109 : QMainWindow( parent, flags ), 106 110 near_top(false), … … 115 119 arg_close_on_finish = -1; 116 120 arg_start_in_fullscreen = -1; 117 use_control_server = use_server;118 121 119 122 setWindowTitle( "SMPlayer" ); 120 123 121 124 // Not created objects 122 server = 0;123 125 popup = 0; 124 126 pref_dialog = 0; 125 127 file_dialog = 0; 126 128 clhelp_window = 0; 129 #ifdef FIND_SUBTITLES 127 130 find_subs_dialog = 0; 131 #endif 132 #ifdef VIDEOPREVIEW 128 133 video_preview = 0; 134 #endif 129 135 130 136 // Create objects: … … 160 166 #endif 161 167 162 mplayer_log_window = new LogWindow(0); 168 #ifdef LOG_MPLAYER 169 mplayer_log_window = new LogWindow(0); 170 #endif 171 #ifdef LOG_SMPLAYER 163 172 smplayer_log_window = new LogWindow(0); 173 #endif 164 174 165 175 createActions(); … … 201 211 202 212 // Single instance 203 if (use_control_server) { 204 server = new MyServer(this); 205 connect(server, SIGNAL(receivedOpen(QString)), 206 this, SLOT(remoteOpen(QString))); 207 connect(server, SIGNAL(receivedOpenFiles(QStringList)), 208 this, SLOT(remoteOpenFiles(QStringList))); 209 connect(server, SIGNAL(receivedAddFiles(QStringList)), 210 this, SLOT(remoteAddFiles(QStringList))); 211 connect(server, SIGNAL(receivedFunction(QString)), 212 this, SLOT(processFunction(QString))); 213 connect(server, SIGNAL(receivedLoadSubtitle(QString)), 214 this, SLOT(remoteLoadSubtitle(QString))); 215 connect(server, SIGNAL(receivedPlayItem(int)), 216 this, SLOT(remotePlayItem(int))); 217 connect(server, SIGNAL(receivedRemoveItem(int)), 218 this, SLOT(remoteRemoveItem(int))); 219 connect(server, SIGNAL(receivedViewPlaylist(QString*)), 220 this, SLOT(remoteViewPlaylist(QString*))); 221 connect(server, SIGNAL(receivedViewStatus(QString*)), 222 this, SLOT(remoteViewStatus(QString*))); 223 connect(server, SIGNAL(receivedViewClipInfo(QString*)), 224 this, SLOT(remoteViewClipInfo(QString*))); 225 connect(server, SIGNAL(receivedSeek(double)), 226 this, SLOT(remoteSeek(double))); 227 connect(server, SIGNAL(receivedGetChecked(QString,QString*)), 228 this, SLOT(remoteGetChecked(QString,QString*))); 229 connect(server, SIGNAL(receivedMoveItem(int,int)), 230 this, SLOT(remoteMoveItem(int,int))); 231 connect(server, SIGNAL(receivedGetVolume(int*)), 232 this, SLOT(remoteGetVolume(int*))); 233 connect(server, SIGNAL(receivedSetVolume(int)), 234 core, SLOT(setVolume(int))); 235 236 if (pref->use_single_instance) { 237 int port = 0; 238 if (!pref->use_autoport) port = pref->connection_port; 239 if (server->listen(port)) { 240 pref->autoport = server->serverPort(); 241 pref->save(); 242 qDebug("BaseGui::initializeGui: server running on port %d", pref->autoport); 243 } else { 244 qWarning("BaseGui::initializeGui: server couldn't be started"); 213 /* Deleted */ 214 } 215 216 #ifdef SINGLE_INSTANCE 217 void BaseGui::handleMessageFromOtherInstances(const QString& message) { 218 qDebug("BaseGui::handleMessageFromOtherInstances: '%s'", message.toUtf8().constData()); 219 220 int pos = message.indexOf(' '); 221 if (pos > -1) { 222 QString command = message.left(pos); 223 QString arg = message.mid(pos+1); 224 qDebug("command: '%s'", command.toUtf8().constData()); 225 qDebug("arg: '%s'", arg.toUtf8().constData()); 226 227 if (command == "open_file") { 228 open(arg); 229 } 230 else 231 if (command == "open_files") { 232 QStringList file_list = arg.split(" <<sep>> "); 233 openFiles(file_list); 234 } 235 else 236 if (command == "add_to_playlist") { 237 QStringList file_list = arg.split(" <<sep>> "); 238 playlist->addFiles(file_list); 239 } 240 else 241 if (command == "action") { 242 processFunction(arg); 243 } 244 else 245 if (command == "load_sub") { 246 setInitialSubtitle(arg); 247 if (core->state() != Core::Stopped) { 248 core->loadSub(arg); 245 249 } 246 250 } 247 251 } 248 252 } 249 250 void BaseGui::remotePlayItem(int index){ 251 qDebug("BaseGui::remotePlay: '%s'", QString::number((index)).toUtf8().data()); 252 if (isMinimized()) showNormal(); 253 if (!isVisible()) show(); 254 raise(); 255 activateWindow(); 256 playlist->playItem(index); 257 } 258 259 void BaseGui::remoteRemoveItem(int index){ 260 qDebug("BaseGui::remoteRemove: '%s'", QString::number((index)).toUtf8().data()); 261 if (isMinimized()) showNormal(); 262 if (!isVisible()) show(); 263 raise(); 264 activateWindow(); 265 266 if(index == -1) 267 playlist->removeAll(); 268 else 269 playlist->remove(index); 270 } 271 272 void BaseGui::remoteMoveItem(int index, int shift){ 273 qDebug("BaseGui::remoteRemove: '%s'", QString::number((index)).toUtf8().data()); 274 if (isMinimized()) showNormal(); 275 if (!isVisible()) show(); 276 raise(); 277 activateWindow(); 278 279 int step = shift / abs(shift); 280 for(int i = index; i != (index + shift); i += step){ 281 if(step == -1 && index == 0) break; 282 if(step == +1 && index == (playlist->count() - 1)) break; 283 284 if(step == -1) playlist->moveItemUp(index); 285 if(step == +1) playlist->moveItemDown(index); 286 } //end for 287 } 288 289 void BaseGui::remoteOpen(QString file) { 290 qDebug("BaseGui::remoteOpen: '%s'", file.toUtf8().data()); 291 if (isMinimized()) showNormal(); 292 if (!isVisible()) show(); 293 raise(); 294 activateWindow(); 295 open(file); 296 } 297 298 void BaseGui::remoteOpenFiles(QStringList files) { 299 qDebug("BaseGui::remoteOpenFiles"); 300 if (isMinimized()) showNormal(); 301 if (!isVisible()) show(); 302 raise(); 303 activateWindow(); 304 openFiles(files); 305 } 306 307 void BaseGui::remoteAddFiles(QStringList files) { 308 qDebug("BaseGui::remoteAddFiles"); 309 if (isMinimized()) showNormal(); 310 if (!isVisible()) show(); 311 raise(); 312 activateWindow(); 313 314 playlist->addFiles(files); 315 //open(files[0]); 316 } 317 318 void BaseGui::remoteLoadSubtitle(QString file) { 319 qDebug("BaseGui::remoteLoadSubtitle: '%s'", file.toUtf8().data()); 320 321 setInitialSubtitle(file); 322 323 if (core->state() != Core::Stopped) { 324 core->loadSub(file); 325 } 326 } 327 328 void BaseGui::remoteViewPlaylist(QString * output){ 329 qDebug("BaseGui::remoteViewPlaylist"); 330 *output += playlist->print("\t"); 331 } 332 333 void BaseGui::remoteViewStatus(QString * output){ 334 qDebug("BaseGui::remoteViewStatus"); 335 *output = core->stateToString(); 336 } 337 338 void BaseGui::remoteViewClipInfo(QString * output){ 339 qDebug("BaseGui::remoteViewClipInfo"); 340 341 *output += QString("%1\t%2\r\n").arg("Filename", core->mdat.filename); 342 *output += QString("%1\t%2\r\n").arg("Position", QString::number(core->mset.current_sec)); 343 *output += QString("%1\t%2\r\n").arg("Duration", QString::number(core->mdat.duration)); 344 345 *output += QString("%1\t%2\r\n").arg("Title", core->mdat.clip_name); 346 *output += QString("%1\t%2\r\n").arg("Artist", core->mdat.clip_artist); 347 *output += QString("%1\t%2\r\n").arg("Author", core->mdat.clip_author); 348 *output += QString("%1\t%2\r\n").arg("Album", core->mdat.clip_album); 349 *output += QString("%1\t%2\r\n").arg("Genre", core->mdat.clip_genre); 350 *output += QString("%1\t%2\r\n").arg("Date", core->mdat.clip_date); 351 *output += QString("%1\t%2\r\n").arg("Track", core->mdat.clip_track); 352 *output += QString("%1\t%2\r\n").arg("Copyright", core->mdat.clip_copyright); 353 *output += QString("%1\t%2\r\n").arg("Comment", core->mdat.clip_comment); 354 *output += QString("%1\t%2\r\n").arg("Software", core->mdat.clip_software); 355 } 356 357 void BaseGui::remoteSeek(double sec){ 358 qDebug("BaseGui::remoteSeek"); 359 core->goToSec(sec); 360 } 361 362 void BaseGui::remoteGetChecked(QString function, QString* output){ 363 qDebug("BaseGui::remoteGet"); 364 365 QAction* action = ActionsEditor::findAction(this, function); 366 if(! action) action = ActionsEditor::findAction(playlist, function); 367 if(! action) return; 368 369 bool value = (action->isCheckable() ? action->isChecked() : action->isEnabled()); 370 *output = (value ? "true" : "false"); 371 } 372 373 void BaseGui::remoteGetVolume(int *vol){ 374 *vol = (pref->global_volume ? pref->volume : core->mset.volume); 375 } 253 #endif 376 254 377 255 BaseGui::~BaseGui() { 378 256 delete core; // delete before mplayerwindow, otherwise, segfault... 257 #ifdef LOG_MPLAYER 379 258 delete mplayer_log_window; 259 #endif 260 #ifdef LOG_SMPLAYER 380 261 delete smplayer_log_window; 262 #endif 381 263 382 264 delete favorites; … … 391 273 //#endif 392 274 275 #ifdef FIND_SUBTITLES 393 276 if (find_subs_dialog) { 394 277 delete find_subs_dialog; 395 278 find_subs_dialog = 0; // Necessary? 396 279 } 397 280 #endif 281 282 #ifdef VIDEOPREVIEW 398 283 if (video_preview) { 399 284 delete video_preview; 400 285 } 286 #endif 401 287 } 402 288 … … 628 514 core, SLOT(screenshots()) ); 629 515 516 #ifdef VIDEOPREVIEW 630 517 videoPreviewAct = new MyAction( this, "video_preview" ); 631 518 connect( videoPreviewAct, SIGNAL(triggered()), 632 519 this, SLOT(showVideoPreviewDialog()) ); 520 #endif 633 521 634 522 flipAct = new MyAction( this, "flip" ); … … 663 551 connect( deringAct, SIGNAL(toggled(bool)), 664 552 core, SLOT(toggleDering(bool)) ); 553 554 gradfunAct = new MyAction( this, "gradfun" ); 555 gradfunAct->setCheckable( true ); 556 connect( gradfunAct, SIGNAL(toggled(bool)), 557 core, SLOT(toggleGradfun(bool)) ); 558 665 559 666 560 addNoiseAct = new MyAction( this, "add_noise" ); … … 803 697 connect( subVisibilityAct, SIGNAL(toggled(bool)), core, SLOT(changeSubVisibility(bool)) ); 804 698 699 #ifdef FIND_SUBTITLES 805 700 showFindSubtitlesDialogAct = new MyAction( this, "show_find_sub_dialog" ); 806 701 connect( showFindSubtitlesDialogAct, SIGNAL(triggered()), … … 810 705 connect( openUploadSubtitlesPageAct, SIGNAL(triggered()), //turbos 811 706 this, SLOT(openUploadSubtitlesPage()) ); //turbos 812 707 #endif 813 708 814 709 // Menu Options … … 831 726 832 727 // Submenu Logs 728 #ifdef LOG_MPLAYER 833 729 showLogMplayerAct = new MyAction( QKeySequence("Ctrl+M"), this, "show_mplayer_log" ); 834 730 connect( showLogMplayerAct, SIGNAL(triggered()), 835 731 this, SLOT(showMplayerLog()) ); 836 732 #endif 733 734 #ifdef LOG_SMPLAYER 837 735 showLogSmplayerAct = new MyAction( QKeySequence("Ctrl+S"), this, "show_smplayer_log" ); 838 736 connect( showLogSmplayerAct, SIGNAL(triggered()), 839 737 this, SLOT(showLog()) ); 738 #endif 840 739 841 740 // Menu Help … … 1017 916 denoiseSoftAct = new MyActionGroupItem(this, denoiseGroup, "denoise_soft", MediaSettings::DenoiseSoft); 1018 917 connect( denoiseGroup, SIGNAL(activated(int)), core, SLOT(changeDenoise(int)) ); 918 919 // Unsharp group 920 unsharpGroup = new MyActionGroup(this); 921 unsharpNoneAct = new MyActionGroupItem(this, unsharpGroup, "unsharp_off", 0); 922 blurAct = new MyActionGroupItem(this, unsharpGroup, "blur", 1); 923 sharpenAct = new MyActionGroupItem(this, unsharpGroup, "sharpen", 2); 924 connect( unsharpGroup, SIGNAL(activated(int)), core, SLOT(changeUnsharp(int)) ); 1019 925 1020 926 // Video size … … 1246 1152 deblockAct->setEnabled(b); 1247 1153 deringAct->setEnabled(b); 1154 gradfunAct->setEnabled(b); 1248 1155 addNoiseAct->setEnabled(b); 1249 1156 addLetterboxAct->setEnabled(b); … … 1324 1231 // Groups 1325 1232 denoiseGroup->setActionsEnabled(b); 1233 unsharpGroup->setActionsEnabled(b); 1326 1234 sizeGroup->setActionsEnabled(b); 1327 1235 deinterlaceGroup->setActionsEnabled(b); … … 1383 1291 deblockAct->setEnabled(false); 1384 1292 deringAct->setEnabled(false); 1293 gradfunAct->setEnabled(false); 1385 1294 addNoiseAct->setEnabled(false); 1386 1295 addLetterboxAct->setEnabled(false); … … 1401 1310 1402 1311 denoiseGroup->setActionsEnabled(false); 1312 unsharpGroup->setActionsEnabled(false); 1403 1313 sizeGroup->setActionsEnabled(false); 1404 1314 deinterlaceGroup->setActionsEnabled(false); … … 1425 1335 deblockAct->setEnabled(false); 1426 1336 deringAct->setEnabled(false); 1337 gradfunAct->setEnabled(false); 1427 1338 addNoiseAct->setEnabled(false); 1428 1339 addLetterboxAct->setEnabled(false); … … 1432 1343 rotateGroup->setActionsEnabled(false); 1433 1344 denoiseGroup->setActionsEnabled(false); 1345 unsharpGroup->setActionsEnabled(false); 1434 1346 1435 1347 displayMessage( tr("Video filters are disabled when using vdpau") ); … … 1552 1464 screenshotAct->change( Images::icon("screenshot"), tr("&Screenshot") ); 1553 1465 screenshotsAct->change( Images::icon("screenshots"), tr("Start/stop takin&g screenshots") ); 1466 #ifdef VIDEOPREVIEW 1554 1467 videoPreviewAct->change( Images::icon("video_preview"), tr("Pre&view...") ); 1468 #endif 1555 1469 flipAct->change( Images::icon("flip"), tr("Fli&p image") ); 1556 1470 mirrorAct->change( Images::icon("mirror"), tr("Mirr&or image") ); … … 1577 1491 deblockAct->change( tr("&Deblock") ); 1578 1492 deringAct->change( tr("De&ring") ); 1493 gradfunAct->change( tr("Debanding (&gradfun)") ); 1579 1494 addNoiseAct->change( tr("Add n&oise") ); 1580 1495 addLetterboxAct->change( Images::icon("letterbox"), tr("Add &black borders") ); … … 1618 1533 subVisibilityAct->change( Images::icon("sub_visibility"), tr("Subtitle &visibility") ); 1619 1534 1535 #ifdef FIND_SUBTITLES 1620 1536 showFindSubtitlesDialogAct->change( Images::icon("download_subs"), tr("Find subtitles on &OpenSubtitles.org...") ); 1621 1537 openUploadSubtitlesPageAct->change( Images::icon("upload_subs"), tr("Upload su&btitles to OpenSubtitles.org...") ); 1622 1623 ccNoneAct->change( tr("&Off") ); 1538 #endif 1539 1540 ccNoneAct->change( tr("&Off", "closed captions menu") ); 1624 1541 ccChannel1Act->change( "&1" ); 1625 1542 ccChannel2Act->change( "&2" ); … … 1634 1551 1635 1552 // Submenu Logs 1553 #ifdef LOG_MPLAYER 1636 1554 showLogMplayerAct->change( "MPlayer" ); 1555 #endif 1556 #ifdef LOG_SMPLAYER 1637 1557 showLogSmplayerAct->change( "SMPlayer" ); 1558 #endif 1638 1559 1639 1560 // Menu Help … … 1781 1702 #endif 1782 1703 1783 /*1784 1704 denoise_menu->menuAction()->setText( tr("De&noise") ); 1785 1705 denoise_menu->menuAction()->setIcon( Images::icon("denoise") ); 1786 */ 1706 1707 unsharp_menu->menuAction()->setText( tr("Blur/S&harp") ); 1708 unsharp_menu->menuAction()->setIcon( Images::icon("unsharp") ); 1787 1709 1788 1710 aspectDetectAct->change( tr("&Auto") ); … … 1805 1727 deinterlaceKernAct->change( tr("&Kerndeint") ); 1806 1728 1807 denoiseNoneAct->change( tr("Denoise o&ff") ); 1808 denoiseNormalAct->change( tr("Denoise nor&mal") ); 1809 denoiseSoftAct->change( tr("Denoise &soft") ); 1729 denoiseNoneAct->change( tr("&Off", "denoise menu") ); 1730 denoiseNormalAct->change( tr("&Normal","denoise menu") ); 1731 denoiseSoftAct->change( tr("&Soft", "denoise menu") ); 1732 1733 unsharpNoneAct->change( tr("&None", "unsharp menu") ); 1734 blurAct->change( tr("&Blur", "unsharp menu") ); 1735 sharpenAct->change( tr("&Sharpen", "unsharp menu") ); 1810 1736 1811 1737 rotateNoneAct->change( tr("&Off") ); … … 1884 1810 osd_menu->menuAction()->setIcon( Images::icon("osd") ); 1885 1811 1812 #if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER) 1886 1813 logs_menu->menuAction()->setText( tr("&View logs") ); 1887 1814 logs_menu->menuAction()->setIcon( Images::icon("logs") ); 1888 1815 #endif 1889 1816 1890 1817 // To be sure that the "<empty>" string is translated … … 1892 1819 1893 1820 // Other things 1894 mplayer_log_window->setWindowTitle( tr("SMPlayer - mplayer log") ); 1895 smplayer_log_window->setWindowTitle( tr("SMPlayer - smplayer log") ); 1821 #ifdef LOG_MPLAYER 1822 mplayer_log_window->setWindowTitle( tr("SMPlayer - MPlayer log") ); 1823 #endif 1824 #ifdef LOG_SMPLAYER 1825 smplayer_log_window->setWindowTitle( tr("SMPlayer - SMPlayer log") ); 1826 #endif 1896 1827 1897 1828 updateRecents(); … … 2018 1949 2019 1950 // Log mplayer output 1951 #ifdef LOG_MPLAYER 2020 1952 connect( core, SIGNAL(aboutToStartPlaying()), 2021 1953 this, SLOT(clearMplayerLog()) ); … … 2025 1957 connect( core, SIGNAL(mediaLoaded()), 2026 1958 this, SLOT(autosaveMplayerLog()) ); 1959 #endif 2027 1960 } 2028 1961 … … 2318 2251 videofilter_menu->menuAction()->setObjectName("videofilter_menu"); 2319 2252 videofilter_menu->addAction(postProcessingAct); 2320 videofilter_menu->addAction(phaseAct);2321 2253 videofilter_menu->addAction(deblockAct); 2322 2254 videofilter_menu->addAction(deringAct); 2255 videofilter_menu->addAction(gradfunAct); 2323 2256 videofilter_menu->addAction(addNoiseAct); 2324 2257 videofilter_menu->addAction(addLetterboxAct); 2325 2258 videofilter_menu->addAction(upscaleAct); 2259 videofilter_menu->addAction(phaseAct); 2260 2261 // Denoise submenu 2262 denoise_menu = new QMenu(this); 2263 denoise_menu->menuAction()->setObjectName("denoise_menu"); 2264 denoise_menu->addActions(denoiseGroup->actions()); 2265 videofilter_menu->addMenu(denoise_menu); 2266 2267 // Unsharp submenu 2268 unsharp_menu = new QMenu(this); 2269 unsharp_menu->menuAction()->setObjectName("unsharp_menu"); 2270 unsharp_menu->addActions(unsharpGroup->actions()); 2271 videofilter_menu->addMenu(unsharp_menu); 2272 /* 2326 2273 videofilter_menu->addSeparator(); 2327 2274 videofilter_menu->addActions(denoiseGroup->actions()); 2328 2275 videofilter_menu->addSeparator(); 2276 videofilter_menu->addActions(unsharpGroup->actions()); 2277 */ 2329 2278 videoMenu->addMenu(videofilter_menu); 2330 2331 // Denoise submenu2332 /*2333 denoise_menu = new QMenu(this);2334 denoise_menu->addActions(denoiseGroup->actions());2335 videoMenu->addMenu(denoise_menu);2336 */2337 2279 2338 2280 // Rotate submenu … … 2357 2299 videoMenu->addMenu(ontop_menu); 2358 2300 2301 #ifdef VIDEOPREVIEW 2359 2302 videoMenu->addSeparator(); 2360 2303 videoMenu->addAction(videoPreviewAct); 2304 #endif 2361 2305 2362 2306 … … 2447 2391 subtitlesMenu->addSeparator(); 2448 2392 subtitlesMenu->addAction(useAssAct); 2393 #ifdef FIND_SUBTITLES 2449 2394 subtitlesMenu->addSeparator(); //turbos 2450 2395 subtitlesMenu->addAction(showFindSubtitlesDialogAct); 2451 2396 subtitlesMenu->addAction(openUploadSubtitlesPageAct); //turbos 2397 #endif 2452 2398 2453 2399 // BROWSE MENU … … 2491 2437 { 2492 2438 QString tube_exec = Paths::appPath() + "/smtube"; 2493 #if def Q_OS_WIN2439 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) 2494 2440 tube_exec += ".exe"; 2495 2441 #endif … … 2510 2456 2511 2457 // Logs submenu 2458 #if defined(LOG_MPLAYER) || defined(LOG_SMPLAYER) 2512 2459 logs_menu = new QMenu(this); 2460 #ifdef LOG_MPLAYER 2513 2461 logs_menu->addAction(showLogMplayerAct); 2462 #endif 2463 #ifdef LOG_SMPLAYER 2514 2464 logs_menu->addAction(showLogSmplayerAct); 2515 2465 #endif 2516 2466 optionsMenu->addMenu(logs_menu); 2467 #endif 2517 2468 2518 2469 optionsMenu->addAction(showPreferencesAct); … … 2649 2600 pl->setPlayFilesFromStart(playlist->playFilesFromStart()); 2650 2601 2651 PrefInterface * pi = pref_dialog->mod_interface();2652 pi->setSingleInstanceTabEnabled( use_control_server );2653 2654 2602 pref_dialog->show(); 2655 2603 } … … 2688 2636 changeStyleSheet(pref->iconset); 2689 2637 #endif 2690 }2691 2692 if (use_control_server) {2693 if (!pref->use_single_instance && server->isListening()) {2694 server->close();2695 qDebug("BaseGui::applyNewPreferences: server closed");2696 }2697 else2698 {2699 bool server_requires_restart = _interface->serverPortChanged();2700 if (pref->use_single_instance && !server->isListening())2701 server_requires_restart=true;2702 2703 if (server_requires_restart) {2704 server->close();2705 int port = 0;2706 if (!pref->use_autoport) port = pref->connection_port;2707 if (server->listen(port)) {2708 pref->autoport = server->serverPort();2709 qDebug("BaseGui::applyNewPreferences: server running on port %d", pref->autoport);2710 } else {2711 qWarning("BaseGui::applyNewPreferences: server couldn't be started");2712 }2713 }2714 }2715 2638 } 2716 2639 … … 2772 2695 2773 2696 // Restart the video if needed 2774 2697 if (pref_dialog->requiresRestart()) 2775 2698 core->restart(); 2776 2699 … … 2780 2703 2781 2704 #ifndef NO_USE_INI_FILES 2782 pref->save(); 2783 #endif 2705 pref->save(); 2706 #endif 2707 2708 2709 if (_interface->guiChanged()) { 2710 #ifdef GUI_CHANGE_ON_RUNTIME 2711 core->stop(); 2712 emit guiChanged(pref->gui); 2713 #else 2714 QMessageBox::information(this, tr("Information"), 2715 tr("You need to restart SMPlayer to use the new GUI.") ); 2716 #endif 2717 } 2784 2718 } 2785 2719 … … 2941 2875 } 2942 2876 2877 #ifdef LOG_MPLAYER 2943 2878 void BaseGui::clearMplayerLog() { 2944 2879 mplayer_log.clear(); … … 2953 2888 if (mplayer_log_window->isVisible()) mplayer_log_window->appendText(line); 2954 2889 } 2955 }2956 }2957 2958 void BaseGui::recordSmplayerLog(QString line) {2959 if (pref->log_smplayer) {2960 line.append("\n");2961 smplayer_log.append(line);2962 if (smplayer_log_window->isVisible()) smplayer_log_window->appendText(line);2963 2890 } 2964 2891 } … … 2991 2918 mplayer_log_window->show(); 2992 2919 } 2920 #endif 2921 2922 #ifdef LOG_SMPLAYER 2923 void BaseGui::recordSmplayerLog(QString line) { 2924 if (pref->log_smplayer) { 2925 line.append("\n"); 2926 smplayer_log.append(line); 2927 if (smplayer_log_window->isVisible()) smplayer_log_window->appendText(line); 2928 } 2929 } 2993 2930 2994 2931 void BaseGui::showLog() { 2995 2932 qDebug("BaseGui::showLog"); 2996 2933 2997 2934 exitFullscreenIfNeeded(); 2998 2935 2999 2936 smplayer_log_window->setText( smplayer_log ); 3000 smplayer_log_window->show(); 3001 } 2937 smplayer_log_window->show(); 2938 } 2939 #endif 3002 2940 3003 2941 … … 3084 3022 titles_menu->addActions( titleGroup->actions() ); 3085 3023 3086 #if GENERIC_CHAPTER_SUPPORT 3024 // Chapters 3087 3025 chapterGroup->clear(true); 3088 if (core->mdat.chapters > 0) {3089 for (n=0; n < core->mdat.chapters ; n++) {3026 if (core->mdat.chapters.numItems() > 0) { 3027 for (n=0; n < core->mdat.chapters.numItems(); n++) { 3090 3028 QAction *a = new QAction(chapterGroup); 3091 a->setCheckable(true); 3029 //a->setCheckable(true); 3030 a->setText(core->mdat.chapters.itemAt(n).name()); 3031 a->setData(n + Core::firstChapter()); 3032 } 3033 } 3034 else 3035 if (core->mdat.n_chapters > 0) { 3036 for (n=0; n < core->mdat.n_chapters; n++) { 3037 QAction *a = new QAction(chapterGroup); 3038 //a->setCheckable(true); 3092 3039 a->setText( QString::number(n+1) ); 3093 3040 a->setData( n + Core::firstChapter() ); 3094 3041 } 3095 } else { 3042 } 3043 else { 3096 3044 QAction * a = chapterGroup->addAction( tr("<empty>") ); 3097 3045 a->setEnabled(false); 3098 3046 } 3099 3047 chapters_menu->addActions( chapterGroup->actions() ); 3100 #else3101 // DVD Chapters3102 chapterGroup->clear(true);3103 if ( (core->mdat.type == TYPE_DVD) && (core->mset.current_title_id > 0) ) {3104 for (n=0; n < core->mdat.titles.item(core->mset.current_title_id).chapters(); n++) {3105 QAction *a = new QAction(chapterGroup);3106 a->setCheckable(true);3107 a->setText( QString::number(n+1) );3108 a->setData( n + Core::dvdFirstChapter() );3109 }3110 } else {3111 // *** Matroshka chapters ***3112 if (core->mdat.mkv_chapters > 0) {3113 for (n=0; n < core->mdat.mkv_chapters; n++) {3114 QAction *a = new QAction(chapterGroup);3115 a->setCheckable(true);3116 a->setText( QString::number(n+1) );3117 a->setData( n + Core::firstChapter() );3118 }3119 } else {3120 QAction * a = chapterGroup->addAction( tr("<empty>") );3121 a->setEnabled(false);3122 }3123 }3124 chapters_menu->addActions( chapterGroup->actions() );3125 #endif3126 3048 3127 3049 // Angles … … 3253 3175 deringAct->setChecked( core->mset.dering_filter ); 3254 3176 3177 // Gradfun 3178 gradfunAct->setChecked( core->mset.gradfun_filter ); 3179 3255 3180 // Add noise 3256 3181 addNoiseAct->setChecked( core->mset.noise_filter ); … … 3268 3193 // Denoise submenu 3269 3194 denoiseGroup->setChecked( core->mset.current_denoiser ); 3195 3196 // Unsharp submenu 3197 unsharpGroup->setChecked( core->mset.current_unsharp ); 3270 3198 3271 3199 /* … … 3422 3350 // If file is a playlist, open that playlist 3423 3351 QString extension = QFileInfo(file).suffix().toLower(); 3424 if ( ( extension=="m3u") || (extension=="m3u8") ) {3352 if ( ((extension=="m3u") || (extension=="m3u8")) && (QFile::exists(file)) ) { 3425 3353 playlist->load_m3u(file); 3426 3354 } … … 4568 4496 actions_list += ActionsEditor::actionsNames(playlist); 4569 4497 #endif 4570 4571 if (server) server->setActionsList( actions_list );4572 4498 } 4573 4499 … … 4634 4560 d.setText(tr("MPlayer has finished unexpectedly.") + " " + 4635 4561 tr("Exit code: %1").arg(exit_code)); 4562 #ifdef LOG_MPLAYER 4636 4563 d.setLog( mplayer_log ); 4564 #endif 4637 4565 d.exec(); 4638 4566 } … … 4656 4584 tr("See the log for more info.")); 4657 4585 } 4586 #ifdef LOG_MPLAYER 4658 4587 d.setLog( mplayer_log ); 4588 #endif 4659 4589 d.exec(); 4660 4590 } … … 4662 4592 4663 4593 4594 #ifdef FIND_SUBTITLES 4664 4595 void BaseGui::showFindSubtitlesDialog() { 4665 4596 qDebug("BaseGui::showFindSubtitlesDialog"); … … 4684 4615 QDesktopServices::openUrl( QUrl("http://www.opensubtitles.org/uploadjava") ); 4685 4616 } 4686 4617 #endif 4618 4619 #ifdef VIDEOPREVIEW 4687 4620 void BaseGui::showVideoPreviewDialog() { 4688 4621 qDebug("BaseGui::showVideoPreviewDialog"); … … 4719 4652 } 4720 4653 } 4654 #endif 4721 4655 4722 4656 void BaseGui::showTubeBrowser() { 4723 4657 qDebug("BaseGui::showTubeBrowser"); 4724 if (!QProcess::startDetached("smtube", QStringList())) { 4658 QString exec = Paths::appPath() + "/smtube"; 4659 qDebug("BaseGui::showTubeBrowser: '%s'", exec.toUtf8().constData()); 4660 if (!QProcess::startDetached(exec, QStringList())) { 4725 4661 QMessageBox::warning(this, tr("An error happened - SMPlayer"), tr("The YouTube Browser couldn't be launched")); 4726 4662 }
Note:
See TracChangeset
for help on using the changeset viewer.