Commit 46331c21 authored by Martin Koller's avatar Martin Koller

mroe KF5 port

parent 01aa6534
......@@ -33,7 +33,6 @@
#include <kfiledialog.h>
#include <kinputdialog.h>
#include <kcomponentdata.h>
#include <klocale.h>
#include <knotification.h>
#include <kshell.h>
#include <kpropertiesdialog.h>
......@@ -48,6 +47,7 @@
#include <kactioncollection.h>
#include <ktoggleaction.h>
#include <krecentfilesaction.h>
#include <KLocalizedString>
#include <repositoryinterface.h>
#include <KConfigGroup>
......@@ -86,6 +86,7 @@
using Cervisia::TagDialog;
#define TRANSLATION_DOMAIN "cervisia"
K_PLUGIN_FACTORY( CervisiaFactory, registerPlugin<CervisiaPart>(); )
K_EXPORT_PLUGIN( CervisiaFactory( "cervisiapart", "cervisia" ) )
......@@ -197,7 +198,7 @@ KConfig *CervisiaPart::config()
// destroyed
}
bool CervisiaPart::openUrl( const KUrl &u )
bool CervisiaPart::openUrl( const QUrl &u )
{
// right now, we are unfortunately not network-aware
if( !u.isLocalFile() )
......@@ -220,7 +221,7 @@ bool CervisiaPart::openUrl( const KUrl &u )
// make a deep copy as if we're called via KRecentFilesAction::urlSelected()
// KRecentFilesAction::addUrl() makes the URL invalid
const KUrl deepCopy(u);
const QUrl deepCopy(u);
return openSandbox(deepCopy);
}
......@@ -788,7 +789,7 @@ void CervisiaPart::slotOpenSandbox()
if (dirname.isEmpty())
return;
openSandbox(KUrl(dirname));
openSandbox(QUrl::fromLocalFile(dirname));
}
......@@ -1794,7 +1795,7 @@ void CervisiaPart::slotJobFinished()
}
bool CervisiaPart::openSandbox(const KUrl& url)
bool CervisiaPart::openSandbox(const QUrl& url)
{
// Do we have a cvs service?
if( !cvsService )
......@@ -1999,7 +2000,6 @@ void CervisiaPart::guiActivateEvent(KParts::GUIActivateEvent* event)
CervisiaBrowserExtension::CervisiaBrowserExtension( CervisiaPart *p )
: KParts::BrowserExtension( p )
{
KGlobal::locale()->insertCatalog("cervisia");
}
CervisiaBrowserExtension::~CervisiaBrowserExtension()
......
......@@ -69,7 +69,7 @@ public:
public slots:
// unused because we overwrite the default behaviour of openUrl()
virtual bool openFile() { return true; }
virtual bool openUrl( const KUrl & );
virtual bool openUrl( const QUrl & );
void openFile(QString filename);
void openFiles(const QStringList &filenames);
......@@ -152,7 +152,7 @@ private:
void readSettings();
void writeSettings();
bool openSandbox(const KUrl& url);
bool openSandbox(const QUrl& url);
void updateSandbox(const QString &extraopt = QString());
void addOrRemove(AddRemoveDialog::ActionType action);
void addOrRemoveWatch(WatchDialog::ActionType action);
......
......@@ -32,13 +32,13 @@
<entry name="ProtocolFont" type="Font">
</entry>
<entry name="AnnotateFont" type="Font">
<default code="true">KGlobalSettings::fixedFont()</default>
<default code="true">QFontDatabase::systemFont(QFontDatabase::FixedFont)</default>
</entry>
<entry name="DiffFont" type="Font">
<default code="true">KGlobalSettings::fixedFont()</default>
<default code="true">QFontDatabase::systemFont(QFontDatabase::FixedFont)</default>
</entry>
<entry name="ChangeLogFont" type="Font">
<default code="true">KGlobalSettings::fixedFont()</default>
<default code="true">QFontDatabase::systemFont(QFontDatabase::FixedFont)</default>
</entry>
</group>
<group name="General" >
......
......@@ -2,4 +2,4 @@ File=cervisiapart.kcfg
ClassName=CervisiaSettings
Singleton=true
Mutators=true
SourceIncludeFiles=kcolorscheme.h,kglobalsettings.h
SourceIncludeFiles=kcolorscheme.h,QFontDatabase
......@@ -22,18 +22,22 @@
#include "cervisiashell.h"
#include <kactioncollection.h>
#include <kapplication.h>
#include <kconfig.h>
#include <KSharedConfig>
#include <kedittoolbar.h>
#include <khelpmenu.h>
#include <klocale.h>
#include <kpluginfactory.h>
#include <kpluginloader.h>
#include <kmessagebox.h>
#include <kshortcutsdialog.h>
#include <kstandardaction.h>
#include <kstatusbar.h>
#include <kurl.h>
#include <KLocalizedString>
#include <KAboutData>
#include <KConfigGroup>
#include <QApplication>
#include <QAction>
CervisiaShell::CervisiaShell( const char *name )
......@@ -72,7 +76,7 @@ CervisiaShell::CervisiaShell( const char *name )
setAutoSaveSettings("MainWindow", true);
// if the session is restoring, we already read the settings
if( !kapp->isSessionRestored() )
if( !qApp->isSessionRestored() )
readSettings();
}
......@@ -103,7 +107,7 @@ void CervisiaShell::setupActions()
action->setWhatsThis( hint );
setHelpMenuEnabled(false);
(void) new KHelpMenu(this, componentData().aboutData(), false, actionCollection());
(void) new KHelpMenu(this, componentData(), false);
action = actionCollection()->action("help_contents");
hint = i18n("Invokes the KDE help system with the Cervisia documentation");
......@@ -130,11 +134,11 @@ void CervisiaShell::setupActions()
void CervisiaShell::openURL()
{
if( !m_lastOpenDir.isEmpty() )
m_part->openUrl( KUrl( m_lastOpenDir ) );
m_part->openUrl( QUrl::fromLocalFile( m_lastOpenDir ) );
}
void CervisiaShell::openURL(const KUrl& url)
void CervisiaShell::openURL(const QUrl& url)
{
m_part->openUrl(url);
}
......@@ -152,7 +156,8 @@ void CervisiaShell::slotConfigureKeys()
void CervisiaShell::slotConfigureToolBars()
{
saveMainWindowSettings( KGlobal::config()->group( autoSaveGroup() ) );
KConfigGroup cg(KSharedConfig::openConfig(), autoSaveGroup());
saveMainWindowSettings(cg);
KEditToolBar dlg( factory() );
connect(&dlg,SIGNAL(newToolbarConfig()),this,SLOT(slotNewToolbarConfig()));
dlg.exec();
......@@ -160,7 +165,8 @@ void CervisiaShell::slotConfigureToolBars()
void CervisiaShell::slotNewToolbarConfig()
{
applyMainWindowSettings( KGlobal::config()->group( autoSaveGroup() ) );
KConfigGroup cg(KSharedConfig::openConfig(), autoSaveGroup());
applyMainWindowSettings(cg);
}
void CervisiaShell::closeEvent(QCloseEvent *event)
......@@ -176,7 +182,7 @@ void CervisiaShell::readProperties(const KConfigGroup& config)
// if the session is restoring, make sure we open the URL
// since it's not handled by main()
if( kapp->isSessionRestored() )
if( qApp->isSessionRestored() )
openURL();
}
......@@ -196,7 +202,7 @@ void CervisiaShell::saveProperties(KConfigGroup & config)
void CervisiaShell::readSettings()
{
KConfigGroup cg( KGlobal::config(), "Session");
KConfigGroup cg(KSharedConfig::openConfig(), "Session");
readProperties(cg);
}
......@@ -204,7 +210,7 @@ void CervisiaShell::readSettings()
void CervisiaShell::writeSettings()
{
KConfigGroup cg( KGlobal::config(), "Session");
KConfigGroup cg(KSharedConfig::openConfig(), "Session");
saveProperties(cg);
}
......
......@@ -23,6 +23,7 @@
#define CERVISIASHELL_H
#include <kparts/mainwindow.h>
#include <kparts/readonlypart.h>
......@@ -40,7 +41,7 @@ public:
public slots:
void openURL();
void openURL(const KUrl& url);
void openURL(const QUrl& url);
void slotConfigureKeys();
void slotConfigureToolBars();
......
......@@ -25,12 +25,12 @@
#include <qfile.h>
#include <qtextstream.h>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <klocale.h>
#include <KSharedConfig>
#include <kmessagebox.h>
#include <ktextedit.h>
#include <KConfigGroup>
#include <KLocalizedString>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
......@@ -64,8 +64,6 @@ ChangeLogDialog::ChangeLogDialog(KConfig& cfg, QWidget *parent)
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
//PORTING SCRIPT: WARNING mainLayout->addWidget(buttonBox) must be last item in layout. Please move it.
mainLayout->addWidget(buttonBox);
okButton->setDefault(true);
edit = new KTextEdit(this);
......@@ -79,8 +77,10 @@ ChangeLogDialog::ChangeLogDialog(KConfig& cfg, QWidget *parent)
mainLayout->addWidget(edit);
mainLayout->addWidget(buttonBox);
KConfigGroup cg(&partConfig, "ChangeLogDialog");
restoreDialogSize(cg);
restoreGeometry(cg.readEntry<QByteArray>("geometry", QByteArray()));
connect(okButton,SIGNAL(clicked()),this,SLOT(slotOk()));
}
......@@ -88,7 +88,7 @@ ChangeLogDialog::ChangeLogDialog(KConfig& cfg, QWidget *parent)
ChangeLogDialog::~ChangeLogDialog()
{
KConfigGroup cg(&partConfig, "ChangeLogDialog");
saveDialogSize(cg);
cg.writeEntry("geometry", saveGeometry());
}
......
......@@ -19,12 +19,11 @@
*/
#include <QRegExp>
#include <QApplication>
#include <QCommandLineParser>
#include <kaboutdata.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <klocale.h>
#include <kpassworddialog.h>
#include <KPasswordDialog>
#include <iostream>
......@@ -32,29 +31,30 @@
extern "C" KDE_EXPORT int kdemain(int argc, char** argv)
{
KAboutData about("cvsaskpass", 0, ki18n("cvsaskpass"), "0.1",
ki18n("ssh-askpass for the CVS D-Bus Service"),
KAboutData about("cvsaskpass", 0, i18n("cvsaskpass"), "0.1",
i18n("ssh-askpass for the CVS D-Bus Service"),
KAboutData::License_LGPL,
ki18n("Copyright (c) 2003 Christian Loose"));
i18n("Copyright (c) 2003 Christian Loose"));
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions options;
options.add("+[prompt]", ki18n("prompt"));
KCmdLineArgs::addCmdLineOptions(options);
KAboutData::setApplicationData(about);
// no need to register with the dcop server
//KApplication::disableAutoDcopRegistration();
KApplication app;
QApplication app(argc, argv);
QCommandLineParser parser;
parser.addPositionalArgument(QCommandlineOption(QLatin1String("prompt"), i18n("prompt"), QLatin1String("[prompt]")));
// no need for session management
app.disableSessionManagement();
if( !KCmdLineArgs::parsedArgs()->count() )
parser.process(app);
if( !parser.positionalArguments()->count() )
return 1;
// parse repository name from the passed argument
QString prompt = KCmdLineArgs::parsedArgs()->arg(0);
QString prompt = parser.positionalArguments()[0];
QRegExp rx("(.*@.*)'s password:");
KPasswordDialog dlg;
......
......@@ -28,7 +28,6 @@
#include <klocale.h>
#include <kmessagebox.h>
#include <kshell.h>
#include <kglobal.h>
#include <QDebug>
#include "cvsjob.h"
......@@ -82,8 +81,7 @@ CvsService::CvsService()
// create repository manager
d->repository = new Repository();
KSharedConfig::Ptr config = KGlobal::config();
KConfigGroup cs(config, "General");
KConfigGroup cs(KSharedConfig::open(), "General");
if( cs.readEntry("UseSshAgent", false) )
{
// use the existing or start a new ssh-agent
......
......@@ -23,13 +23,11 @@
#include <qdir.h>
#include <qfile.h>
#include <qstring.h>
//Added by qt3to4:
#include <QTextStream>
#include <ksharedconfig.h>
#include <kdirwatch.h>
#include <kstandarddirs.h>
#include <kglobal.h>
#include "sshagent.h"
#include <QDBusConnection>
......@@ -200,7 +198,7 @@ void Repository::slotConfigDirty(const QString& fileName)
if( fileName == d->configFileName )
{
// reread the configuration data from disk
KGlobal::config()->reparseConfiguration();
KSharedConfig::openConfig()->reparseConfiguration();
d->readConfig();
}
}
......@@ -209,14 +207,14 @@ void Repository::slotConfigDirty(const QString& fileName)
void Repository::Private::readGeneralConfig()
{
// get path to cvs client program
KConfigGroup cg(KGlobal::config(), "General");
KConfigGroup cg(KSharedConfig::openConfig(), "General");
client = cg.readPathEntry("CVSPath", "cvs");
}
void Repository::Private::readConfig()
{
KSharedConfig::Ptr config = KGlobal::config();
KSharedConfig::Ptr config = KSharedConfig::openConfig();
// Sometimes the location can be unequal to the entry in the CVS/Root.
//
......
......@@ -28,13 +28,8 @@
#include <QTreeWidget>
#include <QHeaderView>
#include <kglobal.h>
#include <QPushButton>
#include <kconfig.h>
#include <QLineEdit>
#include <klocale.h>
#include <kdatetime.h>
#include <kconfiggroup.h>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
......@@ -105,7 +100,7 @@ bool HistoryItem::operator<(const QTreeWidgetItem &other) const
QVariant HistoryItem::data(int column, int role) const
{
if ( (role == Qt::DisplayRole) && (column == Date) )
return KGlobal::locale()->formatDateTime(m_date);
return QLocale().toString(m_date);
return QTreeWidgetItem::data(column, role);
}
......
......@@ -353,7 +353,7 @@ bool LogDialog::parseCvsLog(OrgKdeCervisiaCvsserviceCvsserviceInterface* service
QString date = dateTimeStr.section(' ', 0, 0);
QString time = dateTimeStr.section(' ', 1, 1);
logInfo.m_dateTime.setTime_t(KDateTime::fromString(date + 'T' + time).toTime_t());
logInfo.m_dateTime.setTime_t(QDateTime::fromString(date + 'T' + time, Qt::ISODate).toTime_t());
logInfo.m_author = strList[1].section(':', 1, 1).trimmed();
......@@ -485,7 +485,7 @@ void LogDialog::slotOk()
QFile::setPermissions(tempFileName, QFileDevice::ReadOwner);
// open file in preferred editor
KUrl url;
QUrl url;
url.setPath(tempFileName);
(void) new KRun(url, 0, true);
}
......
......@@ -61,7 +61,6 @@ public:
bool parseCvsLog(OrgKdeCervisiaCvsserviceCvsserviceInterface* service, const QString& fileName);
protected slots:
virtual void slotButtonClicked(int button);
void slotOk();
void slotApply();
......
......@@ -20,10 +20,9 @@
#include "loginfo.h"
#include <qtextdocument.h>
#include <QLocale>
#include <kglobal.h>
#include <klocale.h>
#include <KLocalizedString>
namespace Cervisia
{
......@@ -72,17 +71,17 @@ QString TagInfo::typeToString() const
QString LogInfo::createToolTipText(bool showTime) const
{
QString text(QLatin1String("<nobr><b>"));
text += Qt::escape(m_revision);
text += m_revision.toHtmlEscaped();
text += QLatin1String("</b>&nbsp;&nbsp;");
text += Qt::escape(m_author);
text += m_author.toHtmlEscaped();
text += QLatin1String("&nbsp;&nbsp;<b>");
text += Qt::escape(dateTimeToString(showTime));
text += dateTimeToString(showTime).toHtmlEscaped();
text += QLatin1String("</b></nobr>");
if (!m_comment.isEmpty())
{
text += QLatin1String("<pre>");
text += Qt::escape(m_comment);
text += m_comment.toHtmlEscaped();
text += QLatin1String("</pre>");
}
......@@ -94,7 +93,7 @@ QString LogInfo::createToolTipText(bool showTime) const
{
if (it != m_tags.begin() || m_comment.isEmpty())
text += QLatin1String("<br>");
text += Qt::escape((*it).toString());
text += (*it).toString().toHtmlEscaped();
}
text += QLatin1String("</i>");
}
......@@ -105,11 +104,11 @@ QString LogInfo::createToolTipText(bool showTime) const
QString LogInfo::dateTimeToString(bool showTime, bool shortFormat) const
{
KLocale::DateFormat format = shortFormat ? KLocale::ShortDate : KLocale::LongDate;
QLocale::FormatType format = shortFormat ? QLocale::ShortFormat : QLocale::LongFormat;
if( showTime )
return KGlobal::locale()->formatDateTime(m_dateTime, format);
return QLocale().toString(m_dateTime, format);
else
return KGlobal::locale()->formatDate(m_dateTime.date(), format);
return QLocale().toString(m_dateTime.date(), format);
}
......
......@@ -23,7 +23,6 @@
#include <QApplication>
#include <qpainter.h>
#include <QDebug>
#include <kglobal.h>
#include <kcolorscheme.h>
#include "loginfo.h"
......
......@@ -23,12 +23,12 @@
#include <QFileInfo>
#include <kaboutdata.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <QApplication>
#include <QCommandLineParser>
#include <kconfig.h>
#include <klocale.h>
#include <kurl.h>
#include <ktoolinvocation.h>
#include <KLocalizedString>
#include "misc.h"
#include "cervisiashell.h"
......@@ -139,48 +139,52 @@ static int ShowAnnotateDialog(const QString& fileName)
extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
{
KAboutData about("cervisia", 0, ki18n("Cervisia"), CERVISIA_VERSION,
ki18n("A CVS frontend"), KAboutData::License_GPL,
ki18n("Copyright (c) 1999-2002 Bernd Gehrmann\n"
"Copyright (c) 2002-2008 the Cervisia authors"), KLocalizedString(),
"http://cervisia.kde.org");
KAboutData about("cervisia", i18n("Cervisia"), CERVISIA_VERSION,
i18n("A CVS frontend"), KAboutLicense::GPL,
i18n("Copyright (c) 1999-2002 Bernd Gehrmann\n"
"Copyright (c) 2002-2008 the Cervisia authors"), QString(),
QLatin1String("http://cervisia.kde.org"));
about.addAuthor(ki18n("Bernd Gehrmann"), ki18n("Original author and former "
about.addAuthor(i18n("Bernd Gehrmann"), i18n("Original author and former "
"maintainer"), "bernd@mail.berlios.de");
about.addAuthor(ki18n("Christian Loose"), ki18n("Maintainer"),
about.addAuthor(i18n("Christian Loose"), i18n("Maintainer"),
"christian.loose@kdemail.net");
about.addAuthor(ki18n("Andr\303\251 W\303\266bbeking"), ki18n("Developer"),
about.addAuthor(i18n("Andr\303\251 W\303\266bbeking"), i18n("Developer"),
"woebbeking@kde.org");
about.addAuthor(ki18n("Carlos Woelz"), ki18n("Documentation"),
about.addAuthor(i18n("Carlos Woelz"), i18n("Documentation"),
"carloswoelz@imap-mail.com");
about.addCredit(ki18n("Richard Moore"), ki18n("Conversion to KPart"),
about.addCredit(i18n("Richard Moore"), i18n("Conversion to KPart"),
"rich@kde.org");
about.addCredit(ki18n("Laurent Montel"), ki18n("Conversion to D-Bus"),
about.addCredit(i18n("Laurent Montel"), i18n("Conversion to D-Bus"),
"montel@kde.org");
about.addCredit(i18n("Martin Koller"), i18n("Port to KDE Frameworks 5"),
"kollix@aon.at");
KCmdLineArgs::init(argc, argv, &about);
KAboutData::setApplicationData(about);
KCmdLineOptions options;
options.add("+[directory]", ki18n("The sandbox to be loaded"));
options.add("resolve <file>", ki18n("Show resolve dialog for the given file"));
options.add("log <file>", ki18n("Show log dialog for the given file"));
options.add("annotate <file>", ki18n("Show annotation dialog for the given file"));
KCmdLineArgs::addCmdLineOptions(options);
QApplication app(argc, argv);
KApplication app;
QCommandLineParser parser;
QString resolvefile = KCmdLineArgs::parsedArgs()->getOption("resolve");
parser.addPositionalArgument(QLatin1String("directory"), i18n("The sandbox to be loaded"), QLatin1String("[directory]"));
parser.addOption(QCommandLineOption("resolve <file>", i18n("Show resolve dialog for the given file")));
parser.addOption(QCommandLineOption("log <file>", i18n("Show log dialog for the given file")));
parser.addOption(QCommandLineOption("annotate <file>", i18n("Show annotation dialog for the given file")));
parser.process(app);
QString resolvefile = parser.value(QLatin1String("resolve"));
if (!resolvefile.isEmpty())
return ShowResolveDialog(resolvefile);
// is command line option 'show log dialog' specified?
QString logFile = KCmdLineArgs::parsedArgs()->getOption("log");
QString logFile = parser.value(QLatin1String("log"));
if( !logFile.isEmpty() )
return ShowLogDialog(logFile);
// is command line option 'show annotation dialog' specified?
QString annotateFile = KCmdLineArgs::parsedArgs()->getOption("annotate");
QString annotateFile = parser.value(QLatin1String("annotate"));
if( !annotateFile.isEmpty() )
return ShowAnnotateDialog(annotateFile);
......@@ -189,10 +193,9 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
} else {
CervisiaShell* shell = new CervisiaShell();
const KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
if( args->count() )
if( parser.positionalArguments().count() )
{
KUrl directory = args->url(0);
QUrl directory = QUrl::fromLocalFile(parser.positionalArguments()[0]);
shell->openURL(directory);
}
else
......
......@@ -20,6 +20,7 @@
#include "misc.h"
#include "debug.h"
#include <ctype.h>
#include <pwd.h>
......@@ -30,8 +31,8 @@
#include <qregexp.h>
#include <qstringlist.h>
#include <kemailsettings.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <KLocalizedString>
#include <QTemporaryFile>
#include <kuser.h>
#include <QDebug>
......@@ -273,9 +274,7 @@ QString tempFileName(const QString& suffix)
if (!tempFiles)
tempFiles = new QStringList;
QTemporaryFile f;
//code was f.setSuffix(suffix);
//Add to constructor and adapt if necessary: QDir::tempPath() + QLatin1String("/myapp_XXXXXX") + QLatin1String(suffix)
QTemporaryFile f(QDir::tempPath() + QLatin1String("/cervisia_XXXXXX") + suffix);
f.setAutoRemove(false);
f.open();
tempFiles->append(f.fileName());
......
......@@ -24,7 +24,7 @@
#include <QAction>
#include <QMenu>
//#include <QTextDocument>
#include <QContextMenuEvent>
#include <klocale.h>
#include <kmessagebox.h>
......@@ -32,6 +32,7 @@
#include "cervisiapart.h"
#include "cervisiasettings.h"
#include "cvsjobinterface.h"
#include "debug.h"
ProtocolView::ProtocolView(const QString& appId, QWidget *parent)
......@@ -166,7 +167,7 @@ void ProtocolView::appendLine(const QString &line)
{
// Escape output line, so that html tags in commit