Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log|libappfw|Client: Added PrivilegedLogWidget (developer utility)
Often when working on a specific piece of code, it is easiest to just use qDebug to print debug messages because they can be easily seen among the other messages. Doomsday's Log should provide a better way to handle this use case, so now there are Privileged entries. Instead of qDebug, you can now use LOG_WIP() in a similar fashion, and the entries will show up in the special overlaid log in the top left side of the screen. LOG_WIP() entries will appear normally in doomsday.out and the standard output, however they are omitted from the runtime console log widget.
- Loading branch information
Showing
8 changed files
with
162 additions
and
4 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
doomsday/apps/client/include/ui/widgets/privilegedlogwidget.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** @file privilegedlogwidget.h | ||
* | ||
* @authors Copyright (c) 2015 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef CLIENT_UI_WIDGETS_PRIVILEGEDLOGWIDGET_H | ||
#define CLIENT_UI_WIDGETS_PRIVILEGEDLOGWIDGET_H | ||
|
||
#include <de/GuiWidget> | ||
|
||
/** | ||
* Special heads-up log for viewing information about the current task (for | ||
* developers). | ||
*/ | ||
class PrivilegedLogWidget : public de::GuiWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
PrivilegedLogWidget(); | ||
|
||
public slots: | ||
void showLog(); | ||
void hideLog(); | ||
|
||
private: | ||
DENG2_PRIVATE(d) | ||
}; | ||
|
||
|
||
#endif // CLIENT_UI_WIDGETS_PRIVILEGEDLOGWIDGET_H | ||
|
77 changes: 77 additions & 0 deletions
77
doomsday/apps/client/src/ui/widgets/privilegedlogwidget.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** @file privilegedlogwidget.cpp | ||
* | ||
* @authors Copyright (c) 2015 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "ui/widgets/privilegedlogwidget.h" | ||
#include "ui/styledlogsinkformatter.h" | ||
#include <de/LogWidget> | ||
#include <de/ButtonWidget> | ||
|
||
using namespace de; | ||
|
||
DENG_GUI_PIMPL(PrivilegedLogWidget) | ||
{ | ||
StyledLogSinkFormatter formatter; | ||
LogWidget *log = nullptr; | ||
ButtonWidget *closeButton = nullptr; | ||
|
||
Instance(Public *i) : Base(i) | ||
{ | ||
log = new LogWidget("privlog"); | ||
log->setLogFormatter(formatter); | ||
log->setPrivilegedEntries(true); | ||
self.add(log); | ||
|
||
closeButton = new ButtonWidget; | ||
closeButton->setSizePolicy(ui::Expand, ui::Expand); | ||
closeButton->setImage(style().images().image("close.ringless")); | ||
closeButton->setImageScale(toDevicePixels(.25f)); | ||
closeButton->setImageColor(style().colors().colorf("altaccent")); | ||
self.add(closeButton); | ||
} | ||
}; | ||
|
||
PrivilegedLogWidget::PrivilegedLogWidget() | ||
: d(new Instance(this)) | ||
{ | ||
auto const &gap = style().rules().rule("gap"); | ||
|
||
hide(); | ||
connect(d->log, SIGNAL(contentHeightIncreased(int)), this, SLOT(showLog())); | ||
connect(d->closeButton, SIGNAL(pressed()), this, SLOT(hideLog())); | ||
|
||
d->log->rule() | ||
.setInput(Rule::Left, rule().left() + gap) | ||
.setInput(Rule::Top, rule().top() + gap) | ||
.setInput(Rule::Right, (rule().left() + rule().midX()) / 2) | ||
.setInput(Rule::Bottom, rule().midY() - gap); | ||
|
||
d->closeButton->rule() | ||
.setInput(Rule::Top, d->log->rule().top()) | ||
.setInput(Rule::Right, d->log->rule().right()); | ||
} | ||
|
||
void PrivilegedLogWidget::showLog() | ||
{ | ||
show(); | ||
} | ||
|
||
void PrivilegedLogWidget::hideLog() | ||
{ | ||
hide(); | ||
d->log->clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters