QXRD  0.11.16
Public Slots | Public Member Functions | Protected Member Functions | List of all members
QcepMainWindow Class Referenceabstract

#include <qcepmainwindow.h>

Inheritance diagram for QcepMainWindow:
Inheritance graph
[legend]
Collaboration diagram for QcepMainWindow:
Collaboration graph
[legend]

Public Slots

void shrinkPanels (int fontSize, int spacing)
 
void setFontSize (int fontSize)
 
void setSpacing (int spacing)
 
virtual void printMessage (QString msg, QDateTime ts=QDateTime::currentDateTime())=0
 

Public Member Functions

 QcepMainWindow (QWidget *parent=0)
 
void possiblyClose ()
 
bool wantToClose ()
 

Protected Member Functions

void shrinkDockWidget (QDockWidget *dockWidget, int fontSize, int spacing)
 
void shrinkObject (QObject *obj, int fontSize, int spacing)
 
void setObjectSpacing (QObject *obj, int spacing)
 

Detailed Description

Definition at line 7 of file qcepmainwindow.h.

Constructor & Destructor Documentation

QcepMainWindow::QcepMainWindow ( QWidget *  parent = 0)
explicit

Definition at line 12 of file qcepmainwindow.cpp.

12  : QMainWindow(parent)
13 {
14 
15 }

Member Function Documentation

void QcepMainWindow::possiblyClose ( )

Definition at line 18 of file qcepmainwindow.cpp.

References wantToClose().

19 {
20  // printf("QxrdWindow::possiblyClose()\n");
21  if (wantToClose()) {
22  close();
23  }
24 }

Here is the call graph for this function:

virtual void QcepMainWindow::printMessage ( QString  msg,
QDateTime  ts = QDateTime::currentDateTime() 
)
pure virtualslot

Referenced by shrinkObject().

Here is the caller graph for this function:

void QcepMainWindow::setFontSize ( int  fontSize)
slot

Definition at line 35 of file qcepmainwindow.cpp.

References INVOKE_CHECK.

Referenced by QxrdWindow::initialize(), QxrdDetectorControlWindow::QxrdDetectorControlWindow(), and shrinkPanels().

36 {
37  if (QThread::currentThread()==thread()) {
38  if (fontSize > 0) {
39  QFont f = font();
40 
41  f.setPointSize(fontSize);
42 
43  setFont(f);
44  } else {
45  QFont f = QApplication::font(this);
46  setFont(f);
47  }
48  } else {
49  INVOKE_CHECK(QMetaObject::invokeMethod(this,
50  "setFontSize",
51  Qt::QueuedConnection,
52  Q_ARG(int, fontSize)));
53  }
54 }
#define INVOKE_CHECK(res)
Definition: qcepmacros.h:13

Here is the caller graph for this function:

void QcepMainWindow::setObjectSpacing ( QObject *  obj,
int  spacing 
)
protected

Definition at line 68 of file qcepmainwindow.cpp.

Referenced by setSpacing().

69 {
70  QLayout *ly = qobject_cast<QLayout*>(obj);
71 
72  if (ly) {
73  ly->setContentsMargins(spacing, spacing, spacing, spacing);
74 
75  QGridLayout *gl = qobject_cast<QGridLayout*>(ly);
76 
77  if (gl) {
78  gl->setHorizontalSpacing(spacing);
79  gl->setVerticalSpacing(spacing);
80  }
81  }
82  // QTableView *tv = qobject_cast<QTableView*>(obj);
83 
84  // if (tv) {
85  // tv->setStyleSheet(tr("QTableWidget::item { padding: %1px }").arg(spacing));
86  // }
87 
88  foreach(QObject* chobj, obj->children()) {
89  if (chobj) {
90  setObjectSpacing(chobj, spacing);
91  }
92  }
93 }
void setObjectSpacing(QObject *obj, int spacing)

Here is the caller graph for this function:

void QcepMainWindow::setSpacing ( int  spacing)
slot

Definition at line 56 of file qcepmainwindow.cpp.

References INVOKE_CHECK, and setObjectSpacing().

Referenced by QxrdWindow::initialize(), QxrdDetectorControlWindow::QxrdDetectorControlWindow(), and shrinkPanels().

57 {
58  if (QThread::currentThread()==thread()) {
59  setObjectSpacing(this, spacing);
60  } else {
61  INVOKE_CHECK(QMetaObject::invokeMethod(this,
62  "setSpacing",
63  Qt::QueuedConnection,
64  Q_ARG(int, spacing)));
65  }
66 }
#define INVOKE_CHECK(res)
Definition: qcepmacros.h:13
void setObjectSpacing(QObject *obj, int spacing)

Here is the call graph for this function:

Here is the caller graph for this function:

void QcepMainWindow::shrinkDockWidget ( QDockWidget *  dockWidget,
int  fontSize,
int  spacing 
)
protected

Definition at line 110 of file qcepmainwindow.cpp.

References shrinkObject().

111 {
112  shrinkObject(dw, fontSize, spacing);
113 }
void shrinkObject(QObject *obj, int fontSize, int spacing)

Here is the call graph for this function:

void QcepMainWindow::shrinkObject ( QObject *  obj,
int  fontSize,
int  spacing 
)
protected

Definition at line 115 of file qcepmainwindow.cpp.

References DEBUG_WINDOW, HEXARG, printMessage(), and qcepDebug().

Referenced by shrinkDockWidget().

116 {
117  if (obj) {
118  // printf("shrinkObject %p[%s]\n", obj, qPrintable(obj->objectName()));
119 
120  QWidget *wid = qobject_cast<QWidget*>(obj);
121 
122  QVariant fsz = obj->property("defaultFontSize");
123  QVariant mrga = obj->property("defaultAMargins");
124  QVariant mrgb = obj->property("defaultBMargins");
125 
126  if (qcepDebug(DEBUG_WINDOW)) {
127  printMessage(tr("QxrdWindow::shrinkObject(\"%1\",%2)").arg(obj->objectName()).HEXARG(obj));
128  printMessage(tr("Default Font Size %1, Margins A [%2,%3], B [%4,%5]").arg(fsz.toInt())
129  .arg(mrga.toPoint().x()).arg(mrga.toPoint().y())
130  .arg(mrgb.toPoint().x()).arg(mrgb.toPoint().y()));
131  }
132 
133  if (wid) {
134  int sz = wid->font().pointSize();
135 
136  int left, top, right, bottom;
137  wid->getContentsMargins(&left, &top, &right, &bottom);
138 
139  if (qcepDebug(DEBUG_WINDOW)) {
140  printMessage(tr("Existing Font Size %1, Margins A [%2,%3], B [%4,%5]").arg(sz).arg(left).arg(top).arg(right).arg(bottom));
141  }
142 
143  if (!fsz.isValid()) {
144  wid->setProperty("defaultFontSize", sz);
145  fsz = wid->property("defaultFontSize");
146  }
147 
148  if (!mrga.isValid()) {
149  wid->setProperty("defaultAMargins", QPoint(left, top));
150  mrga = wid->property("defaultAMargins");
151  }
152 
153  if (!mrgb.isValid()) {
154  wid->setProperty("defaultBMargins", QPoint(right, bottom));
155  mrgb = wid->property("defaultBMargins");
156  }
157 
158  if (fontSize >= 0) {
159  QFont f = wid->font();
160  f.setPointSize(fontSize);
161  wid->setFont(f);
162  } else {
163  QFont f = wid->font();
164  f.setPointSize(fsz.toInt());
165  wid->setFont(f);
166  }
167 
168  if (spacing >= 0) {
169  wid->setContentsMargins(spacing, spacing, spacing, spacing);
170  } else {
171  QPoint ma = mrga.toPoint();
172  QPoint mb = mrgb.toPoint();
173 
174  if (!ma.isNull() && !mb.isNull()) {
175  wid->setContentsMargins(ma.x(), ma.y(), mb.x(), mb.y());
176  }
177  }
178  }
179 
180  if (qcepDebug(DEBUG_WINDOW)) {
181  printMessage(tr("Default Font Size %1, Margins A [%2,%3], B [%4,%5]").arg(fsz.toInt())
182  .arg(mrga.toPoint().x()).arg(mrga.toPoint().y())
183  .arg(mrgb.toPoint().x()).arg(mrgb.toPoint().y()));
184  }
185 
186  QLayout *ly = qobject_cast<QLayout*>(obj);
187 
188  if (ly) {
189  if (spacing >= 0) {
190  ly->setContentsMargins(spacing, spacing, spacing, spacing);
191  } else {
192  QPoint ma = mrga.toPoint();
193  QPoint mb = mrgb.toPoint();
194 
195  if (!ma.isNull() && !mb.isNull()) {
196  ly->setContentsMargins(ma.x(), ma.y(), mb.x(), mb.y());
197  }
198  }
199 
200  QGridLayout *gl = qobject_cast<QGridLayout*>(ly);
201 
202  if (gl) {
203 // gl->setContentsMargins(spacing, spacing, spacing, spacing);
204  QVariant spc = gl->property("defaultSpacing");
205 
206  if (qcepDebug(DEBUG_WINDOW)) {
207  printMessage(tr("Default spacing [%1,%2]").arg(spc.toPoint().x()).arg(spc.toPoint().y()));
208  }
209 
210  if (!spc.isValid()) {
211  int hs = gl->horizontalSpacing();
212  int vs = gl->verticalSpacing();
213 
214  if (qcepDebug(DEBUG_WINDOW)) {
215  printMessage(tr("Existing spacing [%1,%2]").arg(hs).arg(vs));
216  }
217 
218  gl->setProperty("defaultSpacing", QPoint(hs,vs));
219  spc = gl->property("defaultSpacing");
220  }
221 
222  if (spacing >= 0) {
223  gl->setHorizontalSpacing(spacing);
224  gl->setVerticalSpacing(spacing);
225  } else {
226  QPoint sp = spc.toPoint();
227  if (!sp.isNull()) {
228  gl->setHorizontalSpacing(sp.x());
229  gl->setVerticalSpacing(sp.y());
230  }
231  }
232 
233  if (qcepDebug(DEBUG_WINDOW)) {
234  printMessage(tr("Default spacing [%1,%2]").arg(spc.toPoint().x()).arg(spc.toPoint().y()));
235  }
236  }
237  }
238 
239  foreach(QObject* chobj, obj->children()) {
240  if (chobj) {
241  shrinkObject(chobj, fontSize, spacing);
242  }
243  }
244  }
245 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
void shrinkObject(QObject *obj, int fontSize, int spacing)
#define HEXARG(a)
Definition: qcepdebug.h:50
virtual void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime())=0

Here is the call graph for this function:

Here is the caller graph for this function:

void QcepMainWindow::shrinkPanels ( int  fontSize,
int  spacing 
)
slot

Definition at line 95 of file qcepmainwindow.cpp.

References setFontSize(), and setSpacing().

Referenced by QxrdWindow::initialize().

96 {
97 // if (QThread::currentThread()==thread()) {
98 // shrinkObject(this, fontSize, spacing);
99 // } else {
100 // INVOKE_CHECK(QMetaObject::invokeMethod(this,
101 // "shrinkPanels",
102 // Qt::QueuedConnection,
103 // Q_ARG(int, fontSize),
104 // Q_ARG(int, spacing)));
105 // }
106  setFontSize(fontSize);
107  setSpacing(spacing);
108 }
void setSpacing(int spacing)
void setFontSize(int fontSize)

Here is the call graph for this function:

Here is the caller graph for this function:

bool QcepMainWindow::wantToClose ( )

Definition at line 26 of file qcepmainwindow.cpp.

References THREAD_CHECK.

Referenced by QxrdWindow::closeEvent(), and possiblyClose().

27 {
29 
30  return QMessageBox::question(this, tr("Really Close?"),
31  tr("Do you really want to close the window?"),
32  QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok;
33 }
#define THREAD_CHECK
Definition: qcepmacros.h:11

Here is the caller graph for this function:


The documentation for this class was generated from the following files: