<commit_before>/* This file is part of the KDE project
   Copyright (C) 2001 <NAME> <<EMAIL>>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.
 
   This library 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
   Library General Public License for more details.
 
   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#include "kateappadaptor.h"

#include "kateapp.h"
#include "katesession.h"
#include "katedocmanager.h"
#include "katemainwindow.h"
#include "kateappadaptor.moc"

#include "katedebug.h"
#include <KWindowSystem>

KateAppAdaptor::KateAppAdaptor (KateApp *app)
    : QDBusAbstractAdaptor( app )
    , m_app (app)
{}

void KateAppAdaptor::activate ()
{
  KateMainWindow *win = m_app->activeMainWindow();
  if (!win)
    return;

  win->show();
  win->activateWindow();
  win->raise();
  
#ifdef Q_WS_X11
  KWindowSystem::forceActiveWindow (win->winId ());
  KWindowSystem::raiseWindow (win->winId ());
#endif
}

bool KateAppAdaptor::openUrl (QString url, QString encoding)
{
  return m_app->openUrl (QUrl(url), encoding, false);
}

bool KateAppAdaptor::openUrl (QString url, QString encoding, bool isTempFile)
{
  qCDebug(LOG_KATE) << "openURL";

  return m_app->openUrl (QUrl(url), encoding, isTempFile);
}

//-----------
QString KateAppAdaptor::tokenOpenUrl (QString url, QString encoding)
{
  KTextEditor::Document *doc=m_app->openDocUrl (QUrl(url), encoding, false);
  if (!doc) return QString("ERROR");
  return QString("%1").arg((qptrdiff)doc);
}

QString KateAppAdaptor::tokenOpenUrl (QString url, QString encoding, bool isTempFile)
{
  qCDebug(LOG_KATE) << "openURL";
  KTextEditor::Document *doc=m_app->openDocUrl (QUrl(url), encoding, isTempFile);
  if (!doc) return QString("ERROR");
  return QString("%1").arg((qptrdiff)doc);
}<commit_msg>set urgent flag on window activated by dbus call<commit_after>/* This file is part of the KDE project
   Copyright (C) 2001 <NAME> <<EMAIL>>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.
 
   This library 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
   Library General Public License for more details.
 
   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#include "kateappadaptor.h"

#include "kateapp.h"
#include "katesession.h"
#include "katedocmanager.h"
#include "katemainwindow.h"
#include "kateappadaptor.moc"

#include "katedebug.h"
#include <KWindowSystem>

KateAppAdaptor::KateAppAdaptor (KateApp *app)
    : QDBusAbstractAdaptor( app )
    , m_app (app)
{}

void KateAppAdaptor::activate ()
{
  KateMainWindow *win = m_app->activeMainWindow();
  if (!win)
    return;

  win->show();
  win->activateWindow();
  win->raise();

  KWindowSystem::forceActiveWindow(win->winId());
  KWindowSystem::raiseWindow(win->winId());
  KWindowSystem::demandAttention(win->winId());
}

bool KateAppAdaptor::openUrl (QString url, QString encoding)
{
  return m_app->openUrl (QUrl(url), encoding, false);
}

bool KateAppAdaptor::openUrl (QString url, QString encoding, bool isTempFile)
{
  qCDebug(LOG_KATE) << "openURL";

  return m_app->openUrl (QUrl(url), encoding, isTempFile);
}

//-----------
QString KateAppAdaptor::tokenOpenUrl (QString url, QString encoding)
{
  KTextEditor::Document *doc=m_app->openDocUrl (QUrl(url), encoding, false);
  if (!doc) return QString("ERROR");
  return QString("%1").arg((qptrdiff)doc);
}

QString KateAppAdaptor::tokenOpenUrl (QString url, QString encoding, bool isTempFile)
{
  qCDebug(LOG_KATE) << "openURL";
  KTextEditor::Document *doc=m_app->openDocUrl (QUrl(url), encoding, isTempFile);
  if (!doc) return QString("ERROR");
  return QString("%1").arg((qptrdiff)doc);
}
{'fraction_non_alphanumeric': 0.12006145741878842, 'fraction_numerical': 0.008340649692712906, 'mean_word_length': 4.724874371859296, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4303454', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1447, 'n_words': 460}