Results 1 to 10 of 10

Thread: QMAKE_INFO_PLIST undocumented function

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QMAKE_INFO_PLIST undocumented function

    To open documents on window i can catch on main arguments to open file.. this is ok...
    And to set other extension to the new application i use the installer and if i click the document is open ok. super!

    Now on mac after qt4 to drag document to the dock or open by normal click on finder the operation is more complicated....
    On qt3 i found a sample hot to drag file on dock.. this link
    http://doc.trolltech.com/qq/qq12-mac-events.html this method not run on qt4

    on mac to associate my new doc type *.sdat i found on google this way:

    on pro file i insert an other info.plist xml file to bring icon to new file type and to open application on finder by click the file.... this run ... the app start but a empty file is here.. and main arguments not work!

    to find this Hack .. i open http://www.google.com/codesearch and i search QMAKE_INFO_PLIST && macEventFilter ... assistant not say nothing about this ...

    QMAKE_INFO_PLIST = resource/mac_qedit.plist

    <plist version="1.0">
    <dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleDocumentTypes</key>
    <array>
    <dict>
    <key>CFBundleTypeExtensions</key>
    <array>
    <string>sdat</string>
    </array>
    <key>CFBundleTypeIconFile</key>
    <string>mac_QeditIcon.icns</string>
    <key>CFBundleTypeMIMETypes</key>
    <array>
    <string>text/plain</string>
    <string>text/plain utf-8</string>
    </array>
    <key>CFBundleTypeName</key>
    <string>Text File</string>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>LSIsAppleDefaultForType</key>
    <true/>
    </dict>
    </array>

    After i search / grep the qt4 source QMAKE_INFO_PLIST and i find the designer... and his associate ui file ok... now how designer open this ui file by click on finder or drag to dock from finder?

    I found a designer server... , client ecc.. so much args...

    Qt Code:
    1. /*
    2. header...
    3. QDesigner::QDesigner(int &argc, char **argv)
    4.   : QApplication(argc, argv),
    5.   m_server(0),
    6.   m_client(0),
    7.   m_workbench(0), suppressNewFormShow(false)
    8. */
    9.  
    10.  
    11. QDesigner::QDesigner(int &argc, char **argv)
    12. : QApplication(argc, argv),
    13. m_server(0),
    14. m_client(0),
    15. m_workbench(0), suppressNewFormShow(false)
    16. {
    17. setOrganizationName(QLatin1String("Trolltech"));
    18. setApplicationName(QLatin1String("Designer"));
    19. QDesignerComponents::initializeResources();
    20.  
    21. #ifndef Q_WS_MAC
    22. setWindowIcon(QIcon(QLatin1String(":/trolltech/designer/images/designer.png")));
    23. #endif
    24.  
    25. initialize();
    26. }
    To copy to clipboard, switch view to plain text mode 


    But how designer open this ui file on MAC ? undocumented function?

    Must i write a server and a client to open a new document type?


    Or is here the event to open the file! and not QCoreApplication::.arguments();

    Qt Code:
    1. bool QDesigner::event(QEvent *ev)
    2. {
    3. bool eaten;
    4. switch (ev->type()) {
    5. case QEvent::FileOpen:
    6. // set it true first since, if it's a Qt 3 form, the messagebox from convert will fire the timer.
    7. suppressNewFormShow = true;
    8. if (!m_workbench->readInForm(static_cast<QFileOpenEvent *>(ev)->file()))
    9. suppressNewFormShow = false;
    10. eaten = true;
    11. break;
    12. case QEvent::Close: {
    13. QCloseEvent *closeEvent = static_cast<QCloseEvent *>(ev);
    14. closeEvent->setAccepted(m_workbench->handleClose());
    15. if (closeEvent->isAccepted()) {
    16. // We're going down, make sure that we don't get our settings saved twice.
    17. if (m_mainWindow)
    18. m_mainWindow->setSaveSettingsOnClose(false);
    19. eaten = QApplication::event(ev);
    20. }
    21. eaten = true;
    22. break;
    23. }
    24. default:
    25. eaten = QApplication::event(ev);
    26. break;
    27. }
    28. return eaten;
    29. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by patrik08; 3rd June 2007 at 11:09.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMAKE_INFO_PLIST undocumented function

    I'm not sure if I understand correctly, but on Mac when you open a file from Finder ( or drag it to the app icon in the dock ), your app will receive a mac event ( no details, sorry ).
    So you must reimplement macEvent and catch this event. In this event there are passed the action type( open ) and the file(s) name(s).

    So it will not be a Qt event, but a mac event.

    More info on developer.apple.com, probably in the window manager reference.

    Regards

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMAKE_INFO_PLIST undocumented function

    Oh, I have found it:
    http://developer.apple.com/documenta...CH206-BEJBDEGI

    See the open documents section, Listing 5-5.

    Regards

  4. #4
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMAKE_INFO_PLIST undocumented function

    Quote Originally Posted by marcel View Post
    Oh, I have found it:
    http://developer.apple.com/documenta...CH206-BEJBDEGI

    See the open documents section, Listing 5-5.

    Regards
    Why qt4.2 designer not use Apple Events , ui file go open and run....
    to implement Apple Event on pro file must append LIBS += -framework Carbon
    and designer not have it...

    I like to open only file *.sdat on my app and the info.plist not have difined method open only mime apps ant tipe extension....

    i suppode designer use an event like
    http://doc.trolltech.com/4.2/qapplic...macEventFilter or event QEvent::FileOpen...

    I understand only a smal piece of Cocoa objektiv C but Carbon it is an other pair of sleeves

  5. #5
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMAKE_INFO_PLIST undocumented function

    Quote Originally Posted by marcel View Post
    So it will not be a Qt event, but a mac event.
    AFAIK Qt Designer uses QFileOpenEvent which is clearly said to be related with Finder actions (or whatever you call that... I'm not familiar with Mac...)
    Current Qt projects : QCodeEdit, RotiDeCode

  6. #6
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMAKE_INFO_PLIST undocumented function

    I found its on qt4 no apple event are needet is comming all on normal event
    on subclass QApplication && QCoreApplication no carbon ecc...

    i write a LogEvents( const QString xml ) to see wathts of event go.... if i drag document to dock on graphics gui args on main is no needet i can catch all file on event window / mac / maybe linux is same....

    all event from http://doc.trolltech.com/4.2/qevent.html#Type-enum can grab normal cross build.... QT4 is a Rolls-Royce Framework


    Qt Code:
    1. #ifndef OS_APPLICATION_H
    2. #define OS_APPLICATION_H
    3.  
    4. #include "main.h"
    5.  
    6. #include <QApplication>
    7. #include <QtGui>
    8. #include <QMessageBox>
    9. #ifdef Q_WS_MAC
    10. #include <Carbon/Carbon.h>
    11. #endif
    12.  
    13. /* on main Q_INIT_RESOURCE(osApplication); same name osApplication.qrc */
    14. /* to access info.plist live write append .... each extension wo app open go in ...*/
    15.  
    16. #define osApplication \
    17. (static_cast<OS_application*>(QCoreApplication::instance()))
    18.  
    19. class OS_application : public QApplication
    20. {
    21. Q_OBJECT
    22. //
    23. public:
    24. OS_application( int &argc, char **argv )
    25. : QApplication(argc, argv)
    26. {
    27. /* QSetting setup */
    28. QCoreApplication::setOrganizationName(_ORGANIZATION_NAME_);
    29. QCoreApplication::setOrganizationDomain(_PROGRAM_NAME_DOMAINE_);
    30. QCoreApplication::setApplicationName(_PROGRAM_NAME_);
    31. }
    32. protected:
    33. bool event(QEvent *ev)
    34. {
    35. LogEvents( QString("normal event first ev->type() = %1").arg(ev->type()));
    36. /* http://doc.trolltech.com/4.2/qevent.html#Type-enum 170 event resize context ecc...*/
    37.  
    38. bool eaten;
    39. switch (ev->type()) {
    40. case QEvent::FileOpen:
    41. /* 126 */
    42. LogEvents( QString("QEvent::FileOpen nr. %1 catch file \"%2\" ").arg(QEvent::FileOpen).arg(static_cast<QFileOpenEvent *>(ev)->file()));
    43. eaten = true;
    44. break;
    45. case QEvent::Close: {
    46. QCloseEvent *closeEvent = static_cast<QCloseEvent *>(ev);
    47. eaten = true;
    48. break;
    49. }
    50. default:
    51. eaten = QApplication::event(ev);
    52. break;
    53. }
    54. return eaten;
    55. }
    56. #ifdef Q_WS_MAC
    57. bool macEventFilter( EventHandlerCallRef, EventRef inEvent )
    58. {
    59. int etype = GetEventKind(inEvent);
    60. LogEvents( QString("mac event first GetEventKind(inEvent) = %1").arg(etype));
    61. return false; /* default if not use */
    62. }
    63. #endif
    64. private:
    65. /* leave this outside debug by open application write 135 line of events */
    66. bool LogEvents( const QString xml )
    67. {
    68. const QString fullFileName = QDir::homePath() + "/_todaylog/event.log";
    69. if (fullFileName.contains("/", Qt::CaseInsensitive)) {
    70. QString ultimacartellaaperta = fullFileName.left(fullFileName.lastIndexOf("/"))+"/";
    71. QDir dira(ultimacartellaaperta);
    72. if ( dira.mkpath(ultimacartellaaperta) ) { } else {
    73. return false;
    74. }
    75. }
    76.  
    77.  
    78. QString data = xml+"\n";
    79. QFile f( fullFileName );
    80. if ( f.open( QFile::Append | QFile::Text ) )
    81. {
    82. QTextStream sw( &f );
    83. sw << data;
    84. f.close();
    85. return true;
    86. }
    87. return false;
    88.  
    89. }
    90.  
    91.  
    92.  
    93. };
    94.  
    95.  
    96.  
    97.  
    98. /*
    99.  
    100. bool eaten;
    101. UInt32 eclass = GetEventClass(inEvent);
    102. int etype = GetEventKind(inEvent);
    103.   ////////QMessageBox::warning(0,QString(_PROGRAM_NAME_),QString("macEventFilter int %1").arg(etype));
    104.  
    105.  
    106. if(etype == kEventAppleEvent) {
    107. /////////allargeMacSlidewidget ! lateral thing....;
    108.   eaten = false;
    109. }
    110. return false;
    111.  
    112.  
    113. */
    114.  
    115. //
    116. #endif // OS_APPLICATION_H
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMAKE_INFO_PLIST undocumented function

    Quote Originally Posted by fullmetalcoder View Post
    AFAIK Qt Designer uses QFileOpenEvent which is clearly said to be related with Finder actions (or whatever you call that... I'm not familiar with Mac...)
    Ok , i found it QEvent::FileOpen id 116 ,

    you must not know or are familiar with Mac .. qt4 handle all os one same way ;
    incredible .
    on subclass QApplication you find event which you do not know that they exist..

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMAKE_INFO_PLIST undocumented function

    Just thought you might want to take a look:

    http://doc.trolltech.com/qq/qq18-mac...html#newevents
    http://doc.trolltech.com/qq/qq12-mac-events.html

    Please read especially the one from QQ #12.

  9. #9
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMAKE_INFO_PLIST undocumented function

    Quote Originally Posted by wysota View Post
    Just thought you might want to take a look:

    http://doc.trolltech.com/qq/qq18-mac...html#newevents
    http://doc.trolltech.com/qq/qq12-mac-events.html

    Please read especially the one from QQ #12.

    The QQ #12 is only to QT3 ... Issue 12 · Q4 2004 or QT4 was born on 2004?

    I have write on wiki you see its? http://wiki.qtcentre.org/index.php?t...Mac_OSX_Finder

    The method QApplication::event( QEvent *ev ) QEvent::FileOpen 116 open file on mac & window .. maybe Linux ... so on int main(int argc, char *argv[]) GUI version is not needed to grab file from argv .... only on console apps.... or QCoreApplication:event()..

    I digested all http://www.google.com/codesearch && http://sourceforge.net/index.php QT4 filter code ; and i never found Apple Event only on QT3

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMAKE_INFO_PLIST undocumented function

    Quote Originally Posted by patrik08 View Post
    The QQ #12 is only to QT3 ... Issue 12 · Q4 2004 or QT4 was born on 2004?
    So? It explains the reason, idea and an example implementation. You don't have to copy the code.

    I have write on wiki you see its? http://wiki.qtcentre.org/index.php?t...Mac_OSX_Finder
    Yes, but we were wondering yesterday what this article is all about. You should rewrite the article and change its title to something more descriptive.

    The method QApplication::event( QEvent *ev ) QEvent::FileOpen 116 open file on mac & window .. maybe Linux ... so on int main(int argc, char *argv[]) GUI version is not needed to grab file from argv .... only on console apps.... or QCoreApplication:event()..
    Sorry, I don't understand what you want to say.

    I digested all (...)
    Was it tasty?

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  2. Link Errors
    By magikalpnoi in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 22:04
  3. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  4. Qt 4.1.4 plugin QPSQL
    By jcr in forum Installation and Deployment
    Replies: 4
    Last Post: 22nd June 2006, 22:55
  5. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.