Qt 4.8
Functions | Variables
qdecorationdefault_qws.cpp File Reference
#include <qapplication.h>
#include <qwidget.h>
#include <qpainter.h>
#include <qpaintengine.h>
#include <qdrawutil.h>
#include "qdecorationdefault_qws.h"

Go to the source code of this file.

Functions

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...
 

Variables

static const char *const default_close_xpm []
 
static const char *const default_help_xpm []
 
static const char *const default_maximize_xpm []
 
static const char *const default_menu_xpm []
 
static const char *const default_minimize_xpm []
 
static const char *const default_normalize_xpm []
 

Function Documentation

◆ 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 QDecorationDefault::paintButton(), and QDecorationDefault::windowTitleFor().

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

Variable Documentation

◆ default_close_xpm

const char* const default_close_xpm[]
static
Initial value:
= {
"16 16 3 1",
" s None c None",
". c #ffffff",
"X c #707070",
" ",
" ",
" .X .X ",
" .XX .XX ",
" .XX .XX ",
" .XX .XX ",
" .XX.XX ",
" .XXX ",
" .XXX ",
" .XX.XX ",
" .XX .XX ",
" .XX .XX ",
" .XX .XX ",
" .X .X ",
" ",
" "}

Definition at line 119 of file qdecorationdefault_qws.cpp.

Referenced by QDecorationDefault::xpmForRegion().

◆ default_help_xpm

const char* const default_help_xpm[]
static
Initial value:
= {
"16 16 3 1",
" s None c None",
". c #ffffff",
"X c #707070",
" ",
" ",
" ...... ",
" ..XXXXXX ",
" .XX .XX ",
" .XX .XX ",
" ..XX ",
" ..XX ",
" ..XX ",
" .XX ",
" .XX ",
" .. ",
" .XX ",
" .XX ",
" ",
" "}

Definition at line 97 of file qdecorationdefault_qws.cpp.

Referenced by QDecorationDefault::xpmForRegion().

◆ default_maximize_xpm

const char* const default_maximize_xpm[]
static
Initial value:
= {
"16 16 3 1",
" s None c None",
". c #ffffff",
"X c #707070",
" ",
" ",
" ........... ",
" .XXXXXXXXXX ",
" .X .X ",
" .X .X ",
" .X .X ",
" .X .X ",
" .X .X ",
" .X .X ",
" .X .X ",
" .X........X ",
" .XXXXXXXXXX ",
" ",
" ",
" "}

Definition at line 141 of file qdecorationdefault_qws.cpp.

Referenced by QDecorationDefault::xpmForRegion().

◆ default_menu_xpm

const char* const default_menu_xpm[]
static

Definition at line 63 of file qdecorationdefault_qws.cpp.

Referenced by QDecorationDefault::xpmForRegion().

◆ default_minimize_xpm

const char* const default_minimize_xpm[]
static
Initial value:
= {
"16 16 3 1",
" s None c None",
". c #ffffff",
"X c #707070",
" ",
" ",
" ",
" ",
" ",
" ",
" ... ",
" . X ",
" .XX ",
" ",
" ",
" ",
" ",
" ",
" ",
" "}

Definition at line 163 of file qdecorationdefault_qws.cpp.

Referenced by QDecorationDefault::xpmForRegion().

◆ default_normalize_xpm

const char* const default_normalize_xpm[]
static
Initial value:
= {
"16 16 3 1",
" s None c None",
". c #ffffff",
"X c #707070",
" ",
" ",
" ........ ",
" .XXXXXXXX ",
" .X .X ",
" .X .X ",
" ....X... .X ",
" .XXXXXXXX .X ",
" .X .XXXX ",
" .X .X ",
" .X .X ",
" .X......X ",
" .XXXXXXXX ",
" ",
" ",
" "}

Definition at line 185 of file qdecorationdefault_qws.cpp.

Referenced by QDecorationDefault::xpmForRegion().