13 #include "MainWindow.h"
14 #include "MdiCubeViewport.h"
17 #include <QDoubleSpinBox>
19 #include <QHBoxLayout>
20 #include <QListWidgetItem>
23 #include <QPushButton>
28 #include <QToolButton>
29 #include <QVBoxLayout>
42 p_dialog->setWindowTitle(
"Blink Comparator");
51 connect(
p_listWidget, SIGNAL(itemActivated(QListWidgetItem *)),
56 p_splitter =
new QSplitter(Qt::Vertical,
p_dialog);
59 p_splitter->setCollapsible(0,
false);
60 p_splitter->setCollapsible(1,
false);
61 p_splitter->setStretchFactor(0, 0);
62 p_splitter->setStretchFactor(1, 1);
66 QVBoxLayout *layout =
new QVBoxLayout();
69 layout->addWidget(p_splitter, 1);
70 layout->addWidget(buttons, 0);
73 QToolButton *
reverse =
new QToolButton(buttons);
75 reverse->setIconSize(QSize(22, 22));
76 reverse->setShortcut(Qt::CTRL + Qt::Key_Delete);
77 reverse->setToolTip(
"Previous");
78 QString text =
"<b>Function:</b> Show previous linked viewport and \
79 stop automatic timed blinking \
80 <p><b>Shortcut:</b> Ctrl+Delete</p>";
84 QToolButton *
stop =
new QToolButton(buttons);
86 stop->setIconSize(QSize(22, 22));
87 stop->setToolTip(
"Stop");
88 text =
"<b>Function:</b> Stop automatic timed blinking";
89 stop->setWhatsThis(text);
90 connect(
stop, SIGNAL(released()),
this, SLOT(
stop()));
92 QToolButton *
start =
new QToolButton(buttons);
94 start->setIconSize(QSize(22, 22));
95 start->setToolTip(
"Start");
96 text =
"<b>Function:</b> Start automatic timed blinking. Cycles \
97 through linked viewports at variable rate";
98 start->setWhatsThis(text);
99 connect(
start, SIGNAL(released()),
this, SLOT(
start()));
101 QToolButton *forward =
new QToolButton(buttons);
102 forward->setIcon(QPixmap(
toolIconDir() +
"/blinkAdvance.png"));
103 forward->setIconSize(QSize(22, 22));
104 forward->setToolTip(
"Next");
105 forward->setShortcut(Qt::Key_Delete);
106 text =
"<b>Function:</b> Show next linked viewport and stop \
107 automatic timed blinking \
108 <p><b>Shortcut:</b> Delete</p>";
109 forward->setWhatsThis(text);
110 connect(forward, SIGNAL(released()),
this, SLOT(
advance()));
119 text =
"<b>Function:</b> Change automatic blink rate between " +
120 QString::number(
p_timeBox->minimum()) +
" and " +
121 QString::number(
p_timeBox->maximum()) +
" seconds";
124 QPushButton *close =
new QPushButton(
"Close", buttons);
125 close->setDefault(
false);
126 close->setAutoDefault(
false);
127 connect(close, SIGNAL(released()),
p_dialog, SLOT(hide()));
128 connect(close, SIGNAL(released()),
this, SLOT(
stop()));
130 QHBoxLayout *hlayout =
new QHBoxLayout();
132 hlayout->addWidget(
stop);
133 hlayout->addWidget(
start);
134 hlayout->addWidget(forward);
136 hlayout->addStretch(1);
137 hlayout->addWidget(close);
138 buttons->setLayout(hlayout);
147 "<b>Function:</b> Opens a blink comparator for linked viewports. \
148 <p><b>Shortcut:</b>K</p>";
186 QString unlinkedIcon =
FileName(
"$ISISROOT/appdata/images/icons/unlinked.png").
expanded();
187 static QIcon unlinked(unlinkedIcon);
188 QString linkedIcon =
FileName(
"$ISISROOT/appdata/images/icons/linked.png").
expanded();
189 static QIcon linked(linkedIcon);
193 disconnect(d, SIGNAL(linkChanging(
bool)),
this, 0);
194 disconnect(d, SIGNAL(windowTitleChanged()),
this, 0);
195 QListWidgetItem *item =
new QListWidgetItem(
p_listWidget);
196 item->setText(d->parentWidget()->windowTitle());
198 item->setIcon(linked);
201 item->setIcon(unlinked);
203 connect(d, SIGNAL(linkChanging(
bool)),
this, SLOT(
updateTool()));
204 connect(d, SIGNAL(windowTitleChanged()),
this, SLOT(
updateTool()));
273 int msec = (int)(
p_timeBox->value() * 1000.0);
274 QTimer::singleShot(msec,
this, SLOT(
timeout()));
325 QSettings settings(MainWindow::settingsFileName(
"BlinkTool"), QSettings::NativeFormat);
326 settings.setValue(
"rate",
p_timeBox->value());
327 settings.setValue(
"size",
p_dialog->size());
328 settings.setValue(
"pos",
p_dialog->pos());
329 settings.setValue(
"geom",
p_dialog->saveGeometry());
330 settings.setValue(
"splitterState", p_splitter->saveState());
340 QSettings settings(MainWindow::settingsFileName(
"BlinkTool"), QSettings::NativeFormat);
341 double rate = settings.value(
"rate", 0.5).toDouble();
343 p_dialog->restoreGeometry(settings.value(
"geom").toByteArray());
344 p_splitter->restoreState(settings.value(
"splitterState").toByteArray());
346 if (!settings.value(
"pos").toPoint().isNull())
347 p_dialog->move(settings.value(
"pos").toPoint());
349 p_dialog->resize(settings.value(
"size", QSize(492, 492)).toSize());
368 if(e->type() != QEvent::Paint)
return false;
370 static QPixmap lastPixmap;
393 p.drawPixmap(x, y, lastPixmap, sx, sy, -1, -1);