From 106d7a210be1e6d52946b575a262e2c76c5e51e6 Mon Sep 17 00:00:00 2001
From: Morten Sorvig <msorvig@trolltech.com>
Date: Thu, 10 Sep 2009 11:53:31 +0200
Subject: [PATCH] Enable Qt3Support for Qt/Cocoa on Mac OS X.
Qt on Mac OS X should not be the only desktop platform
without Qt3Support once the Carpon port is dropped. This
will also make the switch from Carbon to Cocoa-based Qt
as smooth as possible.
This is a minimal port, with some code removed:
Q3FileDialog is gone.
Q3MainWindow won't get the "hide toolbar" button.
Q3ScrollView might to more updates than structly neccesary.
The rest is there, including the QT3_SUPPORT functions
in QtCore and QtGui.
---
configure | 1 -
src/qt3support/dialogs/q3filedialog.cpp | 5 ++++-
src/qt3support/dialogs/q3filedialog.h | 4 ++++
src/qt3support/dialogs/q3filedialog_mac.cpp | 4 ++++
src/qt3support/widgets/q3mainwindow.cpp | 4 ++--
src/qt3support/widgets/q3scrollview.cpp | 4 ++++
6 files changed, 18 insertions(+), 4 deletions(-)
diff --git configure configure
index 719db32..43aa739 100755
|
|
case "$PLATFORM,$CFG_MAC_COCOA" in |
5859 | 5859 | macx*,yes) |
5860 | 5860 | # Cocoa |
5861 | 5861 | QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.5 |
5862 | | CFG_QT3SUPPORT="no" |
5863 | 5862 | ;; |
5864 | 5863 | macx*,no) |
5865 | 5864 | # gcc, Carbon |
diff --git src/qt3support/dialogs/q3filedialog.cpp src/qt3support/dialogs/q3filedialog.cpp
index 66ace5d..c14ff5c 100644
|
|
|
116 | 116 | |
117 | 117 | QT_BEGIN_NAMESPACE |
118 | 118 | |
| 119 | #ifndef QT_MAC_USE_COCOA |
| 120 | |
119 | 121 | /* XPM */ |
120 | 122 | static const char * const start_xpm[]={ |
121 | 123 | "16 15 8 1", |
… |
… |
Q3FilePreview::Q3FilePreview() |
6051 | 6053 | function to provide file previewing. |
6052 | 6054 | */ |
6053 | 6055 | |
6054 | | |
| 6056 | #endif // QT_MAC_USE_COCOA |
| 6057 | |
6055 | 6058 | QT_END_NAMESPACE |
6056 | 6059 | |
6057 | 6060 | #include "moc_q3filedialog.cpp" |
diff --git src/qt3support/dialogs/q3filedialog.h src/qt3support/dialogs/q3filedialog.h
index f6a7950..8644b4c 100644
|
|
class QUrlInfo; |
69 | 69 | |
70 | 70 | #ifndef QT_NO_FILEDIALOG |
71 | 71 | |
| 72 | #ifndef QT_MAC_USE_COCOA |
| 73 | |
72 | 74 | class Q_COMPAT_EXPORT Q3FileIconProvider : public QObject |
73 | 75 | { |
74 | 76 | Q_OBJECT |
… |
… |
private: |
337 | 339 | #endif |
338 | 340 | }; |
339 | 341 | |
| 342 | #endif // QT_MAC_USE_COCOA |
| 343 | |
340 | 344 | #endif // QT_NO_FILEDIALOG |
341 | 345 | |
342 | 346 | QT_END_NAMESPACE |
diff --git src/qt3support/dialogs/q3filedialog_mac.cpp src/qt3support/dialogs/q3filedialog_mac.cpp
index a36274d..585fa8f 100644
|
|
|
60 | 60 | |
61 | 61 | QT_BEGIN_NAMESPACE |
62 | 62 | |
| 63 | #ifndef QT_MAC_USE_COCOA |
| 64 | |
63 | 65 | /***************************************************************************** |
64 | 66 | Externals |
65 | 67 | *****************************************************************************/ |
… |
… |
QString Q3FileDialog::macGetSaveFileName(const QString &start, const QString &fi |
564 | 566 | return retstr; |
565 | 567 | } |
566 | 568 | |
| 569 | #endif // QT_MAC_USE_COCOA |
| 570 | |
567 | 571 | QT_END_NAMESPACE |
568 | 572 | |
569 | 573 | #endif |
diff --git src/qt3support/widgets/q3mainwindow.cpp src/qt3support/widgets/q3mainwindow.cpp
index b7fc486..e02d890 100644
|
|
void Q3MainWindow::addDockWindow(Q3DockWindow *dockWindow, |
1042 | 1042 | Qt::Dock edge, bool newLine) |
1043 | 1043 | { |
1044 | 1044 | Q_D(Q3MainWindow); |
1045 | | #ifdef Q_WS_MAC |
| 1045 | #if defined (Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) |
1046 | 1046 | extern WindowPtr qt_mac_window_for(const QWidget*); //qwidget_mac.cpp |
1047 | 1047 | if(isWindow() && edge == Qt::DockTop) { |
1048 | 1048 | d->createWinId(); |
… |
… |
void Q3MainWindow::removeDockWindow(Q3DockWindow * dockWindow) |
1217 | 1217 | { |
1218 | 1218 | Q_D(Q3MainWindow); |
1219 | 1219 | |
1220 | | #ifdef Q_WS_MAC |
| 1220 | #if defined (Q_WS_MAC) && !defined (QT_MAC_USE_COCOA) |
1221 | 1221 | extern WindowPtr qt_mac_window_for(const QWidget*); //qwidget_mac.cpp |
1222 | 1222 | if(isWindow() && dockWindow->area() == topDock() && !dockWindows(Qt::DockTop).count()) |
1223 | 1223 | ChangeWindowAttributes(qt_mac_window_for(this), 0, kWindowToolbarButtonAttribute); |
diff --git src/qt3support/widgets/q3scrollview.cpp src/qt3support/widgets/q3scrollview.cpp
index 1178047..3be0145 100644
|
|
void Q3ScrollView::updateScrollBars() |
870 | 870 | mac_need_scroll = true; |
871 | 871 | } else { |
872 | 872 | QWidget *tlw = window(); |
| 873 | #ifndef QT_MAC_USE_COCOA |
873 | 874 | QPoint tlw_br = QPoint(tlw->width(), tlw->height()), |
874 | 875 | my_br = qt_mac_posInWindow(this) + QPoint(w, h); |
875 | 876 | if(my_br.x() >= tlw_br.x() - 3 && my_br.y() >= tlw_br.y() - 3) |
| 877 | #endif |
876 | 878 | mac_need_scroll = true; |
877 | 879 | } |
878 | 880 | if(mac_need_scroll) { |
| 881 | #ifndef QT_MAC_USE_COCOA |
879 | 882 | WindowAttributes attr; |
880 | 883 | GetWindowAttributes((WindowPtr)handle(), &attr); |
881 | 884 | mac_need_scroll = (attr & kWindowResizableAttribute); |
| 885 | #endif |
882 | 886 | } |
883 | 887 | if(mac_need_scroll) { |
884 | 888 | showc = true; |