- Timestamp:
- Oct 27, 2009 9:08:43 AM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 added
- 6 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r24002 r24107 272 272 include/QITreeWidget.h \ 273 273 include/QIMainDialog.h \ 274 include/QIHelpButton.h \275 274 include/QIDialog.h \ 276 275 include/QIFileDialog.h \ … … 335 334 include/VBoxImportApplianceWzd.h \ 336 335 include/VBoxExportApplianceWgt.h \ 337 include/VBoxExportApplianceWzd.h 336 include/VBoxExportApplianceWzd.h \ 337 include/VBoxSpecialControls.h 338 338 339 339 # Sources containing local definitions of classes that use the Q_OBJECT macro. … … 374 374 src/QIMainDialog.cpp \ 375 375 src/QILineEdit.cpp \ 376 src/QIHelpButton.cpp \377 376 src/QISplitter.cpp \ 378 377 src/QITreeView.cpp \ … … 435 434 src/VBoxImportApplianceWzd.cpp \ 436 435 src/VBoxExportApplianceWgt.cpp \ 437 src/VBoxExportApplianceWzd.cpp 436 src/VBoxExportApplianceWzd.cpp \ 437 src/VBoxSpecialControls.cpp 438 438 439 439 ifeq ($(filter-out freebsd linux netbsd openbsd solaris,$(KBUILD_TARGET)),) # X11 … … 473 473 474 474 ifdef VBOX_WITH_COCOA_QT 475 VirtualBox_DEFS += VBOX_DARWIN_USE_NATIVE_CONTROLS 475 476 VirtualBox_SOURCES.darwin += \ 476 477 src/darwin/VBoxCocoaApplication.m \ 477 src/darwin/VBoxUtils-darwin-cocoa.m \ 478 src/darwin/VBoxDockIconPreview-cocoa.m 478 src/darwin/VBoxUtils-darwin-cocoa.mm \ 479 src/darwin/VBoxCocoaSpecialControls.mm \ 480 src/darwin/VBoxDockIconPreview-cocoa.m 481 VirtualBox_QT_MOCHDRS.darwin = \ 482 include/VBoxCocoaSpecialControls.h 483 479 484 else 480 485 VirtualBox_SOURCES.darwin += \ -
trunk/src/VBox/Frontends/VirtualBox/include/QIDialogButtonBox.h
r9866 r24107 32 32 class QBoxLayout; 33 33 34 class QIHelpButton;34 class VBoxHelpButton; 35 35 36 36 class QIDialogButtonBox: public QIWithRetranslateUI<QDialogButtonBox> … … 60 60 private: 61 61 62 QPointer< QIHelpButton> mHelpButton;62 QPointer<VBoxHelpButton> mHelpButton; 63 63 }; 64 64 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxSpecialControls.h
r24065 r24107 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * QIHelpButton class declaration4 * VBoxSpecialButtons declarations 5 5 */ 6 6 7 7 /* 8 * Copyright (C) 200 8Sun Microsystems, Inc.8 * Copyright (C) 2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 */ 22 22 23 #ifndef __QIHelpButton_h_ 24 #define __QIHelpButton_h_ 25 23 #ifndef ___VBoxSpecialControls_h__ 24 #define ___VBoxSpecialControls_h__ 25 26 /* VBox includes */ 26 27 #include "QIWithRetranslateUI.h" 27 28 … … 29 30 #include <QPushButton> 30 31 31 class QIHelpButton: public QIWithRetranslateUI<QPushButton> 32 { 33 Q_OBJECT; 34 35 public: 36 37 QIHelpButton (QWidget *aParent = NULL); 32 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 33 34 /* VBox includes */ 35 #include "VBoxCocoaSpecialControls.h" 36 37 /******************************************************************************** 38 * 39 * A mini cancel button in the native Cocoa version. 40 * 41 ********************************************************************************/ 42 class VBoxMiniCancelButton: public QAbstractButton 43 { 44 Q_OBJECT; 45 46 public: 47 VBoxMiniCancelButton (QWidget *aParent = 0); 48 49 void setToolTip (const QString &aTip) { mButton->setToolTip (aTip); } 50 51 protected: 52 void paintEvent (QPaintEvent * /* aEvent */) {} 53 54 private: 55 VBoxCocoaButton *mButton; 56 }; 57 58 /******************************************************************************** 59 * 60 * A help button in the native Cocoa version. 61 * 62 ********************************************************************************/ 63 class VBoxHelpButton: public QPushButton 64 { 65 Q_OBJECT; 66 67 public: 68 VBoxHelpButton (QWidget *aParent = 0); 69 70 void setToolTip (const QString &aTip) { mButton->setToolTip (aTip); } 71 72 void initFrom (QPushButton * /* aOther */) {} 73 74 protected: 75 void paintEvent (QPaintEvent * /* aEvent */) {} 76 77 private: 78 VBoxCocoaButton *mButton; 79 }; 80 81 /******************************************************************************** 82 * 83 * A segmented button in the native Cocoa version. 84 * 85 ********************************************************************************/ 86 class VBoxSegmentedButton: public VBoxCocoaSegmentedButton 87 { 88 Q_OBJECT; 89 90 public: 91 VBoxSegmentedButton (int aCount, QWidget *aParent = 0); 92 93 void setIcon (int /* aSegment */, const QIcon & /* aIcon */) {} 94 }; 95 96 /******************************************************************************** 97 * 98 * A search field in the native Cocoa version. 99 * 100 ********************************************************************************/ 101 class VBoxSearchField: public VBoxCocoaSearchField 102 { 103 Q_OBJECT; 104 105 public: 106 VBoxSearchField (QWidget *aParent = 0); 107 }; 108 109 #else /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 110 111 /* VBox includes */ 112 #include "QIToolButton.h" 113 114 /* Qt includes */ 115 #include <QLineEdit> 116 117 /* Qt forward declarations */ 118 class QSignalMapper; 119 120 /******************************************************************************** 121 * 122 * A mini cancel button for the other OS's. 123 * 124 ********************************************************************************/ 125 class VBoxMiniCancelButton: public QIWithRetranslateUI<QIToolButton> 126 { 127 Q_OBJECT; 128 129 public: 130 VBoxMiniCancelButton (QWidget *aParent = 0); 131 132 protected: 133 void retranslateUi() {}; 134 }; 135 136 /******************************************************************************** 137 * 138 * A help button for the other OS's. 139 * 140 ********************************************************************************/ 141 class VBoxHelpButton: public QIWithRetranslateUI<QPushButton> 142 { 143 Q_OBJECT; 144 145 public: 146 VBoxHelpButton (QWidget *aParent = 0); 147 #ifdef Q_WS_MAC 148 ~VBoxHelpButton(); 149 QSize sizeHint() const; 150 #endif /* Q_WS_MAC */ 38 151 39 152 void initFrom (QPushButton *aOther); 40 153 154 protected: 155 void retranslateUi(); 156 41 157 #ifdef Q_WS_MAC 42 ~QIHelpButton(); 43 44 QSize sizeHint() const; 45 46 protected: 158 void paintEvent (QPaintEvent *aEvent); 47 159 48 160 bool hitButton (const QPoint &pos) const; … … 52 164 void leaveEvent (QEvent *aEvent); 53 165 54 void paintEvent (QPaintEvent *aEvent); 55 #endif /* Q_WS_MAC */ 56 57 protected: 58 59 void retranslateUi(); 60 61 private: 62 63 #ifdef Q_WS_MAC 166 private: 64 167 /* Private member vars */ 65 168 bool mButtonPressed; … … 73 176 }; 74 177 75 #endif /* __QIHelpButton_h_ */ 76 178 /******************************************************************************** 179 * 180 * A segmented button for the other OS's. 181 * 182 ********************************************************************************/ 183 class VBoxSegmentedButton: public QWidget 184 { 185 Q_OBJECT; 186 187 public: 188 VBoxSegmentedButton (int aCount, QWidget *aParent = 0); 189 ~VBoxSegmentedButton(); 190 191 void setTitle (int aSegment, const QString &aTitle); 192 void setToolTip (int aSegment, const QString &aTip); 193 void setIcon (int aSegment, const QIcon &aIcon); 194 void setEnabled (int aSegment, bool fEnabled); 195 196 void animateClick (int aSegment); 197 198 signals: 199 void clicked (int aSegment); 200 201 private: 202 /* Private member vars */ 203 QList<QIToolButton*> mButtons; 204 QSignalMapper *mSignalMapper; 205 }; 206 207 /******************************************************************************** 208 * 209 * A search field for the other OS's. 210 * 211 ********************************************************************************/ 212 class VBoxSearchField: public QLineEdit 213 { 214 Q_OBJECT; 215 216 public: 217 VBoxSearchField (QWidget *aParent = 0); 218 219 void markError(); 220 void unmarkError(); 221 222 private: 223 /* Private member vars */ 224 QBrush mBaseBrush; 225 }; 226 227 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 228 229 #endif /* ___VBoxSpecialControls_h__ */ 230 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h
r23708 r24107 41 41 42 42 # include <qglobal.h> /* for QT_MAC_USE_COCOA */ 43 # include <QRect>44 43 45 44 # include <ApplicationServices/ApplicationServices.h> … … 62 61 63 62 #include <iprt/cdefs.h> /* for RT_C_DECLS_BEGIN/RT_C_DECLS_END & stuff */ 63 #include <QRect> 64 64 65 65 RT_C_DECLS_BEGIN … … 93 93 void darwinWindowInvalidateShadowImpl (NativeWindowRef aWindow); 94 94 int darwinWindowToolBarHeight (NativeWindowRef aWindow); 95 float darwinSmallFontSize(); 95 96 96 97 RT_C_DECLS_END 97 98 #ifndef __OBJC__99 /********************************************************************************100 *101 * Window/View management (Qt Wrapper)102 *103 ********************************************************************************/104 105 /**106 * Returns a reference to the native View of the QWidget.107 *108 * @returns either HIViewRef or NSView* of the QWidget.109 * @param aWidget Pointer to the QWidget110 */111 NativeViewRef darwinToNativeView (QWidget *aWidget);112 113 /**114 * Returns a reference to the native Window of the QWidget.115 *116 * @returns either WindowRef or NSWindow* of the QWidget.117 * @param aWidget Pointer to the QWidget118 */119 NativeWindowRef darwinToNativeWindow (QWidget *aWidget);120 121 /* This is necessary because of the C calling convention. Its a simple wrapper122 for darwinToNativeWindowImpl to allow operator overloading which isn't123 allowed in C. */124 /**125 * Returns a reference to the native Window of the View..126 *127 * @returns either WindowRef or NSWindow* of the View.128 * @param aWidget Pointer to the native View129 */130 NativeWindowRef darwinToNativeWindow (NativeViewRef aView);131 132 /**133 * Returns a reference to the native View of the Window.134 *135 * @returns either HIViewRef or NSView* of the Window.136 * @param aWidget Pointer to the native Window137 */138 NativeViewRef darwinToNativeView (NativeWindowRef aWindow);139 140 /********************************************************************************141 *142 * Simple setter methods (Qt Wrapper)143 *144 ********************************************************************************/145 void darwinSetShowsToolbarButton (QToolBar *aToolBar, bool aEnabled);146 void darwinSetShowsResizeIndicator (QWidget *aWidget, bool aEnabled);147 void darwinSetHidesAllTitleButtons (QWidget *aWidget);148 void darwinSetShowsWindowTransparent (QWidget *aWidget, bool aEnabled);149 void darwinDisableIconsInMenus (void);150 151 /********************************************************************************152 *153 * Simple helper methods (Qt Wrapper)154 *155 ********************************************************************************/156 void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget);157 void darwinWindowInvalidateShape (QWidget *aWidget);158 void darwinWindowInvalidateShadow (QWidget *aWidget);159 int darwinWindowToolBarHeight (QWidget *aWidget);160 QString darwinSystemLanguage (void);161 QPixmap darwinCreateDragPixmap (const QPixmap& aPixmap, const QString &aText);162 163 164 /********************************************************************************165 *166 * Graphics stuff (Qt Wrapper)167 *168 ********************************************************************************/169 /**170 * Returns a reference to the CGContext of the QWidget.171 *172 * @returns CGContextRef of the QWidget.173 * @param aWidget Pointer to the QWidget174 */175 CGContextRef darwinToCGContextRef (QWidget *aWidget);176 177 CGImageRef darwinToCGImageRef (const QImage *aImage);178 CGImageRef darwinToCGImageRef (const QPixmap *aPixmap);179 CGImageRef darwinToCGImageRef (const char *aSource);180 98 181 99 DECLINLINE(CGRect) darwinToCGRect (const QRect& aRect) { return CGRectMake (aRect.x(), aRect.y(), aRect.width(), aRect.height()); } … … 188 106 return aRect; 189 107 } 108 109 110 #ifndef __OBJC__ 111 /******************************************************************************** 112 * 113 * Window/View management (Qt Wrapper) 114 * 115 ********************************************************************************/ 116 117 /** 118 * Returns a reference to the native View of the QWidget. 119 * 120 * @returns either HIViewRef or NSView* of the QWidget. 121 * @param aWidget Pointer to the QWidget 122 */ 123 NativeViewRef darwinToNativeView (QWidget *aWidget); 124 125 /** 126 * Returns a reference to the native Window of the QWidget. 127 * 128 * @returns either WindowRef or NSWindow* of the QWidget. 129 * @param aWidget Pointer to the QWidget 130 */ 131 NativeWindowRef darwinToNativeWindow (QWidget *aWidget); 132 133 /* This is necessary because of the C calling convention. Its a simple wrapper 134 for darwinToNativeWindowImpl to allow operator overloading which isn't 135 allowed in C. */ 136 /** 137 * Returns a reference to the native Window of the View.. 138 * 139 * @returns either WindowRef or NSWindow* of the View. 140 * @param aWidget Pointer to the native View 141 */ 142 NativeWindowRef darwinToNativeWindow (NativeViewRef aView); 143 144 /** 145 * Returns a reference to the native View of the Window. 146 * 147 * @returns either HIViewRef or NSView* of the Window. 148 * @param aWidget Pointer to the native Window 149 */ 150 NativeViewRef darwinToNativeView (NativeWindowRef aWindow); 151 152 /******************************************************************************** 153 * 154 * Simple setter methods (Qt Wrapper) 155 * 156 ********************************************************************************/ 157 void darwinSetShowsToolbarButton (QToolBar *aToolBar, bool aEnabled); 158 void darwinSetShowsResizeIndicator (QWidget *aWidget, bool aEnabled); 159 void darwinSetHidesAllTitleButtons (QWidget *aWidget); 160 void darwinSetShowsWindowTransparent (QWidget *aWidget, bool aEnabled); 161 void darwinDisableIconsInMenus (void); 162 163 /******************************************************************************** 164 * 165 * Simple helper methods (Qt Wrapper) 166 * 167 ********************************************************************************/ 168 void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget); 169 void darwinWindowInvalidateShape (QWidget *aWidget); 170 void darwinWindowInvalidateShadow (QWidget *aWidget); 171 int darwinWindowToolBarHeight (QWidget *aWidget); 172 QString darwinSystemLanguage (void); 173 QPixmap darwinCreateDragPixmap (const QPixmap& aPixmap, const QString &aText); 174 175 176 /******************************************************************************** 177 * 178 * Graphics stuff (Qt Wrapper) 179 * 180 ********************************************************************************/ 181 /** 182 * Returns a reference to the CGContext of the QWidget. 183 * 184 * @returns CGContextRef of the QWidget. 185 * @param aWidget Pointer to the QWidget 186 */ 187 CGContextRef darwinToCGContextRef (QWidget *aWidget); 188 189 CGImageRef darwinToCGImageRef (const QImage *aImage); 190 CGImageRef darwinToCGImageRef (const QPixmap *aPixmap); 191 CGImageRef darwinToCGImageRef (const char *aSource); 190 192 191 193 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMLogViewer.h
r23260 r24107 32 32 class QTabWidget; 33 33 class QTextEdit; 34 class QLineEdit;34 class VBoxSearchField; 35 35 class QLabel; 36 36 class QIToolButton; 37 class VBoxMiniCancelButton; 38 class VBoxSegmentedButton; 37 39 class QCheckBox; 38 40 … … 104 106 private slots: 105 107 108 void find (int aButton); 106 109 void findNext() { search (true); } 107 110 void findBack() { search (false); } … … 120 123 void toggleWarning (bool aHide); 121 124 122 VBoxVMLogViewer *mViewer; 123 QIToolButton *mButtonClose; 124 QLabel *mSearchName; 125 QLineEdit *mSearchString; 126 QIToolButton *mButtonPrev; 127 QIToolButton *mButtonNext; 128 QCheckBox *mCaseSensitive; 129 QSpacerItem *mWarningSpacer; 130 QLabel *mWarningIcon; 131 QLabel *mWarningString; 125 VBoxVMLogViewer *mViewer; 126 VBoxMiniCancelButton *mButtonClose; 127 QLabel *mSearchName; 128 VBoxSearchField *mSearchString; 129 VBoxSegmentedButton *mButtonsNextPrev; 130 QCheckBox *mCaseSensitive; 131 QSpacerItem *mWarningSpacer; 132 QLabel *mWarningIcon; 133 QLabel *mWarningString; 132 134 }; 133 135 -
trunk/src/VBox/Frontends/VirtualBox/src/QIDialogButtonBox.cpp
r10101 r24107 22 22 23 23 #include "QIDialogButtonBox.h" 24 #include " QIHelpButton.h"24 #include "VBoxSpecialControls.h" 25 25 26 26 #include <iprt/assert.h> … … 114 114 /* Use our very own help button if the user requested for one. */ 115 115 if (!mHelpButton) 116 mHelpButton = new QIHelpButton;116 mHelpButton = new VBoxHelpButton; 117 117 mHelpButton->initFrom (btn); 118 118 removeButton (btn); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSpecialControls.cpp
r24065 r24107 1 /** @file 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * QIHelpButton class implementation 5 */ 6 7 /* 8 * Copyright (C) 2008 Sun Microsystems, Inc. 9 * 10 * This file is part of VirtualBox Open Source Edition (OSE), as 11 * available from http://www.virtualbox.org. This file is free software; 12 * you can redistribute it and/or modify it under the terms of the GNU 13 * General Public License (GPL) as published by the Free Software 14 * Foundation, in version 2 as it comes in the "COPYING" file of the 15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the 16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 17 * 18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa 19 * Clara, CA 95054 USA or visit http://www.sun.com if you need 20 * additional information or have any questions. 21 */ 22 23 #include "QIHelpButton.h" 1 /* VBox includes */ 2 #include "VBoxSpecialControls.h" 3 4 /* VBox includes */ 5 #include "VBoxGlobal.h" 6 7 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 8 9 /******************************************************************************** 10 * 11 * A mini cancel button in the native Cocoa version. 12 * 13 ********************************************************************************/ 14 VBoxMiniCancelButton::VBoxMiniCancelButton (QWidget *aParent /* = 0 */) 15 : QAbstractButton (aParent) 16 { 17 setShortcut (QKeySequence (Qt::Key_Escape)); 18 mButton = new VBoxCocoaButton (VBoxCocoaButton::CancelButton, this); 19 connect (mButton, SIGNAL (clicked()), 20 this, SIGNAL (clicked())); 21 setFixedSize (mButton->size()); 22 } 23 24 /******************************************************************************** 25 * 26 * A help button in the native Cocoa version. 27 * 28 ********************************************************************************/ 29 VBoxHelpButton::VBoxHelpButton (QWidget *aParent /* = 0 */) 30 : QPushButton (aParent) 31 { 32 setShortcut (QKeySequence (QKeySequence::HelpContents)); 33 mButton = new VBoxCocoaButton (VBoxCocoaButton::HelpButton, this); 34 connect (mButton, SIGNAL (clicked()), 35 this, SIGNAL (clicked())); 36 setFixedSize (mButton->size()); 37 } 38 39 /******************************************************************************** 40 * 41 * A segmented button in the native Cocoa version. 42 * 43 ********************************************************************************/ 44 VBoxSegmentedButton::VBoxSegmentedButton (int aCount, QWidget *aParent /* = 0 */) 45 : VBoxCocoaSegmentedButton (aCount, aParent) 46 { 47 } 48 /******************************************************************************** 49 * 50 * A search field in the native Cocoa version. 51 * 52 ********************************************************************************/ 53 VBoxSearchField::VBoxSearchField (QWidget *aParent /* = 0 */) 54 : VBoxCocoaSearchField (aParent) 55 { 56 } 57 58 #else /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 24 59 25 60 /* Qt includes */ … … 27 62 #include <QBitmap> 28 63 #include <QMouseEvent> 29 64 #include <QSignalMapper> 65 66 /******************************************************************************** 67 * 68 * A mini cancel button for the other OS's. 69 * 70 ********************************************************************************/ 71 VBoxMiniCancelButton::VBoxMiniCancelButton (QWidget *aParent /* = 0 */) 72 : QIWithRetranslateUI<QIToolButton> (aParent) 73 { 74 setAutoRaise (true); 75 setFocusPolicy (Qt::TabFocus); 76 setShortcut (QKeySequence (Qt::Key_Escape)); 77 setIcon (VBoxGlobal::iconSet (":/delete_16px.png", 78 ":/delete_dis_16px.png")); 79 } 80 81 /******************************************************************************** 82 * 83 * A help button for the other OS's. 84 * 85 ********************************************************************************/ 30 86 /* From: src/gui/styles/qmacstyle_mac.cpp */ 31 87 static const int PushButtonLeftOffset = 6; … … 34 90 static const int PushButtonBottomOffset = 4; 35 91 36 QIHelpButton::QIHelpButton(QWidget *aParent /* = NULL*/)92 VBoxHelpButton::VBoxHelpButton (QWidget *aParent /* = 0 */) 37 93 : QIWithRetranslateUI<QPushButton> (aParent) 38 94 { … … 43 99 mSize = mNormalPixmap->size(); 44 100 mMask = new QImage (mNormalPixmap->mask().toImage()); 45 mBRect = QRect (PushButtonLeftOffset, 101 mBRect = QRect (PushButtonLeftOffset, 46 102 PushButtonTopOffset, 47 103 mSize.width(), … … 52 108 } 53 109 54 void QIHelpButton::initFrom (QPushButton *aOther)110 void VBoxHelpButton::initFrom (QPushButton *aOther) 55 111 { 56 112 setIcon (aOther->icon()); … … 64 120 } 65 121 122 void VBoxHelpButton::retranslateUi() 123 { 124 QPushButton::setText (tr ("&Help")); 125 if (QPushButton::shortcut().isEmpty()) 126 QPushButton::setShortcut (QKeySequence::HelpContents); 127 } 128 66 129 #ifdef Q_WS_MAC 67 QIHelpButton::~QIHelpButton()130 VBoxHelpButton::~VBoxHelpButton() 68 131 { 69 132 delete mNormalPixmap; … … 72 135 } 73 136 74 QSize QIHelpButton::sizeHint() const137 QSize VBoxHelpButton::sizeHint() const 75 138 { 76 139 return QSize (mSize.width() + PushButtonLeftOffset + PushButtonRightOffset, … … 78 141 } 79 142 80 bool QIHelpButton::hitButton (const QPoint &pos) const 143 void VBoxHelpButton::paintEvent (QPaintEvent * /* aEvent */) 144 { 145 QPainter painter (this); 146 painter.drawPixmap (PushButtonLeftOffset, PushButtonTopOffset, mButtonPressed ? *mPressedPixmap: *mNormalPixmap); 147 } 148 149 bool VBoxHelpButton::hitButton (const QPoint &pos) const 81 150 { 82 151 if (mBRect.contains (pos)) … … 87 156 } 88 157 89 void QIHelpButton::mousePressEvent (QMouseEvent *aEvent)158 void VBoxHelpButton::mousePressEvent (QMouseEvent *aEvent) 90 159 { 91 160 if (hitButton (aEvent->pos())) … … 95 164 } 96 165 97 void QIHelpButton::mouseReleaseEvent (QMouseEvent *aEvent)166 void VBoxHelpButton::mouseReleaseEvent (QMouseEvent *aEvent) 98 167 { 99 168 QPushButton::mouseReleaseEvent (aEvent); … … 102 171 } 103 172 104 void QIHelpButton::leaveEvent (QEvent * aEvent)173 void VBoxHelpButton::leaveEvent (QEvent * aEvent) 105 174 { 106 175 QPushButton::leaveEvent (aEvent); … … 108 177 update(); 109 178 } 110 111 void QIHelpButton::paintEvent (QPaintEvent * /* aEvent */)112 {113 QPainter painter (this);114 painter.drawPixmap (PushButtonLeftOffset, PushButtonTopOffset, mButtonPressed ? *mPressedPixmap: *mNormalPixmap);115 }116 179 #endif /* Q_WS_MAC */ 117 180 118 void QIHelpButton::retranslateUi() 119 { 120 QPushButton::setText (tr ("&Help")); 121 if (QPushButton::shortcut().isEmpty()) 122 QPushButton::setShortcut (QKeySequence::HelpContents); 123 } 124 181 /******************************************************************************** 182 * 183 * A segmented button for the other OS's. 184 * 185 ********************************************************************************/ 186 VBoxSegmentedButton::VBoxSegmentedButton (int aCount, QWidget *aParent /* = 0 */) 187 : QWidget (aParent) 188 { 189 mSignalMapper = new QSignalMapper (this); 190 191 QHBoxLayout *layout = new QHBoxLayout (this); 192 for (int i=0; i < aCount; ++i) 193 { 194 QIToolButton *button = new QIToolButton (this); 195 button->setAutoRaise (true); 196 button->setFocusPolicy (Qt::TabFocus); 197 button->setToolButtonStyle (Qt::ToolButtonTextBesideIcon); 198 mButtons.append (button); 199 layout->addWidget (button); 200 connect (button, SIGNAL(clicked()), 201 mSignalMapper, SLOT(map())); 202 mSignalMapper->setMapping (button, i); 203 } 204 connect (mSignalMapper, SIGNAL(mapped(int)), 205 this, SIGNAL(clicked(int))); 206 207 } 208 209 VBoxSegmentedButton::~VBoxSegmentedButton() 210 { 211 delete mSignalMapper; 212 qDeleteAll (mButtons); 213 } 214 215 void VBoxSegmentedButton::setTitle (int aSegment, const QString &aTitle) 216 { 217 mButtons.at (aSegment)->setText (aTitle); 218 } 219 220 void VBoxSegmentedButton::setToolTip (int aSegment, const QString &aTip) 221 { 222 mButtons.at (aSegment)->setToolTip (aTip); 223 } 224 225 void VBoxSegmentedButton::setIcon (int aSegment, const QIcon &aIcon) 226 { 227 mButtons.at (aSegment)->setIcon (aIcon); 228 } 229 230 void VBoxSegmentedButton::setEnabled (int aSegment, bool fEnabled) 231 { 232 mButtons.at (aSegment)->setEnabled (fEnabled); 233 } 234 235 void VBoxSegmentedButton::animateClick (int aSegment) 236 { 237 mButtons.at (aSegment)->animateClick(); 238 } 239 240 /******************************************************************************** 241 * 242 * A search field for the other OS's. 243 * 244 ********************************************************************************/ 245 VBoxSearchField::VBoxSearchField (QWidget *aParent /* = 0 */) 246 : QLineEdit (aParent) 247 { 248 mBaseBrush = palette().base(); 249 } 250 251 void VBoxSearchField::markError() 252 { 253 QPalette pal = palette(); 254 QColor c (Qt::red); 255 c.setAlphaF (0.3); 256 pal.setBrush (QPalette::Base, c); 257 setPalette (pal); 258 } 259 260 void VBoxSearchField::unmarkError() 261 { 262 QPalette pal = palette(); 263 pal.setBrush (QPalette::Base, mBaseBrush); 264 setPalette (pal); 265 } 266 267 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 268 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.cpp
r23260 r24107 21 21 */ 22 22 23 #include <VBoxVMLogViewer.h> 24 #include <VBoxGlobal.h> 25 #include <VBoxProblemReporter.h> 26 #include "QIToolButton.h" 23 #include "VBoxVMLogViewer.h" 24 #include "VBoxGlobal.h" 25 #include "VBoxProblemReporter.h" 26 #include "VBoxSpecialControls.h" 27 #include "VBoxUtils.h" 27 28 28 29 /* Qt includes */ … … 121 122 /* We have to force this to get the default button L&F on the mac. */ 122 123 defaultButton()->setEnabled (true); 124 # ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 125 logsFrameLayout->setSpacing (4); 126 # endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 123 127 #endif /* Q_WS_MAC */ 124 128 /* Loading language constants */ … … 339 343 , mButtonClose (0) 340 344 , mSearchName (0), mSearchString (0) 341 , mButton Prev (0), mButtonNext(0)345 , mButtonsNextPrev (0) 342 346 , mCaseSensitive (0) 343 347 , mWarningSpacer (0), mWarningIcon (0), mWarningString (0) 344 348 { 345 mButtonClose = new QIToolButton (this); 346 mButtonClose->setAutoRaise (true); 347 mButtonClose->setFocusPolicy (Qt::TabFocus); 348 mButtonClose->setShortcut (QKeySequence (Qt::Key_Escape)); 349 mButtonClose = new VBoxMiniCancelButton (this); 349 350 connect (mButtonClose, SIGNAL (clicked()), this, SLOT (hide())); 350 mButtonClose->setIcon (VBoxGlobal::iconSet (":/delete_16px.png",351 ":/delete_dis_16px.png"));352 351 353 352 mSearchName = new QLabel (this); 354 mSearchString = new QLineEdit(this);353 mSearchString = new VBoxSearchField (this); 355 354 mSearchString->setSizePolicy (QSizePolicy::Preferred, 356 355 QSizePolicy::Fixed); … … 358 357 this, SLOT (findCurrent (const QString &))); 359 358 360 mButtonNext = new QIToolButton (this); 361 mButtonNext->setEnabled (false); 362 mButtonNext->setAutoRaise (true); 363 mButtonNext->setFocusPolicy (Qt::TabFocus); 364 mButtonNext->setToolButtonStyle (Qt::ToolButtonTextBesideIcon); 365 connect (mButtonNext, SIGNAL (clicked()), this, SLOT (findNext())); 366 mButtonNext->setIcon (VBoxGlobal::iconSet (":/list_movedown_16px.png", 367 ":/list_movedown_disabled_16px.png")); 368 369 mButtonPrev = new QIToolButton (this); 370 mButtonPrev->setEnabled (false); 371 mButtonPrev->setAutoRaise (true); 372 mButtonPrev->setFocusPolicy (Qt::TabFocus); 373 mButtonPrev->setToolButtonStyle (Qt::ToolButtonTextBesideIcon); 374 connect (mButtonPrev, SIGNAL (clicked()), this, SLOT (findBack())); 375 mButtonPrev->setIcon (VBoxGlobal::iconSet (":/list_moveup_16px.png", 376 ":/list_moveup_disabled_16px.png")); 359 mButtonsNextPrev = new VBoxSegmentedButton (2, this); 360 mButtonsNextPrev->setEnabled (0, false); 361 mButtonsNextPrev->setIcon (0, VBoxGlobal::iconSet (":/list_movedown_16px.png", 362 ":/list_movedown_disabled_16px.png")); 363 mButtonsNextPrev->setEnabled (1, false); 364 mButtonsNextPrev->setIcon (1, VBoxGlobal::iconSet (":/list_moveup_16px.png", 365 ":/list_moveup_disabled_16px.png")); 366 connect (mButtonsNextPrev, SIGNAL (clicked (int)), this, SLOT (find (int))); 377 367 378 368 mCaseSensitive = new QCheckBox (this); … … 391 381 QSpacerItem *spacer = new QSpacerItem (0, 0, QSizePolicy::Expanding, 392 382 QSizePolicy::Minimum); 383 384 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 385 QFont font = mSearchName->font(); 386 font.setPointSize (::darwinSmallFontSize()); 387 mSearchName->setFont (font); 388 mCaseSensitive->setFont (font); 389 mWarningString->setFont (font); 390 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 393 391 394 392 QHBoxLayout *mainLayout = new QHBoxLayout (this); … … 398 396 mainLayout->addWidget (mSearchName); 399 397 mainLayout->addWidget (mSearchString); 400 mainLayout->addWidget (mButtonNext); 401 mainLayout->addWidget (mButtonPrev); 398 mainLayout->addWidget (mButtonsNextPrev); 402 399 mainLayout->addWidget (mCaseSensitive); 403 400 mainLayout->addItem (mWarningSpacer); … … 419 416 mSearchString->setToolTip (tr ("Enter a search string here")); 420 417 421 VBoxGlobal::setTextLabel (mButtonPrev, tr ("&Previous")); 422 mButtonPrev->setToolTip (tr ("Search for the previous occurrence " 423 "of the string")); 424 425 VBoxGlobal::setTextLabel (mButtonNext, tr ("&Next")); 426 mButtonNext->setToolTip (tr ("Search for the next occurrence of " 427 "the string")); 418 mButtonsNextPrev->setTitle (0, tr ("&Next")); 419 mButtonsNextPrev->setToolTip (0, tr ("Search for the previous occurrence " 420 "of the string")); 421 422 mButtonsNextPrev->setTitle (1, tr ("&Previous")); 423 mButtonsNextPrev->setToolTip (1, tr ("Search for the next occurrence of " 424 "the string")); 425 428 426 429 427 mCaseSensitive->setText (tr ("C&ase Sensitive")); … … 436 434 void VBoxLogSearchPanel::findCurrent (const QString &aSearchString) 437 435 { 438 mButton Next->setEnabled (aSearchString.length());439 mButton Prev->setEnabled (aSearchString.length());436 mButtonsNextPrev->setEnabled (0, aSearchString.length()); 437 mButtonsNextPrev->setEnabled (1, aSearchString.length()); 440 438 toggleWarning (!aSearchString.length()); 441 439 if (aSearchString.length()) … … 507 505 (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return)) 508 506 { 509 mButton Next->animateClick();507 mButtonsNextPrev->animateClick (0); 510 508 return true; 511 509 } … … 514 512 { 515 513 if (e->QInputEvent::modifiers() == 0) 516 mButton Next->animateClick();514 mButtonsNextPrev->animateClick (0); 517 515 else if (e->QInputEvent::modifiers() == Qt::ShiftModifier) 518 mButton Prev->animateClick();516 mButtonsNextPrev->animateClick (1); 519 517 return true; 520 518 } … … 573 571 mWarningSpacer->changeSize (aHide ? 0 : 16, 0, QSizePolicy::Fixed, 574 572 QSizePolicy::Minimum); 573 if (!aHide) 574 mSearchString->markError(); 575 else 576 mSearchString->unmarkError(); 575 577 mWarningIcon->setHidden (aHide); 576 578 mWarningString->setHidden (aHide); 577 579 } 578 580 581 void VBoxLogSearchPanel::find (int aButton) 582 { 583 if (aButton == 0) 584 findNext(); 585 else 586 findBack(); 587 } -
trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm
r24106 r24107 28 28 #import <AppKit/NSEvent.h> 29 29 #import <AppKit/NSColor.h> 30 #import <AppKit/NSFont.h> 30 31 31 32 NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView) … … 36 37 if (aView) 37 38 window = [aView window]; 38 39 39 40 [pool release]; 40 41 return window; … … 47 48 NativeViewRef view = NULL; 48 49 if (aWindow) 49 view = [aWindow contentView]; 50 view = [aWindow contentView]; 50 51 51 52 [pool release]; … … 156 157 } 157 158 159 int darwinWindowToolBarHeight (NativeWindowRef aWindow) 160 { 161 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 162 163 NSToolbar *toolbar = [aWindow toolbar]; 164 NSRect windowFrame = [aWindow frame]; 165 int toolbarHeight = 0; 166 int theight = (NSHeight([NSWindow contentRectForFrameRect:[aWindow frame] styleMask:[aWindow styleMask]]) - NSHeight([[aWindow contentView] frame])); 167 /* toolbar height: */ 168 if(toolbar && [toolbar isVisible]) 169 /* title bar height: */ 170 toolbarHeight = NSHeight (windowFrame) - NSHeight ([[aWindow contentView] frame]) - theight; 171 172 [pool release]; 173 return toolbarHeight; 174 } 175 176 float darwinSmallFontSize() 177 { 178 return [NSFont systemFontSizeForControlSize: NSSmallControlSize]; 179 } 180
Note:
See TracChangeset
for help on using the changeset viewer.