Commit 1a2360b2 authored by Laurent Montel's avatar Laurent Montel 😁

Use debug categories

parent ee9e5570
......@@ -13,6 +13,7 @@ include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMInstallIcons)
include(ECMQtDeclareLoggingCategory)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
......@@ -46,6 +47,8 @@ set(kmenueditcommon_STAT_SRCS preferencesdlg.cpp klinespellchecking.cpp basictab
########### next target ###############
qt5_add_dbus_adaptor( kmenueditcommon_STAT_SRCS org.kde.kmenuedit.xml kmenuedit.h KMenuEdit)
ecm_qt_declare_logging_category(kmenueditcommon_STAT_SRCS HEADER kmenuedit_debug.h IDENTIFIER KMENUEDIT_LOG CATEGORY_NAME org.kde.kmenuedit)
if(NOT WIN32 AND KHotKeysDBusInterface_FOUND)
qt5_add_dbus_interface(
kmenueditcommon_STAT_SRCS
......@@ -87,3 +90,5 @@ install( FILES kmenueditui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/kmenuedit
ecm_install_icons( ICONS 16-apps-kmenuedit.png 22-apps-kmenuedit.png 32-apps-kmenuedit.png 48-apps-kmenuedit.png DESTINATION ${KDE_INSTALL_ICONDIR} THEME hicolor )
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
install( FILES kmenuedit.categories DESTINATION ${KDE_INSTALL_CONFDIR} )
......@@ -21,11 +21,11 @@
#include "khotkeys.h"
#include "khotkeys_interface.h"
#include <QDebug>
#include "kmenuedit_debug.h"
#include <KLocalizedString>
#include <KMessageBox>
#include <QDebug>
#include "kmenuedit_debug.h"
static bool khotkeys_present = false;
static bool khotkeys_inited = false;
......@@ -46,7 +46,7 @@ bool KHotKeys::init()
if (!khotkeysInterface->isValid()) {
QDBusError err = khotkeysInterface->lastError();
if (err.isValid()) {
qCritical() << err.name() << ":" << err.message();
qCCritical(KMENUEDIT_LOG) << err.name() << ":" << err.message();
}
KMessageBox::error(
NULL,
......@@ -55,7 +55,7 @@ bool KHotKeys::init()
khotkeys_present = khotkeysInterface->isValid();
qDebug() << khotkeys_present;
qCDebug(KMENUEDIT_LOG) << khotkeys_present;
return true;
}
......@@ -70,13 +70,13 @@ void KHotKeys::cleanup()
bool KHotKeys::present()
{
qDebug() << khotkeys_inited;
qCDebug(KMENUEDIT_LOG) << khotkeys_inited;
if (!khotkeys_inited) {
init();
}
qDebug() << khotkeys_present;
qCDebug(KMENUEDIT_LOG) << khotkeys_present;
return khotkeys_present;
}
......@@ -90,15 +90,15 @@ QString KHotKeys::getMenuEntryShortcut(const QString &entry_P)
if (!khotkeys_present || !khotkeysInterface->isValid()) {
return QLatin1String("");
}
qDebug() << khotkeys_inited;
qDebug() << khotkeys_present;
qDebug() << entry_P;
qCDebug(KMENUEDIT_LOG) << khotkeys_inited;
qCDebug(KMENUEDIT_LOG) << khotkeys_present;
qCDebug(KMENUEDIT_LOG) << entry_P;
QDBusReply<QString> reply = khotkeysInterface->get_menuentry_shortcut(entry_P);
if (!reply.isValid()) {
qCritical() << reply.error();
qCCritical(KMENUEDIT_LOG) << reply.error();
return QLatin1String("");
} else {
qDebug() << reply;
qCDebug(KMENUEDIT_LOG) << reply;
return reply;
}
}
......@@ -114,20 +114,20 @@ QString KHotKeys::changeMenuEntryShortcut(
return QLatin1String("");
}
qDebug() << khotkeys_inited;
qDebug() << khotkeys_present;
qDebug() << entry_P;
qDebug() << shortcut_P;
qCDebug(KMENUEDIT_LOG) << khotkeys_inited;
qCDebug(KMENUEDIT_LOG) << khotkeys_present;
qCDebug(KMENUEDIT_LOG) << entry_P;
qCDebug(KMENUEDIT_LOG) << shortcut_P;
QDBusReply<QString> reply = khotkeysInterface->register_menuentry_shortcut(
entry_P,
shortcut_P);
if (!reply.isValid()) {
qCritical() << reply.error();
qCCritical(KMENUEDIT_LOG) << reply.error();
return QLatin1String("");
} else {
qDebug() << reply;
qCDebug(KMENUEDIT_LOG) << reply;
return reply;
}
}
org.kde.kmenuedit kmenuedit IDENTIFIER [KMENUEDIT_LOG]
......@@ -23,7 +23,7 @@
#include <QRegExp>
#include <QFileInfo>
#include <QDebug>
#include "kmenuedit_debug.h"
#include <KGlobal>
#include <KLocalizedString>
#include <KStandardDirs>
......@@ -66,7 +66,7 @@ bool MenuFile::load()
QFile file(m_fileName);
if (!file.open(QIODevice::ReadOnly)) {
if (file.exists()) {
qWarning() << "Could not read " << m_fileName;
qCWarning(KMENUEDIT_LOG) << "Could not read " << m_fileName;
}
create();
return false;
......@@ -76,7 +76,7 @@ bool MenuFile::load()
int errorRow;
int errorCol;
if (!m_doc.setContent(&file, &errorMsg, &errorRow, &errorCol)) {
qWarning() << "Parse error in " << m_fileName << ", line " << errorRow << ", col " << errorCol << ": " << errorMsg;
qCWarning(KMENUEDIT_LOG) << "Parse error in " << m_fileName << ", line " << errorRow << ", col " << errorCol << ": " << errorMsg;
file.close();
create();
return false;
......@@ -98,7 +98,7 @@ bool MenuFile::save()
QFile file(m_fileName);
if (!file.open(QIODevice::WriteOnly)) {
qWarning() << "Could not write " << m_fileName;
qCWarning(KMENUEDIT_LOG) << "Could not write " << m_fileName;
m_error = i18n("Could not write to %1", m_fileName);
return false;
}
......@@ -110,7 +110,7 @@ bool MenuFile::save()
file.close();
if (file.error() != QFile::NoError) {
qWarning() << "Could not close " << m_fileName;
qCWarning(KMENUEDIT_LOG) << "Could not close " << m_fileName;
m_error = i18n("Could not write to %1", m_fileName);
return false;
}
......
......@@ -39,7 +39,7 @@
#include <QAction>
#include <KActionCollection>
#include <KBuildSycocaProgressDialog>
#include <QDebug>
#include "kmenuedit_debug.h"
#include <KDesktopFile>
#include <KGlobal>
#include <KIconLoader>
......@@ -451,7 +451,7 @@ TreeItem *TreeView::createTreeItem(TreeItem *parent, QTreeWidgetItem *after, Men
name = entryInfo->caption;
}
////qDebug() << parent << after << name;
////qCDebug(KMENUEDIT_LOG) << parent << after << name;
item->setMenuEntryInfo(entryInfo);
item->setName(name);
item->setIcon(0, QIcon::fromTheme(entryInfo->icon));
......@@ -900,7 +900,7 @@ bool TreeView::dropMimeData(QTreeWidgetItem *item, int index, const QMimeData *d
QString folder = parentItem ? parentItem->directory() : QStringLiteral("/");
MenuFolderInfo *parentFolderInfo = parentItem ? parentItem->folderInfo() : m_rootFolder;
//qDebug() << "think we're dropping on" << (parentItem ? parentItem->text(0) : "Top Level") << index;
//qCDebug(KMENUEDIT_LOG) << "think we're dropping on" << (parentItem ? parentItem->text(0) : "Top Level") << index;
if (!data->hasFormat(QLatin1String(s_internalMimeType))) {
// External drop
......@@ -964,7 +964,7 @@ bool TreeView::dropMimeData(QTreeWidgetItem *item, int index, const QMimeData *d
return false; // Nothing to do
}
////qDebug() << "an internal drag of" << dragItem->text(0) << (parentItem ? parentItem->text(0) : "Top level");
////qCDebug(KMENUEDIT_LOG) << "an internal drag of" << dragItem->text(0) << (parentItem ? parentItem->text(0) : "Top level");
if (dragItem->isDirectory()) {
MenuFolderInfo *folderInfo = dragItem->folderInfo();
if (action == Qt::CopyAction) {
......@@ -993,7 +993,7 @@ bool TreeView::dropMimeData(QTreeWidgetItem *item, int index, const QMimeData *d
// Add file to menu
//m_menuFile->moveMenu(oldFolder, folder + newFolder);
//qDebug() << "moving" << dragItem->text(0) << "to" << folder + newFolder;
//qCDebug(KMENUEDIT_LOG) << "moving" << dragItem->text(0) << "to" << folder + newFolder;
m_menuFile->pushAction(MenuFile::MOVE_MENU, oldFolder, folder + newFolder);
// Make sure caption is unique
......@@ -1079,7 +1079,7 @@ bool TreeView::dropMimeData(QTreeWidgetItem *item, int index, const QMimeData *d
setCurrentItem(newItem);
}
//qDebug() << "setting the layout to be dirty at" << parentItem;
//qCDebug(KMENUEDIT_LOG) << "setting the layout to be dirty at" << parentItem;
setLayoutDirty(parentItem);
return true;
}
......@@ -1865,16 +1865,16 @@ void TreeView::restoreMenuSystem()
QString kmenueditfile = KStandardDirs::locateLocal("xdgconf-menu", QStringLiteral("applications-kmenuedit.menu"));
if (QFile::exists(kmenueditfile)) {
if (!QFile::remove(kmenueditfile)) {
qWarning()<<"Could not delete "<<kmenueditfile;
qCWarning(KMENUEDIT_LOG)<<"Could not delete "<<kmenueditfile;
}
}
QString xdgdir = KGlobal::dirs()->KStandardDirs::localxdgdatadir();
if (!KIO::NetAccess::del(QUrl::fromLocalFile(xdgdir + QStringLiteral("/applications")), this)) {
qWarning()<<"Could not delete dir :"<<(xdgdir+ QStringLiteral("/applications"));
qCWarning(KMENUEDIT_LOG)<<"Could not delete dir :"<<(xdgdir+ QStringLiteral("/applications"));
}
if (!KIO::NetAccess::del(QUrl::fromLocalFile(xdgdir + QStringLiteral("/desktop-directories")), this)) {
qWarning()<<"Could not delete dir :"<<(xdgdir + QStringLiteral("/desktop-directories"));
qCWarning(KMENUEDIT_LOG)<<"Could not delete dir :"<<(xdgdir + QStringLiteral("/desktop-directories"));
}
KBuildSycocaProgressDialog::rebuildKSycoca(this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment