start moving to qt5 style logging

This commit is contained in:
arcan1s
2015-08-29 00:58:39 +03:00
parent 466faf53fa
commit aacb50c946
44 changed files with 598 additions and 516 deletions

View File

@ -111,6 +111,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[about::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -230,6 +230,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[activeapp::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -255,6 +255,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[advanced::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -230,6 +230,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[inactiveapp::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -108,11 +108,11 @@ Item {
}
onNeedUpdate: {
if (debug) console.log("[main::onNeedUpdate]")
if (debug) console.log("")
for (var i=0; i<repeater.count; i++) {
if (!repeater.itemAt(i)) {
if (debug) console.log("[main::onNeedUpdate] : Nothing to do here " + i)
if (debug) console.log("Nothing to do here " + i)
timer.start()
return
}
@ -138,7 +138,7 @@ Item {
}
onNeedTooltipUpdate: {
if (debug) console.log("[main::onNeedTooltipUpdate]")
if (debug) console.log("")
for (var i=0; i<repeater.count; i++) {
repeater.itemAt(i).tooltip.text = dpAdds.toolTipImage(i + 1)
@ -146,7 +146,7 @@ Item {
}
onSizeUpdate: {
if (debug) console.log("[main::onSizeUpdate]")
if (debug) console.log("")
if (plasmoid.configuration.height == 0) {
var newHeight = 0
@ -171,14 +171,14 @@ Item {
}
Plasmoid.onActivated: {
if (debug) console.log("[main::onActivated]")
if (debug) console.log("")
// dpAdds.changePanelsState()
}
Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.log("[main::onUserConfiguringChanged]")
if (debug) console.log("")
dpAdds.setMark(plasmoid.configuration.mark)
dpAdds.setPanelsToControl(plasmoid.configuration.panels)
@ -188,7 +188,7 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[main::onCompleted]")
if (debug) console.log("")
// init submodule
Plasmoid.userConfiguringChanged(false)

View File

@ -59,7 +59,7 @@ Item {
iconName: "font"
onClicked: {
if (debug) console.log("[widget::onClicked] : Font button")
if (debug) console.log("Font button")
var defaultFont = {
"color": plasmoid.configuration.fontColor,
@ -81,7 +81,7 @@ Item {
iconName: "format-indent-more"
onClicked: {
if (debug) console.log("[widget::onClicked] : Indent button")
if (debug) console.log("Indent button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -95,7 +95,7 @@ Item {
iconName: "format-text-bold"
onClicked: {
if (debug) console.log("[widget::onClicked] : Bold button")
if (debug) console.log("Bold button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -108,7 +108,7 @@ Item {
iconName: "format-text-italic"
onClicked: {
if (debug) console.log("[widget::onClicked] : Italic button")
if (debug) console.log("Italic button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -121,7 +121,7 @@ Item {
iconName: "format-text-underline"
onClicked: {
if (debug) console.log("[widget::onClicked] : Underline button")
if (debug) console.log("Underline button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -134,7 +134,7 @@ Item {
iconName: "format-text-strikethrough"
onClicked: {
if (debug) console.log("[widget::onClicked] : Strike button")
if (debug) console.log("Strike button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -148,7 +148,7 @@ Item {
iconName: "format-justify-left"
onClicked: {
if (debug) console.log("[widget::onClicked] : Left button")
if (debug) console.log("Left button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -161,7 +161,7 @@ Item {
iconName: "format-justify-center"
onClicked: {
if (debug) console.log("[widget::onClicked] : Center button")
if (debug) console.log("Center button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -174,7 +174,7 @@ Item {
iconName: "format-justify-right"
onClicked: {
if (debug) console.log("[widget::onClicked] : Right button")
if (debug) console.log("Right button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -187,7 +187,7 @@ Item {
iconName: "format-justify-fill"
onClicked: {
if (debug) console.log("[widget::onClicked] : Justify button")
if (debug) console.log("Justify button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -210,7 +210,7 @@ Item {
text: i18n("Add")
onClicked: {
if (debug) console.log("[widget::onClicked] : Add tag button")
if (debug) console.log("Add tag button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -223,7 +223,7 @@ Item {
text: i18n("Show value")
onClicked: {
if (debug) console.log("[widget::onClicked] : Show tag button")
if (debug) console.log("Show tag button")
var message = i18n("Tag: %1", tags.currentText)
message += "<br>"
@ -244,6 +244,6 @@ Item {
Component.onCompleted: {
if (debug) console.log("[widget::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -11,8 +11,7 @@ include_directories(
${Kf5_INCLUDE}
)
file(GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
file(GLOB SUBPROJECT_NOTIFY *.notifyrc)
add_library(${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})

View File

@ -22,7 +22,6 @@
#include <KWindowSystem/KWindowSystem>
#include <QBuffer>
#include <QDebug>
#include <QGraphicsPixmapItem>
#include <QGraphicsScene>
#include <QGraphicsView>
@ -34,21 +33,22 @@
#include <QScreen>
#include <fontdialog/fontdialog.h>
#include <pdebug/pdebug.h>
#include <pdebug/pdebug-time.h>
#include "awdebug.h"
#include "version.h"
DPAdds::DPAdds(QObject *parent)
: QObject(parent)
{
qInstallMessageHandler(debugString);
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes"));
bool debug = (debugEnv == QString("yes"));
// logging
const_cast<QLoggingCategory &>(LOG_DP()).setEnabled(QtMsgType::QtDebugMsg, debug);
qSetMessagePattern(LOG_FORMAT);
connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SIGNAL(desktopChanged()));
connect(KWindowSystem::self(), SIGNAL(windowAdded(WId)), this, SIGNAL(windowListChanged()));
@ -58,21 +58,21 @@ DPAdds::DPAdds(QObject *parent)
DPAdds::~DPAdds()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
}
bool DPAdds::isDebugEnabled() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
return debug;
return LOG_DP().isDebugEnabled();
}
int DPAdds::currentDesktop() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
return KWindowSystem::currentDesktop();
}
@ -80,7 +80,7 @@ int DPAdds::currentDesktop() const
QStringList DPAdds::dictKeys() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
QStringList allKeys;
allKeys.append(QString("mark"));
@ -94,7 +94,7 @@ QStringList DPAdds::dictKeys() const
int DPAdds::numberOfDesktops() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
return KWindowSystem::numberOfDesktops();
}
@ -102,8 +102,8 @@ int DPAdds::numberOfDesktops() const
QString DPAdds::toolTipImage(const int desktop) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Desktop" << desktop;
if (tooltipType == QString("none")) return QString();
// prepare
@ -181,7 +181,7 @@ QString DPAdds::toolTipImage(const int desktop) const
QString DPAdds::parsePattern(const QString pattern, const int desktop) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
QString parsed = pattern;
parsed.replace(QString("$$"), QString("$\\$\\"));
@ -195,8 +195,8 @@ QString DPAdds::parsePattern(const QString pattern, const int desktop) const
void DPAdds::setMark(const QString newMark)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Mark" << newMark;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Mark" << newMark;
mark = newMark;
}
@ -204,8 +204,8 @@ void DPAdds::setMark(const QString newMark)
void DPAdds::setPanelsToControl(const QString newPanels)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Panels" << newPanels;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Panels" << newPanels;
panelsToControl.clear();
if (newPanels == QString("-1")) {
@ -220,8 +220,8 @@ void DPAdds::setPanelsToControl(const QString newPanels)
void DPAdds::setToolTipData(const QVariantMap tooltipData)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Data" << tooltipData;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Data" << tooltipData;
tooltipColor = tooltipData[QString("tooltipColor")].toString();
tooltipType = tooltipData[QString("tooltipType")].toString();
@ -231,8 +231,8 @@ void DPAdds::setToolTipData(const QVariantMap tooltipData)
QString DPAdds::valueByKey(const QString key, int desktop) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Requested key" << key;
if (desktop == -1) desktop = currentDesktop();
QString currentMark = currentDesktop() == desktop ? mark : QString("");
@ -252,7 +252,7 @@ QString DPAdds::valueByKey(const QString key, int desktop) const
QString DPAdds::editPanelsToContol(const QString current)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
// paint
QDialog *dialog = new QDialog(nullptr);
@ -302,8 +302,8 @@ QString DPAdds::editPanelsToContol(const QString current)
QString DPAdds::getAboutText(const QString type) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Type" << type;
QString text;
if (type == QString("header"))
@ -341,7 +341,7 @@ QString DPAdds::getAboutText(const QString type) const
QVariantMap DPAdds::getFont(const QVariantMap defaultFont) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
QVariantMap fontMap;
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
@ -359,7 +359,7 @@ QVariantMap DPAdds::getFont(const QVariantMap defaultFont) const
void DPAdds::changePanelsState() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
if (panelsToControl.isEmpty()) return;
// QList<Plasma::Containment *> panels = getPanels();
@ -368,12 +368,12 @@ void DPAdds::changePanelsState() const
// bool wasVisible = panels.at(i)->view()->isVisible();
// int winId = panels.at(i)->view()->winId();
// if (wasVisible) {
// if (debug) qDebug() << PDEBUG << ":" << "Hide panel";
// qCDebug(LOG_DP) << "Hide panel";
// KWindowInfo oldInfo = KWindowSystem::windowInfo(winId, NET::WMState);
// oldState = oldInfo.state();
// panels.at(i)->view()->setVisible(false);
// } else {
// if (debug) qDebug() << PDEBUG << ":" << "Show panel";
// qCDebug(LOG_DP) << "Show panel";
// panels.at(i)->view()->setVisible(true);
// KWindowSystem::clearState(winId, NET::KeepAbove);
// KWindowSystem::setState(winId, oldState | NET::StaysOnTop);
@ -386,6 +386,10 @@ void DPAdds::changePanelsState() const
void DPAdds::sendNotification(const QString eventId, const QString message)
{
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Event" << eventId;
qCDebug(LOG_DP) << "Message" << message;
KNotification *notification = KNotification::event(eventId, QString("Desktop Panel ::: %1").arg(eventId), message);
notification->setComponentName(QString("plasma-applet-org.kde.plasma.desktop-panel"));
}
@ -393,8 +397,8 @@ void DPAdds::sendNotification(const QString eventId, const QString message)
void DPAdds::setCurrentDesktop(const int desktop) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Desktop" << desktop;
KWindowSystem::setCurrentDesktop(desktop);
}
@ -402,8 +406,8 @@ void DPAdds::setCurrentDesktop(const int desktop) const
DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int desktop) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Desktop" << desktop;
DesktopWindowsInfo info;
@ -433,7 +437,7 @@ DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int desktop) const
QList<Plasma::Containment *> DPAdds::getPanels() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
// Plasma::Corona *corona = new Plasma::Corona(this);
QList<Plasma::Containment *> panels;
@ -449,8 +453,8 @@ QList<Plasma::Containment *> DPAdds::getPanels() const
QString DPAdds::panelLocationToStr(Plasma::Types::Location location) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Location" << location;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Location" << location;
switch (location) {
case Plasma::Types::Location::TopEdge:

View File

@ -76,7 +76,6 @@ private:
QList<Plasma::Containment *> getPanels() const;
QString panelLocationToStr(Plasma::Types::Location location) const;
// variables
bool debug = false;
int oldState, tooltipWidth = 200;
QString mark = QString("*");
QString tooltipColor = QString("#000000");