diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,6 +1,6 @@ option(WITH_latex "Enable Kopete latex plugin" OFF) # to be fixed or rewritten option(WITH_autoreplace "Enable Kopete autoreplace plugin" ON) -option(WITH_history "Enable Kopete history plugin" OFF) # To be re-written +option(WITH_history "Enable Kopete history plugin" ON) # Attempt to revive option(WITH_history2 "Enable Kopete history2 plugin" OFF) # To be re-written option(WITH_contactnotes "Enable Kopete contactnotes plugin" ON) option(WITH_translator "Enable Kopete translator plugin" OFF) diff --git a/plugins/history/CMakeLists.txt b/plugins/history/CMakeLists.txt --- a/plugins/history/CMakeLists.txt +++ b/plugins/history/CMakeLists.txt @@ -13,6 +13,7 @@ converter.cpp historyguiclient.cpp historyimport.cpp ) +ki18n_wrap_ui(kopete_history_PART_SRCS historyviewer.ui) kconfig_add_kcfg_files(kopete_history_PART_SRCS historyconfig.kcfgc ) @@ -27,6 +28,7 @@ ########### next target ############### set(kcm_kopete_history_PART_SRCS historypreferences.cpp ) +ki18n_wrap_ui(kcm_kopete_history_PART_SRCS historyprefsui.ui) kconfig_add_kcfg_files(kcm_kopete_history_PART_SRCS historyconfig.kcfgc ) @@ -44,7 +46,7 @@ install( FILES historyconfig.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) install( FILES kopete_history.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) -install( FILES historyui.rc historychatui.rc DESTINATION ${KDE_INSTALL_DATADIR}/kopete_history) +install( FILES historyui.rc historychatui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/kopete_history) install( FILES kopete_history_config.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}/kconfiguredialog) diff --git a/plugins/history/converter.cpp b/plugins/history/converter.cpp --- a/plugins/history/converter.cpp +++ b/plugins/history/converter.cpp @@ -214,7 +214,7 @@ doc.doctype().save(stream, 1); doc.documentElement().save(stream, 1); // QDomDocument::save() override stream codec to UTF-8 file.write(buf.toUtf8()); - file.finalize(); + file.commit(); } } @@ -276,7 +276,7 @@ doc.doctype().save(stream, 1); doc.documentElement().save(stream, 1); // QDomDocument::save() override stream codec to UTF-8 file.write(buf.toUtf8()); - file.finalize(); + file.commit(); } } } diff --git a/plugins/history/historydialog.cpp b/plugins/history/historydialog.cpp --- a/plugins/history/historydialog.cpp +++ b/plugins/history/historydialog.cpp @@ -105,10 +105,8 @@ QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); mainLayout->addWidget(mainWidget); - 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); + connect(buttonBox, &QDialogButtonBox::accepted, this, &HistoryDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &HistoryDialog::reject); QString fontSize; QString htmlCode; QString fontStyle; @@ -156,7 +154,7 @@ mHtmlView->setMarginHeight(4); mHtmlView->setFocusPolicy(Qt::ClickFocus); mHtmlView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); - l->setMargin(0); + l->setMargin(4); l->addWidget(mHtmlView); QTextStream(&fontSize) << Kopete::AppearanceSettings::self()->chatFont().pointSize(); @@ -168,16 +166,15 @@ mHtmlPart->write(QString::fromLatin1(htmlCode.toLatin1())); mHtmlPart->end(); - connect(mHtmlPart->browserExtension(), SIGNAL(openUrlRequestDelayed(QUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)), - this, SLOT(slotOpenURLRequest(QUrl,KParts::OpenUrlArguments,KParts::BrowserArguments))); - connect(mMainWidget->dateTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *,int)), this, SLOT(dateSelected(QTreeWidgetItem *))); - connect(mMainWidget->searchButton, SIGNAL(clicked()), this, SLOT(slotSearch())); - connect(mMainWidget->searchLine, SIGNAL(returnPressed()), this, SLOT(slotSearch())); - connect(mMainWidget->searchLine, SIGNAL(textChanged(QString)), this, SLOT(slotSearchTextChanged(QString))); - connect(mMainWidget->contactComboBox, SIGNAL(activated(int)), this, SLOT(slotContactChanged(int))); - connect(mMainWidget->messageFilterBox, SIGNAL(activated(int)), this, SLOT(slotFilterChanged(int))); - connect(mMainWidget->importHistory, SIGNAL(clicked()), this, SLOT(slotImportHistory())); - connect(mHtmlPart, SIGNAL(popupMenu(QString,QPoint)), this, SLOT(slotRightClick(QString,QPoint))); + connect(mHtmlPart->browserExtension(), &KParts::BrowserExtension::openUrlRequestDelayed, this, &HistoryDialog::slotOpenURLRequest); + connect(mMainWidget->dateTreeWidget, &QTreeWidget::itemClicked, this, &HistoryDialog::dateSelected); + connect(mMainWidget->searchButton, &QPushButton::clicked, this, &HistoryDialog::slotSearch); + connect(mMainWidget->searchLine, &KLineEdit::returnPressed, this, &HistoryDialog::slotSearch); + connect(mMainWidget->searchLine, &KLineEdit::textChanged, this, &HistoryDialog::slotSearchTextChanged); + connect(mMainWidget->contactComboBox, static_cast(&KComboBox::activated), this, &HistoryDialog::slotContactChanged); + connect(mMainWidget->messageFilterBox, static_cast(&QComboBox::activated), this, &HistoryDialog::slotFilterChanged); + connect(mMainWidget->importHistory, &QPushButton::clicked, this, &HistoryDialog::slotImportHistory); + // connect(mHtmlPart, &KHTMLPart::popupMenu, this, &HistoryDialog::slotRightClick); //initActions mCopyAct = KStandardAction::copy(this, SLOT(slotCopy()), mHtmlView); @@ -185,9 +182,10 @@ mCopyURLAct = new QAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy Link Address"), mHtmlView); mHtmlView->addAction(mCopyURLAct); - connect(mCopyURLAct, SIGNAL(triggered(bool)), this, SLOT(slotCopyURL())); - - resize(650, 700); + connect(mCopyURLAct, &QAction::triggered, this, &HistoryDialog::slotCopyURL); + mainLayout->addWidget(buttonBox); + + resize(634, 555); // show the dialog before people get impatient show(); @@ -603,7 +601,7 @@ mCopyAct->setEnabled(mHtmlPart->hasSelection()); chatWindowPopup->addAction(mCopyAct); - connect(chatWindowPopup, SIGNAL(aboutToHide()), chatWindowPopup, SLOT(deleteLater())); + connect(chatWindowPopup, &QMenu::aboutToHide, chatWindowPopup, &QMenu::deleteLater); chatWindowPopup->popup(point); } diff --git a/plugins/history/historyguiclient.cpp b/plugins/history/historyguiclient.cpp --- a/plugins/history/historyguiclient.cpp +++ b/plugins/history/historyguiclient.cpp @@ -54,7 +54,7 @@ actionLast = new QAction(QIcon::fromTheme(QStringLiteral("go-last")), i18n("Latest History"), this); actionCollection()->addAction("historyLast", actionLast); - connect(actionLast, SIGNAL(triggered(bool)), this, SLOT(slotLast())); + connect(actionLast, &QAction::triggered, this, &HistoryGUIClient::slotLast); actionPrev = KStandardAction::back(this, SLOT(slotPrevious()), this); actionCollection()->addAction("historyPrevious", actionPrev); actionNext = KStandardAction::forward(this, SLOT(slotNext()), this); @@ -63,11 +63,11 @@ QAction *viewChatHistory = new QAction(QIcon::fromTheme(QStringLiteral("view-history")), i18n("View &History"), this); actionCollection()->addAction("viewChatHistory", viewChatHistory); viewChatHistory->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H)); - connect(viewChatHistory, SIGNAL(triggered(bool)), this, SLOT(slotViewHistory())); + connect(viewChatHistory, &QAction::triggered, this, &HistoryGUIClient::slotViewHistory); QAction *actionQuote = new QAction(QIcon::fromTheme(QStringLiteral("go-last")), i18n("Quote Last Message"), this); actionCollection()->addAction("historyQuote", actionQuote); - connect(actionQuote, SIGNAL(triggered(bool)), this, SLOT(slotQuote())); + connect(actionQuote, &QAction::triggered, this, &HistoryGUIClient::slotQuote); // we are generally at last when beginning actionPrev->setEnabled(true); @@ -148,7 +148,7 @@ Kopete::Message msg = m_manager->view()->currentMessage(); QString body = msgs.isEmpty() ? "" : msgs.last().plainBody(); - kDebug(14310) << "Quoting last message " << body; + qDebug() << "Quoting last message " << body; body = body.replace('\n', "\n> "); body.prepend("> "); @@ -166,19 +166,19 @@ //The same as above but with some checking KopeteView *view = Kopete::ChatSessionManager::self()->activeView(); if (!view) { - kDebug()<<"Unable to Get Active View!"; + qDebug()<<"Unable to Get Active View!"; return; } Kopete::ChatSession *session = view->msgManager(); if (!session) { - kDebug()<<"Unable to Get Active Session!"; + qDebug()<<"Unable to Get Active Session!"; return; } Kopete::Contact *contact = session->members().first(); if (!contact) { - kDebug()<<"Unable to get contact!"; + qDebug()<<"Unable to get contact!"; return; } diff --git a/plugins/history/historyimport.cpp b/plugins/history/historyimport.cpp --- a/plugins/history/historyimport.cpp +++ b/plugins/history/historyimport.cpp @@ -87,9 +87,9 @@ model->setHorizontalHeaderLabels(QStringList(i18n("Parsed History"))); // connect everything - connect(treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(itemClicked(QModelIndex))); - connect(fromPidgin, SIGNAL(clicked()), this, SLOT(importPidgin())); - connect(this, SIGNAL(okClicked()), this, SLOT(save())); + connect(treeView, &QTreeView::clicked, this, &HistoryImport::itemClicked); + connect(fromPidgin, &QPushButton::clicked, this, &HistoryImport::importPidgin); + connect(this, &HistoryImport::okClicked, this, &HistoryImport::save); // define variables amount = 0; diff --git a/plugins/history/historylogger.cpp b/plugins/history/historylogger.cpp --- a/plugins/history/historylogger.cpp +++ b/plugins/history/historylogger.cpp @@ -68,7 +68,7 @@ m_filterRegExp = false; //the contact may be destroyed, for example, if the contact changes its metacontact - connect(m_metaContact, SIGNAL(destroyed(QObject *)), this, SLOT(slotMCDeleted())); + connect(m_metaContact, &Kopete::MetaContact::destroyed, this, &HistoryLogger::slotMCDeleted); setPositionToLast(); } @@ -87,7 +87,7 @@ m_filterRegExp = false; //the contact may be destroyed, for example, if the contact changes its metacontact - connect(m_metaContact, SIGNAL(destroyed(QObject *)), this, SLOT(slotMCDeleted())); + connect(m_metaContact, &Kopete::MetaContact::destroyed, this, &HistoryLogger::slotMCDeleted); setPositionToLast(); } @@ -326,7 +326,7 @@ if (!m_saveTimer) { m_saveTimer = new QTimer(this); - connect(m_saveTimer, SIGNAL(timeout()), this, SLOT(saveToDisk())); + connect(m_saveTimer, &QTimer::timeout, this, &HistoryLogger::saveToDisk); } if (!m_saveTimer->isActive()) { m_saveTimer->setSingleShot(true); @@ -688,14 +688,22 @@ QString HistoryLogger::getFileName(const Kopete::Contact *c, QDate date) { - QString name = c->protocol()->pluginId().replace(QRegExp(QString::fromLatin1("[./~?*]")), QString::fromLatin1("-")) - +QString::fromLatin1("/") - +c->account()->accountId().replace(QRegExp(QString::fromLatin1("[./~?*]")), QString::fromLatin1("-")) - +QString::fromLatin1("/") - +c->contactId().replace(QRegExp(QString::fromLatin1("[./~?*]")), QString::fromLatin1("-")) + QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + QString directoryToLog = QString::fromLatin1("/logs/") + + c->protocol()->pluginId().replace(QRegExp(QString::fromLatin1("[./~?*]")), QString::fromLatin1("-")) + + QString::fromLatin1("/") + + c->account()->accountId().replace(QRegExp(QString::fromLatin1("[./~?*]")), QString::fromLatin1("-")) + + QString::fromLatin1("/"); + + // Create Directory to store History Log if It does not exist + QDir dir(directoryToLog); + if (!dir.exists()) { + dir.mkpath(dataLocation); + } + QString name = c->contactId().replace(QRegExp(QString::fromLatin1("[./~?*]")), QString::fromLatin1("-")) +date.toString(".yyyyMM"); - QString filename = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + QString::fromLatin1("kopete/logs/") + name+ QString::fromLatin1(".xml"); + QString filename = dataLocation + directoryToLog + name + QString::fromLatin1(".xml"); //Check if there is a kopete 0.7.x file QFileInfo fi(filename); diff --git a/plugins/history/historyplugin.cpp b/plugins/history/historyplugin.cpp --- a/plugins/history/historyplugin.cpp +++ b/plugins/history/historyplugin.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "kopetechatsessionmanager.h" #include "kopetemetacontact.h" @@ -52,18 +53,17 @@ QAction *viewMetaContactHistory = new QAction(QIcon::fromTheme(QStringLiteral("view-history")), i18n("View &History"), this); actionCollection()->addAction("viewMetaContactHistory", viewMetaContactHistory); viewMetaContactHistory->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H)); - connect(viewMetaContactHistory, SIGNAL(triggered(bool)), this, SLOT(slotViewHistory())); + connect(viewMetaContactHistory, &QAction::triggered, this, &HistoryPlugin::slotViewHistory); viewMetaContactHistory->setEnabled( Kopete::ContactList::self()->selectedMetaContacts().count() == 1); - connect(Kopete::ContactList::self(), SIGNAL(metaContactSelected(bool)), - viewMetaContactHistory, SLOT(setEnabled(bool))); + connect(Kopete::ContactList::self(), &Kopete::ContactList::metaContactSelected, viewMetaContactHistory, &QAction::setEnabled); - connect(Kopete::ChatSessionManager::self(), SIGNAL(viewCreated(KopeteView *)), - this, SLOT(slotViewCreated(KopeteView *))); + connect(Kopete::ChatSessionManager::self(), &Kopete::ChatSessionManager::viewCreated, this, &HistoryPlugin::slotViewCreated); - connect(this, SIGNAL(settingsChanged()), this, SLOT(slotSettingsChanged())); + connect(this, &HistoryPlugin::settingsChanged, this, &HistoryPlugin::slotSettingsChanged); + setComponentName(QStringLiteral("kopete_history"), i18n("Kopete")); setXMLFile("historyui.rc"); if (detectOldHistory()) { if ( @@ -81,8 +81,7 @@ for (QList::Iterator it = sessions.begin(); it != sessions.end(); ++it) { if (!m_loggers.contains(*it)) { m_loggers.insert(*it, new HistoryGUIClient(*it)); - connect(*it, SIGNAL(closing(Kopete::ChatSession *)), - this, SLOT(slotKMMClosed(Kopete::ChatSession *))); + connect(*it, &Kopete::ChatSession::closing, this, &HistoryPlugin::slotKMMClosed); } } } @@ -109,8 +108,7 @@ if (!m_loggers.contains(m.manager())) { m_loggers.insert(m.manager(), new HistoryGUIClient(m.manager())); - connect(m.manager(), SIGNAL(closing(Kopete::ChatSession *)), - this, SLOT(slotKMMClosed(Kopete::ChatSession *))); + connect(m.manager(), &Kopete::ChatSession::closing, this, &HistoryPlugin::slotKMMClosed); } HistoryLogger *l = m_loggers[m.manager()]->logger(); @@ -153,8 +151,7 @@ if (!m_loggers.contains(m_currentChatSession)) { m_loggers.insert(m_currentChatSession, new HistoryGUIClient(m_currentChatSession)); - connect(m_currentChatSession, SIGNAL(closing(Kopete::ChatSession *)), - this, SLOT(slotKMMClosed(Kopete::ChatSession *))); + connect(m_currentChatSession, &Kopete::ChatSession::closing, this, &HistoryPlugin::slotKMMClosed); } if (!autoChatWindow || nbAutoChatWindow == 0) { @@ -186,7 +183,7 @@ void HistoryPlugin::slotSettingsChanged() { - kDebug(14310) << "RELOADING CONFIG"; + qDebug() << "RELOADING CONFIG"; HistoryConfig::self()->load(); } diff --git a/plugins/history/historypreferences.cpp b/plugins/history/historypreferences.cpp --- a/plugins/history/historypreferences.cpp +++ b/plugins/history/historypreferences.cpp @@ -35,7 +35,7 @@ HistoryPreferences::HistoryPreferences(QWidget *parent, const QVariantList &args) : KCModule(parent, args) { - kDebug(14310) << "called."; + qDebug() << "called."; QVBoxLayout *l = new QVBoxLayout(this); QWidget *w = new QWidget; @@ -43,24 +43,21 @@ p->setupUi(w); l->addWidget(w); - connect(p->chkShowPrevious, SIGNAL(toggled(bool)), this, SLOT(slotShowPreviousChanged(bool))); - connect(p->Number_Auto_chatwindow, SIGNAL(valueChanged(int)), - this, SLOT(slotModified())); - connect(p->Number_ChatWindow, SIGNAL(valueChanged(int)), - this, SLOT(slotModified())); - connect(p->History_color, SIGNAL(changed(QColor)), - this, SLOT(slotModified())); + connect(p->chkShowPrevious, &QCheckBox::toggled, this, &HistoryPreferences::slotShowPreviousChanged); + connect(p->Number_Auto_chatwindow, static_cast(&QSpinBox::valueChanged), this, &HistoryPreferences::slotModified); + connect(p->Number_ChatWindow, static_cast(&QSpinBox::valueChanged), this, &HistoryPreferences::slotModified); + connect(p->History_color, &KColorButton::changed, this, &HistoryPreferences::slotModified); } HistoryPreferences::~HistoryPreferences() { - kDebug(14310) << "called."; + qDebug() << "called."; delete p; } void HistoryPreferences::load() { - kDebug(14310) << "called."; + qDebug() << "called."; HistoryConfig::self()->load(); p->chkShowPrevious->setChecked(HistoryConfig::auto_chatwindow()); slotShowPreviousChanged(p->chkShowPrevious->isChecked()); @@ -73,7 +70,7 @@ void HistoryPreferences::save() { - kDebug(14310) << "called."; + qDebug() << "called."; HistoryConfig::setAuto_chatwindow(p->chkShowPrevious->isChecked()); HistoryConfig::setNumber_Auto_chatwindow(p->Number_Auto_chatwindow->value()); HistoryConfig::setNumber_ChatWindow(p->Number_ChatWindow->value()); diff --git a/plugins/history/historyviewer.ui b/plugins/history/historyviewer.ui --- a/plugins/history/historyviewer.ui +++ b/plugins/history/historyviewer.ui @@ -1,49 +1,59 @@ - + + HistoryViewer - - + + 0 0 - 682 - 384 + 624 + 519 - - + + 0 0 - + 300 200 - - + + + 0 + + + 0 + + + 0 + + 0 - + - - - + + + 0 0 - + Contact: - - - + + + 0 0 @@ -51,45 +61,45 @@ - - + + Import History... - - + + Message filter: - - - + + + 0 0 - + 140 0 - + All Messages - + Only Incoming - + Only Outgoing @@ -98,39 +108,39 @@ - - - + + + 0 0 - + Qt::Horizontal - - + + - + - - + + true - + false - + true - + Date - + Contact @@ -138,9 +148,9 @@ - - - + + + 1 0 @@ -149,23 +159,23 @@ - + - - + + Search: - + - - + + false - + &Search @@ -173,23 +183,23 @@ - + - - + + 16777215 20 - + Ready - - + + Qt::Horizontal @@ -198,7 +208,7 @@ - + KComboBox QComboBox