Project

General

Profile

0003-Configuration-support-for-desktop-notifications.patch

admin, 05/21/2008 02:46 PM

View differences:

src/qtui/mainwin.cpp
578 578
    UiSettings uiSettings;
579 579

  
580 580
#ifndef SPUTDEV
581
    if(uiSettings.value("DisplayPopupMessages", QVariant(true)).toBool()) {
581
	bool displayBubble = uiSettings.value("NotificationBubble", QVariant(true)).toBool();
582
	bool displayDesktop = uiSettings.value("NotificationDesktop", QVariant(true)).toBool();
583
    if(displayBubble || displayDesktop) {
582 584
      // FIXME don't invoke style engine for this!
583 585
      QString text = QtUi::style()->styleString(Message::mircToInternal(msg.contents())).plainText;
584
      displayTrayIconMessage(title, text);
585
	  sendDesktopNotification(title, text);
586
	  if (displayBubble) displayTrayIconMessage(title, text);
587
	  if (displayDesktop) sendDesktopNotification(title, text);
586 588
    }
587 589
#endif
588 590
    if(uiSettings.value("AnimateTrayIcon", QVariant(true)).toBool()) {
......
607 609
{
608 610
	QStringList actions;
609 611
	QMap<QString, QVariant> hints;
612
    UiSettings uiSettings;
610 613

  
611
	hints["x"] = 100; // Standard hint: x location for the popup to show up
612
	hints["y"] = 100; // Standard hint: y location for the popup to show up
614
	hints["x"] = uiSettings.value("NotificationDesktopHintX", QVariant(0)).toInt(); // Standard hint: x location for the popup to show up
615
	hints["y"] = uiSettings.value("NotificationDesktopHintY", QVariant(0)).toInt(); // Standard hint: y location for the popup to show up
613 616

  
614 617
	actions << "click" << "Click Me!";
615 618

  
......
621 624
		QString("%1: %2:\n%2").arg(QTime::currentTime().toString()).arg(title).arg(message), // Body of the message to display
622 625
		actions, // Actions from which the user may choose
623 626
		hints, // Hints to the server displaying the message
624
		5000 // Timeout in milliseconds
627
		uiSettings.value("NotificationDesktopTimeout", QVariant(5000)).toInt() // Timeout in milliseconds
625 628
	);
626 629

  
627 630
	if (!reply.isValid())
src/qtui/settingspages/generalsettingspage.cpp
44 44
  connect(ui.minimizeOnClose, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
45 45

  
46 46
  connect(ui.animateTrayIcon, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
47
  connect(ui.displayPopupMessages, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
47
  connect(ui.bubbleBox, SIGNAL(toggled(bool)), this, SLOT(widgetHasChanged()));
48
  connect(ui.desktopBox, SIGNAL(toggled(bool)), this, SLOT(widgetHasChanged()));
49
  connect(ui.timeout_value, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
50
  connect(ui.x_value, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
51
  connect(ui.y_value, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
48 52

  
49 53
  connect(ui.userMessagesInStatusBuffer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
50 54
  connect(ui.userMessagesInQueryBuffer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
......
65 69
  ui.minimizeOnClose->setChecked(false);
66 70

  
67 71
  ui.animateTrayIcon->setChecked(true);
68
  ui.displayPopupMessages->setChecked(true);
72
  ui.bubbleBox->setChecked(true);
73
  ui.desktopBox->setChecked(true);
74
  ui.timeout_value->setValue(5000);
75
  ui.x_value->setValue(0);
76
  ui.y_value->setValue(0);
69 77

  
70 78
  ui.userMessagesInStatusBuffer->setChecked(true);
71 79
  ui.userMessagesInQueryBuffer->setChecked(false);
......
96 104
  settings["AnimateTrayIcon"] = uiSettings.value("AnimateTrayIcon", QVariant(true));
97 105
  ui.animateTrayIcon->setChecked(settings["AnimateTrayIcon"].toBool());
98 106

  
99
  settings["DisplayPopupMessages"] = uiSettings.value("DisplayPopupMessages", QVariant(true));
100
  ui.displayPopupMessages->setChecked(settings["DisplayPopupMessages"].toBool());
107
  settings["NotificationBubble"] = uiSettings.value("NotificationBubble", QVariant(true));
108
  ui.bubbleBox->setChecked(settings["NotificationBubble"].toBool());
109

  
110
  settings["NotificationDesktop"] = uiSettings.value("NotificationDesktop", QVariant(true));
111
  ui.desktopBox->setChecked(settings["NotificationDesktop"].toBool());
112
  settings["NotificationDesktopTimeout"] = uiSettings.value("NotificationDesktopTimeout", QVariant(5000));
113
  ui.timeout_value->setValue(settings["NotificationDesktopTimeout"].toInt());
114
  settings["NotificationDesktopHintX"] = uiSettings.value("NotificationDesktopHintX", QVariant(0));
115
  ui.x_value->setValue(settings["NotificationDesktopHintX"].toInt());
116
  settings["NotificationDesktopHintY"] = uiSettings.value("NotificationDesktopHintY", QVariant(0));
117
  ui.y_value->setValue(settings["NotificationDesktopHintY"].toInt());
101 118

  
102 119
  // bufferSettings:
103 120
  BufferSettings bufferSettings;
......
124 141
  uiSettings.setValue("MouseWheelChangesBuffers", ui.mouseWheelChangesBuffers->isChecked());
125 142

  
126 143
  uiSettings.setValue("AnimateTrayIcon", ui.animateTrayIcon->isChecked());
127
  uiSettings.setValue("DisplayPopupMessages", ui.displayPopupMessages->isChecked());
144
  uiSettings.setValue("NotificationBubble", ui.bubbleBox->isChecked());
145
  uiSettings.setValue("NotificationDesktop", ui.desktopBox->isChecked());
146
  uiSettings.setValue("NotificationDesktopTimeout", ui.timeout_value->value());
147
  uiSettings.setValue("NotificationDesktopHintX", ui.x_value->value());
148
  uiSettings.setValue("NotificationDesktopHintY", ui.y_value->value());
128 149

  
129 150
  BufferSettings bufferSettings;
130 151
  bufferSettings.setValue("UserMessagesInStatusBuffer", ui.userMessagesInStatusBuffer->isChecked());
......
148 169
  if(settings["MinimizeOnClose"].toBool() != ui.minimizeOnClose->isChecked()) return true;
149 170

  
150 171
  if(settings["AnimateTrayIcon"].toBool() != ui.animateTrayIcon->isChecked()) return true;
151
  if(settings["DisplayPopupMessages"].toBool() != ui.displayPopupMessages->isChecked()) return true;
172
  if(settings["NotificationBubble"].toBool() != ui.bubbleBox->isChecked()) return true;
173
  if(settings["NotificationDesktop"].toBool() != ui.desktopBox->isChecked()) return true;
174
  if(settings["NotificationDesktopTimeout"].toInt() != ui.timeout_value->value()) return true;
175
  if(settings["NotificationDesktopHintX"].toInt() != ui.x_value->value()) return true;
176
  if(settings["NotificationDesktopHintY"].toInt() != ui.y_value->value()) return true;
152 177

  
153 178
  if(settings["UserMessagesInStatusBuffer"].toBool() != ui.userMessagesInStatusBuffer->isChecked()) return true;
154 179
  if(settings["UserMessagesInQueryBuffer"].toBool() != ui.userMessagesInQueryBuffer->isChecked()) return true;
src/qtui/settingspages/generalsettingspage.ui
6 6
    <x>0</x>
7 7
    <y>0</y>
8 8
    <width>453</width>
9
    <height>632</height>
9
    <height>800</height>
10 10
   </rect>
11 11
  </property>
12 12
  <property name="windowTitle" >
......
64 64
      <string>User Notification:</string>
65 65
     </property>
66 66
     <layout class="QGridLayout" >
67
      <item row="0" column="0" >
68
       <widget class="QCheckBox" name="animateTrayIcon" >
69
        <property name="text" >
70
         <string>Animate tray icon</string>
67
      <item row="2" column="0" >
68
       <widget class="QGroupBox" name="bubbleBox" >
69
        <property name="title" >
70
         <string>Bubble</string>
71 71
        </property>
72
        <property name="checked" >
72
        <property name="checkable" >
73 73
         <bool>true</bool>
74 74
        </property>
75
        <layout class="QVBoxLayout" name="verticalLayout" />
76
       </widget>
77
      </item>
78
      <item row="2" column="1" >
79
       <widget class="QGroupBox" name="desktopBox" >
80
        <property name="title" >
81
         <string>Desktop</string>
82
        </property>
83
        <property name="checkable" >
84
         <bool>true</bool>
85
        </property>
86
        <layout class="QVBoxLayout" name="verticalLayout_2" >
87
         <item>
88
          <widget class="QFrame" name="desktopFrame" >
89
           <property name="frameShape" >
90
            <enum>QFrame::StyledPanel</enum>
91
           </property>
92
           <property name="frameShadow" >
93
            <enum>QFrame::Raised</enum>
94
           </property>
95
           <layout class="QFormLayout" name="formLayout" >
96
            <item row="0" column="0" >
97
             <widget class="QLabel" name="timeout_label" >
98
              <property name="text" >
99
               <string>Timeout</string>
100
              </property>
101
             </widget>
102
            </item>
103
            <item row="0" column="1" >
104
             <widget class="QSpinBox" name="timeout_value" >
105
              <property name="minimum" >
106
               <number>-1</number>
107
              </property>
108
              <property name="maximum" >
109
               <number>100000</number>
110
              </property>
111
              <property name="value" >
112
               <number>5000</number>
113
              </property>
114
             </widget>
115
            </item>
116
            <item row="1" column="0" >
117
             <widget class="QLabel" name="x_label" >
118
              <property name="text" >
119
               <string>X</string>
120
              </property>
121
             </widget>
122
            </item>
123
            <item row="2" column="0" >
124
             <widget class="QLabel" name="y_label" >
125
              <property name="text" >
126
               <string>Y</string>
127
              </property>
128
             </widget>
129
            </item>
130
            <item row="1" column="1" >
131
             <widget class="QSpinBox" name="x_value" >
132
              <property name="maximum" >
133
               <number>10000</number>
134
              </property>
135
             </widget>
136
            </item>
137
            <item row="2" column="1" >
138
             <widget class="QSpinBox" name="y_value" >
139
              <property name="maximum" >
140
               <number>10000</number>
141
              </property>
142
             </widget>
143
            </item>
144
           </layout>
145
          </widget>
146
         </item>
147
        </layout>
75 148
       </widget>
76 149
      </item>
77 150
      <item row="1" column="0" >
78
       <widget class="QCheckBox" name="displayPopupMessages" >
151
       <widget class="QCheckBox" name="animateTrayIcon" >
79 152
        <property name="text" >
80
         <string>Display pop-up messages</string>
153
         <string>Animate tray icon</string>
81 154
        </property>
82 155
        <property name="checked" >
83 156
         <bool>true</bool>
......
156 229
    </widget>
157 230
   </item>
158 231
   <item>
159
    <spacer>
232
    <spacer name="verticalSpacer" >
160 233
     <property name="orientation" >
161 234
      <enum>Qt::Vertical</enum>
162 235
     </property>
163
     <property name="sizeHint" >
236
     <property name="sizeHint" stdset="0" >
164 237
      <size>
165 238
       <width>20</width>
166 239
       <height>40</height>
167
-