|
|
@ -19,10 +19,10 @@
|
|
|
|
***************************************************************************/
|
|
|
|
***************************************************************************/
|
|
|
|
#include "configuration.h"
|
|
|
|
#include "configuration.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <qfile.h>
|
|
|
|
#include <ntqfile.h>
|
|
|
|
#include <qwidgetstack.h>
|
|
|
|
#include <ntqwidgetstack.h>
|
|
|
|
#include <qobjectlist.h>
|
|
|
|
#include <ntqobjectlist.h>
|
|
|
|
#include <qdir.h>
|
|
|
|
#include <ntqdir.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
#include <kshell.h>
|
|
|
|
#include <kshell.h>
|
|
|
@ -31,18 +31,18 @@
|
|
|
|
#include "menulistviewitem.h"
|
|
|
|
#include "menulistviewitem.h"
|
|
|
|
|
|
|
|
|
|
|
|
Config::Config()
|
|
|
|
Config::Config()
|
|
|
|
:mTintColor(Qt::black),mOpacity(0.2f),mScheme("none"),mMenuButtonSize(32),mNavButtonSize(32),mMenuRadius(132),doc(NULL)
|
|
|
|
:mTintColor(TQt::black),mOpacity(0.2f),mScheme("none"),mMenuButtonSize(32),mNavButtonSize(32),mMenuRadius(132),doc(NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mConfigPath = locate("data", "kommando/kommandorc");
|
|
|
|
mConfigPath = locate("data", "kommando/kommandorc");
|
|
|
|
kdDebug() << "kommandorc located: " << mConfigPath << endl;
|
|
|
|
kdDebug() << "kommandorc located: " << mConfigPath << endl;
|
|
|
|
|
|
|
|
|
|
|
|
if (mConfigPath.isNull() || !QFile::exists(mConfigPath)){ //test for new config file
|
|
|
|
if (mConfigPath.isNull() || !TQFile::exists(mConfigPath)){ //test for new config file
|
|
|
|
kdDebug() << "There is no kommandorc in kdedirs" << endl;
|
|
|
|
kdDebug() << "There is no kommandorc in kdedirs" << endl;
|
|
|
|
mConfigPath = locateLocal("data", "kommando/kommandorc");
|
|
|
|
mConfigPath = locateLocal("data", "kommando/kommandorc");
|
|
|
|
|
|
|
|
|
|
|
|
if(QFile::exists(KShell::homeDir("")+"/.kommandorc")){ //tries old config file
|
|
|
|
if(TQFile::exists(KShell::homeDir("")+"/.kommandorc")){ //tries old config file
|
|
|
|
kdDebug() << "There is a kommandorc in homedir, moving it to " << mConfigPath << endl;
|
|
|
|
kdDebug() << "There is a kommandorc in homedir, moving it to " << mConfigPath << endl;
|
|
|
|
QDir dir;
|
|
|
|
TQDir dir;
|
|
|
|
if (!dir.rename(KShell::homeDir("")+"/.kommandorc", mConfigPath)) {
|
|
|
|
if (!dir.rename(KShell::homeDir("")+"/.kommandorc", mConfigPath)) {
|
|
|
|
kdWarning() << "Moving ~/.kommandorc failed, creating a default one" << endl;
|
|
|
|
kdWarning() << "Moving ~/.kommandorc failed, creating a default one" << endl;
|
|
|
|
createDefaultConfigFile();
|
|
|
|
createDefaultConfigFile();
|
|
|
@ -69,22 +69,22 @@ void Config::createDefaultConfigFile()
|
|
|
|
|
|
|
|
|
|
|
|
bool Config::readConfigFile( )
|
|
|
|
bool Config::readConfigFile( )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QFile file(mConfigPath);
|
|
|
|
TQFile file(mConfigPath);
|
|
|
|
if(!file.open(IO_ReadOnly)){
|
|
|
|
if(!file.open(IO_ReadOnly)){
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(doc){
|
|
|
|
if(doc){
|
|
|
|
delete doc;
|
|
|
|
delete doc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doc = new QDomDocument();
|
|
|
|
doc = new TQDomDocument();
|
|
|
|
doc->setContent( &file );
|
|
|
|
doc->setContent( &file );
|
|
|
|
file.close();
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
|
|
|
|
if(doc){
|
|
|
|
if(doc){
|
|
|
|
QDomNode topLevelNode = doc->documentElement().firstChild();
|
|
|
|
TQDomNode topLevelNode = doc->documentElement().firstChild();
|
|
|
|
while(!topLevelNode.isNull()){
|
|
|
|
while(!topLevelNode.isNull()){
|
|
|
|
if(topLevelNode.isElement()){
|
|
|
|
if(topLevelNode.isElement()){
|
|
|
|
QDomElement elem = topLevelNode.toElement();
|
|
|
|
TQDomElement elem = topLevelNode.toElement();
|
|
|
|
if(elem.tagName()=="access"){
|
|
|
|
if(elem.tagName()=="access"){
|
|
|
|
setShortcut(elem.text());
|
|
|
|
setShortcut(elem.text());
|
|
|
|
} else if(elem.tagName()=="tintcolor"){
|
|
|
|
} else if(elem.tagName()=="tintcolor"){
|
|
|
@ -114,11 +114,11 @@ bool Config::writeConfigFile( )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mConfigPath = locateLocal("data", "kommando/kommandorc");
|
|
|
|
mConfigPath = locateLocal("data", "kommando/kommandorc");
|
|
|
|
QFile file(mConfigPath);
|
|
|
|
TQFile file(mConfigPath);
|
|
|
|
if(!file.open(IO_WriteOnly)){
|
|
|
|
if(!file.open(IO_WriteOnly)){
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QTextStream str(&file);
|
|
|
|
TQTextStream str(&file);
|
|
|
|
str << *doc;
|
|
|
|
str << *doc;
|
|
|
|
file.close();
|
|
|
|
file.close();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -129,8 +129,8 @@ void Config::fromConfigDlg(KommandoViewList& listViews )
|
|
|
|
if(doc){
|
|
|
|
if(doc){
|
|
|
|
delete doc;
|
|
|
|
delete doc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doc = new QDomDocument();
|
|
|
|
doc = new TQDomDocument();
|
|
|
|
QDomElement root=doc->createElement("root");
|
|
|
|
TQDomElement root=doc->createElement("root");
|
|
|
|
doc->appendChild(root);
|
|
|
|
doc->appendChild(root);
|
|
|
|
|
|
|
|
|
|
|
|
newNode("access",root,Shortcut(),"method","shortcut");
|
|
|
|
newNode("access",root,Shortcut(),"method","shortcut");
|
|
|
@ -143,8 +143,8 @@ void Config::fromConfigDlg(KommandoViewList& listViews )
|
|
|
|
|
|
|
|
|
|
|
|
for(KommandoView* it = listViews.first(); it != 0; it = listViews.next()){
|
|
|
|
for(KommandoView* it = listViews.first(); it != 0; it = listViews.next()){
|
|
|
|
if(it->childCount() > 0){
|
|
|
|
if(it->childCount() > 0){
|
|
|
|
QDomElement node = newMenu(root,it->appName());
|
|
|
|
TQDomElement node = newMenu(root,it->appName());
|
|
|
|
QListViewItem* temp = it->firstChild();
|
|
|
|
TQListViewItem* temp = it->firstChild();
|
|
|
|
while(temp){
|
|
|
|
while(temp){
|
|
|
|
menuItemToXML(node,static_cast<MenuListViewItem*>(temp));
|
|
|
|
menuItemToXML(node,static_cast<MenuListViewItem*>(temp));
|
|
|
|
temp=temp->nextSibling();
|
|
|
|
temp=temp->nextSibling();
|
|
|
@ -154,12 +154,12 @@ void Config::fromConfigDlg(KommandoViewList& listViews )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//ARGHHH!! I need this function because QListView::lastItem returns not only top level items but also children of top level items
|
|
|
|
//ARGHHH!! I need this function because TQListView::lastItem returns not only top level items but also children of top level items
|
|
|
|
//It took me hours of my precious lifetime to figure that out!! _Terribly_ annoying -.-
|
|
|
|
//It took me hours of my precious lifetime to figure that out!! _Terribly_ annoying -.-
|
|
|
|
QListViewItem* lastChild(QListView* view)
|
|
|
|
TQListViewItem* lastChild(TQListView* view)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QListViewItem* temp=view->firstChild();
|
|
|
|
TQListViewItem* temp=view->firstChild();
|
|
|
|
QListViewItem* item=NULL;
|
|
|
|
TQListViewItem* item=NULL;
|
|
|
|
while(temp!=NULL){
|
|
|
|
while(temp!=NULL){
|
|
|
|
item=temp;
|
|
|
|
item=temp;
|
|
|
|
temp=temp->nextSibling();
|
|
|
|
temp=temp->nextSibling();
|
|
|
@ -167,15 +167,15 @@ QListViewItem* lastChild(QListView* view)
|
|
|
|
return item;
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::toListView(KommandoViewList& listViews, QWidgetStack* listViewParent)//QListView* listView )
|
|
|
|
void Config::toListView(KommandoViewList& listViews, TQWidgetStack* listViewParent)//TQListView* listView )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(doc){
|
|
|
|
if(doc){
|
|
|
|
QDomNode topLevelNode = doc->documentElement().firstChild();
|
|
|
|
TQDomNode topLevelNode = doc->documentElement().firstChild();
|
|
|
|
const QObjectList *children = listViewParent->children();
|
|
|
|
const TQObjectList *children = listViewParent->children();
|
|
|
|
if (children != 0) {
|
|
|
|
if (children != 0) {
|
|
|
|
QObjectListIterator it(*children);
|
|
|
|
TQObjectListIterator it(*children);
|
|
|
|
for (; *it != 0; ++it)
|
|
|
|
for (; *it != 0; ++it)
|
|
|
|
listViewParent->removeWidget(static_cast<QWidget*>(*it));
|
|
|
|
listViewParent->removeWidget(static_cast<TQWidget*>(*it));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while(!topLevelNode.isNull()){
|
|
|
|
while(!topLevelNode.isNull()){
|
|
|
@ -184,10 +184,10 @@ void Config::toListView(KommandoViewList& listViews, QWidgetStack* listViewParen
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KommandoView* view = new KommandoView(listViewParent,topLevelNode.toElement().attribute("appname"));
|
|
|
|
KommandoView* view = new KommandoView(listViewParent,topLevelNode.toElement().attribute("appname"));
|
|
|
|
listViewParent->addWidget(view);
|
|
|
|
listViewParent->addWidget(view);
|
|
|
|
QDomNode menuNode = topLevelNode.firstChild();
|
|
|
|
TQDomNode menuNode = topLevelNode.firstChild();
|
|
|
|
while(!menuNode.isNull()){
|
|
|
|
while(!menuNode.isNull()){
|
|
|
|
if(menuNode.isElement()){
|
|
|
|
if(menuNode.isElement()){
|
|
|
|
QDomElement elemNode=menuNode.toElement();
|
|
|
|
TQDomElement elemNode=menuNode.toElement();
|
|
|
|
menuItemFromXML(view,lastChild(view),menuNode.toElement());
|
|
|
|
menuItemFromXML(view,lastChild(view),menuNode.toElement());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menuNode = menuNode.nextSibling();
|
|
|
|
menuNode = menuNode.nextSibling();
|
|
|
@ -202,15 +202,15 @@ void Config::toListView(KommandoViewList& listViews, QWidgetStack* listViewParen
|
|
|
|
|
|
|
|
|
|
|
|
void Config::toKommandoMenu(Kommando* buttonParent)
|
|
|
|
void Config::toKommandoMenu(Kommando* buttonParent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QPtrList<Menu> topLevelMenus;
|
|
|
|
TQPtrList<Menu> topLevelMenus;
|
|
|
|
Menu* defaultMenu = 0;
|
|
|
|
Menu* defaultMenu = 0;
|
|
|
|
if(doc){
|
|
|
|
if(doc){
|
|
|
|
QDomNode node = doc->documentElement().firstChild();
|
|
|
|
TQDomNode node = doc->documentElement().firstChild();
|
|
|
|
|
|
|
|
|
|
|
|
while(!node.isNull()){
|
|
|
|
while(!node.isNull()){
|
|
|
|
if(node.isElement()&&(node.toElement().tagName() == "menu")){
|
|
|
|
if(node.isElement()&&(node.toElement().tagName() == "menu")){
|
|
|
|
Menu* mainMenu = menuFromXML(node.toElement(),buttonParent);
|
|
|
|
Menu* mainMenu = menuFromXML(node.toElement(),buttonParent);
|
|
|
|
if((mainMenu->appName() == "default") || (mainMenu->appName() == QString::null)){
|
|
|
|
if((mainMenu->appName() == "default") || (mainMenu->appName() == TQString::null)){
|
|
|
|
defaultMenu = mainMenu;
|
|
|
|
defaultMenu = mainMenu;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mainMenu->arrangeButtons();
|
|
|
|
mainMenu->arrangeButtons();
|
|
|
@ -237,7 +237,7 @@ void Config::toKommandoMenu(Kommando* buttonParent)
|
|
|
|
|
|
|
|
|
|
|
|
void Config::setDefaultValues()
|
|
|
|
void Config::setDefaultValues()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setTintColor(Qt::black);
|
|
|
|
setTintColor(TQt::black);
|
|
|
|
setOpacity(0.2f);
|
|
|
|
setOpacity(0.2f);
|
|
|
|
setShortcut("Alt+Ctrl+H");
|
|
|
|
setShortcut("Alt+Ctrl+H");
|
|
|
|
setNavButtonSize(32);
|
|
|
|
setNavButtonSize(32);
|
|
|
@ -248,8 +248,8 @@ void Config::setDefaultValues()
|
|
|
|
if(doc){
|
|
|
|
if(doc){
|
|
|
|
delete doc;
|
|
|
|
delete doc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doc = new QDomDocument();
|
|
|
|
doc = new TQDomDocument();
|
|
|
|
QDomElement root = doc->createElement("root");
|
|
|
|
TQDomElement root = doc->createElement("root");
|
|
|
|
doc->appendChild(root);
|
|
|
|
doc->appendChild(root);
|
|
|
|
|
|
|
|
|
|
|
|
newNode("access",root,Shortcut(),"method","shortcut");
|
|
|
|
newNode("access",root,Shortcut(),"method","shortcut");
|
|
|
@ -260,23 +260,23 @@ void Config::setDefaultValues()
|
|
|
|
newNode("menuradius",root,132);
|
|
|
|
newNode("menuradius",root,132);
|
|
|
|
newNode("scheme",root,"Normal");
|
|
|
|
newNode("scheme",root,"Normal");
|
|
|
|
|
|
|
|
|
|
|
|
QDomElement node= newMenu(root,"default");
|
|
|
|
TQDomElement node= newMenu(root,"default");
|
|
|
|
newButton(node,"konsole","konsole --workdir $HOME");
|
|
|
|
newButton(node,"konsole","konsole --workdir $HOME");
|
|
|
|
newButton(node,"kwrite","kwrite");
|
|
|
|
newButton(node,"kwrite","kwrite");
|
|
|
|
newButton(node,"konqueror","konqueror");
|
|
|
|
newButton(node,"konqueror","konqueror");
|
|
|
|
newButton(node,"kcalc","kcalc");
|
|
|
|
newButton(node,"kcalc","kcalc");
|
|
|
|
newButton(node,"gimp","gimp");
|
|
|
|
newButton(node,"gimp","gimp");
|
|
|
|
newButton(node,"kfm_home","kfmclient openProfile filemanagement");
|
|
|
|
newButton(node,"kfm_home","kfmclient openProfile filemanagement");
|
|
|
|
node = newMenu(node,QString::null,"kmix");
|
|
|
|
node = newMenu(node,TQString::null,"kmix");
|
|
|
|
newButton(node,"kmix","kmix");
|
|
|
|
newButton(node,"kmix","kmix");
|
|
|
|
newButton(node,"k3b","k3b");
|
|
|
|
newButton(node,"k3b","k3b");
|
|
|
|
newButton(node,"amarok","amarok");
|
|
|
|
newButton(node,"amarok","amarok");
|
|
|
|
newButton(node,"kaffeine","kaffeine");
|
|
|
|
newButton(node,"kaffeine","kaffeine");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Menu * Config::menuFromXML( const QDomElement & ownNode, Kommando * buttonParent, Menu* parent)
|
|
|
|
Menu * Config::menuFromXML( const TQDomElement & ownNode, Kommando * buttonParent, Menu* parent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDomNode node=ownNode.firstChild();
|
|
|
|
TQDomNode node=ownNode.firstChild();
|
|
|
|
|
|
|
|
|
|
|
|
Menu* newMenu = new Menu(parent,ownNode.attribute("appname"));
|
|
|
|
Menu* newMenu = new Menu(parent,ownNode.attribute("appname"));
|
|
|
|
|
|
|
|
|
|
|
@ -303,11 +303,11 @@ Menu * Config::menuFromXML( const QDomElement & ownNode, Kommando * buttonParent
|
|
|
|
return newMenu;
|
|
|
|
return newMenu;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CommandoButton* Config::comButtonFromXML(const QDomElement& ownNode, Kommando* parent)
|
|
|
|
CommandoButton* Config::comButtonFromXML(const TQDomElement& ownNode, Kommando* parent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CommandoButton* button = new CommandoButton(parent,mMenuButtonSize);
|
|
|
|
CommandoButton* button = new CommandoButton(parent,mMenuButtonSize);
|
|
|
|
|
|
|
|
|
|
|
|
QDomNode bnode=ownNode.firstChild();
|
|
|
|
TQDomNode bnode=ownNode.firstChild();
|
|
|
|
while (!bnode.isNull()){
|
|
|
|
while (!bnode.isNull()){
|
|
|
|
if(bnode.nodeName() == "command"){
|
|
|
|
if(bnode.nodeName() == "command"){
|
|
|
|
button->setCommand(bnode.firstChild().nodeValue());
|
|
|
|
button->setCommand(bnode.firstChild().nodeValue());
|
|
|
@ -319,36 +319,36 @@ CommandoButton* Config::comButtonFromXML(const QDomElement& ownNode, Kommando* p
|
|
|
|
return button;
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QDomElement Config::newNode( const QString& nodename, QDomNode& parent, int value )
|
|
|
|
TQDomElement Config::newNode( const TQString& nodename, TQDomNode& parent, int value )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDomElement node=doc->createElement(nodename);
|
|
|
|
TQDomElement node=doc->createElement(nodename);
|
|
|
|
node.appendChild(doc->createTextNode(QString::number(value)));
|
|
|
|
node.appendChild(doc->createTextNode(TQString::number(value)));
|
|
|
|
parent.appendChild(node);
|
|
|
|
parent.appendChild(node);
|
|
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QDomElement Config::newNode( const QString& nodename, QDomNode& parent, float value )
|
|
|
|
TQDomElement Config::newNode( const TQString& nodename, TQDomNode& parent, float value )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDomElement node=doc->createElement(nodename);
|
|
|
|
TQDomElement node=doc->createElement(nodename);
|
|
|
|
node.appendChild(doc->createTextNode(QString::number(value)));
|
|
|
|
node.appendChild(doc->createTextNode(TQString::number(value)));
|
|
|
|
parent.appendChild(node);
|
|
|
|
parent.appendChild(node);
|
|
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QDomElement Config::newNode( const QString& nodename, QDomNode& parent, const QString& value )
|
|
|
|
TQDomElement Config::newNode( const TQString& nodename, TQDomNode& parent, const TQString& value )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDomElement node=doc->createElement(nodename);
|
|
|
|
TQDomElement node=doc->createElement(nodename);
|
|
|
|
node.appendChild(doc->createTextNode(value));
|
|
|
|
node.appendChild(doc->createTextNode(value));
|
|
|
|
parent.appendChild(node);
|
|
|
|
parent.appendChild(node);
|
|
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QDomElement Config::newNode( const QString& nodename, QDomNode& parent, const QString& value, const QString& attrname, const QString& attrvalue )
|
|
|
|
TQDomElement Config::newNode( const TQString& nodename, TQDomNode& parent, const TQString& value, const TQString& attrname, const TQString& attrvalue )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDomElement node=doc->createElement(nodename);
|
|
|
|
TQDomElement node=doc->createElement(nodename);
|
|
|
|
node.setAttribute(attrname,attrvalue);
|
|
|
|
node.setAttribute(attrname,attrvalue);
|
|
|
|
node.appendChild(doc->createTextNode(value));
|
|
|
|
node.appendChild(doc->createTextNode(value));
|
|
|
|
parent.appendChild(node);
|
|
|
|
parent.appendChild(node);
|
|
|
@ -356,16 +356,16 @@ QDomElement Config::newNode( const QString& nodename, QDomNode& parent, const QS
|
|
|
|
return node;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QDomElement Config::newButton(QDomNode& parent, const QString& icon, const QString& command )
|
|
|
|
TQDomElement Config::newButton(TQDomNode& parent, const TQString& icon, const TQString& command )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDomElement root = doc->createElement("button");
|
|
|
|
TQDomElement root = doc->createElement("button");
|
|
|
|
if(command!=""){
|
|
|
|
if(command!=""){
|
|
|
|
QDomElement node = doc->createElement("command");
|
|
|
|
TQDomElement node = doc->createElement("command");
|
|
|
|
node.appendChild(doc->createTextNode(command));
|
|
|
|
node.appendChild(doc->createTextNode(command));
|
|
|
|
root.appendChild(node);
|
|
|
|
root.appendChild(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(icon!=""){
|
|
|
|
if(icon!=""){
|
|
|
|
QDomElement node=doc->createElement("icon");
|
|
|
|
TQDomElement node=doc->createElement("icon");
|
|
|
|
node.appendChild(doc->createTextNode(icon));
|
|
|
|
node.appendChild(doc->createTextNode(icon));
|
|
|
|
root.appendChild(node);
|
|
|
|
root.appendChild(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -373,14 +373,14 @@ QDomElement Config::newButton(QDomNode& parent, const QString& icon, const QStri
|
|
|
|
return root;
|
|
|
|
return root;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QDomElement Config::newMenu( QDomNode & parent, const QString& appName, const QString& icon )
|
|
|
|
TQDomElement Config::newMenu( TQDomNode & parent, const TQString& appName, const TQString& icon )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDomElement root = doc->createElement("menu");
|
|
|
|
TQDomElement root = doc->createElement("menu");
|
|
|
|
if(appName != QString::null){
|
|
|
|
if(appName != TQString::null){
|
|
|
|
root.setAttribute("appname", appName);
|
|
|
|
root.setAttribute("appname", appName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(icon != QString::null){
|
|
|
|
if(icon != TQString::null){
|
|
|
|
QDomElement node=doc->createElement("icon");
|
|
|
|
TQDomElement node=doc->createElement("icon");
|
|
|
|
node.appendChild(doc->createTextNode(icon));
|
|
|
|
node.appendChild(doc->createTextNode(icon));
|
|
|
|
root.appendChild(node);
|
|
|
|
root.appendChild(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -388,11 +388,11 @@ QDomElement Config::newMenu( QDomNode & parent, const QString& appName, const QS
|
|
|
|
return root;
|
|
|
|
return root;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::menuItemToXML( QDomNode & parent, MenuListViewItem* item)
|
|
|
|
void Config::menuItemToXML( TQDomNode & parent, MenuListViewItem* item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(item->type()==MenuListViewItem::Menu){
|
|
|
|
if(item->type()==MenuListViewItem::Menu){
|
|
|
|
QDomElement node = newMenu(parent,QString::null,item->iconPath());
|
|
|
|
TQDomElement node = newMenu(parent,TQString::null,item->iconPath());
|
|
|
|
QListViewItem* temp = item->firstChild();
|
|
|
|
TQListViewItem* temp = item->firstChild();
|
|
|
|
while(temp){
|
|
|
|
while(temp){
|
|
|
|
menuItemToXML(node,static_cast<MenuListViewItem*>(temp));
|
|
|
|
menuItemToXML(node,static_cast<MenuListViewItem*>(temp));
|
|
|
|
temp=temp->nextSibling();
|
|
|
|
temp=temp->nextSibling();
|
|
|
@ -402,7 +402,7 @@ void Config::menuItemToXML( QDomNode & parent, MenuListViewItem* item)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::menuItemFromXML(KommandoView* parent, QListViewItem* after, const QDomElement& ownNode)
|
|
|
|
void Config::menuItemFromXML(KommandoView* parent, TQListViewItem* after, const TQDomElement& ownNode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MenuListViewItem* item;
|
|
|
|
MenuListViewItem* item;
|
|
|
|
if (ownNode.tagName()=="menu"){
|
|
|
|
if (ownNode.tagName()=="menu"){
|
|
|
@ -414,7 +414,7 @@ void Config::menuItemFromXML(KommandoView* parent, QListViewItem* after, const Q
|
|
|
|
itemHelper(ownNode,item); //Parse properties and children of this item
|
|
|
|
itemHelper(ownNode,item); //Parse properties and children of this item
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::menuItemFromXML(QListViewItem* parent, QListViewItem* after, const QDomElement& ownNode)
|
|
|
|
void Config::menuItemFromXML(TQListViewItem* parent, TQListViewItem* after, const TQDomElement& ownNode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MenuListViewItem* item;
|
|
|
|
MenuListViewItem* item;
|
|
|
|
if (ownNode.tagName()=="menu"){
|
|
|
|
if (ownNode.tagName()=="menu"){
|
|
|
@ -427,13 +427,13 @@ void Config::menuItemFromXML(QListViewItem* parent, QListViewItem* after, const
|
|
|
|
itemHelper(ownNode,item); //Parse properties and children of this item
|
|
|
|
itemHelper(ownNode,item); //Parse properties and children of this item
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::itemHelper(const QDomElement& ownNode, MenuListViewItem* item)
|
|
|
|
void Config::itemHelper(const TQDomElement& ownNode, MenuListViewItem* item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDomNode temp = ownNode.firstChild();
|
|
|
|
TQDomNode temp = ownNode.firstChild();
|
|
|
|
|
|
|
|
|
|
|
|
while(!temp.isNull()){
|
|
|
|
while(!temp.isNull()){
|
|
|
|
if(temp.isElement()){
|
|
|
|
if(temp.isElement()){
|
|
|
|
QDomElement temp2=temp.toElement();
|
|
|
|
TQDomElement temp2=temp.toElement();
|
|
|
|
if(temp2.tagName() == "icon"){
|
|
|
|
if(temp2.tagName() == "icon"){
|
|
|
|
item->setIconPath(temp2.firstChild().nodeValue());
|
|
|
|
item->setIconPath(temp2.firstChild().nodeValue());
|
|
|
|
} else if((temp2.tagName() == "command") && (item->type() == MenuListViewItem::Button)){
|
|
|
|
} else if((temp2.tagName() == "command") && (item->type() == MenuListViewItem::Button)){
|
|
|
|