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

List:       kde-commits
Subject:    [labplot/thememanager] src: Created 'Publish Theme' button + cleaned code
From:       Prakriti Bhardwaj <prakritibhrdwj () gmail ! com>
Date:       2016-08-20 18:17:50
Message-ID: E1bbAq6-0002WC-CU () code ! kde ! org
[Download RAW message or body]

Git commit 6885791e4d0b49a629efa50c602e3d801f29b919 by Prakriti Bhardwaj.
Committed on 20/08/2016 at 18:09.
Pushed by prakritibhardwaj into branch 'thememanager'.

Created 'Publish Theme' button + cleaned code

M  +1    -1    src/CMakeLists.txt
M  +36   -12   src/kdefrontend/ThemeHandler.cpp
M  +2    -5    src/kdefrontend/ThemeHandler.h
M  +15   -55   src/kdefrontend/widgets/ThemesWidget.cpp
M  +0    -1    src/kdefrontend/widgets/ThemesWidget.h
M  +1    -1    src/themes/CMakeLists.txt
R  +0    -0    src/themes/labplot2_themes.knsrc [from: src/themes/labplot2.knsrc - \
100% similarity]

http://commits.kde.org/labplot/6885791e4d0b49a629efa50c602e3d801f29b919

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 21f9d3c..92c3a35 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -230,7 +230,7 @@ set(LABPLOT_SRCS ${GUI_SOURCES} ${PLOTS_SOURCES})
 INCLUDE_DIRECTORIES(. ${GSL_INCLUDE_DIR} ${GSL_INCLUDEDIR}/..)
 kde4_add_ui_files(LABPLOT_SRCS ${UI_SOURCES})
 kde4_add_executable(labplot2 ${LABPLOT_SRCS} ${BACKEND_SOURCES} \
                ${DATASOURCES_SOURCES} ${COMMONFRONTEND_SOURCES} ${TOOLS_SOURCES})
-target_link_libraries(labplot2 ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${GSL_LIBRARIES} \
${GSL_CBLAS_LIBRARIES} ${HDF5_LIBRARY} ${NETCDF_LIBRARY} ${FFTW_LIBRARIES} \
${KDE4_KNEWSTUFF3_LIBS}) +target_link_libraries(labplot2 ${KDE4_KDEUI_LIBS} \
${KDE4_KIO_LIBS} ${GSL_LIBRARIES} ${GSL_CBLAS_LIBRARIES} ${HDF5_LIBRARY} \
${NETCDF_LIBRARY} ${FFTW_LIBRARIES} ${KDE4_KTEXTEDITOR_LIBS} ${KDE4_KNEWSTUFF3_LIBS}) \
# ${OPJ_LIBRARY}  
 ############## installation ################################
diff --git a/src/kdefrontend/ThemeHandler.cpp b/src/kdefrontend/ThemeHandler.cpp
index 662e06a..fd83002 100755
--- a/src/kdefrontend/ThemeHandler.cpp
+++ b/src/kdefrontend/ThemeHandler.cpp
@@ -43,6 +43,14 @@
 #include <KConfig>
 #include <KConfigGroup>
 
+#include <KMessageBox>
+#include <knewstuff3/uploaddialog.h>
+//#include <kapplication.h>
+#include <kdebug.h>
+//#include <klocale.h>
+//#include <kcmdlineargs.h>
+//#include <kaboutdata.h>
+
 /*!
   \class ThemeHandler
   \brief Provides a widget with buttons for loading of themes.
@@ -64,13 +72,17 @@ ThemeHandler::ThemeHandler(QWidget* parent) : QWidget(parent) {
 	pbSaveTheme = new QPushButton(this);
 	horizontalLayout->addWidget(pbSaveTheme);
 	pbSaveTheme->setText("Save theme");
-	this->saveThemeEnable(true);
+
+	pbPublishTheme = new QPushButton(this);
+	horizontalLayout->addWidget(pbPublishTheme);
+	pbPublishTheme->setText("Publish theme");
 
 	QSpacerItem* horizontalSpacer2 = new QSpacerItem(10, 20, QSizePolicy::Fixed, \
QSizePolicy::Minimum);  horizontalLayout->addItem(horizontalSpacer2);
 
 	connect( pbLoadTheme, SIGNAL(clicked()), this, SLOT(showPanel()));
 	connect( pbSaveTheme, SIGNAL(clicked()), this, SLOT(saveMenu()));
+	connect( pbPublishTheme, SIGNAL(clicked()), this, SLOT(publishThemes()));
 
 	m_themeList = KGlobal::dirs()->findAllResources("data", \
"labplot2/themes/theme_files/*");  \
m_themeList.append(KGlobal::dirs()->findAllResources("appdata", "themes/local/*")); \
@@ -158,18 +170,30 @@ void ThemeHandler::saveNewSelected(const QString& filename) {  \
emit info( i18n("New theme \"%1\" was saved.", filename) );  }
 
-void ThemeHandler::saveDefaults() {
-	KConfig config;
-	emit (saveThemeRequested(config));
-	emit info( i18n("New default theme was saved.") );
-}
+void ThemeHandler::publishThemes() {
+	QStringList localThemeFiles = KGlobal::dirs()->findAllResources("appdata", \
"themes/local/*");  
-void ThemeHandler::saveThemeEnable(bool enable) {
-	pbSaveTheme->setEnabled(enable);
-}
+	int ret = KMessageBox::questionYesNo(this,
+					     i18n("Do you want to upload your themes to public web server?"),
+					     i18n("Question - Labplot"));
+	if (ret != KMessageBox::Yes) return;
 
-QStringList ThemeHandler::getLocalThemes() {
 
-	QStringList list = KGlobal::dirs()->findAllResources("appdata", "themes/local/*");
-	return list;
+	// creating upload dialog
+
+	if(!localThemeFiles.empty()) {
+		foreach(QString fileName, localThemeFiles) {
+			KNS3::UploadDialog dialog("labplot2_themes.knsrc", this);
+			qDebug()<<"uploading file "<<fileName;
+			dialog.setUploadFile(fileName);
+			dialog.exec();
+		}
+	}
+	else {
+		ret = KMessageBox::warningContinueCancel(this,
+							 i18n("There are no locally saved themes to be uploaded. Please create new \
themes."), +							 i18n("Warning - Labplot"),  KStandardGuiItem::ok());
+		if (ret != KMessageBox::Continue) return;
+	}
+
 }
diff --git a/src/kdefrontend/ThemeHandler.h b/src/kdefrontend/ThemeHandler.h
index 1530545..7124a65 100755
--- a/src/kdefrontend/ThemeHandler.h
+++ b/src/kdefrontend/ThemeHandler.h
@@ -42,7 +42,6 @@ class ThemeHandler : public QWidget {
 		ThemeHandler(QWidget* parent);
 		static QStringList themes();
 		static const QString themeConfigPath(const QString&);
-		QStringList getLocalThemes();
 
 	private:
 		QList<QString> dirNames;
@@ -50,16 +49,14 @@ class ThemeHandler : public QWidget {
 
 		QPushButton* pbLoadTheme;
 		QPushButton* pbSaveTheme;
+		QPushButton* pbPublishTheme;
 
 	private slots:
 		void loadSelected(QString);
 		void showPanel();
 		void saveMenu();
 		void saveNewSelected(const QString&);
-		void saveDefaults();
-
-	public slots:
-		void saveThemeEnable(bool);
+		void publishThemes();
 
 	signals:
 		void loadThemeRequested(KConfig&);
diff --git a/src/kdefrontend/widgets/ThemesWidget.cpp \
b/src/kdefrontend/widgets/ThemesWidget.cpp index ef6bae4..4141dc9 100644
--- a/src/kdefrontend/widgets/ThemesWidget.cpp
+++ b/src/kdefrontend/widgets/ThemesWidget.cpp
@@ -35,11 +35,7 @@
 #include <KStandardDirs>
 
 #include <KMessageBox>
-#include <knewstuff3/uploaddialog.h>
-#include <kapplication.h>
 #include <kdebug.h>
-#include <klocale.h>
-#include <kcmdlineargs.h>
 #include <kaboutdata.h>
 #include <knewstuff3/downloaddialog.h>
 
@@ -77,20 +73,13 @@ ThemesWidget::ThemesWidget(QWidget* parent) : QListView(parent) {
 		listItem->setData(themeList.at(i), Qt::UserRole);
 		mContentItemModel->appendRow(listItem);
 	}
-	//adding upload themes option in list
-	QStandardItem* listItem1 = new QStandardItem();
-	tempPath = themeImgPath+"Unavailable.png";
-	listItem1->setIcon(QIcon(QPixmap(tempPath)));
-	listItem1->setText("Publish Themes");
-	listItem1->setData("file_publish_theme", Qt::UserRole);
-	mContentItemModel->appendRow(listItem1);
-
-	//adding download themes option in list
-	QStandardItem* listItem2 = new QStandardItem();
-	listItem2->setIcon(QIcon(QPixmap(tempPath)));
-	listItem2->setText("Download Themes");
-	listItem2->setData("file_download_theme", Qt::UserRole);
-	mContentItemModel->appendRow(listItem2);
+
+	//adding download themes option
+	QStandardItem* listItem = new QStandardItem();
+	listItem->setIcon(QIcon::fromTheme("get-hot-new-stuff"));
+	listItem->setText("Download Themes");
+	listItem->setData("file_download_theme", Qt::UserRole);
+	mContentItemModel->appendRow(listItem);
 
 	setModel(mContentItemModel);
 
@@ -101,51 +90,22 @@ ThemesWidget::ThemesWidget(QWidget* parent) : QListView(parent) \
{  
 void ThemesWidget::applyClicked() {
 	QString themeName = currentIndex().data(Qt::UserRole).value<QString>();
-	if(themeName=="file_publish_theme")
-		this->publishThemes();
-	else if(themeName=="file_download_theme")
+	if(themeName=="file_download_theme")
 		this->downloadThemes();
 	else
 		emit(themeSelected(themeName));
 }
 
-void ThemesWidget::publishThemes() {
-	this->parentWidget()->close();
-	QStringList localThemeFiles = KGlobal::dirs()->findAllResources("appdata", \
                "themes/local/*");
-
-	int ret = KMessageBox::questionYesNo(this->parentWidget(),
-					     i18n("Do you want to upload your themes to public web server?"),
-					     i18n("Question - Labplot"));
-	if (ret != KMessageBox::Yes) return;
-
-
-	// upload
-
-	if(!localThemeFiles.empty()) {
-		foreach(QString fileName, localThemeFiles) {
-			qDebug()<<"uploading file "<<fileName;
-			KNS3::UploadDialog dialog("labplot2.knsrc", this);
-			dialog.setUploadFile(KUrl(fileName));
-			dialog.exec();
-		}
-	}
-	else {
-		ret = KMessageBox::warningContinueCancel(this,
-							 i18n("There are no locally saved themes to be uploaded. Please create new \
                themes."),
-							 i18n("Warning - Labplot"),  KStandardGuiItem::ok());
-		if (ret != KMessageBox::Continue) return;
-	}
-
-
-}
 
 void ThemesWidget::downloadThemes() {
 	this->parentWidget()->close();
-	KNS3::DownloadDialog dialog;
+	KAboutData about("khotnewstuff", 0, ki18n("KHotNewStuff"), "0.4");
+	about.setProgramIconName("get-hot-new-stuff");
+
+	KNS3::DownloadDialog dialog("labplot2_themes.knsrc", this);
 	dialog.exec();
-//	foreach (const KNS3::Entry& e,  dialog.changedEntries())
-//	{
-//	    qDebug() << "Changed Entry: " << e.name();
-//	}
+	foreach (const KNS3::Entry& e, dialog.changedEntries()) {
+	    kDebug() << "Changed Entry: " << e.name();
+	}
 
 }
diff --git a/src/kdefrontend/widgets/ThemesWidget.h \
b/src/kdefrontend/widgets/ThemesWidget.h index 84e61ba..bcc2e46 100644
--- a/src/kdefrontend/widgets/ThemesWidget.h
+++ b/src/kdefrontend/widgets/ThemesWidget.h
@@ -44,7 +44,6 @@ class ThemesWidget : public QListView {
 
 	private slots:
 		void applyClicked();
-		void publishThemes();
 		void downloadThemes();
 };
 
diff --git a/src/themes/CMakeLists.txt b/src/themes/CMakeLists.txt
index b2294eb..f976443 100644
--- a/src/themes/CMakeLists.txt
+++ b/src/themes/CMakeLists.txt
@@ -2,4 +2,4 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/theme_files DESTINATION \
${DATA_INS  
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/screenshots DESTINATION \
${DATA_INSTALL_DIR}/${PROJECT_NAME}/themes )  
-install( FILES labplot2.knsrc  DESTINATION  ${CONFIG_INSTALL_DIR} )
+install( FILES labplot2_themes.knsrc  DESTINATION  ~/.kde/share/config/ )
diff --git a/src/themes/labplot2.knsrc b/src/themes/labplot2_themes.knsrc
similarity index 100%
rename from src/themes/labplot2.knsrc
rename to src/themes/labplot2_themes.knsrc


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

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