Qt 4.8
qworkspace.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qworkspace.h"
43 #ifndef QT_NO_WORKSPACE
44 #include "qapplication.h"
45 #include "qbitmap.h"
46 #include "qcursor.h"
47 #include "qdesktopwidget.h"
48 #include "qevent.h"
49 #include "qhash.h"
50 #include "qicon.h"
51 #include "qimage.h"
52 #include "qlabel.h"
53 #include "qlayout.h"
54 #include "qmenubar.h"
55 #include "qmenu.h"
56 #include "qpainter.h"
57 #include "qpointer.h"
58 #include "qscrollbar.h"
59 #include "qstyle.h"
60 #include "qstyleoption.h"
61 #include "qelapsedtimer.h"
62 #include "qtooltip.h"
63 #include "qdebug.h"
64 #include <private/qwidget_p.h>
65 #include <private/qwidgetresizehandler_p.h>
66 #include <private/qlayoutengine_p.h>
67 
69 
71 
72 
73 /**************************************************************
74 * QMDIControl
75 *
76 * Used for displaying MDI controls in a maximized MDI window
77 *
78 */
79 class QMDIControl : public QWidget
80 {
81  Q_OBJECT
82 signals:
83  void _q_minimize();
84  void _q_restore();
85  void _q_close();
86 
87 public:
89 
90 private:
91  QSize sizeHint() const;
93  void mousePressEvent(QMouseEvent *event);
94  void mouseReleaseEvent(QMouseEvent *event);
95  void mouseMoveEvent(QMouseEvent *event);
96  void leaveEvent(QEvent *event);
97  bool event(QEvent *event);
98  void initStyleOption(QStyleOptionComplex *option) const;
99  QStyle::SubControl activeControl; //control locked by pressing and holding the mouse
100  QStyle::SubControl hoverControl; //previously active hover control, used for tracking repaints
101 };
102 
104 {
105  if (event->type() == QEvent::ToolTip) {
107  initStyleOption(&opt);
108 #ifndef QT_NO_TOOLTIP
109  QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
111  helpEvent->pos(), this);
112  if (ctrl == QStyle::SC_MdiCloseButton)
113  QToolTip::showText(helpEvent->globalPos(), QWorkspace::tr("Close"), this);
114  else if (ctrl == QStyle::SC_MdiMinButton)
115  QToolTip::showText(helpEvent->globalPos(), QWorkspace::tr("Minimize"), this);
116  else if (ctrl == QStyle::SC_MdiNormalButton)
117  QToolTip::showText(helpEvent->globalPos(), QWorkspace::tr("Restore Down"), this);
118  else
120 #endif // QT_NO_TOOLTIP
121  }
122  return QWidget::event(event);
123 }
124 
126 {
127  option->initFrom(this);
128  option->subControls = QStyle::SC_All;
130 }
131 
133  : QWidget(widget), activeControl(QStyle::SC_None),
134  hoverControl(QStyle::SC_None)
135 {
136  setObjectName(QLatin1String("qt_maxcontrols"));
139  setMouseTracking(true);
140 }
141 
143 {
144  ensurePolished();
146  initStyleOption(&opt);
147  QSize size(48, 16);
148  return style()->sizeFromContents(QStyle::CT_MdiControls, &opt, size, this);
149 }
150 
152 {
153  if (event->button() != Qt::LeftButton) {
154  event->ignore();
155  return;
156  }
158  initStyleOption(&opt);
160  event->pos(), this);
161  activeControl = ctrl;
162  update();
163 }
164 
166 {
167  if (event->button() != Qt::LeftButton) {
168  event->ignore();
169  return;
170  }
172  initStyleOption(&opt);
174  event->pos(), this);
175  if (under_mouse == activeControl) {
176  switch (activeControl) {
178  emit _q_close();
179  break;
181  emit _q_restore();
182  break;
184  emit _q_minimize();
185  break;
186  default:
187  break;
188  }
189  }
191  update();
192 }
193 
195 {
197  update();
198 }
199 
201 {
203  initStyleOption(&opt);
205  event->pos(), this);
206  //test if hover state changes
207  if (hoverControl != under_mouse) {
208  hoverControl = under_mouse;
209  update();
210  }
211 }
212 
214 {
215  QPainter p(this);
217  initStyleOption(&opt);
218  if (activeControl == hoverControl) {
224  }
225  style()->drawComplexControl(QStyle::CC_MdiControls, &opt, &p, this);
226 }
227 
229 {
230  Q_OBJECT
232  bool autoRaise;
233  bool movable;
234 
235 public:
236  QWorkspaceTitleBar (QWidget *w, QWidget *parent, Qt::WindowFlags f = 0);
238 
239  bool isActive() const;
240  bool usesActiveColor() const;
241 
242  bool isMovable() const;
243  void setMovable(bool);
244 
245  bool autoRaise() const;
246  void setAutoRaise(bool);
247 
248  QWidget *window() const;
249  bool isTool() const;
250 
251  QSize sizeHint() const;
252  void initStyleOption(QStyleOptionTitleBar *option) const;
253 
254 public slots:
255  void setActive(bool);
256 
257 signals:
258  void doActivate();
259  void doNormal();
260  void doClose();
261  void doMaximize();
262  void doMinimize();
263  void doShade();
264  void showOperationMenu();
265  void popupOperationMenu(const QPoint&);
266  void doubleClicked();
267 
268 protected:
269  bool event(QEvent *);
270 #ifndef QT_NO_CONTEXTMENU
272 #endif
276  void mouseMoveEvent(QMouseEvent *);
277  void enterEvent(QEvent *e);
278  void leaveEvent(QEvent *e);
279  void paintEvent(QPaintEvent *p);
280 
281 private:
283 };
284 
285 
287 {
289 public:
291  :
292  lastControl(QStyle::SC_None),
293 #ifndef QT_NO_TOOLTIP
294  toolTip(0),
295 #endif
296  act(0), window(0), movable(1), pressed(0), autoraise(0), moving(0)
297  {
298  }
299 
300  Qt::WindowFlags flags;
304 #ifndef QT_NO_TOOLTIP
306 #endif
307  bool act :1;
309  bool movable :1;
310  bool pressed :1;
311  bool autoraise :1;
312  bool moving : 1;
313 
314  int titleBarState() const;
315  void readColors();
316 };
317 
319 {
320  Q_Q(const QWorkspaceTitleBar);
321  uint state = window ? window->windowState() : static_cast<Qt::WindowStates>(Qt::WindowNoState);
322  state |= uint((act && q->isActiveWindow()) ? QStyle::State_Active : QStyle::State_None);
323  return (int)state;
324 }
325 
327 {
328  Q_D(const QWorkspaceTitleBar);
329  option->initFrom(this);
330  //################
331  if (d->window && (d->flags & Qt::WindowTitleHint)) {
332  option->text = d->window->windowTitle();
333  QIcon icon = d->window->windowIcon();
334  QSize s = icon.actualSize(QSize(64, 64));
335  option->icon = icon.pixmap(s);
336  }
337  option->subControls = QStyle::SC_All;
339  option->titleBarState = d->titleBarState();
340  option->titleBarFlags = d->flags;
341  option->state &= ~QStyle::State_MouseOver;
342 }
343 
346 {
348  if (f == 0 && w)
349  f = w->windowFlags();
350  d->flags = f;
351  d->window = w;
352  d->buttonDown = QStyle::SC_None;
353  d->act = 0;
354  if (w) {
356  d->flags &= ~Qt::WindowMaximizeButtonHint;
358  }
359 
360  d->readColors();
362  setMouseTracking(true);
364 }
365 
367 {
368 }
369 
370 
371 #ifdef Q_WS_WIN
372 static inline QRgb colorref2qrgb(COLORREF col)
373 {
374  return qRgb(GetRValue(col),GetGValue(col),GetBValue(col));
375 }
376 #endif
377 
379 {
381  QPalette pal = q->palette();
382 
383  bool colorsInitialized = false;
384 
385 #ifdef Q_WS_WIN // ask system properties on windows
386 #ifndef SPI_GETGRADIENTCAPTIONS
387 #define SPI_GETGRADIENTCAPTIONS 0x1008
388 #endif
389 #ifndef COLOR_GRADIENTACTIVECAPTION
390 #define COLOR_GRADIENTACTIVECAPTION 27
391 #endif
392 #ifndef COLOR_GRADIENTINACTIVECAPTION
393 #define COLOR_GRADIENTINACTIVECAPTION 28
394 #endif
396  pal.setColor(QPalette::Active, QPalette::Highlight, colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION)));
397  pal.setColor(QPalette::Inactive, QPalette::Highlight, colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION)));
398  pal.setColor(QPalette::Active, QPalette::HighlightedText, colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT)));
399  pal.setColor(QPalette::Inactive, QPalette::HighlightedText, colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT)));
400 
401  colorsInitialized = true;
402  BOOL gradient = false;
403  SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &gradient, 0);
404 
405  if (gradient) {
408  } else {
411  }
412  }
413 #endif // Q_WS_WIN
414  if (!colorsInitialized) {
425  }
426 
427  q->setPalette(pal);
428  q->setActive(act);
429 }
430 
432 {
434  if (!d->act)
435  emit doActivate();
436  if (e->button() == Qt::LeftButton) {
438  && !rect().adjusted(5, 5, -5, 0).contains(e->pos())) {
439  // propagate border events to the QWidgetResizeHandler
440  e->ignore();
441  return;
442  }
443 
444  d->pressed = true;
446  initStyleOption(&opt);
448  e->pos(), this);
449  switch (ctrl) {
451  if (d->flags & Qt::WindowSystemMenuHint) {
452  d->buttonDown = QStyle::SC_None;
453  static QElapsedTimer *t = 0;
454  static QWorkspaceTitleBar *tc = 0;
455  if (!t)
456  t = new QElapsedTimer;
457  if (tc != this || t->elapsed() > QApplication::doubleClickInterval()) {
459  t->start();
460  tc = this;
461  } else {
462  tc = 0;
463  emit doClose();
464  return;
465  }
466  }
467  break;
468 
471  if (d->flags & Qt::WindowShadeButtonHint)
472  d->buttonDown = ctrl;
473  break;
474 
476  d->buttonDown = ctrl;
477  break;
478 
480  if (d->flags & Qt::WindowMinimizeButtonHint)
481  d->buttonDown = ctrl;
482  break;
483 
485  if (d->flags & Qt::WindowMaximizeButtonHint)
486  d->buttonDown = ctrl;
487  break;
488 
490  if (d->flags & Qt::WindowSystemMenuHint)
491  d->buttonDown = ctrl;
492  break;
493 
495  d->buttonDown = ctrl;
496  d->moveOffset = mapToParent(e->pos());
497  break;
498 
499  default:
500  break;
501  }
502  update();
503  } else {
504  d->pressed = false;
505  }
506 }
507 
508 #ifndef QT_NO_CONTEXTMENU
510 {
512  initStyleOption(&opt);
514  this);
516  e->accept();
518  } else {
519  e->ignore();
520  }
521 }
522 #endif // QT_NO_CONTEXTMENU
523 
525 {
527  if (!d->window) {
528  // could have been deleted as part of a double click event on the sysmenu
529  return;
530  }
531  if (e->button() == Qt::LeftButton && d->pressed) {
533  && !rect().adjusted(5, 5, -5, 0).contains(e->pos())) {
534  // propagate border events to the QWidgetResizeHandler
535  e->ignore();
536  d->buttonDown = QStyle::SC_None;
537  d->pressed = false;
538  return;
539  }
540  e->accept();
542  initStyleOption(&opt);
544  e->pos(), this);
545 
546  if (d->pressed) {
547  update();
548  d->pressed = false;
549  d->moving = false;
550  }
551  if (ctrl == d->buttonDown) {
552  d->buttonDown = QStyle::SC_None;
553  switch(ctrl) {
556  if(d->flags & Qt::WindowShadeButtonHint)
557  emit doShade();
558  break;
559 
561  if(d->flags & Qt::WindowMinMaxButtonsHint)
562  emit doNormal();
563  break;
564 
566  if(d->flags & Qt::WindowMinimizeButtonHint) {
567  if (d->window && d->window->isMinimized())
568  emit doNormal();
569  else
570  emit doMinimize();
571  }
572  break;
573 
575  if(d->flags & Qt::WindowMaximizeButtonHint) {
576  if(d->window && d->window->isMaximized())
577  emit doNormal();
578  else
579  emit doMaximize();
580  }
581  break;
582 
584  if(d->flags & Qt::WindowSystemMenuHint) {
585  d->buttonDown = QStyle::SC_None;
586  emit doClose();
587  return;
588  }
589  break;
590 
591  default:
592  break;
593  }
594  }
595  } else {
596  e->ignore();
597  }
598 }
599 
601 {
603  e->ignore();
605  && !rect().adjusted(5, 5, -5, 0).contains(e->pos()) && !d->pressed) {
606  // propagate border events to the QWidgetResizeHandler
607  return;
608  }
609 
611  initStyleOption(&opt);
613  e->pos(), this);
614  if(under_mouse != d->lastControl) {
615  d->lastControl = under_mouse;
616  update();
617  }
618 
619  switch (d->buttonDown) {
620  case QStyle::SC_None:
621  break;
623  break;
625  if (d->buttonDown == QStyle::SC_TitleBarLabel && d->movable && d->pressed) {
626  if (d->moving || (d->moveOffset - mapToParent(e->pos())).manhattanLength() >= 4) {
627  d->moving = true;
628  QPoint p = mapFromGlobal(e->globalPos());
629 
630  QWidget *parent = d->window ? d->window->parentWidget() : 0;
631  if(parent && parent->inherits("QWorkspaceChild")) {
632  QWidget *workspace = parent->parentWidget();
633  p = workspace->mapFromGlobal(e->globalPos());
634  if (!workspace->rect().contains(p)) {
635  if (p.x() < 0)
636  p.rx() = 0;
637  if (p.y() < 0)
638  p.ry() = 0;
639  if (p.x() > workspace->width())
640  p.rx() = workspace->width();
641  if (p.y() > workspace->height())
642  p.ry() = workspace->height();
643  }
644  }
645 
646  QPoint pp = p - d->moveOffset;
647  if (!parentWidget()->isMaximized())
648  parentWidget()->move(pp);
649  }
650  }
651  e->accept();
652  break;
653  default:
654  break;
655  }
656 }
657 
659 {
660  Q_D(const QWorkspaceTitleBar);
661  return (d->flags & Qt::WindowType_Mask) == Qt::Tool;
662 }
663 
664 // from qwidget.cpp
665 extern QString qt_setWindowTitle_helperHelper(const QString &, const QWidget*);
666 
668 {
671  initStyleOption(&opt);
673  opt.activeSubControls = d->buttonDown;
674 
675  if (d->window && (d->flags & Qt::WindowTitleHint)) {
676  QString title = qt_setWindowTitle_helperHelper(opt.text, d->window);
678  this).width();
679  opt.text = fontMetrics().elidedText(title, Qt::ElideRight, maxw);
680  }
681 
682  if (d->flags & Qt::WindowSystemMenuHint) {
684  if (d->window && (d->flags & Qt::WindowShadeButtonHint)) {
685  if (d->window->isMinimized())
687  else
689  }
690  if (d->window && (d->flags & Qt::WindowMinMaxButtonsHint)) {
691  if(d->window && d->window->isMinimized())
693  else
695  }
696  if (d->window && (d->flags & Qt::WindowMaximizeButtonHint) && !d->window->isMaximized())
698  }
699 
700  QStyle::SubControl under_mouse = QStyle::SC_None;
701  under_mouse = style()->hitTestComplexControl(QStyle::CC_TitleBar, &opt,
702  mapFromGlobal(QCursor::pos()), this);
703  if ((d->buttonDown == under_mouse) && d->pressed) {
705  } else if( autoRaise() && under_mouse != QStyle::SC_None && !d->pressed) {
706  opt.activeSubControls = under_mouse;
708  }
710 
711  QPainter p(this);
712  style()->drawComplexControl(QStyle::CC_TitleBar, &opt, &p, this);
713 }
714 
716 {
718  if (e->button() != Qt::LeftButton) {
719  e->ignore();
720  return;
721  }
722  e->accept();
724  initStyleOption(&opt);
725  switch (style()->hitTestComplexControl(QStyle::CC_TitleBar, &opt, e->pos(), this)) {
728  break;
729 
731  if (d->flags & Qt::WindowSystemMenuHint)
732  emit doClose();
733  break;
734 
735  default:
736  break;
737  }
738 }
739 
741 {
743  d->lastControl = QStyle::SC_None;
744  if(autoRaise() && !d->pressed)
745  update();
746 }
747 
749 {
751  if(autoRaise() && !d->pressed)
752  update();
755 }
756 
758 {
760  if (d->act == active)
761  return ;
762 
763  d->act = active;
764  update();
765 }
766 
768 {
769  Q_D(const QWorkspaceTitleBar);
770  return d->act;
771 }
772 
774 {
775  return (isActive() && isActiveWindow()) ||
777 }
778 
780 {
781  Q_D(const QWorkspaceTitleBar);
782  return d->window;
783 }
784 
786 {
789  d->readColors();
790  } else if (e->type() == QEvent::WindowActivate
791  || e->type() == QEvent::WindowDeactivate) {
792  if (d->act)
793  update();
794  }
795  return QWidget::event(e);
796 }
797 
799 {
801  d->movable = b;
802 }
803 
805 {
806  Q_D(const QWorkspaceTitleBar);
807  return d->movable;
808 }
809 
811 {
813  d->autoraise = b;
814 }
815 
817 {
818  Q_D(const QWorkspaceTitleBar);
819  return d->autoraise;
820 }
821 
823 {
824  ensurePolished();
826  initStyleOption(&opt);
829  return QSize(menur.width(), style()->pixelMetric(QStyle::PM_TitleBarHeight, &opt, this));
830 }
831 
900 class QWorkspaceChild : public QWidget
901 {
902  Q_OBJECT
903 
904  friend class QWorkspacePrivate;
905  friend class QWorkspace;
906  friend class QWorkspaceTitleBar;
907 
908 public:
909  QWorkspaceChild(QWidget* window, QWorkspace* parent=0, Qt::WindowFlags flags = 0);
910  ~QWorkspaceChild();
911 
912  void setActive(bool);
913  bool isActive() const;
914 
915  void adjustToFullscreen();
916 
917  QWidget* windowWidget() const;
918  QWidget* iconWidget() const;
919 
920  void doResize();
921  void doMove();
922 
923  QSize sizeHint() const;
924  QSize minimumSizeHint() const;
925 
926  QSize baseSize() const;
927 
928  int frameWidth() const;
929 
930  void show();
931 
932  bool isWindowOrIconVisible() const;
933 
934 signals:
935  void showOperationMenu();
936  void popupOperationMenu(const QPoint&);
937 
938 public slots:
939  void activate();
940  void showMinimized();
941  void showMaximized();
942  void showNormal();
943  void showShaded();
944  void internalRaise();
945  void titleBarDoubleClicked();
946 
947 protected:
948  void enterEvent(QEvent *);
949  void leaveEvent(QEvent *);
950  void childEvent(QChildEvent*);
951  void resizeEvent(QResizeEvent *);
952  void moveEvent(QMoveEvent *);
953  bool eventFilter(QObject *, QEvent *);
954 
955  void paintEvent(QPaintEvent *);
956  void changeEvent(QEvent *);
957 
958 private:
959  void updateMask();
960 
962 
963  QWidget *childWidget;
964  QWidgetResizeHandler *widgetResizeHandler;
967  QSize windowSize;
968  QSize shadeRestore;
969  QSize shadeRestoreMin;
970  bool act :1;
971  bool shademode :1;
972 };
973 
974 int QWorkspaceChild::frameWidth() const
975 {
976  return contentsRect().left();
977 }
978 
979 
980 
983 public:
993 
994  int px;
995  int py;
999 
1000  QMenu *popup, *toolPopup;
1001  enum WSActs { RestoreAct, MoveAct, ResizeAct, MinimizeAct, MaximizeAct, CloseAct, StaysOnTopAct, ShadeAct, NCountAct };
1002  QAction *actions[NCountAct];
1003 
1004  QScrollBar *vbar, *hbar;
1006  int yoffset, xoffset;
1008 
1009  void init();
1010  void insertIcon(QWidget* w);
1011  void removeIcon(QWidget* w);
1012  void place(QWidget*);
1013 
1015  void showMaximizeControls();
1016  void hideMaximizeControls();
1017  void activateWindow(QWidget* w, bool change_focus = true);
1018  void hideChild(QWorkspaceChild *c);
1019  void showWindow(QWidget* w);
1020  void maximizeWindow(QWidget* w);
1021  void minimizeWindow(QWidget* w);
1022  void normalizeWindow(QWidget* w);
1023 
1024  QRect updateWorkspace();
1025 
1026 private:
1027  void _q_normalizeActiveWindow();
1028  void _q_minimizeActiveWindow();
1029  void _q_showOperationMenu();
1030  void _q_popupOperationMenu(const QPoint&);
1031  void _q_operationMenuActivated(QAction *);
1032  void _q_scrollBarChanged();
1033  void _q_updateActions();
1035 };
1036 
1037 static bool isChildOf(QWidget * child, QWidget * parent)
1038 {
1039  if (!parent || !child)
1040  return false;
1041  QWidget * w = child;
1042  while(w && w != parent)
1043  w = w->parentWidget();
1044  return w != 0;
1045 }
1046 
1051  : QWidget(*new QWorkspacePrivate, parent, 0)
1052 {
1053  Q_D(QWorkspace);
1054  d->init();
1055 }
1056 
1057 #ifdef QT3_SUPPORT
1058 
1063  : QWidget(*new QWorkspacePrivate, parent, 0)
1064 {
1065  Q_D(QWorkspace);
1067  d->init();
1068 }
1069 #endif // QT3_SUPPORT
1070 
1074 void
1076 {
1077  Q_Q(QWorkspace);
1078 
1079  maxcontrols = 0;
1080  active = 0;
1081  maxWindow = 0;
1082  maxtools = 0;
1083  px = 0;
1084  py = 0;
1085  becomeActive = 0;
1086  popup = new QMenu(q);
1087  toolPopup = new QMenu(q);
1088  popup->setObjectName(QLatin1String("qt_internal_mdi_popup"));
1089  toolPopup->setObjectName(QLatin1String("qt_internal_mdi_tool_popup"));
1090 
1091  actions[QWorkspacePrivate::RestoreAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarNormalButton, 0, q)),
1092  QWorkspace::tr("&Restore"), q);
1094  actions[QWorkspacePrivate::ResizeAct] = new QAction(QWorkspace::tr("&Size"), q);
1095  actions[QWorkspacePrivate::MinimizeAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarMinButton, 0, q)),
1096  QWorkspace::tr("Mi&nimize"), q);
1097  actions[QWorkspacePrivate::MaximizeAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarMaxButton, 0, q)),
1098  QWorkspace::tr("Ma&ximize"), q);
1099  actions[QWorkspacePrivate::CloseAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, q)),
1100  QWorkspace::tr("&Close")
1101 #ifndef QT_NO_SHORTCUT
1103 #endif
1104  ,q);
1106  actions[QWorkspacePrivate::StaysOnTopAct] = new QAction(QWorkspace::tr("Stay on &Top"), q);
1108  actions[QWorkspacePrivate::ShadeAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarShadeButton, 0, q)),
1109  QWorkspace::tr("Sh&ade"), q);
1110 
1111  QObject::connect(popup, SIGNAL(aboutToShow()), q, SLOT(_q_updateActions()));
1112  QObject::connect(popup, SIGNAL(triggered(QAction*)), q, SLOT(_q_operationMenuActivated(QAction*)));
1113  popup->addAction(actions[QWorkspacePrivate::RestoreAct]);
1114  popup->addAction(actions[QWorkspacePrivate::MoveAct]);
1115  popup->addAction(actions[QWorkspacePrivate::ResizeAct]);
1116  popup->addAction(actions[QWorkspacePrivate::MinimizeAct]);
1117  popup->addAction(actions[QWorkspacePrivate::MaximizeAct]);
1118  popup->addSeparator();
1119  popup->addAction(actions[QWorkspacePrivate::CloseAct]);
1120 
1121  QObject::connect(toolPopup, SIGNAL(aboutToShow()), q, SLOT(_q_updateActions()));
1122  QObject::connect(toolPopup, SIGNAL(triggered(QAction*)), q, SLOT(_q_operationMenuActivated(QAction*)));
1123  toolPopup->addAction(actions[QWorkspacePrivate::MoveAct]);
1124  toolPopup->addAction(actions[QWorkspacePrivate::ResizeAct]);
1125  toolPopup->addAction(actions[QWorkspacePrivate::StaysOnTopAct]);
1126  toolPopup->addSeparator();
1127  toolPopup->addAction(actions[QWorkspacePrivate::ShadeAct]);
1128  toolPopup->addAction(actions[QWorkspacePrivate::CloseAct]);
1129 
1130 #ifndef QT_NO_SHORTCUT
1131  // Set up shortcut bindings (id -> slot), most used first
1133  foreach (const QKeySequence &seq, shortcuts)
1134  shortcutMap.insert(q->grabShortcut(seq), "activateNextWindow");
1135 
1137  foreach (const QKeySequence &seq, shortcuts)
1138  shortcutMap.insert(q->grabShortcut(seq), "activatePreviousWindow");
1139 
1141  foreach (const QKeySequence &seq, shortcuts)
1142  shortcutMap.insert(q->grabShortcut(seq), "closeActiveWindow");
1143 
1144  shortcutMap.insert(q->grabShortcut(QKeySequence(QLatin1String("ALT+-"))), "_q_showOperationMenu");
1145 #endif // QT_NO_SHORTCUT
1146 
1147  q->setBackgroundRole(QPalette::Dark);
1148  q->setAutoFillBackground(true);
1150 
1151  hbar = vbar = 0;
1152  corner = 0;
1153  xoffset = yoffset = 0;
1154 
1155  q->window()->installEventFilter(q);
1156 
1157  inTitleChange = false;
1158  updateWorkspace();
1159 }
1160 
1166 {
1167 }
1168 
1171 {
1173  return QSize(s.width()*2/3, s.height()*2/3);
1174 }
1175 
1176 
1177 #ifdef QT3_SUPPORT
1178 
1182 void QWorkspace::setPaletteBackgroundColor(const QColor & c)
1183 {
1184  setBackground(c);
1185 }
1186 
1191 void QWorkspace::setPaletteBackgroundPixmap(const QPixmap & pm)
1192 {
1193  setBackground(pm);
1194 }
1195 #endif // QT3_SUPPORT
1196 
1205 {
1206  Q_D(const QWorkspace);
1207  if (d->background.style() == Qt::NoBrush)
1208  return palette().dark();
1209  return d->background;
1210 }
1211 
1213 {
1214  Q_D(QWorkspace);
1215  d->background = background;
1217  update();
1218 }
1219 
1230 QWidget * QWorkspace::addWindow(QWidget *w, Qt::WindowFlags flags)
1231 {
1232  Q_D(QWorkspace);
1233  if (!w)
1234  return 0;
1235 
1236  w->setAutoFillBackground(true);
1237 
1239 
1240 #if 0
1241  bool wasMaximized = w->isMaximized();
1242  bool wasMinimized = w->isMinimized();
1243 #endif
1244  bool hasSize = w->testAttribute(Qt::WA_Resized);
1245  int x = w->x();
1246  int y = w->y();
1247  bool hasPos = w->testAttribute(Qt::WA_Moved);
1248  if (!hasSize && w->sizeHint().isValid())
1249  w->adjustSize();
1250 
1251  QWorkspaceChild* child = new QWorkspaceChild(w, this, flags);
1252  child->setObjectName(QLatin1String("qt_workspacechild"));
1253  child->installEventFilter(this);
1254 
1255  connect(child, SIGNAL(popupOperationMenu(QPoint)),
1256  this, SLOT(_q_popupOperationMenu(QPoint)));
1257  connect(child, SIGNAL(showOperationMenu()),
1258  this, SLOT(_q_showOperationMenu()));
1259  d->windows.append(child);
1260  if (child->isVisibleTo(this))
1261  d->focus.append(child);
1262  child->internalRaise();
1263 
1264  if (!hasPos)
1265  d->place(child);
1266  if (!hasSize)
1267  child->adjustSize();
1268  if (hasPos)
1269  child->move(x, y);
1270 
1271  return child;
1272 
1273 #if 0
1274  if (wasMaximized)
1275  w->showMaximized();
1276  else if (wasMinimized)
1277  w->showMinimized();
1278  else if (!hasBeenHidden)
1279  d->activateWindow(w);
1280 
1281  d->updateWorkspace();
1282  return child;
1283 #endif
1284 }
1285 
1288 {
1289  Q_D(QWorkspace);
1290  if (e->removed()) {
1291  if (d->windows.removeAll(static_cast<QWorkspaceChild*>(e->child()))) {
1292  d->focus.removeAll(static_cast<QWorkspaceChild*>(e->child()));
1293  if (d->maxWindow == e->child())
1294  d->maxWindow = 0;
1295  d->updateWorkspace();
1296  }
1297  }
1298 }
1299 
1301 #ifndef QT_NO_WHEELEVENT
1303 {
1304  Q_D(QWorkspace);
1305  if (!scrollBarsEnabled())
1306  return;
1307  // the scroll bars are children of the workspace, so if we receive
1308  // a wheel event we redirect to the scroll bars using a direct event
1309  // call, /not/ using sendEvent() because if the scroll bar ignores the
1310  // event QApplication::sendEvent() will propagate the event to the parent widget,
1311  // which is us, who /just/ sent it.
1312  if (d->vbar && d->vbar->isVisible() && !(e->modifiers() & Qt::AltModifier))
1313  d->vbar->event(e);
1314  else if (d->hbar && d->hbar->isVisible())
1315  d->hbar->event(e);
1316 }
1317 #endif
1318 
1319 void QWorkspacePrivate::activateWindow(QWidget* w, bool change_focus)
1320 {
1321  Q_Q(QWorkspace);
1322  if (!w) {
1323  active = 0;
1324  emit q->windowActivated(0);
1325  return;
1326  }
1327  if (!q->isVisible()) {
1328  becomeActive = w;
1329  return;
1330  }
1331 
1332  if (active && active->windowWidget() == w) {
1333  if (!isChildOf(q->focusWidget(), w)) // child window does not have focus
1334  active->setActive(true);
1335  return;
1336  }
1337 
1338  active = 0;
1339  // First deactivate all other workspace clients
1340  QList<QWorkspaceChild *>::Iterator it(windows.begin());
1341  while (it != windows.end()) {
1342  QWorkspaceChild* c = *it;
1343  ++it;
1344  if (c->windowWidget() == w)
1345  active = c;
1346  else
1347  c->setActive(false);
1348  }
1349 
1350  if (!active)
1351  return;
1352 
1353  // Then activate the new one, so the focus is stored correctly
1354  active->setActive(true);
1355 
1356  if (!active)
1357  return;
1358 
1359  if (maxWindow && maxWindow != active && active->windowWidget() &&
1360  (active->windowWidget()->windowFlags() & Qt::WindowMaximizeButtonHint))
1361  active->showMaximized();
1362 
1363  active->internalRaise();
1364 
1365  if (change_focus) {
1366  int from = focus.indexOf(active);
1367  if (from >= 0)
1368  focus.move(from, focus.size() - 1);
1369  }
1370 
1371  updateWorkspace();
1372  emit q->windowActivated(w);
1373 }
1374 
1375 
1383 {
1384  Q_D(const QWorkspace);
1385  return d->active? d->active->windowWidget() : 0;
1386 }
1387 
1394 {
1395  Q_D(QWorkspace);
1396  d->activateWindow(w, true);
1397  if (w && w->isMinimized())
1399 }
1400 
1402 {
1403  Q_Q(QWorkspace);
1404 
1405  QList<QWidget *> widgets;
1406  for (QList<QWorkspaceChild *>::Iterator it(windows.begin()); it != windows.end(); ++it)
1407  if (*it != w)
1408  widgets.append(*it);
1409 
1410  int overlap, minOverlap = 0;
1411  int possible;
1412 
1413  QRect r1(0, 0, 0, 0);
1414  QRect r2(0, 0, 0, 0);
1415  QRect maxRect = q->rect();
1416  int x = maxRect.left(), y = maxRect.top();
1417  QPoint wpos(maxRect.left(), maxRect.top());
1418 
1419  bool firstPass = true;
1420 
1421  do {
1422  if (y + w->height() > maxRect.bottom()) {
1423  overlap = -1;
1424  } else if(x + w->width() > maxRect.right()) {
1425  overlap = -2;
1426  } else {
1427  overlap = 0;
1428 
1429  r1.setRect(x, y, w->width(), w->height());
1430 
1431  QWidget *l;
1432  QList<QWidget *>::Iterator it(widgets.begin());
1433  while (it != widgets.end()) {
1434  l = *it;
1435  ++it;
1436 
1437  if (maxWindow == l)
1438  r2 = QStyle::visualRect(q->layoutDirection(), maxRect, maxRestore);
1439  else
1440  r2 = QStyle::visualRect(q->layoutDirection(), maxRect,
1441  QRect(l->x(), l->y(), l->width(), l->height()));
1442 
1443  if (r2.intersects(r1)) {
1444  r2.setCoords(qMax(r1.left(), r2.left()),
1445  qMax(r1.top(), r2.top()),
1446  qMin(r1.right(), r2.right()),
1447  qMin(r1.bottom(), r2.bottom())
1448  );
1449 
1450  overlap += (r2.right() - r2.left()) *
1451  (r2.bottom() - r2.top());
1452  }
1453  }
1454  }
1455 
1456  if (overlap == 0) {
1457  wpos = QPoint(x, y);
1458  break;
1459  }
1460 
1461  if (firstPass) {
1462  firstPass = false;
1463  minOverlap = overlap;
1464  } else if (overlap >= 0 && overlap < minOverlap) {
1465  minOverlap = overlap;
1466  wpos = QPoint(x, y);
1467  }
1468 
1469  if (overlap > 0) {
1470  possible = maxRect.right();
1471  if (possible - w->width() > x) possible -= w->width();
1472 
1473  QWidget *l;
1474  QList<QWidget *>::Iterator it(widgets.begin());
1475  while (it != widgets.end()) {
1476  l = *it;
1477  ++it;
1478  if (maxWindow == l)
1479  r2 = QStyle::visualRect(q->layoutDirection(), maxRect, maxRestore);
1480  else
1481  r2 = QStyle::visualRect(q->layoutDirection(), maxRect,
1482  QRect(l->x(), l->y(), l->width(), l->height()));
1483 
1484  if((y < r2.bottom()) && (r2.top() < w->height() + y)) {
1485  if(r2.right() > x)
1486  possible = possible < r2.right() ?
1487  possible : r2.right();
1488 
1489  if(r2.left() - w->width() > x)
1490  possible = possible < r2.left() - w->width() ?
1491  possible : r2.left() - w->width();
1492  }
1493  }
1494 
1495  x = possible;
1496  } else if (overlap == -2) {
1497  x = maxRect.left();
1498  possible = maxRect.bottom();
1499 
1500  if (possible - w->height() > y) possible -= w->height();
1501 
1502  QWidget *l;
1503  QList<QWidget *>::Iterator it(widgets.begin());
1504  while (it != widgets.end()) {
1505  l = *it;
1506  ++it;
1507  if (maxWindow == l)
1508  r2 = QStyle::visualRect(q->layoutDirection(), maxRect, maxRestore);
1509  else
1510  r2 = QStyle::visualRect(q->layoutDirection(), maxRect,
1511  QRect(l->x(), l->y(), l->width(), l->height()));
1512 
1513  if(r2.bottom() > y)
1514  possible = possible < r2.bottom() ?
1515  possible : r2.bottom();
1516 
1517  if(r2.top() - w->height() > y)
1518  possible = possible < r2.top() - w->height() ?
1519  possible : r2.top() - w->height();
1520  }
1521 
1522  y = possible;
1523  }
1524  }
1525  while(overlap != 0 && overlap != -1);
1526 
1527  QRect resultRect = w->geometry();
1528  resultRect.moveTo(wpos);
1529  w->setGeometry(QStyle::visualRect(q->layoutDirection(), maxRect, resultRect));
1530  updateWorkspace();
1531 }
1532 
1533 
1535 {
1536  Q_Q(QWorkspace);
1537  if (!w || icons.contains(w))
1538  return;
1539  icons.append(w);
1540  if (w->parentWidget() != q) {
1541  w->setParent(q, 0);
1542  w->move(0,0);
1543  }
1544  QRect cr = updateWorkspace();
1545  int x = 0;
1546  int y = cr.height() - w->height();
1547 
1548  QList<QWidget *>::Iterator it(icons.begin());
1549  while (it != icons.end()) {
1550  QWidget* i = *it;
1551  ++it;
1552  if (x > 0 && x + i->width() > cr.width()){
1553  x = 0;
1554  y -= i->height();
1555  }
1556 
1557  if (i != w &&
1558  i->geometry().intersects(QRect(x, y, w->width(), w->height())))
1559  x += i->width();
1560  }
1561  w->move(x, y);
1562 
1563  if (q->isVisibleTo(q->parentWidget())) {
1564  w->show();
1565  w->lower();
1566  }
1567  updateWorkspace();
1568 }
1569 
1570 
1572 {
1573  if (icons.removeAll(w))
1574  w->hide();
1575 }
1576 
1577 
1580 {
1581  Q_D(QWorkspace);
1582  if (d->maxWindow) {
1583  d->maxWindow->adjustToFullscreen();
1584  if (d->maxWindow->windowWidget())
1585  d->maxWindow->windowWidget()->overrideWindowState(Qt::WindowMaximized);
1586  }
1587  d->updateWorkspace();
1588 }
1589 
1592 {
1593  Q_D(QWorkspace);
1594  if (d->maxWindow)
1595  d->showMaximizeControls();
1596  QWidget::showEvent(e);
1597  if (d->becomeActive) {
1598  d->activateWindow(d->becomeActive);
1599  d->becomeActive = 0;
1600  } else if (d->windows.count() > 0 && !d->active) {
1601  d->activateWindow(d->windows.first()->windowWidget());
1602  }
1603 
1604 // // force a frame repaint - this is a workaround for what seems to be a bug
1605 // // introduced when changing the QWidget::show() implementation. Might be
1606 // // a windows bug as well though.
1607 // for (int i = 0; i < d->windows.count(); ++i) {
1608 // QWorkspaceChild* c = d->windows.at(i);
1609 // c->update(c->rect());
1610 // }
1611 
1612  d->updateWorkspace();
1613 }
1614 
1617 {
1618  Q_D(QWorkspace);
1619  if (!isVisible())
1620  d->hideMaximizeControls();
1621 }
1622 
1625 {
1626  Q_D(QWorkspace);
1627 
1628  if (d->background.style() != Qt::NoBrush) {
1629  QPainter p(this);
1630  p.fillRect(0, 0, width(), height(), d->background);
1631  }
1632 }
1633 
1635 {
1636  QWorkspaceChild* c = findChild(w);
1637 
1638  if (!w || !(w->windowFlags() & Qt::WindowMinimizeButtonHint))
1639  return;
1640 
1641  if (c) {
1642  bool wasMax = false;
1643  if (c == maxWindow) {
1644  wasMax = true;
1645  maxWindow = 0;
1646  hideMaximizeControls();
1647  for (QList<QWorkspaceChild *>::Iterator it(windows.begin()); it != windows.end(); ++it) {
1648  QWorkspaceChild* c = *it;
1649  if (c->titlebar)
1650  c->titlebar->setMovable(true);
1651  c->widgetResizeHandler->setActive(true);
1652  }
1653  }
1654  c->hide();
1655  if (wasMax)
1656  c->setGeometry(maxRestore);
1657  if (!focus.contains(c))
1658  focus.append(c);
1659  insertIcon(c->iconWidget());
1660 
1661  if (!maxWindow)
1662  activateWindow(w);
1663 
1664  updateWorkspace();
1665 
1668  }
1669 }
1670 
1672 {
1673  Q_Q(QWorkspace);
1674  QWorkspaceChild* c = findChild(w);
1675  if (!w)
1676  return;
1677  if (c) {
1679  hideMaximizeControls();
1680  if (!maxmenubar || q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q) || !maxWindow) {
1681  if (w->minimumSize() != w->maximumSize())
1682  c->widgetResizeHandler->setActive(true);
1683  if (c->titlebar)
1684  c->titlebar->setMovable(true);
1685  }
1688 
1689  if (c == maxWindow) {
1690  c->setGeometry(maxRestore);
1691  maxWindow = 0;
1692  } else {
1693  if (c->iconw)
1694  removeIcon(c->iconw->parentWidget());
1695  c->show();
1696  }
1697 
1698  hideMaximizeControls();
1699  for (QList<QWorkspaceChild *>::Iterator it(windows.begin()); it != windows.end(); ++it) {
1700  QWorkspaceChild* c = *it;
1701  if (c->titlebar)
1702  c->titlebar->setMovable(true);
1703  if (c->childWidget && c->childWidget->minimumSize() != c->childWidget->maximumSize())
1704  c->widgetResizeHandler->setActive(true);
1705  }
1706  activateWindow(w, true);
1707  updateWorkspace();
1708  }
1709 }
1710 
1712 {
1713  Q_Q(QWorkspace);
1714  QWorkspaceChild* c = findChild(w);
1715 
1716  if (!w || !(w->windowFlags() & Qt::WindowMaximizeButtonHint))
1717  return;
1718 
1719  if (!c || c == maxWindow)
1720  return;
1721 
1722  bool updatesEnabled = q->updatesEnabled();
1723  q->setUpdatesEnabled(false);
1724 
1725  if (c->iconw && icons.contains(c->iconw->parentWidget()))
1726  normalizeWindow(w);
1727  QRect r(c->geometry());
1728  QWorkspaceChild *oldMaxWindow = maxWindow;
1729  maxWindow = c;
1730 
1731  showMaximizeControls();
1732 
1733  c->adjustToFullscreen();
1734  c->show();
1735  c->internalRaise();
1736  if (oldMaxWindow != c) {
1737  if (oldMaxWindow) {
1738  oldMaxWindow->setGeometry(maxRestore);
1739  oldMaxWindow->overrideWindowState(Qt::WindowNoState);
1740  if(oldMaxWindow->windowWidget())
1741  oldMaxWindow->windowWidget()->overrideWindowState(Qt::WindowNoState);
1742  }
1743  maxRestore = r;
1744  }
1745 
1746  activateWindow(w);
1747 
1748  if(!maxmenubar || q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) {
1749  if (!active && becomeActive) {
1750  active = (QWorkspaceChild*)becomeActive->parentWidget();
1751  active->setActive(true);
1752  becomeActive = 0;
1753  emit q->windowActivated(active->windowWidget());
1754  }
1755  c->widgetResizeHandler->setActive(false);
1756  if (c->titlebar)
1757  c->titlebar->setMovable(false);
1758  }
1759  updateWorkspace();
1760 
1763  q->setUpdatesEnabled(updatesEnabled);
1764 }
1765 
1767 {
1769  minimizeWindow(w);
1770  else if ((maxWindow || w->isMaximized()) && w->windowFlags() & Qt::WindowMaximizeButtonHint)
1771  maximizeWindow(w);
1772  else if (w->windowFlags() & Qt::WindowMaximizeButtonHint)
1773  normalizeWindow(w);
1774  else
1775  w->parentWidget()->show();
1776  if (maxWindow)
1777  maxWindow->internalRaise();
1778  updateWorkspace();
1779 }
1780 
1781 
1783 {
1784  QList<QWorkspaceChild *>::Iterator it(windows.begin());
1785  while (it != windows.end()) {
1786  QWorkspaceChild* c = *it;
1787  ++it;
1788  if (c->windowWidget() == w)
1789  return c;
1790  }
1791  return 0;
1792 }
1793 
1802 {
1803  Q_D(const QWorkspace);
1804  QWidgetList windows;
1805  if (order == StackingOrder) {
1806  QObjectList cl = children();
1807  for (int i = 0; i < cl.size(); ++i) {
1809  if (c && c->isWindowOrIconVisible())
1810  windows.append(c->windowWidget());
1811  }
1812  } else {
1813  QList<QWorkspaceChild *>::ConstIterator it(d->windows.begin());
1814  while (it != d->windows.end()) {
1815  QWorkspaceChild* c = *it;
1816  ++it;
1817  if (c && c->isWindowOrIconVisible())
1818  windows.append(c->windowWidget());
1819  }
1820  }
1821  return windows;
1822 }
1823 
1824 
1827 {
1828 #ifndef QT_NO_SHORTCUT
1829  Q_D(QWorkspace);
1830  if (e->type() == QEvent::Shortcut) {
1831  QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
1832  const char *theSlot = d->shortcutMap.value(se->shortcutId(), 0);
1833  if (theSlot)
1834  QMetaObject::invokeMethod(this, theSlot);
1835  } else
1836 #endif
1837  if (e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut){
1838  return true;
1839  }
1840  return QWidget::event(e);
1841 }
1842 
1845 {
1846  Q_D(QWorkspace);
1847  static QElapsedTimer* t = 0;
1848  static QWorkspace* tc = 0;
1849  if (o == d->maxtools) {
1850  switch (e->type()) {
1852  {
1853  QMenuBar* b = (QMenuBar*)o->parent();
1854  if (!t)
1855  t = new QElapsedTimer;
1856  if (tc != this || t->elapsed() > QApplication::doubleClickInterval()) {
1857  if (isRightToLeft()) {
1858  QPoint p = b->mapToGlobal(QPoint(b->x() + b->width(), b->y() + b->height()));
1859  p.rx() -= d->popup->sizeHint().width();
1860  d->_q_popupOperationMenu(p);
1861  } else {
1862  d->_q_popupOperationMenu(b->mapToGlobal(QPoint(b->x(), b->y() + b->height())));
1863  }
1864  t->start();
1865  tc = this;
1866  } else {
1867  tc = 0;
1869  }
1870  return true;
1871  }
1872  default:
1873  break;
1874  }
1875  return QWidget::eventFilter(o, e);
1876  }
1877  switch (e->type()) {
1878  case QEvent::HideToParent:
1879  break;
1880  case QEvent::ShowToParent:
1881  if (QWorkspaceChild *c = qobject_cast<QWorkspaceChild*>(o))
1882  if (!d->focus.contains(c))
1883  d->focus.append(c);
1884  d->updateWorkspace();
1885  break;
1887  if (!d->inTitleChange) {
1888  if (o == window())
1889  d->topTitle = window()->windowTitle();
1890  if (d->maxWindow && d->maxWindow->windowWidget() && d->topTitle.size()) {
1891  d->inTitleChange = true;
1892  window()->setWindowTitle(tr("%1 - [%2]")
1893  .arg(d->topTitle).arg(d->maxWindow->windowWidget()->windowTitle()));
1894  d->inTitleChange = false;
1895  }
1896  }
1897  break;
1898 
1900  if (o == d->maxWindow)
1901  window()->setWindowModified(d->maxWindow->isWindowModified());
1902  break;
1903 
1904  case QEvent::Close:
1905  if (o == window())
1906  {
1907  QList<QWorkspaceChild *>::Iterator it(d->windows.begin());
1908  while (it != d->windows.end()) {
1909  QWorkspaceChild* c = *it;
1910  ++it;
1911  if (c->shademode)
1912  c->showShaded();
1913  }
1914  } else if (qobject_cast<QWorkspaceChild*>(o)) {
1915  d->popup->hide();
1916  }
1917  d->updateWorkspace();
1918  break;
1919  default:
1920  break;
1921  }
1922  return QWidget::eventFilter(o, e);
1923 }
1924 
1926 {
1927  // don't search recursively to avoid finding a menu bar of a
1928  // mainwindow that happens to be a workspace window (like
1929  // a mainwindow in designer)
1931  for (int i = 0; i < children.count(); ++i) {
1932  QMenuBar *bar = qobject_cast<QMenuBar *>(children.at(i));
1933  if (bar)
1934  return bar;
1935  }
1936  return 0;
1937 }
1938 
1940 {
1941  Q_Q(QWorkspace);
1942  Q_ASSERT(maxWindow);
1943 
1944  // merge windowtitle and modified state
1945  if (!topTitle.size())
1946  topTitle = q->window()->windowTitle();
1947 
1948  if (maxWindow->windowWidget()) {
1949  QString docTitle = maxWindow->windowWidget()->windowTitle();
1950  if (topTitle.size() && docTitle.size()) {
1951  inTitleChange = true;
1952  q->window()->setWindowTitle(QWorkspace::tr("%1 - [%2]").arg(topTitle).arg(docTitle));
1953  inTitleChange = false;
1954  }
1955  q->window()->setWindowModified(maxWindow->windowWidget()->isWindowModified());
1956  }
1957 
1958  if (!q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) {
1959  QMenuBar* b = 0;
1960 
1961  // Do a breadth-first search first on every parent,
1962  QWidget* w = q->parentWidget();
1963  while (w) {
1964  b = findMenuBar(w);
1965  if (b)
1966  break;
1967  w = w->parentWidget();
1968  }
1969 
1970  // last attempt.
1971  if (!b)
1972  b = findMenuBar(q->window());
1973 
1974  if (!b)
1975  return;
1976 
1977  if (!maxcontrols) {
1978  maxmenubar = b;
1979  maxcontrols = new QMDIControl(b);
1980  QObject::connect(maxcontrols, SIGNAL(_q_minimize()),
1981  q, SLOT(_q_minimizeActiveWindow()));
1982  QObject::connect(maxcontrols, SIGNAL(_q_restore()),
1983  q, SLOT(_q_normalizeActiveWindow()));
1984  QObject::connect(maxcontrols, SIGNAL(_q_close()),
1985  q, SLOT(closeActiveWindow()));
1986  }
1987 
1988  b->setCornerWidget(maxcontrols);
1989  if (b->isVisible())
1990  maxcontrols->show();
1991  if (!active && becomeActive) {
1992  active = (QWorkspaceChild*)becomeActive->parentWidget();
1993  active->setActive(true);
1994  becomeActive = 0;
1995  emit q->windowActivated(active->windowWidget());
1996  }
1997  if (active) {
1998  if (!maxtools) {
1999  maxtools = new QLabel(q->window());
2000  maxtools->setObjectName(QLatin1String("qt_maxtools"));
2001  maxtools->installEventFilter(q);
2002  }
2003  if (active->windowWidget() && !active->windowWidget()->windowIcon().isNull()) {
2004  QIcon icon = active->windowWidget()->windowIcon();
2005  int iconSize = maxcontrols->size().height();
2006  maxtools->setPixmap(icon.pixmap(QSize(iconSize, iconSize)));
2007  } else {
2008  QPixmap pm = q->style()->standardPixmap(QStyle::SP_TitleBarMenuButton, 0, q);
2009  if (pm.isNull()) {
2010  pm = QPixmap(14,14);
2011  pm.fill(Qt::black);
2012  }
2013  maxtools->setPixmap(pm);
2014  }
2015  b->setCornerWidget(maxtools, Qt::TopLeftCorner);
2016  if (b->isVisible())
2017  maxtools->show();
2018  }
2019  }
2020 }
2021 
2022 
2024 {
2025  Q_Q(QWorkspace);
2026  if (maxmenubar && !q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) {
2027  if (maxmenubar) {
2028  maxmenubar->setCornerWidget(0, Qt::TopLeftCorner);
2029  maxmenubar->setCornerWidget(0, Qt::TopRightCorner);
2030  }
2031  if (maxcontrols) {
2032  maxcontrols->deleteLater();
2033  maxcontrols = 0;
2034  }
2035  if (maxtools) {
2036  maxtools->deleteLater();
2037  maxtools = 0;
2038  }
2039  }
2040 
2041  //unmerge the title bar/modification state
2042  if (topTitle.size()) {
2043  inTitleChange = true;
2044  q->window()->setWindowTitle(topTitle);
2045  inTitleChange = false;
2046  }
2047  q->window()->setWindowModified(false);
2048 }
2049 
2056 {
2057  Q_D(QWorkspace);
2058  if (d->maxWindow && d->maxWindow->windowWidget())
2059  d->maxWindow->windowWidget()->close();
2060  else if (d->active && d->active->windowWidget())
2061  d->active->windowWidget()->close();
2062  d->updateWorkspace();
2063 }
2064 
2074 {
2075  Q_D(QWorkspace);
2076  bool did_close = true;
2077  QList<QWorkspaceChild *>::const_iterator it = d->windows.constBegin();
2078  while (it != d->windows.constEnd() && did_close) {
2079  QWorkspaceChild *c = *it;
2080  ++it;
2081  if (c->windowWidget() && !c->windowWidget()->isHidden())
2082  did_close = c->windowWidget()->close();
2083  }
2084 }
2085 
2087 {
2088  if (maxWindow)
2089  maxWindow->showNormal();
2090  else if (active)
2091  active->showNormal();
2092 }
2093 
2095 {
2096  if (maxWindow)
2097  maxWindow->showMinimized();
2098  else if (active)
2099  active->showMinimized();
2100 }
2101 
2103 {
2104  Q_Q(QWorkspace);
2105  if (!active || !active->windowWidget())
2106  return;
2107  Q_ASSERT((active->windowWidget()->windowFlags() & Qt::WindowSystemMenuHint));
2108  QPoint p;
2109  QMenu *popup = (active->titlebar && active->titlebar->isTool()) ? toolPopup : this->popup;
2110  if (q->isRightToLeft()) {
2111  p = QPoint(active->windowWidget()->mapToGlobal(QPoint(active->windowWidget()->width(),0)));
2112  p.rx() -= popup->sizeHint().width();
2113  } else {
2114  p = QPoint(active->windowWidget()->mapToGlobal(QPoint(0,0)));
2115  }
2116  if (!active->isVisible()) {
2117  p = active->iconWidget()->mapToGlobal(QPoint(0,0));
2118  p.ry() -= popup->sizeHint().height();
2119  }
2120  _q_popupOperationMenu(p);
2121 }
2122 
2124 {
2125  if (!active || !active->windowWidget() || !(active->windowWidget()->windowFlags() & Qt::WindowSystemMenuHint))
2126  return;
2127  if (active->titlebar && active->titlebar->isTool())
2128  toolPopup->popup(p);
2129  else
2130  popup->popup(p);
2131 }
2132 
2134 {
2135  Q_Q(QWorkspace);
2136  for (int i = 1; i < NCountAct-1; i++) {
2137  bool enable = active != 0;
2138  actions[i]->setEnabled(enable);
2139  }
2140 
2141  if (!active || !active->windowWidget())
2142  return;
2143 
2144  QWidget *windowWidget = active->windowWidget();
2145  bool canResize = windowWidget->maximumSize() != windowWidget->minimumSize();
2146  actions[QWorkspacePrivate::ResizeAct]->setEnabled(canResize);
2148  actions[QWorkspacePrivate::MaximizeAct]->setEnabled((windowWidget->windowFlags() & Qt::WindowMaximizeButtonHint) && canResize);
2149 
2150  if (active == maxWindow) {
2151  actions[QWorkspacePrivate::MoveAct]->setEnabled(false);
2152  actions[QWorkspacePrivate::ResizeAct]->setEnabled(false);
2153  actions[QWorkspacePrivate::MaximizeAct]->setEnabled(false);
2154  actions[QWorkspacePrivate::RestoreAct]->setEnabled(true);
2155  } else if (active->isVisible()){
2156  actions[QWorkspacePrivate::RestoreAct]->setEnabled(false);
2157  } else {
2158  actions[QWorkspacePrivate::MoveAct]->setEnabled(false);
2159  actions[QWorkspacePrivate::ResizeAct]->setEnabled(false);
2160  actions[QWorkspacePrivate::MinimizeAct]->setEnabled(false);
2161  actions[QWorkspacePrivate::RestoreAct]->setEnabled(true);
2162  }
2163  if (active->shademode) {
2165  QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarUnshadeButton, 0, q)));
2166  actions[QWorkspacePrivate::ShadeAct]->setText(QWorkspace::tr("&Unshade"));
2167  } else {
2169  QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarShadeButton, 0, q)));
2170  actions[QWorkspacePrivate::ShadeAct]->setText(QWorkspace::tr("Sh&ade"));
2171  }
2172  actions[QWorkspacePrivate::StaysOnTopAct]->setEnabled(!active->shademode && canResize);
2174  (active->windowWidget()->windowFlags() & Qt::WindowStaysOnTopHint));
2175 }
2176 
2178 {
2179  if (!active)
2180  return;
2181  if(action == actions[QWorkspacePrivate::RestoreAct]) {
2182  active->showNormal();
2183  } else if(action == actions[QWorkspacePrivate::MoveAct]) {
2184  active->doMove();
2185  } else if(action == actions[QWorkspacePrivate::ResizeAct]) {
2186  if (active->shademode)
2187  active->showShaded();
2188  active->doResize();
2189  } else if(action == actions[QWorkspacePrivate::MinimizeAct]) {
2190  active->showMinimized();
2191  } else if(action == actions[QWorkspacePrivate::MaximizeAct]) {
2192  active->showMaximized();
2193  } else if(action == actions[QWorkspacePrivate::ShadeAct]) {
2194  active->showShaded();
2195  } else if(action == actions[QWorkspacePrivate::StaysOnTopAct]) {
2196  if(QWidget* w = active->windowWidget()) {
2197  if ((w->windowFlags() & Qt::WindowStaysOnTopHint)) {
2198  w->overrideWindowFlags(w->windowFlags() & ~Qt::WindowStaysOnTopHint);
2199  } else {
2200  w->overrideWindowFlags(w->windowFlags() | Qt::WindowStaysOnTopHint);
2201  w->parentWidget()->raise();
2202  }
2203  }
2204  }
2205 }
2206 
2207 
2209 {
2210  Q_Q(QWorkspace);
2211 
2212 // bool updatesEnabled = q->updatesEnabled();
2213 // q->setUpdatesEnabled(false);
2214  focus.removeAll(c);
2215  QRect restore;
2216  if (maxWindow == c)
2217  restore = maxRestore;
2218  if (active == c) {
2219  q->setFocus();
2220  q->activatePreviousWindow();
2221  }
2222  if (active == c)
2223  activateWindow(0);
2224  if (maxWindow == c) {
2225  hideMaximizeControls();
2226  maxWindow = 0;
2227  }
2228  c->hide();
2229  if (!restore.isEmpty())
2230  c->setGeometry(restore);
2231 // q->setUpdatesEnabled(updatesEnabled);
2232 }
2233 
2241 {
2242  Q_D(QWorkspace);
2243 
2244  if (d->focus.isEmpty())
2245  return;
2246  if (!d->active) {
2247  if (d->focus.first())
2248  d->activateWindow(d->focus.first()->windowWidget(), false);
2249  return;
2250  }
2251 
2252  int a = d->focus.indexOf(d->active) + 1;
2253 
2254  a = a % d->focus.count();
2255 
2256  if (d->focus.at(a))
2257  d->activateWindow(d->focus.at(a)->windowWidget(), false);
2258  else
2259  d->activateWindow(0);
2260 }
2261 
2269 {
2270  Q_D(QWorkspace);
2271 
2272  if (d->focus.isEmpty())
2273  return;
2274  if (!d->active) {
2275  if (d->focus.last())
2276  d->activateWindow(d->focus.first()->windowWidget(), false);
2277  else
2278  d->activateWindow(0);
2279  return;
2280  }
2281 
2282  int a = d->focus.indexOf(d->active) - 1;
2283  if (a < 0)
2284  a = d->focus.count()-1;
2285 
2286  if (d->focus.at(a))
2287  d->activateWindow(d->focus.at(a)->windowWidget(), false);
2288  else
2289  d->activateWindow(0);
2290 }
2291 
2292 
2309 {
2310  Q_D(QWorkspace);
2311  blockSignals(true);
2312  if (d->maxWindow)
2313  d->maxWindow->showNormal();
2314 
2315  if (d->vbar) {
2316  d->vbar->blockSignals(true);
2317  d->vbar->setValue(0);
2318  d->vbar->blockSignals(false);
2319  d->hbar->blockSignals(true);
2320  d->hbar->setValue(0);
2321  d->hbar->blockSignals(false);
2322  d->_q_scrollBarChanged();
2323  }
2324 
2325  const int xoffset = 13;
2326  const int yoffset = 20;
2327 
2328  // make a list of all relevant mdi clients
2329  QList<QWorkspaceChild *> widgets;
2330  QList<QWorkspaceChild *>::Iterator it(d->windows.begin());
2331  QWorkspaceChild* wc = 0;
2332 
2333  for (it = d->focus.begin(); it != d->focus.end(); ++it) {
2334  wc = *it;
2335  if (wc->windowWidget()->isVisibleTo(this) && !(wc->titlebar && wc->titlebar->isTool()))
2336  widgets.append(wc);
2337  }
2338 
2339  int x = 0;
2340  int y = 0;
2341 
2342  it = widgets.begin();
2343  while (it != widgets.end()) {
2344  QWorkspaceChild *child = *it;
2345  ++it;
2346 
2347  QSize prefSize = child->windowWidget()->sizeHint().expandedTo(qSmartMinSize(child->windowWidget()));
2348  if (!prefSize.isValid())
2349  prefSize = child->windowWidget()->size();
2350  prefSize = prefSize.expandedTo(qSmartMinSize(child->windowWidget()));
2351  if (prefSize.isValid())
2352  prefSize += QSize(child->baseSize().width(), child->baseSize().height());
2353 
2354  int w = prefSize.width();
2355  int h = prefSize.height();
2356 
2357  child->showNormal();
2358  if (y + h > height())
2359  y = 0;
2360  if (x + w > width())
2361  x = 0;
2362  child->setGeometry(x, y, w, h);
2363  x += xoffset;
2364  y += yoffset;
2365  child->internalRaise();
2366  }
2367  d->updateWorkspace();
2368  blockSignals(false);
2369 }
2370 
2377 {
2378  Q_D(QWorkspace);
2379  blockSignals(true);
2380  QWidget *oldActive = d->active ? d->active->windowWidget() : 0;
2381  if (d->maxWindow)
2382  d->maxWindow->showNormal();
2383 
2384  if (d->vbar) {
2385  d->vbar->blockSignals(true);
2386  d->vbar->setValue(0);
2387  d->vbar->blockSignals(false);
2388  d->hbar->blockSignals(true);
2389  d->hbar->setValue(0);
2390  d->hbar->blockSignals(false);
2391  d->_q_scrollBarChanged();
2392  }
2393 
2394  int rows = 1;
2395  int cols = 1;
2396  int n = 0;
2397  QWorkspaceChild* c;
2398 
2399  QList<QWorkspaceChild *>::Iterator it(d->windows.begin());
2400  while (it != d->windows.end()) {
2401  c = *it;
2402  ++it;
2403  if (!c->windowWidget()->isHidden()
2405  && !c->iconw)
2406  n++;
2407  }
2408 
2409  while (rows * cols < n) {
2410  if (cols <= rows)
2411  cols++;
2412  else
2413  rows++;
2414  }
2415  int add = cols * rows - n;
2416  bool* used = new bool[cols*rows];
2417  for (int i = 0; i < rows*cols; i++)
2418  used[i] = false;
2419 
2420  int row = 0;
2421  int col = 0;
2422  int w = width() / cols;
2423  int h = height() / rows;
2424 
2425  it = d->windows.begin();
2426  while (it != d->windows.end()) {
2427  c = *it;
2428  ++it;
2429  if (c->iconw || c->windowWidget()->isHidden() || (c->titlebar && c->titlebar->isTool()))
2430  continue;
2431  if (!row && !col) {
2432  w -= c->baseSize().width();
2433  h -= c->baseSize().height();
2434  }
2436  QPoint p = c->pos();
2437  if (p.x()+c->width() < 0)
2438  p.setX(0);
2439  if (p.x() > width())
2440  p.setX(width() - c->width());
2441  if (p.y() + 10 < 0)
2442  p.setY(0);
2443  if (p.y() > height())
2444  p.setY(height() - c->height());
2445 
2446  if (p != c->pos())
2447  c->QWidget::move(p);
2448  } else {
2449  c->showNormal();
2450  used[row*cols+col] = true;
2451  QSize sz(w, h);
2452  QSize bsize(c->baseSize());
2453  sz = sz.expandedTo(c->windowWidget()->minimumSize()).boundedTo(c->windowWidget()->maximumSize());
2454  sz += bsize;
2455 
2456  if ( add ) {
2457  if (sz.height() == h + bsize.height()) // no relevant constrains
2458  sz.rheight() *= 2;
2459  used[(row+1)*cols+col] = true;
2460  add--;
2461  }
2462 
2463  c->setGeometry(col*w + col*bsize.width(), row*h + row*bsize.height(), sz.width(), sz.height());
2464 
2465  while(row < rows && col < cols && used[row*cols+col]) {
2466  col++;
2467  if (col == cols) {
2468  col = 0;
2469  row++;
2470  }
2471  }
2472  }
2473  }
2474  delete [] used;
2475 
2476  d->activateWindow(oldActive);
2477  d->updateWorkspace();
2478  blockSignals(false);
2479 }
2480 
2487 {
2488  Q_D(QWorkspace);
2489 
2490  QRect cr = d->updateWorkspace();
2491  int x = 0;
2492  int y = -1;
2493 
2494  QList<QWidget *>::Iterator it(d->icons.begin());
2495  while (it != d->icons.end()) {
2496  QWidget* i = *it;
2497  if (y == -1)
2498  y = cr.height() - i->height();
2499  if (x > 0 && x + i->width() > cr.width()) {
2500  x = 0;
2501  y -= i->height();
2502  }
2503  i->move(x, y);
2504  x += i->width();
2505  ++it;
2506  }
2507  d->updateWorkspace();
2508 }
2509 
2510 
2512  : QWidget(parent,
2514 {
2517  setMouseTracking(true);
2518  act = false;
2519  iconw = 0;
2520  shademode = false;
2521  titlebar = 0;
2522  setAutoFillBackground(true);
2523 
2525  if (window) {
2526  flags |= (window->windowFlags() & Qt::MSWindowsOwnDC);
2527  if (flags)
2528  window->setParent(this, flags & ~Qt::WindowType_Mask);
2529  else
2530  window->setParent(this);
2531  }
2532 
2533  if (window && (flags & (Qt::WindowTitleHint
2538  titlebar = new QWorkspaceTitleBar(window, this, flags);
2539  connect(titlebar, SIGNAL(doActivate()),
2540  this, SLOT(activate()));
2541  connect(titlebar, SIGNAL(doClose()),
2542  window, SLOT(close()));
2543  connect(titlebar, SIGNAL(doMinimize()),
2544  this, SLOT(showMinimized()));
2545  connect(titlebar, SIGNAL(doNormal()),
2546  this, SLOT(showNormal()));
2547  connect(titlebar, SIGNAL(doMaximize()),
2548  this, SLOT(showMaximized()));
2550  this, SIGNAL(popupOperationMenu(QPoint)));
2552  this, SIGNAL(showOperationMenu()));
2553  connect(titlebar, SIGNAL(doShade()),
2554  this, SLOT(showShaded()));
2555  connect(titlebar, SIGNAL(doubleClicked()),
2556  this, SLOT(titleBarDoubleClicked()));
2557  }
2558 
2559  setMinimumSize(128, 0);
2560  int fw = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this);
2561  setContentsMargins(fw, fw, fw, fw);
2562 
2563  childWidget = window;
2564  if (!childWidget)
2565  return;
2566 
2568 
2569  QPoint p;
2570  QSize s;
2571  QSize cs;
2572 
2573  bool hasBeenResized = childWidget->testAttribute(Qt::WA_Resized);
2574 
2575  if (!hasBeenResized)
2577  else
2578  cs = childWidget->size();
2579 
2580  windowSize = cs;
2581 
2582  int th = titlebar ? titlebar->sizeHint().height() : 0;
2583  if (titlebar) {
2584  if (!childWidget->windowIcon().isNull())
2586 
2588  th -= contentsRect().y();
2589 
2590  p = QPoint(contentsRect().x(),
2591  th + contentsRect().y());
2592  s = QSize(cs.width() + 2*frameWidth(),
2593  cs.height() + 2*frameWidth() + th);
2594  } else {
2595  p = QPoint(contentsRect().x(), contentsRect().y());
2596  s = QSize(cs.width() + 2*frameWidth(),
2597  cs.height() + 2*frameWidth());
2598  }
2599 
2600  childWidget->move(p);
2601  resize(s);
2602 
2604 
2605  widgetResizeHandler = new QWidgetResizeHandler(this, window);
2609  this, SLOT(activate()));
2612  else
2616  setBaseSize(baseSize());
2617 }
2618 
2620 {
2621  QWorkspace *workspace = qobject_cast<QWorkspace*>(parentWidget());
2622  if (iconw) {
2623  if (workspace)
2624  workspace->d_func()->removeIcon(iconw->parentWidget());
2625  delete iconw->parentWidget();
2626  }
2627 
2628  if (workspace) {
2629  workspace->d_func()->focus.removeAll(this);
2630  if (workspace->d_func()->active == this)
2631  workspace->activatePreviousWindow();
2632  if (workspace->d_func()->active == this)
2633  workspace->d_func()->activateWindow(0);
2634  if (workspace->d_func()->maxWindow == this) {
2635  workspace->d_func()->hideMaximizeControls();
2636  workspace->d_func()->maxWindow = 0;
2637  }
2638  }
2639 }
2640 
2642 {
2643  ((QWorkspace*)parentWidget())->d_func()->updateWorkspace();
2644 }
2645 
2647 {
2648  bool wasMax = isMaximized();
2649  QRect r = contentsRect();
2650  QRect cr;
2651 
2652  updateMask();
2653 
2654  if (titlebar) {
2655  int th = titlebar->sizeHint().height();
2656  QRect tbrect(0, 0, width(), th);
2658  tbrect = QRect(r.x(), r.y(), r.width(), th);
2659  titlebar->setGeometry(tbrect);
2660 
2662  th -= frameWidth();
2663  cr = QRect(r.x(), r.y() + th + (shademode ? (frameWidth() * 3) : 0),
2664  r.width(), r.height() - th);
2665  } else {
2666  cr = r;
2667  }
2668 
2669  if (!childWidget)
2670  return;
2671 
2672  bool doContentsResize = (windowSize == childWidget->size()
2674  ||childWidget->isMaximized());
2675 
2676  windowSize = cr.size();
2677  childWidget->move(cr.topLeft());
2678  if (doContentsResize)
2679  childWidget->resize(cr.size());
2680  ((QWorkspace*)parentWidget())->d_func()->updateWorkspace();
2681 
2682  if (wasMax) {
2685  }
2686 }
2687 
2689 {
2690  int th = titlebar ? titlebar->sizeHint().height() : 0;
2692  th -= frameWidth();
2693  return QSize(2*frameWidth(), 2*frameWidth() + th);
2694 }
2695 
2697 {
2698  if (!childWidget)
2699  return QWidget::sizeHint() + baseSize();
2700 
2702  prefSize = prefSize.expandedTo(windowWidget()->minimumSize()).boundedTo(windowWidget()->maximumSize());
2703  prefSize += baseSize();
2704 
2705  return prefSize;
2706 }
2707 
2709 {
2710  if (!childWidget)
2711  return QWidget::minimumSizeHint() + baseSize();
2712  QSize s = childWidget->minimumSize();
2713  if (s.isEmpty())
2715  return s + baseSize();
2716 }
2717 
2719 {
2720  ((QWorkspace*)parentWidget())->d_func()->activateWindow(windowWidget());
2721 }
2722 
2724 {
2725  if (!isActive()
2726  && (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::FocusIn)) {
2727  if (iconw) {
2728  ((QWorkspace*)parentWidget())->d_func()->normalizeWindow(windowWidget());
2729  if (iconw) {
2730  ((QWorkspace*)parentWidget())->d_func()->removeIcon(iconw->parentWidget());
2731  delete iconw->parentWidget();
2732  iconw = 0;
2733  }
2734  }
2735  activate();
2736  }
2737 
2738  // for all widgets except the window, that's the only thing we
2739  // process, and if we have no childWidget we skip totally
2740  if (o != childWidget || childWidget == 0)
2741  return false;
2742 
2743  switch (e->type()) {
2744  case QEvent::ShowToParent:
2745  if (((QWorkspace*)parentWidget())->d_func()->focus.indexOf(this) < 0)
2746  ((QWorkspace*)parentWidget())->d_func()->focus.append(this);
2747 
2749  internalRaise();
2750  show();
2751  }
2752  ((QWorkspace*)parentWidget())->d_func()->showWindow(windowWidget());
2753  break;
2755  if (static_cast<QWindowStateChangeEvent*>(e)->isOverride())
2756  break;
2757  Qt::WindowStates state = windowWidget()->windowState();
2758 
2759  if (state & Qt::WindowMinimized) {
2760  ((QWorkspace*)parentWidget())->d_func()->minimizeWindow(windowWidget());
2761  } else if (state & Qt::WindowMaximized) {
2762  if (windowWidget()->maximumSize().isValid() &&
2767  if (titlebar)
2768  titlebar->update();
2769  break;
2770  }
2772  ((QWorkspace*)parentWidget())->d_func()->maximizeWindow(windowWidget());
2773  else
2774  ((QWorkspace*)parentWidget())->d_func()->normalizeWindow(windowWidget());
2775  } else {
2776  ((QWorkspace*)parentWidget())->d_func()->normalizeWindow(windowWidget());
2777  if (iconw) {
2778  ((QWorkspace*)parentWidget())->d_func()->removeIcon(iconw->parentWidget());
2779  delete iconw->parentWidget();
2780  }
2781  }
2782  } break;
2783  case QEvent::HideToParent:
2784  {
2785  QWidget * w = iconw;
2786  if (w && (w = w->parentWidget())) {
2787  ((QWorkspace*)parentWidget())->d_func()->removeIcon(w);
2788  delete w;
2789  }
2790  ((QWorkspace*)parentWidget())->d_func()->hideChild(this);
2791  } break;
2793  {
2795  if (ws->d_func()->maxtools && ws->d_func()->maxWindow == this) {
2796  int iconSize = ws->d_func()->maxtools->size().height();
2797  ws->d_func()->maxtools->setPixmap(childWidget->windowIcon().pixmap(QSize(iconSize, iconSize)));
2798  }
2799  }
2800  // fall through
2803  if (titlebar)
2804  titlebar->update();
2805  if (iconw)
2806  iconw->update();
2807  break;
2810  if (titlebar)
2811  titlebar->update();
2812  if (iconw)
2813  iconw->update();
2814  break;
2815  case QEvent::Resize:
2816  {
2817  QResizeEvent* re = (QResizeEvent*)e;
2818  if (re->size() != windowSize && !shademode) {
2819  resize(re->size() + baseSize());
2820  childWidget->update(); //workaround
2821  }
2822  }
2823  break;
2824 
2826  if (titlebar && titlebar->isActive()) {
2827  update();
2828  }
2829  break;
2830 
2832  if (titlebar && titlebar->isActive()) {
2833  update();
2834  }
2835  break;
2836 
2837  default:
2838  break;
2839  }
2840 
2841  return QWidget::eventFilter(o, e);
2842 }
2843 
2845 {
2846  if (e->type() == QEvent::ChildRemoved && e->child() == childWidget) {
2847  childWidget = 0;
2848  if (iconw) {
2849  ((QWorkspace*)parentWidget())->d_func()->removeIcon(iconw->parentWidget());
2850  delete iconw->parentWidget();
2851  }
2852  close();
2853  }
2854 }
2855 
2856 
2858 {
2860 }
2861 
2863 {
2865 }
2866 
2868 {
2869 }
2870 
2872 {
2873 #ifndef QT_NO_CURSOR
2876 #endif
2877 }
2878 
2880 {
2881  QPainter p(this);
2882  QStyleOptionFrame opt;
2883  opt.rect = rect();
2884  opt.palette = palette();
2885  opt.state = QStyle::State_None;
2887  opt.midLineWidth = 1;
2888 
2889  if (titlebar && titlebar->isActive() && isActiveWindow())
2890  opt.state |= QStyle::State_Active;
2891 
2892  style()->drawPrimitive(QStyle::PE_FrameWindow, &opt, &p, this);
2893 }
2894 
2896 {
2897  if(ev->type() == QEvent::StyleChange) {
2898  resizeEvent(0);
2899  if (iconw) {
2900  QFrame *frame = qobject_cast<QFrame*>(iconw->parentWidget());
2901  Q_ASSERT(frame);
2904  frame->resize(196+2*frame->frameWidth(), 20 + 2*frame->frameWidth());
2905  } else {
2906  frame->resize(196, 20);
2907  }
2908  }
2909  updateMask();
2910  }
2912 }
2913 
2915 {
2916  if (!childWidget)
2917  return;
2918 
2919  bool hasFocus = isChildOf(window()->focusWidget(), this);
2920  if (act == b && (act == hasFocus))
2921  return;
2922 
2923  act = b;
2924 
2925  if (titlebar)
2927  if (iconw)
2928  iconw->setActive(act);
2929  update();
2930 
2932  if (act) {
2933  for (int i = 0; i < wl.size(); ++i) {
2934  QWidget *w = wl.at(i);
2935  w->removeEventFilter(this);
2936  }
2937  if (!hasFocus) {
2938  QWidget *lastfocusw = childWidget->focusWidget();
2939  if (lastfocusw && lastfocusw->focusPolicy() != Qt::NoFocus) {
2940  lastfocusw->setFocus();
2941  } else if (childWidget->focusPolicy() != Qt::NoFocus) {
2942  childWidget->setFocus();
2943  } else {
2944  // find something, anything, that accepts focus, and use that.
2945  for (int i = 0; i < wl.size(); ++i) {
2946  QWidget *w = wl.at(i);
2947  if(w->focusPolicy() != Qt::NoFocus) {
2948  w->setFocus();
2949  hasFocus = true;
2950  break;
2951  }
2952  }
2953  if (!hasFocus)
2954  setFocus();
2955  }
2956  }
2957  } else {
2958  for (int i = 0; i < wl.size(); ++i) {
2959  QWidget *w = wl.at(i);
2960  w->removeEventFilter(this);
2961  w->installEventFilter(this);
2962  }
2963  }
2964 }
2965 
2967 {
2968  return act;
2969 }
2970 
2972 {
2973  return childWidget;
2974 }
2975 
2977 {
2978  return childWidget && (!isHidden() || (iconw && !iconw->isHidden()));
2979 }
2980 
2982 {
2983  QStyleOptionTitleBar titleBarOptions;
2984  titleBarOptions.rect = rect();
2985  titleBarOptions.titleBarFlags = windowFlags();
2986  titleBarOptions.titleBarState = windowState();
2987 
2988  QStyleHintReturnMask frameMask;
2989  if (style()->styleHint(QStyle::SH_WindowFrame_Mask, &titleBarOptions, this, &frameMask)) {
2990  setMask(frameMask.region);
2991  } else if (!mask().isEmpty()) {
2992  clearMask();
2993  }
2994 
2995  if (iconw) {
2996  QFrame *frame = qobject_cast<QFrame *>(iconw->parentWidget());
2997  Q_ASSERT(frame);
2998 
2999  titleBarOptions.rect = frame->rect();
3000  titleBarOptions.titleBarFlags = frame->windowFlags();
3001  titleBarOptions.titleBarState = frame->windowState() | Qt::WindowMinimized;
3002  if (style()->styleHint(QStyle::SH_WindowFrame_Mask, &titleBarOptions, frame, &frameMask)) {
3003  frame->setMask(frameMask.region);
3004  } else if (!frame->mask().isEmpty()) {
3005  frame->clearMask();
3006  }
3007  }
3008 }
3009 
3011 {
3012  if (!iconw) {
3013  QWorkspaceChild* that = (QWorkspaceChild*) this;
3014 
3015  QFrame* frame = new QFrame(that, Qt::Window);
3016  QVBoxLayout *vbox = new QVBoxLayout(frame);
3017  vbox->setMargin(0);
3019  vbox->addWidget(tb);
3020  tb->setObjectName(QLatin1String("_workspacechild_icon_"));
3022  tb->initStyleOption(&opt);
3023  int th = style()->pixelMetric(QStyle::PM_TitleBarHeight, &opt, tb);
3024  int iconSize = style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, this);
3027  frame->resize(iconSize+2*frame->frameWidth(), th+2*frame->frameWidth());
3028  } else {
3029  frame->resize(iconSize, th);
3030  }
3031 
3032  that->iconw = tb;
3033  that->updateMask();
3034  iconw->setActive(isActive());
3035 
3036  connect(iconw, SIGNAL(doActivate()),
3037  this, SLOT(activate()));
3038  connect(iconw, SIGNAL(doClose()),
3039  windowWidget(), SLOT(close()));
3040  connect(iconw, SIGNAL(doNormal()),
3041  this, SLOT(showNormal()));
3042  connect(iconw, SIGNAL(doMaximize()),
3043  this, SLOT(showMaximized()));
3045  this, SIGNAL(popupOperationMenu(QPoint)));
3047  this, SIGNAL(showOperationMenu()));
3048  connect(iconw, SIGNAL(doubleClicked()),
3049  this, SLOT(titleBarDoubleClicked()));
3050  }
3051  if (windowWidget()) {
3053  }
3054  return iconw->parentWidget();
3055 }
3056 
3058 {
3060 }
3061 
3063 {
3065 }
3066 
3068 {
3070 }
3071 
3073 {
3074  if (!titlebar)
3075  return;
3076  ((QWorkspace*)parentWidget())->d_func()->activateWindow(windowWidget());
3077  QWidget* w = windowWidget();
3078  if (shademode) {
3081 
3082  shademode = false;
3085  style()->polish(this);
3086  } else {
3087  shadeRestore = size();
3089  setMinimumHeight(0);
3090  shademode = true;
3093 
3095  resize(width(), titlebar->height());
3096  else
3097  resize(width(), titlebar->height() + 2*frameWidth() + 1);
3098  style()->polish(this);
3099  }
3100  titlebar->update();
3101 }
3102 
3104 {
3105  if (!windowWidget())
3106  return;
3107  if (iconw)
3108  showNormal();
3110  showShaded();
3112  showMaximized();
3113 }
3114 
3116 {
3117  if (!childWidget)
3118  return;
3119 
3120  if(!((QWorkspace*)parentWidget())->d_func()->maxmenubar || style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, this)) {
3122  } else {
3123  int fw = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this);
3124  bool noBorder = style()->styleHint(QStyle::SH_TitleBar_NoBorder, 0, titlebar);
3125  int th = titlebar ? titlebar->sizeHint().height() : 0;
3126  int w = parentWidget()->width() + 2*fw;
3127  int h = parentWidget()->height() + (noBorder ? fw : 2*fw) + th;
3128  w = qMax(w, childWidget->minimumWidth());
3129  h = qMax(h, childWidget->minimumHeight());
3130  setGeometry(-fw, (noBorder ? 0 : -fw) - th, w, h);
3131  }
3134 }
3135 
3137 {
3138 
3139  QWidget *stackUnderWidget = 0;
3141 
3142  QList<QWorkspaceChild *>::Iterator it(((QWorkspace*)parent())->d_func()->windows.begin());
3143  while (it != ((QWorkspace*)parent())->d_func()->windows.end()) {
3144  QWorkspaceChild* c = *it;
3145  ++it;
3146  if (c->windowWidget() &&
3147  !c->windowWidget()->isHidden() &&
3149  if (stackUnderWidget)
3150  c->stackUnder(stackUnderWidget);
3151  else
3152  c->raise();
3153  stackUnderWidget = c;
3154  }
3155  }
3156  }
3157 
3158  if (stackUnderWidget) {
3159  if (iconw)
3160  iconw->parentWidget()->stackUnder(stackUnderWidget);
3161  stackUnder(stackUnderWidget);
3162  } else {
3163  if (iconw)
3164  iconw->parentWidget()->raise();
3165  raise();
3166  }
3167 
3168 }
3169 
3171 {
3172  if (childWidget && childWidget->isHidden())
3173  childWidget->show();
3174  QWidget::show();
3175 }
3176 
3177 bool QWorkspace::scrollBarsEnabled() const
3178 {
3179  Q_D(const QWorkspace);
3180  return d->vbar != 0;
3181 }
3182 
3201 {
3202  Q_D(QWorkspace);
3203  if ((d->vbar != 0) == enable)
3204  return;
3205 
3206  d->xoffset = d->yoffset = 0;
3207  if (enable) {
3208  d->vbar = new QScrollBar(Qt::Vertical, this);
3209  d->vbar->setObjectName(QLatin1String("vertical scrollbar"));
3210  connect(d->vbar, SIGNAL(valueChanged(int)), this, SLOT(_q_scrollBarChanged()));
3211  d->hbar = new QScrollBar(Qt::Horizontal, this);
3212  d->hbar->setObjectName(QLatin1String("horizontal scrollbar"));
3213  connect(d->hbar, SIGNAL(valueChanged(int)), this, SLOT(_q_scrollBarChanged()));
3214  d->corner = new QWidget(this);
3215  d->corner->setBackgroundRole(QPalette::Window);
3216  d->corner->setObjectName(QLatin1String("qt_corner"));
3217  d->updateWorkspace();
3218  } else {
3219  delete d->vbar;
3220  delete d->hbar;
3221  delete d->corner;
3222  d->vbar = d->hbar = 0;
3223  d->corner = 0;
3224  }
3225 
3226  QList<QWorkspaceChild *>::Iterator it(d->windows.begin());
3227  while (it != d->windows.end()) {
3228  QWorkspaceChild *child = *it;
3229  ++it;
3230  child->widgetResizeHandler->setSizeProtection(!enable);
3231  }
3232 }
3233 
3235 {
3236  Q_Q(QWorkspace);
3237  QRect cr(q->rect());
3238 
3239  if (q->scrollBarsEnabled() && !maxWindow) {
3240  corner->raise();
3241  vbar->raise();
3242  hbar->raise();
3243  if (maxWindow)
3244  maxWindow->internalRaise();
3245 
3246  QRect r(0, 0, 0, 0);
3247  QList<QWorkspaceChild *>::Iterator it(windows.begin());
3248  while (it != windows.end()) {
3249  QWorkspaceChild *child = *it;
3250  ++it;
3251  if (!child->isHidden())
3252  r = r.unite(child->geometry());
3253  }
3254  vbar->blockSignals(true);
3255  hbar->blockSignals(true);
3256 
3257  int hsbExt = hbar->sizeHint().height();
3258  int vsbExt = vbar->sizeHint().width();
3259 
3260 
3261  bool showv = yoffset || yoffset + r.bottom() - q->height() + 1 > 0 || yoffset + r.top() < 0;
3262  bool showh = xoffset || xoffset + r.right() - q->width() + 1 > 0 || xoffset + r.left() < 0;
3263 
3264  if (showh && !showv)
3265  showv = yoffset + r.bottom() - q->height() + hsbExt + 1 > 0;
3266  if (showv && !showh)
3267  showh = xoffset + r.right() - q->width() + vsbExt + 1 > 0;
3268 
3269  if (!showh)
3270  hsbExt = 0;
3271  if (!showv)
3272  vsbExt = 0;
3273 
3274  if (showv) {
3275  vbar->setSingleStep(qMax(q->height() / 12, 30));
3276  vbar->setPageStep(q->height() - hsbExt);
3277  vbar->setMinimum(qMin(0, yoffset + qMin(0, r.top())));
3278  vbar->setMaximum(qMax(0, yoffset + qMax(0, r.bottom() - q->height() + hsbExt + 1)));
3279  vbar->setGeometry(q->width() - vsbExt, 0, vsbExt, q->height() - hsbExt);
3280  vbar->setValue(yoffset);
3281  vbar->show();
3282  } else {
3283  vbar->hide();
3284  }
3285 
3286  if (showh) {
3287  hbar->setSingleStep(qMax(q->width() / 12, 30));
3288  hbar->setPageStep(q->width() - vsbExt);
3289  hbar->setMinimum(qMin(0, xoffset + qMin(0, r.left())));
3290  hbar->setMaximum(qMax(0, xoffset + qMax(0, r.right() - q->width() + vsbExt + 1)));
3291  hbar->setGeometry(0, q->height() - hsbExt, q->width() - vsbExt, hsbExt);
3292  hbar->setValue(xoffset);
3293  hbar->show();
3294  } else {
3295  hbar->hide();
3296  }
3297 
3298  if (showh && showv) {
3299  corner->setGeometry(q->width() - vsbExt, q->height() - hsbExt, vsbExt, hsbExt);
3300  corner->show();
3301  } else {
3302  corner->hide();
3303  }
3304 
3305  vbar->blockSignals(false);
3306  hbar->blockSignals(false);
3307 
3308  cr.setRect(0, 0, q->width() - vsbExt, q->height() - hsbExt);
3309  }
3310 
3311  QList<QWidget *>::Iterator ii(icons.begin());
3312  while (ii != icons.end()) {
3313  QWidget* w = *ii;
3314  ++ii;
3315  int x = w->x();
3316  int y = w->y();
3317  bool m = false;
3318  if (x+w->width() > cr.width()) {
3319  m = true;
3320  x = cr.width() - w->width();
3321  }
3322  if (y+w->height() > cr.height()) {
3323  y = cr.height() - w->height();
3324  m = true;
3325  }
3326  if (m) {
3327  if (QWorkspaceChild *child = qobject_cast<QWorkspaceChild*>(w))
3328  child->move(x, y);
3329  else
3330  w->move(x, y);
3331  }
3332  }
3333 
3334  return cr;
3335 
3336 }
3337 
3339 {
3340  int ver = yoffset - vbar->value();
3341  int hor = xoffset - hbar->value();
3342  yoffset = vbar->value();
3343  xoffset = hbar->value();
3344 
3345  QList<QWorkspaceChild *>::Iterator it(windows.begin());
3346  while (it != windows.end()) {
3347  QWorkspaceChild *child = *it;
3348  ++it;
3349  // we do not use move() due to the reimplementation in QWorkspaceChild
3350  child->setGeometry(child->x() + hor, child->y() + ver, child->width(), child->height());
3351  }
3352  updateWorkspace();
3353 }
3354 
3369 {
3370  Q_D(QWorkspace);
3371  if(ev->type() == QEvent::StyleChange) {
3372  if (isVisible() && d->maxWindow && d->maxmenubar) {
3374  d->hideMaximizeControls(); //hide any visible maximized controls
3375  d->showMaximizeControls(); //updates the modification state as well
3376  }
3377  }
3378  }
3380 }
3381 
3383 
3384 #include "moc_qworkspace.cpp"
3385 
3386 #include "qworkspace.moc"
3387 
3388 #endif // QT_NO_WORKSPACE
void enterEvent(QEvent *e)
This event handler can be reimplemented in a subclass to receive widget enter events which are passed...
Definition: qworkspace.cpp:748
QPoint pos() const
QSize baseSize() const
void showMaximized()
Shows the widget maximized.
Definition: qwidget.cpp:3218
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
QSize maximumSize
the widget&#39;s maximum size in pixels
Definition: qwidget.h:173
void stackUnder(QWidget *)
Places the widget under w in the parent widget&#39;s stack.
Definition: qwidget.cpp:11972
void resizeEvent(QResizeEvent *)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
QSize minimumSize
the widget&#39;s minimum size
Definition: qwidget.h:172
void _q_close()
QStyle::SubControl activeControl
Definition: qworkspace.cpp:99
QPointer< QWorkspaceTitleBar > iconw
Definition: qworkspace.cpp:966
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void contextMenuEvent(QContextMenuEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive widget context men...
Definition: qworkspace.cpp:509
static QRgb colorref2qrgb(COLORREF col)
Definition: qworkspace.cpp:372
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
Definition: qobject.cpp:1406
unsigned int QRgb
Definition: qrgb.h:53
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
void mousePressEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition: qworkspace.cpp:151
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
virtual void showEvent(QShowEvent *)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
Definition: qwidget.cpp:9842
void mouseMoveEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
Definition: qworkspace.cpp:200
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
void showEvent(QShowEvent *e)
Reimplemented Function
QWorkspaceChild * findChild(QWidget *w)
void adjustToFullscreen()
int y() const
unsigned char c[8]
Definition: qnumeric_p.h:62
bool isTool() const
Definition: qworkspace.cpp:658
bool scrollBarsEnabled
whether the workspace provides scroll bars
Definition: qworkspace.h:63
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define COLOR_GRADIENTINACTIVECAPTION
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
Q_GUI_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
Q_CORE_EXPORT QTextStream & ws(QTextStream &s)
QSize size() const
QPointer< QWidget > widget
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
void activateNextWindow()
Gives the input focus to the next window in the list of child windows.
int minimumHeight
the widget&#39;s minimum height in pixels
Definition: qwidget.h:175
QSize sizeHint() const
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowModified(bool)
Definition: qwidget.cpp:11559
QStyle::SubControl hoverControl
Definition: qworkspace.cpp:100
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
#define add(aName)
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
virtual QSize minimumSizeHint() const
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
#define it(className, varName)
QRect contentsRect() const
Returns the area inside the widget&#39;s margins.
Definition: qwidget.cpp:7544
friend class QWorkspaceChild
Definition: qworkspace.h:128
void moveEvent(QMoveEvent *)
This event handler can be reimplemented in a subclass to receive widget move events which are passed ...
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
void mouseReleaseEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
Definition: qworkspace.cpp:165
bool isVisible() const
Definition: qwidget.h:1005
const QPoint & pos() const
Returns the position of the mouse pointer relative to the widget that received the event...
Definition: qevent.h:412
bool isVisibleTo(QWidget *) const
Returns true if this widget would become visible if ancestor is shown; otherwise returns false...
Definition: qwidget.cpp:8371
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QIcon icon
the icon for the title bar
Definition: qstyleoption.h:823
void initStyleOption(QStyleOptionTitleBar *option) const
Definition: qworkspace.cpp:326
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qworkspace.cpp:785
static void adjustFlags(Qt::WindowFlags &flags, QWidget *w=0)
Definition: qwidget.cpp:1242
void setBaseSize(const QSize &)
Definition: qwidget.h:978
#define SLOT(a)
Definition: qobjectdefs.h:226
QWidget * becomeActive
Definition: qworkspace.cpp:996
void minimizeWindow(QWidget *w)
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
void arrangeIcons()
Arranges all iconified windows at the bottom of the workspace.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
QSize sizeHint() const
Reimplemented Function
Definition: qmenu.cpp:1805
void _q_minimizeActiveWindow()
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
The QShortcutEvent class provides an event which is generated when the user presses a key combination...
Definition: qevent.h:675
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
QHash< int, const char * > shortcutMap
Definition: qworkspace.cpp:992
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
int & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:143
virtual void resizeEvent(QResizeEvent *)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition: qwidget.cpp:9587
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
virtual void moveEvent(QMoveEvent *)
This event handler can be reimplemented in a subclass to receive widget move events which are passed ...
Definition: qwidget.cpp:9566
bool updatesEnabled() const
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
void setMinimumSize(const QSize &)
Definition: qwidget.h:969
QString text
the text of the title bar
Definition: qstyleoption.h:822
QWidget * childWidget
Definition: qworkspace.cpp:963
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void moveTo(int x, int t)
Moves the rectangle, leaving the top-left corner at the given position (x, y).
Definition: qrect.h:334
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
static QList< QKeySequence > keyBindings(StandardKey key)
Returns a list of key bindings for the given key.
QWidget * window() const
Definition: qworkspace.cpp:779
static QMenuBar * findMenuBar(QWidget *w)
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QBrush background() const
bool isActiveWindow() const
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
void overrideWindowState(Qt::WindowStates state)
Definition: qwidget.cpp:3098
bool hasFocus() const
Definition: qwidget.cpp:6583
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
void showMaximizeControls()
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void removeIcon(QWidget *w)
#define Q_D(Class)
Definition: qglobal.h:2482
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
int height() const
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:53
bool removed() const
Returns true if type() is QEvent::ChildRemoved; otherwise returns false.
Definition: qcoreevent.h:364
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:192
void popupOperationMenu(const QPoint &)
void setMinimumHeight(int minh)
Definition: qwidget.cpp:4334
QScrollBar * vbar
QIcon windowIcon
the widget&#39;s icon
Definition: qwidget.h:199
bool event(QEvent *e)
Reimplemented Function
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
void showNormal()
Restores the widget after it has been maximized or minimized.
Definition: qwidget.cpp:3250
QWidgetList windowList(WindowOrder order=CreationOrder) const
Returns a list of all visible or minimized child windows.
int frameWidth() const
Definition: qworkspace.cpp:974
QRect unite(const QRect &r) const
Use united(rectangle) instead.
Definition: qrect.h:486
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
If the string text is wider than width, returns an elided version of the string (i.
virtual QSize sizeHint() const
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
QStyle * style() const
Definition: qwidget.cpp:2742
void _q_minimize()
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
WindowOrder
Specifies the order in which child windows are returned from windowList().
Definition: qworkspace.h:70
The QWorkspace widget provides a workspace window that can be used in an MDI application.
Definition: qworkspace.h:60
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
bool focus
whether this widget (or its focus proxy) has the keyboard input focus
Definition: qwidget.h:188
bool eventFilter(QObject *, QEvent *)
Reimplemented Function
bool isWindowModified() const
Definition: qwidget.cpp:11554
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void hideEvent(QHideEvent *e)
Reimplemented Function
void setWindowTitle(const QString &)
Definition: qwidget.cpp:6312
int lineWidth
the line width for drawing the frame
Definition: qstyleoption.h:124
void setActive(bool)
int width() const
Returns the width.
Definition: qsize.h:126
The QScrollBar widget provides a vertical or horizontal scroll bar.
Definition: qscrollbar.h:59
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void setBackgroundRole(QPalette::ColorRole)
Sets the background role of the widget to role.
Definition: qwidget.cpp:4708
void clearMask()
Removes any mask set by setMask().
Definition: qwidget.cpp:13324
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QSize sizeHint() const
Definition: qworkspace.cpp:822
void hideMaximizeControls()
The QMoveEvent class contains event parameters for move events.
Definition: qevent.h:334
void lower()
Lowers the widget to the bottom of the parent widget&#39;s stack.
Definition: qwidget.cpp:11939
static bool isEmpty(const char *str)
bool usesActiveColor() const
Definition: qworkspace.cpp:773
friend class QPixmap
Definition: qwidget.h:748
void _q_operationMenuActivated(QAction *)
void popupOperationMenu(const QPoint &)
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
virtual void childEvent(QChildEvent *)
This event handler can be reimplemented in a subclass to receive child events.
Definition: qobject.cpp:1332
QWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a widget which is a child of parent, with widget flags set to f.
Definition: qwidget.cpp:1189
static bool init
int width() const
void setContentsMargins(int left, int top, int right, int bottom)
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom.
Definition: qwidget.cpp:7449
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
void adjustSize()
Adjusts the size of the widget to fit its contents.
Definition: qwidget.cpp:8488
const char * name
void enterEvent(QEvent *)
This event handler can be reimplemented in a subclass to receive widget enter events which are passed...
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qwidget.cpp:9170
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition: qevent.h:388
const QPalette & palette() const
virtual void mouseDoubleClickEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse double click...
Definition: qwidget.cpp:9306
void paintEvent(QPaintEvent *event)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
Definition: qworkspace.cpp:213
void activateWindow(QWidget *w, bool change_focus=true)
void wheelEvent(QWheelEvent *e)
Reimplemented Function
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
const char * styleHint(const QFontDef &request)
int & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:140
#define SPI_GETGRADIENTCAPTIONS
QWidgetResizeHandler * widgetResizeHandler
Definition: qworkspace.cpp:964
void tile()
Arranges all child windows in a tile pattern.
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
QSize minimumSizeHint
the recommended minimum size for the widget
Definition: qwidget.h:196
unsigned int uint
Definition: qglobal.h:996
T findChild(const QString &aName=QString()) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object.
Definition: qobject.h:158
QString windowTitle
the window title (caption)
Definition: qwidget.h:198
QWorkspace(QWidget *parent=0)
Constructs a workspace with the given parent.
QList< QWidget * > icons
Definition: qworkspace.cpp:987
QString windowTitle() const
void changeEvent(QEvent *)
Reimplemented Function
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QToolTip class provides tool tips (balloon help) for any widget.
Definition: qtooltip.h:55
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
QList< QWorkspaceChild * > windows
Definition: qworkspace.cpp:985
bool isWindowOrIconVisible() const
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=0) const =0
Draws the given control using the provided painter with the style options specified by option...
void setMovable(bool)
Definition: qworkspace.cpp:798
void resizeEvent(QResizeEvent *)
Reimplemented Function
void mouseReleaseEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
Definition: qworkspace.cpp:524
bool event(QEvent *event)
This is the main event handler; it handles event event.
Definition: qworkspace.cpp:103
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
void setWindowIcon(const QIcon &icon)
Definition: qwidget.cpp:6362
void activatePreviousWindow()
Gives the input focus to the previous window in the list of child windows.
void show()
Shows the widget and its child widgets.
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
bool isMovable() const
Definition: qworkspace.cpp:804
void _q_restore()
static void hideText()
Hides the tool tip.
Definition: qtooltip.h:61
QPointer< QLabel > maxtools
Definition: qworkspace.cpp:997
void setMask(const QBitmap &)
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible...
Definition: qwidget.cpp:13309
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
void showOperationMenu()
QRect rect() const
#define COLOR_GRADIENTACTIVECAPTION
QRegion mask() const
Returns the mask currently set on a widget.
Definition: qwidget.cpp:10058
void showMinimized()
Shows the widget minimized, as an icon.
Definition: qwidget.cpp:3038
void leaveEvent(QEvent *event)
This event handler can be reimplemented in a subclass to receive widget leave events which are passed...
Definition: qworkspace.cpp:194
#define Q_OBJECT
Definition: qobjectdefs.h:157
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
void _q_scrollBarChanged()
void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
void hide()
Hides the widget.
Definition: qwidget.h:501
bool isMaximized() const
Definition: qwidget.cpp:3074
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
void setMouseTracking(bool enable)
Definition: qwidget.h:990
void normalizeWindow(QWidget *w)
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
void paintEvent(QPaintEvent *p)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
Definition: qworkspace.cpp:667
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
void setAutoFillBackground(bool enabled)
Definition: qwidget.cpp:631
void setActive(bool)
Definition: qworkspace.cpp:757
The QChildEvent class contains event parameters for child object events.
Definition: qcoreevent.h:353
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
#define QT_NO_TOOLTIP
QPointer< QMenuBar > maxmenubar
Definition: qworkspace.cpp:991
virtual void contextMenuEvent(QContextMenuEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive widget context men...
Definition: qwidget.cpp:9645
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void setCornerWidget(QWidget *w, Qt::Corner corner=Qt::TopRightCorner)
This sets the given widget to be shown directly on the left of the first menu item, or on the right of the last menu item, depending on corner.
Definition: qmenubar.cpp:1980
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
void mouseDoubleClickEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse double click...
Definition: qworkspace.cpp:715
int minimumWidth
the widget&#39;s minimum width in pixels
Definition: qwidget.h:174
int shortcutId()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qevent.h:683
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
QSize baseSize() const
void _q_showOperationMenu()
QSize minimumSizeHint() const
void place(QWidget *)
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
Definition: qpoint.h:137
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
QString toolTip() const
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
int x() const
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
void setChecked(bool)
Definition: qaction.cpp:1138
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
QWidget * iconWidget() const
void setAutoRaise(bool)
Definition: qworkspace.cpp:810
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
void setBackground(const QBrush &background)
void insertIcon(QWidget *w)
const QSize & size() const
Returns the new size of the widget.
Definition: qevent.h:355
int midLineWidth
the mid-line width for drawing the frame
Definition: qstyleoption.h:125
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Definition: qicon.cpp:730
QWorkspaceTitleBar(QWidget *w, QWidget *parent, Qt::WindowFlags f=0)
Definition: qworkspace.cpp:344
int y
the y coordinate of the widget relative to its parent and including any window frame ...
Definition: qwidget.h:162
bool scrollBarsEnabled() const
QMDIControl(QWidget *widget)
Definition: qworkspace.cpp:132
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QSize sizeHint() const
Definition: qworkspace.cpp:142
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
void closeActiveWindow()
Closes the child window that is currently active.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
void childEvent(QChildEvent *)
This event handler can be reimplemented in a subclass to receive child events.
void setFrameStyle(int)
Sets the frame style to style.
Definition: qframe.cpp:329
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
QSize maximumSize() const
QPoint mapToParent(const QPoint &) const
Translates the widget coordinate pos to a coordinate in the parent widget.
Definition: qwidget.cpp:4459
QWorkspaceTitleBar * titlebar
Definition: qworkspace.cpp:965
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
QList< QAction * > actions() const
Returns the (possibly empty) list of this widget&#39;s actions.
Definition: qwidget.cpp:3407
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
int maximumHeight() const
int height() const
Returns the height.
Definition: qsize.h:129
const QPoint & globalPos() const
Returns the mouse cursor position when the event was generated in global coordinates.
Definition: qevent.h:598
friend class QWorkspaceTitleBar
Definition: qworkspace.cpp:906
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123
Definition: qnamespace.h:54
QFactoryLoader * l
QSize minimumSize() const
bool isActive() const
The QLabel widget provides a text or image display.
Definition: qlabel.h:55
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget=0) const =0
Returns the sub control at the given position in the given complex control (with the style options sp...
void leaveEvent(QEvent *)
This event handler can be reimplemented in a subclass to receive widget leave events which are passed...
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QStyle::SubControl lastControl
Definition: qworkspace.cpp:302
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
bool isMinimized() const
Definition: qwidget.cpp:3027
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
return(isPopup||isToolTip)
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
QWorkspaceChild * active
Definition: qworkspace.cpp:984
QWorkspaceChild(QWidget *window, QWorkspace *parent=0, Qt::WindowFlags flags=0)
void titleBarDoubleClicked()
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition: qicon.cpp:693
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QSize sizeHint
the recommended size for the widget
Definition: qwidget.h:195
QWidget * windowWidget() const
QList< QWorkspaceChild * > focus
Definition: qworkspace.cpp:986
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
bool isRightToLeft() const
Definition: qwidget.h:428
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:1429
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
void closeAllWindows()
Closes all child windows.
Qt::WindowFlags titleBarFlags
the widget flags for the title bar
Definition: qstyleoption.h:825
void mousePressEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition: qworkspace.cpp:431
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition: qevent.h:413
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
QWorkspaceChild * maxWindow
Definition: qworkspace.cpp:988
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:149
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
void setActiveWindow(QWidget *w)
Makes the child window that contains w the active child window.
QRegion region
the region for style hints that return a QRegion
Definition: qstyleoption.h:930
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Definition: qsize.h:120
QPointer< QMDIControl > maxcontrols
Definition: qworkspace.cpp:990
void showWindow(QWidget *w)
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
void initStyleOption(QStyleOptionComplex *option) const
Definition: qworkspace.cpp:125
#define slots
Definition: qobjectdefs.h:68
const QRect & geometry() const
void _q_popupOperationMenu(const QPoint &)
~QWorkspace()
Destroys the workspace and frees any allocated resources.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
#define signals
Definition: qobjectdefs.h:69
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
void setSizePolicy(QSizePolicy)
Definition: qwidget.cpp:10198
int frameWidth
the width of the frame that is drawn.
Definition: qframe.h:64
int titleBarState
the state of the title bar
Definition: qstyleoption.h:824
void setMargin(int)
Definition: qlayout.cpp:464
QPointer< QWidget > window
Definition: qworkspace.cpp:308
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
bool isActive() const
Definition: qworkspace.cpp:767
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QFrame class is the base class of widgets that can have a frame.
Definition: qframe.h:55
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Definition: qevent.h:96
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
Definition: qpoint.h:134
static int doubleClickInterval()
void childEvent(QChildEvent *)
Reimplemented Function
bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
static bool isChildOf(QWidget *child, QWidget *parent)
QSize sizeHint() const
Reimplemented Function
QString qt_setWindowTitle_helperHelper(const QString &, const QWidget *)
Returns a modified window title with the [*] place holder replaced according to the rules described i...
Definition: qwidget.cpp:6240
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
bool autoRaise() const
void start()
Starts this timer.
QList< T > findChildren(const QString &aName=QString()) const
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
Definition: qobject.h:162
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
void maximizeWindow(QWidget *w)
void cascade()
Arranges all the child windows in a cascade pattern.
void _q_normalizeActiveWindow()
QWidget * addWindow(QWidget *w, Qt::WindowFlags flags=0)
Adds widget w as new sub window to the workspace.
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
virtual void enterEvent(QEvent *)
This event handler can be reimplemented in a subclass to receive widget enter events which are passed...
Definition: qwidget.cpp:9475
QObject * child() const
Returns the child object that was added or removed.
Definition: qcoreevent.h:358
QStyle::SubControl buttonDown
Definition: qworkspace.cpp:301
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011
void leaveEvent(QEvent *e)
This event handler can be reimplemented in a subclass to receive widget leave events which are passed...
Definition: qworkspace.cpp:740
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
void setScrollBarsEnabled(bool enable)
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7631
void hideChild(QWorkspaceChild *c)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
void mouseMoveEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
Definition: qworkspace.cpp:600
static void showText(const QPoint &pos, const QString &text, QWidget *w=0)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qtooltip.cpp:497
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition: qevent.h:586
void paintEvent(QPaintEvent *e)
Reimplemented Function
QWidget * activeWindow() const
Returns a pointer to the widget corresponding to the active child window, or 0 if no window is active...
int maximumWidth() const
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60
const QPoint & pos() const
Returns the mouse cursor position when the event was generated, relative to the widget to which the e...
Definition: qevent.h:597