Merge branch 'qt-fixes'

A multitude of miscellaneous Qt fixes and improvements.

See https://github.com/wxWidgets/wxWidgets/pull/1552
This commit is contained in:
Vadim Zeitlin
2019-09-27 19:18:11 +02:00
20 changed files with 392 additions and 183 deletions

View File

@@ -56,6 +56,9 @@ public:
protected:
virtual void DoGetClientSize(int *width, int *height) const wxOVERRIDE;
virtual void DoSetClientSize(int width, int height) wxOVERRIDE;
virtual QWidget* QtGetParentWidget() const wxOVERRIDE;
private:
// Common part of all ctors.

View File

@@ -60,7 +60,7 @@ public:
virtual QWidget *GetHandle() const wxOVERRIDE;
void QtSendEvent(wxEventType evtType, const QModelIndex &index, bool selected);
void QtSendEvent(wxEventType evtType, int rowIndex, bool selected);
protected:
virtual void DoSetFirstItem(int n) wxOVERRIDE;

View File

@@ -12,6 +12,7 @@
#include "wx/bitmap.h"
class QAction;
class wxQtAction;
class WXDLLIMPEXP_FWD_CORE wxMenu;
@@ -41,7 +42,7 @@ public:
private:
// Qt is using an action instead of a menu item.
QAction *m_qtAction;
wxQtAction *m_qtAction;
wxBitmap m_bitmap;
wxDECLARE_DYNAMIC_CLASS( wxMenuItem );

View File

@@ -11,6 +11,7 @@
#define _WX_QT_PRIVATE_TREEITEM_DELEGATE_H
#include <QtWidgets/QStyledItemDelegate>
#include <QtWidgets/QToolTip>
#include "wx/app.h"
#include "wx/textctrl.h"
@@ -67,6 +68,28 @@ public:
QStyledItemDelegate::setModelData(editor, model, index);
}
bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index)
{
if ( event->type() == QEvent::ToolTip )
{
const QRect &itemRect = view->visualRect(index);
const QSize &bestSize = sizeHint(option, index);
if ( itemRect.width() < bestSize.width() )
{
const QString &value = index.data(Qt::DisplayRole).toString();
QToolTip::showText(event->globalPos(), value, view);
}
else
{
QToolTip::hideText();
}
return true;
}
return QStyledItemDelegate::helpEvent(event, view, option, index);
}
private:
wxWindow* m_parent;
mutable wxTextCtrl* m_textCtrl;

View File

@@ -61,6 +61,7 @@ public:
QObject::connect( this, &QObject::destroyed, this,
&wxQtEventSignalHandler::HandleDestroyedSignal );
Widget::setMouseTracking(true);
}
void HandleDestroyedSignal()
@@ -104,7 +105,7 @@ protected:
if ( !this->GetHandler()->QtHandleCloseEvent(this, event) )
Widget::closeEvent(event);
else
event->accept();
event->ignore();
}
//wxContextMenuEvent

View File

@@ -168,6 +168,7 @@ public:
static void QtStoreWindowPointer( QWidget *widget, const wxWindowQt *window );
static wxWindowQt *QtRetrieveWindowPointer( const QWidget *widget );
static void QtSendSetCursorEvent(wxWindowQt* win, wxPoint posClient);
#if wxUSE_ACCEL
virtual void QtHandleShortcut ( int command );
@@ -215,6 +216,12 @@ protected:
virtual bool DoPopupMenu(wxMenu *menu, int x, int y) wxOVERRIDE;
#endif // wxUSE_MENUS
// Return the parent to use for children being reparented to us: this is
// overridden in wxFrame to use its central widget rather than the frame
// itself.
virtual QWidget* QtGetParentWidget() const { return GetHandle(); }
QWidget *m_qtWindow;
private:
@@ -224,6 +231,11 @@ private:
QScrollBar *m_horzScrollBar; // owned by m_qtWindow when allocated
QScrollBar *m_vertScrollBar; // owned by m_qtWindow when allocated
// Return the viewport of m_qtContainer, if it's used, or just m_qtWindow.
//
// Always returns non-null pointer if the window has been already created.
QWidget *QtGetClientWidget() const;
QScrollBar *QtGetScrollBar( int orientation ) const;
QScrollBar *QtSetScrollBar( int orientation, QScrollBar *scrollBar=NULL );