KBiff – mail notification utility
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.
 
 
 

2016 lines
59 KiB

  1. /*
  2. * setupdlg.cpp
  3. * Copyright (C) 1999-2008 Kurt Granroth <granroth@kde.org>
  4. *
  5. * This file contains the implementation of the setup dialog
  6. * class for KBiff.
  7. */
  8. #include "setupdlg.h"
  9. #include "setupdlg.moc"
  10. #include <ntqgroupbox.h>
  11. #include <ntqfileinfo.h>
  12. #include <ntqlineedit.h>
  13. #include <ntqcheckbox.h>
  14. #include <ntqpushbutton.h>
  15. #include <ntqcombobox.h>
  16. #include <ntqheader.h>
  17. #include <ntqtabwidget.h>
  18. #include <ntqpixmap.h>
  19. #include <ntqfont.h>
  20. #include <ntqlabel.h>
  21. #include <ntqstrlist.h>
  22. #include <ntqlayout.h>
  23. #include <ntqtooltip.h>
  24. #include <ntqdict.h>
  25. #include <ntqptrlist.h>
  26. #include <ntqwhatsthis.h>
  27. #include <ntqstylesheet.h>
  28. #include <kaudioplayer.h>
  29. #include <tdemessagebox.h>
  30. #include <tdefiledialog.h>
  31. #include <kapp.h>
  32. #include <tdeglobal.h>
  33. #include <kiconloader.h>
  34. #include <tdelocale.h>
  35. #include <kstddirs.h>
  36. #include <ksimpleconfig.h>
  37. #include <kbiffurl.h>
  38. #include <kprocess.h>
  39. #include <krun.h>
  40. #include <kurllabel.h>
  41. #include <twin.h>
  42. #include <kbiffcodec.h>
  43. #include "version.h"
  44. #include <stdlib.h>
  45. #include <unistd.h>
  46. #include <pwd.h>
  47. #include <sys/types.h>
  48. #define CONFIG_FILE "kbiffrc"
  49. #ifdef HAVE_PATHS_H
  50. #include <paths.h>
  51. #endif
  52. #ifndef _PATH_MAILDIR
  53. #define _PATH_MAILDIR "/var/spool/mail"
  54. #endif
  55. ///////////////////////////////////////////////////////////////////////////
  56. // KBiffSetup
  57. ///////////////////////////////////////////////////////////////////////////
  58. KBiffSetup::KBiffSetup(const TQString& profile_, bool secure_)
  59. : KDialog(0, 0, true)
  60. {
  61. // set the icon just to be cute
  62. KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
  63. // make sure the profile is *something*
  64. TQString the_profile;
  65. if (profile_.isEmpty() || profile_.isNull())
  66. the_profile = getSomeProfile();
  67. else
  68. the_profile = profile_;
  69. setCaption(i18n("KBiff Setup"));
  70. // The profile combo box and buttons all go in this groupbox
  71. TQGroupBox* profile_groupbox = new TQGroupBox(i18n("Profile"), this);
  72. // combo box to hold the profile names
  73. comboProfile = new TQComboBox(false, profile_groupbox);
  74. comboProfile->setSizeLimit(10);
  75. TQString whatsthis = i18n(
  76. "This is a list of all of the KBiff <b>profiles</b><p>"
  77. "A profile is a logical grouping of settings for either one "
  78. "mailbox or several mailboxes. Each profile gets one icon "
  79. "and one new mail sound and one... well, everything");
  80. TQWhatsThis::add(comboProfile, whatsthis);
  81. // Add New Profile button
  82. TQPushButton *new_profile_button = new TQPushButton(i18n("&New..."),
  83. profile_groupbox);
  84. whatsthis = i18n("Create a new profile");
  85. TQWhatsThis::add(new_profile_button, whatsthis);
  86. connect(new_profile_button, SIGNAL(clicked()), SLOT(slotAddNewProfile()));
  87. // Rename Profile button
  88. TQPushButton *rename_profile_button = new TQPushButton(i18n("&Rename..."),
  89. profile_groupbox);
  90. whatsthis = i18n("Rename the current profile");
  91. TQWhatsThis::add(rename_profile_button, whatsthis);
  92. connect(rename_profile_button, SIGNAL(clicked()), SLOT(slotRenameProfile()));
  93. // Delete Profile button
  94. TQPushButton *delete_profile_button = new TQPushButton(i18n("&Delete"),
  95. profile_groupbox);
  96. whatsthis = i18n("Delete the current profile");
  97. TQWhatsThis::add(delete_profile_button, whatsthis);
  98. connect(delete_profile_button, SIGNAL(clicked()), SLOT(slotDeleteProfile()));
  99. // setup the tabs
  100. TQTabWidget *tabctl = new TQTabWidget(this);
  101. generalTab = new KBiffGeneralTab(the_profile, tabctl);
  102. newmailTab = new KBiffNewMailTab(the_profile, tabctl);
  103. mailboxTab = new KBiffMailboxTab(the_profile, tabctl);
  104. aboutTab = new KBiffAboutTab(tabctl);
  105. connect(comboProfile, SIGNAL(highlighted(const TQString&)),
  106. generalTab, SLOT(readConfig(const TQString&)));
  107. connect(comboProfile, SIGNAL(highlighted(const TQString&)),
  108. newmailTab, SLOT(readConfig(const TQString&)));
  109. connect(comboProfile, SIGNAL(highlighted(const TQString&)),
  110. mailboxTab, SLOT(readConfig(const TQString&)));
  111. // add the tabs
  112. tabctl->addTab(generalTab, i18n("General"));
  113. tabctl->addTab(newmailTab, i18n("New Mail"));
  114. tabctl->addTab(mailboxTab, i18n("Mailbox"));
  115. tabctl->addTab(aboutTab, i18n("About"));
  116. // help button
  117. TQPushButton *help_button = new TQPushButton(i18n("&Help"), this);
  118. connect(help_button, SIGNAL(clicked()), SLOT(invokeHelp()));
  119. // ok button
  120. TQPushButton *ok_button = new TQPushButton(i18n("&OK"), this);
  121. ok_button->setDefault(true);
  122. connect(ok_button, SIGNAL(clicked()), SLOT(slotDone()));
  123. // cancel button
  124. TQPushButton *cancel_button = new TQPushButton(i18n("&Cancel"), this);
  125. connect(cancel_button, SIGNAL(clicked()), SLOT(reject()));
  126. // are we secure?
  127. isSecure = secure_;
  128. // NOW, SETUP ALL THE LAYOUTS!
  129. // This layout handles the buttons for the profile combobox
  130. TQBoxLayout *pro_button_layout = new TQBoxLayout(TQBoxLayout::LeftToRight, 12);
  131. pro_button_layout->addWidget(new_profile_button);
  132. pro_button_layout->addWidget(rename_profile_button);
  133. pro_button_layout->addWidget(delete_profile_button);
  134. // This layout handles the upper profile groupbox
  135. TQBoxLayout *profile_layout = new TQBoxLayout(profile_groupbox,
  136. TQBoxLayout::Down, 12);
  137. profile_layout->addSpacing(8);
  138. profile_layout->addWidget(comboProfile);
  139. profile_layout->addLayout(pro_button_layout);
  140. // This layout handles the dialog buttons
  141. TQBoxLayout *dialog_button_layout = new TQBoxLayout(TQBoxLayout::LeftToRight,
  142. 12);
  143. dialog_button_layout->addWidget(help_button);
  144. dialog_button_layout->addStretch(1);
  145. dialog_button_layout->addWidget(ok_button);
  146. dialog_button_layout->addWidget(cancel_button);
  147. // This is the outermost layout
  148. TQBoxLayout *top_layout = new TQBoxLayout(this, TQBoxLayout::Down, 12);
  149. top_layout->addWidget(profile_groupbox);
  150. top_layout->addWidget(tabctl, 1);
  151. top_layout->addLayout(dialog_button_layout);
  152. // Read in the config for this profile
  153. readConfig(the_profile);
  154. }
  155. KBiffSetup::~KBiffSetup()
  156. {
  157. }
  158. bool KBiffSetup::getSecure() const
  159. {
  160. return isSecure;
  161. }
  162. const TQString KBiffSetup::getProfile() const
  163. {
  164. return comboProfile->currentText();
  165. }
  166. const KBiffURL KBiffSetup::getCurrentMailbox() const
  167. {
  168. return mailboxTab->getMailbox();
  169. }
  170. const TQPtrList<KBiffMailbox> KBiffSetup::getMailboxList() const
  171. {
  172. return mailboxTab->getMailboxList();
  173. }
  174. const TQString KBiffSetup::getMailClient() const
  175. {
  176. return generalTab->getMailClient();
  177. }
  178. const TQString KBiffSetup::getNoMailIcon() const
  179. {
  180. return generalTab->getButtonNoMail();
  181. }
  182. const TQString KBiffSetup::getNewMailIcon() const
  183. {
  184. return generalTab->getButtonNewMail();
  185. }
  186. const TQString KBiffSetup::getOldMailIcon() const
  187. {
  188. return generalTab->getButtonOldMail();
  189. }
  190. const TQString KBiffSetup::getNoConnIcon() const
  191. {
  192. return generalTab->getButtonNoConn();
  193. }
  194. const TQString KBiffSetup::getStoppedIcon() const
  195. {
  196. return generalTab->getButtonStopped();
  197. }
  198. bool KBiffSetup::getSessionManagement() const
  199. {
  200. return generalTab->getSessionManagement();
  201. }
  202. bool KBiffSetup::getCheckStartup() const
  203. {
  204. return generalTab->getCheckStartup();
  205. }
  206. bool KBiffSetup::getDock() const
  207. {
  208. return generalTab->getDock();
  209. }
  210. unsigned int KBiffSetup::getPoll() const
  211. {
  212. return generalTab->getPoll();
  213. }
  214. const TQString KBiffSetup::getRunCommandPath() const
  215. {
  216. return newmailTab->getRunCommandPath();
  217. }
  218. const TQString KBiffSetup::getRunResetCommandPath() const
  219. {
  220. return newmailTab->getRunResetCommandPath();
  221. }
  222. const TQString KBiffSetup::getPlaySoundPath() const
  223. {
  224. return newmailTab->getPlaySoundPath();
  225. }
  226. bool KBiffSetup::getRunCommand() const
  227. {
  228. return newmailTab->getRunCommand();
  229. }
  230. bool KBiffSetup::getRunResetCommand() const
  231. {
  232. return newmailTab->getRunResetCommand();
  233. }
  234. bool KBiffSetup::getPlaySound() const
  235. {
  236. return newmailTab->getPlaySound();
  237. }
  238. bool KBiffSetup::getSystemBeep() const
  239. {
  240. return newmailTab->getSystemBeep();
  241. }
  242. bool KBiffSetup::getNotify() const
  243. {
  244. return newmailTab->getNotify();
  245. }
  246. bool KBiffSetup::getStatus() const
  247. {
  248. return newmailTab->getStatus();
  249. }
  250. void KBiffSetup::invokeHelp()
  251. {
  252. kapp->invokeHelp();
  253. }
  254. void KBiffSetup::readConfig(const TQString& profile_)
  255. {
  256. TQStringList profile_list;
  257. // open the config file
  258. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE, true);
  259. config->setDollarExpansion(false);
  260. config->setGroup("General");
  261. // read in the mailboxes
  262. profile_list = config->readListEntry("Profiles", ',');
  263. int number_of_mailboxes = profile_list.count();
  264. delete config;
  265. // check if we have any mailboxes to read in
  266. if (number_of_mailboxes > 0)
  267. {
  268. comboProfile->clear();
  269. // load up the combo box
  270. comboProfile->insertStringList(profile_list);
  271. // read in the data from the first mailbox if we don't have a name
  272. for (int i = 0; i < comboProfile->count(); i++)
  273. {
  274. if (TQString(profile_) == comboProfile->text(i))
  275. {
  276. comboProfile->setCurrentItem(i);
  277. break;
  278. }
  279. }
  280. }
  281. else
  282. comboProfile->insertItem(profile_);
  283. }
  284. TQString KBiffSetup::getSomeProfile() const
  285. {
  286. TQStringList profile_list;
  287. // open the config file
  288. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE, true);
  289. config->setGroup("General");
  290. // read in the mailboxes
  291. profile_list = config->readListEntry("Profiles", ',');
  292. int number_of_mailboxes = profile_list.count();
  293. delete config;
  294. // get the first mailbox if it exists
  295. if (number_of_mailboxes > 0)
  296. return profile_list.last();
  297. else
  298. return TQString("Inbox");
  299. }
  300. void KBiffSetup::saveConfig()
  301. {
  302. // open the config file for writing
  303. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE);
  304. config->setGroup("General");
  305. // get the list of profiles
  306. TQStringList profile_list;
  307. for (int i = 0; i < comboProfile->count(); i++)
  308. profile_list.append(comboProfile->text(i));
  309. // write the mailboxes
  310. config->writeEntry("Profiles", profile_list, ',');
  311. delete config;
  312. }
  313. ///////////////////////////////////////////////////////////////////////
  314. // Protected slots
  315. ///////////////////////////////////////////////////////////////////////
  316. void KBiffSetup::slotDone()
  317. {
  318. TQString profile = comboProfile->currentText();
  319. saveConfig();
  320. generalTab->saveConfig(profile);
  321. newmailTab->saveConfig(profile);
  322. mailboxTab->saveConfig(profile);
  323. accept();
  324. }
  325. void KBiffSetup::slotAddNewProfile()
  326. {
  327. KBiffNewDlg dlg;
  328. // popup the name chooser
  329. dlg.setCaption(i18n("New Profile"));
  330. if (dlg.exec())
  331. {
  332. TQString profile_name = dlg.getName();
  333. // bail out if we already have this name
  334. for (int i = 0; i < comboProfile->count(); i++)
  335. {
  336. if (profile_name == comboProfile->text(i))
  337. return;
  338. }
  339. // continue only if we received a decent name
  340. if (profile_name.isEmpty() == false)
  341. {
  342. comboProfile->insertItem(profile_name, 0);
  343. saveConfig();
  344. readConfig(profile_name);
  345. generalTab->readConfig(profile_name);
  346. newmailTab->readConfig(profile_name);
  347. mailboxTab->readConfig(profile_name);
  348. }
  349. }
  350. }
  351. void KBiffSetup::slotRenameProfile()
  352. {
  353. KBiffNewDlg dlg;
  354. TQString title;
  355. TQString old_profile = comboProfile->currentText();
  356. title = i18n("Rename Profile: %1").arg(old_profile);
  357. dlg.setCaption(title);
  358. // popup the name chooser
  359. if (dlg.exec())
  360. {
  361. TQString profile_name = dlg.getName();
  362. // bail out if we already have this name
  363. for (int i = 0; i < comboProfile->count(); i++)
  364. {
  365. if (profile_name == comboProfile->text(i))
  366. return;
  367. }
  368. // continue only if we received a decent name
  369. if (profile_name.isNull() == false)
  370. {
  371. comboProfile->removeItem(comboProfile->currentItem());
  372. comboProfile->insertItem(profile_name, 0);
  373. // remove the reference from the config file
  374. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE);
  375. // nuke the group
  376. config->deleteGroup(old_profile, true);
  377. delete config;
  378. // now save the profile settings
  379. saveConfig();
  380. generalTab->saveConfig(profile_name);
  381. newmailTab->saveConfig(profile_name);
  382. mailboxTab->saveConfig(profile_name);
  383. }
  384. }
  385. }
  386. void KBiffSetup::slotDeleteProfile()
  387. {
  388. TQString title, msg;
  389. TQString profile = comboProfile->currentText();
  390. title = i18n("Delete Profile: %1").arg(profile);
  391. msg = i18n("Are you sure you wish to delete this profile?\n");
  392. switch (KMessageBox::warningYesNo(this, msg, title))
  393. {
  394. case KMessageBox::Yes:
  395. {
  396. comboProfile->removeItem(comboProfile->currentItem());
  397. saveConfig();
  398. // remove the reference from the config file
  399. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE);
  400. // nuke the group
  401. config->deleteGroup(profile, true);
  402. delete config;
  403. if (comboProfile->count() == 0)
  404. {
  405. readConfig("Inbox");
  406. generalTab->readConfig("Inbox");
  407. newmailTab->readConfig("Inbox");
  408. mailboxTab->readConfig("Inbox");
  409. }
  410. else
  411. {
  412. readConfig(comboProfile->currentText());
  413. generalTab->readConfig(comboProfile->currentText());
  414. newmailTab->readConfig(comboProfile->currentText());
  415. mailboxTab->readConfig(comboProfile->currentText());
  416. }
  417. break;
  418. }
  419. case KMessageBox::No:
  420. default:
  421. break;
  422. }
  423. }
  424. ///////////////////////////////////////////////////////////////////////
  425. // KBiffGeneralTab
  426. ///////////////////////////////////////////////////////////////////////
  427. KBiffGeneralTab::KBiffGeneralTab(const TQString& profile_, TQWidget *parent_)
  428. : TQWidget(parent_)
  429. {
  430. // the poll time (in seconds)
  431. TQLabel* poll_label = new TQLabel(i18n("P&oll (sec):"), this);
  432. editPoll = new TQLineEdit(this);
  433. poll_label->setBuddy(editPoll);
  434. TQString whatsthis = i18n(
  435. "This is the interval (in seconds) that KBiff will check "
  436. "for new mail. Typically, this can be quite small (under "
  437. "60 seconds) for local mailboxes but should be around 5 "
  438. "minutes (300 seconds) for remote mailboxes");
  439. TQWhatsThis::add(editPoll, whatsthis);
  440. // the command to run when clicked
  441. TQLabel *mail_label = new TQLabel(i18n("&Mail client:"), this);
  442. editCommand = new TQLineEdit(this);
  443. mail_label->setBuddy(editCommand);
  444. whatsthis = i18n(
  445. "This is the mail client that KBiff was use when you click "
  446. "on the icon or the Mailer button. If it's not in your path, "
  447. "then you must specify the location using an absolute path. "
  448. "This recognizes the <b>%m</b> and <b>%u</b> arguments. The "
  449. "first is replaced with the first mailbox containing new mail "
  450. "and the latter is replaced with the mailbox's URL.");
  451. TQWhatsThis::add(editCommand, whatsthis);
  452. // do we dock automatically?
  453. checkDock = new TQCheckBox(i18n("Doc&k in panel"), this);
  454. // should we support session management?
  455. checkNoSession = new TQCheckBox(i18n("Use &session management"), this);
  456. // should we check at startup?
  457. checkNoStartup = new TQCheckBox(i18n("Don't &check at startup"), this);
  458. whatsthis = i18n(
  459. "This option is for those people using KBiff to check their "
  460. "IMAP4 or POP3 account over a dial-up connection. If KBiff "
  461. "tries to connect at startup and you are not connected, the "
  462. "DNS lookup will hang for a long time. If this is checked, "
  463. "then KBiff will not check for new mail on startup. You will "
  464. "need to manually start it every time you connect");
  465. TQWhatsThis::add(checkNoStartup, whatsthis);
  466. // group box to hold the icons together
  467. TQGroupBox* icons_groupbox = new TQGroupBox(i18n("Icons:"), this);
  468. // "stopped" pixmap button
  469. TQLabel* stopped_label = new TQLabel(i18n("&Stopped:"), icons_groupbox);
  470. buttonStopped = new TDEIconButton(icons_groupbox);
  471. buttonStopped->setFixedSize(50, 50);
  472. buttonStopped->setIconType(TDEIcon::User, TDEIcon::Any, true);
  473. stopped_label->setBuddy(buttonStopped);
  474. // "no mailbox" pixmap button
  475. TQLabel* noconn_label = new TQLabel(i18n("No Mail&box:"), icons_groupbox);
  476. buttonNoConn = new TDEIconButton(icons_groupbox);
  477. buttonNoConn->setFixedSize(50, 50);
  478. buttonNoConn->setIconType(TDEIcon::User, TDEIcon::Any, true);
  479. noconn_label->setBuddy(buttonNoConn);
  480. // "no mail" pixmap button
  481. TQLabel* nomail_label = new TQLabel(i18n("No M&ail:"), icons_groupbox);
  482. buttonNoMail = new TDEIconButton(icons_groupbox);
  483. buttonNoMail->setIconType(TDEIcon::User, TDEIcon::Any, true);
  484. buttonNoMail->setFixedSize(50, 50);
  485. nomail_label->setBuddy(buttonNoMail);
  486. // "old mail" pixmap button
  487. TQLabel* oldmail_label = new TQLabel(i18n("O&ld Mail:"), icons_groupbox);
  488. buttonOldMail = new TDEIconButton(icons_groupbox);
  489. buttonOldMail->setIconType(TDEIcon::User, TDEIcon::Any, true);
  490. buttonOldMail->setFixedSize(50, 50);
  491. oldmail_label->setBuddy(buttonOldMail);
  492. // "new mail" pixmap button
  493. TQLabel* newmail_label = new TQLabel(i18n("N&ew Mail:"), icons_groupbox);
  494. buttonNewMail = new TDEIconButton(icons_groupbox);
  495. buttonNewMail->setIconType(TDEIcon::User, TDEIcon::Any, true);
  496. buttonNewMail->setFixedSize(50, 50);
  497. newmail_label->setBuddy(buttonNewMail);
  498. // poll time layout
  499. TQGridLayout *info_layout = new TQGridLayout(5, 3, 8);
  500. info_layout->addWidget(poll_label, 0, 0);
  501. info_layout->addWidget(editPoll, 0, 1);
  502. info_layout->setColStretch(2, 1);
  503. info_layout->addWidget(mail_label, 1, 0);
  504. info_layout->addMultiCellWidget(editCommand, 1, 1, 1, 2);
  505. info_layout->addMultiCellWidget(checkDock, 2, 2, 1, 2);
  506. info_layout->addMultiCellWidget(checkNoSession, 3, 3, 1, 2);
  507. info_layout->addMultiCellWidget(checkNoStartup, 4, 4, 1, 2);
  508. // icons layout
  509. TQVBoxLayout *stopped_layout = new TQVBoxLayout;
  510. stopped_layout->addWidget(stopped_label);
  511. stopped_layout->addWidget(buttonStopped);
  512. TQVBoxLayout *no_conn_layout = new TQVBoxLayout;
  513. no_conn_layout->addWidget(noconn_label);
  514. no_conn_layout->addWidget(buttonNoConn);
  515. TQVBoxLayout *no_mail_layout = new TQVBoxLayout;
  516. no_mail_layout->addWidget(nomail_label);
  517. no_mail_layout->addWidget(buttonNoMail);
  518. TQVBoxLayout *old_mail_layout = new TQVBoxLayout;
  519. old_mail_layout->addWidget(oldmail_label);
  520. old_mail_layout->addWidget(buttonOldMail);
  521. TQVBoxLayout *new_mail_layout = new TQVBoxLayout;
  522. new_mail_layout->addWidget(newmail_label);
  523. new_mail_layout->addWidget(buttonNewMail);
  524. TQHBoxLayout *inner_icon_layout = new TQHBoxLayout;
  525. inner_icon_layout->addStretch(1);
  526. inner_icon_layout->addLayout(stopped_layout);
  527. inner_icon_layout->addStretch(1);
  528. inner_icon_layout->addLayout(no_conn_layout);
  529. inner_icon_layout->addStretch(1);
  530. inner_icon_layout->addLayout(no_mail_layout);
  531. inner_icon_layout->addStretch(1);
  532. inner_icon_layout->addLayout(old_mail_layout);
  533. inner_icon_layout->addStretch(1);
  534. inner_icon_layout->addLayout(new_mail_layout);
  535. inner_icon_layout->addStretch(1);
  536. TQBoxLayout *outer_icon_layout = new TQBoxLayout(icons_groupbox,
  537. TQBoxLayout::Down, 5);
  538. outer_icon_layout->addSpacing(8);
  539. outer_icon_layout->addLayout(inner_icon_layout);
  540. outer_icon_layout->addStretch(1);
  541. // main "outer" layout for this tab
  542. TQVBoxLayout *top_layout = new TQVBoxLayout(this, 12);
  543. top_layout->addLayout(info_layout);
  544. top_layout->addWidget(icons_groupbox);
  545. top_layout->addStretch(1);
  546. // now read in the config data for this profile
  547. readConfig(profile_);
  548. }
  549. KBiffGeneralTab::~KBiffGeneralTab()
  550. {
  551. }
  552. bool KBiffGeneralTab::getSessionManagement() const
  553. {
  554. return checkNoSession->isChecked();
  555. }
  556. bool KBiffGeneralTab::getCheckStartup() const
  557. {
  558. return checkNoStartup->isChecked();
  559. }
  560. bool KBiffGeneralTab::getDock() const
  561. {
  562. return checkDock->isChecked();
  563. }
  564. const TQString KBiffGeneralTab::getButtonOldMail() const
  565. {
  566. return buttonOldMail->icon();
  567. }
  568. const TQString KBiffGeneralTab::getButtonNewMail() const
  569. {
  570. return buttonNewMail->icon();
  571. }
  572. const TQString KBiffGeneralTab::getButtonNoMail() const
  573. {
  574. return buttonNoMail->icon();
  575. }
  576. const TQString KBiffGeneralTab::getButtonNoConn() const
  577. {
  578. return buttonNoConn->icon();
  579. }
  580. const TQString KBiffGeneralTab::getButtonStopped() const
  581. {
  582. return buttonStopped->icon();
  583. }
  584. const TQString KBiffGeneralTab::getMailClient() const
  585. {
  586. return editCommand->text();
  587. }
  588. int KBiffGeneralTab::getPoll() const
  589. {
  590. return TQString(editPoll->text()).toInt();
  591. }
  592. void KBiffGeneralTab::readConfig(const TQString& profile_)
  593. {
  594. // open the config file
  595. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE, true);
  596. config->setGroup(profile_);
  597. // someday, we need to read in the system email prefs
  598. editPoll->setText(config->readEntry("Poll", "60"));
  599. editCommand->setText(config->readEntry("MailClient", "kmail -check"));
  600. checkDock->setChecked(config->readBoolEntry("Docked", true));
  601. checkNoSession->setChecked(config->readBoolEntry("Sessions", true));
  602. checkNoStartup->setChecked(config->readBoolEntry("DontCheck", false));
  603. TQString stopped, no_mail, old_mail, new_mail, no_conn;
  604. stopped = config->readEntry("StoppedPixmap", "stopped");
  605. no_mail = config->readEntry("NoMailPixmap", "nomail");
  606. old_mail = config->readEntry("OldMailPixmap", "oldmail");
  607. new_mail = config->readEntry("NewMailPixmap", "newmail");
  608. no_conn = config->readEntry("NoConnPixmap", "noconn");
  609. buttonOldMail->setIcon(old_mail);
  610. buttonNewMail->setIcon(new_mail);
  611. buttonNoMail->setIcon(no_mail);
  612. buttonNoConn->setIcon(no_conn);
  613. buttonStopped->setIcon(stopped);
  614. delete config;
  615. }
  616. static TQString justIconName(const TQString& icon_name)
  617. {
  618. // the following code is a bit of a hack, but there is a rationale
  619. // to it. if possible, we want to just save the name of the icons
  620. // (without extension), and not the whole path due to name munging
  621. // later on.
  622. TQFileInfo info( icon_name );
  623. // we first test if the basename (filename without extensions) is
  624. // the same as the filename. if it is, then we are perfect. no
  625. // need to do anything further
  626. if ( info.baseName() == info.fileName() )
  627. return icon_name;
  628. // now we see if we can load based just on the basename
  629. TQPixmap icon = TDEGlobal::iconLoader()->loadIcon( info.baseName(), TDEIcon::User );
  630. // if it's null, then it's in a non-standard path so we must use an
  631. // absolute path. no need to go further
  632. if ( icon.isNull() )
  633. return icon_name;
  634. // now we know that the icon loader can find it.. but is it the same
  635. // one as the one the user picked?
  636. if ( TDEGlobal::iconLoader()->iconPath( info.baseName(), TDEIcon::User ) !=
  637. TDEGlobal::iconLoader()->iconPath( icon_name, TDEIcon::User ) )
  638. return icon_name;
  639. // FINALLY done! if we got this far, then we know that the icon
  640. // loader can handle just the name and that the icon returned is the
  641. // same one that the user wanted. whew!
  642. return info.baseName();
  643. }
  644. void KBiffGeneralTab::saveConfig(const TQString& profile_)
  645. {
  646. // open the config file for writing
  647. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE);
  648. config->setGroup(profile_);
  649. config->writeEntry("Poll", editPoll->text());
  650. config->writeEntry("MailClient", editCommand->text());
  651. config->writeEntry("Docked", checkDock->isChecked());
  652. config->writeEntry("Sessions", checkNoSession->isChecked());
  653. config->writeEntry("DontCheck", checkNoStartup->isChecked());
  654. config->writeEntry("NoMailPixmap", justIconName(buttonNoMail->icon()));
  655. config->writeEntry("NewMailPixmap", justIconName(buttonNewMail->icon()));
  656. config->writeEntry("OldMailPixmap", justIconName(buttonOldMail->icon()));
  657. config->writeEntry("NoConnPixmap", justIconName(buttonNoConn->icon()));
  658. config->writeEntry("StoppedPixmap", justIconName(buttonStopped->icon()));
  659. delete config;
  660. }
  661. ///////////////////////////////////////////////////////////////////////
  662. // KBiffNewMailTab
  663. ///////////////////////////////////////////////////////////////////////
  664. KBiffNewMailTab::KBiffNewMailTab(const TQString& profile_, TQWidget *parent_)
  665. : TQWidget(parent_)
  666. {
  667. // setup the Run Command stuff
  668. checkRunCommand = new TQCheckBox(i18n("R&un Command"), this);
  669. editRunCommand = new TQLineEdit(this);
  670. buttonBrowseRunCommand = new TQPushButton(i18n("Browse"), this);
  671. // setup the Run Reset Command stuff
  672. checkRunResetCommand = new TQCheckBox(i18n("R&un Reset-Command"), this);
  673. editRunResetCommand = new TQLineEdit(this);
  674. buttonBrowseRunResetCommand = new TQPushButton(i18n("Browse"), this);
  675. // setup the Play Sound stuff
  676. checkPlaySound = new TQCheckBox(i18n("&Play Sound"), this);
  677. editPlaySound = new TQLineEdit(this);
  678. buttonBrowsePlaySound = new TQPushButton(i18n("Browse"), this);
  679. buttonTestPlaySound = new TQPushButton(this);
  680. buttonTestPlaySound->setPixmap(UserIcon("playsound"));
  681. // setup the System stuff
  682. checkBeep = new TQCheckBox(i18n("System &Beep"), this);
  683. checkNotify = new TQCheckBox(i18n("N&otify"), this);
  684. checkStatus = new TQCheckBox(i18n("&Floating Status"), this);
  685. // connect some slots and signals
  686. connect(buttonBrowsePlaySound, SIGNAL(clicked()), SLOT(browsePlaySound()));
  687. connect(buttonBrowseRunCommand, SIGNAL(clicked()), SLOT(browseRunCommand()));
  688. connect(buttonBrowseRunResetCommand, SIGNAL(clicked()), SLOT(browseRunResetCommand()));
  689. connect(checkPlaySound, SIGNAL(toggled(bool)), SLOT(enablePlaySound(bool)));
  690. connect(buttonTestPlaySound, SIGNAL(clicked()), SLOT(testPlaySound()));
  691. connect(checkRunCommand, SIGNAL(toggled(bool)), SLOT(enableRunCommand(bool)));
  692. connect(checkRunResetCommand, SIGNAL(toggled(bool)), SLOT(enableRunResetCommand(bool)));
  693. // NOW DO THE LAYOUT
  694. TQHBoxLayout *run_command_layout = new TQHBoxLayout(5);
  695. run_command_layout->addWidget(editRunCommand);
  696. run_command_layout->addWidget(buttonBrowseRunCommand);
  697. TQHBoxLayout *run_reset_command_layout = new TQHBoxLayout(5);
  698. run_reset_command_layout->addWidget(editRunResetCommand);
  699. run_reset_command_layout->addWidget(buttonBrowseRunResetCommand);
  700. TQHBoxLayout *play_sound_layout = new TQHBoxLayout(5);
  701. play_sound_layout->addWidget(buttonTestPlaySound, 0);
  702. play_sound_layout->addWidget(editPlaySound, 1);
  703. play_sound_layout->addWidget(buttonBrowsePlaySound);
  704. TQVBoxLayout *top_layout = new TQVBoxLayout(this, 5);
  705. top_layout->addWidget(checkRunCommand);
  706. top_layout->addLayout(run_command_layout);
  707. top_layout->addWidget(checkRunResetCommand);
  708. top_layout->addLayout(run_reset_command_layout);
  709. top_layout->addWidget(checkPlaySound);
  710. top_layout->addLayout(play_sound_layout);
  711. top_layout->addWidget(checkBeep);
  712. top_layout->addWidget(checkNotify);
  713. top_layout->addWidget(checkStatus);
  714. top_layout->addStretch(1);
  715. readConfig(profile_);
  716. }
  717. KBiffNewMailTab::~KBiffNewMailTab()
  718. {
  719. }
  720. void KBiffNewMailTab::testPlaySound()
  721. {
  722. KAudioPlayer::play(getPlaySoundPath());
  723. }
  724. void KBiffNewMailTab::readConfig(const TQString& profile_)
  725. {
  726. // open the config file
  727. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE, true);
  728. config->setGroup(profile_);
  729. checkRunCommand->setChecked(config->readBoolEntry("RunCommand", false));
  730. checkRunResetCommand->setChecked(config->readBoolEntry("RunResetCommand", false));
  731. checkPlaySound->setChecked(config->readBoolEntry("PlaySound", false));
  732. checkBeep->setChecked(config->readBoolEntry("SystemBeep", true));
  733. checkNotify->setChecked(config->readBoolEntry("Notify", true));
  734. checkStatus->setChecked(config->readBoolEntry("Status", true));
  735. editRunCommand->setText(config->readEntry("RunCommandPath"));
  736. editRunResetCommand->setText(config->readEntry("RunResetCommandPath"));
  737. editPlaySound->setText(config->readEntry("PlaySoundPath"));
  738. enableRunCommand(checkRunCommand->isChecked());
  739. enableRunResetCommand(checkRunResetCommand->isChecked());
  740. enablePlaySound(checkPlaySound->isChecked());
  741. delete config;
  742. }
  743. void KBiffNewMailTab::saveConfig(const TQString& profile_)
  744. {
  745. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE);
  746. config->setGroup(profile_);
  747. config->writeEntry("RunCommand", checkRunCommand->isChecked());
  748. config->writeEntry("RunResetCommand", checkRunResetCommand->isChecked());
  749. config->writeEntry("PlaySound", checkPlaySound->isChecked());
  750. config->writeEntry("SystemBeep", checkBeep->isChecked());
  751. config->writeEntry("Notify", checkNotify->isChecked());
  752. config->writeEntry("Status", checkStatus->isChecked());
  753. config->writeEntry("RunCommandPath", editRunCommand->text());
  754. config->writeEntry("RunResetCommandPath", editRunResetCommand->text());
  755. config->writeEntry("PlaySoundPath", editPlaySound->text());
  756. delete config;
  757. }
  758. bool KBiffNewMailTab::getRunCommand() const
  759. {
  760. return checkRunCommand->isChecked();
  761. }
  762. const TQString KBiffNewMailTab::getRunCommandPath() const
  763. {
  764. return editRunCommand->text();
  765. }
  766. bool KBiffNewMailTab::getRunResetCommand() const
  767. {
  768. return checkRunResetCommand->isChecked();
  769. }
  770. const TQString KBiffNewMailTab::getRunResetCommandPath() const
  771. {
  772. return editRunResetCommand->text();
  773. }
  774. bool KBiffNewMailTab::getPlaySound() const
  775. {
  776. return checkPlaySound->isChecked();
  777. }
  778. const TQString KBiffNewMailTab::getPlaySoundPath() const
  779. {
  780. return editPlaySound->text();
  781. }
  782. bool KBiffNewMailTab::getSystemBeep() const
  783. {
  784. return checkBeep->isChecked();
  785. }
  786. bool KBiffNewMailTab::getNotify() const
  787. {
  788. return checkNotify->isChecked();
  789. }
  790. bool KBiffNewMailTab::getStatus() const
  791. {
  792. return checkStatus->isChecked();
  793. }
  794. void KBiffNewMailTab::enableRunCommand(bool enable)
  795. {
  796. editRunCommand->setEnabled(enable);
  797. buttonBrowseRunCommand->setEnabled(enable);
  798. }
  799. void KBiffNewMailTab::enableRunResetCommand(bool enable)
  800. {
  801. editRunResetCommand->setEnabled(enable);
  802. buttonBrowseRunResetCommand->setEnabled(enable);
  803. }
  804. void KBiffNewMailTab::enablePlaySound(bool enable)
  805. {
  806. editPlaySound->setEnabled(enable);
  807. buttonBrowsePlaySound->setEnabled(enable);
  808. buttonTestPlaySound->setEnabled(enable);
  809. }
  810. void KBiffNewMailTab::browseRunCommand()
  811. {
  812. KURL url = KFileDialog::getOpenURL();
  813. if( url.isEmpty() )
  814. return;
  815. if( !url.isLocalFile() )
  816. {
  817. KMessageBox::sorry( 0L, i18n( "Only local files can be executed." ) );
  818. return;
  819. }
  820. editRunCommand->setText( url.path() );
  821. }
  822. void KBiffNewMailTab::browseRunResetCommand()
  823. {
  824. KURL url = KFileDialog::getOpenURL();
  825. if( url.isEmpty() )
  826. return;
  827. if( !url.isLocalFile() )
  828. {
  829. return;
  830. }
  831. editRunResetCommand->setText( url.path() );
  832. }
  833. void KBiffNewMailTab::browsePlaySound()
  834. {
  835. KURL url = KFileDialog::getOpenURL();
  836. if( url.isEmpty() )
  837. return;
  838. if( !url.isLocalFile() )
  839. {
  840. KMessageBox::sorry( 0L, i18n( "Only local files are supported yet." ) );
  841. return;
  842. }
  843. editPlaySound->setText( url.path() );
  844. }
  845. //////////////////////////////////////////////////////////////////////
  846. // KBiffMailboxTab
  847. //////////////////////////////////////////////////////////////////////
  848. KBiffMailboxAdvanced::KBiffMailboxAdvanced()
  849. : KDialog(0, 0, true, 0)
  850. {
  851. setCaption(i18n("Advanced Options"));
  852. TQLabel *mailbox_label = new TQLabel(i18n("Mailbox &URL:"), this);
  853. mailbox_label->setAlignment(AlignVCenter | AlignRight);
  854. mailbox = new TQLineEdit(this);
  855. mailbox_label->setBuddy(mailbox);
  856. TQString whatsthis = i18n(
  857. "KBiff uses URLs to specify a mailbox and the parameters "
  858. "to the mailbox. This allows you to modify the URL directly. "
  859. "Do so <i>only</i> if you really really know what you're doing!");
  860. TQWhatsThis::add(mailbox, whatsthis);
  861. TQLabel *port_label = new TQLabel(i18n("P&ort:"), this);
  862. port_label->setAlignment(AlignVCenter | AlignRight);
  863. port = new TQLineEdit(this);
  864. port_label->setBuddy(port);
  865. whatsthis = i18n(
  866. "This allows you to specify the port of your socket protocol. "
  867. "It usually is correct, so the only time you would change it is "
  868. "if you are accessing a non-standard server or going through "
  869. "a proxy (or something similar");
  870. TQWhatsThis::add(port, whatsthis);
  871. whatsthis = i18n(
  872. "IMAP4, POP3, and NNTP sockets each have their own timeout "
  873. "before they give up. If you have a slow connection, you might "
  874. "want to set this to some random high value");
  875. TQLabel *timeout_label = new TQLabel(i18n("&Timeout:"), this);
  876. timeout_label->setAlignment(AlignVCenter | AlignRight);
  877. timeout = new TQLineEdit(this);
  878. TQWhatsThis::add(timeout, whatsthis);
  879. timeout_label->setBuddy(timeout);
  880. preauth = new TQCheckBox(i18n("&PREAUTH"), this);
  881. preauth->setEnabled(false);
  882. whatsthis = i18n(
  883. "Check this if you login to your IMAP4 or POP3 server before "
  884. "kbiff accesses it.");
  885. TQWhatsThis::add(preauth, whatsthis);
  886. keepalive = new TQCheckBox(i18n("&Keep Alive"), this);
  887. keepalive->setEnabled(false);
  888. whatsthis = i18n(
  889. "If this is checked, then the IMAP4, POP3, or NNTP client "
  890. "will not log off each time");
  891. TQWhatsThis::add(keepalive, whatsthis);
  892. async = new TQCheckBox(i18n("&Asynchronous"), this);
  893. async->setEnabled(false);
  894. whatsthis = i18n(
  895. "If this is checked, then the socket protocols will access "
  896. "the server asynchronously");
  897. TQWhatsThis::add(async, whatsthis);
  898. apop = new TQCheckBox(i18n("&Disable APOP"), this);
  899. apop->setEnabled(false);
  900. whatsthis = i18n(
  901. "If this is checked, then POP mailboxes will not use Authenticated POP where available, "
  902. "and send passwords in plaintext over the network, which is a security risk");
  903. TQWhatsThis::add(apop, whatsthis);
  904. TQPushButton *ok = new TQPushButton(i18n("&OK"), this);
  905. ok->setDefault(true);
  906. TQPushButton *cancel = new TQPushButton(i18n("&Cancel"), this);
  907. // connect all the slots to signals
  908. connect(preauth, SIGNAL(toggled(bool)), SLOT(preauthModified(bool)));
  909. connect(keepalive, SIGNAL(toggled(bool)), SLOT(keepaliveModified(bool)));
  910. connect(async, SIGNAL(toggled(bool)), SLOT(asyncModified(bool)));
  911. connect(apop, SIGNAL(toggled(bool)), SLOT(apopModified(bool)));
  912. connect(port, SIGNAL(textChanged(const TQString&)),
  913. SLOT(portModified(const TQString&)));
  914. connect(ok, SIGNAL(clicked()), SLOT(accept()));
  915. connect(cancel, SIGNAL(clicked()), SLOT(reject()));
  916. connect(timeout, SIGNAL(textChanged(const TQString&)),
  917. SLOT(timeoutModified(const TQString&)));
  918. // NOW DO THE LAYOUT
  919. TQGridLayout *top_layout = new TQGridLayout(this, 7, 4, 12);
  920. top_layout->addWidget(mailbox_label, 0, 0);
  921. top_layout->addMultiCellWidget(mailbox, 0, 0, 1, 3);
  922. top_layout->addWidget(port_label, 1, 0);
  923. top_layout->addWidget(port, 1, 1);
  924. top_layout->addWidget(timeout_label, 1, 2);
  925. top_layout->addWidget(timeout, 1, 3);
  926. top_layout->addWidget(preauth, 2, 1);
  927. top_layout->addWidget(keepalive, 3, 1);
  928. top_layout->addWidget(async, 4, 1);
  929. top_layout->addWidget(apop, 4, 1);
  930. top_layout->addWidget(ok, 6, 2);
  931. top_layout->addWidget(cancel, 6, 3);
  932. }
  933. KBiffMailboxAdvanced::~KBiffMailboxAdvanced()
  934. {
  935. }
  936. const KBiffURL KBiffMailboxAdvanced::getMailbox() const
  937. {
  938. KBiffURL url(mailbox->text());
  939. url.setPass(password);
  940. return url;
  941. }
  942. unsigned int KBiffMailboxAdvanced::getPort() const
  943. {
  944. return TQString(port->text()).toInt();
  945. }
  946. void KBiffMailboxAdvanced::setMailbox(const KBiffURL& url)
  947. {
  948. password = url.pass();
  949. KBiffURL new_url(url);
  950. new_url.setPass("");
  951. mailbox->setText(new_url.url());
  952. }
  953. void KBiffMailboxAdvanced::setPort(unsigned int the_port, bool enable)
  954. {
  955. port->setEnabled(enable);
  956. port->setText(TQString().setNum(the_port));
  957. }
  958. void KBiffMailboxAdvanced::portModified(const TQString& text)
  959. {
  960. KBiffURL url = getMailbox();
  961. url.setPort(TQString(text).toInt());
  962. setMailbox(url);
  963. }
  964. void KBiffMailboxAdvanced::setTimeout(unsigned int the_to, bool enable)
  965. {
  966. timeout->setEnabled(enable);
  967. timeout->setText(TQString().setNum(the_to));
  968. }
  969. void KBiffMailboxAdvanced::timeoutModified(const TQString& text)
  970. {
  971. KBiffURL url = getMailbox();
  972. url.setSearchPar("timeout", text.local8Bit());
  973. setMailbox(url);
  974. }
  975. void KBiffMailboxAdvanced::preauthModified(bool is_preauth)
  976. {
  977. KBiffURL url = getMailbox();
  978. if (is_preauth)
  979. url.setSearchPar("preauth", "yes");
  980. else
  981. url.setSearchPar("preauth", "no");
  982. setMailbox(url);
  983. }
  984. void KBiffMailboxAdvanced::keepaliveModified(bool is_keepalive)
  985. {
  986. KBiffURL url = getMailbox();
  987. if (is_keepalive)
  988. url.setSearchPar("keepalive", "yes");
  989. else
  990. url.setSearchPar("keepalive", "no");
  991. setMailbox(url);
  992. }
  993. void KBiffMailboxAdvanced::asyncModified(bool is_async)
  994. {
  995. KBiffURL url = getMailbox();
  996. if (is_async)
  997. url.setSearchPar("async", "yes");
  998. else
  999. url.setSearchPar("async", "no");
  1000. setMailbox(url);
  1001. }
  1002. void KBiffMailboxAdvanced::apopModified(bool disable_apop)
  1003. {
  1004. KBiffURL url = getMailbox();
  1005. if ( url.protocol() == "pop3" || url.protocol() == "pop3s" )
  1006. {
  1007. if ( disable_apop )
  1008. url.setSearchPar("apop", "no");
  1009. else
  1010. url.setSearchPar("apop", "yes");
  1011. setMailbox(url);
  1012. }
  1013. }
  1014. void KBiffMailboxAdvanced::setPreauth(bool on)
  1015. {
  1016. preauth->setEnabled(true);
  1017. preauth->setChecked(on);
  1018. }
  1019. void KBiffMailboxAdvanced::setKeepalive(bool on)
  1020. {
  1021. keepalive->setEnabled(true);
  1022. keepalive->setChecked(on);
  1023. }
  1024. void KBiffMailboxAdvanced::setAsync(bool on)
  1025. {
  1026. async->setEnabled(true);
  1027. async->setChecked(on);
  1028. }
  1029. void KBiffMailboxAdvanced::setDisableApop(bool on)
  1030. {
  1031. apop->setEnabled(true);
  1032. apop->setChecked(on);
  1033. }
  1034. bool KBiffMailboxAdvanced::getPreauth() const
  1035. {
  1036. return preauth->isChecked();
  1037. }
  1038. KBiffMailboxTab::KBiffMailboxTab(const TQString& profile_, TQWidget *parent_)
  1039. : TQWidget(parent_), mailboxHash(new TQDict<KBiffMailbox>)
  1040. {
  1041. if (mailboxHash)
  1042. mailboxHash->setAutoDelete(true);
  1043. mailboxes = new TQListView(this);
  1044. mailboxes->setFrameStyle(TQFrame::WinPanel | TQFrame::Sunken);
  1045. mailboxes->addColumn(i18n("Mailbox:"));
  1046. mailboxes->header()->hide();
  1047. TQPushButton *new_mailbox = new TQPushButton(this);
  1048. new_mailbox->setPixmap(UserIcon("mailbox"));
  1049. TQToolTip::add(new_mailbox, i18n("New Mailbox"));
  1050. TQPushButton *delete_mailbox = new TQPushButton(this);
  1051. delete_mailbox->setPixmap(UserIcon("delete"));
  1052. TQToolTip::add(delete_mailbox, i18n("Delete Mailbox"));
  1053. TQLabel *protocol_label = new TQLabel(i18n("Pro&tocol:"), this);
  1054. comboProtocol = new TQComboBox(this);
  1055. comboProtocol->insertItem("");
  1056. comboProtocol->insertItem("mbox");
  1057. comboProtocol->insertItem("maildir");
  1058. comboProtocol->insertItem("imap4");
  1059. comboProtocol->insertItem("pop3");
  1060. comboProtocol->insertItem("mh");
  1061. comboProtocol->insertItem("file");
  1062. comboProtocol->insertItem("nntp");
  1063. #ifdef USE_SSL
  1064. comboProtocol->insertItem("imap4s");
  1065. comboProtocol->insertItem("pop3s");
  1066. #endif // USE_SSL
  1067. protocol_label->setBuddy(comboProtocol);
  1068. TQLabel *mailbox_label = new TQLabel(i18n("&Mailbox:"), this);
  1069. editMailbox = new TQLineEdit(this);
  1070. mailbox_label->setBuddy(editMailbox);
  1071. buttonBrowse = new TQPushButton("...", this);
  1072. TQLabel *server_label = new TQLabel(i18n("&Server:"), this);
  1073. editServer = new TQLineEdit(this);
  1074. server_label->setBuddy(editServer);
  1075. TQLabel *user_label = new TQLabel(i18n("&User:"), this);
  1076. editUser = new TQLineEdit(this);
  1077. user_label->setBuddy(editUser);
  1078. TQLabel *password_label = new TQLabel(i18n("P&assword:"), this);
  1079. editPassword = new TQLineEdit(this);
  1080. editPassword->setEchoMode(TQLineEdit::Password);
  1081. password_label->setBuddy(editPassword);
  1082. checkStorePassword = new TQCheckBox(i18n("S&tore password"), this);
  1083. TQPushButton *advanced_button = new TQPushButton(i18n("&Advanced"), this);
  1084. // the command to run before polling
  1085. TQGroupBox *fetch_box = new TQGroupBox(this);
  1086. fetch_box->setTitle(i18n("Pre-&Polling Command"));
  1087. fetch_box->setColumnLayout(0, TQt::Vertical );
  1088. fetch_box->layout()->setSpacing(0);
  1089. fetch_box->layout()->setMargin(0);
  1090. checkFetchCommand = new TQCheckBox(i18n("&Enable"), fetch_box);
  1091. editFetchCommand = new TQLineEdit(fetch_box);
  1092. buttonBrowseFetchCommand = new TQPushButton(i18n("Browse"), fetch_box);
  1093. TQString whatsthis = i18n(
  1094. "This command shall be run <em>before</em> KBiff polls for new "
  1095. "mail. It is useful for those people that want to download their "
  1096. "POP3 mail regularly using (for instance) 'fetchmail'");
  1097. TQWhatsThis::add(checkFetchCommand, whatsthis);
  1098. TQWhatsThis::add(editFetchCommand, whatsthis);
  1099. TQWhatsThis::add(buttonBrowseFetchCommand, whatsthis);
  1100. enableFetchCommand(false);
  1101. // connect all the signals
  1102. connect(mailboxes, SIGNAL(selectionChanged(TQListViewItem *)),
  1103. SLOT(slotMailboxSelected(TQListViewItem *)));
  1104. connect(new_mailbox, SIGNAL(clicked()), SLOT(slotNewMailbox()));
  1105. connect(delete_mailbox, SIGNAL(clicked()), SLOT(slotDeleteMailbox()));
  1106. connect(comboProtocol, SIGNAL(highlighted(int)),
  1107. SLOT(protocolSelected(int)));
  1108. connect(buttonBrowse, SIGNAL(clicked()), SLOT(browse()));
  1109. connect(advanced_button, SIGNAL(clicked()), SLOT(advanced()));
  1110. connect(buttonBrowseFetchCommand, SIGNAL(clicked()), SLOT(browseFetchCommand()));
  1111. connect(checkFetchCommand, SIGNAL(toggled(bool)), SLOT(enableFetchCommand(bool)));
  1112. // NOW DO THE LAYOUT
  1113. TQHBoxLayout *fetch_command_layout = new TQHBoxLayout(5);
  1114. fetch_command_layout->addWidget(editFetchCommand, 1);
  1115. fetch_command_layout->addWidget(buttonBrowseFetchCommand);
  1116. TQVBoxLayout *group_layout = new TQVBoxLayout(fetch_box->layout());
  1117. group_layout->setAlignment(TQt::AlignTop);
  1118. group_layout->setSpacing(6);
  1119. group_layout->setMargin(11);
  1120. group_layout->addWidget(checkFetchCommand);
  1121. group_layout->addLayout(fetch_command_layout);
  1122. TQHBoxLayout *advanced_layout = new TQHBoxLayout;
  1123. advanced_layout->addStretch(1);
  1124. advanced_layout->addWidget(advanced_button);
  1125. TQGridLayout *param_layout = new TQGridLayout(6, 3, 12);
  1126. param_layout->addWidget(protocol_label, 0, 0);
  1127. param_layout->addWidget(comboProtocol, 0, 1, 1);
  1128. param_layout->addWidget(buttonBrowse, 0, 2);
  1129. param_layout->addWidget(mailbox_label, 1, 0);
  1130. param_layout->addMultiCellWidget(editMailbox, 1, 1, 1, 2);
  1131. param_layout->addWidget(server_label, 2, 0);
  1132. param_layout->addMultiCellWidget(editServer, 2, 2, 1, 2);
  1133. param_layout->addWidget(user_label, 3, 0);
  1134. param_layout->addMultiCellWidget(editUser, 3, 3, 1, 2);
  1135. param_layout->addWidget(password_label, 4, 0);
  1136. param_layout->addMultiCellWidget(editPassword, 4, 4, 1, 2);
  1137. param_layout->addMultiCellWidget(checkStorePassword, 5, 5, 1, 2);
  1138. param_layout->setColStretch(1, 1);
  1139. TQVBoxLayout *right_side_layout = new TQVBoxLayout;
  1140. right_side_layout->addLayout(param_layout);
  1141. right_side_layout->addWidget(fetch_box);
  1142. right_side_layout->addLayout(advanced_layout);
  1143. right_side_layout->addStretch(1);
  1144. TQGridLayout *mailbox_layout = new TQGridLayout(2, 2, 1);
  1145. mailbox_layout->addMultiCellWidget(mailboxes, 0, 0, 0, 1);
  1146. mailbox_layout->addWidget(new_mailbox, 1, 0);
  1147. mailbox_layout->addWidget(delete_mailbox, 1, 1);
  1148. TQHBoxLayout *top_layout = new TQHBoxLayout(this, 12);
  1149. top_layout->addLayout(mailbox_layout);
  1150. top_layout->addLayout(right_side_layout);
  1151. readConfig(profile_);
  1152. }
  1153. KBiffMailboxTab::~KBiffMailboxTab()
  1154. {
  1155. delete mailboxHash;
  1156. }
  1157. void KBiffMailboxTab::readConfig(const TQString& profile_)
  1158. {
  1159. // initialize some variables that need initing
  1160. oldItem = 0;
  1161. // open the config file
  1162. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE, true);
  1163. config->setDollarExpansion(false);
  1164. mailboxHash->clear();
  1165. mailboxes->clear();
  1166. config->setGroup(profile_);
  1167. TQStringList mailbox_list;
  1168. mailbox_list = config->readListEntry("Mailboxes", ',');
  1169. int number_of_mailboxes = mailbox_list.count();
  1170. if (number_of_mailboxes > 0)
  1171. {
  1172. for (unsigned int i = 0; i < mailbox_list.count(); i+=3)
  1173. {
  1174. KBiffMailbox *mailbox = new KBiffMailbox();
  1175. mailbox->key = *mailbox_list.at(i);
  1176. mailbox->url = KBiffURL(*mailbox_list.at(i+1));
  1177. TQString password(KBiffCodecs::base64Decode(*mailbox_list.at(i+2)));
  1178. if (password.isEmpty())
  1179. mailbox->store = false;
  1180. else
  1181. {
  1182. mailbox->store = true;
  1183. mailbox->url.setPass(password);
  1184. }
  1185. TQListViewItem *item = new TQListViewItem(mailboxes, mailbox->key);
  1186. item->setPixmap(0, TQPixmap(UserIcon("mailbox")));
  1187. mailboxHash->insert(mailbox->key, mailbox);
  1188. }
  1189. }
  1190. else
  1191. {
  1192. KBiffMailbox *mailbox = new KBiffMailbox();
  1193. mailbox->key = i18n("Default");
  1194. mailbox->store = false;
  1195. mailbox->url = defaultMailbox();
  1196. mailboxHash->insert(mailbox->key, mailbox);
  1197. TQListViewItem *item = new TQListViewItem(mailboxes, mailbox->key);
  1198. item->setPixmap(0, TQPixmap(UserIcon("mailbox")));
  1199. }
  1200. mailboxes->setSelected(mailboxes->firstChild(), true);
  1201. delete config;
  1202. }
  1203. void KBiffMailboxTab::saveConfig(const TQString& profile_)
  1204. {
  1205. // open the config file
  1206. KSimpleConfig *config = new KSimpleConfig(CONFIG_FILE);
  1207. config->setDollarExpansion(false);
  1208. config->setGroup(profile_);
  1209. TQStringList mailbox_list;
  1210. for (TQListViewItem *item = mailboxes->firstChild();
  1211. item;
  1212. item = item->nextSibling())
  1213. {
  1214. KBiffMailbox *mailbox = new KBiffMailbox();
  1215. TQString item_text(item->text(0));
  1216. // if this mailbox is the current one, then use the current
  1217. // settings instead of the hash
  1218. if (item == mailboxes->currentItem())
  1219. {
  1220. mailbox->store = checkStorePassword->isChecked();
  1221. mailbox->url = getMailbox();
  1222. mailboxHash->replace(item_text, mailbox);
  1223. }
  1224. mailbox = mailboxHash->find(item_text);
  1225. TQString password(KBiffCodecs::base64Encode(mailbox->url.pass().local8Bit()));
  1226. KBiffURL url = mailbox->url;
  1227. url.setPass("");
  1228. if (mailbox->store == false)
  1229. password = "";
  1230. mailbox_list.append(item_text);
  1231. mailbox_list.append(url.url());
  1232. mailbox_list.append(password);
  1233. }
  1234. config->writeEntry("Mailboxes", mailbox_list, ',');
  1235. delete config;
  1236. }
  1237. void KBiffMailboxTab::enableFetchCommand(bool enable)
  1238. {
  1239. editFetchCommand->setEnabled(enable);
  1240. buttonBrowseFetchCommand->setEnabled(enable);
  1241. }
  1242. void KBiffMailboxTab::browseFetchCommand()
  1243. {
  1244. KURL url = KFileDialog::getOpenURL();
  1245. if( url.isEmpty() )
  1246. return;
  1247. if( !url.isLocalFile() )
  1248. {
  1249. KMessageBox::sorry( 0L, i18n( "Only local files can be executed." ) );
  1250. return;
  1251. }
  1252. editFetchCommand->setText( url.path() );
  1253. }
  1254. void KBiffMailboxTab::setMailbox(const KBiffURL& url)
  1255. {
  1256. TQString prot(url.protocol());
  1257. if (prot == "mbox")
  1258. protocolSelected(1);
  1259. else if (prot == "maildir")
  1260. protocolSelected(2);
  1261. else if (prot == "imap4")
  1262. protocolSelected(3);
  1263. else if (prot == "pop3")
  1264. protocolSelected(4);
  1265. else if (prot == "mh")
  1266. protocolSelected(5);
  1267. else if (prot == "file")
  1268. protocolSelected(6);
  1269. else if (prot == "nntp")
  1270. protocolSelected(7);
  1271. #ifdef USE_SSL
  1272. else if (prot == "imap4s")
  1273. protocolSelected(8);
  1274. else if (prot == "pop3s")
  1275. protocolSelected(9);
  1276. #endif // USE_SSL
  1277. else
  1278. return;
  1279. if (editMailbox->isEnabled())
  1280. {
  1281. TQString path(url.path());
  1282. if (((prot == "imap4") || (prot == "nntp") || (prot == "imap4s")) && !path.isEmpty() && path[0] == '/')
  1283. path.remove(0, 1);
  1284. editMailbox->setText(path);
  1285. }
  1286. port = url.port();
  1287. if (editServer->isEnabled())
  1288. editServer->setText(url.host());
  1289. if (editUser->isEnabled())
  1290. {
  1291. TQString user(url.user());
  1292. editUser->setText(user);
  1293. }
  1294. if (editPassword->isEnabled())
  1295. {
  1296. TQString passwd(url.pass());
  1297. editPassword->setText(passwd);
  1298. }
  1299. timeout = url.searchPar("timeout").toInt();
  1300. preauth = url.searchPar("preauth") == "yes" ? true : false;
  1301. keepalive = url.searchPar("keepalive") == "yes" ? true : false;
  1302. async = url.searchPar("async") == "yes" ? true : false;
  1303. useApop = url.searchPar("apop") == "no" ? false : true;
  1304. TQString fetch = url.searchPar("fetch");
  1305. checkFetchCommand->setChecked(!fetch.isEmpty());
  1306. editFetchCommand->setText(fetch);
  1307. }
  1308. const KBiffURL KBiffMailboxTab::getMailbox() const
  1309. {
  1310. KBiffURL url;
  1311. url.setProtocol(comboProtocol->currentText());
  1312. TQString prot(url.protocol());
  1313. if (editUser->isEnabled())
  1314. {
  1315. TQString user(editUser->text());
  1316. url.setUser(user);
  1317. }
  1318. if (editPassword->isEnabled())
  1319. {
  1320. TQString passwd(editPassword->text());
  1321. url.setPass(passwd);
  1322. }
  1323. if (editServer->isEnabled())
  1324. url.setHost(editServer->text());
  1325. url.setPort(port);
  1326. if (editMailbox->isEnabled())
  1327. {
  1328. TQString path(editMailbox->text());
  1329. if (!path.isEmpty() && path[0] != '/')
  1330. path.prepend("/");
  1331. url.setPath(path);
  1332. }
  1333. if ((prot == "imap4") || (prot == "pop3") || (prot == "nntp") || (prot == "imap4s") || (prot == "pop3s"))
  1334. {
  1335. if (keepalive)
  1336. url.setSearchPar("keepalive", "yes");
  1337. else
  1338. url.setSearchPar("keepalive", "no");
  1339. if (async)
  1340. url.setSearchPar("async", "yes");
  1341. else
  1342. url.setSearchPar("async", "no");
  1343. if ((prot == "pop3s") || (prot == "pop3") )
  1344. {
  1345. if (useApop)
  1346. url.setSearchPar("apop", "yes");
  1347. else
  1348. url.setSearchPar("apop", "no");
  1349. }
  1350. url.setSearchPar("timeout", TQString().setNum(timeout));
  1351. }
  1352. if (checkFetchCommand->isChecked() && !editFetchCommand->text().isEmpty())
  1353. url.setSearchPar("fetch", editFetchCommand->text());
  1354. return url;
  1355. }
  1356. const TQPtrList<KBiffMailbox> KBiffMailboxTab::getMailboxList() const
  1357. {
  1358. TQPtrList<KBiffMailbox> mbox_list;
  1359. for (TQListViewItem *item = mailboxes->firstChild();
  1360. item;
  1361. item = item->nextSibling())
  1362. {
  1363. KBiffMailbox *mailbox = mailboxHash->find(item->text(0));
  1364. // without the next line the key of the first mailbox is lost.
  1365. // it's a mystery for me
  1366. mailbox->key = item->text(0);
  1367. mbox_list.append(mailbox);
  1368. }
  1369. return mbox_list;
  1370. }
  1371. void KBiffMailboxTab::slotDeleteMailbox()
  1372. {
  1373. /* only delete the non default mailboxes */
  1374. if (mailboxes->childCount() == 1)
  1375. return;
  1376. /* need some "Are you sure?" code here */
  1377. TQListViewItem *item = mailboxes->currentItem();
  1378. mailboxHash->remove(item->text(0));
  1379. mailboxes->takeItem(item);
  1380. item = 0;
  1381. mailboxes->setSelected(mailboxes->firstChild(), true);
  1382. }
  1383. void KBiffMailboxTab::slotNewMailbox()
  1384. {
  1385. KBiffNewDlg dlg;
  1386. // popup the name chooser
  1387. dlg.setCaption(i18n("New Mailbox"));
  1388. if (dlg.exec())
  1389. {
  1390. TQString mailbox_name = dlg.getName();
  1391. // continue only if we received a decent name
  1392. if (mailbox_name.isEmpty() == false)
  1393. {
  1394. TQListViewItem *item = new TQListViewItem(mailboxes, mailbox_name);
  1395. item->setPixmap(0, TQPixmap(UserIcon("mailbox")));
  1396. KBiffMailbox *mailbox = new KBiffMailbox();
  1397. mailbox->store = false;
  1398. mailbox->url = defaultMailbox();
  1399. mailboxHash->insert(mailbox_name, mailbox);
  1400. mailboxes->setSelected(item, true);
  1401. }
  1402. }
  1403. }
  1404. void KBiffMailboxTab::slotMailboxSelected(TQListViewItem *item)
  1405. {
  1406. KBiffMailbox *mailbox;
  1407. // if an "old" item exists, save the current info as it
  1408. if (oldItem && !oldItem->text(0).isNull())
  1409. {
  1410. mailbox = mailboxHash->find(oldItem->text(0));
  1411. if (mailbox)
  1412. {
  1413. // change the hash only if the item is different
  1414. KBiffURL url(getMailbox());
  1415. bool checked = checkStorePassword->isChecked();
  1416. if (mailbox->url.url() != url.url() || mailbox->store != checked)
  1417. {
  1418. mailbox->url = getMailbox();
  1419. mailbox->store = checkStorePassword->isChecked();
  1420. }
  1421. }
  1422. }
  1423. mailbox = mailboxHash->find(item->text(0));
  1424. if (mailbox)
  1425. {
  1426. setMailbox(mailbox->url);
  1427. checkStorePassword->setChecked(mailbox->store);
  1428. // save this as the "old" item
  1429. oldItem = item;
  1430. }
  1431. }
  1432. void KBiffMailboxTab::protocolSelected(int protocol)
  1433. {
  1434. comboProtocol->setCurrentItem(protocol);
  1435. switch (protocol)
  1436. {
  1437. case 1: // mbox
  1438. case 2: // maildir
  1439. case 5: // mh
  1440. case 6: // file
  1441. port = 0;
  1442. buttonBrowse->setEnabled(true);
  1443. editMailbox->setEnabled(true);
  1444. editServer->setEnabled(false);
  1445. editUser->setEnabled(false);
  1446. editPassword->setEnabled(false);
  1447. checkStorePassword->setEnabled(false);
  1448. break;
  1449. case 3: // IMAP4
  1450. port = 143;
  1451. timeout = 10;
  1452. editMailbox->setEnabled(true);
  1453. buttonBrowse->setEnabled(true);
  1454. editServer->setEnabled(true);
  1455. editUser->setEnabled(true);
  1456. editPassword->setEnabled(true);
  1457. checkStorePassword->setEnabled(true);
  1458. break;
  1459. #ifdef USE_SSL
  1460. case 8: // IMAP4S
  1461. port = 993;
  1462. timeout = 10;
  1463. editMailbox->setEnabled(true);
  1464. buttonBrowse->setEnabled(true);
  1465. editServer->setEnabled(true);
  1466. editUser->setEnabled(true);
  1467. editPassword->setEnabled(true);
  1468. checkStorePassword->setEnabled(true);
  1469. break;
  1470. #endif // USE_SSL
  1471. case 7: // NNTP
  1472. port = 119;
  1473. timeout = 10;
  1474. editMailbox->setEnabled(true);
  1475. buttonBrowse->setEnabled(false);
  1476. editServer->setEnabled(true);
  1477. editUser->setEnabled(true);
  1478. editPassword->setEnabled(true);
  1479. checkStorePassword->setEnabled(true);
  1480. break;
  1481. case 4: // POP3
  1482. port = 110;
  1483. timeout = 10;
  1484. editMailbox->setEnabled(false);
  1485. buttonBrowse->setEnabled(false);
  1486. editServer->setEnabled(true);
  1487. editUser->setEnabled(true);
  1488. editPassword->setEnabled(true);
  1489. checkStorePassword->setEnabled(true);
  1490. break;
  1491. #ifdef USE_SSL
  1492. case 9: // POP3S
  1493. port = 995;
  1494. timeout = 10;
  1495. editMailbox->setEnabled(false);
  1496. buttonBrowse->setEnabled(false);
  1497. editServer->setEnabled(true);
  1498. editUser->setEnabled(true);
  1499. editPassword->setEnabled(true);
  1500. checkStorePassword->setEnabled(true);
  1501. break;
  1502. #endif // USE_SSL
  1503. default: // blank
  1504. port = 0;
  1505. timeout = 0;
  1506. editMailbox->setEnabled(false);
  1507. buttonBrowse->setEnabled(false);
  1508. editServer->setEnabled(false);
  1509. editUser->setEnabled(false);
  1510. editPassword->setEnabled(false);
  1511. checkStorePassword->setEnabled(false);
  1512. break;
  1513. }
  1514. }
  1515. void KBiffMailboxTab::browse()
  1516. {
  1517. TQString proto(getMailbox().protocol());
  1518. if (proto == "imap4" || proto == "imap4s")
  1519. {
  1520. KURL start;
  1521. start.setProtocol((proto == "imap4s") ? "imaps" : "imap");
  1522. start.setUser(getMailbox().user());
  1523. start.setHost(getMailbox().host());
  1524. start.setPath("/");
  1525. KURL url = KFileDialog::getOpenURL(start.url());
  1526. if (url.url().isEmpty())
  1527. return;
  1528. TQString path(url.path());
  1529. if (path.isEmpty())
  1530. return;
  1531. if (path[0] == '/')
  1532. path = path.right(path.length() - 1);
  1533. if (path.right(1) == "/")
  1534. path = path.left(path.length() - 1);
  1535. editMailbox->setText( path );
  1536. return;
  1537. }
  1538. else
  1539. {
  1540. TQString file;
  1541. if (proto == "maildir")
  1542. file = KFileDialog::getExistingDirectory();
  1543. else
  1544. file = KFileDialog::getOpenFileName();
  1545. if( file.isEmpty() )
  1546. return;
  1547. editMailbox->setText( file );
  1548. }
  1549. }
  1550. void KBiffMailboxTab::advanced()
  1551. {
  1552. KBiffMailboxAdvanced advanced_dlg;
  1553. TQString prot(getMailbox().protocol());
  1554. if (prot == "mbox" || prot == "maildir" || prot == "file" || prot == "mh")
  1555. {
  1556. advanced_dlg.setPort(port, false);
  1557. advanced_dlg.setTimeout(timeout, false);
  1558. }
  1559. else
  1560. {
  1561. advanced_dlg.setPort(port);
  1562. advanced_dlg.setTimeout(timeout);
  1563. }
  1564. if ((prot == "imap4") || (prot == "imap4s"))
  1565. {
  1566. advanced_dlg.setPreauth(preauth);
  1567. advanced_dlg.setKeepalive(keepalive);
  1568. advanced_dlg.setAsync(async);
  1569. }
  1570. if ((prot == "pop3") || (prot == "nntp") || (prot == "pop3s"))
  1571. {
  1572. advanced_dlg.setKeepalive(keepalive);
  1573. advanced_dlg.setAsync(async);
  1574. advanced_dlg.setDisableApop(!useApop);
  1575. }
  1576. advanced_dlg.setMailbox(getMailbox());
  1577. if (advanced_dlg.exec())
  1578. {
  1579. port = advanced_dlg.getPort();
  1580. setMailbox(advanced_dlg.getMailbox());
  1581. }
  1582. }
  1583. const KBiffURL KBiffMailboxTab::defaultMailbox() const
  1584. {
  1585. TQFileInfo mailbox_info(getenv("MAIL"));
  1586. if (mailbox_info.exists() == false)
  1587. {
  1588. TQString s(_PATH_MAILDIR);
  1589. s += "/";
  1590. s += getpwuid(getuid())->pw_name;
  1591. mailbox_info.setFile(s);
  1592. }
  1593. TQString default_path = mailbox_info.isDir() ? TQString("maildir:") :
  1594. TQString("mbox:");
  1595. default_path.append(mailbox_info.absFilePath());
  1596. return KBiffURL(default_path);
  1597. }
  1598. //////////////////////////////////////////////////////////////////////
  1599. // KBiffAboutTab
  1600. //////////////////////////////////////////////////////////////////////
  1601. KBiffAboutTab::KBiffAboutTab(TQWidget *parent_)
  1602. : TQWidget(parent_)
  1603. {
  1604. // load in the kbiff pixmap
  1605. TQPixmap logo_pixmap(kapp->icon());
  1606. TQLabel *pixmap_label = new TQLabel(this);
  1607. pixmap_label->setPixmap(logo_pixmap);
  1608. // we want a bigger logo
  1609. TQFont logo_font = TQApplication::font();
  1610. logo_font.setPointSize(logo_font.pointSize() * 1.5);
  1611. logo_font.setBold(true);
  1612. KURLLabel *logo_label = new KURLLabel(this);
  1613. logo_label->setURL("http://kbiff.granroth.org");
  1614. logo_label->setFont(logo_font);
  1615. logo_label->setText("KBiff");
  1616. logo_label->setUnderline(false);
  1617. logo_label->setGlow(false);
  1618. logo_label->setFloat(true);
  1619. connect(logo_label, SIGNAL(leftClickedURL(const TQString&)),
  1620. SLOT(homepage(const TQString&)));
  1621. TQLabel *version_label = new TQLabel(this);
  1622. version_label->setText(TQString("Version %1\n\nCopyright (C) 1998-2008\nKurt Granroth").arg(kbiff_version));
  1623. KURLLabel *email_label = new KURLLabel(this);
  1624. email_label->setText("granroth@kde.org");
  1625. email_label->setURL("mailto:granroth@kde.org");
  1626. email_label->setUnderline(false);
  1627. email_label->setGlow(false);
  1628. email_label->setFloat(true);
  1629. connect(email_label, SIGNAL(leftClickedURL(const TQString&)),
  1630. SLOT(mailTo(const TQString&)));
  1631. // about tab text layout
  1632. TQVBoxLayout *text_layout = new TQVBoxLayout(0);
  1633. text_layout->addWidget(version_label);
  1634. text_layout->addWidget(email_label);
  1635. // main about tab layout
  1636. TQGridLayout *about_layout = new TQGridLayout(this, 3, 2, 12, 0);
  1637. about_layout->addWidget(pixmap_label, 0, 0);
  1638. about_layout->addWidget(logo_label, 0, 1);
  1639. about_layout->addLayout(text_layout, 1, 1);
  1640. about_layout->setRowStretch(2, 1);
  1641. }
  1642. KBiffAboutTab::~KBiffAboutTab()
  1643. {
  1644. }
  1645. void KBiffAboutTab::mailTo(const TQString& url)
  1646. {
  1647. (void) new KRun ( url );
  1648. }
  1649. void KBiffAboutTab::homepage(const TQString& url)
  1650. {
  1651. (void) new KRun ( url );
  1652. }
  1653. KBiffNewDlg::KBiffNewDlg(TQWidget* parent_, const char * name_)
  1654. : KDialog(parent_, name_, true)
  1655. {
  1656. // set my name
  1657. setCaption(i18n("New Name"));
  1658. TQLabel* label = new TQLabel(i18n("&New Name:"), this);
  1659. editName = new TQLineEdit(this);
  1660. editName->setFocus();
  1661. label->setBuddy(editName);
  1662. // ok button
  1663. TQPushButton* button_ok = new TQPushButton(i18n("&OK"), this);
  1664. button_ok->setDefault(true);
  1665. // cancel button
  1666. TQPushButton* button_cancel = new TQPushButton(i18n("&Cancel"), this);
  1667. connect(button_ok, SIGNAL(clicked()), SLOT(accept()));
  1668. connect(button_cancel, SIGNAL(clicked()), SLOT(reject()));
  1669. // NOW DO THE LAYOUT
  1670. TQGridLayout *top_layout = new TQGridLayout(this, 2, 3, 12);
  1671. top_layout->addWidget(label, 0, 0);
  1672. top_layout->addMultiCellWidget(editName, 0, 0, 1, 2);
  1673. top_layout->addWidget(button_ok, 1, 1);
  1674. top_layout->addWidget(button_cancel, 1, 2);
  1675. }