diff --git a/kstyle/demo/oxygenschemechooser.cpp b/kstyle/demo/oxygenschemechooser.cpp index 1d5e2f13..acdaec2d 100644 --- a/kstyle/demo/oxygenschemechooser.cpp +++ b/kstyle/demo/oxygenschemechooser.cpp @@ -1,81 +1,53 @@ /************************************************************************************* * This file was part of KDevPlatform and now of Oxygen * * Copyright 2016 Zhigalin Alexander * * Copyright 2017 René J.V. Bertin * * * * This library 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) version 3, or any * * later version accepted by the membership of KDE e.V. (or its * * successor approved by the membership of KDE e.V.), which shall * * act as a proxy defined in Section 6 of version 3 of the license. * * * * This library 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 library. If not, see . * *************************************************************************************/ #include "oxygenschemechooser.h" #include #include #include #include #include #include #include #include #include #include namespace Oxygen { ColorSchemeChooser::ColorSchemeChooser( QWidget* parent ) : QPushButton( parent ) { auto manager = new KColorSchemeManager( parent ); - const auto scheme( currentSchemeName() ); - - auto selectionMenu = manager->createSchemeSelectionMenu( scheme, this ); - - manager->activateScheme(manager->indexForScheme(scheme)); + auto selectionMenu = manager->createSchemeSelectionMenu(this); setMenu( selectionMenu->menu() ); - menu()->setIcon( QIcon::fromTheme( QStringLiteral( "preferences-desktop-color" ) ) ); - menu()->setTitle( i18n( "&Color Theme" ) ); + setIcon( menu()->icon() ); setText( menu()->title() ); } -QString ColorSchemeChooser::currentDesktopDefaultScheme() const -{ - KSharedConfigPtr config = KSharedConfig::openConfig( QLatin1String( "kdeglobals" ) ); - KConfigGroup group( config, "General" ); - return group.readEntry( "ColorScheme", QStringLiteral( "Breeze" ) ); -} - -QString ColorSchemeChooser::currentSchemeName() const -{ - if ( !menu() ) - { - return currentDesktopDefaultScheme(); - } - - QAction* const action = menu()->activeAction(); - - if ( action ) - { - return KLocalizedString::removeAcceleratorMarker( action->text() ); - } - return currentDesktopDefaultScheme(); -} - } // namespace Oxygen diff --git a/kstyle/demo/oxygenschemechooser.h b/kstyle/demo/oxygenschemechooser.h index 3176e37e..9d9ab32e 100644 --- a/kstyle/demo/oxygenschemechooser.h +++ b/kstyle/demo/oxygenschemechooser.h @@ -1,51 +1,46 @@ /************************************************************************************* * This file was part of KDevPlatform and now of Oxygen * * Copyright 2016 Zhigalin Alexander * * * * This library 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) version 3, or any * * later version accepted by the membership of KDE e.V. (or its * * successor approved by the membership of KDE e.V.), which shall * * act as a proxy defined in Section 6 of version 3 of the license. * * * * This library 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 library. If not, see . * *************************************************************************************/ #ifndef COLORSCHEMECHOOSER_H #define COLORSCHEMECHOOSER_H #include #include #include #include namespace Oxygen { /** * Provides a menu that will offer to change the color scheme * * Furthermore, it will save the selection in the user configuration. */ class ColorSchemeChooser : public QPushButton { Q_OBJECT public: explicit ColorSchemeChooser( QWidget* parent ); - - QString currentSchemeName() const; - - private: - QString currentDesktopDefaultScheme() const; }; } // namespace Oxygen #endif // COLORSCHEMECHOOSER_H