Changeset View
Changeset View
Standalone View
Standalone View
core/ModuleView.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 52 | public: | |||
---|---|---|---|---|---|
56 | KPageWidget* mPageWidget = nullptr; | 56 | KPageWidget* mPageWidget = nullptr; | ||
57 | QVBoxLayout* mLayout = nullptr; | 57 | QVBoxLayout* mLayout = nullptr; | ||
58 | QDialogButtonBox* mButtons = nullptr; | 58 | QDialogButtonBox* mButtons = nullptr; | ||
59 | KAuth::ObjectDecorator* mApplyAuthorize = nullptr; | 59 | KAuth::ObjectDecorator* mApplyAuthorize = nullptr; | ||
60 | QPushButton* mApply = nullptr; | 60 | QPushButton* mApply = nullptr; | ||
61 | QPushButton* mReset = nullptr; | 61 | QPushButton* mReset = nullptr; | ||
62 | QPushButton* mDefault = nullptr; | 62 | QPushButton* mDefault = nullptr; | ||
63 | QPushButton* mHelp = nullptr; | 63 | QPushButton* mHelp = nullptr; | ||
64 | QLabel* mHeader = nullptr; | ||||
64 | bool pageChangeSupressed; | 65 | bool pageChangeSupressed; | ||
65 | }; | 66 | }; | ||
66 | 67 | | |||
67 | ModuleView::ModuleView( QWidget * parent ) | 68 | ModuleView::ModuleView( QWidget * parent ) | ||
68 | : QWidget( parent ) | 69 | : QWidget( parent ) | ||
69 | , d( new Private() ) | 70 | , d( new Private() ) | ||
70 | { | 71 | { | ||
71 | // Configure a layout first | 72 | // Configure a layout first | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 170 | if ( !KAuthorized::authorizeControlModule( module->service()->menuId() ) ) { | |||
170 | qWarning() << "Not authorised to load module" ; | 171 | qWarning() << "Not authorised to load module" ; | ||
171 | return; | 172 | return; | ||
172 | } | 173 | } | ||
173 | if( module->service()->noDisplay() ) { | 174 | if( module->service()->noDisplay() ) { | ||
174 | return; | 175 | return; | ||
175 | } | 176 | } | ||
176 | 177 | | |||
177 | // Create the scroller | 178 | // Create the scroller | ||
179 | QWidget *mainWidget = new QWidget( this ); | ||||
davidedmundson: why? | |||||
180 | QVBoxLayout *layout = new QVBoxLayout( mainWidget ); | ||||
181 | layout->setSpacing(0); | ||||
182 | d->mHeader = new QLabel( mainWidget ); | ||||
183 | QFont headerFont = d->mHeader->font(); | ||||
184 | //Emulate the look and size of the header in the QML modules | ||||
185 | headerFont.setPointSize(headerFont.pointSize() * 1.6); | ||||
186 | headerFont.setWeight( QFont::Light ); | ||||
187 | d->mHeader->setFont( headerFont ); | ||||
188 | layout->addWidget(d->mHeader); | ||||
189 | | ||||
178 | QScrollArea * moduleScroll = new QScrollArea( this ); | 190 | QScrollArea * moduleScroll = new QScrollArea( this ); | ||
191 | layout->addWidget(moduleScroll); | ||||
179 | // Prepare the scroll area | 192 | // Prepare the scroll area | ||
180 | moduleScroll->setWidgetResizable( true ); | 193 | moduleScroll->setWidgetResizable( true ); | ||
181 | moduleScroll->setFrameStyle( QFrame::NoFrame ); | 194 | moduleScroll->setFrameStyle( QFrame::NoFrame ); | ||
182 | moduleScroll->viewport()->setAutoFillBackground( false ); | 195 | moduleScroll->viewport()->setAutoFillBackground( false ); | ||
183 | // Create the page | 196 | // Create the page | ||
184 | KPageWidgetItem *page = new KPageWidgetItem( moduleScroll, module->moduleName() ); | 197 | KPageWidgetItem *page = new KPageWidgetItem( mainWidget ); | ||
185 | // Provide information to the users | 198 | // Provide information to the users | ||
186 | 199 | | |||
187 | if( module->service()->hasServiceType(QStringLiteral("SystemSettingsExternalApp")) || // Is it an external app? | 200 | if( module->service()->hasServiceType(QStringLiteral("SystemSettingsExternalApp")) || // Is it an external app? | ||
188 | module->service()->substituteUid() ) { // ...or does it require UID substituion? | 201 | module->service()->substituteUid() ) { // ...or does it require UID substituion? | ||
189 | QWidget * externalWidget = new ExternalAppModule( this, module ); | 202 | QWidget * externalWidget = new ExternalAppModule( this, module ); | ||
190 | moduleScroll->setWidget( externalWidget ); | 203 | moduleScroll->setWidget( externalWidget ); | ||
191 | } else { // It must be a normal module then | 204 | } else { // It must be a normal module then | ||
192 | KCModuleProxy * moduleProxy = new KCModuleProxy( *module, moduleScroll ); | 205 | KCModuleProxy * moduleProxy = new KCModuleProxy( *module, moduleScroll ); | ||
Show All 19 Lines | 219 | { | |||
212 | KCModuleProxy * moduleProxy = d->mPages.value( page ); | 225 | KCModuleProxy * moduleProxy = d->mPages.value( page ); | ||
213 | KCModuleInfo * moduleInfo = d->mModules.value( page ); | 226 | KCModuleInfo * moduleInfo = d->mModules.value( page ); | ||
214 | 227 | | |||
215 | if( !moduleInfo ) { | 228 | if( !moduleInfo ) { | ||
216 | // Seems like we have some form of a race condition going on here... | 229 | // Seems like we have some form of a race condition going on here... | ||
217 | return; | 230 | return; | ||
218 | } | 231 | } | ||
219 | 232 | | |||
220 | page->setHeader( moduleInfo->comment() ); | 233 | //HACK: not much other ways to detect is a qml kcm | ||
davidedmundson: we could add a property on KCModule that KCModuleQml sets | |||||
221 | page->setIcon( QIcon::fromTheme( moduleInfo->icon() ) ); | 234 | if (moduleProxy->realModule()->inherits("KCModuleQml")) { | ||
222 | if( light ) { | 235 | d->mHeader->setVisible( false ); | ||
223 | return; | 236 | } else { | ||
224 | } | 237 | d->mHeader->setText(moduleInfo->comment()); | ||
225 | 238 | d->mHeader->setVisible( true ); | |||
226 | if( moduleProxy && moduleProxy->realModule()->useRootOnlyMessage() ) { | | |||
227 | page->setHeader( moduleInfo->comment() + QStringLiteral("<br><small>") + moduleProxy->realModule()->rootOnlyMessage() + QStringLiteral("</small>") ); | | |||
228 | page->setIcon( KDE::icon( moduleInfo->icon(), QStringList() << QStringLiteral("dialog-warning") ) ); | | |||
229 | } | 239 | } | ||
230 | } | 240 | } | ||
231 | 241 | | |||
232 | bool ModuleView::resolveChanges() | 242 | bool ModuleView::resolveChanges() | ||
233 | { | 243 | { | ||
234 | KCModuleProxy * currentProxy = d->mPages.value( d->mPageWidget->currentPage() ); | 244 | KCModuleProxy * currentProxy = d->mPages.value( d->mPageWidget->currentPage() ); | ||
235 | return resolveChanges(currentProxy); | 245 | return resolveChanges(currentProxy); | ||
236 | } | 246 | } | ||
▲ Show 20 Lines • Show All 203 Lines • Show Last 20 Lines |
why?