Call attention to the warn/error logs using animation
This commit is contained in:
parent
dccf2042f0
commit
0e72a58dd7
23
client/icons/error.svg
Normal file
23
client/icons/error.svg
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg width="31.44mm" height="31.44mm" version="1.1" viewBox="0 0 31.44 31.44" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<metadata>
|
||||
<rdf:RDF>
|
||||
<cc:Work rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:title/>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g transform="translate(-37.525 -210.5)">
|
||||
<circle cx="53.245" cy="226.22" r="15.72" fill="#e96c59" opacity=".8"/>
|
||||
<path d="m53.419 212.28c-2.0736-0.0217-4.1616 0.41684-6.0884 1.3285-4.4585 2.1095-7.4154 6.2656-7.9501 11.175-0.50808 4.6643 1.5269 9.4967 5.2044 12.359 2.066 1.6079 4.6873 2.6928 7.1183 2.9462 2.643 0.2755 5.2282-0.17492 7.6011-1.3243 1.9456-0.94242 3.6302-2.2856 4.9044-3.9102 3.2672-4.1658 3.8994-9.8451 1.6275-14.62-1.0934-2.298-2.6916-4.1431-4.8639-5.6154-2.245-1.5216-4.8872-2.3101-7.5533-2.338zm-0.0276 2.2048c2.2445 0.0235 4.4688 0.68733 6.3588 1.9683 1.8288 1.2395 3.1743 2.7928 4.0948 4.7274 1.9126 4.0198 1.3803 8.8011-1.3702 12.308-1.0727 1.3677-2.4908 2.4985-4.1288 3.2919-1.9976 0.96764-4.1741 1.3468-6.3992 1.1148-2.0466-0.21332-4.2533-1.1267-5.9926-2.4803-3.096-2.4094-4.8092-6.4777-4.3814-10.404 0.45017-4.1327 2.9394-7.6316 6.6928-9.4075 1.6221-0.76747 3.38-1.1367 5.1257-1.1184z" fill="#f9bbab" opacity=".8"/>
|
||||
<g fill="#fff">
|
||||
<rect x="50.933" y="217.52" width="4.6236" height="12.862" opacity=".8"/>
|
||||
<rect transform="scale(1,-1)" x="50.933" y="-234.92" width="4.6236" height="3.5749" opacity=".8"/>
|
||||
<rect x="50.933" y="217.52" width="4.6236" height="12.862" opacity=".8"/>
|
||||
<rect transform="scale(1,-1)" x="50.933" y="-234.92" width="4.6236" height="3.5749" opacity=".8"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.9 KiB |
25
client/icons/warn.svg
Normal file
25
client/icons/warn.svg
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg width="221.25mm" height="193.24mm" version="1.1" viewBox="0 0 221.25 193.24" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="linearGradient879" x1="193.48" x2="101.09" y1="198.47" y2="254.08" gradientTransform="matrix(1.7412 0 0 1.7412 -267.69 -212.02)" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#c16602" stop-opacity=".99608" offset="0"/>
|
||||
<stop stop-color="#e8b839" offset="1"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<metadata>
|
||||
<rdf:RDF>
|
||||
<cc:Work rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:title/>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g transform="translate(97.776 -43.224)">
|
||||
<path d="m12.851 49.318 104.53 181.06h-209.07z" fill="#fff" opacity=".8" stroke="url(#linearGradient879)" stroke-linecap="round" stroke-linejoin="round" stroke-opacity=".99216" stroke-width="12.188"/>
|
||||
<path d="m12.851 101.1 62.098 107.56h-124.2z" fill="#f5db61" opacity=".8"/>
|
||||
<rect x=".23388" y="113.27" width="25.235" height="54.405" fill="#c28832" opacity=".8"/>
|
||||
<rect transform="scale(1,-1)" x=".23388" y="-196.48" width="25.235" height="14.793" fill="#c28832" opacity=".8"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include <QHeaderView>
|
||||
#include <QMainWindow>
|
||||
#include <QMovie>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
extern QMainWindow *mainWindow;
|
||||
|
||||
@ -49,6 +50,13 @@ LogsWindow::LogsWindow(LogsModel *model, QWidget *parent)
|
||||
warnAnime_ = new QMovie(":/icons/anime_warn.gif", QByteArray(), this);
|
||||
errorAnime_ = new QMovie(":/icons/anime_error.gif", QByteArray(), this);
|
||||
|
||||
alert_ = new QLabel("ALERT!", this,
|
||||
Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
|
||||
alert_->setScaledContents(true);
|
||||
alertAnime_ = new QPropertyAnimation(alert_, "geometry", this);
|
||||
alertAnime_->setDuration(2000);
|
||||
alertAnime_->setEasingCurve(QEasingCurve::InOutExpo);
|
||||
|
||||
connect(level, SIGNAL(currentIndexChanged(int)),
|
||||
model, SLOT(setLogLevel(int)));
|
||||
connect(clear, SIGNAL(clicked()), model, SLOT(clear()));
|
||||
@ -85,8 +93,7 @@ void LogsWindow::when_visibilityChanged(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
logs->resizeRowsToContents();
|
||||
state_ = kInfo;
|
||||
notify();
|
||||
setState(kInfo);
|
||||
}
|
||||
|
||||
isVisible_ = visible;
|
||||
@ -96,29 +103,26 @@ void LogsWindow::when_visibilityChanged(bool visible)
|
||||
void LogsWindow::when_rowsInserted(const QModelIndex &parent,
|
||||
int first, int last)
|
||||
{
|
||||
|
||||
if (isVisible_) {
|
||||
if (isVisible_)
|
||||
logs->resizeRowsToContents();
|
||||
return;
|
||||
}
|
||||
|
||||
if (state_ == kError)
|
||||
return;
|
||||
|
||||
State incrementalState = kInfo;
|
||||
for (int i = first; i <= last; i++) {
|
||||
// FIXME: use a user-role instead, so we don't need to know column and
|
||||
// have to compare strings?
|
||||
QString level = logs->model()->data(logs->model()->index(i, 1, parent))
|
||||
.toString();
|
||||
if (level == "Error") {
|
||||
state_ = kError;
|
||||
incrementalState = kError;
|
||||
break; // Highest level - no need to look further
|
||||
}
|
||||
else if (level == "Warning") {
|
||||
state_ = kWarning;
|
||||
incrementalState = kWarning;
|
||||
}
|
||||
}
|
||||
notify();
|
||||
alert(incrementalState);
|
||||
if (incrementalState > state())
|
||||
setState(incrementalState);
|
||||
}
|
||||
|
||||
void LogsWindow::on_autoScroll_toggled(bool checked)
|
||||
@ -135,6 +139,19 @@ void LogsWindow::on_autoScroll_toggled(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
LogsWindow::State LogsWindow::state()
|
||||
{
|
||||
return state_;
|
||||
}
|
||||
|
||||
void LogsWindow::setState(State state)
|
||||
{
|
||||
if (isVisible_)
|
||||
return;
|
||||
state_ = state;
|
||||
notify();
|
||||
}
|
||||
|
||||
QLabel* LogsWindow::tabIcon()
|
||||
{
|
||||
QList<QTabBar*> tabBars = mainWindow->findChildren<QTabBar*>();
|
||||
@ -155,6 +172,48 @@ QLabel* LogsWindow::tabIcon()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void LogsWindow::alert(State state)
|
||||
{
|
||||
if (state == kInfo)
|
||||
return;
|
||||
|
||||
QRect start;
|
||||
QWidget *view = isVisible_ ? dynamic_cast<QWidget*>(this) : mainWindow;
|
||||
alert_->setParent(view);
|
||||
start.setSize(QSize(256, 256).scaled(view->size()/2, Qt::KeepAspectRatio));
|
||||
start.moveCenter(QPoint(view->size().width()/2,
|
||||
view->size().height()/2));
|
||||
QPoint c;
|
||||
QLabel *icon = tabIcon();
|
||||
if (icon && !isVisible_) {
|
||||
c = icon->geometry().center(); // in icon's parent (tabBar) coords
|
||||
c = icon->mapFromParent(c); // in icon's own coords
|
||||
c = icon->mapTo(view, c); // in view's coords
|
||||
}
|
||||
else
|
||||
c = view->geometry().center();
|
||||
|
||||
QRect end;
|
||||
end.moveCenter(c);
|
||||
|
||||
switch (state) {
|
||||
case kError:
|
||||
alert_->setPixmap(QPixmap(":/icons/error.svg"));
|
||||
break;
|
||||
case kWarning:
|
||||
alert_->setPixmap(QPixmap(":/icons/warn.svg"));
|
||||
break;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
|
||||
alertAnime_->setStartValue(start);
|
||||
alertAnime_->setEndValue(end);
|
||||
alert_->show(); // ensure it's visible before starting animation
|
||||
alertAnime_->start();
|
||||
}
|
||||
|
||||
void LogsWindow::notify()
|
||||
{
|
||||
QString annotation;
|
||||
@ -164,7 +223,7 @@ void LogsWindow::notify()
|
||||
warnAnime_->stop();
|
||||
errorAnime_->stop();
|
||||
|
||||
switch (state_) {
|
||||
switch (state()) {
|
||||
case kError:
|
||||
anime = errorAnime_;
|
||||
annotation = " - Error(s)";
|
||||
|
@ -26,6 +26,7 @@ class LogsModel;
|
||||
class QDockWidget;
|
||||
class QShowEvent;
|
||||
class QMovie;
|
||||
class QPropertyAnimation;
|
||||
|
||||
class LogsWindow: public QWidget, private Ui::LogsWindow
|
||||
{
|
||||
@ -46,12 +47,17 @@ private:
|
||||
enum State {kInfo, kWarning, kError};
|
||||
|
||||
QLabel* tabIcon();
|
||||
State state();
|
||||
void setState(State state);
|
||||
void alert(State state);
|
||||
void notify();
|
||||
|
||||
State state_{kInfo};
|
||||
QDockWidget *parentDock_;
|
||||
QMovie *warnAnime_{nullptr};
|
||||
QMovie *errorAnime_{nullptr};
|
||||
QLabel *alert_{nullptr};
|
||||
QPropertyAnimation *alertAnime_{nullptr};
|
||||
QString windowTitle_;
|
||||
bool isVisible_{false};
|
||||
QObject *logsModelTest_;
|
||||
|
@ -23,6 +23,7 @@
|
||||
<file>icons/devicegroup_delete.png</file>
|
||||
<file>icons/devicegroup_edit.png</file>
|
||||
<file>icons/donate.png</file>
|
||||
<file>icons/error.svg</file>
|
||||
<file>icons/exit.png</file>
|
||||
<file>icons/frag_capture.png</file>
|
||||
<file>icons/frag_exclusive.png</file>
|
||||
@ -56,5 +57,6 @@
|
||||
<file>icons/stream_edit.png</file>
|
||||
<file>icons/stream_stats.png</file>
|
||||
<file>icons/transmit_on.png</file>
|
||||
<file>icons/warn.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
Reference in New Issue
Block a user