diff --git a/AccountsVC.mm b/AccountsVC.mm index e1ec929f995a72d3a238420d0de81135ce82f0a5..3bbd086d933c1e1070861bfc4e526213f9f180d6 100644 --- a/AccountsVC.mm +++ b/AccountsVC.mm @@ -208,8 +208,8 @@ public: [configPanels insertTabViewItem:generalTabItem atIndex:0]; [configPanels insertTabViewItem:audioTabItem atIndex:1]; [configPanels insertTabViewItem:videoTabItem atIndex:2]; - [configPanels insertTabViewItem:advancedTabItem atIndex:3]; - [configPanels insertTabViewItem:securityTabItem atIndex:4]; + //[configPanels insertTabViewItem:advancedTabItem atIndex:3]; + //[configPanels insertTabViewItem:securityTabItem atIndex:4]; [self.generalVC loadAccount:acc]; [self.audioVC loadAccount:acc]; @@ -248,8 +248,8 @@ public: [configPanels insertTabViewItem:ringTabItem atIndex:0]; [configPanels insertTabViewItem:audioTabItem atIndex:1]; [configPanels insertTabViewItem:videoTabItem atIndex:2]; - [configPanels insertTabViewItem:advancedTabItem atIndex:3]; - [configPanels insertTabViewItem:securityTabItem atIndex:4]; + //[configPanels insertTabViewItem:advancedTabItem atIndex:3]; + //[configPanels insertTabViewItem:securityTabItem atIndex:4]; [self.ringVC loadAccount:acc]; [self.audioVC loadAccount:acc]; diff --git a/CMakeLists.txt b/CMakeLists.txt index d75b45e49486dd672cd37103da81a79b1bcd30b7..aa1af2d9b3b2f74b95f5e46f6cc974c23344ef16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,11 @@ IF(POLICY CMP0022) ENDIF(POLICY CMP0022) SET(PROJ_NAME Ring) -SET(RING_VERSION 1.0) +SET(RING_VERSION "0.1.0") +SET(RING_VERSION_NAME "Samuel de Champlain") +SET(BUNDLE_VERSION "Samuel de Champlain (0.1.0") + +SET(PROJ_COPYRIGHT " © 2015 Savoir-faire Linux \n GPLv3 https://www.gnu.org/copyleft/gpl.html") ADD_DEFINITIONS("-std=c++11") @@ -86,11 +90,7 @@ SET(ringclient_HDRS # Icons -# NOTE: Don't include the path in MACOSX_BUNDLE_ICON_FILE -- this is -# the property added to Info.plist -#SET(MACOSX_BUNDLE_ICON_FILE appicon.icns) - -# And this part tells CMake where to find and install the file itself +# This part tells CMake where to find and install the file itself SET(myApp_ICON ${CMAKE_CURRENT_SOURCE_DIR}/data/appicon.icns) SET_SOURCE_FILES_PROPERTIES(${myApp_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") @@ -106,13 +106,23 @@ ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/audio.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/general.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/video.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_video.png) + SET_SOURCE_FILES_PROPERTIES(${ring_ICONS} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) +SET_SOURCE_FILES_PROPERTIES(Credits.rtf PROPERTIES + MACOSX_PACKAGE_LOCATION Resources) + +# append '.xib' extension before linking xib files in executable +FOREACH(xib ${ringclient_XIBS}) + SET(ringclient_XIBS_FOR_EXECUTABLE ${ringclient_XIBS_FOR_EXECUTABLE} ${xib}.xib) +ENDFOREACH() ADD_EXECUTABLE(${PROJ_NAME} MACOSX_BUNDLE ${ringclient_SRCS} ${ringclient_HDRS} + ${ringclient_XIBS_FOR_EXECUTABLE} ${myApp_ICON} + Credits.rtf ${ring_ICONS}) TARGET_LINK_LIBRARIES( ${PROJ_NAME} @@ -134,10 +144,10 @@ set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication") SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in MACOSX_BUNDLE_GUI_IDENTIFIER "cx.ring" - MACOSX_BUNDLE_SHORT_VERSION_STRING ${RING_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${RING_VERSION_NAME} MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJ_NAME} ${RING_VERSION} Nightly" MACOSX_BUNDLE_BUNDLE_VERSION ${RING_VERSION} - MACOSX_BUNDLE_COPYRIGHT "${PROJ_NAME}" + MACOSX_BUNDLE_COPYRIGHT "${PROJ_COPYRIGHT}" MACOSX_BUNDLE_INFO_STRING "Nightly build of ${PROJ_NAME} ${RING_VERSION} for testing and development" MACOSX_BUNDLE_BUNDLE_NAME ${PROJ_NAME} MACOSX_BUNDLE_ICON_FILE "appicon.icns" @@ -164,3 +174,46 @@ FOREACH(xib ${ringclient_XIBS}) COMMENT "Compiling ${CMAKE_CURRENT_SOURCE_DIR}/${xib}.xib") ENDFOREACH() + +set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${CMAKE_INSTALL_PREFIX}) + +SET(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJ_NAME}.app") + +#-------------------------------------------------------------------------------- +# Install the QtTest application, on Apple, the bundle is at the root of the +# install tree +INSTALL(TARGETS ${PROJ_NAME} BUNDLE DESTINATION . COMPONENT Runtime) + +SET(QT_PLUGINS_DESTDIR ${PROJ_NAME}.app/Contents/Plugins/platforms) +#-------------------------------------------------------------------------------- +# Install needed Qt plugins by copying directories from the qt installation +LIST(APPEND QT_PLUGINS Qt5::QTgaPlugin Qt5::QTiffPlugin Qt5::QCocoaIntegrationPlugin) +FOREACH(plugin ${QT_PLUGINS}) + GET_TARGET_PROPERTY(_loc ${plugin} LOCATION) + INSTALL(FILES ${_loc} DESTINATION ${QT_PLUGINS_DESTDIR} COMPONENT Runtime) +ENDFOREACH() + +# directories to look for dependencies +SET(DIRS ${CMAKE_INSTALL_PREFIX}/lib ${QT_LIB_DIR}) + +INSTALL(CODE " + file(GLOB_RECURSE QTPLUGINS + \"\${CMAKE_INSTALL_PREFIX}/${QT_PLUGINS_DESTDIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\") + include(BundleUtilities) + SET(BU_CHMOD_BUNDLE_ITEMS TRUE) + fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\") + " COMPONENT Runtime) + +#================================ +# Packaging +#================================ +SET( CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJ_NAME}) +SET( CPACK_PACKAGE_NAME ${PROJ_NAME} ) +SET( CPACK_PACKAGE_CONTACT "Alexandre Lision") +SET( CPACK_PACKAGE_VENDOR "Savoir-faire Linux") +SET( CPACK_PACKAGE_VERSION_MAJOR ${PROG_MAJOR_VERSION}) +SET( CPACK_PACKAGE_VERSION_MINOR ${PROG_MINOR_VERSION}) +SET( CPACK_PACKAGE_VERSION_PATCH ${PROG_PATCH_VERSION}) +SET(CPACK_BINARY_DRAGNDROP ON) +SET( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}") +INCLUDE(CPack) diff --git a/ConversationsViewController.mm b/ConversationsViewController.mm index f514d76effe82fd4d2b9093e1e2043dadb544898..4b7ce22d28e2305a91157b226c7a281b52db9238 100644 --- a/ConversationsViewController.mm +++ b/ConversationsViewController.mm @@ -70,8 +70,6 @@ QObject::connect(CallModel::instance(), &QAbstractItemModel::dataChanged, [=](const QModelIndex &topLeft, const QModelIndex &bottomRight) { - NSLog(@"data changed for call tree %d, %d", topLeft.row(), bottomRight.row()); - [conversationsView reloadDataForRowIndexes: [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(topLeft.row(), bottomRight.row() + 1)] columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, conversationsView.tableColumns.count)]]; diff --git a/Credits.rtf b/Credits.rtf new file mode 100644 index 0000000000000000000000000000000000000000..a91e42a9e81b8d563dbd198f9048377110789683 --- /dev/null +++ b/Credits.rtf @@ -0,0 +1,25 @@ +{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf210 +{\fonttbl\f0\fswiss\fcharset0 Helvetica;} +{\colortbl;\red255\green255\blue255;} +\margl1440\margr1440\vieww9000\viewh8400\viewkind0 +\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\qc + +\f0\i\fs24 \cf0 \ +\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\qc +{\field{\*\fldinst{HYPERLINK "http://ring.cx/"}}{\fldrslt \cf0 http://ring.cx/}}\ +\ +\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\qc + +\i0\b \cf0 Authors +\i\b0 \ +Adrien B\'e9raud\ +Alexandre Lision\ +\'c9dric Ladent-Milaret\ +Eloi Bail\ +Emmanuel Lepage-Vall\'e9e\ +Guillaume Roguez\ +Marianne Forget\ +Stepan Salenikovich\ +\ +Based on SFLphone's project\ +} diff --git a/CurrentCallVC.mm b/CurrentCallVC.mm index 337aa23d2aa7c0f56ec8c9ed179690c0b8dfabba..ba70063e7458d550de51879ca30365106ad1a26c 100644 --- a/CurrentCallVC.mm +++ b/CurrentCallVC.mm @@ -206,7 +206,6 @@ QObject::connect(CallModel::instance()->selectionModel(), &QItemSelectionModel::currentChanged, [=](const QModelIndex ¤t, const QModelIndex &previous) { - NSLog(@"selection changed!"); if(!current.isValid()) { [self animateOut]; return; @@ -219,14 +218,12 @@ QObject::connect(CallModel::instance(), &QAbstractItemModel::dataChanged, [=](const QModelIndex &topLeft, const QModelIndex &bottomRight) { - NSLog(@"data changed!"); [self updateCall]; }); QObject::connect(CallModel::instance()->userActionModel(), &QAbstractItemModel::dataChanged, [=](const QModelIndex &topLeft, const QModelIndex &bottomRight) { - NSLog(@"useraction changed"); const int first(topLeft.row()),last(bottomRight.row()); for(int i = first; i <= last;i++) { [self updateActionAtIndex:i]; @@ -236,7 +233,6 @@ QObject::connect(CallModel::instance(), &CallModel::callStateChanged, [self](Call* c, Call::State state) { - NSLog(@"callStateChanged"); [self updateCall]; }); } @@ -255,7 +251,6 @@ if(call->videoRenderer()) { - NSLog(@"GONNA CONNECT TO FRAMES"); [self connectVideoRenderer:call->videoRenderer()]; } diff --git a/MainMenu.xib b/MainMenu.xib index 1ad9425954c0a0175dccb83f2264e5005a095186..a7263c76a355510eea99e2d0f5a0e7e3f4359977 100644 --- a/MainMenu.xib +++ b/MainMenu.xib @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00"> <data> - <int key="IBDocument.SystemTarget">1090</int> + <int key="IBDocument.SystemTarget">101000</int> <string key="IBDocument.SystemVersion">13F34</string> <string key="IBDocument.InterfaceBuilderVersion">6254</string> <string key="IBDocument.AppKitVersion">1265.21</string> diff --git a/RingWindowController.mm b/RingWindowController.mm index f7a08c4272bf6bed4963a92f30dacd10ccd28b95..f46bf664220b7260874cdedbd964a3c402d0eaf7 100644 --- a/RingWindowController.mm +++ b/RingWindowController.mm @@ -201,7 +201,17 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier"; - (IBAction)placeCall:(id)sender { Call* c = CallModel::instance()->dialingCall(); - c->setDialNumber(QString::fromNSString([callField stringValue])); + + // check for a valid ring hash + NSCharacterSet *hexSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789abcdefABCDEF"]; + BOOL valid = [[[callField stringValue] stringByTrimmingCharactersInSet:hexSet] isEqualToString:@""]; + + if(valid && callField.stringValue.length == 40) { + c->setDialNumber(QString::fromNSString([NSString stringWithFormat:@"ring:%@",[callField stringValue]])); + } else { + c->setDialNumber(QString::fromNSString([callField stringValue])); + } + c << Call::Action::ACCEPT; } @@ -237,7 +247,6 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier"; - (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doCommandBySelector:(SEL)commandSelector { - NSLog(@"Selector method is (%@)", NSStringFromSelector( commandSelector ) ); if (commandSelector == @selector(insertNewline:)) { if([[callField stringValue] isNotEqualTo:@""]) { [self placeCall:nil]; diff --git a/VideoPrefs.xib b/VideoPrefs.xib index 2341d852b3832e47de163e9dce0b75a5adf31274..b79be51f2f31c99839b0eb23eba442ce65a8e35c 100644 --- a/VideoPrefs.xib +++ b/VideoPrefs.xib @@ -1,57 +1,57 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1510" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <dependencies> - <deployment identifier="macosx"/> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/> </dependencies> <objects> <customObject id="-2" userLabel="File's Owner" customClass="VideoPrefsVC"> <connections> + <outlet property="previewView" destination="qAJ-w8-a6Q" id="uSq-tE-heV"/> + <outlet property="ratesList" destination="e3h-qA-wZ5" id="EPS-08-l6m"/> + <outlet property="sizesList" destination="Aec-P9-KNS" id="nYI-YP-fpQ"/> + <outlet property="videoDevicesList" destination="5L8-b6-N3k" id="ZsJ-sc-pYZ"/> <outlet property="view" destination="c22-O7-iKe" id="EfM-Op-S9T"/> </connections> </customObject> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/> <customView id="c22-O7-iKe"> - <rect key="frame" x="0.0" y="0.0" width="683" height="609"/> + <rect key="frame" x="0.0" y="0.0" width="541" height="440"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <subviews> - <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DTo-76-fYS"> - <rect key="frame" x="71" y="369" width="53" height="17"/> - <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Camera" id="YCM-JC-jin"> - <font key="font" metaFont="system"/> + <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FRq-3r-0WL"> + <rect key="frame" x="16" y="406" width="66" height="17"/> + <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Selection" id="VqO-Gm-CbB"> + <font key="font" metaFont="systemBold"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> </textField> - <customView wantsLayer="YES" canDrawConcurrently="YES" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qAJ-w8-a6Q" userLabel="Preview"> - <rect key="frame" x="106" y="104" width="470" height="230"/> - </customView> - <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Upa-iB-KCC"> - <rect key="frame" x="124" y="358" width="122" height="32"/> - <buttonCell key="cell" type="push" title="Start preview" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="bX7-eQ-8Ea"> - <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> - <font key="font" metaFont="system"/> - </buttonCell> - </button> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VWx-4c-7aF"> - <rect key="frame" x="116" y="550" width="50" height="17"/> + <rect key="frame" x="61" y="381" width="50" height="17"/> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Device:" id="170-NP-CSP"> <font key="font" metaFont="system"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> </textField> - <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Y00-jB-8Ux"> - <rect key="frame" x="106" y="505" width="60" height="17"/> - <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Channel:" id="IJ5-l7-dN7"> - <font key="font" metaFont="system"/> - <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> - </textFieldCell> - </textField> + <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5L8-b6-N3k" userLabel="Devices"> + <rect key="frame" x="115" y="375" width="189" height="26"/> + <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="6Vf-hb-26C"> + <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> + <font key="font" metaFont="menu"/> + <menu key="menu" title="devices" id="zJ9-1a-cpr"> + <connections> + <outlet property="delegate" destination="-2" id="mF2-Zc-wNP"/> + </connections> + </menu> + </popUpButtonCell> + <connections> + <action selector="chooseDevice:" target="-2" id="JjJ-Ul-8VM"/> + </connections> + </popUpButton> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cDr-8B-RiJ"> - <rect key="frame" x="132" y="460" width="34" height="17"/> + <rect key="frame" x="77" y="349" width="34" height="17"/> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Size:" id="4bq-ls-mCp"> <font key="font" metaFont="system"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> @@ -59,87 +59,78 @@ </textFieldCell> </textField> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="60X-MX-gun"> - <rect key="frame" x="130" y="413" width="36" height="17"/> + <rect key="frame" x="75" y="315" width="36" height="17"/> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Rate:" id="5Im-df-jdd"> <font key="font" metaFont="system"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> </textField> - <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5L8-b6-N3k"> - <rect key="frame" x="170" y="544" width="189" height="26"/> - <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="PLA-b4-Y2Z" id="6Vf-hb-26C"> - <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> - <font key="font" metaFont="menu"/> - <menu key="menu" id="zJ9-1a-cpr"> - <items> - <menuItem title="Item 1" state="on" id="PLA-b4-Y2Z"/> - <menuItem title="Item 2" id="AqV-S1-JqC"/> - <menuItem title="Item 3" id="CkU-QC-dVQ"/> - </items> - </menu> - </popUpButtonCell> - </popUpButton> - <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="weW-fX-GwJ"> - <rect key="frame" x="170" y="500" width="189" height="26"/> - <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="jp0-zC-w4a" id="TPq-dw-EwN"> + <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Aec-P9-KNS" userLabel="Sizes"> + <rect key="frame" x="115" y="344" width="189" height="26"/> + <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="6ly-dX-MT4"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="menu"/> - <menu key="menu" id="9bI-4N-gfG"> - <items> - <menuItem title="Item 1" state="on" id="jp0-zC-w4a"/> - <menuItem title="Item 2" id="WQz-Y3-iY1"/> - <menuItem title="Item 3" id="gky-36-FHp"/> - </items> + <menu key="menu" title="sizes" id="ykd-50-las"> + <connections> + <outlet property="delegate" destination="-2" id="5cI-wH-0AT"/> + </connections> </menu> </popUpButtonCell> + <connections> + <action selector="chooseSize:" target="-2" id="qra-Ci-Om8"/> + </connections> </popUpButton> - <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Aec-P9-KNS"> - <rect key="frame" x="170" y="455" width="189" height="26"/> - <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="n8r-LT-t3t" id="6ly-dX-MT4"> + <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="e3h-qA-wZ5" userLabel="Rates"> + <rect key="frame" x="115" y="310" width="189" height="26"/> + <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="pDt-c4-Fhs"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="menu"/> - <menu key="menu" id="ykd-50-las"> - <items> - <menuItem title="Item 1" state="on" id="n8r-LT-t3t"/> - <menuItem title="Item 2" id="jUy-xn-1kn"/> - <menuItem title="Item 3" id="obd-cQ-mz8"/> - </items> + <menu key="menu" title="rates" id="aKL-76-vSP"> + <connections> + <outlet property="delegate" destination="-2" id="5Gu-bg-y3C"/> + </connections> </menu> </popUpButtonCell> + <connections> + <action selector="chooseRate:" target="-2" id="nye-jT-0NU"/> + </connections> </popUpButton> - <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="e3h-qA-wZ5"> - <rect key="frame" x="170" y="408" width="189" height="26"/> - <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="GFu-rO-tr4" id="pDt-c4-Fhs"> - <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> - <font key="font" metaFont="menu"/> - <menu key="menu" id="aKL-76-vSP"> - <items> - <menuItem title="Item 1" state="on" id="GFu-rO-tr4"/> - <menuItem title="Item 2" id="aF9-ac-MF4"/> - <menuItem title="Item 3" id="FoN-dd-DcF"/> - </items> - </menu> - </popUpButtonCell> - </popUpButton> - <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="WNL-Ul-Jbr"> - <rect key="frame" x="526" y="342" width="52" height="17"/> - <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Preview" id="Lrq-tD-NYF"> - <font key="font" metaFont="system"/> - <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> - </textFieldCell> - </textField> - <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FRq-3r-0WL"> - <rect key="frame" x="71" y="575" width="61" height="17"/> - <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Selection" id="VqO-Gm-CbB"> - <font key="font" metaFont="system"/> + <customView wantsLayer="YES" canDrawConcurrently="YES" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qAJ-w8-a6Q" userLabel="Preview"> + <rect key="frame" x="32" y="20" width="470" height="230"/> + <constraints> + <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="470" id="WVf-8f-i99"/> + <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="230" id="udn-lE-Jd4"/> + </constraints> + </customView> + <button verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qHu-4n-CTV"> + <rect key="frame" x="32" y="257" width="122" height="19"/> + <buttonCell key="cell" type="roundRect" title="Test preview" bezelStyle="roundedRect" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="IGT-OE-qJj"> + <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/> + <font key="font" metaFont="cellTitle"/> + </buttonCell> + <connections> + <action selector="togglePreview:" target="-2" id="Z1R-EV-1Na"/> + </connections> + </button> + <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DTo-76-fYS"> + <rect key="frame" x="18" y="284" width="53" height="17"/> + <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Camera" id="YCM-JC-jin"> + <font key="font" metaFont="systemBold"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> </textField> </subviews> - <point key="canvasLocation" x="428.5" y="407.5"/> + <constraints> + <constraint firstAttribute="trailing" secondItem="qAJ-w8-a6Q" secondAttribute="trailing" constant="39" id="EIm-N6-noX"/> + <constraint firstItem="qHu-4n-CTV" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="32" id="HL9-hR-8AT"/> + <constraint firstAttribute="bottom" secondItem="qAJ-w8-a6Q" secondAttribute="bottom" constant="20" id="Sv6-Ls-4tS"/> + <constraint firstItem="qAJ-w8-a6Q" firstAttribute="top" secondItem="qHu-4n-CTV" secondAttribute="bottom" constant="8" id="cQh-RN-ARc"/> + <constraint firstItem="qAJ-w8-a6Q" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="32" id="gt3-zq-vOi"/> + <constraint firstItem="qAJ-w8-a6Q" firstAttribute="leading" secondItem="qHu-4n-CTV" secondAttribute="leading" id="oaw-xG-gPo"/> + </constraints> + <point key="canvasLocation" x="372.5" y="257"/> </customView> </objects> </document> diff --git a/VideoPrefsVC.h b/VideoPrefsVC.h index c9f8bac46c6c8ae43b9413ac0fb865308cf8b6b3..8a85304f5dae0d38060121447ad5fbdaf87dc1b0 100644 --- a/VideoPrefsVC.h +++ b/VideoPrefsVC.h @@ -1,13 +1,41 @@ -// -// VideoPrefsVC.h -// Ring -// -// Created by Alexandre Lision on 2015-02-20. -// -// +/* + * Copyright (C) 2004-2015 Savoir-Faire Linux Inc. + * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ +#ifndef RING_VIDEOPREFSVC_H +#define RING_VIDEOPREFSVC_H #import <Cocoa/Cocoa.h> -@interface VideoPrefsVC : NSViewController +@interface VideoPrefsVC : NSViewController <NSMenuDelegate> { + +} @end + +#endif // RING_VIDEOPREFSVC_H diff --git a/VideoPrefsVC.mm b/VideoPrefsVC.mm index 8e68436dbc89f077023f04b70da0943451eb7eb3..79a9353594f2e0a49b0d47100ba2516c8f63f1dc 100644 --- a/VideoPrefsVC.mm +++ b/VideoPrefsVC.mm @@ -29,15 +29,211 @@ */ #import "VideoPrefsVC.h" +#import <QuartzCore/QuartzCore.h> + +#import <QItemSelectionModel> +#import <QAbstractProxyModel> + +#import <video/configurationproxy.h> +#import <video/sourcemodel.h> +#import <video/previewmanager.h> +#import <video/renderer.h> +#import <video/device.h> +#import <video/devicemodel.h> + @interface VideoPrefsVC () +@property (assign) IBOutlet NSView *previewView; +@property (assign) IBOutlet NSPopUpButton *videoDevicesList; +@property (assign) IBOutlet NSPopUpButton *sizesList; +@property (assign) IBOutlet NSPopUpButton *ratesList; + @end @implementation VideoPrefsVC +@synthesize previewView; +@synthesize videoDevicesList; +@synthesize sizesList; +@synthesize ratesList; + +QMetaObject::Connection frameUpdated; +QMetaObject::Connection previewStarted; +QMetaObject::Connection previewStopped; + +- (void)loadView +{ + [super loadView]; + + Video::ConfigurationProxy::deviceModel()->rowCount(); + Video::ConfigurationProxy::resolutionModel()->rowCount(); + Video::ConfigurationProxy::rateModel()->rowCount(); + + QModelIndex qDeviceIdx = Video::ConfigurationProxy::deviceSelectionModel()->currentIndex(); + qDeviceIdx = Video::ConfigurationProxy::deviceSelectionModel()->currentIndex(); + + [videoDevicesList addItemWithTitle:Video::ConfigurationProxy::deviceModel()->data(qDeviceIdx, Qt::DisplayRole).toString().toNSString()]; + + QModelIndex qSizeIdx = Video::ConfigurationProxy::resolutionSelectionModel()->currentIndex(); + [sizesList addItemWithTitle:Video::ConfigurationProxy::resolutionModel()->data(qSizeIdx, Qt::DisplayRole).toString().toNSString()]; + + if(qobject_cast<QAbstractProxyModel*>(Video::ConfigurationProxy::resolutionModel())) { + QObject::connect(qobject_cast<QAbstractProxyModel*>(Video::ConfigurationProxy::resolutionModel()), + &QAbstractProxyModel::modelReset, + [=]() { + NSLog(@"resolution Source model changed!!!"); + }); + + } + + QModelIndex qRate = Video::ConfigurationProxy::rateSelectionModel()->currentIndex(); + [ratesList addItemWithTitle:Video::ConfigurationProxy::rateModel()->data(qDeviceIdx, Qt::DisplayRole).toString().toNSString()]; + + if(qobject_cast<QAbstractProxyModel*>(Video::ConfigurationProxy::rateModel())) { + QObject::connect(qobject_cast<QAbstractProxyModel*>(Video::ConfigurationProxy::rateModel()), + &QAbstractProxyModel::modelReset, + [=]() { + NSLog(@"rates Source model changed!!!"); + }); + + } + + + [previewView setWantsLayer:YES]; + [previewView setLayer:[CALayer layer]]; + [previewView.layer setBackgroundColor:[NSColor blackColor].CGColor]; + [previewView.layer setContentsGravity:kCAGravityResizeAspect]; + [previewView.layer setFrame:previewView.frame]; + [previewView.layer setBounds:previewView.frame]; + + [self connectPreviewSignals]; +} + +- (IBAction)chooseDevice:(id)sender { + int index = [sender indexOfSelectedItem]; + QModelIndex qIdx = Video::ConfigurationProxy::deviceModel()->index(index, 0); + Video::ConfigurationProxy::deviceSelectionModel()->setCurrentIndex(qIdx, QItemSelectionModel::ClearAndSelect); +} + +- (IBAction)chooseSize:(id)sender { + int index = [sender indexOfSelectedItem]; + QModelIndex qIdx = Video::ConfigurationProxy::resolutionModel()->index(index, 0); + Video::ConfigurationProxy::resolutionSelectionModel()->setCurrentIndex(qIdx, QItemSelectionModel::ClearAndSelect); +} + +- (IBAction)chooseRate:(id)sender { + int index = [sender indexOfSelectedItem]; + QModelIndex qIdx = Video::ConfigurationProxy::rateModel()->index(index, 0); + Video::ConfigurationProxy::rateSelectionModel()->setCurrentIndex(qIdx, QItemSelectionModel::ClearAndSelect); +} + +- (void) connectPreviewSignals +{ + QObject::disconnect(frameUpdated); + QObject::disconnect(previewStopped); + QObject::disconnect(previewStarted); + previewStarted = QObject::connect(Video::PreviewManager::instance(), + &Video::PreviewManager::previewStarted, + [=](Video::Renderer* renderer) { + NSLog(@"Preview started"); + QObject::disconnect(frameUpdated); + frameUpdated = QObject::connect(renderer, + &Video::Renderer::frameUpdated, + [=]() { + [self renderer:Video::PreviewManager::instance()->previewRenderer() renderFrameForView:previewView]; + }); + }); + + previewStopped = QObject::connect(Video::PreviewManager::instance(), + &Video::PreviewManager::previewStopped, + [=](Video::Renderer* renderer) { + NSLog(@"Preview stopped"); + QObject::disconnect(frameUpdated); + [previewView.layer setContents:nil]; + }); + + frameUpdated = QObject::connect(Video::PreviewManager::instance()->previewRenderer(), + &Video::Renderer::frameUpdated, + [=]() { + [self renderer:Video::PreviewManager::instance()->previewRenderer() + renderFrameForView:previewView]; + }); +} + +-(void) renderer: (Video::Renderer*)renderer renderFrameForView:(NSView*) view +{ + const QByteArray& data = renderer->currentFrame(); + QSize res = renderer->size(); + + auto buf = reinterpret_cast<const unsigned char*>(data.data()); + + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGContextRef newContext = CGBitmapContextCreate((void *)buf, + res.width(), + res.height(), + 8, + 4*res.width(), + colorSpace, + kCGImageAlphaPremultipliedLast); + + + CGImageRef newImage = CGBitmapContextCreateImage(newContext); + + /*We release some components*/ + CGContextRelease(newContext); + CGColorSpaceRelease(colorSpace); + + [CATransaction begin]; + view.layer.contents = (__bridge id)newImage; + [CATransaction commit]; + + CFRelease(newImage); +} + +- (IBAction)togglePreview:(id)sender { + if([sender state] == NSOnState) + Video::PreviewManager::instance()->startPreview(); + else + Video::PreviewManager::instance()->stopPreview(); +} + +- (void)viewWillDisappear +{ + Video::PreviewManager::instance()->stopPreview(); +} + +#pragma mark - NSMenuDelegate methods + +- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel +{ + QModelIndex qIdx; + if([menu.title isEqualToString:@"devices"]) { + + qIdx = Video::ConfigurationProxy::deviceModel()->index(index, 0); + [item setTitle:Video::ConfigurationProxy::deviceModel()->data(qIdx, Qt::DisplayRole).toString().toNSString()]; + + } else if([menu.title isEqualToString:@"sizes"]) { + + qIdx = Video::ConfigurationProxy::resolutionModel()->index(index, 0); + [item setTitle:Video::ConfigurationProxy::resolutionModel()->data(qIdx, Qt::DisplayRole).toString().toNSString()]; + + } else if([menu.title isEqualToString:@"rates"]) { + + qIdx = Video::ConfigurationProxy::rateModel()->index(index, 0); + [item setTitle:Video::ConfigurationProxy::rateModel()->data(qIdx, Qt::DisplayRole).toString().toNSString()]; + + } + return YES; +} -- (void)viewDidLoad { - [super viewDidLoad]; - // Do view setup here. +- (NSInteger)numberOfItemsInMenu:(NSMenu *)menu +{ + if([menu.title isEqualToString:@"devices"]) { + return Video::ConfigurationProxy::deviceModel()->rowCount(); + } else if([menu.title isEqualToString:@"sizes"]) { + return Video::ConfigurationProxy::resolutionModel()->rowCount(); + } else if([menu.title isEqualToString:@"rates"]) { + return Video::ConfigurationProxy::rateModel()->rowCount(); + } } @end diff --git a/main.mm b/main.mm index b97e6126712ce671b683016d23a5a5b7ee5b635b..c1d86761437e639b1af1d57afc352a0f592f307d 100644 --- a/main.mm +++ b/main.mm @@ -29,9 +29,17 @@ */ #import <AppKit/NSApplication.h> // NSApplicationMain #import <qapplication.h> +#import <QDebug> +#import <QDir> int main(int argc, const char *argv[]) { + QDir dir(QString::fromUtf8(argv[0])); + dir.cdUp(); + dir.cdUp(); + dir.cd("Plugins"); + QCoreApplication::addLibraryPath(dir.absolutePath()); + qDebug() << "" << QCoreApplication::libraryPaths(); //Qt event loop will override native event loop QApplication* app = new QApplication(argc, const_cast<char**>(argv)); app->setAttribute(Qt::AA_MacPluginApplication);