Changeset 181 for smplayer/trunk/src/baseguiplus.cpp
- Timestamp:
- Aug 31, 2016, 5:31:04 PM (9 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 179
- Property svn:mergeinfo changed
-
smplayer/trunk/src/baseguiplus.cpp
r176 r181 24 24 #include "playlist.h" 25 25 26 #ifdef Q_OS_WIN 26 #ifdef TV_SUPPORT 27 #include "tvlist.h" 28 #else 27 29 #include "favorites.h" 28 #else29 #include "tvlist.h"30 30 #endif 31 31 32 32 #include "widgetactions.h" 33 #include "myactiongroup.h" 33 34 34 35 #include <QMenu> … … 45 46 #endif 46 47 48 #ifdef SCREENS_SUPPORT 49 #include <QVBoxLayout> 50 #include <QLabel> 51 #include "mplayerwindow.h" 52 #include "infowindow.h" 53 54 #if QT_VERSION >= 0x050000 55 #include <QScreen> 56 #include <QWindow> 57 #endif 58 #endif 59 60 #ifdef GLOBALSHORTCUTS 61 #include "globalshortcuts/globalshortcuts.h" 62 #include "preferencesdialog.h" 63 #include "prefinput.h" 64 #endif 65 47 66 using namespace Global; 48 67 49 68 BaseGuiPlus::BaseGuiPlus( QWidget * parent, Qt::WindowFlags flags) 50 69 : BaseGui( parent, flags ) 70 #ifdef SCREENS_SUPPORT 71 , screens_info_window(0) 72 , detached_label(0) 73 #endif 74 , mainwindow_visible(true) 75 , trayicon_playlist_was_visible(false) 76 , widgets_size(0) 77 #if DOCK_PLAYLIST 78 , fullscreen_playlist_was_visible(false) 79 , fullscreen_playlist_was_floating(false) 80 , compact_playlist_was_visible(false) 81 , ignore_playlist_events(false) 82 #endif 51 83 { 52 84 // Initialize variables 53 mainwindow_visible = true;54 85 //infowindow_visible = false; 55 trayicon_playlist_was_visible = false;56 widgets_size = 0;57 #if DOCK_PLAYLIST58 fullscreen_playlist_was_visible = false;59 fullscreen_playlist_was_floating = false;60 compact_playlist_was_visible = false;61 ignore_playlist_events = false;62 #endif63 64 86 mainwindow_pos = pos(); 65 87 … … 71 93 72 94 quitAct = new MyAction(QKeySequence("Ctrl+Q"), this, "quit"); 73 connect( quitAct, SIGNAL(triggered()), this, SLOT(quit()) ); 74 openMenu->addAction(quitAct); 95 connect( quitAct, SIGNAL(triggered()), this, SLOT(quit()) ); 75 96 76 97 showTrayAct = new MyAction(this, "show_tray_icon" ); … … 79 100 tray, SLOT(setVisible(bool)) ); 80 101 81 #ifndef Q_OS_OS282 optionsMenu->addAction(showTrayAct);83 #else84 trayAvailable();85 connect( optionsMenu, SIGNAL(aboutToShow()),86 this, SLOT(trayAvailable()) );87 #endif88 89 102 showAllAct = new MyAction(this, "restore/hide"); 90 103 connect( showAllAct, SIGNAL(triggered()), 91 104 this, SLOT(toggleShowAll()) ); 92 93 105 94 106 context_menu = new QMenu(this); … … 101 113 context_menu->addAction(openURLAct); 102 114 context_menu->addMenu(favorites); 103 #if ndef Q_OS_WIN115 #if defined(TV_SUPPORT) && !defined(Q_OS_WIN) 104 116 context_menu->addMenu(tvlist); 105 117 context_menu->addMenu(radiolist); … … 116 128 context_menu->addSeparator(); 117 129 context_menu->addAction(quitAct); 118 130 119 131 tray->setContextMenu( context_menu ); 120 132 … … 150 162 #endif // DOCK_PLAYLIST 151 163 164 #ifdef DETACH_VIDEO_OPTION 165 detachVideoAct = new MyAction(this, "detach_video"); 166 detachVideoAct->setCheckable(true); 167 connect(detachVideoAct, SIGNAL(toggled(bool)), this, SLOT(detachVideo(bool))); 168 #endif 169 170 #ifdef SCREENS_SUPPORT 171 sendToScreen_menu = new QMenu(this); 172 sendToScreen_menu->menuAction()->setObjectName("send_to_screen_menu"); 173 174 sendToScreenGroup = new MyActionGroup(this); 175 connect(sendToScreenGroup, SIGNAL(activated(int)), this, SLOT(sendVideoToScreen(int))); 176 177 updateSendToScreen(); 178 179 showScreensInfoAct = new MyAction(this, "screens_info"); 180 connect(showScreensInfoAct, SIGNAL(triggered()), this, SLOT(showScreensInfo())); 181 182 #if QT_VERSION >= 0x040600 && QT_VERSION < 0x050000 183 connect(qApp->desktop(), SIGNAL(screenCountChanged(int)), this, SLOT(updateSendToScreen())); 184 #endif 185 #if QT_VERSION >= 0x050000 186 connect(qApp, SIGNAL(screenAdded(QScreen *)), this, SLOT(updateSendToScreen())); 187 #endif 188 #if QT_VERSION >= 0x050400 189 connect(qApp, SIGNAL(screenRemoved(QScreen *)), this, SLOT(updateSendToScreen())); 190 #endif 191 #if QT_VERSION >= 0x050600 192 connect(qApp, SIGNAL(primaryScreenChanged(QScreen *)), this, SLOT(updateSendToScreen())); 193 #endif 194 195 // Label that replaces the mplayerwindow when detached 196 detached_label = new QLabel(panel); 197 detached_label->setAlignment(Qt::AlignCenter); 198 panel->layout()->addWidget(detached_label); 199 detached_label->hide(); 200 #endif 201 202 #ifdef GLOBALSHORTCUTS 203 global_shortcuts = new GlobalShortcuts(this); 204 global_shortcuts->setEnabled(pref->use_global_shortcuts); 205 connect(this, SIGNAL(preferencesChanged()), this, SLOT(updateGlobalShortcuts())); 206 #endif 207 152 208 retranslateStrings(); 153 154 loadConfig(); 209 loadConfig(); 155 210 } 156 211 … … 158 213 saveConfig(); 159 214 tray->hide(); 215 } 216 217 void BaseGuiPlus::populateMainMenu() { 218 qDebug("BaseGuiPlus::populateMainMenu"); 219 220 BaseGui::populateMainMenu(); 221 222 if (!pref->tablet_mode) { 223 openMenu->addAction(quitAct); 224 optionsMenu->addAction(showTrayAct); 225 } 226 227 #ifdef DETACH_VIDEO_OPTION 228 optionsMenu->addAction(detachVideoAct); 229 #endif 230 231 #ifdef SCREENS_SUPPORT 232 videoMenu->insertMenu(videosize_menu->menuAction(), sendToScreen_menu); 233 //optionsMenu->addMenu(sendToScreen_menu); 234 235 if (!pref->tablet_mode) { 236 viewMenu->addSeparator(); 237 viewMenu->addAction(showScreensInfoAct); 238 } 239 240 access_menu->insertMenu(tabletModeAct, sendToScreen_menu); 241 #endif 160 242 } 161 243 … … 217 299 #if DOCK_PLAYLIST 218 300 playlistdock->setWindowTitle( tr("Playlist") ); 301 #endif 302 303 #ifdef DETACH_VIDEO_OPTION 304 detachVideoAct->change("Detach video"); 305 #endif 306 307 #ifdef SCREENS_SUPPORT 308 sendToScreen_menu->menuAction()->setText( tr("Send &video to screen") ); 309 sendToScreen_menu->menuAction()->setIcon(Images::icon("send_to_screen")); 310 showScreensInfoAct->change(tr("Information about connected &screens")); 311 312 detached_label->setText("<img src=\"" + Images::file("send_to_screen") + "\">" + 313 "<p style=\"color: white;\">" + tr("Video is sent to an external screen") +"</p"); 219 314 #endif 220 315 } … … 411 506 (!fullscreen_playlist_was_floating) */ ) 412 507 { 508 #if QT_VERSION < 0x050000 || !defined(Q_OS_LINUX) 413 509 playlistdock->setFloating(true); 510 #endif 414 511 playlistdock->hide(); 415 512 } … … 583 680 #endif 584 681 682 #ifdef GLOBALSHORTCUTS 683 void BaseGuiPlus::showPreferencesDialog() { 684 qDebug("BaseGuiPlus::showPreferencesDialog"); 685 global_shortcuts->setEnabled(false); 686 BaseGui::showPreferencesDialog(); 687 } 688 689 void BaseGuiPlus::updateGlobalShortcuts() { 690 qDebug("BaseGuiPlus::updateGlobalShortcuts"); 691 global_shortcuts->setEnabled(pref->use_global_shortcuts); 692 } 693 #endif 694 695 585 696 // Convenience functions intended for other GUI's 586 697 TimeSliderAction * BaseGuiPlus::createTimeSliderAction(QWidget * parent) { … … 623 734 volumeslider_action->setObjectName("volumeslider_action"); 624 735 625 connect( volumeslider_action, SIGNAL( valueChanged(int) ), 736 connect( volumeslider_action, SIGNAL( valueChanged(int) ), 626 737 core, SLOT( setVolume(int) ) ); 627 738 connect( core, SIGNAL(volumeChanged(int)), … … 631 742 } 632 743 633 #ifdef Q_OS_OS2 634 // we test if xcenter is available at all. if not disable the tray action. this is possible when xcenter is not opened or crashed 635 void BaseGuiPlus::trayAvailable() { 636 if (!tray->isSystemTrayAvailable()) { 637 optionsMenu->removeAction(showTrayAct); 638 } 639 else { 640 optionsMenu->addAction(showTrayAct); 641 } 642 } 744 TimeLabelAction * BaseGuiPlus::createTimeLabelAction(TimeLabelAction::TimeLabelType type, QWidget * parent) { 745 TimeLabelAction * time_label_action = new TimeLabelAction(type, parent); 746 time_label_action->setObjectName("timelabel_action"); 747 748 connect(this, SIGNAL(timeChanged(double)), time_label_action, SLOT(setCurrentTime(double))); 749 connect(core, SIGNAL(newDuration(double)), time_label_action, SLOT(setTotalTime(double))); 750 751 return time_label_action; 752 } 753 754 #ifdef SCREENS_SUPPORT 755 void BaseGuiPlus::showScreensInfo() { 756 qDebug("BaseGuiPlus::showScreensInfo"); 757 758 /* 759 updateSendToScreen(); 760 */ 761 762 if (!screens_info_window) { 763 screens_info_window = new InfoWindow(this); 764 screens_info_window->setWindowTitle(tr("Information about connected screens")); 765 } 766 767 QString t = "<h1>" + tr("Connected screens") + "</h1>"; 768 #if QT_VERSION >= 0x050000 769 QList<QScreen *> screen_list = qApp->screens(); 770 t += "<p>" + tr("Number of screens: %1").arg(screen_list.count()); 771 QString screen_name = qApp->primaryScreen()->name(); 772 #ifdef Q_OS_WIN 773 screen_name = screen_name.replace("\\\\.\\",""); 774 #endif 775 t += "<p>" + tr("Primary screen: %1").arg(screen_name); 776 777 t += "<ul>"; 778 foreach(QScreen *screen, screen_list) { 779 screen_name = screen->name(); 780 #ifdef Q_OS_WIN 781 screen_name = screen_name.replace("\\\\.\\",""); 782 #endif 783 t += "<li>" + tr("Information for screen %1").arg(screen_name); 784 t += "<ul>"; 785 t += "<li>" + tr("Available geometry: %1 %2 %3 x %4").arg(screen->availableGeometry().x()).arg(screen->availableGeometry().y()) 786 .arg(screen->availableGeometry().width()).arg(screen->availableGeometry().height()) + "</li>"; 787 t += "<li>" + tr("Available size: %1 x %2").arg(screen->availableSize().width()).arg(screen->availableSize().height()) + "</li>"; 788 t += "<li>" + tr("Available virtual geometry: %1 %2 %3 x %4").arg(screen->availableVirtualGeometry().x()) 789 .arg(screen->availableVirtualGeometry().y()) 790 .arg(screen->availableVirtualGeometry().width()) 791 .arg(screen->availableVirtualGeometry().height()) + "</li>"; 792 t += "<li>" + tr("Available virtual size: %1 x %2").arg(screen->availableVirtualSize().width()) 793 .arg(screen->availableVirtualSize().height()) + "</li>"; 794 t += "<li>" + tr("Depth: %1 bits").arg(screen->depth()) + "</li>"; 795 t += "<li>" + tr("Geometry: %1 %2 %3 x %4").arg(screen->geometry().x()).arg(screen->geometry().y()) 796 .arg(screen->geometry().width()).arg(screen->geometry().height()) + "</li>"; 797 t += "<li>" + tr("Logical DPI: %1").arg(screen->logicalDotsPerInch()) + "</li>"; 798 //t += "<li>" + tr("Orientation: %1").arg(screen->orientation()) + "</li>"; 799 t += "<li>" + tr("Physical DPI: %1").arg(screen->physicalDotsPerInch()) + "</li>"; 800 t += "<li>" + tr("Physical size: %1 x %2 mm").arg(screen->physicalSize().width()).arg(screen->physicalSize().height()) + "</li>"; 801 //t += "<li>" + tr("Primary orientation: %1").arg(screen->primaryOrientation()) + "</li>"; 802 t += "<li>" + tr("Refresh rate: %1 Hz").arg(screen->refreshRate()) + "</li>"; 803 t += "<li>" + tr("Size: %1 x %2").arg(screen->size().width()).arg(screen->size().height()) + "</li>"; 804 t += "<li>" + tr("Virtual geometry: %1 %2 %3 x %4").arg(screen->virtualGeometry().x()).arg(screen->virtualGeometry().y()) 805 .arg(screen->virtualGeometry().width()).arg(screen->virtualGeometry().height()) + "</li>"; 806 t += "<li>" + tr("Virtual size: %1 x %2").arg(screen->virtualSize().width()).arg(screen->virtualSize().height()) + "</li>"; 807 t += "</ul></li>"; 808 } 809 t += "</ul>"; 810 #else 811 QDesktopWidget * dw = qApp->desktop(); 812 t += "<p>" + tr("Number of screens: %1").arg(dw->screenCount()); 813 t += "<p>" + tr("Primary screen: %1").arg(dw->primaryScreen()+1); 814 815 t += "<ul>"; 816 for (int n = 0; n < dw->screenCount(); n++) { 817 t += "<li>" + tr("Information for screen %1").arg(n+1); 818 t += "<ul>"; 819 t += "<li>" + tr("Available geometry: %1 %2 %3 x %4").arg(dw->availableGeometry(n).x()).arg(dw->availableGeometry(n).y()) 820 .arg(dw->availableGeometry(n).width()).arg(dw->availableGeometry(n).height()) + "</li>"; 821 t += "<li>" + tr("Geometry: %1 %2 %3 x %4").arg(dw->screenGeometry(n).x()).arg(dw->screenGeometry(n).y()) 822 .arg(dw->screenGeometry(n).width()).arg(dw->screenGeometry(n).height()) + "</li>"; 823 t += "</ul></li>"; 824 } 825 t += "</ul>"; 826 #endif 827 828 screens_info_window->setHtml(t); 829 screens_info_window->show(); 830 } 831 832 void BaseGuiPlus::updateSendToScreen() { 833 qDebug("BaseGuiPlus::updateSendToScreen"); 834 835 sendToScreenGroup->clear(true); 836 837 #if QT_VERSION >= 0x050000 838 QList<QScreen *> screen_list = qApp->screens(); 839 int n_screens = screen_list.count(); 840 #else 841 QDesktopWidget * dw = qApp->desktop(); 842 int n_screens = dw->screenCount(); 843 #endif 844 845 for (int n = 0; n < n_screens; n++) { 846 QString name; 847 #if QT_VERSION >= 0x050000 848 name = screen_list[n]->name(); 849 #ifdef Q_OS_WIN 850 name = name.replace("\\\\.\\",""); 851 #endif 852 bool is_primary_screen = (screen_list[n] == qApp->primaryScreen()); 853 #else 854 bool is_primary_screen = (n == dw->primaryScreen()); 855 #endif 856 MyAction * screen_item = new MyActionGroupItem(this, sendToScreenGroup, QString("send_to_screen_%1").arg(n+1).toLatin1().constData(), n); 857 QString desc = "&" + QString::number(n+1); 858 if (!name.isEmpty()) desc += " - " + name; 859 if (is_primary_screen) desc += " (" + tr("Primary screen") + ")"; 860 screen_item->change(desc); 861 } 862 863 sendToScreen_menu->clear(); 864 sendToScreen_menu->addActions(sendToScreenGroup->actions()); 865 866 if (n_screens == 1 && isVideoDetached()) detachVideo(false); 867 } 868 869 void BaseGuiPlus::sendVideoToScreen(int screen) { 870 qDebug() << "BaseGuiPlus::sendVideoToScreen:" << screen; 871 872 #if QT_VERSION >= 0x050000 873 QList<QScreen *> screen_list = qApp->screens(); 874 int n_screens = screen_list.count(); 875 #else 876 QDesktopWidget * dw = qApp->desktop(); 877 int n_screens = dw->screenCount(); 878 #endif 879 880 if (screen < n_screens) { 881 #if QT_VERSION >= 0x050000 882 bool is_primary_screen = (screen_list[screen] == qApp->primaryScreen()); 883 QRect geometry = screen_list[screen]->geometry(); 884 #else 885 bool is_primary_screen = (screen == dw->primaryScreen()); 886 QRect geometry = dw->screenGeometry(screen); 887 qDebug() << "BaseGuiPlus::sendVideoToScreen: screen geometry:" << geometry; 888 #endif 889 qDebug() << "BaseGuiPlus::sendVideoToScreen: is_primary_screen:" << is_primary_screen; 890 //is_primary_screen = false; 891 if (is_primary_screen) { 892 mplayerwindow->showNormal(); 893 detachVideo(false); 894 } else { 895 detachVideo(true); 896 //#if QT_VERSION >= 0x050000 897 //mplayerwindow->windowHandle()->setScreen(screen_list[screen]); // Doesn't work 898 //#else 899 mplayerwindow->move(geometry.x(), geometry.y()); 900 //#endif 901 qApp->processEvents(); 902 //toggleFullscreen(true); 903 mplayerwindow->showFullScreen(); 904 } 905 } else { 906 // Error 907 qWarning() << "BaseGuiPlus::sendVideoToScreen: screen" << screen << "is not valid"; 908 } 909 } 910 911 bool BaseGuiPlus::isVideoDetached() { 912 return (mplayerwindow->parent() == 0); 913 } 914 915 void BaseGuiPlus::detachVideo(bool detach) { 916 qDebug() << "BaseGuiPlus::detachVideo:" << detach; 917 918 if (detach) { 919 if (!isVideoDetached()) { 920 toggleFullscreen(false); 921 fullscreenAct->setEnabled(false); 922 923 panel->layout()->removeWidget(mplayerwindow); 924 mplayerwindow->setParent(0); 925 mplayerwindow->setWindowTitle(tr("SMPlayer external screen output")); 926 927 detached_label->show(); 928 } 929 mplayerwindow->show(); 930 } else { 931 if (isVideoDetached()) { 932 fullscreenAct->setEnabled(true); 933 934 detached_label->hide(); 935 936 mplayerwindow->setWindowTitle(QString::null); 937 mplayerwindow->setParent(panel); 938 panel->layout()->addWidget(mplayerwindow); 939 } 940 } 941 } 942 943 /* 944 void BaseGuiPlus::toggleFullscreen(bool b) { 945 qDebug() << "BaseGuiPlus::toggleFullscreen:" << b; 946 if (!isVideoDetached()) { 947 BaseGui::toggleFullscreen(b); 948 } else { 949 if (b == pref->fullscreen) return; 950 pref->fullscreen = b; 951 952 if (pref->fullscreen) { 953 //aboutToEnterFullscreen(); 954 mplayerwindow->showFullScreen(); 955 } else { 956 mplayerwindow->showNormal(); 957 //aboutToExitFullscreen(); 958 } 959 } 960 } 961 */ 643 962 #endif 644 963
Note:
See TracChangeset
for help on using the changeset viewer.