]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface_win32.cpp
Qt: use DIR_SEP for BDMV and VIDEO_TS detection
[vlc] / modules / gui / qt4 / main_interface_win32.cpp
index 970cd9d90fee1904ed64c8eae0455614922ceab8..e49f2564b2a3fd6c088fff86f8a985cf2001595f 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * main_interface.cpp : Main interface
+ * main_interface_win32.cpp : Main interface
  ****************************************************************************
  * Copyright (C) 2006-2010 VideoLAN and AUTHORS
  * $Id$
 
 #include "input_manager.hpp"
 #include "actions_manager.hpp"
+#include "dialogs_provider.hpp"
 
-#ifdef WIN32
- #include <QBitmap>
- #include <vlc_windows_interfaces.h>
+#include <QBitmap>
+#include <vlc_windows_interfaces.h>
 
 #define WM_APPCOMMAND 0x0319
 
@@ -49,6 +49,8 @@
 #define APPCOMMAND_MICROPHONE_VOLUME_MUTE 24
 #define APPCOMMAND_MICROPHONE_VOLUME_DOWN 25
 #define APPCOMMAND_MICROPHONE_VOLUME_UP   26
+#define APPCOMMAND_HELP                   27
+#define APPCOMMAND_OPEN                   30
 #define APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE    43
 #define APPCOMMAND_MIC_ON_OFF_TOGGLE      44
 #define APPCOMMAND_MEDIA_PLAY             46
 
 void MainInterface::createTaskBarButtons()
 {
-    taskbar_wmsg = WM_NULL;
     /*Here is the code for the taskbar thumb buttons
     FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt
     FIXME:the play button's picture doesn't changed to pause when clicked
     */
 
-    CoInitialize( 0 );
+    CoInitializeEx( NULL, COINIT_MULTITHREADED );
 
-    if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
+    if( S_OK == CoCreateInstance( CLSID_TaskbarList,
                 NULL, CLSCTX_INPROC_SERVER,
-                &IID_ITaskbarList3,
+                IID_ITaskbarList3,
                 (void **)&p_taskbl) )
     {
-        p_taskbl->vt->HrInit(p_taskbl);
+        p_taskbl->HrInit();
 
-        if(himl = ImageList_Create( 20, //cx
-                        20, //cy
-                        ILC_COLOR,//flags
+        if( (himl = ImageList_Create( 16, //cx
+                        16, //cy
+                        ILC_COLOR32,//flags
                         4,//initial nb of images
                         0//nb of images that can be added
-                        ))
+                        ) ) != NULL )
         {
             QPixmap img   = QPixmap(":/win7/prev");
             QPixmap img2  = QPixmap(":/win7/pause");
@@ -104,18 +105,18 @@ void MainInterface::createTaskBarButtons()
             QBitmap mask4 = img4.createMaskFromColor(Qt::transparent);
 
             if(-1 == ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask.toWinHBITMAP()))
-                msg_Err( p_intf, "ImageList_Add failed" );
+                msg_Err( p_intf, "First ImageList_Add failed" );
             if(-1 == ImageList_Add(himl, img2.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask2.toWinHBITMAP()))
-                msg_Err( p_intf, "ImageList_Add failed" );
+                msg_Err( p_intf, "Second ImageList_Add failed" );
             if(-1 == ImageList_Add(himl, img3.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask3.toWinHBITMAP()))
-                msg_Err( p_intf, "ImageList_Add failed" );
+                msg_Err( p_intf, "Third ImageList_Add failed" );
             if(-1 == ImageList_Add(himl, img4.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask4.toWinHBITMAP()))
-                msg_Err( p_intf, "ImageList_Add failed" );
+                msg_Err( p_intf, "Fourth ImageList_Add failed" );
         }
 
         // Define an array of two buttons. These buttons provide images through an
         // image list and also provide tooltips.
-        DWORD dwMask = THB_BITMAP | THB_FLAGS;
+        THUMBBUTTONMASK dwMask = THUMBBUTTONMASK(THB_BITMAP | THB_FLAGS);
 
         THUMBBUTTON thbButtons[3];
         thbButtons[0].dwMask = dwMask;
@@ -133,16 +134,16 @@ void MainInterface::createTaskBarButtons()
         thbButtons[2].iBitmap = 3;
         thbButtons[2].dwFlags = THBF_HIDDEN;
 
-        HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, winId(), himl );
+        HRESULT hr = p_taskbl->ThumbBarSetImageList(winId(), himl );
         if(S_OK != hr)
-            msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr );
+            msg_Err( p_intf, "ThumbBarSetImageList failed with error %08lx", hr );
         else
         {
-            hr = p_taskbl->vt->ThumbBarAddButtons(p_taskbl, winId(), 3, thbButtons);
+            hr = p_taskbl->ThumbBarAddButtons(winId(), 3, thbButtons);
             if(S_OK != hr)
-                msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", hr );
+                msg_Err( p_intf, "ThumbBarAddButtons failed with error %08lx", hr );
         }
-        CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) );
+        CONNECT( THEMIM->getIM(), playingStatusChanged( int ), this, changeThumbbarButtons( int ) );
     }
     else
     {
@@ -156,7 +157,7 @@ bool MainInterface::winEvent ( MSG * msg, long * result )
 {
     if (msg->message == taskbar_wmsg)
     {
-        //We received the taskbarbuttoncreated, now we can really create th buttons
+        //We received the taskbarbuttoncreated, now we can really create the buttons
         createTaskBarButtons();
     }
 
@@ -182,6 +183,17 @@ bool MainInterface::winEvent ( MSG * msg, long * result )
             break;
         case WM_APPCOMMAND:
             cmd = GET_APPCOMMAND_LPARAM(msg->lParam);
+
+            if( p_intf->p_sys->disable_volume_keys &&
+                    (   cmd == APPCOMMAND_VOLUME_DOWN   ||
+                        cmd == APPCOMMAND_VOLUME_UP     ||
+                        cmd == APPCOMMAND_VOLUME_MUTE ) )
+            {
+                break;
+            }
+
+            *result = TRUE;
+
             switch(cmd)
             {
                 case APPCOMMAND_MEDIA_PLAY_PAUSE:
@@ -193,15 +205,20 @@ bool MainInterface::winEvent ( MSG * msg, long * result )
                 case APPCOMMAND_MEDIA_PAUSE:
                     THEMIM->pause();
                     break;
+                case APPCOMMAND_MEDIA_CHANNEL_DOWN:
                 case APPCOMMAND_MEDIA_PREVIOUSTRACK:
                     THEMIM->prev();
                     break;
+                case APPCOMMAND_MEDIA_CHANNEL_UP:
                 case APPCOMMAND_MEDIA_NEXTTRACK:
                     THEMIM->next();
                     break;
                 case APPCOMMAND_MEDIA_STOP:
                     THEMIM->stop();
                     break;
+                case APPCOMMAND_MEDIA_RECORD:
+                    THEAM->record();
+                    break;
                 case APPCOMMAND_VOLUME_DOWN:
                     THEAM->AudioDown();
                     break;
@@ -211,23 +228,37 @@ bool MainInterface::winEvent ( MSG * msg, long * result )
                 case APPCOMMAND_VOLUME_MUTE:
                     THEAM->toggleMuteAudio();
                     break;
+                case APPCOMMAND_MEDIA_FAST_FORWARD:
+                    THEMIM->getIM()->faster();
+                    break;
+                case APPCOMMAND_MEDIA_REWIND:
+                    THEMIM->getIM()->slower();
+                    break;
+                case APPCOMMAND_HELP:
+                    THEDP->mediaInfoDialog();
+                    break;
+                case APPCOMMAND_OPEN:
+                    THEDP->simpleOpenDialog();
+                    break;
                 default:
                      msg_Dbg( p_intf, "unknown APPCOMMAND = %d", cmd);
+                     *result = FALSE;
                      break;
             }
+            if (*result) return true;
             break;
     }
     return false;
 }
-#endif
 
-//moc doesn't know about #ifdef, so we have to build this method for every platform
-void MainInterface::changeThumbbarButtons( int i_status)
+void MainInterface::changeThumbbarButtons( int i_status )
 {
-#ifdef WIN32
+    if( p_taskbl == NULL )
+        return;
+
     // Define an array of three buttons. These buttons provide images through an
     // image list and also provide tooltips.
-    DWORD dwMask = THB_BITMAP | THB_FLAGS;
+    THUMBBUTTONMASK dwMask = THUMBBUTTONMASK(THB_BITMAP | THB_FLAGS);
 
     THUMBBUTTON thbButtons[3];
     //prev
@@ -246,6 +277,7 @@ void MainInterface::changeThumbbarButtons( int i_status)
 
     switch( i_status )
     {
+        case OPENING_S:
         case PLAYING_S:
             {
                 thbButtons[0].dwFlags = THBF_ENABLED;
@@ -254,7 +286,9 @@ void MainInterface::changeThumbbarButtons( int i_status)
                 thbButtons[1].iBitmap = 1;
                 break;
             }
+        case END_S:
         case PAUSE_S:
+        case ERROR_S:
             {
                 thbButtons[0].dwFlags = THBF_ENABLED;
                 thbButtons[1].dwFlags = THBF_ENABLED;
@@ -265,10 +299,7 @@ void MainInterface::changeThumbbarButtons( int i_status)
         default:
             return;
     }
-    HRESULT hr =  p_taskbl->vt->ThumbBarUpdateButtons(p_taskbl, this->winId(), 3, thbButtons);
+    HRESULT hr =  p_taskbl->ThumbBarUpdateButtons(this->winId(), 3, thbButtons);
     if(S_OK != hr)
-        msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08x", hr );
-#endif
+        msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08lx", hr );
 }
-
-