Qt 4.8
Classes | Macros | Functions
qworkspace.cpp File Reference
#include "qworkspace.h"
#include "qapplication.h"
#include "qbitmap.h"
#include "qcursor.h"
#include "qdesktopwidget.h"
#include "qevent.h"
#include "qhash.h"
#include "qicon.h"
#include "qimage.h"
#include "qlabel.h"
#include "qlayout.h"
#include "qmenubar.h"
#include "qmenu.h"
#include "qpainter.h"
#include "qpointer.h"
#include "qscrollbar.h"
#include "qstyle.h"
#include "qstyleoption.h"
#include "qelapsedtimer.h"
#include "qtooltip.h"
#include "qdebug.h"
#include <private/qwidget_p.h>
#include <private/qwidgetresizehandler_p.h>
#include <private/qlayoutengine_p.h>
#include "moc_qworkspace.cpp"
#include "qworkspace.moc"

Go to the source code of this file.

Classes

class  QMDIControl
 
class  QWorkspaceChild
 
class  QWorkspacePrivate
 
class  QWorkspaceTitleBar
 
class  QWorkspaceTitleBarPrivate
 

Macros

#define COLOR_GRADIENTACTIVECAPTION   27
 
#define COLOR_GRADIENTINACTIVECAPTION   28
 
#define SPI_GETGRADIENTCAPTIONS   0x1008
 

Functions

static QRgb colorref2qrgb (COLORREF col)
 
static QMenuBarfindMenuBar (QWidget *w)
 
static bool isChildOf (QWidget *child, QWidget *parent)
 
QString qt_setWindowTitle_helperHelper (const QString &, const QWidget *)
 Returns a modified window title with the [*] place holder replaced according to the rules described in QWidget::setWindowTitle. More...
 

Macro Definition Documentation

◆ COLOR_GRADIENTACTIVECAPTION

#define COLOR_GRADIENTACTIVECAPTION   27

◆ COLOR_GRADIENTINACTIVECAPTION

#define COLOR_GRADIENTINACTIVECAPTION   28

◆ SPI_GETGRADIENTCAPTIONS

#define SPI_GETGRADIENTCAPTIONS   0x1008

Function Documentation

◆ colorref2qrgb()

static QRgb colorref2qrgb ( COLORREF  col)
inlinestatic

Definition at line 372 of file qworkspace.cpp.

Referenced by QWorkspaceTitleBarPrivate::readColors().

373 {
374  return qRgb(GetRValue(col),GetGValue(col),GetBValue(col));
375 }
QRgb qRgb(int r, int g, int b)
Returns the ARGB quadruplet (255, {r}, {g}, {b}).
Definition: qrgb.h:69

◆ findMenuBar()

static QMenuBar* findMenuBar ( QWidget w)
static

Definition at line 1925 of file qworkspace.cpp.

Referenced by QWorkspacePrivate::showMaximizeControls().

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)
1930  QList<QObject *> children = w->children();
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 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
T * qobject_cast(QObject *object)
Definition: qobject.h:375
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ isChildOf()

static bool isChildOf ( QWidget child,
QWidget parent 
)
static

Definition at line 1037 of file qworkspace.cpp.

Referenced by QWorkspacePrivate::activateWindow(), and QWorkspaceChild::setActive().

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 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150

◆ qt_setWindowTitle_helperHelper()

QString qt_setWindowTitle_helperHelper ( const QString title,
const QWidget widget 
)

Returns a modified window title with the [*] place holder replaced according to the rules described in QWidget::setWindowTitle.

This function assumes that "[*]" can be quoted by another "[*]", so it will replace two place holders by one and a single last one by either "*" or nothing depending on the modified flag.

Warning
This function is not part of the public interface.

Definition at line 6240 of file qwidget.cpp.

Referenced by QWorkspaceTitleBar::isTool(), QWorkspaceTitleBar::paintEvent(), QWidgetPrivate::setWindowIconText_helper(), and QWidgetPrivate::setWindowTitle_helper().

6241 {
6242  Q_ASSERT(widget);
6243 
6244 #ifdef QT_EVAL
6245  extern QString qt_eval_adapt_window_title(const QString &title);
6246  QString cap = qt_eval_adapt_window_title(title);
6247 #else
6248  QString cap = title;
6249 #endif
6250 
6251  if (cap.isEmpty())
6252  return cap;
6253 
6254  QLatin1String placeHolder("[*]");
6255  int placeHolderLength = 3; // QLatin1String doesn't have length()
6256 
6257  int index = cap.indexOf(placeHolder);
6258 
6259  // here the magic begins
6260  while (index != -1) {
6261  index += placeHolderLength;
6262  int count = 1;
6263  while (cap.indexOf(placeHolder, index) == index) {
6264  ++count;
6265  index += placeHolderLength;
6266  }
6267 
6268  if (count%2) { // odd number of [*] -> replace last one
6269  int lastIndex = cap.lastIndexOf(placeHolder, index - 1);
6270  if (widget->isWindowModified()
6271  && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget))
6272  cap.replace(lastIndex, 3, QWidget::tr("*"));
6273  else
6274  cap.remove(lastIndex, 3);
6275  }
6276 
6277  index = cap.indexOf(placeHolder, index);
6278  }
6279 
6280  cap.replace(QLatin1String("[*][*]"), placeHolder);
6281 
6282  return cap;
6283 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
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...
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QStyle * style() const
Definition: qwidget.cpp:2742
bool isWindowModified() const
Definition: qwidget.cpp:11554
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
quint16 index
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867