aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/theme
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/theme')
-rw-r--r--src/modules/theme/CMakeLists.txt4
-rw-r--r--src/modules/theme/PackThemeDialog.cpp5
-rw-r--r--src/modules/theme/SaveThemeDialog.cpp20
-rw-r--r--src/modules/theme/ThemeFunctions.cpp17
-rw-r--r--src/modules/theme/ThemeManagementDialog.cpp63
-rw-r--r--src/modules/theme/ThemeManagementDialog.h16
-rw-r--r--src/modules/theme/WebThemeInterfaceDialog.cpp253
-rw-r--r--src/modules/theme/WebThemeInterfaceDialog.h73
-rw-r--r--src/modules/theme/libkvitheme.cpp7
9 files changed, 415 insertions, 43 deletions
diff --git a/src/modules/theme/CMakeLists.txt b/src/modules/theme/CMakeLists.txt
index 9605b5abe..b68843bc5 100644
--- a/src/modules/theme/CMakeLists.txt
+++ b/src/modules/theme/CMakeLists.txt
@@ -1,13 +1,15 @@
# CMakeLists for src/modules/theme
SET(kvitheme_MOC_HDRS
- ThemeManagementDialog.h
+ WebThemeInterfaceDialog.h
+ ThemeManagementDialog.h
PackThemeDialog.h
SaveThemeDialog.h
)
SET(kvitheme_SRCS
libkvitheme.cpp
+ WebThemeInterfaceDialog.cpp
ThemeManagementDialog.cpp
PackThemeDialog.cpp
SaveThemeDialog.cpp
diff --git a/src/modules/theme/PackThemeDialog.cpp b/src/modules/theme/PackThemeDialog.cpp
index 991f1c6ea..dc92c62a7 100644
--- a/src/modules/theme/PackThemeDialog.cpp
+++ b/src/modules/theme/PackThemeDialog.cpp
@@ -533,8 +533,9 @@ bool PackThemeDialog::packTheme()
bufferz.close();
f.addInfoField(szTmp,pba);
}
-
- if(!f.addDirectory(pInfo->absoluteDirectory(),pInfo->subdirectory()))
+ QString szThemePath;
+ pInfo->getCompleteDirPath(szThemePath);
+ if(!f.addDirectory(szThemePath,pInfo->subdirectory()))
{
szTmp = __tr2qs_ctx("Packaging failed","theme");
szTmp += ": ";
diff --git a/src/modules/theme/SaveThemeDialog.cpp b/src/modules/theme/SaveThemeDialog.cpp
index 6c4e0e9d7..090b97cd0 100644
--- a/src/modules/theme/SaveThemeDialog.cpp
+++ b/src/modules/theme/SaveThemeDialog.cpp
@@ -64,6 +64,9 @@ SaveThemeDialog::SaveThemeDialog(QWidget * pParent)
setWindowTitle(__tr2qs_ctx("Save Current Theme - KVIrc","theme"));
setMinimumSize(400,350);
+ KviThemeInfo info;
+ info.load(KVI_OPTION_STRING(KviOption_stringIconThemeSubdir));
+
// welcome page ==================================================================================
QWidget * pPage = new QWidget(this);
QGridLayout * pLayout = new QGridLayout(pPage);
@@ -104,7 +107,7 @@ SaveThemeDialog::SaveThemeDialog(QWidget * pParent)
pLayout->addWidget(pLabel,1,0);
m_pThemeNameEdit = new QLineEdit(pPage);
- //m_pThemeNameEdit->setText(szThemeName);
+ m_pThemeNameEdit->setText(info.name());
pLayout->addWidget(m_pThemeNameEdit,1,1);
pLabel = new QLabel(pPage);
@@ -112,7 +115,11 @@ SaveThemeDialog::SaveThemeDialog(QWidget * pParent)
pLayout->addWidget(pLabel,2,0);
m_pThemeVersionEdit = new QLineEdit(pPage);
- //m_pThemeVersionEdit->setText(szThemeVersion);
+ m_pThemeVersionEdit->setText(info.version());
+ QRegExp rx("(.[0-9]{1,2}){3,3}");
+ QValidator *validator = new QRegExpValidator(rx, this);
+m_pThemeVersionEdit->setValidator(validator);
+
pLayout->addWidget(m_pThemeVersionEdit,2,1);
pLabel = new QLabel(pPage);
@@ -120,7 +127,7 @@ SaveThemeDialog::SaveThemeDialog(QWidget * pParent)
pLayout->addWidget(pLabel,3,0);
m_pThemeDescriptionEdit = new QTextEdit(pPage);
- //m_pThemeDescriptionEdit->setText(szThemeDescription);
+ m_pThemeDescriptionEdit->setText(info.description());
pLayout->addWidget(m_pThemeDescriptionEdit,3,1);
pLabel = new QLabel(pPage);
@@ -128,7 +135,7 @@ SaveThemeDialog::SaveThemeDialog(QWidget * pParent)
pLayout->addWidget(pLabel,4,0);
m_pAuthorNameEdit = new QLineEdit(pPage);
- //m_pAuthorNameEdit->setText(szThemeAuthor);
+ m_pAuthorNameEdit->setText(info.author());
pLayout->addWidget(m_pAuthorNameEdit,4,1);
@@ -272,7 +279,6 @@ bool SaveThemeDialog::saveTheme()
return false;
}
- sto.setAbsoluteDirectory(szAbsDir);
if(!KviTheme::save(sto))
{
@@ -296,7 +302,9 @@ bool SaveThemeDialog::saveTheme()
}
QString szMsg = __tr2qs_ctx("Theme saved successfully to ","theme");
- szMsg += sto.absoluteDirectory();
+ QString szThemePath;
+ sto.getCompleteDirPath(szThemePath);
+ szMsg += szThemePath;
QMessageBox::information(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),szMsg,QMessageBox::Ok,
QMessageBox::NoButton,QMessageBox::NoButton);
diff --git a/src/modules/theme/ThemeFunctions.cpp b/src/modules/theme/ThemeFunctions.cpp
index a24684c7b..271fef739 100644
--- a/src/modules/theme/ThemeFunctions.cpp
+++ b/src/modules/theme/ThemeFunctions.cpp
@@ -64,6 +64,7 @@ namespace ThemeFunctions
if(!r.readHeader(szThemePackageFileName))
{
+ qDebug("The selected file does not seem to be a valid KVIrc package");
QString szErr = r.lastError();
szError = QString(__tr2qs_ctx("The selected file does not seem to be a valid KVIrc package: %1","theme")).arg(szErr);
return false;
@@ -72,8 +73,10 @@ namespace ThemeFunctions
pInfoFields = r.stringInfoFields();
pValue = pInfoFields->find("PackageType");
- if(!pValue)
+ if(!pValue){
+ qDebug("no package type");
return notAValidThemePackage(szError);
+ }
if(!KviQString::equalCI(*pValue,"ThemePack"))
return notAValidThemePackage(szError);
@@ -91,16 +94,22 @@ namespace ThemeFunctions
}
pValue = pInfoFields->find("ThemeCount");
- if(!pValue)
+ if(!pValue){
+ qDebug("no theme count");
return notAValidThemePackage(szError);
+ }
bool bOk;
int iThemeCount = pValue->toInt(&bOk);
- if(!bOk)
+ if(!bOk){
+ qDebug("no theme count 2");
return notAValidThemePackage(szError);
+ }
+ if(iThemeCount < 1){
- if(iThemeCount < 1)
+ qDebug("no theme count 2");
return notAValidThemePackage(szError);
+ }
// ok.. it should be really valid at this point
diff --git a/src/modules/theme/ThemeManagementDialog.cpp b/src/modules/theme/ThemeManagementDialog.cpp
index 182dd64d8..ead7de0e7 100644
--- a/src/modules/theme/ThemeManagementDialog.cpp
+++ b/src/modules/theme/ThemeManagementDialog.cpp
@@ -21,6 +21,11 @@
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================
+#include "kvi_settings.h"
+#if defined(COMPILE_WEBKIT_SUPPORT) && (QT_VERSION >= 0x040600)
+#include "WebThemeInterfaceDialog.h"
+#endif
+
#include "ThemeManagementDialog.h"
#include "PackThemeDialog.h"
@@ -67,6 +72,9 @@
extern QRect g_rectManagementDialogGeometry;
+#define BUILTIN_THEMES 1
+
+#define USER_DEFINED_THEMES 0
ThemeListWidgetItem::ThemeListWidgetItem(KviTalListWidget * box,KviThemeInfo * inf)
: KviTalListWidgetItem(box)
@@ -111,6 +119,9 @@ ThemeManagementDialog::ThemeManagementDialog(QWidget * parent)
: QWidget(parent)
{
m_pItemDelegate=0;
+ #if defined(COMPILE_WEBKIT_SUPPORT) && (QT_VERSION >= 0x040600)
+ m_pWebThemeInterfaceDialog = 0;
+ #endif
setObjectName("theme_options_widget");
setWindowTitle(__tr2qs_ctx("Manage Themes - KVIrc","theme"));
setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Theme)));
@@ -218,6 +229,13 @@ ThemeManagementDialog::~ThemeManagementDialog()
if (m_pItemDelegate) delete m_pItemDelegate;
g_rectManagementDialogGeometry = QRect(pos().x(),pos().y(),size().width(),size().height());
m_pInstance = 0;
+ #if defined(COMPILE_WEBKIT_SUPPORT) && (QT_VERSION >= 0x040600)
+ if(m_pWebThemeInterfaceDialog)
+ {
+ delete m_pWebThemeInterfaceDialog;
+ m_pWebThemeInterfaceDialog = 0;
+ }
+ #endif
}
void ThemeManagementDialog::closeClicked()
@@ -303,11 +321,11 @@ void ThemeManagementDialog::applyCurrentTheme()
__tr2qs_ctx("Do you wish to apply theme \"%Q\" (version %Q)?","theme"),
&(it->themeInfo()->name()),&(it->themeInfo()->version())))
{
- QString szPath = it->themeInfo()->absoluteDirectory();
+ QString szPath = it->themeInfo()->dirName();
if(szPath.isEmpty())return;
KviThemeInfo out;
- if(!KviTheme::load(szPath,out))
+ if(!KviTheme::load(szPath,out,it->themeInfo()->isBuiltin()))
{
QString szErr = out.lastError();
QString szMsg = QString(__tr2qs_ctx("Failed to apply the specified theme: %1","theme")).arg(szErr);
@@ -327,7 +345,9 @@ void ThemeManagementDialog::deleteTheme()
if(!KviMessageBox::yesNo(__tr2qs_ctx("Delete Theme - KVIrc","theme"),
__tr2qs_ctx("Do you really wish to delete theme \"%Q\" (version %Q)?","theme"),
&(((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->name()),&(((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->version())))goto jump_out;
- KviFileUtils::deleteDir(((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->absoluteDirectory());
+ QString szThemePath;
+ ((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->getCompleteDirPath(szThemePath);
+ KviFileUtils::deleteDir(szThemePath);
}
jump_out:
fillThemeBox();
@@ -350,10 +370,20 @@ void ThemeManagementDialog::installFromFile()
void ThemeManagementDialog::getMoreThemes()
{
+ #if defined(COMPILE_WEBKIT_SUPPORT) && (QT_VERSION >= 0x040600)
+ if (m_pWebThemeInterfaceDialog) m_pWebThemeInterfaceDialog->show();
+ else{
+ m_pWebThemeInterfaceDialog = new WebThemeInterfaceDialog();
+ m_pWebThemeInterfaceDialog->show();
+ }
+ return;
+ #else
if(!g_pMainWindow)return;
g_pMainWindow->executeInternalCommand(KVI_INTERNALCOMMAND_OPENURL_KVIRC_THEMES);
+ #endif
}
+
void ThemeManagementDialog::saveCurrentTheme()
{
SaveThemeDialog * pSaveThemeDialog = new SaveThemeDialog(this);
@@ -362,25 +392,17 @@ void ThemeManagementDialog::saveCurrentTheme()
fillThemeBox();
}
-void ThemeManagementDialog::fillThemeBox(const QString &szDir)
+void ThemeManagementDialog::fillThemeBox(bool bBuiltin)
{
- QDir d(szDir);
-
- QStringList sl = d.entryList(QDir::Dirs);
+ QStringList slThemes;
+ KviTheme::installedThemes(slThemes,bBuiltin);
- for(QStringList::Iterator it = sl.begin();it != sl.end();++it)
+ for(int i=0;i<slThemes.count();i++)
{
- if(*it == ".")continue;
- if(*it == "..")continue;
-
- QString szTest = szDir;
- szTest += KVI_PATH_SEPARATOR_CHAR;
- szTest += *it;
-
KviThemeInfo * inf = new KviThemeInfo();
- if(inf->loadFromDirectory(szTest))
+ if(inf->load(slThemes.at(i),bBuiltin))
{
- inf->setSubdirectory(*it);
+ inf->setSubdirectory(slThemes.at(i));
new ThemeListWidgetItem(m_pListWidget,inf);
} else {
delete inf;
@@ -392,11 +414,8 @@ void ThemeManagementDialog::fillThemeBox()
{
m_pListWidget->clear();
- QString szDir;
- g_pApp->getGlobalKvircDirectory(szDir,KviApplication::Themes);
- fillThemeBox(szDir);
- g_pApp->getLocalKvircDirectory(szDir,KviApplication::Themes);
- fillThemeBox(szDir);
+ fillThemeBox(BUILTIN_THEMES);
+ fillThemeBox(USER_DEFINED_THEMES);
enableDisableButtons();
}
diff --git a/src/modules/theme/ThemeManagementDialog.h b/src/modules/theme/ThemeManagementDialog.h
index 5c6d46de8..d4f7fa61d 100644
--- a/src/modules/theme/ThemeManagementDialog.h
+++ b/src/modules/theme/ThemeManagementDialog.h
@@ -38,13 +38,15 @@
#include <QListWidget>
#include <QItemDelegate>
#include <QToolButton>
-
+#include "kvi_settings.h"
+#if defined(COMPILE_WEBKIT_SUPPORT) || defined(Q_MOC_RUN)
+#include "WebThemeInterfaceDialog.h"
+#endif
class QLineEdit;
class QPushButton;
class QLabel;
class KviDynamicToolTip;
-
class ThemeListWidgetItem : public KviTalListWidgetItem
{
public:
@@ -53,7 +55,7 @@ public:
public:
KviThemeInfo * m_pThemeInfo;
public:
- KviThemeInfo * themeInfo(){ return m_pThemeInfo; };
+ KviThemeInfo * themeInfo(){ return m_pThemeInfo; }
};
@@ -70,15 +72,19 @@ protected:
KviTalPopupMenu * m_pContextPopup;
QToolButton * m_pDeleteThemeButton;
QToolButton * m_pPackThemeButton;
+#if defined(COMPILE_WEBKIT_SUPPORT) || defined(Q_MOC_RUN)
+ WebThemeInterfaceDialog *m_pWebThemeInterfaceDialog;
+#endif
public:
- static ThemeManagementDialog * instance(){ return m_pInstance; };
+ static ThemeManagementDialog * instance(){ return m_pInstance; }
static void display(bool bTopLevel);
static void cleanup();
protected:
- void fillThemeBox(const QString &szDir);
+ void fillThemeBox(bool bBuiltin);
bool hasSelectedItems();
virtual void closeEvent(QCloseEvent * e);
protected slots:
+
void saveCurrentTheme();
void getMoreThemes();
void installFromFile();
diff --git a/src/modules/theme/WebThemeInterfaceDialog.cpp b/src/modules/theme/WebThemeInterfaceDialog.cpp
new file mode 100644
index 000000000..98b683d67
--- /dev/null
+++ b/src/modules/theme/WebThemeInterfaceDialog.cpp
@@ -0,0 +1,253 @@
+//=============================================================================
+//
+// File : WebThemeInterfaceDialog.cpp
+// Creation date : Mon Mar 14 2011 15:10:20 by Alessandro Carbone
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 2011 Alessandro Carbone(elfonol at gmail dot 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 opinion) 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 "kvi_settings.h"
+#define KVI_URL_THEMES "http://www.kvirc.de/app/themes.php"
+#if defined(COMPILE_WEBKIT_SUPPORT) && (QT_VERSION >= 0x040600)
+#include "WebThemeInterfaceDialog.h"
+#include "ThemeFunctions.h"
+
+#include "KviLocale.h"
+#include "KviApplication.h"
+#include "KviMessageBox.h"
+#include "KviModule.h"
+#include "KviFileUtils.h"
+#include "KviIconManager.h"
+
+#include <QDesktopWidget>
+#include <QToolButton>
+#include <QLineEdit>
+#include <QToolTip>
+#include <QTimer>
+#include <QClipboard>
+#include <QHBoxLayout>
+#include <QDir>
+
+WebThemeInterfaceDialog::WebThemeInterfaceDialog(QWidget * par)
+: QWidget (par)
+{
+ m_pLayout = new QVBoxLayout(this);
+ setWindowTitle(__tr2qs_ctx("KVIrc Web Theme Interface","theme"));
+ setWindowIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_WWW)));
+ m_pFile = 0;
+ m_bBusy = false;
+ QWidget *pStatus = new QWidget(this);
+ m_pLayout->addWidget(pStatus);
+ QHBoxLayout *hbox= new QHBoxLayout(pStatus);
+ // m_pLayout = new QVBoxLayout(this);
+ m_pFtp = 0;
+ m_pLayout->setMargin(3);
+ m_pLayout->setSpacing(2);
+ setLayout(m_pLayout);
+ m_pToolBar= new QToolBar(pStatus);
+ m_pProgressBar = new QProgressBar(pStatus);
+ m_pProgressBar->setMaximumWidth(220);
+ m_pProgressBar->setMinimumWidth(220);
+ hbox->addWidget(m_pToolBar);
+ hbox->addWidget(m_pProgressBar);
+ hbox->setAlignment(m_pProgressBar,Qt::AlignRight);
+
+ m_pWebView = new QWebView(this);
+ m_pLayout->addWidget(m_pWebView);
+ // disable context menu
+ m_pWebView->setContextMenuPolicy(Qt::NoContextMenu);
+ m_pToolBar->addAction(m_pWebView->pageAction(QWebPage::Back));
+ m_pToolBar->addAction(m_pWebView->pageAction(QWebPage::Forward));
+
+ //connect(pWebView,SIGNAL(loadStarted()),this,SLOT(slotLoadStarted()));
+ connect(m_pWebView,SIGNAL(loadFinished(bool)),this,SLOT(slotLoadFinished(bool)));
+ connect(m_pWebView,SIGNAL(loadProgress(int)),this,SLOT(slotLoadProgress(int)));
+ connect(m_pWebView->page(),SIGNAL(linkClicked(const QUrl &)),this,SLOT(slotLinkClicked(const QUrl &)));
+
+ // we managing the links
+ m_pWebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+ m_pWebView->load(QUrl(KVI_URL_THEMES));
+
+
+}
+WebThemeInterfaceDialog::~WebThemeInterfaceDialog()
+{
+ if (m_pFile) delete m_pFile;
+ if (m_pFtp) delete m_pFtp;
+}
+
+void WebThemeInterfaceDialog::slotLoadFinished(bool bOk)
+{
+ if (bOk){
+ m_pProgressBar->hide();
+ m_pProgressBar->setValue(0);
+ if(!isVisible()) show();
+ // main frame
+ QWebFrame *pFrame=m_pWebView->page()->mainFrame();
+ /*QWebElement style=pFrame->documentElement().findFirst("style");
+ QString szCss=style.toPlainText();
+ szCss.append("div.item_entry:hover {background-color: rgba(0,0,0,0.9)}");
+ style.setPlainText(szCss);*/
+ // search for all item_entry div
+ QWebElementCollection elementscollection=pFrame->documentElement().findAll("div.item_entry");
+
+ // local dir for user defined themes
+ QString szLocalThemesPath;
+ g_pApp->getLocalKvircDirectory(szLocalThemesPath,KviApplication::Themes);
+ szLocalThemesPath += KVI_PATH_SEPARATOR_CHAR;
+
+ // global dir for builtin themes
+ QString szGlobalThemesPath;
+ g_pApp->getGlobalKvircDirectory(szGlobalThemesPath,KviApplication::Themes);
+ szGlobalThemesPath += KVI_PATH_SEPARATOR_CHAR;
+
+ // if this is null something is wrong
+ if(elementscollection.count())
+ {
+ foreach(QWebElement element,elementscollection)
+ {
+ // web element 'title'
+ QWebElement eTitle=element.findFirst("span.item_name");
+ // string title
+ QString szTitle=eTitle.toPlainText();
+ // number version
+ QString szVersion=element.findFirst("span.item_version").toPlainText();
+ //QString t=szLocalThemesPath+szTitle+"-"+szVersion;
+ // is the theme installed?
+ if(KviFileUtils::fileExists(szGlobalThemesPath+szTitle+"-"+szVersion)|| KviFileUtils::fileExists(szLocalThemesPath+szTitle+"-"+szVersion))
+ {
+ // yeah: change the background color for highlight the item
+ element.findFirst("div.item_id").setStyleProperty("background","none repeat scroll 0 0 #3cd543");
+ // then change the 'install' text into 'uninstall'
+ QWebElement eDownload=element.findFirst("a.item_download_link");
+ eDownload.setPlainText("Uninstall");
+ // why use a c++ var when we can use the web page for store it? :-D
+ eDownload.setAttribute("Installed",QString("1"));
+ }
+ }
+ }
+ }
+ else qDebug("Error loading page");// fixme: add warning dialog
+}
+void WebThemeInterfaceDialog::slotLinkClicked(const QUrl &url)
+{
+ // check if one download is running
+ if(m_bBusy) return;
+ QString szScheme=url.scheme();
+ // it's an ftp link?
+ if (KviQString::equalCI(szScheme,"ftp"))
+ {
+ // let's search for the 'a' tag
+ QWebElementCollection elementscollection=m_pWebView->page()->mainFrame()->findAllElements("a.item_download_link");
+ if(elementscollection.count())
+ {
+
+ foreach(QWebElement element,elementscollection)
+ {
+ // check the href to find the item
+ if (KviQString::equalCI(element.attribute("href"),url.toString()))
+ {
+ // check the hidden attribute for installed item
+ if (element.attribute("Installed").isEmpty())
+ {
+ // one download at once
+ m_bBusy = true;
+ if(!m_pFtp)
+ {
+ m_pFtp = new QFtp();
+ connect(m_pFtp,SIGNAL(commandFinished(int,bool)),this,SLOT(slotCommandFinished(int,bool)));
+ connect(m_pFtp,SIGNAL(dataTransferProgress(qint64,qint64)),this,SLOT(slotDataTransferProgress(qint64,qint64)));
+ }
+ m_pProgressBar->show();
+ QString szUrl = url.toString();
+ int iIdx=szUrl.lastIndexOf("/");
+ QString szFile = szUrl.right(szUrl.length()-iIdx-1);
+ m_pFile = new QFile(m_pFtp);
+ g_pApp->getLocalKvircDirectory(m_szLocalTmpThemeCompletePath,KviApplication::Tmp,szFile);
+ m_pFile->setFileName(m_szLocalTmpThemeCompletePath);
+ m_pFile->open(QIODevice::ReadWrite);
+ m_pFtp->connectToHost(url.host());
+ m_pFtp->login("anonymous","anonymous");
+ m_pFtp->get(url.path(),m_pFile);
+ }
+ else qDebug("uninstall theme");//to be continued
+ }
+ }
+ }
+ }
+ else {
+ m_pProgressBar->show();
+ m_pWebView->load(url);
+ }
+}
+
+void WebThemeInterfaceDialog::slotDataTransferProgress(qint64 iDone,qint64 iTotal)
+{
+ m_pProgressBar->setMaximum(iTotal);
+ m_pProgressBar->setValue(iDone);
+ m_pProgressBar->setFormat(__tr2qs_ctx("Downloading ","theme")+"%p");
+}
+
+void WebThemeInterfaceDialog::slotLoadProgress(int iProgress)
+{
+ m_pProgressBar->setMaximum(100);
+ m_pProgressBar->setValue(iProgress);
+ m_pProgressBar->setFormat(__tr2qs_ctx("Loading ","theme")+"%p");
+}
+
+void WebThemeInterfaceDialog::slotCommandFinished(int id,bool error)
+{
+ if(m_pFtp->currentCommand()==QFtp::Get)
+ {
+ m_pProgressBar->hide();
+ m_pProgressBar->setValue(0);
+ if(!error)
+ {
+ QString szError;
+ m_pFile->close();
+ if(!ThemeFunctions::installThemePackage(m_szLocalTmpThemeCompletePath,szError,this))
+ {
+ KviMessageBox::information(szError);
+ }
+ else{
+ m_pWebView->load(QUrl(KVI_URL_THEMES));
+ }
+ QFileInfo info(m_szLocalTmpThemeCompletePath);
+
+ delete m_pFile;
+ m_pFile = 0;
+ if (info.exists()) KviFileUtils::removeFile(m_szLocalTmpThemeCompletePath);
+ m_bBusy = false;
+ m_pFtp->close();
+ }
+ }
+ id=0; //to be continued
+}
+void WebThemeInterfaceDialog::showEvent(QShowEvent *)
+{
+ m_pProgressBar->hide();
+ QRect rect = g_pApp->desktop()->screenGeometry(g_pApp->desktop()->primaryScreen());
+ move((rect.width() - width())/2,(rect.height() - height())/2);
+
+}
+
+#endif
+#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
+#include "WebThemeInterfaceDialog.moc"
+#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES
diff --git a/src/modules/theme/WebThemeInterfaceDialog.h b/src/modules/theme/WebThemeInterfaceDialog.h
new file mode 100644
index 000000000..ed65cae97
--- /dev/null
+++ b/src/modules/theme/WebThemeInterfaceDialog.h
@@ -0,0 +1,73 @@
+#ifndef _WEBTHEMEINTERFACEDIALOG_H_
+#define _WEBTHEMEINTERFACEDIALOG_H_
+//=============================================================================
+//
+// File : WebThemeInterfaceDialog.h
+// Creation date : Mon Mar 14 2011 15:10:20 by Alessandro Carbone
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 2011 Alessandro Carbone(elfonol at gmail dot 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 opinion) 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 "kvi_settings.h"
+#if defined(COMPILE_WEBKIT_SUPPORT)
+#include <QDialog>
+#include <QtWebKit/QWebView>
+#include <QtWebKit/QWebFrame>
+#include <QWebElement>
+#include <QToolBar>
+#include <QFtp>
+#include <QUrl>
+#include <QFile>
+#include <QVBoxLayout>
+#include <QProgressBar>
+#include <QShowEvent>
+
+
+class WebThemeInterfaceDialog : public QWidget
+{
+ Q_OBJECT
+public:
+ WebThemeInterfaceDialog(QWidget *par=0);
+ ~WebThemeInterfaceDialog();
+private:
+ QToolBar * m_pToolBar;
+ QString m_szLocalTmpThemeCompletePath;
+ QVBoxLayout *m_pLayout;
+ QWebView * m_pWebView;
+ QFile *m_pFile;
+ QFtp *m_pFtp;
+ bool m_bBusy;
+ QProgressBar *m_pProgressBar;
+protected:
+ virtual void showEvent(QShowEvent *e);
+protected slots:
+
+ void slotLoadFinished(bool ok);
+ void slotLoadProgress(int iProgress);
+ void slotDataTransferProgress(qint64 iDone,qint64 iTotal);
+ void slotCommandFinished(int id,bool error);
+ void slotLinkClicked(const QUrl &url);
+};
+
+#endif
+
+
+#endif //_WEBTHEMEINTERFACEDIALOG_H_
+
diff --git a/src/modules/theme/libkvitheme.cpp b/src/modules/theme/libkvitheme.cpp
index 86425b9a7..3422291cc 100644
--- a/src/modules/theme/libkvitheme.cpp
+++ b/src/modules/theme/libkvitheme.cpp
@@ -101,14 +101,15 @@ static bool theme_kvs_cmd_apply(KviKvsModuleCommandCall * c)
szDir += KVI_PATH_SEPARATOR_CHAR;
szDir += szThemePackFile;
KviThemeInfo * themeInfo = new KviThemeInfo();
- if(themeInfo->loadFromDirectory(szDir))
+ if(themeInfo->load(szDir))
{
themeInfo->setSubdirectory(szThemePackFile);
if(KviMessageBox::yesNo(__tr2qs_ctx("Apply theme - KVIrc","theme"),
__tr2qs_ctx("Do you wish to apply theme \"%Q\" (version %Q)?","theme"),
&(themeInfo->name()),&(themeInfo->version())))
{
- QString szPath = themeInfo->absoluteDirectory();
+ QString szPath;
+ themeInfo->getCompleteDirPath(szPath);
if(szPath.isEmpty())return true;
KviThemeInfo out;
@@ -151,7 +152,7 @@ static bool theme_kvs_fnc_info(KviKvsModuleFunctionCall * c)
szDir += KVI_PATH_SEPARATOR_CHAR;
szDir += szThemePackFile;
KviThemeInfo * themeInfo = new KviThemeInfo();
- if(themeInfo->loadFromDirectory(szDir))
+ if(themeInfo->load(szDir))
{
KviKvsHash *pHash=new KviKvsHash();
KviKvsVariant *name=new KviKvsVariant(themeInfo->name());