Commit 46cfc108 authored by Robert Knight's avatar Robert Knight

* Replace all usage of qDebug() with kDebug(), since kDebug() provides information about 
  which part of the code the message came from and allows filtering of output
  using kdebugdialog
* Remove explicit creation of singleton classes SessionManager,ColorSchemeManager and
  KeyboardTranslatorManager and automate it with K_GLOBAL_STATIC.
  This ensures that the singleton destructors are called appropriately by KPart clients
  when they unload the libkonsolepart library.


svn path=/trunk/KDE/kdebase/apps/konsole/; revision=754334
parent 26b54917
......@@ -64,15 +64,6 @@ void Application::init()
_sessionList = 0;
_backgroundInstance = 0;
// create session manager
SessionManager::setInstance( new SessionManager() );
// create color scheme manager
ColorSchemeManager::setInstance( new ColorSchemeManager() );
// new keyboard translator manager
KeyboardTranslatorManager::setInstance( new KeyboardTranslatorManager() );
// check for compositing functionality
TerminalDisplay::setTransparencyEnabled( KWindowSystem::compositingActive() );
}
......@@ -267,13 +258,6 @@ void Application::toggleBackgroundInstance()
Application::~Application()
{
delete SessionManager::instance();
delete ColorSchemeManager::instance();
delete KeyboardTranslatorManager::instance();
SessionManager::setInstance(0);
ColorSchemeManager::setInstance(0);
KeyboardTranslatorManager::setInstance(0);
}
void Application::detachView(Session* session)
......
......@@ -157,7 +157,7 @@ QList<QPair<QString,QString> > BookmarkHandler::currentBookmarkList() const
void BookmarkHandler::setViews(const QList<ViewProperties*>& views)
{
//qDebug() << "BookmarkHandler - View list changed.";
//kDebug() << "BookmarkHandler - View list changed.";
m_views = views;
}
QList<ViewProperties*> BookmarkHandler::views() const
......
......@@ -112,8 +112,6 @@ const char* ColorScheme::translatedColorNames[TABLE_COLORS] =
I18N_NOOP("Color 8 (Intense)")
};
ColorSchemeManager* ColorSchemeManager::_instance = 0;
ColorScheme::ColorScheme()
{
_table = 0;
......@@ -178,9 +176,9 @@ ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const
ColorEntry entry = colorTable()[index];
// qDebug() << "Old color: " << entry.color;
// kDebug() << "Old color: " << entry.color;
// qDebug() << "Random seed: " << randomSeed << "random table: " <<
// kDebug() << "Random seed: " << randomSeed << "random table: " <<
// _randomTable << "isnull: " << ((_randomTable) ? _randomTable[index].isNull() : true);
if ( randomSeed != 0 &&
......@@ -195,18 +193,18 @@ ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const
int valueDifference = range.value ? (qrand() % range.value) - range.value/2 : 0;
QColor& color = entry.color;
// qDebug() << "Standard hue" << color.hue() << "saturation" << color.saturation() << "value" << color.value();
// kDebug() << "Standard hue" << color.hue() << "saturation" << color.saturation() << "value" << color.value();
int newHue = qAbs( (color.hue() + hueDifference) % MAX_HUE );
int newValue = qMin( qAbs(color.value() + valueDifference) , 255 );
int newSaturation = qMin( qAbs(color.saturation() + saturationDifference) , 255 );
// qDebug() << "New hue: " << newHue << "New sat:" << newSaturation <<
// kDebug() << "New hue: " << newHue << "New sat:" << newSaturation <<
// "New value:" << newValue;
color.setHsv(newHue,newSaturation,newValue);
}
// qDebug() << "New color: " << entry.color;
// kDebug() << "New color: " << entry.color;
return entry;
}
......@@ -532,9 +530,9 @@ void ColorSchemeManager::loadAllColorSchemes()
}
// if ( success > 0 )
// qDebug() << "succeeded to load " << success << " color schemes.";
// kDebug() << "succeeded to load " << success << " color schemes.";
if ( failed > 0 )
qDebug() << "failed to load " << failed << " color schemes.";
kDebug() << "failed to load " << failed << " color schemes.";
_haveLoadedAll = true;
}
......@@ -549,7 +547,7 @@ QList<const ColorScheme*> ColorSchemeManager::allColorSchemes()
}
bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)
{
//qDebug() << "loading KDE 3 format color scheme from " << filePath;
//kDebug() << "loading KDE 3 format color scheme from " << filePath;
QFile file(filePath);
if (!filePath.endsWith(".schema") || !file.open(QIODevice::ReadOnly))
......@@ -562,19 +560,19 @@ bool ColorSchemeManager::loadKDE3ColorScheme(const QString& filePath)
Q_ASSERT( !scheme->name().isEmpty() );
//qDebug() << "found KDE 3 format color scheme - " << scheme->name();
//kDebug() << "found KDE 3 format color scheme - " << scheme->name();
QFileInfo info(filePath);
if ( !_colorSchemes.contains(info.baseName()) )
{
//qDebug() << "added color scheme - " << info.baseName();
//kDebug() << "added color scheme - " << info.baseName();
_colorSchemes.insert(scheme->name(),scheme);
}
else
{
qDebug() << "color scheme with name" << scheme->name() << "has already been" <<
kDebug() << "color scheme with name" << scheme->name() << "has already been" <<
"found, ignoring.";
delete scheme;
}
......@@ -616,7 +614,7 @@ bool ColorSchemeManager::loadColorScheme(const QString& filePath)
}
else
{
qDebug() << "color scheme with name" << scheme->name() << "has already been" <<
kDebug() << "color scheme with name" << scheme->name() << "has already been" <<
"found, ignoring.";
delete scheme;
......@@ -672,7 +670,7 @@ QString ColorSchemeManager::findColorSchemePath(const QString& name) const
}
const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
{
//qDebug() << "looking for color scheme - " << name;
//kDebug() << "looking for color scheme - " << name;
if ( name.isEmpty() )
return defaultColorScheme();
......@@ -693,16 +691,13 @@ const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
return findColorScheme(name);
}
qDebug() << "Could not find color scheme - " << name;
kDebug() << "Could not find color scheme - " << name;
return 0;
}
}
K_GLOBAL_STATIC( ColorSchemeManager , theColorSchemeManager )
ColorSchemeManager* ColorSchemeManager::instance()
{
return _instance;
}
void ColorSchemeManager::setInstance(ColorSchemeManager* instance)
{
_instance = instance;
return theColorSchemeManager;
}
......@@ -301,8 +301,6 @@ public:
*/
QList<const ColorScheme*> allColorSchemes();
/** Sets the global color scheme manager instance. */
static void setInstance(ColorSchemeManager* instance);
/** Returns the global color scheme manager instance. */
static ColorSchemeManager* instance();
......@@ -327,7 +325,6 @@ private:
bool _haveLoadedAll;
static const ColorScheme _defaultColorScheme;
static ColorSchemeManager* _instance;
};
}
......
......@@ -92,7 +92,7 @@ ColorSchemeEditor::ColorSchemeEditor(QWidget* parent)
connect( _ui->colorTable , SIGNAL(itemClicked(QTableWidgetItem*)) , this ,
SLOT(editColorItem(QTableWidgetItem*)) );
qDebug() << "Color scheme editor - have compositing = " << KWindowSystem::compositingActive();
kDebug() << "Color scheme editor - have compositing = " << KWindowSystem::compositingActive();
// warning label when transparency is not available
if ( KWindowSystem::compositingActive() )
......@@ -147,7 +147,7 @@ void ColorSchemeEditor::setTransparencyPercentLabel(int percent)
qreal opacity = ( 100.0 - percent ) / 100.0;
_colors->setOpacity(opacity);
//qDebug() << "set opacity to:" << opacity;
//kDebug() << "set opacity to:" << opacity;
}
void ColorSchemeEditor::setup(const ColorScheme* scheme)
{
......@@ -163,7 +163,7 @@ void ColorSchemeEditor::setup(const ColorScheme* scheme)
setupColorTable(_colors);
// setup transparency slider
//qDebug() << "read opacity: " << _colors->opacity();
//kDebug() << "read opacity: " << _colors->opacity();
const int transparencyPercent = (int) ( (1-_colors->opacity())*100 );
_ui->transparencySlider->setValue(transparencyPercent);
......
......@@ -25,7 +25,7 @@
#include <QtGui/QBrush>
#include <QtGui/QPainter>
#include <QtGui/QStandardItem>
#include <QtCore/QDebug>
#include <KDebug>
#include <QtCore/QTextCodec>
#include <QtGui/QTextEdit>
#include <QtGui/QLinearGradient>
......@@ -36,6 +36,7 @@
// KDE
#include <kcodecaction.h>
#include <KDebug>
#include <KFontDialog>
#include <KIcon>
#include <KIconDialog>
......@@ -673,7 +674,7 @@ void EditProfileDialog::colorSchemeSelected()
QAbstractItemModel* model = _ui->colorSchemeList->model();
const ColorScheme* colors = model->data(selected.first(),Qt::UserRole+1).value<const ColorScheme*>();
qDebug() << "Setting temp profile color to" << colors->name();
kDebug() << "Setting temp profile color to" << colors->name();
previewColorScheme(selected.first());
_tempProfile->setProperty(Profile::ColorScheme,colors->name());
......
......@@ -426,7 +426,7 @@ char Emulation::getErase() const
void Emulation::setImageSize(int lines, int columns)
{
//qDebug() << "Resizing image to: " << lines << "by" << columns << QTime::currentTime().msec();
//kDebug() << "Resizing image to: " << lines << "by" << columns << QTime::currentTime().msec();
Q_ASSERT( lines > 0 );
Q_ASSERT( columns > 0 );
......
......@@ -28,7 +28,7 @@
#include <QtGui/QApplication>
#include <QtGui/QClipboard>
#include <QtCore/QString>
#include <QtCore/QDebug>
#include <KDebug>
#include <QtCore/QSharedData>
#include <QtCore/QFile>
......@@ -209,7 +209,7 @@ void Filter::getLineColumn(int position , int& startLine , int& startColumn)
for (int i = 0 ; i < _linePositions->count() ; i++)
{
//qDebug() << "line position at " << i << " = " << _linePositions[i];
//kDebug() << "line position at " << i << " = " << _linePositions[i];
int nextLine = 0;
if ( i == _linePositions->count()-1 )
......@@ -221,7 +221,7 @@ void Filter::getLineColumn(int position , int& startLine , int& startColumn)
nextLine = _linePositions->value(i+1);
}
// qDebug() << "pos - " << position << " line pos(" << i<< ") " << _linePositions->value(i) <<
// kDebug() << "pos - " << position << " line pos(" << i<< ") " << _linePositions->value(i) <<
// " next = " << nextLine << " buffer len = " << _buffer->length();
if ( _linePositions->value(i) <= position && position < nextLine )
......@@ -386,13 +386,13 @@ void RegExpFilter::process()
int endColumn = 0;
//qDebug() << "pos from " << pos << " to " << pos + _searchText.matchedLength();
//kDebug() << "pos from " << pos << " to " << pos + _searchText.matchedLength();
getLineColumn(pos,startLine,startColumn);
getLineColumn(pos + _searchText.matchedLength(),endLine,endColumn);
//qDebug() << "start " << startLine << " / " << startColumn;
//qDebug() << "end " << endLine << " / " << endColumn;
//kDebug() << "start " << startLine << " / " << startColumn;
//kDebug() << "end " << endLine << " / " << endColumn;
RegExpFilter::HotSpot* spot = newHotSpot(startLine,startColumn,
endLine,endColumn);
......@@ -460,7 +460,7 @@ void UrlFilter::HotSpot::activate(QObject* object)
if ( actionName == "copy-action" )
{
//qDebug() << "Copying url to clipboard:" << url;
//kDebug() << "Copying url to clipboard:" << url;
QApplication::clipboard()->setText(url);
return;
......
......@@ -345,7 +345,7 @@ bool HistoryScrollBuffer::isWrappedLine(int lineNumber)
if (lineNumber < _usedLines)
{
//qDebug() << "Line" << lineNumber << "wrapped is" << _wrappedLine[bufferIndex(lineNumber)];
//kDebug() << "Line" << lineNumber << "wrapped is" << _wrappedLine[bufferIndex(lineNumber)];
return _wrappedLine[bufferIndex(lineNumber)];
}
else
......@@ -366,9 +366,9 @@ void HistoryScrollBuffer::getCells(int lineNumber, int startColumn, int count, C
const HistoryLine& line = _historyBuffer[bufferIndex(lineNumber)];
//qDebug() << "startCol " << startColumn;
//qDebug() << "line.size() " << line.size();
//qDebug() << "count " << count;
//kDebug() << "startCol " << startColumn;
//kDebug() << "line.size() " << line.size();
//kDebug() << "count " << count;
Q_ASSERT( startColumn <= line.size() - count );
......
......@@ -137,7 +137,7 @@ bool KeyBindingEditor::eventFilter( QObject* watched , QEvent* event )
_ui->testAreaInputEdit->setText(keyEvent->text());
_ui->testAreaOutputEdit->setText(keyEvent->text());
}
//qDebug() << "Entry: " << entry.resultToString();
//kDebug() << "Entry: " << entry.resultToString();
keyEvent->accept();
return true;
......@@ -187,7 +187,7 @@ void KeyBindingEditor::bindingTableItemChanged(QTableWidgetItem* item)
KeyboardTranslator::Entry entry = KeyboardTranslatorReader::createEntry(condition,result);
qDebug() << "Created entry: " << entry.conditionToString() << " , " << entry.resultToString();
kDebug() << "Created entry: " << entry.conditionToString() << " , " << entry.resultToString();
_translator->replaceEntry(existing,entry);
......@@ -206,7 +206,7 @@ void KeyBindingEditor::setupKeyBindingTable(const KeyboardTranslator* translator
QList<KeyboardTranslator::Entry> entries = translator->entries();
_ui->keyBindingTable->setRowCount(entries.count());
//qDebug() << "Keyboard translator has" << entries.count() << "entries.";
//kDebug() << "Keyboard translator has" << entries.count() << "entries.";
for ( int row = 0 ; row < entries.count() ; row++ )
{
......
......@@ -28,13 +28,14 @@
// Qt
#include <QtCore/QBuffer>
#include <QtCore/QDebug>
#include <KDebug>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QTextStream>
#include <QtGui/QKeySequence>
// KDE
#include <KDebug>
#include <KLocale>
#include <KStandardDirs>
......@@ -45,8 +46,6 @@ const char* KeyboardTranslatorManager::defaultTranslatorText =
#include <DefaultTranslatorText.h>
;
KeyboardTranslatorManager* KeyboardTranslatorManager::_instance = 0;
KeyboardTranslatorManager::KeyboardTranslatorManager()
: _haveLoadedAll(false)
{
......@@ -105,7 +104,7 @@ bool KeyboardTranslatorManager::saveTranslator(const KeyboardTranslator* transla
const QString path = KGlobal::dirs()->saveLocation("data","konsole/")+translator->name()
+".keytab";
qDebug() << "Saving translator to" << path;
kDebug() << "Saving translator to" << path;
QFile destination(path);
......@@ -144,7 +143,7 @@ KeyboardTranslator* KeyboardTranslatorManager::loadTranslator(const QString& nam
const KeyboardTranslator* KeyboardTranslatorManager::defaultTranslator()
{
qDebug() << "Loading default translator from text" << defaultTranslatorText;
kDebug() << "Loading default translator from text" << defaultTranslatorText;
QBuffer textBuffer;
textBuffer.setData(defaultTranslatorText,strlen(defaultTranslatorText));
return loadTranslator(&textBuffer,"fallback");
......@@ -363,7 +362,7 @@ bool KeyboardTranslatorReader::decodeSequence(const QString& text,
else if ( parseAsKeyCode(buffer,itemKeyCode) )
keyCode = itemKeyCode;
else
qDebug() << "Unable to parse key binding item:" << buffer;
kDebug() << "Unable to parse key binding item:" << buffer;
buffer.clear();
}
......@@ -427,7 +426,7 @@ bool KeyboardTranslatorReader::parseAsKeyCode(const QString& item , int& keyCode
if ( sequence.count() > 1 )
{
qDebug() << "Unhandled key codes in sequence: " << item;
kDebug() << "Unhandled key codes in sequence: " << item;
}
}
// additional cases implemented for backwards compatibility with KDE 3
......@@ -873,11 +872,8 @@ bool KeyboardTranslatorManager::deleteTranslator(const QString& name)
return false;
}
}
void KeyboardTranslatorManager::setInstance(KeyboardTranslatorManager* instance)
{
_instance = instance;
}
K_GLOBAL_STATIC( KeyboardTranslatorManager , theKeyboardTranslatorManager )
KeyboardTranslatorManager* KeyboardTranslatorManager::instance()
{
return _instance;
return theKeyboardTranslatorManager;
}
......@@ -484,9 +484,6 @@ public:
*/
QList<QString> allTranslators();
/** Sets the global KeyboardTranslatorManager instance. */
static void setInstance(KeyboardTranslatorManager* instance);
/** Returns the global KeyboardTranslatorManager instance. */
static KeyboardTranslatorManager* instance();
......@@ -503,11 +500,7 @@ private:
QHash<QString,KeyboardTranslator*> _translators; // maps translator-name -> KeyboardTranslator
// instance
bool _haveLoadedAll;
static KeyboardTranslatorManager* _instance;
};
inline int KeyboardTranslator::Entry::keyCode() const { return _keyCode; }
......
......@@ -109,7 +109,7 @@ void ManageProfilesDialog::itemDataChanged(QStandardItem* item)
{
QKeySequence sequence = QKeySequence::fromString(item->text());
qDebug() << "New key sequence: " << item->text();
kDebug() << "New key sequence: " << item->text();
SessionManager::instance()->setShortcut(item->data(ShortcutRole).value<QString>(),
sequence);
......
......@@ -70,14 +70,6 @@ Part::Part(QWidget* parentWidget , QObject* parent)
,_pluggedController(0)
,_manageProfilesAction(0)
{
// setup global managers
if ( SessionManager::instance() == 0 )
SessionManager::setInstance( new SessionManager() );
if ( ColorSchemeManager::instance() == 0 )
ColorSchemeManager::setInstance( new ColorSchemeManager() );
if ( KeyboardTranslatorManager::instance() == 0 )
KeyboardTranslatorManager::setInstance( new KeyboardTranslatorManager() );
// setup global actions
createGlobalActions();
......
......@@ -26,7 +26,7 @@
#include <arpa/inet.h>
// Qt
#include <QtCore/QDebug>
#include <KDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QRegExp>
......@@ -484,9 +484,9 @@ SSHProcessInfo::SSHProcessInfo(const ProcessInfo& process)
if ( !ok || name != "ssh" )
{
if ( !ok )
qDebug() << "Could not read process info";
kDebug() << "Could not read process info";
else
qDebug() << "Process is not a SSH process";
kDebug() << "Process is not a SSH process";
return;
}
......@@ -538,7 +538,7 @@ SSHProcessInfo::SSHProcessInfo(const ProcessInfo& process)
if ( _host.isEmpty() )
{
// found username and host argument
qDebug() << "[username] and host: " << args[i];
kDebug() << "[username] and host: " << args[i];
// check to see if only a hostname is specified, or whether
// both a username and host are specified ( in which case they
......@@ -551,14 +551,14 @@ SSHProcessInfo::SSHProcessInfo(const ProcessInfo& process)
_user = args[i].left(separatorPosition);
_host = args[i].mid(separatorPosition+1);
qDebug() << "found user: " << _user;
qDebug() << "found host: " << _host;
kDebug() << "found user: " << _user;
kDebug() << "found host: " << _host;
}
else
{
// just the host specified
_host = args[i];
qDebug() << "found only host: " << _host;
kDebug() << "found only host: " << _host;
}
}
else
......@@ -566,14 +566,14 @@ SSHProcessInfo::SSHProcessInfo(const ProcessInfo& process)
// host has already been found, this must be the command argument
_command = args[i];
qDebug() << "found command: " << _command;
kDebug() << "found command: " << _command;
}
}
}
else
{
qDebug() << "Could not read arguments";
kDebug() << "Could not read arguments";
return;
}
......
......@@ -64,15 +64,15 @@ namespace Konsole
* bool ok;
* QString value = info->name(&ok);
*
* if ( ok ) qDebug() << "process name - " << name;
* if ( ok ) kDebug() << "process name - " << name;
*
* int parentPid = info->parentPid(&ok);
*
* if ( ok ) qDebug() << "parent process - " << parentPid;
* if ( ok ) kDebug() << "parent process - " << parentPid;
*
* int foregroundPid = info->foregroundColororegroundPid(&ok);
*
* if ( ok ) qDebug() << "foreground process - " << foregroundPid;
* if ( ok ) kDebug() << "foreground process - " << foregroundPid;
* }
* @endcode
*/
......
......@@ -345,7 +345,7 @@ QStringList KDE4ProfileReader::findProfiles()
}
bool KDE4ProfileReader::readProfile(const QString& path , Profile* profile , QString& parentProfile)
{
//qDebug() << "KDE 4 Profile Reader:" << path;
//kDebug() << "KDE 4 Profile Reader:" << path;
KConfig config(path,KConfig::NoGlobals);
......@@ -450,7 +450,7 @@ bool KDE3ProfileReader::readProfile(const QString& path , Profile* profile , QSt
if ( config->hasKey("Name") )
profile->setProperty(Profile::Name,config->readEntry("Name"));
qDebug() << "reading KDE 3 profile " << profile->name();
kDebug() << "reading KDE 3 profile " << profile->name();
if ( config->hasKey("Icon") )
profile->setProperty(Profile::Icon,config->readEntry("Icon"));
......@@ -513,7 +513,7 @@ QHash<Profile::Property,QVariant> ProfileCommandParser::parse(const QString& inp
regExp.capturedTexts()[1]);
const QString value = regExp.capturedTexts()[2];
qDebug() << "property:" << property << "value:" << value;
kDebug() << "property:" << property << "value:" << value;
changes.insert(property,value);
}
......
......@@ -23,7 +23,7 @@
// Qt
#include <QtGui/QAction>
#include <QtGui/QActionGroup>
#include <QtCore/QDebug>
#include <KDebug>
// KDE
#include <KIcon>
......
......@@ -21,7 +21,7 @@
#include "ProfileListWidget.h"
// Qt
#include <QtCore/QDebug>
#include <KDebug>
#include <QtGui/QDrag>
#include <QtGui/QKeyEvent>
#include <QtCore/QMimeData>
......@@ -45,7 +45,7 @@ ProfileListWidget::ProfileListWidget(QWidget* parent)
void ProfileListWidget::startDrag(Qt::DropActions /*supportedActions*/)
{
qDebug() << "drag and drop started in session list widget";
kDebug() << "drag and drop started in session list widget";
QMimeData* mimeData = new QMimeData();
......
......@@ -111,7 +111,7 @@ char Pty::erase() const
{
if (pty()->masterFd() >= 0)
{
qDebug() << "Getting erase char";
kDebug() << "Getting erase char";
struct ::termios ttyAttributes;
pty()->tcGetAttr(&ttyAttributes);
return ttyAttributes.c_cc[VERASE];
......@@ -135,7 +135,7 @@ void Pty::addEnvironmentVariables(const QStringList& environment)
QString variable = pair.left(pos);
QString value = pair.mid(pos+1);
//qDebug() << "Setting environment pair" << variable <<
//kDebug() << "Setting environment pair" << variable <<
// " set to " << value;
setEnvironment(variable,value);
......
......@@ -21,7 +21,7 @@
#include "RemoteConnectionDialog.h"
// Qt
#include <QtCore/QDebug>
#include <KDebug>
// KDE
#include <KLocale>
......@@ -76,7 +76,7 @@ QString RemoteConnectionDialog::sessionKey() const
*/
//QString key = manager->addSessionType( customSession );
//qDebug() << "session key = " << key;
//kDebug() << "session key = " << key;
return QString();
//return key;
......
......@@ -845,7 +845,7 @@ void Screen::resetDroppedLines()
}
void Screen::resetScrolledLines()
{
//qDebug() << "scrolled lines reset";
//kDebug() << "scrolled lines reset";
_scrolledLines = 0;
}
......@@ -895,7 +895,7 @@ void Screen::scrollDown(int n)
void Screen::scrollDown(int from, int n)
{