diff --git a/CMakeLists.txt b/CMakeLists.txt index 39c26d8..aa2dd3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,80 +1,80 @@ cmake_minimum_required(VERSION 2.8.12) project(sweeper) include(FeatureSummary) find_package(Qt5 REQUIRED COMPONENTS Core DBus Widgets) find_package(ECM 1.7.0 NO_MODULE REQUIRED) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(ECMAddAppIcon) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) add_definitions( -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_URL_CAST_FROM_STRING ) -find_package(KF5 5.15.0 REQUIRED COMPONENTS +find_package(KF5 5.23.0 REQUIRED COMPONENTS Bookmarks Crash Config ConfigWidgets CoreAddons DocTools I18n KIO TextWidgets XmlGui ) include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) configure_file(config-sweeper.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-sweeper.h ) set(sweeper_SRCS main.cpp sweeper.cpp privacyfunctions.cpp privacyaction.cpp ) qt5_add_dbus_adaptor( sweeper_SRCS org.kde.sweeper.xml sweeper.h Sweeper) # file(GLOB ICONS_SRCS "${KDE4_INSTALL_DIR}/share/icons/oxygen/*/actions/trash-empty.png") # ecm_add_app_icon(sweeper_SRCS ICONS ${ICONS_SRCS}) ki18n_wrap_ui(sweeper_SRCS sweeperdialog.ui ) add_executable(sweeper ${sweeper_SRCS}) target_link_libraries(sweeper Qt5::Core Qt5::DBus Qt5::Widgets KF5::Bookmarks KF5::Crash KF5::I18n KF5::KIOCore KF5::TextWidgets KF5::XmlGui ) install(TARGETS sweeper ${INSTALL_TARGETS_DEFAULT_ARGS} ) ########### install files ############### install( PROGRAMS org.kde.sweeper.desktop DESTINATION ${KDE_INSTALL_APPDIR}) install( FILES sweeperui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/sweeper) install( FILES org.kde.sweeper.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR} ) install( FILES org.kde.sweeper.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) add_subdirectory(doc) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/sweeper.cpp b/sweeper.cpp index 879ef22..5e44e0e 100644 --- a/sweeper.cpp +++ b/sweeper.cpp @@ -1,174 +1,172 @@ /** * Copyright (c) 2003-2005 Ralf Hoelzer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sweeper.h" #include "privacyaction.h" #include "privacyfunctions.h" #include "sweeperadaptor.h" -#include -#include -#include -#include -#include +#include +#include +#include #include +#include +#include Sweeper::Sweeper(bool automatic) : KXmlGuiWindow(0) , m_privacyConfGroup(KSharedConfig::openConfig(QStringLiteral("kprivacyrc"), KConfig::NoGlobals), "Cleaning") , m_automatic(automatic) { QWidget *mainWidget = new QWidget(this); ui.setupUi(mainWidget); setCentralWidget(mainWidget); QTreeWidget *sw = ui.privacyListView; - KStandardAction::quit(this, SLOT(close()), actionCollection()); + KStandardAction::quit(this, &Sweeper::close, actionCollection()); createGUI(QStringLiteral("sweeperui.rc")); setAutoSaveSettings(); generalCLI = new QTreeWidgetItem(QStringList() << i18nc("General system content", "General")); sw->addTopLevelItem(generalCLI); webbrowsingCLI = new QTreeWidgetItem(QStringList() << i18nc("Web browsing content", "Web Browsing")); sw->addTopLevelItem(webbrowsingCLI); generalCLI->setExpanded(true); webbrowsingCLI->setExpanded(true); this->InitActions(); - connect(ui.cleanupButton, SIGNAL(clicked()), SLOT(cleanup())); - connect(ui.selectAllButton, SIGNAL(clicked()), SLOT(selectAll())); - connect(ui.selectNoneButton, SIGNAL(clicked()), SLOT(selectNone())); + connect(ui.cleanupButton, &QPushButton::clicked, this, &Sweeper::cleanup); + connect(ui.selectAllButton, &QPushButton::clicked, this, &Sweeper::selectAll); + connect(ui.selectNoneButton, &QPushButton::clicked, this, &Sweeper::selectNone); new KsweeperAdaptor(this); QDBusConnection::sessionBus().registerObject(QStringLiteral("/ksweeper"), this); load(); if(automatic) { cleanup(); close(); } } Sweeper::~Sweeper() { save(); } void Sweeper::load() { QLinkedList::iterator itr; for (itr = checklist.begin(); itr != checklist.end(); ++itr) { (*itr)->setCheckState(0, m_privacyConfGroup.readEntry((*itr)->configKey(), true) ? Qt::Checked : Qt::Unchecked); } } void Sweeper::save() { QLinkedList::iterator itr; for (itr = checklist.begin(); itr != checklist.end(); ++itr) { m_privacyConfGroup.writeEntry((*itr)->configKey(), (*itr)->checkState(0) == Qt::Checked); } m_privacyConfGroup.sync(); } void Sweeper::selectAll() { QLinkedList::iterator itr; for (itr = checklist.begin(); itr != checklist.end(); ++itr) { (*itr)->setCheckState(0, Qt::Checked); } } void Sweeper::selectNone() { QLinkedList::iterator itr; for (itr = checklist.begin(); itr != checklist.end(); ++itr) { (*itr)->setCheckState(0, Qt::Unchecked); } } void Sweeper::cleanup() { if (!m_automatic) { if (KMessageBox::warningContinueCancel(this, i18n("You are deleting data that is potentially valuable to you. Are you sure?")) != KMessageBox::Continue) { return; } } ui.statusTextEdit->clear(); ui.statusTextEdit->setText(i18n("Starting cleanup...")); QLinkedList::iterator itr; for (itr = checklist.begin(); itr != checklist.end(); ++itr) { if((*itr)->checkState(0) == Qt::Checked) { QString statusText = i18n("Clearing %1...", (*itr)->text(0)); ui.statusTextEdit->append(statusText); // actions return whether they were successful if(!(*itr)->action()) { QString errorText = i18n("Clearing of %1 failed: %2", (*itr)->text(0), (*itr)->getErrMsg()); ui.statusTextEdit->append(errorText); } } } ui.statusTextEdit->append(i18n("Clean up finished.")); } void Sweeper::InitActions() { // store all entries in a list for easy access later on checklist.append(new ClearSavedClipboardContentsAction(generalCLI)); checklist.append(new ClearRecentDocumentsAction(generalCLI)); checklist.append(new ClearRunCommandHistoryAction(generalCLI)); #ifdef Q_WS_X11 checklist.append( new ClearRecentApplicationAction( generalCLI ) ); #endif checklist.append(new ClearThumbnailsAction(generalCLI)); checklist.append(new ClearAllCookiesAction(webbrowsingCLI)); checklist.append(new ClearFaviconsAction(webbrowsingCLI)); checklist.append(new ClearWebHistoryAction(webbrowsingCLI)); checklist.append(new ClearWebCacheAction(webbrowsingCLI)); checklist.append(new ClearFormCompletionAction(webbrowsingCLI)); checklist.append(new ClearAllCookiesPoliciesAction(webbrowsingCLI)); ui.privacyListView->resizeColumnToContents(0); } -#include "sweeper.moc" - // kate: tab-width 3; indent-mode cstyle; replace-tabs true; diff --git a/sweeper.h b/sweeper.h index eae2e2b..c690dbb 100644 --- a/sweeper.h +++ b/sweeper.h @@ -1,77 +1,73 @@ /** * Copyright (c) 2003-2005 Ralf Hoelzer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SWEEPER_H #define SWEEPER_H #include #include #include #include "ui_sweeperdialog.h" class PrivacyAction; class QTreeWidgetItem; class Sweeper: public KXmlGuiWindow { - Q_OBJECT - public: // if automatic is true, no user interaction is required Sweeper(bool automatic); ~Sweeper(); - - public Q_SLOTS: + void cleanup(); - - private Q_SLOTS: + + private: void selectAll(); void selectNone(); - - private: + /** * methods */ void load(); void save(); - + /** * Set up all the actions we are going to manage. */ void InitActions(); - + /** * attributes */ Ui::SweeperDialog ui; - + QLinkedList checklist; - + QTreeWidgetItem *generalCLI; QTreeWidgetItem *webbrowsingCLI; KConfigGroup m_privacyConfGroup; bool m_automatic; }; #endif // kate: tab-width 3; indent-mode cstyle; replace-tabs true;