Commit 24f4c6f9 authored by Marco Martin's avatar Marco Martin

Kill the KinfoCenter binary

Summary:
Remove the binary, only install the modules and categories.
The categories have been reorganized a bit to be compatible with SystemSettings
Depends from D26895

Test Plan: {F7930949}

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: ngraham, broulik, davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26896
parent 5a5f32ea
......@@ -81,8 +81,6 @@ endif()
ecm_find_qmlmodule(org.kde.kirigami 2.5)
configure_file(config-project-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-project-version.h)
configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_KEYWORDS)
......@@ -97,38 +95,6 @@ add_subdirectory( Modules )
include(ECMOptionalAddSubdirectory)
ecm_optional_add_subdirectory( doc )
include_directories( ToolTips )
set( kinfocenter_SRCS
infocenter.cpp
main.cpp
sidepanel.cpp
kcmcontainer.cpp
kcmtreeitem.cpp
kcmcategoryitem.cpp
infokcmmodel.cpp
infokcmproxymodel.cpp
ToolTips/tooltipmanager.cpp
)
add_executable( kinfocenter ${kinfocenter_SRCS} )
target_compile_definitions(kinfocenter PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}")
target_link_libraries( kinfocenter
KF5::Completion
KF5::ConfigWidgets
KF5::CoreAddons
KF5::Crash
KF5::DBusAddons
KF5::I18n
KF5::IconThemes
KF5::KCMUtils
KF5::Service
KF5::Solid
KF5::WidgetsAddons
KF5::WindowSystem
KF5::XmlGui
)
# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
......@@ -136,9 +102,12 @@ kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
##install
install( TARGETS kinfocenter ${INSTALL_TARGETS_DEFAULT_ARGS} )
install( FILES org.kde.kinfocenter.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
install( PROGRAMS org.kde.kinfocenter.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
install( FILES kinfocenterui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/kinfocenter )
ADD_CUSTOM_TARGET(kinfocenter_link ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${KDE_INSTALL_FULL_BINDIR}/systemsettings5 ${CMAKE_CURRENT_BINARY_DIR}/kinfocenter)
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/kinfocenter DESTINATION ${KDE_INSTALL_FULL_BINDIR}/ )
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
install( FILES kinfocentercategory.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
install( FILES deviceinfocategory.desktop graphicalinfocategory.desktop networkinfocategory.desktop lostfoundcategory.desktop
install( FILES deviceinfocategory.desktop graphicalinfocategory.desktop networkinfocategory.desktop lostfoundcategory.desktop basicinformation.desktop detailedinformation.desktop
DESTINATION ${SERVICES_INSTALL_DIR} )
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KInfoCenterCategory
X-KDE-KInfoCenter-Category=basic_information
Icon=dialog-information
Name=Basic Information
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KInfoCenterCategory
X-KDE-KInfoCenter-Category=detailed_information
Icon=dialog-information
Name=Detailed Information
......@@ -2,9 +2,10 @@
Type=Service
X-KDE-ServiceTypes=KInfoCenterCategory
X-KDE-KInfoCenter-Category=device_information
X-KDE-KInfoCenter-Parent-Category=detailed_information
Icon=hwinfo
Name=Device Information
Name=Devices
Name[ar]=معلومات الأجهزة
Name[be@latin]=Źviestki z pryłady
Name[bg]=Данни за устройства
......
......@@ -2,9 +2,10 @@
Type=Service
X-KDE-ServiceTypes=KInfoCenterCategory
X-KDE-KInfoCenter-Category=graphical_information
X-KDE-KInfoCenter-Parent-Category=detailed_information
Icon=applications-graphics
Name=Graphical Information
Name=Graphics
Name[ar]=المعلومات الرّسوميّة
Name[bg]=Данни за графичната система
Name[bs]=Podaci o grafici
......
......@@ -65,4 +65,5 @@ Name[zh_TW]=KInfoCenter 類別
# Cat Ident
[PropertyDef::X-KDE-KInfoCenter-Category]
Type=QString
[PropertyDef::X-KDE-KInfoCenter-Parent-Category]
Type=QString
......@@ -2,9 +2,10 @@
Type=Service
X-KDE-ServiceTypes=KInfoCenterCategory
X-KDE-KInfoCenter-Category=network_information
X-KDE-KInfoCenter-Parent-Category=detailed_information
Icon=preferences-system-network
Name=Network Information
Name=Network
Name[ar]=معلومات الشّبكة
Name[bg]=Мрежови данни
Name[bs]=Podaci o mreži
......
......@@ -8,6 +8,7 @@ X-KDE-ServiceTypes=KCModule
X-KDE-ParentApp=kinfocenter
X-KDE-PluginKeyword=kcm-about-distro
X-KDE-System-Settings-Parent-Category=system-administration
X-KDE-KInfoCenter-Category=basic_information
X-KDE-Weight=0
X-KDE-Keywords=about,info,information,distribution,distro,system,kernel,qt,kde
X-KDE-Keywords[ca]=quant a,info,informació,distribució,distro,sistema,nucli,qt,kde
......
......@@ -5,8 +5,9 @@ Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_energyinfo
X-KDE-ParentApp=kinfocenter
X-KDE-KInfoCenter-Category=basic_information
Name=Energy Information
Name=Energy
Name[ar]=معلومات عن الطّاقة
Name[ca]=Informació de l'energia
Name[ca@valencia]=Informació de l'energia
......
......@@ -5,6 +5,7 @@ Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_fileindexermonitor
X-KDE-ParentApp=kinfocenter
X-KDE-KInfoCenter-Category=basic_information
Name=File Indexer Monitor
Name[ar]=مرقاب مفهرس الملفّات
......
......@@ -7,6 +7,7 @@ X-KDE-ServiceTypes=KCModule
X-KDE-Weight=1
X-KDE-Library=kcm_memory
X-KDE-ParentApp=kinfocenter
X-KDE-KInfoCenter-Category=basic_information
X-DocPath=kinfocenter/index.html#kcm_memory
Name=Memory
......
/*******************************************************************************
* Copyright (C) 2008 by Konstantin Heil <konst.heil@stud.uni-heidelberg.de> *
* *
* 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 "tooltipmanager.h"
#include "kcmtreeitem.h"
#include "sidepanel.h"
#include <QRect>
#include <QLabel>
#include <QTimer>
#include <QScrollBar>
#include <QGridLayout>
#include <QApplication>
#include <QAbstractItemView>
#include <QStyle>
#include <QIcon>
#include <KIconLoader>
#include <KColorScheme>
#include <KToolTipWidget>
class IconLoaderSingleton
{
public:
IconLoaderSingleton() = default;
KIconLoader self;
};
Q_GLOBAL_STATIC(IconLoaderSingleton, privateIconLoaderSelf)
class ToolTipManager::Private
{
public:
KToolTipWidget *tooltip = nullptr;
QAbstractItemView* view = nullptr;
QTimer* timer = nullptr;
QModelIndex item;
QRect itemRect;
int delay = QApplication::style()->styleHint(QStyle::SH_ToolTip_WakeUpDelay);
};
ToolTipManager::ToolTipManager(QAbstractItemView* parent)
: QObject(parent)
, d(new ToolTipManager::Private)
{
d->view = parent;
d->tooltip = new KToolTipWidget(d->view);
d->tooltip->setHideDelay(0);
connect(parent, &QAbstractItemView::viewportEntered, this, &ToolTipManager::hideToolTip);
connect(parent, &QAbstractItemView::entered, this, &ToolTipManager::requestToolTip);
d->timer = new QTimer(this);
d->timer->setSingleShot(true);
connect(d->timer, &QTimer::timeout, this, &ToolTipManager::prepareToolTip);
// When the mousewheel is used, the items don't get a hovered indication
// (Qt-issue #200665). To assure that the tooltip still gets hidden,
// the scrollbars are observed.
connect(parent->horizontalScrollBar(), &QAbstractSlider::valueChanged, this, &ToolTipManager::hideToolTip);
connect(parent->verticalScrollBar(), &QAbstractSlider::valueChanged, this, &ToolTipManager::hideToolTip);
d->view->viewport()->installEventFilter(this);
}
ToolTipManager::~ToolTipManager()
{
delete d;
}
bool ToolTipManager::eventFilter(QObject* watched, QEvent* event)
{
if ( watched == d->view->viewport() ) {
switch ( event->type() ) {
case QEvent::Leave:
case QEvent::MouseButtonPress:
hideToolTip();
break;
case QEvent::ToolTip:
return true;
default:
break;
}
}
return QObject::eventFilter(watched, event);
}
void ToolTipManager::requestToolTip(const QModelIndex& index)
{
// only request a tooltip for the name column and when no selection or
// drag & drop operation is done (indicated by the left mouse button)
if ( !(QApplication::mouseButtons() & Qt::LeftButton) ) {
d->tooltip->hide();
d->itemRect = d->view->visualRect(index);
const QPoint pos = d->view->viewport()->mapToGlobal(d->itemRect.topLeft());
d->itemRect.moveTo(pos);
d->item = index;
d->timer->start(d->delay);
} else {
hideToolTip();
}
}
void ToolTipManager::hideToolTip()
{
d->timer->stop();
d->tooltip->hideLater();
}
void ToolTipManager::prepareToolTip()
{
showToolTip( d->item );
}
void ToolTipManager::showToolTip( const QModelIndex& menuItem )
{
if (QApplication::mouseButtons() & Qt::LeftButton) {
return;
}
QWidget * tip = createTipContent( menuItem );
connect(d->tooltip, &KToolTipWidget::hidden, tip, &QObject::deleteLater);
d->tooltip->showBelow(d->itemRect, tip, d->view->nativeParentWidget()->windowHandle());
}
QWidget * ToolTipManager::createTipContent( const QModelIndex& item )
{
QWidget * tipContent = new QWidget();
QGridLayout* tipLayout = new QGridLayout();
QLayout * primaryLine = generateToolTipLine( item, tipContent, QSize(32,32), true );
tipLayout->addLayout( primaryLine, 0, 0 );
for ( int done = 0; d->view->model()->rowCount( item ) > done; done = 1 + done ) {
QModelIndex childItem = d->view->model()->index( done, 0, item );
QLayout * subLine = generateToolTipLine( childItem, tipContent, QSize(24,24), false );
tipLayout->addLayout( subLine, done + 2, 0 );
}
tipLayout->setVerticalSpacing( 0 );
tipContent->setLayout( tipLayout );
if( d->view->model()->rowCount( item ) > 0 ) {
QFrame * separatorLine = new QFrame( tipContent );
separatorLine->setFrameStyle( QFrame::HLine );
tipLayout->addWidget( separatorLine, 1, 0 );
}
return tipContent;
}
QLayout * ToolTipManager::generateToolTipLine( const QModelIndex & item, QWidget * toolTip, const QSize& iconSize, bool comment )
{
SidePanel *sidePanel = static_cast<SidePanel*>(d->view);
KcmTreeItem *menuItem = static_cast<KcmTreeItem*>( sidePanel->mapToProxySource(item).internalPointer() );
QString text = menuItem->data();
if ( comment ) {
text = QStringLiteral( "<b>%1</b>" ).arg( menuItem->data() );
}
QLabel * textLabel = new QLabel( toolTip );
textLabel->setForegroundRole(QPalette::ToolTipText);
textLabel->setText( text );
// Get icon
QPalette pal = textLabel->palette();
for (auto state : { QPalette::Active, QPalette::Inactive, QPalette::Disabled }) {
pal.setBrush(state, QPalette::WindowText, pal.toolTipText());
pal.setBrush(state, QPalette::Window, pal.toolTipBase());
}
privateIconLoaderSelf->self.setCustomPalette(pal);
QIcon icon = KDE::icon(menuItem->iconName(), &privateIconLoaderSelf->self);
QLabel * iconLabel = new QLabel( toolTip );
iconLabel->setPixmap( icon.pixmap(iconSize) );
iconLabel->setMaximumSize( iconSize );
// Generate layout
QHBoxLayout * layout = new QHBoxLayout();
layout->addWidget( iconLabel );
layout->addWidget( textLabel );
return layout;
}
/*******************************************************************************
* Copyright (C) 2008 by Konstantin Heil <konst.heil@stud.uni-heidelberg.de> *
* *
* 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 TOOLTIPMANAGER_H
#define TOOLTIPMANAGER_H
#include <QObject>
#include <QModelIndex>
class QLayout;
class QAbstractItemView;
/**
* @brief Manages the tooltips for an item view.
*
* When hovering an item, a tooltip is shown after
* a short timeout. The tooltip is hidden again when the
* viewport is hovered or the item view has been left.
*/
class ToolTipManager : public QObject
{
Q_OBJECT
public:
/**
* Standard constructor. The ToolTipManager will start handling ToolTip events on the provided
* view immediately.
*
* @param parent The view which will have the tooltips displayed for.
*/
explicit ToolTipManager(QAbstractItemView* parent);
~ToolTipManager() override;
public Q_SLOTS:
/**
* Hides the currently shown tooltip. Invoking this method is
* only needed when the tooltip should be hidden although
* an item is hovered.
*/
void hideToolTip();
protected:
/**
* Please see the Qt documentation for more details.
*
* @param watched The object that was being watched.
* @param event The event object.
* @returns true if the event was handled in this filter, or false if it was not.
*/
bool eventFilter( QObject* watched, QEvent* event ) override;
private Q_SLOTS:
void prepareToolTip();
void requestToolTip(const QModelIndex& index);
private:
void showToolTip( const QModelIndex& menuItem );
QWidget * createTipContent( const QModelIndex& item );
QLayout * generateToolTipLine( const QModelIndex& item, QWidget * toolTip, const QSize& iconSize, bool comment );
class Private;
ToolTipManager::Private* d;
};
#endif
/* Set to 1 if you have X11 at all */
#cmakedefine01 HAVE_X11
#define PROJECT_VERSION "${PROJECT_VERSION}"
/*
* infocenter.cpp
*
* Copyright (C) 2010 David Hubner <hubnerd@ntlworld.com>
*
* 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.
*
*/
//Local
#include "infocenter.h"
//KDE
#include <KLocalizedString>
#include <QIcon>
#include <KConfig>
#include <KToolInvocation>
#include <KActionMenu>
#include <kxmlguifactory.h>
#include <KStandardAction>
#include <KActionCollection>
#include <KAboutApplicationDialog>
#include <KMessageBox>
#include <KToolBar>
//QT
#include <QUrl>
#include <QProcess>
#include <QTextStream>
#include <QFile>
#include <QKeySequence>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QMenuBar>
KInfoCenter::KInfoCenter() : KXmlGuiWindow( 0, Qt::WindowContextHelpButtonHint )
{
setWindowIcon(QIcon::fromTheme(QStringLiteral("hwinfo")));
setWindowTitle(i18nc("Main window title", "KInfocenter"));
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setMinimumWidth(800);
setMinimumHeight(600);
m_cWidget = new QWidget(this);
setCentralWidget(m_cWidget);
QVBoxLayout *cLayout = new QVBoxLayout(m_cWidget);
cLayout->setSpacing(0);
cLayout->setContentsMargins(0, 0, 0, 0);
createMainFrame();
createToolBar();
//TreeWidget
connect(m_sideMenu,SIGNAL(clicked(const KcmTreeItem*)),this,SLOT(itemClickedSlot(const KcmTreeItem*)));
//SearchBox
connect(m_searchText, &QLineEdit::textChanged, m_sideMenu, &SidePanel::filterSideMenuSlot);
connect(m_searchAction, SIGNAL(triggered()),m_searchText,SLOT(setFocus()));
//Buttons
connect(m_moduleHelpAction, &QAction::triggered,this,&KInfoCenter::helpClickedSlot);
//Menu
connect(m_aboutKcm, &QAction::triggered, this, &KInfoCenter::aboutKcmSlot);
//Startup
m_searchText->completionObject()->setItems(m_sideMenu->allChildKeywords());
m_sideMenu->setFocus(Qt::OtherFocusReason);
m_sideMenu->changeToFirstValidItem();
m_toolTips = new ToolTipManager(m_sideMenu);
setupGUI(QSize(800,600), ToolBar | Keys | Save | Create, QStringLiteral("kinfocenterui.rc"));
delete m_helpAction->menu();
m_helpAction->setMenu( dynamic_cast<QMenu*>( factory()->container(QStringLiteral("help"), this) ) );
menuBar()->hide();
QAction *aboutApp = actionCollection()->action(QStringLiteral("help_about_app"));
aboutApp->setIcon(QIcon::fromTheme(QStringLiteral("hwinfo")));
}
KInfoCenter::~KInfoCenter()
{
delete m_toolTips;
//TreeWidget
disconnect(m_sideMenu,SIGNAL(clicked(const KcmTreeItem*)),this,SLOT(itemClickedSlot(const KcmTreeItem*)));
//SearchBox
disconnect(m_searchText, &QLineEdit::textChanged, m_sideMenu, &SidePanel::filterSideMenuSlot);
disconnect(m_searchAction, SIGNAL(triggered()),m_searchText, SLOT(setFocus()));
//Buttons
disconnect(m_moduleHelpAction, &QAction::triggered, this, &KInfoCenter::helpClickedSlot);
//Menu
disconnect(m_aboutKcm, &QAction::triggered, this, &KInfoCenter::aboutKcmSlot);
}
bool KInfoCenter::eventFilter(QObject *watched, QEvent *event)
{
if (watched == m_sideMenu && event->type() == QEvent::Move) {
m_contain->setKcmTopEdge(m_sideMenu->y());
}
return false;
}
void KInfoCenter::createToolBar()
{
KStandardAction::quit(this, &KInfoCenter::close, actionCollection());
KStandardAction::keyBindings(guiFactory(), SLOT(configureShortcuts()), actionCollection());
toolBar()->setMovable(false);
m_aboutKcm = actionCollection()->addAction(QStringLiteral("help_about_module"));
m_aboutKcm->setText(i18nc("Information about current module located in about menu","About Current Information Module"));
m_aboutKcm->setIcon(QIcon::fromTheme(QStringLiteral("help-about")));
m_aboutKcm->setEnabled(false);
m_moduleHelpAction = new QAction(this);
m_moduleHelpAction->setText(i18nc("Module help button label", "Module Help"));
m_moduleHelpAction->setIcon(QIcon::fromTheme(QStringLiteral("help-contextual")));
m_helpAction = new KActionMenu( QIcon::fromTheme(QStringLiteral("help-contents")), i18nc("Help button label","Help"), this );
m_helpAction->setDelayed( false );
actionCollection()->addAction(QStringLiteral("helpModule"), m_moduleHelpAction);
actionCollection()->addAction(QStringLiteral("helpMenu"), m_helpAction);
}
void KInfoCenter::createMainFrame()
{
QWidget *mainDisplay = new QWidget();
mainDisplay->setContentsMargins(0,0,0,0);
QHBoxLayout *mainLayout = new QHBoxLayout(mainDisplay);
m_splitter = new QSplitter(m_cWidget);
m_splitter->setContentsMargins(0, 0, 0, 0);
m_splitter->setHandleWidth(5);
mainLayout->addWidget(m_splitter);
createMenuFrame();
m_contain = new KcmContainer(m_splitter);
m_splitter->addWidget(m_contain);
m_splitter->setStretchFactor(0, 0);
m_splitter->setStretchFactor(1, 1);
m_cWidget->layout()->addWidget(mainDisplay);
}
void KInfoCenter::createMenuFrame()
{
QWidget *sideFrame = new QWidget(m_splitter);
sideFrame->setContentsMargins(0,0,0,0);
QVBoxLayout *menuLayout = new QVBoxLayout(sideFrame);
menuLayout->setContentsMargins(0, 0, 0, 0);
m_searchText = new KLineEdit(sideFrame);
m_searchText->setClearButtonEnabled(true);
m_searchText->setPlaceholderText( i18nc( "Search Bar Click Message", "Search" ) );
m_searchText->setCompletionMode( KCompletion::CompletionPopup );
m_searchText->completionObject()->setIgnoreCase(true);
m_searchAction = new QAction(this);
m_searchAction->setText(i18nc("Kaction search label", "Search Modules"));
m_searchAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-find")));
actionCollection()->addAction(QStringLiteral("search"),m_searchAction);
actionCollection()->setDefaultShortcut(m_searchAction, QKeySequence(Qt::CTRL + Qt::Key_F));
m_sideMenu = new SidePanel(sideFrame);
m_sideMenu->installEventFilter(this);
connect(m_sideMenu, &SidePanel::clearSearchLine, this, &KInfoCenter::clearSearchLine);
menuLayout->addWidget(m_searchText);
menuLayout->addWidget(m_sideMenu);
m_splitter->addWidget(sideFrame);
}
void KInfoCenter::clearSearchLine()
{
m_searchText->clear();
}
void KInfoCenter::itemClickedSlot(const KcmTreeItem *item)
{
if (item != m_kcmItem) {
resetCondition();
if(item->type() != KcmTreeItem::CATEGORY) {
setKcm(item);
}
}
m_kcmItem = item;
}
void KInfoCenter::setKcm(const KcmTreeItem *kcmItem)