PageRenderTime 56ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/quassel-0.7.3/src/qtui/settingspages/itemviewsettingspage.cpp

#
C++ | 76 lines | 47 code | 10 blank | 19 comment | 15 complexity | a61bdb6b54a27a8d1b49db83cfd04d44 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0
  1. /***************************************************************************
  2. * Copyright (C) 2005-09 by the Quassel Project *
  3. * devel@quassel-irc.org *
  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) version 3. *
  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 <QSignalMapper>
  21. #include "itemviewsettingspage.h"
  22. #include "colorbutton.h"
  23. #include "qtui.h"
  24. #include "qtuistyle.h"
  25. ItemViewSettingsPage::ItemViewSettingsPage(QWidget *parent)
  26. : SettingsPage(tr("Interface"), tr("Chat & Nick Lists"), parent),
  27. _mapper(new QSignalMapper(this))
  28. {
  29. ui.setupUi(this);
  30. _networkItem = new QTreeWidgetItem(ui.bufferViewPreview, QStringList(tr("Network")));
  31. _networkItem->setFlags(Qt::NoItemFlags);
  32. _inactiveBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Inactive")));
  33. _defaultBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Normal")));
  34. _unreadBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Unread messages")));
  35. _highlightedBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Highlight")));
  36. _activeBufferItem = new QTreeWidgetItem(_networkItem, QStringList(tr("Other activity")));
  37. ui.bufferViewPreview->expandAll();
  38. foreach(ColorButton *button, findChildren<ColorButton *>()) {
  39. connect(button, SIGNAL(colorChanged(QColor)), _mapper, SLOT(map()));
  40. _mapper->setMapping(button, button);
  41. }
  42. connect(_mapper, SIGNAL(mapped(QWidget *)), SLOT(updateBufferViewPreview(QWidget *)));
  43. initAutoWidgets();
  44. }
  45. void ItemViewSettingsPage::save() {
  46. SettingsPage::save();
  47. QtUi::style()->generateSettingsQss();
  48. QtUi::style()->reload();
  49. }
  50. void ItemViewSettingsPage::updateBufferViewPreview(QWidget *widget) {
  51. ColorButton *button = qobject_cast<ColorButton *>(widget);
  52. if(!button)
  53. return;
  54. QString objName = button->objectName();
  55. if(objName == "defaultBufferColor") {
  56. _networkItem->setForeground(0, button->color());
  57. _defaultBufferItem->setForeground(0, button->color());
  58. } else if(objName == "inactiveBufferColor")
  59. _inactiveBufferItem->setForeground(0, button->color());
  60. else if(objName == "activeBufferColor")
  61. _activeBufferItem->setForeground(0, button->color());
  62. else if(objName == "unreadBufferColor")
  63. _unreadBufferItem->setForeground(0, button->color());
  64. else if(objName == "highlightedBufferColor")
  65. _highlightedBufferItem->setForeground(0, button->color());
  66. }