Baghira widget style for TDE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tdestyle_baghira_config.cpp 55KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  1. /***************************************************************************
  2. * Copyright (C) 2004 by Thomas Lübking *
  3. * thomas@home *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19. ***************************************************************************/
  20. #include <tqdesktopwidget.h>
  21. #include <tqlayout.h>
  22. #include <tqpushbutton.h>
  23. #include <tqcombobox.h>
  24. #include <tqcheckbox.h>
  25. #include <tqdir.h>
  26. #include <tqfile.h>
  27. #include <tqfileinfo.h>
  28. #include <tqgroupbox.h>
  29. #include <tdefiledialog.h>
  30. #include <tqpainter.h>
  31. //#include <tqpalette.h>
  32. // #include <tqsettings.h>
  33. #include <tqslider.h>
  34. #include <tqspinbox.h>
  35. #include <tqstringlist.h>
  36. #include <tqlabel.h>
  37. #include <tqlineedit.h>
  38. #include <tqpixmap.h>
  39. #include <tdelistview.h>
  40. #include <tqtabwidget.h>
  41. #include <tqtimer.h>
  42. #include <dcopclient.h>
  43. #include <tdeapplication.h>
  44. #include <kcolorbutton.h>
  45. #include <tdeconfig.h>
  46. #include <kimageeffect.h>
  47. #include <tdelocale.h>
  48. #include <tdemessagebox.h>
  49. #include <tdeglobal.h>
  50. #include <tdeglobalsettings.h>
  51. #include <kprocess.h>
  52. #include <tdeparts/genericfactory.h>
  53. #include <kstandarddirs.h>
  54. #include <X11/Xlib.h>
  55. #include <X11/Xatom.h>
  56. #include <X11/Xutil.h>
  57. #include <fixx11h.h>
  58. #include "tdestyle_baghira_config.h"
  59. #include "pixmaps.h"
  60. #include "colordialog.h"
  61. #include "colorpicker.h"
  62. #include "config.h"
  63. //#define VERSION "0.7"
  64. #ifndef TDE_VERSION_STRING
  65. #define TDE_VERSION_STRING "error"
  66. #endif
  67. #ifndef TQT_BUILD_KEY
  68. #define TQT_BUILD_KEY "error error error error"
  69. #endif
  70. #define CLAMP(x,l,u) x < l ? l :\
  71. x > u ? u :\
  72. x
  73. #define SATURATION_COLOR(R,G,B) \
  74. grey = (299 * R + 587 * G + 114 * B) / 1000; \
  75. delta = 255 - grey; \
  76. grey = (grey *(10 - 5)) / 10; \
  77. iGrey = 255 - grey;\
  78. destR = (iGrey * (srcR - delta) + grey * R) / 255; \
  79. destG = (iGrey * (srcG - delta) + grey * G) / 255; \
  80. destB = (iGrey * (srcB - delta) + grey * B) / 255;
  81. #define SATURATION_COLOR2(S,R,G,B) \
  82. int max = (int)(255+0.65*(100-S)); \
  83. destR = CLAMP((srcR + R - 128), 0, max); \
  84. destG = CLAMP((srcG + G - 128), 0, max); \
  85. destB = CLAMP((srcB + B - 128), 0, max); \
  86. destR = (S*destR + (100-S)*R)/100; \
  87. destG = (S*destG + (100-S)*G)/100; \
  88. destB = (S*destB + (100-S)*B)/100;
  89. #define COLOR_SPACE(R,G,B) \
  90. if ( R < 0 ) R = 0; else if ( R > 255 ) R = 255; \
  91. if ( G < 0 ) G = 0; else if ( G > 255 ) G = 255; \
  92. if ( B < 0 ) B = 0; else if ( B > 255 ) B = 255;
  93. void tdestyle_baghira_config::openHtml1()
  94. {
  95. TQStringList args;
  96. args << "exec" << "http://baghira.sf.net/";
  97. kapp->tdeinitExec("kfmclient", args);
  98. }
  99. void tdestyle_baghira_config::openHtml2()
  100. {
  101. TQStringList args;
  102. args << "exec" << "http://www.sf.net/projects/baghira/files/";
  103. kapp->tdeinitExec("kfmclient", args);
  104. }
  105. void tdestyle_baghira_config::startBab()
  106. {
  107. kapp->tdeinitExec("bab");
  108. }
  109. void tdestyle_baghira_config::startKRuler()
  110. {
  111. kapp->tdeinitExec("kruler");
  112. }
  113. TQImage* tdestyle_baghira_config::tintButton(TQImage &src, TQColor c)
  114. {
  115. TQImage *dest = new TQImage( src.width(), src.height(), 32, 0 );
  116. dest->setAlphaBuffer( true );
  117. unsigned int *data = ( unsigned int * ) src.bits();
  118. unsigned int *destData = ( unsigned int* ) dest->bits();
  119. int total = src.width() * src.height();
  120. int red, green, blue;
  121. int destR, destG, destB, alpha;
  122. int srcR = c.red();
  123. int srcG = c.green();
  124. int srcB = c.blue();
  125. int hue, s, v;
  126. c.getHsv( &hue, &s, &v );
  127. int sq = CLAMP((int)((45.0/128.0)*s+55),0,100);
  128. // float srcPercent, destPercent;
  129. for ( int current = 0 ; current < total ; ++current ) {
  130. alpha = tqAlpha( data[ current ] );
  131. blue = tqBlue( data[ current ] );
  132. red = tqRed( data[ current ] );
  133. green = tqGreen( data[ current ] );
  134. SATURATION_COLOR2(sq, red, green, blue);
  135. // force back to valid colorspace !
  136. COLOR_SPACE(destR, destG, destB);
  137. destData[ current ] = tqRgba( destR, destG, destB, alpha );
  138. }
  139. return ( dest );
  140. }
  141. TQImage* tdestyle_baghira_config::tintBrush( TQImage &img, TQColor c)
  142. {
  143. TQImage *dest = new TQImage( img.width(), img.height(), 32, 0 );
  144. unsigned int *data = ( unsigned int * ) img.bits();
  145. unsigned int *destData = ( unsigned int* ) dest->bits();
  146. int total = img.width() * img.height();
  147. int current;
  148. int delta;
  149. int red, green, blue, grey, iGrey;
  150. int destR, destG, destB, alpha;
  151. int srcR = c.red();
  152. int srcG = c.green();
  153. int srcB = c.blue();
  154. // float srcPercent, destPercent;
  155. for ( current = 0 ; current < total ; ++current ) {
  156. alpha = tqAlpha( data[ current ] );
  157. blue = tqBlue( data[ current ] );
  158. red = tqRed( data[ current ] );
  159. green = tqGreen( data[ current ] );
  160. SATURATION_COLOR(red, green, blue);
  161. // force back to valid colorspace !
  162. COLOR_SPACE(destR, destG, destB);
  163. destData[ current ] = tqRgba( destR, destG, destB, alpha );
  164. }
  165. return ( dest );
  166. }
  167. void tdestyle_baghira_config::sliderButtonRedChanged(int value)
  168. {
  169. sliderButtonRedValue = value;
  170. dialog_->valueButtonRed->setNum(value);
  171. dialog_->pixmapButtonPreview->setPixmap(*tintButton(baseImage, TQColor(sliderButtonRedValue, sliderButtonGreenValue, sliderButtonBlueValue)));
  172. dialog_->pixmapButtonPreview->repaint(false);
  173. configChanged();
  174. }
  175. void tdestyle_baghira_config::sliderButtonGreenChanged(int value)
  176. {
  177. sliderButtonGreenValue = value;
  178. dialog_->valueButtonGreen->setNum(value);
  179. dialog_->pixmapButtonPreview->setPixmap(*tintButton(baseImage, TQColor(sliderButtonRedValue, sliderButtonGreenValue, sliderButtonBlueValue)));
  180. dialog_->pixmapButtonPreview->repaint(false);
  181. configChanged();
  182. }
  183. void tdestyle_baghira_config::sliderButtonBlueChanged(int value)
  184. {
  185. sliderButtonBlueValue = value;
  186. dialog_->valueButtonBlue->setNum(value);
  187. dialog_->pixmapButtonPreview->setPixmap(*tintButton(baseImage, TQColor(sliderButtonRedValue, sliderButtonGreenValue, sliderButtonBlueValue)));
  188. dialog_->pixmapButtonPreview->repaint(false);
  189. configChanged();
  190. }
  191. void tdestyle_baghira_config::sliderBrushRedChanged(int value)
  192. {
  193. sliderBrushRedValue = value;
  194. dialog_->pixmapBrushPreview->setPixmap(*tintBrush(baseImage2, TQColor(sliderBrushRedValue, sliderBrushGreenValue, sliderBrushBlueValue)));
  195. dialog_->pixmapBrushPreview->repaint(false);
  196. configChanged();
  197. }
  198. void tdestyle_baghira_config::sliderBrushGreenChanged(int value)
  199. {
  200. sliderBrushGreenValue = value;
  201. dialog_->pixmapBrushPreview->setPixmap(*tintBrush(baseImage2, TQColor(sliderBrushRedValue, sliderBrushGreenValue, sliderBrushBlueValue)));
  202. dialog_->pixmapBrushPreview->repaint(false);
  203. configChanged();
  204. }
  205. void tdestyle_baghira_config::sliderBrushBlueChanged(int value)
  206. {
  207. sliderBrushBlueValue = value;
  208. dialog_->pixmapBrushPreview->setPixmap(*tintBrush(baseImage2, TQColor(sliderBrushRedValue, sliderBrushGreenValue, sliderBrushBlueValue)));
  209. dialog_->pixmapBrushPreview->repaint(false);
  210. configChanged();
  211. }
  212. // void tdestyle_baghira_config::sliderBrushSaturationChanged(int value)
  213. // {
  214. // sliderBrushSaturationValue = value;
  215. // dialog_->pixmapBrushPreview->setPixmap(*tintBrush(baseImage2, TQColor(sliderBrushRedValue, sliderBrushGreenValue, sliderBrushBlueValue), sliderBrushSaturationValue));
  216. // dialog_->pixmapBrushPreview->repaint(false);
  217. // emit changed(true);
  218. // }
  219. // button color preset table - internal only, AND DON'T CHANGE ONLY ONE!
  220. enum ColorPreset {Aqua = 0, Graphite, GraphiteDark, Orange, Lime, Black, Smoke, Girlie, Smaragd, Emerald, Yellow, DeepBlueSea, Blood, Turquoise, Lilac, NUMBEROFCOLORS};
  221. const char * presetColorName[NUMBEROFCOLORS] = {
  222. "Aqua", "Graphite", "Graphite (Dark)", "Orange", "Lime", "Black", "Smoke", "Girlie", "Smaragd", "Emerald", "Yellow", "Deep Blue Sea", "Blood", "Turquoise", "Lilac"
  223. };
  224. int presetColor[NUMBEROFCOLORS][3] = {{84,144,218},{130,170,190},{103,118,134},{200,130,30},{130,180,80},{0,0,0},{106,110,120},{255,130,200},{100,160,75},{255,100,90},{160,160,70},{50,100,200},{150,25,25},{60,170,190},{150,130,220}};
  225. // --------------------------------
  226. typedef KGenericFactory<tdestyle_baghira_config, TQWidget> tdestyle_baghira_configFactory;
  227. K_EXPORT_COMPONENT_FACTORY( tdecm_tdestyle_baghira_config, tdestyle_baghira_configFactory("tdecmtdestyle_baghira_config"))
  228. //extern TQImage uic_findImage(const TQString& name);
  229. //extern void qInitImages_baghira();
  230. //extern void qCleanupImages_baghira();
  231. void tdestyle_baghira_config::updateCR()
  232. {
  233. if (!about_->isShown())
  234. {
  235. timer->stop();
  236. return;
  237. }
  238. if (crCurrent < 2)
  239. crCurrent++;
  240. else
  241. crCurrent = 0;
  242. about_->crLabel->setText(crNotes[crCurrent]);
  243. }
  244. void tdestyle_baghira_config::showAbout()
  245. {
  246. crCurrent = 0;
  247. about_->crLabel->setText(crNotes[0]);
  248. timer->start( 4000 );
  249. about_->exec();
  250. }
  251. tdestyle_baghira_config::tdestyle_baghira_config(TQWidget *parent, const char *name, const TQStringList&) : TQWidget(parent, name )//, myAboutData(0)
  252. {
  253. loadDone = false;
  254. if (parent) parent->setCaption("Configure Your Cat");
  255. TQVBoxLayout *layout = new TQVBoxLayout(this);
  256. dialog_ = new Config(this);
  257. for (int i = 0; i < NUMBEROFCOLORS; i++)
  258. dialog_->colorPresets->insertItem ( presetColorName[i], i );
  259. TQWidget *rulesWidget = new TQWidget(dialog_->tabWidget);
  260. TQHBoxLayout *rwlh = new TQHBoxLayout(rulesWidget);
  261. applist = new TDEListView(rulesWidget);
  262. applist->setFullWidth(true);
  263. #if KDE_IS_VERSION(3,3,91)
  264. applist->setShadeSortColumn(false);
  265. #endif
  266. applist->setAllColumnsShowFocus( true );
  267. applist->setSelectionMode(TQListView::Single);
  268. applist->addColumn ( i18n("Name") );
  269. applist->addColumn ( i18n("Links to") );
  270. TQDir d( TQDir::homeDirPath() + "/.baghira", 0L, TQDir::Name | TQDir::IgnoreCase, TQDir::Files | TQDir::Readable | TQDir::Writable );
  271. if (!d.exists())
  272. d.mkdir(TQDir::homeDirPath() + "/.baghira");
  273. else
  274. {
  275. for ( uint i = 0; i < d.count(); i++ )
  276. {
  277. TQFileInfo FI = TQFileInfo(d, d[i]);
  278. if (FI.isSymLink())
  279. applist->insertItem(new TDEListViewItem(applist, d[i], FI.readLink().section('/',-1,-1)));
  280. else
  281. applist->insertItem(new TDEListViewItem(applist, d[i]));
  282. }
  283. }
  284. rwlh->addWidget(applist);
  285. // rwlh->addLayout(rwlv);
  286. TQVBoxLayout *rwlv = new TQVBoxLayout(rwlh);
  287. rwlv->addStretch();
  288. TQPushButton *btnNew = new TQPushButton("New...", rulesWidget);
  289. TQPushButton *btnEdit = new TQPushButton("Edit...", rulesWidget);
  290. TQPushButton *btnDel = new TQPushButton("Remove", rulesWidget);
  291. TQPushButton *btnDet = new TQPushButton("Detect", rulesWidget);
  292. rwlv->addWidget(btnNew);
  293. rwlv->addWidget(btnEdit);
  294. rwlv->addWidget(btnDel);
  295. rwlv->addSpacing( 5 );
  296. rwlv->addWidget(btnDet);
  297. rwlv->addStretch();
  298. dialog_->tabWidget->addTab( rulesWidget, TQString("Rules") );
  299. appsetter = new AppSetter(this);
  300. connect(btnNew, SIGNAL(clicked()), appsetter, SLOT(show()));
  301. connect(btnEdit, SIGNAL(clicked()), this, SLOT(editApp()));
  302. connect(this, SIGNAL(editApp(TQString, TQString)), appsetter, SLOT(show(TQString, TQString)));
  303. connect(btnDel, SIGNAL(clicked()), this, SLOT(removeApp()));
  304. connect(btnDet, SIGNAL(clicked()), this, SLOT(selectWindow()));
  305. connect(appsetter, SIGNAL(addApp(TQString, TQString)), this, SLOT(addApp(TQString, TQString)));
  306. connect(appsetter, SIGNAL(removeApp(TQString)), this, SLOT(removeApp(TQString)));
  307. // preview stuff
  308. baseImage = uic_findImage("button-base");
  309. layout->addWidget(dialog_);
  310. dialog_->show();
  311. help_ = new Help(dialog_);
  312. about_ = new About(dialog_);
  313. about_->versionLabel->setText(VERSION);
  314. about_->kdeLabel->setText(TDE_VERSION_STRING);
  315. crCurrent = 0;
  316. crNotes[0] = "<qt>© 2003-2005 by Thomas Lübking<br>http://baghira.SourceForge.net</qt>";
  317. crNotes[1] = "<qt>© \"Design\" 2001-2005 by Apple inc.<br>http://www.apple.com";
  318. crNotes[2] = "<qt>© \"Milk\" 2002-2005 by Max Rudberg<br>http://www.maxthemes.com</qt>";
  319. timer = new TQTimer();
  320. connect( timer, SIGNAL(timeout()), this, SLOT(updateCR()) );
  321. TQString tmpString(TQT_BUILD_KEY);
  322. about_->systemLabel->setText(tmpString.section(' ',1,1));
  323. about_->cpuLabel->setText(tmpString.section(' ',0,0));
  324. about_->setFixedSize (380, 430);
  325. // connections
  326. // buttons
  327. connect(dialog_->buttonHelp, SIGNAL(clicked()), help_, SLOT(exec()));
  328. connect(dialog_->buttonAbout, SIGNAL(clicked()), this, SLOT(showAbout()));
  329. connect(about_->buttonInfo, SIGNAL(clicked()), this, SLOT(openHtml1()));
  330. connect(about_->buttonDownload, SIGNAL(clicked()), this, SLOT(openHtml2()));
  331. connect(help_->startBAB, SIGNAL(clicked()), this, SLOT(startBab()));
  332. connect(dialog_->startKRuler, SIGNAL(clicked()), this, SLOT(startKRuler()));
  333. connect(dialog_->buttonLoad, SIGNAL(clicked()), this, SLOT(buttonLoadAction()));
  334. connect(dialog_->buttonSaveAs, SIGNAL(clicked()), this, SLOT(buttonSaveAsAction()));
  335. connect(dialog_->colorPresets, SIGNAL(activated(int)), this, SLOT(setPresetColor(int)));
  336. // changes
  337. connect(dialog_->defaultStyle, SIGNAL(activated(int)), this, SLOT(configChanged()));
  338. connect(dialog_->buttonStyle, SIGNAL(activated(int)), this, SLOT(handleButtonStyles(int)));
  339. connect(dialog_->toolbuttonStyle, SIGNAL(activated(int)), this, SLOT(handleButtonStyles(int)));
  340. connect(dialog_->animateButtons, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  341. connect(dialog_->stippleBackground, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  342. connect(dialog_->bevelHighlights, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  343. connect(dialog_->stippleContrast, SIGNAL(valueChanged (int)), this, SLOT(configChanged()));
  344. connect(dialog_->shadowGroups, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  345. connect(dialog_->shadowIntensity, SIGNAL(valueChanged (int)), this, SLOT(configChanged()));
  346. connect(dialog_->centerTabs, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  347. connect(dialog_->colorMode, SIGNAL(activated(int)), this, SLOT(configChanged()));
  348. connect(dialog_->inactiveColorType, SIGNAL(activated(int)), this, SLOT(configChanged()));
  349. connect(dialog_->animateSlider, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  350. connect(dialog_->shadowSlider, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  351. connect(dialog_->squeezeSlider, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  352. connect(dialog_->unhoveredToolButtons, SIGNAL(activated(int)), this, SLOT(configChanged()));
  353. connect(dialog_->aquaTabs, SIGNAL(activated(int)), this, SLOT(configChanged()));
  354. connect(dialog_->brushedTabs, SIGNAL(activated(int)), this, SLOT(configChanged()));
  355. connect(dialog_->drawTreeLines, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  356. connect(dialog_->useCustomExpanderColor, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  357. connect(dialog_->treeLineMode, SIGNAL(activated(int)), this, SLOT(configChanged()));
  358. connect(dialog_->expanderMode, SIGNAL(activated(int)), this, SLOT(configChanged()));
  359. connect(dialog_->useCustomExpanderColor, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  360. connect(dialog_->useRectLVH, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  361. connect(dialog_->removeKickerBevel, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  362. connect(dialog_->replaceMenubar, SIGNAL(toggled(bool)), this, SLOT(menuToggled(bool)));
  363. connect(dialog_->roundTasks, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  364. connect(dialog_->showProgressValue, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  365. connect(dialog_->progressType, SIGNAL(activated(int)), this, SLOT(configChanged()));
  366. connect(dialog_->menuBackground, SIGNAL(activated(int)), this, SLOT(configChanged()));
  367. connect(dialog_->menuOpacity, SIGNAL(valueChanged (int)), this, SLOT(configChanged()));
  368. connect(dialog_->shadowMenuText, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  369. connect(dialog_->menuColorMode, SIGNAL(activated(int)), this, SLOT(configChanged()));
  370. connect(dialog_->useCustomColors, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  371. connect(dialog_->drawMenuStripe, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  372. connect(dialog_->glossyMenus, SIGNAL(stateChanged(int)), this, SLOT(configChanged()));
  373. connect(dialog_->customInactiveColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  374. connect(dialog_->toolbuttonHighColor, SIGNAL(changed(const TQColor &)), this, SLOT(changeTooluttonHighlightColor(const TQColor &)));
  375. connect(dialog_->treeLineColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  376. connect(dialog_->customExpanderColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  377. connect(dialog_->menuTextColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  378. connect(dialog_->menuTextColorHigh, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  379. connect(dialog_->menuColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  380. connect(dialog_->menuColorHigh, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  381. connect(dialog_->menuColor2, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  382. connect(dialog_->radioOffColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  383. connect(dialog_->radioOnColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  384. connect(dialog_->checkOffColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  385. connect(dialog_->checkOnColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  386. connect(dialog_->sliderColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  387. connect(dialog_->hoverSliderColorColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  388. connect(dialog_->pressedSliderColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  389. connect(dialog_->inactiveTabColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  390. connect(dialog_->activeTabColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  391. connect(dialog_->menuStripeColor, SIGNAL(changed(const TQColor &)), this, SLOT(configChanged()));
  392. connect(dialog_->sliderButtonRed, SIGNAL(valueChanged (int)), this, SLOT(sliderButtonRedChanged(int)));
  393. connect(dialog_->sliderButtonGreen, SIGNAL(valueChanged (int)), this, SLOT(sliderButtonGreenChanged(int)));
  394. connect(dialog_->sliderButtonBlue, SIGNAL(valueChanged (int)), this, SLOT(sliderButtonBlueChanged(int)));
  395. connect(dialog_->sliderBrushRed, SIGNAL(valueChanged (int)), this, SLOT(sliderBrushRedChanged(int)));
  396. connect(dialog_->sliderBrushGreen, SIGNAL(valueChanged (int)), this, SLOT(sliderBrushGreenChanged(int)));
  397. connect(dialog_->sliderBrushBlue, SIGNAL(valueChanged (int)), this, SLOT(sliderBrushBlueChanged(int)));
  398. // GUI
  399. connect (dialog_->defaultStyle, SIGNAL(activated(int)), this, SLOT(setDesign(int)));
  400. connect (dialog_->inactiveColorType, SIGNAL(activated(int)), this, SLOT(enableInButtonColor(int)));
  401. connect (dialog_->drawTreeLines, SIGNAL(toggled(bool)), dialog_->treeLineMode, SLOT(setEnabled(bool)));
  402. connect (dialog_->drawTreeLines, SIGNAL(toggled(bool)), dialog_->treeLineColor, SLOT(setEnabled(bool)));
  403. connect (dialog_->useCustomExpanderColor, SIGNAL(toggled(bool)), dialog_->customExpanderColor, SLOT(setEnabled(bool)));
  404. connect (dialog_->menuColorMode, SIGNAL(activated(int)), this, SLOT(enableMenuColorStuff(int)));
  405. connect (dialog_->menuBackground, SIGNAL(activated(int)), this, SLOT(enableMenuColorStuff(int)));
  406. connect (dialog_->drawMenuStripe, SIGNAL(toggled(bool)), dialog_->menuStripeColor, SLOT(setEnabled(bool)));
  407. // connect (dialog_->tintBrush, SIGNAL(toggled(bool)), dialog_->brushBox, SLOT(setEnabled(bool)));
  408. connect (dialog_->useCustomColors, SIGNAL(toggled(bool)), dialog_->colorFrame, SLOT(setEnabled(bool)));
  409. // load settings
  410. load();
  411. loadDone = true;
  412. dialog_->pixmapButtonPreview->setPixmap(*tintButton(baseImage, TQColor(sliderButtonRedValue, sliderButtonGreenValue, sliderButtonBlueValue)));
  413. };
  414. tdestyle_baghira_config::~tdestyle_baghira_config()
  415. {
  416. if (timer) delete timer;
  417. }
  418. void tdestyle_baghira_config::setPresetColor(int i)
  419. {
  420. dialog_->sliderButtonRed->setValue(presetColor[i][0]);
  421. dialog_->sliderButtonGreen->setValue(presetColor[i][1]);
  422. dialog_->sliderButtonBlue->setValue(presetColor[i][2]);
  423. }
  424. void tdestyle_baghira_config::load()
  425. {
  426. TQString tmpString = TQDir::homeDirPath() + "/.qt/baghirarc";
  427. load (tmpString);
  428. }
  429. void tdestyle_baghira_config::load(TQString &fileName)
  430. {
  431. TDEConfig *config = new TDEConfig(fileName);
  432. // TQSettings config;
  433. config->setGroup("BAB");
  434. // general Design
  435. dialog_->defaultStyle->setCurrentItem(config->readNumEntry("defaultState", 0 ));
  436. // config->endGroup();
  437. config->setGroup("Style");
  438. dialog_->buttonStyle->setCurrentItem(config->readNumEntry("Special_ButtonStyle", 1 ));
  439. dialog_->toolbuttonStyle->setCurrentItem(config->readNumEntry("Special_ToolbuttonStyle", 1 ));
  440. dialog_->stippleBackground->setChecked( config->readBoolEntry( "Design_StippleBackground", true));
  441. dialog_->animateButtons->setChecked( config->readBoolEntry( "Design_AnimateButtons", true));
  442. dialog_->stippleContrast->setValue( config->readNumEntry( "Design_StippleContrast", 3));
  443. dialog_->shadowGroups->setChecked( config->readBoolEntry( "Design_ShadowGroupBoxes", true));
  444. dialog_->shadowIntensity->setValue( config->readNumEntry( "Design_GroupBoxeShadowDarkness", 6));
  445. dialog_->bevelHighlights->setChecked( config->readBoolEntry( "Design_BevelAsHighlight", true));
  446. dialog_->colorMode->setCurrentItem(config->readNumEntry("Design_ButtonStyle", 0));
  447. dialog_->inactiveColorType->setCurrentItem(config->readNumEntry( "Design_InactiveButtonStyle", 1));
  448. dialog_->customInactiveColor->setColor(TQColor(config->readNumEntry("Design_InactiveButtonColor",(int)colorGroup().background().rgb())));
  449. dialog_->centerTabs->setChecked( config->readBoolEntry( "Design_CenterTabs", true));
  450. // button color stuff
  451. TQColor tmpColor = TQColor(config->readNumEntry("Design_ButtonColor",(int)colorGroup().button().rgb()));
  452. dialog_->sliderButtonRed->setValue(sliderButtonRedValue = tmpColor.red());
  453. dialog_->sliderButtonGreen->setValue(sliderButtonGreenValue = tmpColor.green());
  454. dialog_->sliderButtonBlue->setValue(sliderButtonBlueValue = tmpColor.blue());
  455. dialog_->valueButtonRed->setNum(sliderButtonRedValue);
  456. dialog_->valueButtonGreen->setNum(sliderButtonGreenValue);
  457. dialog_->valueButtonBlue->setNum(sliderButtonBlueValue);
  458. // special Widgets
  459. //ListViews
  460. dialog_->useRectLVH->setChecked( config->readBoolEntry( "Special_UseFlatLVH", false));
  461. dialog_->drawTreeLines->setChecked( config->readBoolEntry( "Special_DrawTreeLines", false));
  462. dialog_->treeLineMode->setCurrentItem(config->readNumEntry( "Special_TreelineStyle", 0));
  463. dialog_->treeLineColor->setColor( TQColor( config->readNumEntry( "Special_TreelineColor", (int) colorGroup().mid().rgb())));
  464. dialog_->expanderMode->setCurrentItem(config->readNumEntry( "Special_ExpanderStyle", 0));
  465. dialog_->useCustomExpanderColor->setChecked( config->readBoolEntry( "Special_CustomExpanderColor", false));
  466. dialog_->customExpanderColor->setColor( TQColor( config->readNumEntry( "Special_ExpanderColor", (int) colorGroup().text().rgb())));
  467. //Kicker
  468. dialog_->removeKickerBevel->setChecked( config->readBoolEntry( "Special_RemoveKickerBevel", true));
  469. dialog_->roundTasks->setChecked( config->readBoolEntry( "Special_RoundTaskbuttons", false));
  470. TQFile file(TDEGlobal::dirs()->localtdedir() + TDEStandardDirs::kde_default("data") + "kicker/applets/menuapplet.desktop");
  471. dialog_->replaceMenubar->setChecked( menuReplaced = file.exists() );
  472. //Scrollbars
  473. dialog_->animateSlider->setChecked( config->readBoolEntry( "Special_AnimateSlider", true));
  474. dialog_->shadowSlider->setChecked( config->readBoolEntry( "Special_ShadowSlider", false));
  475. dialog_->squeezeSlider->setChecked( config->readBoolEntry( "Special_SqueezeSlider", false));
  476. //Progress
  477. dialog_->progressType->setCurrentItem( config->readNumEntry( "Special_ProgressStyle", 0));
  478. dialog_->showProgressValue->setChecked( config->readBoolEntry( "Special_ShowProgressValue", false));
  479. //Toolbars
  480. dialog_->unhoveredToolButtons->setCurrentItem(config->readNumEntry( "Special_UnhoveredToolButtons", 2));
  481. //Tabs
  482. dialog_->aquaTabs->setCurrentItem(config->readNumEntry("Design_TabStyleAqua", 0 ));
  483. dialog_->brushedTabs->setCurrentItem(config->readNumEntry("Design_TabStyleBrushed", 1 ));
  484. // menus
  485. dialog_->menuBackground->setCurrentItem( config->readNumEntry( "Menu_Background", 0));
  486. dialog_->menuOpacity->setValue( config->readNumEntry( "Menu_Opacity", 70));
  487. //Look
  488. dialog_->shadowMenuText->setChecked( config->readBoolEntry( "Menu_ShadowText", true));
  489. dialog_->menuColorMode->setCurrentItem(config->readNumEntry("Menu_ColorStyle"));
  490. dialog_->menuTextColor->setColor( TQColor( config->readNumEntry( "Menu_TextColor", (int) colorGroup().text().rgb())));
  491. dialog_->menuTextColorHigh->setColor( TQColor( config->readNumEntry( "Menu_TextColorHighlight", (int) colorGroup().highlightedText().rgb())));
  492. dialog_->menuColor->setColor( TQColor( config->readNumEntry( "Menu_Color1", (int) colorGroup().background().rgb())));
  493. dialog_->menuColor2->setColor( TQColor( config->readNumEntry( "Menu_Color2", (int) colorGroup().background().dark(130).rgb())));
  494. dialog_->menuColorHigh->setColor( TQColor( config->readNumEntry( "Menu_ColorHighlight", (int) colorGroup().highlight().rgb())));
  495. dialog_->drawMenuStripe->setChecked(config->readBoolEntry( "Menu_DrawMenuStripe", false));
  496. dialog_->glossyMenus->setChecked(config->readBoolEntry( "Menu_Glossy", true));
  497. dialog_->menuStripeColor->setColor( TQColor( config->readNumEntry( "Menu_StripeColor", (int) TQt::white.rgb())));
  498. // custom colors
  499. dialog_->useCustomColors->setChecked( config->readBoolEntry( "Colors_UseCustomColors", false));
  500. dialog_->radioOffColor->setColor( TQColor( config->readNumEntry( "Colors_RadioOff", ( int ) colorGroup().background().rgb())));
  501. dialog_->radioOnColor->setColor( TQColor( config->readNumEntry( "Colors_RadioOn", ( int ) colorGroup().button().rgb())));
  502. dialog_->checkOffColor->setColor( TQColor( config->readNumEntry( "Colors_CheckOff", ( int ) colorGroup().background().rgb())));
  503. dialog_->checkOnColor->setColor( TQColor( config->readNumEntry( "Colors_CheckOn", ( int ) colorGroup().button().rgb())));
  504. dialog_->sliderColor->setColor( TQColor( config->readNumEntry( "Colors_Slider", ( int ) colorGroup().button().rgb())));
  505. dialog_->hoverSliderColorColor->setColor(TQColor(config->readNumEntry("Colors_SliderHovered",(int)colorGroup().button().rgb())));
  506. dialog_->pressedSliderColor->setColor(TQColor(config->readNumEntry("Colors_SliderPressed",(int) colorGroup().button().dark(110).rgb())));
  507. dialog_->sliderGrooveColor->setColor(TQColor(config->readNumEntry("Colors_SliderGroove",(int)colorGroup().background().rgb())));
  508. dialog_->inactiveTabColor->setColor(TQColor(config->readNumEntry("Colors_TabInactive",(int) colorGroup().background().rgb())));
  509. dialog_->activeTabColor->setColor(TQColor(config->readNumEntry("Colors_TabActive",(int)colorGroup().button().rgb())));
  510. dialog_->tintBrush->setChecked( config->readBoolEntry( "Colors_TintBrushedMetal", false));
  511. brushTint = TQColor(config->readNumEntry("Colors_BrushTint",(int)colorGroup().background().rgb()));
  512. // dialog_->brushTintSaturaion->setValue(settings.readNumEntry( "/qt/Baghira/brushTintSaturation", 3));
  513. baseImage2 = uic_findImage("brush-me");
  514. dialog_->pixmapBrushPreview->setPixmap(*tintBrush(baseImage2, brushTint));
  515. dialog_->sliderBrushRed->setValue(sliderBrushRedValue = brushTint.red());
  516. dialog_->sliderBrushGreen->setValue(sliderBrushGreenValue = brushTint.green());
  517. dialog_->sliderBrushBlue->setValue(sliderBrushBlueValue = brushTint.blue());
  518. config->setGroup("Menubar");
  519. dialog_->menuMaxWidth->setValue(config->readNumEntry("Width", TQDesktopWidget().availableGeometry().width()));
  520. config->setGroup("Sidebar");
  521. delete config;
  522. config = new TDEConfig("kdeglobals");
  523. config->setGroup( "Toolbar style" );
  524. dialog_->toolbuttonHighColor->setColor(config->readColorEntry("HighlightColor", new TQColor(103,141,178)) );
  525. delete config;
  526. }
  527. void tdestyle_baghira_config::defaults()
  528. {
  529. dialog_->defaultStyle->setCurrentItem(0);
  530. dialog_->buttonStyle->setCurrentItem(1);
  531. dialog_->toolbuttonStyle->setCurrentItem(1);
  532. dialog_->animateButtons->setChecked( true);
  533. dialog_->stippleBackground->setChecked( true);
  534. dialog_->stippleContrast->setValue( 30);
  535. dialog_->shadowGroups->setChecked( true);
  536. dialog_->shadowIntensity->setValue( 50);
  537. dialog_->bevelHighlights->setChecked( true );
  538. dialog_->centerTabs->setChecked( true);
  539. dialog_->colorMode->setCurrentItem(0);
  540. dialog_->inactiveColorType->setCurrentItem(1);
  541. dialog_->customInactiveColor->setColor(colorGroup().background().rgb());
  542. // button color stuff
  543. dialog_->sliderButtonRed->setValue(sliderButtonRedValue = colorGroup().button().red());
  544. dialog_->sliderButtonGreen->setValue(sliderButtonGreenValue = colorGroup().button().green());
  545. dialog_->sliderButtonBlue->setValue(sliderButtonBlueValue = colorGroup().button().blue());
  546. dialog_->valueButtonRed->setNum(sliderButtonRedValue);
  547. dialog_->valueButtonGreen->setNum(sliderButtonGreenValue);
  548. dialog_->valueButtonBlue->setNum(sliderButtonBlueValue);
  549. // special Widgets
  550. // dialog_->animateSlider;
  551. dialog_->shadowSlider->setChecked( false);
  552. dialog_->squeezeSlider->setChecked( false);
  553. dialog_->unhoveredToolButtons->setCurrentItem(2);
  554. dialog_->toolbuttonHighColor->setColor( TQColor(103,141,178) );
  555. dialog_->drawTreeLines->setChecked( false);
  556. dialog_->useCustomExpanderColor->setChecked( false);
  557. dialog_->treeLineMode->setCurrentItem(0);
  558. dialog_->treeLineColor->setColor( colorGroup().mid().rgb());
  559. dialog_->expanderMode->setCurrentItem(0);
  560. dialog_->customExpanderColor->setColor( colorGroup().text().rgb());
  561. dialog_->useRectLVH->setChecked( false);
  562. dialog_->removeKickerBevel->setChecked( true);
  563. dialog_->roundTasks->setChecked( false);
  564. dialog_->showProgressValue->setChecked( false);
  565. dialog_->progressType->setCurrentItem( 0);
  566. dialog_->aquaTabs->setCurrentItem( 0 );
  567. dialog_->brushedTabs->setCurrentItem(1);
  568. // menus
  569. // dialog_->transGroup;
  570. dialog_->menuBackground->setCurrentItem(0);
  571. dialog_->menuOpacity->setValue( 70);
  572. dialog_->shadowMenuText->setChecked( true);
  573. dialog_->menuColorMode->setCurrentItem(0);
  574. dialog_->menuTextColor->setColor( colorGroup().text().rgb());
  575. dialog_->menuTextColorHigh->setColor( colorGroup().highlightedText().rgb());
  576. dialog_->menuColor->setColor( colorGroup().background().rgb());
  577. dialog_->menuColor2->setColor( colorGroup().background().dark(130).rgb());
  578. dialog_->menuColorHigh->setColor( colorGroup().highlight().rgb());
  579. dialog_->drawMenuStripe->setChecked(false);
  580. dialog_->glossyMenus->setChecked(true);
  581. dialog_->menuStripeColor->setColor( TQt::white.rgb());
  582. // custom colors
  583. dialog_->useCustomColors->setChecked( false);
  584. dialog_->radioOffColor->setColor( colorGroup().background().rgb());
  585. dialog_->radioOnColor->setColor( colorGroup().button().rgb());
  586. dialog_->checkOffColor->setColor( colorGroup().background().rgb());
  587. dialog_->checkOnColor->setColor( colorGroup().button().rgb());
  588. dialog_->sliderColor->setColor( colorGroup().button().rgb());
  589. dialog_->hoverSliderColorColor->setColor(colorGroup().button().rgb());
  590. dialog_->pressedSliderColor->setColor(colorGroup().button().dark(110).rgb());
  591. dialog_->sliderGrooveColor->setColor(colorGroup().background().rgb());
  592. dialog_->inactiveTabColor->setColor(colorGroup().background().rgb());
  593. dialog_->activeTabColor->setColor(colorGroup().button().rgb());
  594. dialog_->tintBrush->setChecked( false);
  595. emit changed(true);
  596. }
  597. void tdestyle_baghira_config::save()
  598. {
  599. TQString tmpString = TQDir::homeDirPath() + "/.qt/baghirarc";
  600. save(tmpString);
  601. // emit changed(true);
  602. }
  603. void tdestyle_baghira_config::changeTooluttonHighlightColor(const TQColor & color)
  604. {
  605. TDEConfig *config = new TDEConfig("kdeglobals");
  606. config->setGroup( "Toolbar style" );
  607. config->writeEntry("HighlightColor", color);
  608. delete config;
  609. }
  610. void tdestyle_baghira_config::handleButtonStyles(int i)
  611. {
  612. if (i != 2 && sender() == dialog_->buttonStyle && dialog_->toolbuttonStyle->currentItem() != 2)
  613. dialog_->toolbuttonStyle->setCurrentItem(i);
  614. else if (i != 2 && sender() == dialog_->toolbuttonStyle && dialog_->buttonStyle->currentItem() != 2)
  615. dialog_->buttonStyle->setCurrentItem(i);
  616. configChanged();
  617. }
  618. void tdestyle_baghira_config::save(TQString &fileName)
  619. {
  620. // TQSettings *config = new TQSettings;
  621. TDEConfig *config = new TDEConfig(fileName);
  622. config->setGroup("BAB");
  623. //General Design
  624. config->writeEntry("defaultState", dialog_->defaultStyle->currentItem());
  625. // config->endGroup();
  626. config->setGroup("Style");
  627. config->writeEntry("Special_ButtonStyle", dialog_->buttonStyle->currentItem());
  628. config->writeEntry("Special_ToolbuttonStyle", dialog_->toolbuttonStyle->currentItem());
  629. config->writeEntry("Design_AnimateButtons", dialog_->animateButtons->isOn());
  630. config->writeEntry("Design_Default", dialog_->defaultStyle->currentItem());
  631. config->writeEntry("Design_StippleBackground", dialog_->stippleBackground->isOn());
  632. config->writeEntry("Design_StippleContrast", dialog_->stippleContrast->value());
  633. config->writeEntry("Design_ShadowGroupBoxes", dialog_->shadowGroups->isOn());
  634. config->writeEntry("Design_GroupBoxeShadowDarkness", dialog_->shadowIntensity->value());
  635. config->writeEntry("Design_BevelAsHighlight", dialog_->bevelHighlights->isOn());
  636. config->writeEntry("Design_ButtonStyle", dialog_->colorMode->currentItem());
  637. config->writeEntry("Design_InactiveButtonStyle", dialog_->inactiveColorType->currentItem());
  638. config->writeEntry("Design_InactiveButtonColor", (int)dialog_->customInactiveColor->color().rgb());
  639. config->writeEntry("Design_CenterTabs", dialog_->centerTabs->isOn());
  640. //button color stuff
  641. config->writeEntry("Design_ButtonColor", (int)(TQColor(sliderButtonRedValue, sliderButtonGreenValue, sliderButtonBlueValue).rgb()));
  642. // special Widgets
  643. //listviews
  644. // dialog_->animateSlider;
  645. config->writeEntry("Special_UseFlatLVH", dialog_->useRectLVH->isOn());
  646. config->writeEntry("Special_DrawTreeLines", dialog_->drawTreeLines->isOn());
  647. config->writeEntry("Special_TreelineStyle", dialog_->treeLineMode->currentItem());
  648. config->writeEntry("Special_TreelineColor", (int)dialog_->treeLineColor->color().rgb());
  649. config->writeEntry("Special_ExpanderStyle", dialog_->expanderMode->currentItem());
  650. config->writeEntry("Special_CustomExpanderColor", dialog_->useCustomExpanderColor->isOn());
  651. config->writeEntry("Special_ExpanderColor", (int)dialog_->customExpanderColor->color().rgb());
  652. //Kicker
  653. config->writeEntry("Special_RemoveKickerBevel", dialog_->removeKickerBevel->isOn());
  654. config->writeEntry("Special_RoundTaskbuttons", dialog_->roundTasks->isOn());
  655. TQDir tmpDir(TDEGlobal::dirs()->localtdedir());
  656. if (!tmpDir.exists()) tmpDir.mkdir(TDEGlobal::dirs()->localtdedir());
  657. tmpDir.setPath(TDEGlobal::dirs()->localtdedir() + "share");
  658. if (!tmpDir.exists()) tmpDir.mkdir(TDEGlobal::dirs()->localtdedir() + "share");
  659. tmpDir.setPath(TDEGlobal::dirs()->localtdedir() + TDEStandardDirs::kde_default("data"));
  660. if (!tmpDir.exists()) tmpDir.mkdir(TDEGlobal::dirs()->localtdedir() + TDEStandardDirs::kde_default("data"));
  661. tmpDir.setPath(TDEGlobal::dirs()->localtdedir() + TDEStandardDirs::kde_default("data") + "kicker");
  662. if (!tmpDir.exists()) tmpDir.mkdir(TDEGlobal::dirs()->localtdedir() + TDEStandardDirs::kde_default("data") + "kicker");
  663. tmpDir.setPath(TDEGlobal::dirs()->localtdedir() + TDEStandardDirs::kde_default("data") + "kicker/applets");
  664. if (!tmpDir.exists()) tmpDir.mkdir(TDEGlobal::dirs()->localtdedir() + TDEStandardDirs::kde_default("data") + "kicker/applets");
  665. TQFile file(TDEGlobal::dirs()->localtdedir() + TDEStandardDirs::kde_default("data") + "kicker/applets/menuapplet.desktop");
  666. if (dialog_->replaceMenubar->isOn())
  667. {
  668. file.open(IO_WriteOnly);
  669. const char *msg =
  670. "[Desktop Entry]\n\
  671. Hidden=true\n\
  672. Type=Plugin\n\
  673. Encoding=UTF-8\n\
  674. Name=BaghiraMenu\n\
  675. X-TDE-Library=b_menu_panelapplet\n\
  676. X-TDE-UniqueApplet=true\n";
  677. file.writeBlock( msg, tqstrlen(msg) );
  678. file.close();
  679. }
  680. else
  681. file.remove();
  682. if (dialog_->replaceMenubar->isOn() != menuReplaced)
  683. TDEApplication::dcopClient()->send("kicker", "default", "restart()", "");
  684. //Srollbars
  685. config->writeEntry("Special_AnimateSlider", dialog_->animateSlider->isOn());
  686. config->writeEntry("Special_ShadowSlider", dialog_->shadowSlider->isOn());
  687. config->writeEntry("Special_SqueezeSlider", dialog_->squeezeSlider->isOn());
  688. //Progress
  689. config->writeEntry("Special_ProgressStyle", dialog_->progressType->currentItem());
  690. config->writeEntry("Special_ShowProgressValue", dialog_->showProgressValue->isOn());
  691. //Toolbars
  692. config->writeEntry("Special_UnhoveredToolButtons", dialog_->unhoveredToolButtons->currentItem());
  693. //Tabs
  694. config->writeEntry("Design_TabStyleAqua", dialog_->aquaTabs->currentItem() );
  695. config->writeEntry("Design_TabStyleBrushed", dialog_->brushedTabs->currentItem() );
  696. // menus
  697. config->writeEntry("Menu_Background", dialog_->menuBackground->currentItem());
  698. config->writeEntry("Menu_Opacity", dialog_->menuOpacity->value());
  699. //Look
  700. config->writeEntry("Menu_ShadowText", dialog_->shadowMenuText->isOn());
  701. config->writeEntry("Menu_ColorStyle", dialog_->menuColorMode->currentItem());
  702. config->writeEntry("Menu_TextColor", (int)dialog_->menuTextColor->color().rgb());
  703. config->writeEntry("Menu_TextColorHighlight", (int)dialog_->menuTextColorHigh->color().rgb());
  704. config->writeEntry("Menu_Color1", (int)dialog_->menuColor->color().rgb());
  705. config->writeEntry("Menu_Color2", (int)dialog_->menuColor2->color().rgb());
  706. config->writeEntry("Menu_ColorHighlight", (int)dialog_->menuColorHigh->color().rgb());
  707. config->writeEntry("Menu_DrawMenuStripe", dialog_->drawMenuStripe->isOn());
  708. config->writeEntry("Menu_Glossy", dialog_->glossyMenus->isOn());
  709. config->writeEntry("Menu_StripeColor", (int)dialog_->menuStripeColor->color().rgb());
  710. // custom colors
  711. config->writeEntry("Colors_UseCustomColors", dialog_->useCustomColors->isOn());
  712. config->writeEntry("Colors_RadioOff", (int)dialog_->radioOffColor->color().rgb());
  713. config->writeEntry("Colors_RadioOn", (int)dialog_->radioOnColor->color().rgb());
  714. config->writeEntry("Colors_CheckOff",(int) dialog_->checkOffColor->color().rgb());
  715. config->writeEntry("Colors_CheckOn", (int)dialog_->checkOnColor->color().rgb());
  716. config->writeEntry("Colors_Slider",(int) dialog_->sliderColor->color().rgb());
  717. config->writeEntry("Colors_SliderHovered", (int)dialog_->hoverSliderColorColor->color().rgb());
  718. config->writeEntry("Colors_SliderPressed", (int)dialog_->pressedSliderColor->color().rgb());
  719. config->writeEntry("Colors_SliderGroove",(int) dialog_->sliderGrooveColor->color().rgb());
  720. config->writeEntry("Colors_TabInactive",(int) dialog_->inactiveTabColor->color().rgb());
  721. config->writeEntry("Colors_TabActive", (int)dialog_->activeTabColor->color().rgb());
  722. config->writeEntry("Colors_TintBrushedMetal", dialog_->tintBrush->isOn());
  723. config->writeEntry("Colors_BrushTint",(int)tqRgb(sliderBrushRedValue, sliderBrushGreenValue, sliderBrushBlueValue));
  724. config->setGroup("Menubar");
  725. config->writeEntry("Width", dialog_->menuMaxWidth->value());
  726. config->sync();
  727. // config->endGroup();
  728. delete config;
  729. }
  730. void tdestyle_baghira_config::configChanged()
  731. {
  732. if (loadDone)
  733. {
  734. dialog_->statusWarning->setText("Config changed");
  735. emit changed(true);
  736. }
  737. }
  738. TQString tdestyle_baghira_config::quickHelp() const
  739. {
  740. return i18n("Configure Your Cat");
  741. }
  742. void tdestyle_baghira_config::setDesign(int d)
  743. {
  744. bool b = (d == 0);
  745. dialog_->stippleBackground->setEnabled(b);
  746. dialog_->stippleContrast->setEnabled(b);
  747. dialog_->shadowGroups->setEnabled(b);
  748. dialog_->shadowIntensity->setEnabled(b);
  749. }
  750. void tdestyle_baghira_config::enableInButtonColor(int d)
  751. {
  752. dialog_->customInactiveColor->setEnabled(d == 3);
  753. }
  754. void tdestyle_baghira_config::enableMenuColorStuff(int d)
  755. {
  756. bool b = (d == 2);
  757. dialog_->menuTextColor->setEnabled(b);
  758. dialog_->menuColor->setEnabled(b && dialog_->menuBackground->currentItem() > 0);
  759. dialog_->menuColor2->setEnabled(b && dialog_->menuBackground->currentItem() > 1);
  760. }
  761. void tdestyle_baghira_config::buttonLoadAction()
  762. {
  763. TQString tmpString = KFileDialog::getOpenFileName(TQDir::homeDirPath(), "*", this, "Select a Baghira config file");
  764. if (!tmpString.isEmpty())
  765. load(tmpString);
  766. }
  767. void tdestyle_baghira_config::buttonSaveAsAction()
  768. {
  769. TQString tmpString = KFileDialog::getSaveFileName(TQDir::homeDirPath(), "*", this, "Save current Baghira configuration as");
  770. save(tmpString);
  771. }
  772. void tdestyle_baghira_config::editApp()
  773. {
  774. emit editApp(applist->currentItem()->text(0), applist->currentItem()->text(1));
  775. }
  776. void tdestyle_baghira_config::removeApp()
  777. {
  778. TQString string = TQDir::homeDirPath() + "/.baghira/" + applist->currentItem()->text(0);
  779. TQFile::remove(string);
  780. applist->takeItem(applist->currentItem());
  781. }
  782. void tdestyle_baghira_config::removeApp(TQString name)
  783. {
  784. TQString string = TQDir::homeDirPath() + "/.baghira/" + name;
  785. TQFile::remove(string);
  786. applist->takeItem(applist->findItem(name, 0, TQt::ExactMatch));
  787. }
  788. void tdestyle_baghira_config::addApp(TQString string, TQString linkString)
  789. {
  790. applist->insertItem(new TDEListViewItem(applist, string, linkString));
  791. applist->sort();
  792. }
  793. void tdestyle_baghira_config::selectWindow()
  794. // taken from kcmkwin
  795. {
  796. // use a dialog, so that all user input is blocked
  797. // use WX11BypassWM and moving away so that it's not actually visible
  798. // grab only mouse, so that keyboard can be used e.g. for switching windows
  799. grabber = new TQDialog( NULL, NULL, true, WX11BypassWM );
  800. grabber->move( -1000, -1000 );
  801. grabber->show();
  802. grabber->grabMouse( crossCursor );
  803. grabber->installEventFilter( this );
  804. }
  805. Atom wm_state = XInternAtom( tqt_xdisplay(), "WM_STATE", False );
  806. // Atom wm_state = XInternAtom( tqt_xdisplay(), "WM_COMMAND", False );
  807. bool tdestyle_baghira_config::eventFilter( TQObject* o, TQEvent* e )
  808. // adapted from kcmkwin... again ;)
  809. {
  810. if( o != grabber )
  811. return false;
  812. if( e->type() != TQEvent::MouseButtonRelease )
  813. return false;
  814. delete grabber;
  815. grabber = NULL;
  816. if( static_cast< TQMouseEvent* >( e )->button() != LeftButton )
  817. return true;
  818. WId winId = findWindow();
  819. XClassHint classHint;
  820. if (XGetClassHint(tqt_xdisplay(), winId, &classHint))
  821. {
  822. TQString tmpString = TQString( classHint.res_class ).lower() + " (uncertain)";
  823. appsetter->show(tmpString, TQString());
  824. // tqWarning("class: %s",TQString( classHint.res_class ).lower().ascii());
  825. XFree( classHint.res_name );
  826. XFree( classHint.res_class );
  827. }
  828. return true;
  829. }
  830. WId tdestyle_baghira_config::findWindow()
  831. // taken from kcmkwin... as well =)
  832. {
  833. Window root;
  834. Window child;
  835. uint mask;
  836. int rootX, rootY, x, y;
  837. Window parent = tqt_xrootwin();
  838. // Atom wm_state = XInternAtom( tqt_xdisplay(), "WM_STATE", False );
  839. for( int i = 0;
  840. i < 10;
  841. ++i )
  842. {
  843. XQueryPointer( tqt_xdisplay(), parent, &root, &child,
  844. &rootX, &rootY, &x, &y, &mask );
  845. if( child == None )
  846. return 0;
  847. Atom type;
  848. int format;
  849. unsigned long nitems, after;
  850. unsigned char* prop;
  851. if( XGetWindowProperty( tqt_xdisplay(), child, wm_state, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &prop ) == Success )
  852. {
  853. if( prop != NULL )
  854. XFree( prop );
  855. if( type != None )
  856. return child;
  857. }
  858. parent = child;
  859. }
  860. return 0;
  861. }
  862. void tdestyle_baghira_config::menuToggled(bool active)
  863. {
  864. if (!active || !loadDone)
  865. return;
  866. TDEConfigGroup menuConfig(TDEGlobal::config(), "KDE");
  867. if (!menuConfig.readBoolEntry("macStyle", false))
  868. if (KMessageBox::questionYesNo(0, i18n("<qt>You just selected to replace kickers menu applet for the Mac like Menubar on top of the screen, but the Mac like style isn't selected anyway<br>Do you want to activate it now?</qt>"), 0L, KStdGuiItem::yes(), KStdGuiItem::no()) == KMessageBox::Yes)
  869. {
  870. TDEProcess proc;
  871. proc << "tdecmshell" << "desktopbehavior";
  872. proc.start(TDEProcess::DontCare);
  873. proc.detach();
  874. }
  875. configChanged();
  876. }
  877. //////////////////////////////////////////////////////////////////////////////
  878. // Plugin Stuff //
  879. //////////////////////////////////////////////////////////////////////////////
  880. extern "C"
  881. {
  882. TQWidget* allocate_tdestyle_config(TQWidget* parent){
  883. return(new tdestyle_baghira_config(parent, "BaghiraConfig"));
  884. }
  885. }
  886. AppSetter::AppSetter(TQWidget *parent, const char *name) : TQWidget(parent, name, TQt::WType_Dialog | TQt::WShowModal )
  887. {
  888. isEdit = FALSE;
  889. TQLabel *label1 = new TQLabel(i18n("<qt><b>Application Name</b></qt>"), this);
  890. command = new TQLineEdit(this);
  891. TQLabel *linkTo = new TQLabel(i18n("<qt><b>Just like</b></qt>"),this);
  892. link = new TQComboBox(this);
  893. box = new TQGroupBox(2,TQt::Horizontal,i18n("Custom Settings"),this);
  894. box->setCheckable( true );
  895. new TQLabel(i18n("<qt><b>Style</b></qt>"), box);
  896. new TQLabel("<qt><b>Deco</b></qt>", box);
  897. style = new TQComboBox(box);
  898. style->insertItem(i18n("Don't set"));
  899. style->insertItem("Jaguar");
  900. style->insertItem("Panther");
  901. style->insertItem("Brushed Metal");
  902. style->insertItem("Tiger");
  903. style->insertItem("Milk");
  904. deco = new TQComboBox(box);
  905. deco->insertItem(i18n("Don't set"));
  906. deco->insertItem("Jaguar");
  907. deco->insertItem("Panther");
  908. deco->insertItem("Brushed Metal");
  909. deco->insertItem("Tiger");
  910. deco->insertItem("Milk");
  911. new TQLabel(i18n("<qt><b>Buttons</b></qt>"), box);
  912. new TQLabel(i18n("<qt><b>Toolbuttons</b></qt>"), box);
  913. buttons = new TQComboBox(box);
  914. buttons->insertItem("Jaguar");
  915. buttons->insertItem("Panther");
  916. buttons->insertItem("iTunes");
  917. buttons->insertItem("Tiger");
  918. buttons->insertItem("Milk");
  919. toolButtons = new TQComboBox(box);
  920. toolButtons->insertItem("Jaguar");
  921. toolButtons->insertItem("Panther");
  922. toolButtons->insertItem("iTunes");
  923. toolButtons->insertItem("Tiger");
  924. toolButtons->insertItem("Milk");
  925. new TQLabel(i18n("<qt><b>Tab vs. Chooser</b></qt>"), box);
  926. new TQLabel(i18n("<qt>Inactive Button</qt>"), box);
  927. tabs = new TQComboBox(box);
  928. tabs->insertItem(i18n("Don't set"));
  929. tabs->insertItem("Tabs");
  930. tabs->insertItem("Adaptive");
  931. tabs->insertItem("Choosers");
  932. inbutton = new TQComboBox(box);
  933. inbutton->insertItem("Fixed");
  934. inbutton->insertItem("Background");
  935. inbutton->insertItem("Active Button");
  936. scanlines = new TQCheckBox("Show scanlines", box);
  937. TQWidget *dumb = new TQWidget(box);
  938. customColors = new TQCheckBox(dumb);
  939. buttonColors = new TQPushButton("Custom Colors", dumb);
  940. TQHBoxLayout *clh = new TQHBoxLayout(dumb);
  941. clh->addWidget(customColors);
  942. clh->addWidget(buttonColors);
  943. TQVBoxLayout *lv = new TQVBoxLayout(this,11,6);
  944. lv->addWidget(label1);
  945. lv->addWidget(command);
  946. TQHBoxLayout *lh0 = new TQHBoxLayout(lv);
  947. lh0->addWidget(linkTo);
  948. lh0->addWidget(link);
  949. lv->addWidget(box);
  950. TQHBoxLayout *lh = new TQHBoxLayout(lv);
  951. TQPushButton *cancel = new TQPushButton("Cancel",this);
  952. lh->addWidget(cancel);
  953. TQPushButton *ok = new TQPushButton("Ok",this);
  954. lh->addWidget(ok);
  955. colorDialog = new ColorDialog(this);
  956. connect(box, SIGNAL(toggled( bool )), link, SLOT(setDisabled(bool)));
  957. connect(box, SIGNAL(toggled( bool )), linkTo, SLOT(setDisabled(bool)));
  958. connect(style, SIGNAL(activated( int )), this, SLOT(handler(int)));
  959. connect(buttons, SIGNAL(activated( int )), this, SLOT(handleButtonStyles(int)));
  960. connect(toolButtons, SIGNAL(activated( int )), this, SLOT(handleButtonStyles(int)));
  961. connect(cancel, SIGNAL(clicked()), this, SLOT(reset()));
  962. connect(ok, SIGNAL(clicked()), this, SLOT(save()));
  963. connect(customColors, SIGNAL(toggled( bool )), buttonColors, SLOT(setEnabled(bool)));
  964. connect(buttonColors, SIGNAL(clicked()), colorDialog, SLOT(exec()));
  965. connect(colorDialog->buttonOk, SIGNAL(clicked()), this, SLOT(updateColors()));
  966. connect(colorDialog->buttonCancel, SIGNAL(clicked()), this, SLOT(resetColorPicker()));
  967. reset();
  968. }
  969. AppSetter::~AppSetter()
  970. {
  971. }
  972. void AppSetter::handleButtonStyles(int i)
  973. {
  974. if (i != 2 && sender() == buttons && toolButtons->currentItem() != 2)
  975. toolButtons->setCurrentItem(i);
  976. else if (i != 2 && sender() == toolButtons && buttons->currentItem() != 2)
  977. buttons->setCurrentItem(i);
  978. }
  979. void AppSetter::handler(int i)
  980. {
  981. scanlines->setEnabled(i != 3);
  982. }
  983. void AppSetter::updateColors()
  984. {
  985. for (int i = 0; i < 8; i++)
  986. colors[i] = (int)colorDialog->picker[i]->color().rgb();
  987. }
  988. void AppSetter::show()
  989. {
  990. link->clear();
  991. TQDir d( TQDir::homeDirPath() + "/.baghira", 0L, TQDir::Name | TQDir::IgnoreCase, TQDir::Files | TQDir::NoSymLinks | TQDir::Readable | TQDir::Writable );
  992. for ( uint i = 0; i < d.count(); i++ )
  993. link->insertItem(d[i]);
  994. TQWidget::show();
  995. }
  996. void AppSetter::show(TQString appName, TQString linkString)
  997. {
  998. isEdit = true;
  999. oldName = appName;
  1000. oldLink = linkString;
  1001. command->setText(appName);
  1002. FILE *file = NULL;
  1003. TQString tmpString = TQDir::homeDirPath() + "/.baghira/" + appName;
  1004. if( (file = fopen(tmpString.latin1(), "r")) != NULL )
  1005. {
  1006. uint s, d, b, t, tc, sc, ib;
  1007. s = d = 4;
  1008. b = t = sc = 2;
  1009. tc = 3;
  1010. for (int i = 0; i < 8; i++)
  1011. colors[i] = -1;
  1012. fscanf(file,"%u\n%u\n%u\n%u\n%u\n%u\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n",&s,&d,&b,&t,&tc,&sc,&colors[0],&colors[1],&colors[2],&colors[3],&colors[4],&colors[5],&colors[6],&colors[7],&ib);
  1013. fclose(file);
  1014. if (s < 5) style->setCurrentItem(s+1);
  1015. if (d < 5) deco->setCurrentItem(d+1);
  1016. if (b < 5) buttons->setCurrentItem(b);
  1017. if (t < 5) toolButtons->setCurrentItem(t);
  1018. if (tc < 3) tabs->setCurrentItem(tc+1);
  1019. if (ib < 3) inbutton->setCurrentItem(ib);
  1020. scanlines->setChecked(sc < 2 ? sc : true);
  1021. scanlines->setEnabled(s != 2);
  1022. customColors->setChecked(colors[0] != -1);
  1023. buttonColors->setEnabled(customColors->isChecked());
  1024. resetColorPicker();
  1025. }
  1026. show();
  1027. if (!linkString.isNull())
  1028. {
  1029. for (int i = 0; i < link->count(); i++)
  1030. {
  1031. if (link->text(i) == linkString)
  1032. {
  1033. link->setCurrentItem(i);
  1034. break;
  1035. }
  1036. }
  1037. }
  1038. else
  1039. {
  1040. box->setChecked(true);
  1041. }
  1042. }
  1043. void AppSetter::resetColorPicker()
  1044. {
  1045. if (colors[0] != -1)
  1046. {
  1047. for (int i = 0; i < 8; i++)
  1048. {
  1049. colorDialog->picker[i]->blockSignals(true);
  1050. colorDialog->picker[i]->setColor(TQColor(colors[i]));
  1051. colorDialog->picker[i]->blockSignals(false);
  1052. }
  1053. ((TQWidget*)colorDialog->demo)->repaint(false);
  1054. }
  1055. else
  1056. {
  1057. for (int i = 0; i < 8; i++)
  1058. colorDialog->picker[i]->blockSignals(true);
  1059. colorDialog->picker[Back]->setColor(colorGroup().background());
  1060. colorDialog->picker[Button]->setColor(colorGroup().button());
  1061. colorDialog->picker[Base]->setColor(colorGroup().base());
  1062. colorDialog->picker[Text]->setColor(colorGroup().text());
  1063. colorDialog->picker[High]->setColor(colorGroup().highlight());
  1064. colorDialog->picker[HighText]->setColor(colorGroup().highlightedText());
  1065. colorDialog->picker[ButText]->setColor(colorGroup().buttonText ());
  1066. colorDialog->picker[Alternate]->setColor(TDEGlobalSettings::alternateBackgroundColor());
  1067. for (int i = 0; i < 8; i++)
  1068. colorDialog->picker[i]->blockSignals(false);
  1069. ((TQWidget*)colorDialog->demo)->repaint(false);
  1070. }
  1071. }
  1072. void AppSetter::save()
  1073. {
  1074. if (command->text() != "" && (!box->isChecked() || (style->currentItem() != 0 && deco->currentItem() != 0)))
  1075. {
  1076. if (!isEdit)
  1077. emit addApp(command->text(), box->isChecked() ? TQString() : link->currentText());
  1078. else if (command->text() != oldName || link->currentText() != oldLink)
  1079. {
  1080. emit removeApp(oldName);
  1081. emit addApp(command->text(), box->isChecked() ? TQString() : link->currentText());
  1082. }
  1083. if (!customColors->isChecked())
  1084. {
  1085. for (int i = 0; i < 8; i++)
  1086. colors[i] = -1;
  1087. }
  1088. FILE *file = NULL;
  1089. TQString tmpString = TQDir::homeDirPath() + "/.baghira/" + command->text();
  1090. if (box->isChecked()) // custom settings
  1091. {
  1092. if( (file = fopen(tmpString.latin1(), "w")) != NULL )
  1093. {
  1094. fprintf(file,"%u\n%u\n%u\n%u\n%u\n%u\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n",style->currentItem()-1, deco->currentItem()-1, buttons->currentItem(), toolButtons->currentItem(), tabs->currentItem()-1, scanlines->isChecked(), colors[0], colors[1], colors[2], colors[3], colors[4], colors[5], colors[6], colors[7], inbutton->currentItem());
  1095. fclose(file);
  1096. }
  1097. }
  1098. else // just link
  1099. {
  1100. TQString tmpString2 = TQDir::homeDirPath() + "/.baghira/" + link->currentText();
  1101. TQFile::remove(tmpString); // just to be sure ;)
  1102. symlink (tmpString2.latin1(), tmpString.latin1());
  1103. }
  1104. }
  1105. reset();
  1106. }
  1107. void AppSetter::reset()
  1108. {
  1109. hide();
  1110. isEdit = false;
  1111. style->setCurrentItem(0);
  1112. deco->setCurrentItem(0);
  1113. buttons->setCurrentItem(1);
  1114. inbutton->setCurrentItem(0);
  1115. toolButtons->setCurrentItem(1);
  1116. tabs->setCurrentItem(0);
  1117. scanlines->setChecked(false);
  1118. command->clear();
  1119. customColors->setChecked(false);
  1120. for (int i = 0; i < 8; i++)
  1121. colors[i] = -1;
  1122. box->setChecked ( false );
  1123. }
  1124. #include "tdestyle_baghira_config.moc"