00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "karamba.h"
00012 #include "karambainterface.h"
00013 #include <kdebug.h>
00014 #include "tqwidgetlist.h"
00015 #include "themesdlg.h"
00016
00017 KarambaIface::KarambaIface(): DCOPObject("KarambaIface")
00018 {
00019 }
00020
00021 KarambaIface::~KarambaIface()
00022 {
00023 }
00024
00025 karamba* KarambaIface::getKaramba(TQString name)
00026 {
00027 TQWidgetList *list = TQApplication::allWidgets();
00028 TQWidgetListIt it(*list);
00029 TQWidget* w;
00030 karamba* result = 0;
00031
00032 while ( (w=it.current()) != 0 )
00033 {
00034 ++it;
00035 if (TQString(w->name()).startsWith("karamba"))
00036 {
00037 karamba* k = (karamba*) w;
00038
00039 if(k->theme().name() == name)
00040 {
00041 result = k;
00042 break;
00043 }
00044 }
00045 }
00046 delete list;
00047 return result;
00048 }
00049
00050 ThemesDlg* KarambaIface::getThemeWnd()
00051 {
00052 TQWidgetList *list = TQApplication::allWidgets();
00053 TQWidgetListIt it( *list );
00054 TQWidget* w;
00055 ThemesDlg* result = 0;
00056
00057 while ( (w=it.current()) != 0 )
00058 {
00059 ++it;
00060 if (TQString(w->name()) == "ThemesLayout")
00061 {
00062 result = (ThemesDlg*) w;
00063 break;
00064 }
00065 }
00066 delete list;
00067 return result;
00068 }
00069
00070 void KarambaIface::openTheme(TQString filename)
00071 {
00072 TQFileInfo file(filename);
00073 if(file.exists())
00074 {
00075 (new karamba(filename, TQString()))->show();
00076 }
00077 }
00078
00079 void KarambaIface::openNamedTheme(TQString filename, TQString name, bool is_sub_theme)
00080 {
00081 TQFileInfo file(filename);
00082 if(file.exists())
00083 {
00084 (new karamba(filename, name, false, -1, is_sub_theme))->show();
00085 }
00086 }
00087
00088 void KarambaIface::closeTheme(TQString name)
00089 {
00090 kdDebug() << "KarambaIface::closeTheme: " << name << endl;
00091 karamba* k;
00092
00093 while((k = getKaramba(name)))
00094 {
00095 k->writeConfigData();
00096 k->close(true);
00097 }
00098 }
00099
00100 int KarambaIface::themeAdded(TQString appId, TQString file)
00101 {
00102 ThemesDlg* tw = getThemeWnd();
00103 if(tw)
00104 return tw->addTheme(appId, file);
00105 return -1;
00106 }
00107
00108 void KarambaIface::themeNotify(TQString name, TQString text)
00109 {
00110 karamba* k = getKaramba(name);
00111 if(k)
00112 {
00113 k->themeNotify(name, text);
00114 }
00115 }
00116
00117 void KarambaIface::setIncomingData(TQString name, TQString text)
00118 {
00119 karamba* k = getKaramba(name);
00120 if(k)
00121 {
00122 k->_setIncomingData(text);
00123 }
00124 }
00125
00126 void KarambaIface::themeClosed(TQString appId, TQString file, int instance)
00127 {
00128 ThemesDlg* tw = getThemeWnd();
00129 if(tw)
00130 tw->removeTheme(appId, file, instance);
00131 }
00132
00133 bool KarambaIface::isMainKaramba()
00134 {
00135 if(getThemeWnd())
00136 return true;
00137 return false;
00138 }
00139
00140 void KarambaIface::quit()
00141 {
00142 karambaApp->quitSuperKaramba();
00143 }
00144
00145 void KarambaIface::hideSystemTray(bool hide)
00146 {
00147 karambaApp->hideSysTray(hide);
00148 }
00149
00150 void KarambaIface::showThemeDialog()
00151 {
00152 karambaApp->showThemeDialog();
00153 }