[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [labplot/thememanager] src: Fixed loading of themes via the context menu.
From:       Alexander Semke <alexander.semke () web ! de>
Date:       2016-07-12 7:26:25
Message-ID: E1bMs5J-00009L-BE () code ! kde ! org
[Download RAW message or body]

Git commit e16d49432ccdc9fc4a689d6367fe82f2102b9335 by Alexander Semke.
Committed on 12/07/2016 at 07:26.
Pushed by asemke into branch 'thememanager'.

Fixed loading of themes via the context menu.

M  +4    -5    src/backend/worksheet/plots/cartesian/CartesianPlot.cpp
M  +10   -13   src/kdefrontend/ThemeHandler.cpp
M  +2    -2    src/kdefrontend/ThemeHandler.h

http://commits.kde.org/labplot/e16d49432ccdc9fc4a689d6367fe82f2102b9335

diff --git a/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp \
b/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp index 99ed64f..830dac9 \
                100644
--- a/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp
+++ b/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp
@@ -439,10 +439,10 @@ void CartesianPlot::initMenus() {
 	zoomMenu->addAction(shiftDownYAction);
 
 	themeMenu = new QMenu(i18n("Apply Theme"));
-	foreach(const QString theme, ThemeHandler::getThemeList())
+	foreach(const QString theme, ThemeHandler::themes())
 		themeMenu->addAction(theme);
 
-	connect(themeMenu, SIGNAL(triggered(QAction* action)), this, \
SLOT(loadTheme(QAction* action))); +	connect(themeMenu, SIGNAL(triggered(QAction*)), \
this, SLOT(loadTheme(QAction*)));  
 }
 
@@ -2093,9 +2093,8 @@ bool CartesianPlot::load(XmlStreamReader* reader) {
 }
 
 void CartesianPlot::loadTheme(QAction* action) {
-	QString themeName = action->data().toString();
-	themeName.append(".txt");
-	emit (triggerLoadTheme(themeName));
+	KConfig config( ThemeHandler::themeConfigPath(action->text().remove('&')), \
KConfig::SimpleConfig ); +	loadThemeConfig(config);
 }
 
 void CartesianPlot::loadThemeConfig(KConfig& config) {
diff --git a/src/kdefrontend/ThemeHandler.cpp b/src/kdefrontend/ThemeHandler.cpp
index 8d175df..97cd6e1 100755
--- a/src/kdefrontend/ThemeHandler.cpp
+++ b/src/kdefrontend/ThemeHandler.cpp
@@ -41,6 +41,7 @@
 #include <KMenu>
 #include <KConfig>
 #include <KConfigGroup>
+
 /*!
   \class ThemeHandler
   \brief Provides a widget with buttons for loading of themes.
@@ -97,8 +98,8 @@ void ThemeHandler::loadSelected(QAction* action) {
 	emit info( i18n("Theme \"%1\" was loaded.", action->text().remove('&')) );
 }
 
-QStringList ThemeHandler::getThemeList() {
-	QStringList pathList = KGlobal::dirs()->findAllResources("data", \
"labplot2/themes/*"); +QStringList ThemeHandler::themes() {
+	const QStringList pathList = KGlobal::dirs()->findAllResources("data", \
"labplot2/themes/*");  QStringList themeList;
 	for(int i = 0; i < pathList.size(); ++i) {
 		QFileInfo fileinfo(pathList.at(i));
@@ -107,16 +108,12 @@ QStringList ThemeHandler::getThemeList() {
 	return themeList;
 }
 
-void ThemeHandler::triggerLoadTheme(QString themeName) {
-	QString name;
-	int i;
-	for(i = 0; i < m_themeList.size(); ++i) {
-		QFileInfo fileinfo(m_themeList.at(i));
-		name = fileinfo.fileName().split('.').at(0);
-		if(name==themeName)
-			break;
+const QString ThemeHandler::themeConfigPath(const QString& name) {
+	const QStringList themes = KGlobal::dirs()->findAllResources("data", \
"labplot2/themes/*"); +	for (int i=0; i<themes.size(); ++i) {
+		if (themes.at(i).indexOf(name + ".txt")!=-1)
+			return themes.at(i);
 	}
 
-	KConfig config(m_themeList.at(i), KConfig::SimpleConfig);
-	emit (loadThemeRequested(config));
-}
+	return QString();
+}
\ No newline at end of file
diff --git a/src/kdefrontend/ThemeHandler.h b/src/kdefrontend/ThemeHandler.h
index d257368..5fbcc3f 100755
--- a/src/kdefrontend/ThemeHandler.h
+++ b/src/kdefrontend/ThemeHandler.h
@@ -43,7 +43,8 @@ class ThemeHandler : public QWidget{
 
 	public:
 		ThemeHandler(QWidget* parent);
-		static QStringList getThemeList();
+		static QStringList themes();
+		static const QString themeConfigPath(const QString&);
 
 	private:
 		QList<QString> dirNames;
@@ -58,7 +59,6 @@ class ThemeHandler : public QWidget{
 	private slots:
 		void loadMenu();
 		void loadSelected(QAction*);
-		void triggerLoadTheme(QString);
 
 	signals:
 		void loadThemeRequested(KConfig& config);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic