mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-15 06:45:48 +00:00
more correct logging, use qt logging for qml as well
This commit is contained in:
@ -111,6 +111,6 @@ Item {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.log("")
|
||||
if (debug) console.debug()
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ Item {
|
||||
width: parent.width * 2 / 3
|
||||
text: plasmoid.configuration.currentFontFamily
|
||||
onClicked: {
|
||||
if (debug) console.debug()
|
||||
fontDialog.setFont()
|
||||
fontDialog.visible = true
|
||||
}
|
||||
@ -133,8 +134,10 @@ Item {
|
||||
]
|
||||
onCurrentIndexChanged: cfg_currentFontWeight = model[currentIndex]["name"]
|
||||
Component.onCompleted: {
|
||||
if (debug) console.debug()
|
||||
for (var i = 0; i < model.length; i++) {
|
||||
if (model[i]["name"] == plasmoid.configuration.currentFontWeight) {
|
||||
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||
fontWeight.currentIndex = i;
|
||||
}
|
||||
}
|
||||
@ -168,8 +171,10 @@ Item {
|
||||
]
|
||||
onCurrentIndexChanged: cfg_currentFontStyle = model[currentIndex]["name"]
|
||||
Component.onCompleted: {
|
||||
if (debug) console.debug()
|
||||
for (var i = 0; i < model.length; i++) {
|
||||
if (model[i]["name"] == plasmoid.configuration.currentFontStyle) {
|
||||
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||
fontStyle.currentIndex = i;
|
||||
}
|
||||
}
|
||||
@ -214,12 +219,14 @@ Item {
|
||||
signal setFont
|
||||
|
||||
onAccepted: {
|
||||
if (debug) console.debug()
|
||||
selectFont.text = fontDialog.font.family
|
||||
fontSize.value = fontDialog.font.pointSize
|
||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||
}
|
||||
onSetFont: {
|
||||
if (debug) console.debug()
|
||||
fontDialog.font = Qt.font({
|
||||
family: selectFont.text,
|
||||
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||
@ -230,6 +237,6 @@ Item {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.log("")
|
||||
if (debug) console.debug()
|
||||
}
|
||||
}
|
||||
|
@ -128,8 +128,10 @@ Item {
|
||||
]
|
||||
onCurrentIndexChanged: cfg_tooltipType = model[currentIndex]["name"]
|
||||
Component.onCompleted: {
|
||||
if (debug) console.debug()
|
||||
for (var i = 0; i < model.length; i++) {
|
||||
if (model[i]["name"] == plasmoid.configuration.tooltipType) {
|
||||
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||
tooltipType.currentIndex = i;
|
||||
}
|
||||
}
|
||||
@ -255,6 +257,6 @@ Item {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.log("")
|
||||
if (debug) console.debug()
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ Item {
|
||||
width: parent.width * 2 / 3
|
||||
text: plasmoid.configuration.fontFamily
|
||||
onClicked: {
|
||||
if (debug) console.debug()
|
||||
fontDialog.setFont()
|
||||
fontDialog.visible = true
|
||||
}
|
||||
@ -133,8 +134,10 @@ Item {
|
||||
]
|
||||
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
|
||||
Component.onCompleted: {
|
||||
if (debug) console.debug()
|
||||
for (var i = 0; i < model.length; i++) {
|
||||
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
|
||||
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||
fontWeight.currentIndex = i;
|
||||
}
|
||||
}
|
||||
@ -168,8 +171,10 @@ Item {
|
||||
]
|
||||
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
|
||||
Component.onCompleted: {
|
||||
if (debug) console.debug()
|
||||
for (var i = 0; i < model.length; i++) {
|
||||
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
|
||||
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||
fontStyle.currentIndex = i;
|
||||
}
|
||||
}
|
||||
@ -214,12 +219,14 @@ Item {
|
||||
signal setFont
|
||||
|
||||
onAccepted: {
|
||||
if (debug) console.debug()
|
||||
selectFont.text = fontDialog.font.family
|
||||
fontSize.value = fontDialog.font.pointSize
|
||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||
}
|
||||
onSetFont: {
|
||||
if (debug) console.debug()
|
||||
fontDialog.font = Qt.font({
|
||||
family: selectFont.text,
|
||||
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||
@ -230,6 +237,6 @@ Item {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.log("")
|
||||
if (debug) console.debug()
|
||||
}
|
||||
}
|
||||
|
@ -108,11 +108,11 @@ Item {
|
||||
}
|
||||
|
||||
onNeedUpdate: {
|
||||
if (debug) console.log("")
|
||||
if (debug) console.debug()
|
||||
|
||||
for (var i=0; i<repeater.count; i++) {
|
||||
if (!repeater.itemAt(i)) {
|
||||
if (debug) console.log("Nothing to do here " + i)
|
||||
if (debug) console.info("Nothing to do here", i)
|
||||
timer.start()
|
||||
return
|
||||
}
|
||||
@ -138,7 +138,7 @@ Item {
|
||||
}
|
||||
|
||||
onNeedTooltipUpdate: {
|
||||
if (debug) console.log("")
|
||||
if (debug) console.debug()
|
||||
|
||||
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("")
|
||||
if (debug) console.debug()
|
||||
|
||||
if (plasmoid.configuration.height == 0) {
|
||||
var newHeight = 0
|
||||
@ -171,14 +171,14 @@ Item {
|
||||
}
|
||||
|
||||
Plasmoid.onActivated: {
|
||||
if (debug) console.log("")
|
||||
if (debug) console.debug()
|
||||
|
||||
// dpAdds.changePanelsState()
|
||||
}
|
||||
|
||||
Plasmoid.onUserConfiguringChanged: {
|
||||
if (plasmoid.userConfiguring) return
|
||||
if (debug) console.log("")
|
||||
if (debug) console.debug()
|
||||
|
||||
dpAdds.setMark(plasmoid.configuration.mark)
|
||||
dpAdds.setPanelsToControl(plasmoid.configuration.panels)
|
||||
@ -188,7 +188,7 @@ Item {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.log("")
|
||||
if (debug) console.debug()
|
||||
|
||||
// init submodule
|
||||
Plasmoid.userConfiguringChanged(false)
|
||||
|
@ -59,8 +59,7 @@ Item {
|
||||
iconName: "font"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Font button")
|
||||
|
||||
if (debug) console.debug("Font button")
|
||||
var defaultFont = {
|
||||
"color": plasmoid.configuration.fontColor,
|
||||
"family": plasmoid.configuration.fontFamily,
|
||||
@ -81,8 +80,7 @@ Item {
|
||||
iconName: "format-indent-more"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Indent button")
|
||||
|
||||
if (debug) console.debug("Indent button")
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -95,8 +93,7 @@ Item {
|
||||
iconName: "format-text-bold"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Bold button")
|
||||
|
||||
if (debug) console.debug("Bold button")
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -108,8 +105,7 @@ Item {
|
||||
iconName: "format-text-italic"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Italic button")
|
||||
|
||||
if (debug) console.debug("Italic button")
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -121,8 +117,7 @@ Item {
|
||||
iconName: "format-text-underline"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Underline button")
|
||||
|
||||
if (debug) console.debug("Underline button")
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -134,8 +129,7 @@ Item {
|
||||
iconName: "format-text-strikethrough"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Strike button")
|
||||
|
||||
if (debug) console.debug("Strike button")
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -148,8 +142,7 @@ Item {
|
||||
iconName: "format-justify-left"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Left button")
|
||||
|
||||
if (debug) console.debug("Left button")
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -161,8 +154,7 @@ Item {
|
||||
iconName: "format-justify-center"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Center button")
|
||||
|
||||
if (debug) console.debug("Center button")
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -174,8 +166,7 @@ Item {
|
||||
iconName: "format-justify-right"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Right button")
|
||||
|
||||
if (debug) console.debug("Right button")
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -187,8 +178,7 @@ Item {
|
||||
iconName: "format-justify-fill"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Justify button")
|
||||
|
||||
if (debug) console.debug("Justify button")
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -210,8 +200,7 @@ Item {
|
||||
text: i18n("Add")
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Add tag button")
|
||||
|
||||
if (debug) console.debug("Add tag button")
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -223,8 +212,7 @@ Item {
|
||||
text: i18n("Show value")
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("Show tag button")
|
||||
|
||||
if (debug) console.debug("Show tag button")
|
||||
var message = i18n("Tag: %1", tags.currentText)
|
||||
message += "<br>"
|
||||
message += i18n("Value: %1", dpAdds.valueByKey(tags.currentText))
|
||||
@ -244,6 +232,6 @@ Item {
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.log("")
|
||||
if (debug) console.debug()
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <QListWidget>
|
||||
#include <QMessageBox>
|
||||
#include <QPixmap>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QScreen>
|
||||
|
||||
#include <fontdialog/fontdialog.h>
|
||||
@ -41,13 +40,12 @@
|
||||
DPAdds::DPAdds(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
bool debug = (debugEnv == QString("yes"));
|
||||
qCDebug(LOG_DP);
|
||||
|
||||
// logging
|
||||
const_cast<QLoggingCategory &>(LOG_DP()).setEnabled(QtMsgType::QtDebugMsg, debug);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||
const_cast<QLoggingCategory &>(LOG_DP()).setEnabled(QtMsgType::QtInfoMsg, false);
|
||||
#endif /* QT_VERSION */
|
||||
qSetMessagePattern(LOG_FORMAT);
|
||||
|
||||
connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SIGNAL(desktopChanged()));
|
||||
@ -110,7 +108,8 @@ QString DPAdds::toolTipImage(const int desktop) const
|
||||
DesktopWindowsInfo info = getInfoByDesktop(desktop);
|
||||
if (tooltipType == QString("names")) {
|
||||
QStringList windowList;
|
||||
foreach(WindowData data, info.windowsData) windowList.append(data.name);
|
||||
std::for_each(info.windowsData.cbegin(), info.windowsData.cend(),
|
||||
[&windowList](WindowData data) { windowList.append(data.name); });
|
||||
return QString("<ul><li>%1</li></ul>").arg(windowList.join(QString("</li><li>")));
|
||||
}
|
||||
// init
|
||||
@ -151,20 +150,23 @@ QString DPAdds::toolTipImage(const int desktop) const
|
||||
}
|
||||
} else if (tooltipType == QString("clean")) {
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
foreach(WindowData data, info.desktopsData) {
|
||||
QPixmap desktop = screen->grabWindow(data.id);
|
||||
toolTipScene->addPixmap(desktop)->setOffset(data.rect.left(), data.rect.top());
|
||||
}
|
||||
std::for_each(info.desktopsData.cbegin(), info.desktopsData.cend(),
|
||||
[&toolTipScene, &screen](WindowData data) {
|
||||
QPixmap desktop = screen->grabWindow(data.id);
|
||||
toolTipScene->addPixmap(desktop)->setOffset(data.rect.left(), data.rect.top());
|
||||
});
|
||||
} else if (tooltipType == QString("windows")) {
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
foreach(WindowData data, info.desktopsData) {
|
||||
QPixmap desktop = screen->grabWindow(data.id);
|
||||
toolTipScene->addPixmap(desktop)->setOffset(data.rect.left(), data.rect.top());
|
||||
}
|
||||
foreach(WindowData data, info.windowsData) {
|
||||
QPixmap window = screen->grabWindow(data.id);
|
||||
toolTipScene->addPixmap(window)->setOffset(data.rect.left(), data.rect.top());
|
||||
}
|
||||
std::for_each(info.desktopsData.cbegin(), info.desktopsData.cend(),
|
||||
[&toolTipScene, &screen](WindowData data) {
|
||||
QPixmap desktop = screen->grabWindow(data.id);
|
||||
toolTipScene->addPixmap(desktop)->setOffset(data.rect.left(), data.rect.top());
|
||||
});
|
||||
std::for_each(info.windowsData.cbegin(), info.windowsData.cend(),
|
||||
[&toolTipScene, &screen](WindowData data) {
|
||||
QPixmap window = screen->grabWindow(data.id);
|
||||
toolTipScene->addPixmap(window)->setOffset(data.rect.left(), data.rect.top());
|
||||
});
|
||||
}
|
||||
|
||||
QPixmap image = toolTipView->grab().scaledToWidth(tooltipWidth);
|
||||
@ -182,6 +184,8 @@ QString DPAdds::toolTipImage(const int desktop) const
|
||||
QString DPAdds::parsePattern(const QString pattern, const int desktop) const
|
||||
{
|
||||
qCDebug(LOG_DP);
|
||||
qCDebug(LOG_DP) << "Pattern" << pattern;
|
||||
qCDebug(LOG_DP) << "Desktop number" << desktop;
|
||||
|
||||
QString parsed = pattern;
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
@ -211,7 +215,7 @@ void DPAdds::setPanelsToControl(const QString newPanels)
|
||||
if (newPanels == QString("-1")) {
|
||||
int count = getPanels().count();
|
||||
for (int i=0; i<count; i++)
|
||||
panelsToControl.append(i);
|
||||
panelsToControl.append(i);
|
||||
} else
|
||||
foreach(QString panel, newPanels.split(QChar(',')))
|
||||
panelsToControl.append(panel.toInt());
|
||||
@ -233,6 +237,7 @@ QString DPAdds::valueByKey(const QString key, int desktop) const
|
||||
{
|
||||
qCDebug(LOG_DP);
|
||||
qCDebug(LOG_DP) << "Requested key" << key;
|
||||
qCDebug(LOG_DP) << "Desktop number" << desktop;
|
||||
if (desktop == -1) desktop = currentDesktop();
|
||||
|
||||
QString currentMark = currentDesktop() == desktop ? mark : QString("");
|
||||
@ -253,6 +258,7 @@ QString DPAdds::valueByKey(const QString key, int desktop) const
|
||||
QString DPAdds::editPanelsToContol(const QString current)
|
||||
{
|
||||
qCDebug(LOG_DP);
|
||||
qCDebug(LOG_DP) << "Current panels" << current;
|
||||
|
||||
// paint
|
||||
QDialog *dialog = new QDialog(nullptr);
|
||||
@ -342,6 +348,7 @@ QString DPAdds::getAboutText(const QString type) const
|
||||
QVariantMap DPAdds::getFont(const QVariantMap defaultFont) const
|
||||
{
|
||||
qCDebug(LOG_DP);
|
||||
qCDebug(LOG_DP) << "Default font is" << defaultFont;
|
||||
|
||||
QVariantMap fontMap;
|
||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||
@ -466,6 +473,7 @@ QString DPAdds::panelLocationToStr(Plasma::Types::Location location) const
|
||||
case Plasma::Types::Location::RightEdge:
|
||||
return i18n("Right Edge");
|
||||
default:
|
||||
qCWarning(LOG_DP) << "Unknown location" << location;
|
||||
return i18n("Unknown location (%1)", location);
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ class DPAdds : public QObject
|
||||
} DesktopWindowsInfo;
|
||||
|
||||
public:
|
||||
DPAdds(QObject *parent = nullptr);
|
||||
~DPAdds();
|
||||
explicit DPAdds(QObject *parent = nullptr);
|
||||
virtual ~DPAdds();
|
||||
|
||||
Q_INVOKABLE bool isDebugEnabled() const;
|
||||
Q_INVOKABLE int currentDesktop() const;
|
||||
|
Reference in New Issue
Block a user