diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,8 +43,6 @@ Declarative Activities ActivitiesStats - OPTIONAL_COMPONENTS - KHtml QUIET ) @@ -61,10 +59,6 @@ add_subdirectory(sidebar) add_subdirectory(doc) -if(KF5KHtml_FOUND) - add_subdirectory(classic) -endif() - if (${ECM_VERSION} STRGREATER "5.58.0") install(FILES systemsettings.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) else() diff --git a/classic/CMakeLists.txt b/classic/CMakeLists.txt deleted file mode 100644 --- a/classic/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -set(classic_mode_srcs - ClassicMode.cpp - CategoryList.cpp -) - -ecm_qt_declare_logging_category(classic_mode_srcs HEADER systemsettings_classic_debug.h IDENTIFIER SYSTEMSETTINGS_CLASSIC_LOG CATEGORY_NAME org.kde.systemsettings.classic) - -ki18n_wrap_ui( classic_mode_srcs configClassic.ui ) -add_library(classic_mode MODULE ${classic_mode_srcs}) - -target_link_libraries(classic_mode systemsettingsview - KF5::ItemViews - KF5::ConfigCore - KF5::KCMUtils - KF5::IconThemes - KF5::I18n - KF5::KIOWidgets - KF5::Service - KF5::KHtml -) - -install( TARGETS classic_mode DESTINATION ${KDE_INSTALL_PLUGINDIR} ) -install( FILES settings-classic-view.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) -install( FILES main.html systemsettings-classic.css DESTINATION ${KDE_INSTALL_DATADIR}/systemsettings/classic/ ) - diff --git a/classic/CategoryList.h b/classic/CategoryList.h deleted file mode 100644 --- a/classic/CategoryList.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (c) 2000,2001 Matthias Elter - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU 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 CATEGORYLIST_H -#define CATEGORYLIST_H - -#include - -class QModelIndex; -class QAbstractItemModel; - - -class CategoryList : public QWidget -{ - Q_OBJECT - -public: - explicit CategoryList( QWidget *parent, QAbstractItemModel *model ); - ~CategoryList() override; - - void changeModule( const QModelIndex &newItem); - -Q_SIGNALS: - void moduleSelected( const QModelIndex &itemSelected ); - -private Q_SLOTS: - void slotModuleLinkClicked( const QUrl& moduleName ); - -private: - void updatePixmap(); - -private: - class Private; - Private *const d; -}; - -#endif diff --git a/classic/CategoryList.cpp b/classic/CategoryList.cpp deleted file mode 100644 --- a/classic/CategoryList.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - Copyright (c) 2000,2001 Matthias Elter - Copyright (c) 2009 Ben Cooksley - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU 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 "CategoryList.h" -#include "systemsettings_classic_debug.h" -#include "MenuItem.h" - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -static const char kcc_infotext[]= I18N_NOOP("System Settings"); -static const char title_infotext[]= I18N_NOOP("Configure your system"); -static const char intro_infotext[]= I18N_NOOP("Welcome to \"System Settings\", " - "a central place to configure your computer system."); - -class CategoryList::Private { -public: - Private() {} - - KHTMLPart * categoryView = nullptr; - QModelIndex categoryMenu; - QAbstractItemModel * itemModel = nullptr; - QMap itemMap; -}; - -CategoryList::CategoryList( QWidget *parent, QAbstractItemModel *model ) - : QWidget(parent), d( new Private() ) -{ - QHBoxLayout *mainLayout = new QHBoxLayout; - setLayout(mainLayout); - setMinimumSize( 400, 400 ); - d->itemModel = model; - - // set what's this help - this->setWhatsThis( i18n( intro_infotext ) ); - d->categoryView = new KHTMLPart( this ); - mainLayout->addWidget(d->categoryView->view()); - d->categoryView->view()->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); - d->categoryView->widget()->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ); - connect( d->categoryView->browserExtension(), - SIGNAL( openUrlRequest( const QUrl&, - const KParts::OpenUrlArguments&, - const KParts::BrowserArguments& ) ), - this, SLOT(slotModuleLinkClicked(QUrl)) ); -} - -CategoryList::~CategoryList() -{ - delete d; -} - -void CategoryList::updatePixmap() -{ - QString content; - QString moduleName; - d->itemMap.clear(); - - const QString templatePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("systemsettings/classic/main.html") ); - QFile templateFile( templatePath ); - templateFile.open( QIODevice::ReadOnly ); - QTextStream templateText( &templateFile ); - QString templateString = templateText.readAll(); - templateString = templateString.arg( QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kf5/infopage/kde_infopage.css") ) ); - if ( qApp->layoutDirection() == Qt::RightToLeft ) { - templateString = templateString.arg( QStringLiteral("@import \"%1\";") ).arg( QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kf5/infopage/kde_infopage_rtl.css") ) ); - } else { - templateString = templateString.arg( QString() ); - } - templateString = templateString.arg( i18n( kcc_infotext ) ); - templateString = templateString.arg( i18n( title_infotext ) ); - templateString = templateString.arg( i18n( intro_infotext ) ); - if ( d->categoryMenu.isValid() ) { - moduleName = d->itemModel->data( d->categoryMenu, Qt::DisplayRole ).toString(); - } - content += QLatin1String("
") + moduleName + QLatin1String("
"); - content += QStringLiteral("\n"); - for( int done = 0; d->itemModel->rowCount( d->categoryMenu ) > done; ++done ) { - QModelIndex childIndex = d->itemModel->index( done, 0, d->categoryMenu ); - MenuItem *childItem = d->itemModel->data( childIndex, Qt::UserRole ).value(); - const QString url = QLatin1String("kcm:///") + childItem->item().fileName(); - QUrl link(url); - const QString szLink = QLatin1String(""); - content += QLatin1String("\n"); - } - content += QStringLiteral("
") + szLink + QLatin1String(""); - const QString szName = childItem->name(); - const QString szComment = childItem->service()->comment(); - content += szLink + szName + QLatin1String("") + szLink + szComment + QLatin1String(""); - - //passing just the path is insufficient as some icon sets (breeze) only provide SVGs - //instead pass data inline - - QIcon icon = QIcon::fromTheme(childItem->service()->icon()); - QImage image(icon.pixmap(24).toImage()); //icons are hardcoded to size 24 above - QByteArray byteArray; - QBuffer buffer(&byteArray); - image.save(&buffer, "PNG"); // writes the image in PNG format inside the buffer - QString iconBase64 = QString::fromLatin1(byteArray.toBase64().data()); - - content = content.arg(QLatin1String("data:image/png;base64,") + iconBase64); - - - d->itemMap.insert( link.url(), childIndex ); - content += QStringLiteral("
"); - d->categoryView->begin( QUrl::fromLocalFile( templatePath ) ); - d->categoryView->write( templateString.arg( content ) ); - d->categoryView->end(); -} - -void CategoryList::changeModule( const QModelIndex &newItem ) -{ - d->categoryMenu = newItem; - updatePixmap(); -} - -void CategoryList::slotModuleLinkClicked( const QUrl& moduleName ) -{ - QModelIndex module = d->itemMap.value( moduleName.url() ); - qCDebug(SYSTEMSETTINGS_CLASSIC_LOG) << "Link name: " << moduleName.url(); - emit moduleSelected( module ); -} - -#include "moc_CategoryList.cpp" diff --git a/classic/ClassicMode.h b/classic/ClassicMode.h deleted file mode 100644 --- a/classic/ClassicMode.h +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************** - * Copyright (C) 2009 Ben Cooksley * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * 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 General Public License for more details. * - * * - * You should have received a copy of the GNU 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 CLASSICMODE_H -#define CLASSICMODE_H - -#include "BaseMode.h" - -class MenuItem; -class ModuleView; -class QModelIndex; - -class ClassicMode : public BaseMode -{ - Q_OBJECT - -public: - ClassicMode(QObject * parent, const QVariantList& ); - ~ClassicMode() override; - void initEvent() override; - void leaveModuleView() override; - QWidget * mainWidget() override; - KAboutData * aboutData() override; - ModuleView * moduleView() const override; - -protected: - QList views() const override; - bool eventFilter(QObject* watched, QEvent* event) override; - -public Q_SLOTS: - void expandColumns(); - void searchChanged( const QString& text ) override; - void selectModule( const QModelIndex& selectedModule ); - void changeModule( const QModelIndex& activeModule ); - void saveState() override; - void giveFocus() override; - void addConfiguration( KConfigDialog * config ) override; - void loadConfiguration() override; - void saveConfiguration() override; - -private Q_SLOTS: - void moduleLoaded(); - void initWidget(); - void moveUp( MenuItem * item ); - -private: - class Private; - Private *const d; -}; - -#endif diff --git a/classic/ClassicMode.cpp b/classic/ClassicMode.cpp deleted file mode 100644 --- a/classic/ClassicMode.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/************************************************************************** - * Copyright (C) 2009 Ben Cooksley * - * Copyright (C) 2008 Mathias Soeken * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * 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 General Public License for more details. * - * * - * You should have received a copy of the GNU 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 "ClassicMode.h" -#include "ui_configClassic.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "MenuItem.h" -#include "MenuModel.h" -#include "ModuleView.h" -#include "CategoryList.h" -#include "MenuProxyModel.h" - -K_PLUGIN_FACTORY(ClassicModeFactory, registerPlugin();) - -class ClassicMode::Private { -public: - Private() {} - virtual ~Private() { - delete aboutClassic; - } - - QSplitter * classicWidget = nullptr; - QTreeView * classicTree = nullptr; - Ui::ConfigClassic classicConfig; - CategoryList * classicCategory = nullptr; - QStackedWidget * stackedWidget = nullptr; - ModuleView * moduleView = nullptr; - QModelIndex currentItem; - - MenuProxyModel * proxyModel = nullptr; - MenuModel * model = nullptr; - KAboutData * aboutClassic = nullptr; -}; - -ClassicMode::ClassicMode( QObject * parent, const QVariantList& ) - : BaseMode( parent ), d( new Private() ) -{ - d->aboutClassic = new KAboutData(QStringLiteral("TreeView"), - i18n("Tree View"), - QStringLiteral("1.0"), - i18n("Provides a classic tree-based view of control modules."), - KAboutLicense::GPL, - i18n("(c) 2009, Ben Cooksley")); - d->aboutClassic->addAuthor(i18n("Ben Cooksley"), i18n("Author"), QStringLiteral("bcooksley@kde.org")); - d->aboutClassic->addAuthor(i18n("Mathias Soeken"), i18n("Developer"), QStringLiteral("msoeken@informatik.uni-bremen.de")); -} - -ClassicMode::~ClassicMode() -{ - if( !d->classicTree ) { - delete d->classicWidget; - } - delete d; -} - -void ClassicMode::initEvent() -{ - // Create the model - d->model = new MenuModel( rootItem(), this ); - - // Move items that are the sole child of a category up.... - moveUp( rootItem() ); - - // Create the proxy model - d->proxyModel = new MenuProxyModel( this ); - d->proxyModel->setSourceModel( d->model ); - d->proxyModel->sort( 0 ); - d->classicWidget = new QSplitter( Qt::Horizontal, nullptr ); - d->classicWidget->setChildrenCollapsible( false ); - d->moduleView = new ModuleView( d->classicWidget ); - d->classicTree = nullptr; -} - -QWidget * ClassicMode::mainWidget() -{ - if( !d->classicTree ) { - initWidget(); - } - return d->classicWidget; -} - -KAboutData * ClassicMode::aboutData() -{ - return d->aboutClassic; -} - -ModuleView * ClassicMode::moduleView() const -{ - return d->moduleView; -} - -QList ClassicMode::views() const -{ - QList theViews; - theViews << d->classicTree; - return theViews; -} - -void ClassicMode::saveState() -{ - config().writeEntry( "viewLayout", d->classicWidget->sizes() ); - config().sync(); -} - -void ClassicMode::expandColumns() -{ - d->classicTree->resizeColumnToContents(0); -} - -void ClassicMode::searchChanged( const QString& text ) -{ - d->proxyModel->setFilterRegExp(text); - if( d->classicTree ) { - d->classicCategory->changeModule( d->classicTree->currentIndex() ); - } -} - -void ClassicMode::selectModule( const QModelIndex& selectedModule ) -{ - d->classicTree->setCurrentIndex( selectedModule ); - if( d->proxyModel->rowCount(selectedModule) > 0 ) { - d->classicTree->setExpanded(selectedModule, true); - } - changeModule( selectedModule ); -} - -void ClassicMode::changeModule( const QModelIndex& activeModule ) -{ - if( activeModule == d->currentItem ) { - return; - } - if( !d->moduleView->resolveChanges() ) { - return; - } - d->moduleView->closeModules(); - d->currentItem = activeModule; - if( d->proxyModel->rowCount(activeModule) > 0 ) { - d->stackedWidget->setCurrentWidget( d->classicCategory ); - d->classicCategory->changeModule(activeModule); - emit viewChanged( false ); - } else { - d->moduleView->loadModule( activeModule ); - } -} - -void ClassicMode::moduleLoaded() -{ - d->stackedWidget->setCurrentWidget( d->moduleView ); -} - -void ClassicMode::initWidget() -{ - // Create the widget - d->classicTree = new QTreeView( d->classicWidget ); - d->classicCategory = new CategoryList( d->classicWidget, d->proxyModel ); - - d->stackedWidget = new QStackedWidget( d->classicWidget ); - d->stackedWidget->layout()->setContentsMargins(0, 0, 0, 0); - d->stackedWidget->addWidget( d->classicCategory ); - d->stackedWidget->addWidget( d->moduleView ); - - d->classicWidget->addWidget( d->classicTree ); - d->classicWidget->addWidget( d->stackedWidget ); - - d->classicTree->setModel( d->proxyModel ); - d->classicTree->setHeaderHidden( true ); - d->classicTree->setIconSize( QSize( 24, 24 ) ); - d->classicTree->setSortingEnabled( true ); - d->classicTree->setMouseTracking( true ); - d->classicTree->setMinimumWidth( 200 ); - d->classicTree->setSelectionMode( QAbstractItemView::SingleSelection ); - d->classicTree->sortByColumn( 0, Qt::AscendingOrder ); - - d->classicCategory->changeModule( d->classicTree->rootIndex() ); - - connect( d->classicCategory, &CategoryList::moduleSelected, this, &ClassicMode::selectModule ); - connect( d->classicTree, &QAbstractItemView::activated, this, &ClassicMode::changeModule ); - connect( d->classicTree, &QTreeView::collapsed, this, &ClassicMode::expandColumns ); - connect( d->classicTree, &QTreeView::expanded, this, &ClassicMode::expandColumns ); - connect( d->moduleView, &ModuleView::moduleChanged, this, &ClassicMode::moduleLoaded ); - - if( !qApp->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) ) { - // Needed because otherwise activated() is not fired with single click, which is apparently expected for tree views - connect( d->classicTree, &QAbstractItemView::clicked, this, &ClassicMode::changeModule ); - } - - if( config().readEntry( "autoExpandOneLevel", false ) ) { - for( int processed = 0; d->proxyModel->rowCount() > processed; processed++ ) { - d->classicTree->setExpanded( d->proxyModel->index( processed, 0 ), true ); - } - } - - expandColumns(); - QList defaultSizes; - defaultSizes << 250 << 500; - d->classicWidget->setSizes( config().readEntry( "viewLayout", defaultSizes ) ); - emit changeToolBarItems( BaseMode::Search | BaseMode::Configure | BaseMode::Quit ); - d->classicWidget->installEventFilter(this); -} - -bool ClassicMode::eventFilter(QObject* watched, QEvent* event) -{ - if (watched == d->classicWidget && event->type() == QEvent::Show) { - emit changeToolBarItems( BaseMode::Search | BaseMode::Configure | BaseMode::Quit ); - } - return BaseMode::eventFilter(watched, event); -} - -void ClassicMode::leaveModuleView() -{ - d->moduleView->closeModules(); - d->stackedWidget->setCurrentWidget( d->classicCategory ); -} - -void ClassicMode::giveFocus() -{ - d->classicTree->setFocus(); -} - -void ClassicMode::addConfiguration( KConfigDialog * config ) -{ - QWidget * configWidget = new QWidget( config ); - d->classicConfig.setupUi( configWidget ); - config->addPage( configWidget, i18n("Tree View"), QStringLiteral("view-list-tree") ); -} - -void ClassicMode::loadConfiguration() -{ - d->classicConfig.CbExpand->setChecked( config().readEntry( "autoExpandOneLevel", false ) ); -} - -void ClassicMode::saveConfiguration() -{ - config().writeEntry("autoExpandOneLevel", d->classicConfig.CbExpand->isChecked()); -} - -void ClassicMode::moveUp( MenuItem * item ) -{ - foreach( MenuItem * child, item->children() ) { - if( child->children().count() == 1 ) { - d->model->addException( child ); - } - moveUp( child ); - } -} - -#include "ClassicMode.moc" diff --git a/classic/configClassic.ui b/classic/configClassic.ui deleted file mode 100644 --- a/classic/configClassic.ui +++ /dev/null @@ -1,38 +0,0 @@ - - - ConfigClassic - - - - 0 - 0 - 400 - 66 - - - - - - - Expand the first level automatically - - - - - - - Qt::Vertical - - - - 20 - 28 - - - - - - - - - diff --git a/classic/main.html b/classic/main.html deleted file mode 100644 --- a/classic/main.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - -