diff options
Diffstat (limited to 'src/gui')
51 files changed, 986 insertions, 663 deletions
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp index aee592c..0357a7a 100644 --- a/src/gui/dialogs/qcolordialog.cpp +++ b/src/gui/dialogs/qcolordialog.cpp @@ -1836,8 +1836,8 @@ QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent) QColorDialog::~QColorDialog() { - Q_D(QColorDialog); #if defined(Q_WS_MAC) + Q_D(QColorDialog); if (d->delegate) { d->releaseCocoaColorPanelDelegate(); QColorDialogPrivate::sharedColorPanelAvailable = true; diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 3f7da57..03b4789 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -396,6 +396,9 @@ QList<QUrl> QFileDialog::sidebarUrls() const static const qint32 QFileDialogMagic = 0xbe; +const char *qt_file_dialog_filter_reg_exp = +"^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; + /*! \since 4.3 Saves the state of the dialog's layout, history and current directory. @@ -1018,8 +1021,13 @@ void QFileDialog::setNameFilters(const QStringList &filters) if (testOption(HideNameFilterDetails)) { QStringList strippedFilters; + QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp)); for (int i = 0; i < cleanedFilters.count(); ++i) { - strippedFilters.append(cleanedFilters[i].mid(0, cleanedFilters[i].indexOf(QLatin1String(" (")))); + QString filterName; + int index = r.indexIn(cleanedFilters[i]); + if (index >= 0) + filterName = r.cap(1); + strippedFilters.append(filterName.simplified()); } d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters); } else { @@ -2871,10 +2879,6 @@ void QFileDialogPrivate::_q_goToDirectory(const QString &path) } } -const char *qt_file_dialog_filter_reg_exp = -"(\\W|[a-zA-Z0-9 -]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; - - // Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)" QStringList qt_clean_filter_list(const QString &filter) { diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index 9bf82c3..114456d 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -59,7 +59,10 @@ #endif #include <shlobj.h> - +//At some point we can hope that mingw will support that interface +#if !defined(Q_WS_WINCE) && !defined(Q_CC_MINGW) +#include <shobjidl.h> +#endif #include <objbase.h> #if defined(__IFileDialog_INTERFACE_DEFINED__) \ @@ -173,15 +176,22 @@ static QStringList qt_win_make_filters_list(const QString &filter) } // Makes a NUL-oriented Windows filter from a Qt filter. -static QString qt_win_filter(const QString &filter) +static QString qt_win_filter(const QString &filter, bool hideFiltersDetails) { QStringList filterLst = qt_win_make_filters_list(filter); QStringList::Iterator it = filterLst.begin(); QString winfilters; + QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp)); for (; it != filterLst.end(); ++it) { QString subfilter = *it; if (!subfilter.isEmpty()) { - winfilters += subfilter; + if (hideFiltersDetails) { + int index = r.indexIn(subfilter); + if (index >= 0) + winfilters += r.cap(1); + } else { + winfilters += subfilter; + } winfilters += QChar(); winfilters += qt_win_extract_filter(subfilter); winfilters += QChar(); @@ -295,9 +305,10 @@ QString qt_win_get_open_file_name(const QFileDialogArgs &args, modal_widget.setParent(args.parent, Qt::Window); QApplicationPrivate::enterModal(&modal_widget); + bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails; OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection, args.directory, args.caption, - qt_win_filter(args.filter), + qt_win_filter(args.filter, hideFiltersDetails), QFileDialog::ExistingFile, args.options); if (idx) @@ -354,7 +365,7 @@ QString qt_win_get_save_file_name(const QFileDialogArgs &args, modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true); modal_widget.setParent(args.parent, Qt::Window); QApplicationPrivate::enterModal(&modal_widget); - + bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails; // This block is used below for the lpstrDefExt member. // Note that the current MSDN docs document this member wrong. // It should rather be documented as "the default extension if no extension was given and if the @@ -374,7 +385,7 @@ QString qt_win_get_save_file_name(const QFileDialogArgs &args, OPENFILENAME *ofn = qt_win_make_OFN(args.parent, args.selection, args.directory, args.caption, - qt_win_filter(args.filter), + qt_win_filter(args.filter, hideFiltersDetails), QFileDialog::AnyFile, args.options); @@ -441,6 +452,8 @@ static bool qt_win_set_IFileDialogOptions(IFileDialog *pfd, QString subfilter = *it; if (!subfilter.isEmpty()) { offsets<<currentOffset; + //Here the COMMON_ITEM_DIALOG API always add the details for the filter (e.g. *.txt) + //so we don't need to handle the flag HideNameFilterDetails. winfilters += subfilter; // The name of the filter. winfilters += QChar(); currentOffset += subfilter.size()+1; @@ -638,9 +651,10 @@ QStringList qt_win_get_open_file_names(const QFileDialogArgs &args, modal_widget.setParent(args.parent, Qt::Window); QApplicationPrivate::enterModal(&modal_widget); + bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails; OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection, args.directory, args.caption, - qt_win_filter(args.filter), + qt_win_filter(args.filter, hideFiltersDetails), QFileDialog::ExistingFiles, args.options); if (idx) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index d529976..52f333b 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -9963,20 +9963,25 @@ void QGraphicsItemGroup::addToGroup(QGraphicsItem *item) } // COMBINE - // ### Use itemTransform() instead. - QTransform oldSceneMatrix = item->sceneTransform(); + bool ok; + QTransform itemTransform = item->itemTransform(this, &ok); + + if (!ok) { + qWarning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates"); + return; + } + + QTransform newItemTransform(itemTransform); item->setPos(mapFromItem(item, 0, 0)); item->setParentItem(this); - QTransform newItemTransform(oldSceneMatrix); - newItemTransform *= sceneTransform().inverted(); + + // removing position from translation component of the new transform if (!item->pos().isNull()) newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); + item->setTransform(newItemTransform); item->d_func()->setIsMemberOfGroup(true); prepareGeometryChange(); - QTransform itemTransform(item->transform()); - if (!item->pos().isNull()) - itemTransform *= QTransform::fromTranslate(item->x(), item->y()); d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect()); update(); } diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index e1f9f62..5d8bce5 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -2224,8 +2224,7 @@ QPolygonF QGraphicsView::mapToScene(const QRect &rect) const QPointF br = scrollOffset + r.bottomRight(); QPointF bl = scrollOffset + r.bottomLeft(); - QPolygonF poly; - poly.resize(4); + QPolygonF poly(4); if (!d->identityMatrix) { QTransform x = d->matrix.inverted(); poly[0] = x.map(tl); @@ -2328,8 +2327,7 @@ QPolygon QGraphicsView::mapFromScene(const QRectF &rect) const br -= scrollOffset; bl -= scrollOffset; - QPolygon poly; - poly.resize(4); + QPolygon poly(4); poly[0] = tl.toPoint(); poly[1] = tr.toPoint(); poly[2] = br.toPoint(); @@ -3662,8 +3660,7 @@ QRectF QGraphicsViewPrivate::mapToScene(const QRectF &rect) const QPointF br = scrollOffset + rect.bottomRight(); QPointF bl = scrollOffset + rect.bottomLeft(); - QPolygonF poly; - poly.resize(4); + QPolygonF poly(4); if (!identityMatrix) { QTransform x = matrix.inverted(); poly[0] = x.map(tl); diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 9ad9da7..e63d1aa 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -961,7 +961,8 @@ void QAbstractItemView::reset() d->currentIndexSet = false; setState(NoState); setRootIndex(QModelIndex()); - d->selectionModel->reset(); + if (d->selectionModel) + d->selectionModel->reset(); } /*! @@ -2653,7 +2654,7 @@ void QAbstractItemView::keyboardSearch(const QString &search) if (search.isEmpty() || (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) { d->keyboardInput = search; - skipRow = true; + skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0) } else { d->keyboardInput += search; } @@ -2680,6 +2681,7 @@ void QAbstractItemView::keyboardSearch(const QString &search) QModelIndex current = start; QModelIndexList match; QModelIndex firstMatch; + QModelIndex startMatch; QModelIndexList previous; do { match = d->model->match(current, Qt::DisplayRole, searchString); @@ -2696,6 +2698,12 @@ void QAbstractItemView::keyboardSearch(const QString &search) if (row >= d->model->rowCount(firstMatch.parent())) row = 0; current = firstMatch.sibling(row, firstMatch.column()); + + //avoid infinite loop if all the matching items are disabled. + if (!startMatch.isValid()) + startMatch = firstMatch; + else if (startMatch == firstMatch) + break; } } while (current != start && firstMatch.isValid()); } diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index 82d75ba..1d97340 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -1296,8 +1296,14 @@ bool QItemDelegate::editorEvent(QEvent *event, return false; } - Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked + Qt::CheckState state; + if ( flags & Qt::ItemIsTristate ) { + state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 ); + } else { + state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked); + } + return model->setData(index, state, Qt::CheckStateRole); } diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index 9dad95f..0f35ac1 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -593,10 +593,30 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare // update selectionsx QModelIndex tl = model->index(start, 0, parent); QModelIndex br = model->index(end, model->columnCount(parent) - 1, parent); - q->select(QItemSelection(tl, br), QItemSelectionModel::Deselect); + recursiveDeselect(QItemSelectionRange(tl, br)); finalize(); } +void QItemSelectionModelPrivate::recursiveDeselect(const QItemSelectionRange &range) +{ + Q_Q(QItemSelectionModel); + + QItemSelection sel(range.topLeft(), range.bottomRight()); + q->select(sel, QItemSelectionModel::Deselect); + + QModelIndexList idxList = range.indexes(); + QModelIndexList::const_iterator it = idxList.begin(); + for (; it != idxList.end(); ++it) + { + if (!model->hasChildren(*it)) + continue; + + const QModelIndex &firstChild = it->child(0,0); + const QModelIndex &lastChild = it->child(model->rowCount(*it) - 1, model->columnCount(*it) - 1); + recursiveDeselect(QItemSelectionRange(firstChild, lastChild)); + } +} + /*! \internal */ diff --git a/src/gui/itemviews/qitemselectionmodel_p.h b/src/gui/itemviews/qitemselectionmodel_p.h index 18ad506..8176d4c 100644 --- a/src/gui/itemviews/qitemselectionmodel_p.h +++ b/src/gui/itemviews/qitemselectionmodel_p.h @@ -77,6 +77,8 @@ public: void _q_layoutAboutToBeChanged(); void _q_layoutChanged(); + void recursiveDeselect(const QItemSelectionRange &range); + inline void remove(QList<QItemSelectionRange> &r) { QList<QItemSelectionRange>::const_iterator it = r.constBegin(); diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index 2565657..b518ff2 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -447,21 +447,20 @@ Qt::DropActions QListModel::supportedDropActions() const \ingroup model-view - QListWidgetItem is used to represent items in a list provided by the - QListWidget class. Each item can hold several pieces of information, - and will display these appropriately. + A QListWidgetItem represents a single item in a QListWidget. Each item can + hold several pieces of information, and will display them appropriately. - The item view convenience classes use a classic item-based interface - rather than a pure model/view approach. For a more flexible list view - widget, consider using the QListView class with a standard model. + The item view convenience classes use a classic item-based interface rather + than a pure model/view approach. For a more flexible list view widget, + consider using the QListView class with a standard model. - List items can be automatically inserted into a list when they are - constructed by specifying the list widget: + List items can be inserted automatically into a list, when they are + constructed, by specifying the list widget: \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 2 - They can also be created without a parent widget, and later inserted into - a list (see \l{QListWidget::insertItem()}). + Alternatively, list items can also be created without a parent widget, and + later inserted into a list using QListWidget::insertItem(). List items are typically used to display text() and an icon(). These are set with the setText() and setIcon() functions. The appearance of the text @@ -471,22 +470,24 @@ Qt::DropActions QListModel::supportedDropActions() const with setToolTip(), setStatusTip(), and setWhatsThis(). By default, items are enabled, selectable, checkable, and can be the source - of a drag and drop operation. + of drag and drop operations. + Each item's flags can be changed by calling setFlags() with the appropriate - value (see \l{Qt::ItemFlags}). Checkable items can be checked, unchecked and + value (see Qt::ItemFlags). Checkable items can be checked, unchecked and partially checked with the setCheckState() function. The corresponding - checkState() function indicates what check state the item currently has. + checkState() function indicates the item's current check state. + + The isHidden() function can be used to determine whether the item is + hidden. To hide an item, use setHidden(). - The isHidden() function can be used to determine whether the - item is hidden. Items can be hidden with setHidden(). \section1 Subclassing When subclassing QListWidgetItem to provide custom items, it is possible to - define new types for them so that they can be distinguished from standard - items. The constructors for subclasses that require this feature need to - call the base class constructor with a new type value equal to or greater - than \l UserType. + define new types for them enabling them to be distinguished from standard + items. For subclasses that require this feature, ensure that you call the + base class constructor with a new type value equal to or greater than + \l UserType, within \e your constructor. \sa QListWidget, {Model/View Programming}, QTreeWidgetItem, QTableWidgetItem */ @@ -515,59 +516,58 @@ Qt::DropActions QListModel::supportedDropActions() const /*! \fn QListWidget *QListWidgetItem::listWidget() const - Returns the list widget that contains the item. + Returns the list widget containing the item. */ /*! - \fn void QListWidgetItem::setSelected(bool select) - \since 4.2 + \fn void QListWidgetItem::setSelected(bool select) + \since 4.2 - Sets the selected state of the item to \a select. + Sets the selected state of the item to \a select. - \sa isSelected() + \sa isSelected() */ /*! - \fn bool QListWidgetItem::isSelected() const - \since 4.2 + \fn bool QListWidgetItem::isSelected() const + \since 4.2 - Returns true if the item is selected, otherwise returns false. + Returns true if the item is selected; otherwise returns false. - \sa setSelected() + \sa setSelected() */ /*! - \fn void QListWidgetItem::setHidden(bool hide) - \since 4.2 + \fn void QListWidgetItem::setHidden(bool hide) + \since 4.2 - Hides the item if \a hide is true, otherwise shows the item. + Hides the item if \a hide is true; otherwise shows the item. - \sa isHidden() + \sa isHidden() */ /*! - \fn bool QListWidgetItem::isHidden() const - \since 4.2 + \fn bool QListWidgetItem::isHidden() const + \since 4.2 - Returns true if the item is hidden, otherwise returns false. + Returns true if the item is hidden; otherwise returns false. - \sa setHidden() + \sa setHidden() */ /*! \fn QListWidgetItem::QListWidgetItem(QListWidget *parent, int type) Constructs an empty list widget item of the specified \a type with the - given \a parent. - If the parent is not specified, the item will need to be inserted into a - list widget with QListWidget::insertItem(). - - \note that this constructor inserts this same object into the model of - the parent that is passed to the constructor. If the model is sorted then - the behavior of the insert is undetermined since the model will call - the '<' operator method on this object which has still not yet been - constructed. In this case it would be better not to specify the parent - and use the QListWidget::insertItem method to insert the item instead. + given \a parent. If \a parent is not specified, the item will need to be + inserted into a list widget with QListWidget::insertItem(). + + This constructor inserts the item into the model of the parent that is + passed to the constructor. If the model is sorted then the behavior of the + insert is undetermined since the model will call the \c '<' operator method + on the item which, at this point, is not yet constructed. To avoid the + undetermined behavior, we recommend not to specify the parent and use + QListWidget::insertItem() instead. \sa type() */ @@ -586,16 +586,15 @@ QListWidgetItem::QListWidgetItem(QListWidget *view, int type) \fn QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *parent, int type) Constructs an empty list widget item of the specified \a type with the - given \a text and \a parent. - If the parent is not specified, the item will need to be inserted into a - list widget with QListWidget::insertItem(). - - \note that this constructor inserts this same object into the model of - the parent that is passed to the constructor. If the model is sorted then - the behavior of the insert is undetermined since the model will call - the '<' operator method on this object which has still not yet been - constructed. In this case it would be better not to specify the parent - and use the QListWidget::insertItem method to insert the item instead. + given \a text and \a parent. If the parent is not specified, the item will + need to be inserted into a list widget with QListWidget::insertItem(). + + This constructor inserts the item into the model of the parent that is + passed to the constructor. If the model is sorted then the behavior of the + insert is undetermined since the model will call the \c '<' operator method + on the item which, at this point, is not yet constructed. To avoid the + undetermined behavior, we recommend not to specify the parent and use + QListWidget::insertItem() instead. \sa type() */ @@ -616,17 +615,17 @@ QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *view, int typ \fn QListWidgetItem::QListWidgetItem(const QIcon &icon, const QString &text, QListWidget *parent, int type) Constructs an empty list widget item of the specified \a type with the - given \a icon, \a text and \a parent. - If the parent is not specified, the item will need to be inserted into a - list widget with QListWidget::insertItem(). - - \note that this constructor inserts this same object into the model of - the parent that is passed to the constructor. If the model is sorted then - the behavior of the insert is undetermined since the model will call - the '<' operator method on this object which has still not yet been - constructed. In this case it would be better not to specify the parent - and use the QListWidget::insertItem method to insert the item instead. - + given \a icon, \a text and \a parent. If the parent is not specified, the + item will need to be inserted into a list widget with + QListWidget::insertItem(). + + This constructor inserts the item into the model of the parent that is + passed to the constructor. If the model is sorted then the behavior of the + insert is undetermined since the model will call the \c '<' operator method + on the item which, at this point, is not yet constructed. To avoid the + undetermined behavior, we recommend not to specify the parent and use + QListWidget::insertItem() instead. + \sa type() */ QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text, @@ -645,7 +644,7 @@ QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text, } /*! - Destroys the list item. + Destroys the list item. */ QListWidgetItem::~QListWidgetItem() { @@ -655,7 +654,7 @@ QListWidgetItem::~QListWidgetItem() } /*! - Creates an exact copy of the item. + Creates an exact copy of the item. */ QListWidgetItem *QListWidgetItem::clone() const { @@ -663,11 +662,10 @@ QListWidgetItem *QListWidgetItem::clone() const } /*! - This function sets the data for a given \a role to the given \a value (see - \l{Qt::ItemDataRole}). Reimplement this function if you need - extra roles or special behavior for certain roles. + Sets the data for a given \a role to the given \a value. Reimplement this + function if you need extra roles or special behavior for certain roles. - \sa Qt::ItemDataRole, data() + \sa Qt::ItemDataRole, data() */ void QListWidgetItem::setData(int role, const QVariant &value) { @@ -689,9 +687,10 @@ void QListWidgetItem::setData(int role, const QVariant &value) } /*! - This function returns the item's data for a given \a role (see - Qt::ItemDataRole). Reimplement this function if you need - extra roles or special behavior for certain roles. + Returns the item's data for a given \a role. Reimplement this function if + you need extra roles or special behavior for certain roles. + + \sa Qt::ItemDataRole, setData() */ QVariant QListWidgetItem::data(int role) const { @@ -703,8 +702,8 @@ QVariant QListWidgetItem::data(int role) const } /*! - Returns true if this item's text is less then \a other item's text; - otherwise returns false. + Returns true if this item's text is less then \a other item's text; + otherwise returns false. */ bool QListWidgetItem::operator<(const QListWidgetItem &other) const { @@ -740,8 +739,8 @@ void QListWidgetItem::write(QDataStream &out) const /*! \since 4.1 - Constructs a copy of \a other. Note that type() and listWidget() - are not copied. + Constructs a copy of \a other. Note that type() and listWidget() are not + copied. This function is useful when reimplementing clone(). @@ -756,8 +755,8 @@ QListWidgetItem::QListWidgetItem(const QListWidgetItem &other) } /*! - Assigns \a other's data and flags to this item. Note that type() - and listWidget() are not copied. + Assigns \a other's data and flags to this item. Note that type() and + listWidget() are not copied. This function is useful when reimplementing clone(). @@ -805,9 +804,9 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) #endif // QT_NO_DATASTREAM /*! - \fn Qt::ItemFlags QListWidgetItem::flags() const + \fn Qt::ItemFlags QListWidgetItem::flags() const - Returns the item flags for this item (see \l{Qt::ItemFlags}). + Returns the item flags for this item (see \l{Qt::ItemFlags}). */ /*! @@ -851,15 +850,17 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) */ /*! - \fn QFont QListWidgetItem::font() const + \fn QFont QListWidgetItem::font() const - Returns the font used to display this list item's text. + Returns the font used to display this list item's text. */ /*! - \fn int QListWidgetItem::textAlignment() const + \fn int QListWidgetItem::textAlignment() const - Returns the text alignment for the list item (see \l{Qt::AlignmentFlag}). + Returns the text alignment for the list item. + + \sa Qt::AlignmentFlag */ /*! @@ -905,26 +906,26 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) */ /*! - \fn QSize QListWidgetItem::sizeHint() const - \since 4.1 + \fn QSize QListWidgetItem::sizeHint() const + \since 4.1 - Returns the size hint set for the list item. + Returns the size hint set for the list item. */ /*! - \fn void QListWidgetItem::setSizeHint(const QSize &size) - \since 4.1 + \fn void QListWidgetItem::setSizeHint(const QSize &size) + \since 4.1 - Sets the size hint for the list item to be \a size. - If no size hint is set, the item delegate will compute the - size hint based on the item data. + Sets the size hint for the list item to be \a size. If no size hint is set, + the item delegate will compute the size hint based on the item data. */ /*! - \fn void QListWidgetItem::setFlags(Qt::ItemFlags flags) + \fn void QListWidgetItem::setFlags(Qt::ItemFlags flags) - Sets the item flags for the list item to \a flags (see - \l{Qt::ItemFlags}). + Sets the item flags for the list item to \a flags. + + \sa Qt::ItemFlags */ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) { itemFlags = aflags; @@ -953,10 +954,10 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) { \fn void QListWidgetItem::setStatusTip(const QString &statusTip) Sets the status tip for the list item to the text specified by - \a statusTip. QListWidget mouse tracking needs to be enabled for this + \a statusTip. QListWidget mouseTracking needs to be enabled for this feature to work. - \sa statusTip() setToolTip() setWhatsThis() + \sa statusTip(), setToolTip(), setWhatsThis(), QWidget::setMouseTracking() */ /*! @@ -964,29 +965,30 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) { Sets the tooltip for the list item to the text specified by \a toolTip. - \sa toolTip() setStatusTip() setWhatsThis() + \sa toolTip(), setStatusTip(), setWhatsThis() */ /*! \fn void QListWidgetItem::setWhatsThis(const QString &whatsThis) - Sets the "What's This?" help for the list item to the text specified - by \a whatsThis. + Sets the "What's This?" help for the list item to the text specified by + \a whatsThis. - \sa whatsThis() setStatusTip() setToolTip() + \sa whatsThis(), setStatusTip(), setToolTip() */ /*! - \fn void QListWidgetItem::setFont(const QFont &font) + \fn void QListWidgetItem::setFont(const QFont &font) - Sets the font used when painting the item to the given \a font. + Sets the font used when painting the item to the given \a font. */ /*! - \fn void QListWidgetItem::setTextAlignment(int alignment) + \fn void QListWidgetItem::setTextAlignment(int alignment) + + Sets the list item's text alignment to \a alignment. - Sets the list item's text alignment to \a alignment (see - \l{Qt::AlignmentFlag}). + \sa Qt::AlignmentFlag */ /*! @@ -1127,10 +1129,10 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, \ingroup model-view \mainclass - QListWidget is a convenience class that provides a list view similar to - the one supplied by QListView, but with a classic item-based interface - for adding and removing items. QListWidget uses an internal model to - manage each QListWidgetItem in the list. + QListWidget is a convenience class that provides a list view similar to the + one supplied by QListView, but with a classic item-based interface for + adding and removing items. QListWidget uses an internal model to manage + each QListWidgetItem in the list. For a more flexible list view widget, use the QListView class with a standard model. @@ -1145,23 +1147,23 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, function. There are two ways to add items to the list: they can be constructed with - the list widget as their parent widget, or they can be constructed with - no parent widget and added to the list later. If a list widget already - exists when the items are constructed, the first method is easier to use: + the list widget as their parent widget, or they can be constructed with no + parent widget and added to the list later. If a list widget already exists + when the items are constructed, the first method is easier to use: \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 1 - If you need to insert a new item into the list at a particular position, - it is more required to construct the item without a parent widget and - use the insertItem() function to place it within the list. The list - widget will take ownership of the item. + If you need to insert a new item into the list at a particular position, it + is more required to construct the item without a parent widget and use the + insertItem() function to place it within the list. The list widget will + take ownership of the item. \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 6 \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 7 - For multiple items, insertItems() can be used instead. The number of - items in the list is found with the count() function. - To remove items from the list, use takeItem(). + For multiple items, insertItems() can be used instead. The number of items + in the list is found with the count() function. To remove items from the + list, use takeItem(). The current item in the list can be found with currentItem(), and changed with setCurrentItem(). The user can also change the current item by @@ -1187,9 +1189,9 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, Inserts the \a item at the end of the list widget. - \warning A QListWidgetItem can only be added to a - QListWidget once. Adding the same QListWidgetItem multiple - times to a QListWidget will result in undefined behavior. + \warning A QListWidgetItem can only be added to a QListWidget once. Adding + the same QListWidgetItem multiple times to a QListWidget will result in + undefined behavior. \sa insertItem() */ @@ -1197,8 +1199,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, /*! \fn void QListWidget::addItem(const QString &label) - Inserts an item with the text \a label at the end of the list - widget. + Inserts an item with the text \a label at the end of the list widget. */ /*! @@ -1212,8 +1213,8 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, /*! \fn void QListWidget::itemPressed(QListWidgetItem *item) - This signal is emitted with the specified \a item when a mouse button is pressed - on an item in the widget. + This signal is emitted with the specified \a item when a mouse button is + pressed on an item in the widget. \sa itemClicked(), itemDoubleClicked() */ @@ -1221,8 +1222,8 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, /*! \fn void QListWidget::itemClicked(QListWidgetItem *item) - This signal is emitted with the specified \a item when a mouse button is clicked - on an item in the widget. + This signal is emitted with the specified \a item when a mouse button is + clicked on an item in the widget. \sa itemPressed(), itemDoubleClicked() */ @@ -1230,8 +1231,8 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, /*! \fn void QListWidget::itemDoubleClicked(QListWidgetItem *item) - This signal is emitted with the specified \a item when a mouse button is double - clicked on an item in the widget. + This signal is emitted with the specified \a item when a mouse button is + double clicked on an item in the widget. \sa itemClicked(), itemPressed() */ @@ -1239,20 +1240,21 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, /*! \fn void QListWidget::itemActivated(QListWidgetItem *item) - This signal is emitted when the \a item is activated. The \a item - is activated when the user clicks or double clicks on it, - depending on the system configuration. It is also activated when - the user presses the activation key (on Windows and X11 this is - the \gui Return key, on Mac OS X it is \key{Ctrl+0}). + This signal is emitted when the \a item is activated. The \a item is + activated when the user clicks or double clicks on it, depending on the + system configuration. It is also activated when the user presses the + activation key (on Windows and X11 this is the \gui Return key, on Mac OS + X it is \key{Ctrl+0}). */ /*! \fn void QListWidget::itemEntered(QListWidgetItem *item) - This signal is emitted when the mouse cursor enters an item. The - \a item is the item entered. This signal is only emitted when - mouseTracking is turned on, or when a mouse button is pressed - while moving into an item. + This signal is emitted when the mouse cursor enters an item. The \a item is + the item entered. This signal is only emitted when mouseTracking is turned + on, or when a mouse button is pressed while moving into an item. + + \sa QWidget::setMouseTracking() */ /*! @@ -1264,24 +1266,28 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, /*! \fn void QListWidget::currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) - This signal is emitted whenever the current item changes. The \a - previous item is the item that previously had the focus, \a - current is the new current item. + This signal is emitted whenever the current item changes. + + \a previous is the item that previously had the focus; \a current is the + new current item. */ /*! - \fn void QListWidget::currentTextChanged(const QString ¤tText) + \fn void QListWidget::currentTextChanged(const QString ¤tText) - This signal is emitted whenever the current item changes. The \a currentText - is the text data in the current item. If there is no current item, the \a currentText - is invalid. + This signal is emitted whenever the current item changes. + + \a currentText is the text data in the current item. If there is no current + item, the \a currentText is invalid. */ /*! - \fn void QListWidget::currentRowChanged(int currentRow) + \fn void QListWidget::currentRowChanged(int currentRow) + + This signal is emitted whenever the current item changes. - This signal is emitted whenever the current item changes. The \a currentRow - is the row of the current item. If there is no current item, the \a currentRow is -1. + \a currentRow is the row of the current item. If there is no current item, + the \a currentRow is -1. */ /*! @@ -1289,15 +1295,15 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, This signal is emitted whenever the selection changes. - \sa selectedItems() QListWidgetItem::isSelected() currentItemChanged() + \sa selectedItems(), QListWidgetItem::isSelected(), currentItemChanged() */ /*! - \since 4.3 + \since 4.3 - \fn void QListWidget::removeItemWidget(QListWidgetItem *item) + \fn void QListWidget::removeItemWidget(QListWidgetItem *item) - Removes the widget set on the given \a item. + Removes the widget set on the given \a item. */ /*! @@ -1361,8 +1367,8 @@ void QListWidget::insertItem(int row, QListWidgetItem *item) } /*! - Inserts an item with the text \a label in the list widget at the - position given by \a row. + Inserts an item with the text \a label in the list widget at the position + given by \a row. \sa addItem() */ @@ -1387,11 +1393,11 @@ void QListWidget::insertItems(int row, const QStringList &labels) } /*! - Removes and returns the item from the given \a row in the list widget; otherwise - returns 0. + Removes and returns the item from the given \a row in the list widget; + otherwise returns 0. - Items removed from a list widget will not be managed by Qt, and will need to be - deleted manually. + Items removed from a list widget will not be managed by Qt, and will need + to be deleted manually. \sa insertItem(), addItem() */ @@ -1405,8 +1411,8 @@ QListWidgetItem *QListWidget::takeItem(int row) } /*! - \property QListWidget::count - \brief the number of items in the list including any hidden items. + \property QListWidget::count + \brief the number of items in the list including any hidden items. */ int QListWidget::count() const @@ -1416,7 +1422,7 @@ int QListWidget::count() const } /*! - Returns the current item. + Returns the current item. */ QListWidgetItem *QListWidget::currentItem() const { @@ -1426,9 +1432,9 @@ QListWidgetItem *QListWidget::currentItem() const /*! - Sets the current item to \a item. + Sets the current item to \a item. - Depending on the current selection mode, the item may also be selected. + Depending on the current selection mode, the item may also be selected. */ void QListWidget::setCurrentItem(QListWidgetItem *item) { @@ -1436,8 +1442,8 @@ void QListWidget::setCurrentItem(QListWidgetItem *item) } /*! - \since 4.4 - Set the current item to \a item, using the given \a command. + \since 4.4 + Set the current item to \a item, using the given \a command. */ void QListWidget::setCurrentItem(QListWidgetItem *item, QItemSelectionModel::SelectionFlags command) { @@ -1445,10 +1451,10 @@ void QListWidget::setCurrentItem(QListWidgetItem *item, QItemSelectionModel::Sel } /*! - \property QListWidget::currentRow - \brief the row of the current item. + \property QListWidget::currentRow + \brief the row of the current item. - Depending on the current selection mode, the row may also be selected. + Depending on the current selection mode, the row may also be selected. */ int QListWidget::currentRow() const @@ -1469,9 +1475,9 @@ void QListWidget::setCurrentRow(int row) } /*! - \since 4.4 + \since 4.4 - Sets the current row to be the given \a row, using the given \a command, + Sets the current row to be the given \a row, using the given \a command, */ void QListWidget::setCurrentRow(int row, QItemSelectionModel::SelectionFlags command) { @@ -1498,7 +1504,7 @@ QListWidgetItem *QListWidget::itemAt(const QPoint &p) const /*! - Returns the rectangle on the viewport occupied by the item at \a item. + Returns the rectangle on the viewport occupied by the item at \a item. */ QRect QListWidget::visualItemRect(const QListWidgetItem *item) const { @@ -1508,7 +1514,7 @@ QRect QListWidget::visualItemRect(const QListWidgetItem *item) const } /*! - Sorts all the items in the list widget according to the specified \a order. + Sorts all the items in the list widget according to the specified \a order. */ void QListWidget::sortItems(Qt::SortOrder order) { @@ -1522,8 +1528,10 @@ void QListWidget::sortItems(Qt::SortOrder order) \property QListWidget::sortingEnabled \brief whether sorting is enabled - If this property is true, sorting is enabled for the list; if the - property is false, sorting is not enabled. The default value is false. + If this property is true, sorting is enabled for the list; if the property + is false, sorting is not enabled. + + The default value is false. */ void QListWidget::setSortingEnabled(bool enable) { @@ -1538,7 +1546,7 @@ bool QListWidget::isSortingEnabled() const } /*! - \internal + \internal */ Qt::SortOrder QListWidget::sortOrder() const { @@ -1547,7 +1555,7 @@ Qt::SortOrder QListWidget::sortOrder() const } /*! - Starts editing the \a item if it is editable. + Starts editing the \a item if it is editable. */ void QListWidget::editItem(QListWidgetItem *item) @@ -1557,9 +1565,10 @@ void QListWidget::editItem(QListWidgetItem *item) } /*! - Opens an editor for the given \a item. The editor remains open after editing. + Opens an editor for the given \a item. The editor remains open after + editing. - \sa closePersistentEditor() + \sa closePersistentEditor() */ void QListWidget::openPersistentEditor(QListWidgetItem *item) { @@ -1569,9 +1578,9 @@ void QListWidget::openPersistentEditor(QListWidgetItem *item) } /*! - Closes the persistent editor for the given \a item. + Closes the persistent editor for the given \a item. - \sa openPersistentEditor() + \sa openPersistentEditor() */ void QListWidget::closePersistentEditor(QListWidgetItem *item) { @@ -1597,9 +1606,10 @@ QWidget *QListWidget::itemWidget(QListWidgetItem *item) const Sets the \a widget to be displayed in the give \a item. - This function should only be used to display static content in the place of a list - widget item. If you want to display custom dynamic content or implement a custom - editor widget, use QListView and subclass QItemDelegate instead. + This function should only be used to display static content in the place of + a list widget item. If you want to display custom dynamic content or + implement a custom editor widget, use QListView and subclass QItemDelegate + instead. \sa {Delegate Classes} */ @@ -1611,11 +1621,11 @@ void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget) } /*! - Returns true if \a item is selected; otherwise returns false. + Returns true if \a item is selected; otherwise returns false. - \obsolete + \obsolete - This function is deprecated. Use \l{QListWidgetItem::isSelected()} instead. + This function is deprecated. Use QListWidgetItem::isSelected() instead. */ bool QListWidget::isItemSelected(const QListWidgetItem *item) const { @@ -1625,12 +1635,12 @@ bool QListWidget::isItemSelected(const QListWidgetItem *item) const } /*! - Selects or deselects the given \a item depending on whether \a select is - true of false. + Selects or deselects the given \a item depending on whether \a select is + true of false. - \obsolete + \obsolete - This function is deprecated. Use \l{QListWidgetItem::setSelected()} instead. + This function is deprecated. Use QListWidgetItem::setSelected() instead. */ void QListWidget::setItemSelected(const QListWidgetItem *item, bool select) { @@ -1650,7 +1660,7 @@ void QListWidget::setItemSelected(const QListWidgetItem *item, bool select) } /*! - Returns a list of all selected items in the list widget. + Returns a list of all selected items in the list widget. */ QList<QListWidgetItem*> QListWidget::selectedItems() const @@ -1664,7 +1674,8 @@ QList<QListWidgetItem*> QListWidget::selectedItems() const } /*! - Finds items with the text that matches the string \a text using the given \a flags. + Finds items with the text that matches the string \a text using the given + \a flags. */ QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFlags flags) const @@ -1679,11 +1690,11 @@ QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFla } /*! - Returns true if the \a item is explicitly hidden; otherwise returns false. + Returns true if the \a item is explicitly hidden; otherwise returns false. - \obsolete + \obsolete - This function is deprecated. Use \l{QListWidgetItem::isHidden()} instead. + This function is deprecated. Use QListWidgetItem::isHidden() instead. */ bool QListWidget::isItemHidden(const QListWidgetItem *item) const { @@ -1691,11 +1702,11 @@ bool QListWidget::isItemHidden(const QListWidgetItem *item) const } /*! - If \a hide is true, the \a item will be hidden; otherwise it will be shown. + If \a hide is true, the \a item will be hidden; otherwise it will be shown. - \obsolete + \obsolete - This function is deprecated. Use \l{QListWidgetItem::setHidden()} instead. + This function is deprecated. Use QListWidgetItem::setHidden() instead. */ void QListWidget::setItemHidden(const QListWidgetItem *item, bool hide) { @@ -1703,9 +1714,9 @@ void QListWidget::setItemHidden(const QListWidgetItem *item, bool hide) } /*! - Scrolls the view if necessary to ensure that the \a item is - visible. The \a hint parameter specifies more precisely where the - \a item should be located after the operation. + Scrolls the view if necessary to ensure that the \a item is visible. + + \a hint specifies where the \a item should be located after the operation. */ void QListWidget::scrollToItem(const QListWidgetItem *item, QAbstractItemView::ScrollHint hint) @@ -1718,7 +1729,7 @@ void QListWidget::scrollToItem(const QListWidgetItem *item, QAbstractItemView::S /*! Removes all items and selections in the view. - \note All items will be permanently deleted. + \warning All items will be permanently deleted. */ void QListWidget::clear() { @@ -1743,8 +1754,8 @@ QStringList QListWidget::mimeTypes() const \a items. The format used to describe the items is obtained from the mimeTypes() function. - If the list of items is empty, 0 is returned rather than a serialized - empty list. + If the list of items is empty, 0 is returned instead of a serialized empty + list. */ QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*>) const { @@ -1753,10 +1764,9 @@ QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*>) const #ifndef QT_NO_DRAGANDDROP /*! - Handles the \a data supplied by an external drag and drop operation - that ended with the given \a action in the given \a index. - Returns true if the data and action can be handled by the model; - otherwise returns false. + Handles \a data supplied by an external drag and drop operation that ended + with the given \a action in the given \a index. Returns true if \a data and + \a action can be handled by the model; otherwise returns false. \sa supportedDropActions() */ @@ -1823,9 +1833,9 @@ void QListWidget::dropEvent(QDropEvent *event) { } /*! - Returns the drop actions supported by this view. + Returns the drop actions supported by this view. - \sa Qt::DropActions + \sa Qt::DropActions */ Qt::DropActions QListWidget::supportedDropActions() const { @@ -1835,9 +1845,9 @@ Qt::DropActions QListWidget::supportedDropActions() const #endif // QT_NO_DRAGANDDROP /*! - Returns a list of pointers to the items contained in the \a data object. - If the object was not created by a QListWidget in the same process, the list - is empty. + Returns a list of pointers to the items contained in the \a data object. If + the object was not created by a QListWidget in the same process, the list + is empty. */ QList<QListWidgetItem*> QListWidget::items(const QMimeData *data) const { @@ -1848,7 +1858,7 @@ QList<QListWidgetItem*> QListWidget::items(const QMimeData *data) const } /*! - Returns the QModelIndex assocated with the given \a item. + Returns the QModelIndex assocated with the given \a item. */ QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const @@ -1858,7 +1868,7 @@ QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const } /*! - Returns a pointer to the QListWidgetItem assocated with the given \a index. + Returns a pointer to the QListWidgetItem assocated with the given \a index. */ QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const @@ -1870,7 +1880,7 @@ QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const } /*! - \internal + \internal */ void QListWidget::setModel(QAbstractItemModel * /*model*/) { diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp index 25acbc4..535f903 100644 --- a/src/gui/itemviews/qstandarditemmodel.cpp +++ b/src/gui/itemviews/qstandarditemmodel.cpp @@ -1742,15 +1742,17 @@ QList<QStandardItem*> QStandardItem::takeRow(int row) if (d->model) d->model->d_func()->rowsAboutToBeRemoved(this, row, row); QList<QStandardItem*> items; - int index = d->childIndex(row, 0); - int col_count = d->columnCount(); - for (int column = 0; column < col_count; ++column) { - QStandardItem *ch = d->children.at(index + column); - if (ch) - ch->d_func()->setParentAndModel(0, 0); - items.append(ch); + int index = d->childIndex(row, 0); // Will return -1 if there are no columns + if (index != -1) { + int col_count = d->columnCount(); + for (int column = 0; column < col_count; ++column) { + QStandardItem *ch = d->children.at(index + column); + if (ch) + ch->d_func()->setParentAndModel(0, 0); + items.append(ch); + } + d->children.remove(index, col_count); } - d->children.remove(index, col_count); d->rows--; if (d->model) d->model->d_func()->rowsRemoved(this, row, 1); diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index f64a8ea..c739812 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -746,8 +746,13 @@ bool QStyledItemDelegate::editorEvent(QEvent *event, return false; } - Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked + Qt::CheckState state; + if ( flags & Qt::ItemIsTristate ) { + state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 ); + } else { + state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked); + } return model->setData(index, state, Qt::CheckStateRole); } diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 1766ecd..531c283 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -121,7 +121,8 @@ unix:x11 { INCLUDEPATH += ../3rdparty/xorg HEADERS += \ kernel/qx11embed_x11.h \ - kernel/qx11info_x11.h + kernel/qx11info_x11.h \ + kernel/qkde_p.h SOURCES += \ kernel/qapplication_x11.cpp \ @@ -135,7 +136,8 @@ unix:x11 { kernel/qwidgetcreate_x11.cpp \ kernel/qx11embed_x11.cpp \ kernel/qx11info_x11.cpp \ - kernel/qkeymapper_x11.cpp + kernel/qkeymapper_x11.cpp \ + kernel/qkde.cpp contains(QT_CONFIG, glib) { SOURCES += \ diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 0cd93b9..dc8ea6c 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -235,6 +235,8 @@ typedef struct tagGESTUREINFO # define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002 # define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004 +# define GC_ZOOM 0x00000001 + typedef struct tagGESTURECONFIG { DWORD dwID; @@ -248,11 +250,12 @@ typedef struct tagGESTURECONFIG class QPanGesture; class QPinchGesture; -struct StandardGestures +struct QStandardGestures { QPanGesture *pan; QPinchGesture *pinch; - StandardGestures() : pan(0), pinch(0) { } + + QStandardGestures() : pan(0), pinch(0) { } }; @@ -282,7 +285,6 @@ public: #if defined(Q_WS_X11) #ifndef QT_NO_SETTINGS - static QString kdeHome(); static QString x11_desktop_style(); static bool x11_apply_settings(); #endif @@ -519,6 +521,9 @@ public: QTouchEvent::DeviceType deviceType, const QList<QTouchEvent::TouchPoint> &touchPoints); + typedef QMap<QWidget*, QStandardGestures> WidgetStandardGesturesMap; + WidgetStandardGesturesMap widgetGestures; + #if defined(Q_WS_WIN) static PtrRegisterTouchWindow RegisterTouchWindow; static PtrGetTouchInputInfo GetTouchInputInfo; @@ -528,10 +533,6 @@ public: QList<QTouchEvent::TouchPoint> appAllTouchPoints; bool translateTouchEvent(const MSG &msg); - typedef QMap<QWidget*, StandardGestures> WidgetStandardGesturesMap; - WidgetStandardGesturesMap widgetGestures; - ulong lastGestureId; - PtrGetGestureInfo GetGestureInfo; PtrGetGestureExtraArgs GetGestureExtraArgs; PtrCloseGestureInfoHandle CloseGestureInfoHandle; diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 2bded5c..bdee6ec 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -815,8 +815,6 @@ void qt_init(QApplicationPrivate *priv, int) ptrSetProcessDPIAware(); #endif - priv->lastGestureId = 0; - priv->GetGestureInfo = (PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"), "GetGestureInfo"); @@ -3718,13 +3716,8 @@ bool QETWidget::translateCloseEvent(const MSG &) bool QETWidget::translateGestureEvent(const MSG &msg) { GESTUREINFO gi; + memset(&gi, 0, sizeof(GESTUREINFO)); gi.cbSize = sizeof(GESTUREINFO); - gi.dwFlags = 0; - gi.ptsLocation.x = 0; - gi.ptsLocation.y = 0; - gi.dwID = 0; - gi.dwInstanceID = 0; - gi.dwSequenceID = 0; QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal(); BOOL bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi); @@ -3747,7 +3740,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg) event.gestureType = QNativeGestureEvent::GestureEnd; break; case GID_ZOOM: - event.gestureType = QNativeGestureEvent::Pinch; + event.gestureType = QNativeGestureEvent::Zoom; break; case GID_PAN: event.gestureType = QNativeGestureEvent::Pan; @@ -3758,6 +3751,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg) default: break; } + qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam); if (event.gestureType != QNativeGestureEvent::None) qt_sendSpontaneousEvent(widget, &event); } else { @@ -3765,7 +3759,6 @@ bool QETWidget::translateGestureEvent(const MSG &msg) if (dwErr > 0) qWarning() << "translateGestureEvent: error = " << dwErr; } - qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam); return true; } diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 4016563..32e7e3c 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -83,6 +83,7 @@ #include "qtimer.h" #include "qlibrary.h" #include <private/qgraphicssystemfactory_p.h> +#include "qkde_p.h" #if !defined (QT_NO_TABLET) extern "C" { @@ -813,33 +814,6 @@ Q_GUI_EXPORT void qt_x11_apply_settings_in_all_apps() PropModeReplace, (unsigned char *)stamp.data(), stamp.size()); } -static int kdeSessionVersion() -{ - static int kdeVersion = 0; - if (!kdeVersion) - kdeVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt(); - return kdeVersion; -} - -/*! \internal - Gets the current KDE 3 or 4 home path -*/ -QString QApplicationPrivate::kdeHome() -{ - static QString kdeHomePath; - if (kdeHomePath.isEmpty()) { - kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME")); - if (kdeHomePath.isEmpty()) { - QDir homeDir(QDir::homePath()); - QString kdeConfDir(QLatin1String("/.kde")); - if (4 == kdeSessionVersion() && homeDir.exists(QLatin1String(".kde4"))) - kdeConfDir = QLatin1String("/.kde4"); - kdeHomePath = QDir::homePath() + kdeConfDir; - } - } - return kdeHomePath; -} - /*! \internal apply the settings to the application */ @@ -905,8 +879,8 @@ bool QApplicationPrivate::x11_apply_settings() QFont font(QApplication::font()); QString fontDescription; // Override Qt font if KDE4 settings can be used - if (4 == kdeSessionVersion()) { - QSettings kdeSettings(kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); + if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4) { + QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); fontDescription = kdeSettings.value(QLatin1String("font")).toString(); if (fontDescription.isEmpty()) { // KDE stores fonts without quotes @@ -936,7 +910,6 @@ bool QApplicationPrivate::x11_apply_settings() // read new QStyle QString stylename = settings.value(QLatin1String("style")).toString(); - if (stylename.isEmpty() && QApplicationPrivate::styleOverride.isNull() && X11->use_xrender) { stylename = x11_desktop_style(); } @@ -1094,22 +1067,6 @@ static void qt_set_input_encoding() XFree((char *)data); } -// Reads a KDE color setting -static QColor kdeColor(const QString &key, const QSettings &kdeSettings) -{ - QVariant variant = kdeSettings.value(key); - if (variant.isValid()) { - QStringList values = variant.toStringList(); - if (values.size() == 3) { - int r = values[0].toInt(); - int g = values[1].toInt(); - int b = values[2].toInt(); - return QColor(r, g, b); - } - } - return QColor(); -} - // set font, foreground and background from x11 resources. The // arguments may override the resource settings. static void qt_set_x11_resources(const char* font = 0, const char* fg = 0, @@ -1276,9 +1233,10 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0, QApplicationPrivate::setSystemFont(fnt); } + // QGtkStyle sets it's own system palette + bool gtkStyle = QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"); bool kdeColors = (QApplication::desktopSettingsAware() && X11->desktopEnvironment == DE_KDE); - - if (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty())) {// set app colors + if (!gtkStyle && (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty()))) {// set app colors bool allowX11ColorNames = QColor::allowX11ColorNames(); QColor::setAllowX11ColorNames(true); @@ -1314,45 +1272,6 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0, bright_mode = true; } - if (kdeColors) { - const QSettings theKdeSettings( - QApplicationPrivate::kdeHome() - + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); - - // Setup KDE palette - QColor color; - color = kdeColor(QLatin1String("buttonBackground"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Button/BackgroundNormal"), theKdeSettings); - if (color.isValid()) - btn = color; - - color = kdeColor(QLatin1String("background"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Window/BackgroundNormal"), theKdeSettings); - if (color.isValid()) - bg = color; - - color = kdeColor(QLatin1String("foreground"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:View/ForegroundNormal"), theKdeSettings); - if (color.isValid()) { - fg = color; - } - - color = kdeColor(QLatin1String("windowForeground"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Window/ForegroundNormal"), theKdeSettings); - if (color.isValid()) - wfg = color; - - color = kdeColor(QLatin1String("windowBackground"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:View/BackgroundNormal"), theKdeSettings); - if (color.isValid()) - base = color; - } - QPalette pal(fg, btn, btn.lighter(125), btn.darker(130), btn.darker(120), wfg.isValid() ? wfg : fg, Qt::white, base, bg); QColor disabled((fg.red() + btn.red()) / 2, (fg.green() + btn.green())/ 2, @@ -1365,50 +1284,6 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0, highlight = QColor(selectBackground); highlightText = QColor(selectForeground); } - // Use KDE3 or KDE4 color settings if present - if (kdeColors) { - const QSettings theKdeSettings( - QApplicationPrivate::kdeHome() - + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); - - QColor color = kdeColor(QLatin1String("selectBackground"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Selection/BackgroundNormal"), theKdeSettings); - if (color.isValid()) - highlight = color; - - color = kdeColor(QLatin1String("selectForeground"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Selection/ForegroundNormal"), theKdeSettings); - if (color.isValid()) - highlightText = color; - - color = kdeColor(QLatin1String("alternateBackground"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:View/BackgroundAlternate"), theKdeSettings); - if (color.isValid()) - pal.setColor(QPalette::AlternateBase, color); - else - pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(110)); - - color = kdeColor(QLatin1String("buttonForeground"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Button/ForegroundNormal"), theKdeSettings); - if (color.isValid()) - pal.setColor(QPalette::ButtonText, color); - - color = kdeColor(QLatin1String("linkColor"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:View/ForegroundLink"), theKdeSettings); - if (color.isValid()) - pal.setColor(QPalette::Link, color); - - color = kdeColor(QLatin1String("visitedLinkColor"), theKdeSettings); - if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:View/ForegroundVisited"), theKdeSettings); - if (color.isValid()) - pal.setColor(QPalette::LinkVisited, color); - } if (highlight.isValid() && highlightText.isValid()) { pal.setColor(QPalette::Highlight, highlight); @@ -1431,10 +1306,9 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0, pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::darkBlue); } - // QGtkStyle sets it's own system palette - if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) { - QApplicationPrivate::setSystemPalette(pal); - } + if (kdeColors) + pal = QKde::kdePalette().resolve(pal); + QApplicationPrivate::setSystemPalette(pal); QColor::setAllowX11ColorNames(allowX11ColorNames); } @@ -2315,6 +2189,7 @@ void qt_init(QApplicationPrivate *priv, int, X11->compositingManagerRunning = XGetSelectionOwner(X11->display, ATOM(_NET_WM_CM_S0)); X11->desktopEnvironment = DE_UNKNOWN; + X11->desktopVersion = 0; // See if the current window manager is using the freedesktop.org spec to give its name Window windowManagerWindow = XNone; @@ -2390,6 +2265,9 @@ void qt_init(QApplicationPrivate *priv, int, XFree((char *)data); } + if (X11->desktopEnvironment == DE_KDE) + X11->desktopVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt(); + qt_set_input_encoding(); qt_set_x11_resources(appFont, appFGCol, appBGCol, appBTNCol); @@ -2657,44 +2535,30 @@ void qt_init(QApplicationPrivate *priv, int, QString QApplicationPrivate::x11_desktop_style() { QString stylename; - QStringList availableStyles = QStyleFactory::keys(); - // Override Qt style if KDE4 settings can be used - if (4 == kdeSessionVersion()) { - QSettings kdeSettings(kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); - QString kde4Style = kdeSettings.value(QLatin1String("widgetStyle"), - QLatin1String("Oxygen")).toString(); - foreach (const QString &style, availableStyles) { - if (style.toLower() == kde4Style.toLower()) - stylename = kde4Style; - } - // Set QGtkStyle for GNOME - } else if (X11->desktopEnvironment == DE_GNOME) { + switch(X11->desktopEnvironment) { + case DE_KDE: + stylename = QKde::kdeStyle(); + break; + case DE_GNOME: { + QStringList availableStyles = QStyleFactory::keys(); + // Set QGtkStyle for GNOME if available QString gtkStyleKey = QString::fromLatin1("GTK+"); - if (availableStyles.contains(gtkStyleKey)) + if (availableStyles.contains(gtkStyleKey)) { stylename = gtkStyleKey; - } - - if (stylename.isEmpty()) { - switch(X11->desktopEnvironment) { - case DE_KDE: - if (X11->use_xrender) - stylename = QLatin1String("plastique"); - else - stylename = QLatin1String("windows"); - break; - case DE_GNOME: - if (X11->use_xrender) - stylename = QLatin1String("cleanlooks"); - else - stylename = QLatin1String("windows"); - break; - case DE_CDE: - stylename = QLatin1String("cde"); - break; - default: - // Don't do anything break; } + if (X11->use_xrender) + stylename = QLatin1String("cleanlooks"); + else + stylename = QLatin1String("windows"); + break; + } + case DE_CDE: + stylename = QLatin1String("cde"); + break; + default: + // Don't do anything + break; } return stylename; } diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 1d352cb..8c6f394 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -50,6 +50,7 @@ #include <private/qdnd_p.h> #include <private/qmacinputcontext_p.h> #include <private/qmultitouch_mac_p.h> +#include <private/qevent_p.h> #include <qscrollarea.h> #include <qhash.h> @@ -868,32 +869,65 @@ extern "C" { - (void)magnifyWithEvent:(NSEvent *)event; { - Q_UNUSED(event); -// qDebug() << "magnifyWithEvent"; + if (!QApplicationPrivate::tryModalHelper(qwidget, 0)) + return; + + QNativeGestureEvent qNGEvent; + qNGEvent.gestureType = QNativeGestureEvent::Zoom; + NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; + qNGEvent.position = flipPoint(p).toPoint(); + qNGEvent.percentage = [event magnification]; + qApp->sendEvent(qwidget, &qNGEvent); } - (void)rotateWithEvent:(NSEvent *)event; { - Q_UNUSED(event); -// qDebug() << "rotateWithEvent"; + if (!QApplicationPrivate::tryModalHelper(qwidget, 0)) + return; + + QNativeGestureEvent qNGEvent; + qNGEvent.gestureType = QNativeGestureEvent::Rotate; + NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; + qNGEvent.position = flipPoint(p).toPoint(); + qNGEvent.percentage = [event rotation]; + qApp->sendEvent(qwidget, &qNGEvent); } - (void)swipeWithEvent:(NSEvent *)event; { - Q_UNUSED(event); -// qDebug() << "swipeWithEvent"; + if (!QApplicationPrivate::tryModalHelper(qwidget, 0)) + return; + + QNativeGestureEvent qNGEvent; + qNGEvent.gestureType = QNativeGestureEvent::Swipe; + NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; + qNGEvent.position = flipPoint(p).toPoint(); + qNGEvent.direction = QSize(-[event deltaX], -[event deltaY]); + qApp->sendEvent(qwidget, &qNGEvent); } - (void)beginGestureWithEvent:(NSEvent *)event; { - Q_UNUSED(event); -// qDebug() << "beginGestureWithEvent"; + if (!QApplicationPrivate::tryModalHelper(qwidget, 0)) + return; + + QNativeGestureEvent qNGEvent; + qNGEvent.gestureType = QNativeGestureEvent::GestureBegin; + NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; + qNGEvent.position = flipPoint(p).toPoint(); + qApp->sendEvent(qwidget, &qNGEvent); } - (void)endGestureWithEvent:(NSEvent *)event; { - Q_UNUSED(event); -// qDebug() << "endGestureWithEvent"; + if (!QApplicationPrivate::tryModalHelper(qwidget, 0)) + return; + + QNativeGestureEvent qNGEvent; + qNGEvent.gestureType = QNativeGestureEvent::GestureEnd; + NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]]; + qNGEvent.position = flipPoint(p).toPoint(); + qApp->sendEvent(qwidget, &qNGEvent); } #endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 diff --git a/src/gui/kernel/qdesktopwidget_x11.cpp b/src/gui/kernel/qdesktopwidget_x11.cpp index 5bc4c0c..ad47709 100644 --- a/src/gui/kernel/qdesktopwidget_x11.cpp +++ b/src/gui/kernel/qdesktopwidget_x11.cpp @@ -285,26 +285,36 @@ const QRect QDesktopWidget::availableGeometry(int screen) const if (d->workareas[screen].isValid()) return d->workareas[screen]; - if ((d->screenCount == 1 || !isVirtualDesktop()) - && X11->isSupportedByWM(ATOM(_NET_WORKAREA))) { + if (X11->isSupportedByWM(ATOM(_NET_WORKAREA))) { + int x11Screen = isVirtualDesktop() ? DefaultScreen(X11->display) : screen; + Atom ret; int format, e; unsigned char *data = 0; unsigned long nitems, after; e = XGetWindowProperty(X11->display, - QX11Info::appRootWindow(screen), - ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL, - &ret, &format, &nitems, &after, &data); + QX11Info::appRootWindow(x11Screen), + ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL, + &ret, &format, &nitems, &after, &data); + QRect workArea; if (e == Success && ret == XA_CARDINAL && format == 32 && nitems == 4) { long *workarea = (long *) data; - d->workareas[screen].setRect(workarea[0], workarea[1], - workarea[2], workarea[3]); + workArea = QRect(workarea[0], workarea[1], workarea[2], workarea[3]); } else { - d->workareas[screen] = screenGeometry(screen); + workArea = screenGeometry(screen); + } + + if (isVirtualDesktop()) { + // intersect the workarea (which spawns all Xinerama screens) with the rect for the + // requested screen + workArea &= screenGeometry(screen); } + + d->workareas[screen] = workArea; + if (data) XFree(data); } else { diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 92c4fc1..b21b35c 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -127,11 +127,13 @@ public: GestureBegin, GestureEnd, Pan, - Pinch + Zoom, + Rotate, + Swipe }; QNativeGestureEvent() - : QEvent(QEvent::NativeGesture), gestureType(None) + : QEvent(QEvent::NativeGesture), gestureType(None), percentage(0), direction(0, 0) #ifdef Q_WS_WIN , sequenceId(0) #endif @@ -139,8 +141,10 @@ public: } Type gestureType; -#ifdef Q_WS_WIN + float percentage; QPoint position; + QSize direction; +#ifdef Q_WS_WIN ulong sequenceId; #endif }; diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index 32ac4f8..38e8851 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -97,7 +97,7 @@ private: This is a base class, to create a custom gesture type, you should subclass it and implement its pure virtual functions. - \sa QPanGesture, QTapAndHoldGesture + \sa QPanGesture */ /*! \fn bool QGesture::filterEvent(QEvent *event) @@ -197,11 +197,44 @@ Qt::GestureState QGesture::state() const } /*! - Sets this gesture's recognition state to \a state. + Sets this gesture's recognition state to \a state and emits appropriate + signals. + + This functions emits the signals according to the old state and the new + \a state, and it should be called after all the internal properties have been + initialized. + + \sa started, triggered, finished, cancelled */ -void QGesture::setState(Qt::GestureState state) +void QGesture::updateState(Qt::GestureState state) { - d_func()->state = state; + Q_D(QGesture); + if (d->state == state) { + if (state == Qt::GestureUpdated) + emit triggered(); + return; + } + const Qt::GestureState oldState = d->state; + d->state = state; + if (state != Qt::NoGesture && oldState > state) { + // comparing the state as ints: state should only be changed from + // started to (optionally) updated and to finished. + qWarning("QGesture::updateState: incorrect new state"); + return; + } + if (oldState == Qt::NoGesture) + emit started(); + if (state == Qt::GestureUpdated) + emit triggered(); + else if (state == Qt::GestureFinished) + emit finished(); + else if (state == Qt::NoGesture) + emit cancelled(); + + if (state == Qt::GestureFinished) { + // gesture is finished, so we reset the internal state. + d->state = Qt::NoGesture; + } } /*! @@ -238,14 +271,13 @@ QGraphicsItem* QGesture::graphicsItem() const Resets the internal state of the gesture. This function might be called by the filterEvent() implementation in a derived class, or by the user to - cancel a gesture. The base class implementation emits the cancelled() - signal if the state() of the gesture wasn't empty. + cancel a gesture. The base class implementation calls + updateState(Qt::NoGesture) which emits the cancelled() + signal if the state() of the gesture indicated it was active. */ void QGesture::reset() { - if (state() != Qt::NoGesture) - emit cancelled(); - setState(Qt::NoGesture); + updateState(Qt::NoGesture); } QT_END_NAMESPACE diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 0735160..7da37c4 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -81,7 +81,7 @@ protected: QGesture(QGesturePrivate &dd, QObject *parent); bool eventFilter(QObject*, QEvent*); - void setState(Qt::GestureState state); + void updateState(Qt::GestureState state); Q_SIGNALS: void started(); diff --git a/src/gui/kernel/qkde.cpp b/src/gui/kernel/qkde.cpp new file mode 100644 index 0000000..96ff21e --- /dev/null +++ b/src/gui/kernel/qkde.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qkde_p.h" +#include <QtCore/QLibrary> +#include <QtCore/QDir> +#include <QtCore/qdebug.h> +#include <QtCore/QSettings> +#include "QtGui/qstylefactory.h" +#include "qt_x11_p.h" + +#if defined(Q_WS_X11) + +QT_BEGIN_NAMESPACE + +/*! \internal +Gets the current KDE home path +like "/home/troll/.kde" +*/ +QString QKde::kdeHome() +{ + static QString kdeHomePath; + if (kdeHomePath.isEmpty()) { + kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME")); + if (kdeHomePath.isEmpty()) { + QDir homeDir(QDir::homePath()); + QString kdeConfDir(QLatin1String("/.kde")); + if (4 == X11->desktopVersion && homeDir.exists(QLatin1String(".kde4"))) + kdeConfDir = QLatin1String("/.kde4"); + kdeHomePath = QDir::homePath() + kdeConfDir; + } + } + return kdeHomePath; +} + +/*!\internal + Reads the color from the config, and store it in the palette with the given color role if found + */ +static bool kdeColor(QPalette *pal, QPalette::ColorRole role, const QSettings &kdeSettings, const QString &kde4Key, const QString &kde3Key = QString()) +{ + QVariant variant = kdeSettings.value(kde4Key); + if (!variant.isValid()) + QVariant variant = kdeSettings.value(kde3Key); + if (variant.isValid()) { + QStringList values = variant.toStringList(); + if (values.size() == 3) { + int r = values[0].toInt(); + int g = values[1].toInt(); + int b = values[2].toInt(); + pal->setBrush(role, QColor(r, g, b)); + return true; + } + } + return false; +} + + +/*!\internal + Returns the KDE palette +*/ +QPalette QKde::kdePalette() +{ + const QSettings theKdeSettings(QKde::kdeHome() + + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); + QPalette pal; + + // Setup KDE palette + kdeColor(&pal, QPalette::Button, theKdeSettings, QLatin1String("Colors:Button/BackgroundNormal"), QLatin1String("buttonBackground")); + kdeColor(&pal, QPalette::Window, theKdeSettings, QLatin1String("Colors:Window/BackgroundNormal"), QLatin1String("background")); + kdeColor(&pal, QPalette::Text, theKdeSettings, QLatin1String("Colors:View/ForegroundNormal"), QLatin1String("foreground")); + kdeColor(&pal, QPalette::WindowText, theKdeSettings, QLatin1String("Colors:Window/ForegroundNormal"), QLatin1String("windowForeground")); + kdeColor(&pal, QPalette::Base, theKdeSettings, QLatin1String("Colors:View/BackgroundNormal"), QLatin1String("windowBackground")); + kdeColor(&pal, QPalette::Highlight, theKdeSettings, QLatin1String("Colors:Selection/BackgroundNormal"), QLatin1String("selectBackground")); + kdeColor(&pal, QPalette::HighlightedText, theKdeSettings, QLatin1String("Colors:Selection/ForegroundNormal"), QLatin1String("selectForeground")); + kdeColor(&pal, QPalette::AlternateBase, theKdeSettings, QLatin1String("Colors:View/BackgroundAlternate"), QLatin1String("alternateBackground")); + kdeColor(&pal, QPalette::ButtonText, theKdeSettings, QLatin1String("Colors:Button/ForegroundNormal"), QLatin1String("buttonForeground")); + kdeColor(&pal, QPalette::Link, theKdeSettings, QLatin1String("Colors:View/ForegroundLink"), QLatin1String("linkColor")); + kdeColor(&pal, QPalette::LinkVisited, theKdeSettings, QLatin1String("Colors:View/ForegroundVisited"), QLatin1String("visitedLinkColor")); + //## TODO tooltip color + + return pal; +} + +/*!\internal + Returns the name of the QStyle to use. + (read from the kde config if needed) +*/ +QString QKde::kdeStyle() +{ + if (X11->desktopVersion >= 4) { + QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); + QString style = kdeSettings.value(QLatin1String("widgetStyle"), QLatin1String("Oxygen")).toString(); + + QStringList availableStyles = QStyleFactory::keys(); + if(availableStyles.contains(style, Qt::CaseInsensitive)) + return style; + } + + if (X11->use_xrender) + return QLatin1String("plastique"); + else + return QLatin1String("windows"); + + return QString(); +} + +/*!\internal + placeholder to load icon from kde. + to be implemented + */ +QIcon QKde::kdeIcon(const QString &name) +{ + //###todo + return QIcon(); +} + +QT_END_NAMESPACE + +#endif //Q_WS_X11 + diff --git a/src/gui/kernel/qkde_p.h b/src/gui/kernel/qkde_p.h new file mode 100644 index 0000000..ac760bd --- /dev/null +++ b/src/gui/kernel/qkde_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QKDE_H +#define QKDE_H + +#include <QtCore/qglobal.h> +#include <QtGui/QPalette> +#include <QtGui/QIcon> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +#if defined(Q_WS_X11) + + +QT_BEGIN_NAMESPACE + +// This namespace contains helper function to help KDE integration +namespace QKde { + QString kdeHome(); + QString kdeStyle(); + QPalette kdePalette(); + QIcon kdeIcon(const QString &name); +} + + +QT_END_NAMESPACE + +#endif // Q_WS_X11 +#endif // QKDE_H diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 4753416..7078dbf 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -46,11 +46,12 @@ #include <qscrollbar.h> #include <private/qapplication_p.h> #include <private/qevent_p.h> +#include <private/qwidget_p.h> QT_BEGIN_NAMESPACE #ifdef Q_WS_WIN -QApplicationPrivate* getQApplicationPrivateInternal(); +QWidgetPrivate *qt_widget_private(QWidget *widget); #endif /*! @@ -71,32 +72,38 @@ QApplicationPrivate* getQApplicationPrivateInternal(); QPanGesture::QPanGesture(QWidget *parent) : QGesture(*new QPanGesturePrivate, parent) { -#ifdef Q_WS_WIN if (parent) { - QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal(); + QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); qAppPriv->widgetGestures[parent].pan = this; - } +#ifdef Q_WS_WIN + qt_widget_private(parent)->winSetupGestures(); #endif + } } /*! \internal */ bool QPanGesture::event(QEvent *event) { -#ifdef Q_WS_WIN - QApplicationPrivate* getQApplicationPrivateInternal(); switch (event->type()) { case QEvent::ParentAboutToChange: - if (QWidget *w = qobject_cast<QWidget*>(parent())) - getQApplicationPrivateInternal()->widgetGestures[w].pan = 0; + if (QWidget *w = qobject_cast<QWidget*>(parent())) { + QApplicationPrivate::instance()->widgetGestures[w].pan = 0; +#ifdef Q_WS_WIN + qt_widget_private(w)->winSetupGestures(); +#endif + } break; case QEvent::ParentChange: - if (QWidget *w = qobject_cast<QWidget*>(parent())) - getQApplicationPrivateInternal()->widgetGestures[w].pan = this; + if (QWidget *w = qobject_cast<QWidget*>(parent())) { + QApplicationPrivate::instance()->widgetGestures[w].pan = this; +#ifdef Q_WS_WIN + qt_widget_private(w)->winSetupGestures(); +#endif + } break; default: break; } -#endif #if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) Q_D(QPanGesture); @@ -106,9 +113,7 @@ bool QPanGesture::event(QEvent *event) killTimer(d->panFinishedTimer); d->panFinishedTimer = 0; d->lastOffset = QSize(0, 0); - setState(Qt::GestureFinished); - emit triggered(); - setState(Qt::NoGesture); + updateState(Qt::GestureFinished); } } #endif @@ -119,38 +124,37 @@ bool QPanGesture::event(QEvent *event) bool QPanGesture::eventFilter(QObject *receiver, QEvent *event) { #ifdef Q_WS_WIN + Q_D(QPanGesture); if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) { QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event); - QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal(); + QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); QApplicationPrivate::WidgetStandardGesturesMap::iterator it; it = qAppPriv->widgetGestures.find(static_cast<QWidget*>(receiver)); if (it == qAppPriv->widgetGestures.end()) return false; QPanGesture *gesture = it.value().pan; - if (!gesture) + if (this != gesture) return false; - Qt::GestureState nextState = state(); + Qt::GestureState nextState = Qt::NoGesture; switch(ev->gestureType) { case QNativeGestureEvent::GestureBegin: // next we might receive the first gesture update event, so we // prepare for it. - setState(Qt::GestureStarted); + d->state = Qt::NoGesture; return false; case QNativeGestureEvent::Pan: nextState = Qt::GestureUpdated; + event->accept(); break; case QNativeGestureEvent::GestureEnd: - if (state() != QNativeGestureEvent::Pan) + if (state() == Qt::NoGesture) return false; // some other gesture has ended - setState(Qt::GestureFinished); nextState = Qt::GestureFinished; break; default: return false; } - QPanGesturePrivate *d = gesture->d_func(); - if (state() == Qt::GestureStarted) { - d->lastPosition = ev->position; + if (state() == Qt::NoGesture) { d->lastOffset = d->totalOffset = QSize(); } else { d->lastOffset = QSize(ev->position.x() - d->lastPosition.x(), @@ -158,14 +162,7 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event) d->totalOffset += d->lastOffset; } d->lastPosition = ev->position; - - if (state() == Qt::GestureStarted) - emit gesture->started(); - emit gesture->triggered(); - if (state() == Qt::GestureFinished) - emit gesture->finished(); - event->accept(); - gesture->setState(nextState); + gesture->updateState(nextState); return true; } #endif @@ -185,7 +182,6 @@ bool QPanGesture::filterEvent(QEvent *event) d->lastOffset = d->totalOffset = QSize(); } else if (event->type() == QEvent::TouchEnd) { if (state() != Qt::NoGesture) { - setState(Qt::GestureFinished); if (!ev->touchPoints().isEmpty()) { QTouchEvent::TouchPoint p = ev->touchPoints().at(0); const QPoint pos = p.pos().toPoint(); @@ -194,10 +190,8 @@ bool QPanGesture::filterEvent(QEvent *event) d->lastOffset = QSize(pos.x() - lastPos.x(), pos.y() - lastPos.y()); d->totalOffset = QSize(pos.x() - startPos.x(), pos.y() - startPos.y()); } - emit triggered(); - emit finished(); + updateState(Qt::GestureFinished); } - setState(Qt::NoGesture); reset(); } else if (event->type() == QEvent::TouchUpdate) { QTouchEvent::TouchPoint p = ev->touchPoints().at(0); @@ -208,11 +202,7 @@ bool QPanGesture::filterEvent(QEvent *event) d->totalOffset = QSize(pos.x() - startPos.x(), pos.y() - startPos.y()); if (d->totalOffset.width() > 10 || d->totalOffset.height() > 10 || d->totalOffset.width() < -10 || d->totalOffset.height() < -10) { - if (state() == Qt::NoGesture) - setState(Qt::GestureStarted); - else - setState(Qt::GestureUpdated); - emit triggered(); + updateState(Qt::GestureUpdated); } } #ifdef Q_OS_MAC @@ -231,16 +221,14 @@ bool QPanGesture::filterEvent(QEvent *event) d->lastOffset = wev->orientation() == Qt::Horizontal ? QSize(offset, 0) : QSize(0, offset); if (state() == Qt::NoGesture) { - setState(Qt::GestureStarted); d->totalOffset = d->lastOffset; } else { - setState(Qt::GestureUpdated); d->totalOffset += d->lastOffset; } killTimer(d->panFinishedTimer); d->panFinishedTimer = startTimer(200); - emit triggered(); + updateState(Qt::GestureUpdated); #endif return true; } diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h index 1ac51e0..44652d3 100644 --- a/src/gui/kernel/qt_x11_p.h +++ b/src/gui/kernel/qt_x11_p.h @@ -515,7 +515,8 @@ struct QX11Data char *startupId; - DesktopEnvironment desktopEnvironment; + DesktopEnvironment desktopEnvironment : 8; + uint desktopVersion : 8; /* Used only for KDE */ /* Warning: if you modify this list, modify the names of atoms in qapplication_x11.cpp as well! */ enum X11Atom { diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index a8157d5..b0564bd 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -3573,27 +3573,27 @@ bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh) } } #endif + int mw = minw, mh = minh; + if (mw == QWIDGETSIZE_MAX) + mw = 0; + if (mh == QWIDGETSIZE_MAX) + mh = 0; if (minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX) { qWarning("QWidget::setMinimumSize: (%s/%s) " "The largest allowed size is (%d,%d)", q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); - minw = qMin<int>(minw, QWIDGETSIZE_MAX); - minh = qMin<int>(minh, QWIDGETSIZE_MAX); + minw = mw = qMin<int>(minw, QWIDGETSIZE_MAX); + minh = mh = qMin<int>(minh, QWIDGETSIZE_MAX); } if (minw < 0 || minh < 0) { qWarning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) " "are not possible", q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh); - minw = qMax(minw, 0); - minh = qMax(minh, 0); + minw = mw = qMax(minw, 0); + minh = mh = qMax(minh, 0); } createExtra(); - int mw = minw, mh = minh; - if (mw == QWIDGETSIZE_MAX) - mw = 0; - if (mh == QWIDGETSIZE_MAX) - mh = 0; if (extra->minw == mw && extra->minh == mh) return false; extra->minw = mw; @@ -8120,10 +8120,12 @@ void QWidget::changeEvent(QEvent * event) case QEvent::FontChange: case QEvent::StyleChange: { + Q_D(QWidget); update(); updateGeometry(); + if (d->layout) + d->layout->invalidate(); #ifdef Q_WS_QWS - Q_D(QWidget); if (isWindow()) d->data.fstrut_dirty = true; #endif @@ -11287,8 +11289,6 @@ Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget) } - - #ifndef QT_NO_GRAPHICSVIEW /*! \since 4.5 diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 070110d..6e4d069 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3180,6 +3180,12 @@ void QWidgetPrivate::show_sys() #ifndef QT_MAC_USE_COCOA SizeWindow(window, q->width(), q->height(), true); #endif + +#ifdef QT_MAC_USE_COCOA + // Make sure that we end up sending a repaint event to + // the widget if the window has been visible one before: + [qt_mac_get_contentview_for(window) setNeedsDisplay:YES]; +#endif if(qt_mac_is_macsheet(q)) { qt_event_request_showsheet(q); } else if(qt_mac_is_macdrawer(q)) { diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 1122154..f4cd61a 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -577,6 +577,7 @@ public: #endif void grabMouseWhileInWindow(); void registerTouchWindow(); + void winSetupGestures(); #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC // This is new stuff uint needWindowChange : 1; diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index d5ce40b..49254ef 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -56,6 +56,10 @@ #include "private/qbackingstore_p.h" #include "private/qwindowsurface_raster_p.h" +#include "qscrollbar.h" +#include "qabstractscrollarea.h" +#include <private/qabstractscrollarea_p.h> + #include <qdebug.h> #include <private/qapplication_p.h> @@ -2053,6 +2057,58 @@ void QWidgetPrivate::registerTouchWindow() QApplicationPrivate::RegisterTouchWindow(q->effectiveWinId(), 0); } +void QWidgetPrivate::winSetupGestures() +{ + Q_Q(QWidget); + if (!q) + return; + extern QApplicationPrivate* getQApplicationPrivateInternal(); + QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal(); + bool needh = false; + bool needv = false; + bool singleFingerPanEnabled = false; + QStandardGestures gestures = qAppPriv->widgetGestures[q]; + WId winid = 0; + + if (QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea*>(q)) { + winid = asa->viewport()->winId(); + QScrollBar *hbar = asa->horizontalScrollBar(); + QScrollBar *vbar = asa->verticalScrollBar(); + Qt::ScrollBarPolicy hbarpolicy = asa->horizontalScrollBarPolicy(); + Qt::ScrollBarPolicy vbarpolicy = asa->verticalScrollBarPolicy(); + needh = (hbarpolicy == Qt::ScrollBarAlwaysOn + || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum())); + needv = (vbarpolicy == Qt::ScrollBarAlwaysOn + || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum())); + singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled; + } else { + winid = q->winId(); + } + if (qAppPriv->SetGestureConfig) { + GESTURECONFIG gc[2]; + gc[0].dwID = GID_PAN; + if (gestures.pan || needh || needv) { + gc[0].dwWant = GC_PAN; + gc[0].dwBlock = 0; + if (needv && singleFingerPanEnabled) + gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY; + if (needh && singleFingerPanEnabled) + gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; + } else { + gc[0].dwWant = 0; + gc[0].dwBlock = GC_PAN; + } + + gc[1].dwID = GID_ZOOM; + if (gestures.pinch) { + gc[1].dwWant = GC_ZOOM; + gc[1].dwBlock = 0; + } + Q_ASSERT(winid); + qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0])); + } +} + QT_END_NAMESPACE #ifdef Q_WS_WINCE diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index 55c871d..9a1b590 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -198,24 +198,17 @@ inline QQuaternion &QQuaternion::operator*=(qreal factor) inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2) { - // Algorithm from: - // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q53 - float x = q1.wp * q2.xp + - q1.xp * q2.wp + - q1.yp * q2.zp - - q1.zp * q2.yp; - float y = q1.wp * q2.yp + - q1.yp * q2.wp + - q1.zp * q2.xp - - q1.xp * q2.zp; - float z = q1.wp * q2.zp + - q1.zp * q2.wp + - q1.xp * q2.yp - - q1.yp * q2.xp; - float w = q1.wp * q2.wp - - q1.xp * q2.xp - - q1.yp * q2.yp - - q1.zp * q2.zp; + float ww = (q1.zp + q1.xp) * (q2.xp + q2.yp); + float yy = (q1.wp - q1.yp) * (q2.wp + q2.zp); + float zz = (q1.wp + q1.yp) * (q2.wp - q2.zp); + float xx = ww + yy + zz; + float qq = 0.5 * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp)); + + float w = qq - ww + (q1.zp - q1.yp) * (q2.yp - q2.zp); + float x = qq - xx + (q1.xp + q1.wp) * (q2.xp + q2.wp); + float y = qq - yy + (q1.wp - q1.xp) * (q2.yp + q2.zp); + float z = qq - zz + (q1.zp + q1.yp) * (q2.wp - q2.xp); + return QQuaternion(w, x, y, z, 1); } diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 4aaa799..fa9534f 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2539,6 +2539,9 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe qDebug() << " - QRasterPaintEngine::drawImage(), r=" << r << " sr=" << sr << " image=" << img.size() << "depth=" << img.depth(); #endif + if (r.isEmpty()) + return; + Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); const bool aa = s->flags.antialiased || s->flags.bilinear; diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index bfcb7c9..3420ad1 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -63,7 +63,7 @@ #include <qtoolbar.h> #include <qtoolbutton.h> #include <qrubberband.h> -#include <private/qapplication_p.h> +#include <../kernel/qkde_p.h> #include <private/qcommonstylepixmaps_p.h> #include <private/qmath_p.h> #include <private/qstylehelper_p.h> @@ -842,12 +842,6 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut #ifdef Q_WS_X11 // These functions are used to parse the X11 freedesktop icon spec -static int kdeVersion() -{ - static int kdeVersion = qgetenv("KDE_SESSION_VERSION").toInt(); - return kdeVersion; -} - void QCommonStylePrivate::lookupIconTheme() const { if (!themeName.isEmpty()) @@ -856,7 +850,7 @@ void QCommonStylePrivate::lookupIconTheme() const QString dataDirs = QString::fromLocal8Bit(getenv("XDG_DATA_DIRS")); if (dataDirs.isEmpty()) dataDirs = QLatin1String("/usr/local/share/:/usr/share/"); - dataDirs += QLatin1Char(':') + QApplicationPrivate::kdeHome() + QLatin1String("/share"); + dataDirs += QLatin1Char(':') + QKde::kdeHome() + QLatin1String("/share"); dataDirs.prepend(QDir::homePath() + QLatin1String("/:")); QStringList kdeDirs = QString::fromLocal8Bit(getenv("KDEDIRS")).split(QLatin1Char(':'), QString::SkipEmptyParts); foreach (const QString &dirName, kdeDirs) @@ -865,9 +859,10 @@ void QCommonStylePrivate::lookupIconTheme() const QFileInfo fileInfo(QLatin1String("/usr/share/icons/default.kde")); QDir dir(fileInfo.canonicalFilePath()); - QString kdeDefault = kdeVersion() >= 4 ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg"); + QString kdeDefault = (X11->desktopEnvironment != DE_KDE || X11->desktopVersion >= 4) + ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg"); QString defaultTheme = fileInfo.exists() ? dir.dirName() : kdeDefault; - QSettings settings(QApplicationPrivate::kdeHome() + + QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); settings.beginGroup(QLatin1String("Icons")); themeName = settings.value(QLatin1String("Theme"), defaultTheme).toString(); @@ -979,8 +974,15 @@ QPixmap QCommonStylePrivate::findIconHelper(int size, return pixmap; } +/*! \internal + find a pixmap with the given size and name from the freedesktop theme. +*/ QPixmap QCommonStylePrivate::findIcon(int size, const QString &name) const { + QIcon icon = QKde::kdeIcon(name); + if (!icon.isNull()) + return icon.pixmap(size); + QPixmap pixmap; QString pixmapName = QLatin1String("$qt") + name + QString::number(size); @@ -995,12 +997,17 @@ QPixmap QCommonStylePrivate::findIcon(int size, const QString &name) const return pixmap; } +/*! \internal + create an Icon from the freedesktop theme. + */ QIcon QCommonStylePrivate::createIcon(const QString &name) const { - QIcon icon; - icon.addPixmap(findIcon(16, name)); - icon.addPixmap(findIcon(24, name)); - icon.addPixmap(findIcon(32, name)); + QIcon icon = QKde::kdeIcon(name); + if (icon.isNull()) { + icon.addPixmap(findIcon(16, name)); + icon.addPixmap(findIcon(24, name)); + icon.addPixmap(findIcon(32, name)); + } return icon; } /*!internal @@ -1012,8 +1019,8 @@ from the KDE configuration file int QCommonStylePrivate::lookupToolButtonStyle() const { int result = Qt::ToolButtonIconOnly; - if (kdeVersion() >= 4) { - QSettings settings(QApplicationPrivate::kdeHome() + + if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4) { + QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); settings.beginGroup(QLatin1String("Toolbar style")); QString toolbarStyle = settings.value(QLatin1String("ToolButtonStyle"), QLatin1String("TextBesideIcon")).toString(); diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 2f93034..235cba6 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -5510,9 +5510,15 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op break; } case SC_SpinBoxEditField: - ret.setRect(fw, fw, - spin->rect.width() - spinner_w - fw * 2 - spinBoxSep, - spin->rect.height() - fw * 2); + if (spin->buttonSymbols == QAbstractSpinBox::NoButtons) { + ret.setRect(fw, fw, + spin->rect.width() - fw * 2, + spin->rect.height() - fw * 2); + } else { + ret.setRect(fw, fw, + spin->rect.width() - fw * 2 - spinBoxSep - spinner_w, + spin->rect.height() - fw * 2); + } ret = visualRect(spin->direction, spin->rect, ret); break; default: diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 2efa4a7..5f6d4ab 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -2891,8 +2891,8 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC bool customUp = true, customDown = true; QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton); QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton); - bool upRuleMatch = upRule.hasGeometry(); - bool downRuleMatch = downRule.hasGeometry(); + bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition(); + bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition(); if (rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) { rule.drawBackgroundImage(p, spinOpt.rect); customUp = (opt->subControls & QStyle::SC_SpinBoxUp) @@ -5167,8 +5167,8 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton); QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton); bool ruleMatch = rule.hasBox() || !rule.hasNativeBorder(); - bool upRuleMatch = upRule.hasGeometry(); - bool downRuleMatch = downRule.hasGeometry(); + bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition(); + bool downRuleMatch = downRule.hasGeometry() || upRule.hasPosition(); if (ruleMatch || upRuleMatch || downRuleMatch) { switch (sc) { case SC_SpinBoxFrame: diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp index 391e095..c72c36c 100644 --- a/src/gui/widgets/qabstractscrollarea.cpp +++ b/src/gui/widgets/qabstractscrollarea.cpp @@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate() :hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded), viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0), - xoffset(0), yoffset(0), viewportFilter(0) + xoffset(0), yoffset(0), viewportFilter(0), panGesture(0) #ifdef Q_WS_WIN , singleFingerPanEnabled(false) #endif @@ -294,33 +294,18 @@ void QAbstractScrollAreaPrivate::init() q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layoutChildren(); + + panGesture = new QPanGesture(q); + QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered())); } -void QAbstractScrollAreaPrivate::setupGestures() +#ifdef Q_WS_WIN +void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on) { -#ifdef Q_OS_WIN - if (!viewport) - return; - QApplicationPrivate* getQApplicationPrivateInternal(); - QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal(); - bool needh = (hbarpolicy == Qt::ScrollBarAlwaysOn - || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum())); - - bool needv = (vbarpolicy == Qt::ScrollBarAlwaysOn - || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum())); - if (qAppPriv->SetGestureConfig && (needh || needv)) { - GESTURECONFIG gc[1]; - gc[0].dwID = GID_PAN; - gc[0].dwWant = GC_PAN; - gc[0].dwBlock = 0; - if (needv && singleFingerPanEnabled) - gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY; - if (needh && singleFingerPanEnabled) - gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; - qAppPriv->SetGestureConfig(viewport->winId(), 0, 1, gc, sizeof(gc)); - } -#endif // Q_OS_WIN + singleFingerPanEnabled = on; + winSetupGestures(); } +#endif // Q_WS_WIN void QAbstractScrollAreaPrivate::layoutChildren() { @@ -1278,7 +1263,11 @@ void QAbstractScrollAreaPrivate::_q_vslide(int y) void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars() { layoutChildren(); - setupGestures(); +#ifdef Q_OS_WIN + // Need to re-subscribe to gestures as the content changes to make sure we + // enable/disable panning when needed. + winSetupGestures(); +#endif // Q_OS_WIN } QPoint QAbstractScrollAreaPrivate::contentsOffset() const @@ -1343,6 +1332,25 @@ void QAbstractScrollArea::setupViewport(QWidget *viewport) Q_UNUSED(viewport); } +void QAbstractScrollAreaPrivate::_q_gestureTriggered() +{ + Q_Q(QAbstractScrollArea); + QPanGesture *g = qobject_cast<QPanGesture*>(q->sender()); + if (!g) + return; + QScrollBar *hBar = q->horizontalScrollBar(); + QScrollBar *vBar = q->verticalScrollBar(); + QSize delta = g->lastOffset(); + if (!delta.isNull()) { + if (QApplication::isRightToLeft()) + delta.rwidth() *= -1; + int newX = hBar->value() - delta.width(); + int newY = vBar->value() - delta.height(); + hbar->setValue(newX); + vbar->setValue(newY); + } +} + QT_END_NAMESPACE #include "moc_qabstractscrollarea.cpp" diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h index 3ec41d1..9178629 100644 --- a/src/gui/widgets/qabstractscrollarea.h +++ b/src/gui/widgets/qabstractscrollarea.h @@ -128,8 +128,10 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_hslide(int)) Q_PRIVATE_SLOT(d_func(), void _q_vslide(int)) Q_PRIVATE_SLOT(d_func(), void _q_showOrHideScrollBars()) + Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered()) friend class QStyleSheetStyle; + friend class QWidgetPrivate; }; #endif // QT_NO_SCROLLAREA diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h index f8ea843..a54ba1c 100644 --- a/src/gui/widgets/qabstractscrollarea_p.h +++ b/src/gui/widgets/qabstractscrollarea_p.h @@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_SCROLLAREA +class QPanGesture; class QScrollBar; class QAbstractScrollAreaScrollBarContainer; class Q_AUTOTEST_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate @@ -100,10 +101,12 @@ public: { return q_func()->viewportEvent(event); } QScopedPointer<QObject> viewportFilter; + virtual void _q_gestureTriggered(); + QPanGesture *panGesture; #ifdef Q_WS_WIN bool singleFingerPanEnabled; + void setSingleFingerPanEnabled(bool on = true); #endif - void setupGestures(); }; class QAbstractScrollAreaFilter : public QObject diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index ee29b55..cad6903 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -1545,7 +1545,7 @@ void QDockAreaLayoutInfo::apply(bool animate) QRect geo = w->geometry(); widgetAnimator.animate(w, r, animate); - if (!w->isHidden()) { + if (!w->isHidden() && w->window()->isVisible()) { QDockWidget *dw = qobject_cast<QDockWidget*>(w); if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) { dw->lower(); diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index 5810c81..e60f099 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -1390,7 +1390,7 @@ bool QDockWidget::event(QEvent *event) break; case QEvent::Show: d->toggleViewAction->setChecked(true); - emit visibilityChanged(true); + emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0); break; #endif case QEvent::ApplicationLayoutDirectionChange: diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 64832c8..f4a2348 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -257,6 +257,7 @@ void QLineControl::setSelection(int start, int length) m_cursor = m_selstart; } emit selectionChanged(); + emitCursorPositionChanged(); } void QLineControl::_q_clipboardChanged() @@ -1704,8 +1705,7 @@ void QLineControl::processKeyEvent(QKeyEvent* event) if (passwordEchoEditing()) updatePasswordEchoEditing(false); - // ### TODO this needs to be fixed. - // setEditFocus(false); + emit editFocusChange(false); } else if (!m_deleteAllTimer) { m_deleteAllTimer = startTimer(750); } diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 9cad857..ad4e4e4 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -343,6 +343,9 @@ Q_SIGNALS: void editingFinished(); void updateNeeded(const QRect &); +#ifdef QT_KEYPAD_NAVIGATION + void editFocusChange(bool); +#endif protected: virtual void timerEvent(QTimerEvent *event); @@ -638,7 +641,7 @@ inline void QLineControl::setCursorPosition(int pos) { if (pos < 0) pos = 0; - if (pos < m_text.length()) + if (pos <= m_text.length()) moveCursor(pos); } diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 8ab30fa..5b04616 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1693,12 +1693,10 @@ void QLineEdit::focusInEvent(QFocusEvent *e) d->clickCausedFocus = 1; } #ifdef QT_KEYPAD_NAVIGATION - if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)) + if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)){ #endif - { - int cft = QApplication::cursorFlashTime(); - d->control->setCursorBlinkPeriod(cft/2); - } + int cft = QApplication::cursorFlashTime(); + d->control->setCursorBlinkPeriod(cft/2); QStyleOptionFrameV2 opt; initStyleOption(&opt); if((!hasSelectedText() && d->control->preeditAreaText().isEmpty()) @@ -1709,7 +1707,8 @@ void QLineEdit::focusInEvent(QFocusEvent *e) qt_mac_secure_keyboard(true); #endif #ifdef QT_KEYPAD_NAVIGATION - d->control->setCancelText(d->control->text()); + d->control->setCancelText(d->control->text()); + } #endif #ifndef QT_NO_COMPLETER if (d->control->completer()) { diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h index daac6a7..32ef6a4 100644 --- a/src/gui/widgets/qlineedit.h +++ b/src/gui/widgets/qlineedit.h @@ -273,6 +273,9 @@ private: #ifndef QT_NO_COMPLETER Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(QString)) #endif +#ifdef QT_KEYPAD_NAVIGATION + Q_PRIVATE_SLOT(d_func(), void _q_editFocusChange(bool)) +#endif }; #endif // QT_NO_LINEEDIT diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp index f0ec8ad..d907233 100644 --- a/src/gui/widgets/qlineedit_p.cpp +++ b/src/gui/widgets/qlineedit_p.cpp @@ -126,6 +126,14 @@ void QLineEditPrivate::_q_cursorPositionChanged(int from, int to) emit q->cursorPositionChanged(from, to); } +#ifdef QT_KEYPAD_NAVIGATION +void QLineEditPrivate::_q_editFocusChange(bool e) +{ + Q_Q(QLineEdit); + q->setEditFocus(e); +} +#endif + void QLineEditPrivate::init(const QString& txt) { Q_Q(QLineEdit); @@ -142,6 +150,10 @@ void QLineEditPrivate::init(const QString& txt) q, SIGNAL(returnPressed())); QObject::connect(control, SIGNAL(editingFinished()), q, SIGNAL(editingFinished())); +#ifdef QT_KEYPAD_NAVIGATION + QObject::connect(control, SIGNAL(editFocusChange(bool)), + q, SLOT(_q_editFocusChange(bool))); +#endif // for now, going completely overboard with updates. QObject::connect(control, SIGNAL(selectionChanged()), @@ -149,6 +161,9 @@ void QLineEditPrivate::init(const QString& txt) QObject::connect(control, SIGNAL(displayTextChanged(const QString &)), q, SLOT(update())); + + QObject::connect(control, SIGNAL(updateNeeded(const QRect &)), + q, SLOT(update())); control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter)); #ifndef QT_NO_CURSOR q->setCursor(Qt::IBeamCursor); diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h index b09c3f0..b21820c 100644 --- a/src/gui/widgets/qlineedit_p.h +++ b/src/gui/widgets/qlineedit_p.h @@ -126,6 +126,9 @@ public: void _q_deleteSelected(); void _q_textEdited(const QString &); void _q_cursorPositionChanged(int, int); +#ifdef QT_KEYPAD_NAVIGATION + void _q_editFocusChange(bool); +#endif #ifndef QT_NO_COMPLETER void _q_completionHighlighted(QString); diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 3936a67..55afa70 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1988,6 +1988,9 @@ void QMainWindowLayout::timerEvent(QTimerEvent *e) if (movingSeparatorOrigin == movingSeparatorPos) return; + //when moving the separator, we need to update the previous position + parentWidget()->update(layoutState.dockAreaLayout.separatorRegion()); + layoutState = savedState; layoutState.dockAreaLayout.separatorMove(movingSeparator, movingSeparatorOrigin, movingSeparatorPos); diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 6465975..1ba6fdc 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -205,6 +205,8 @@ void QMenuPrivate::updateActionRects() const Q_Q(const QMenu); if (!itemsDirty) return; + + q->ensurePolished(); //let's reinitialize the buffer actionRects.resize(actions.count()); @@ -226,13 +228,17 @@ void QMenuPrivate::updateActionRects() const dh = popupGeometry(QApplication::desktop()->screenNumber(q)).height(), y = 0; QStyle *style = q->style(); - const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, 0, q), - vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, 0, q), - icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q); - const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); - - const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, 0, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); + QStyleOption opt; + opt.init(q); + const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q), + vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q), + icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q); + const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q); + const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q); + + const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); + const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0; //for compatability now - will have to refactor this away.. tabWidth = 0; @@ -308,7 +314,7 @@ void QMenuPrivate::updateActionRects() const max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width())); //wrapping if (!scroll && - y+sz.height()+vmargin > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) { + y+sz.height()+vmargin > dh - (deskFw * 2)) { ncols++; y = vmargin; } @@ -323,7 +329,7 @@ void QMenuPrivate::updateActionRects() const //calculate position const int base_y = vmargin + fw + topmargin + (scroll ? scroll->scrollOffset : 0) + - (tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q) : 0); + tearoffHeight; int x = hmargin + fw + leftmargin; y = base_y; @@ -332,7 +338,7 @@ void QMenuPrivate::updateActionRects() const if (rect.isNull()) continue; if (!scroll && - y+rect.height() > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) { + y+rect.height() > dh - deskFw * 2) { x += max_column_width + hmargin; y = base_y; } @@ -1708,12 +1714,9 @@ QRect QMenu::actionGeometry(QAction *act) const QSize QMenu::sizeHint() const { Q_D(const QMenu); - ensurePolished(); d->updateActionRects(); QSize s; - QStyleOption opt(0); - opt.init(this); for (int i = 0; i < d->actionRects.count(); ++i) { const QRect &rect = d->actionRects.at(i); if (rect.isNull()) @@ -1726,15 +1729,11 @@ QSize QMenu::sizeHint() const // Note that the action rects calculated above already include // the top and left margins, so we only need to add margins for // the bottom and right. - if (const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this)) { - s.rwidth() += fw; - s.rheight() += fw; - } - - s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this); - s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this); - - s += QSize(d->rightmargin, d->bottommargin); + QStyleOption opt(0); + opt.init(this); + const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this); + s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this) + fw + d->rightmargin; + s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) + fw + d->bottommargin; return style()->sizeFromContents(QStyle::CT_Menu, &opt, s.expandedTo(QApplication::globalStrut()), this); diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index eaf03b3..a0a2f57 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -272,6 +272,9 @@ QRect QMenuBarPrivate::actionRect(QAction *act) const //makes sure the geometries are up-to-date const_cast<QMenuBarPrivate*>(this)->updateGeometries(); + if (index >= actionRects.count()) + return QRect(); // that can happen in case of native menubar + QRect ret = actionRects.at(index); return QStyle::visualRect(q->layoutDirection(), q->rect(), ret); } diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index e5c4d4f..57f43c6 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -119,7 +119,7 @@ QTextEditPrivate::QTextEditPrivate() showCursorOnInitialShow = true; inDrag = false; #ifdef Q_WS_WIN - singleFingerPanEnabled = true; + setSingleFingerPanEnabled(true); #endif } @@ -188,8 +188,6 @@ void QTextEditPrivate::init(const QString &html) #ifndef QT_NO_CURSOR viewport->setCursor(Qt::IBeamCursor); #endif - panGesture = new QPanGesture(q); - QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered())); } void QTextEditPrivate::_q_repaintContents(const QRectF &contentsRect) @@ -2631,26 +2629,6 @@ void QTextEdit::ensureCursorVisible() d->control->ensureCursorVisible(); } -void QTextEditPrivate::_q_gestureTriggered() -{ - Q_Q(QTextEdit); - QPanGesture *g = qobject_cast<QPanGesture*>(q->sender()); - if (!g) - return; - QScrollBar *hBar = q->horizontalScrollBar(); - QScrollBar *vBar = q->verticalScrollBar(); - QSize delta = g->lastOffset(); - if (!delta.isNull()) { - if (QApplication::isRightToLeft()) - delta.rwidth() *= -1; - int newX = hBar->value() - delta.width(); - int newY = vBar->value() - delta.height(); - hbar->setValue(newX); - vbar->setValue(newY); - } -} - - /*! \enum QTextEdit::KeyboardAction diff --git a/src/gui/widgets/qtextedit.h b/src/gui/widgets/qtextedit.h index 9e10e07..617822a 100644 --- a/src/gui/widgets/qtextedit.h +++ b/src/gui/widgets/qtextedit.h @@ -414,7 +414,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_currentCharFormatChanged(const QTextCharFormat &)) Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars()) Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &)) - Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered()) friend class QTextEditControl; friend class QTextDocument; friend class QTextControl; diff --git a/src/gui/widgets/qtextedit_p.h b/src/gui/widgets/qtextedit_p.h index cf87a86..85b6f7c 100644 --- a/src/gui/widgets/qtextedit_p.h +++ b/src/gui/widgets/qtextedit_p.h @@ -70,7 +70,6 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_TEXTEDIT class QMimeData; -class QPanGesture; class QTextEditPrivate : public QAbstractScrollAreaPrivate { Q_DECLARE_PUBLIC(QTextEdit) @@ -130,9 +129,6 @@ public: QString anchorToScrollToWhenVisible; - void _q_gestureTriggered(); - QPanGesture *panGesture; - #ifdef QT_KEYPAD_NAVIGATION QBasicTimer deleteAllTimer; #endif |