~ubuntu-branches/ubuntu/lucid/konversation/lucid-updates

« back to all changes in this revision

Viewing changes to src/viewer/statuspanel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-02-11 14:52:14 UTC
  • mto: This revision was merged to the branch mainline in revision 43.
  • Revision ID: james.westby@ubuntu.com-20100211145214-xsbd3hmrnu5fmb8f
Tags: upstream-1.2.2
ImportĀ upstreamĀ versionĀ 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
*/
12
12
 
13
13
#include "statuspanel.h"
 
14
#include "channel.h"
14
15
#include "application.h"
15
16
#include "ircinput.h"
16
17
#include "ircview.h"
34
35
    awayState=false;
35
36
 
36
37
    // set up text view, will automatically take care of logging
37
 
    IRCViewBox* ircBox = new IRCViewBox(this); // Server will be set later in setServer()
 
38
    IRCViewBox* ircBox = new IRCViewBox(this, 0); // Server will be set later in setServer()
38
39
    setTextView(ircBox->ircView());
39
40
 
40
41
    KHBox* commandLineBox=new KHBox(this);
46
47
    nicknameCombobox->setSizeAdjustPolicy(KComboBox::AdjustToContents);
47
48
    KLineEdit* nicknameComboboxLineEdit = qobject_cast<KLineEdit*>(nicknameCombobox->lineEdit());
48
49
    if (nicknameComboboxLineEdit) nicknameComboboxLineEdit->setClearButtonShown(false);
49
 
    nicknameCombobox->setWhatsThis(i18n("<qt><p>This shows your current nick, and any alternatives you have set up.  If you select or type in a different nickname, then a request will be sent to the IRC server to change your nick.  If the server allows it, the new nickname will be selected.  If you type in a new nickname, you need to press 'Enter' at the end.</p><p>You can edit the alternative nicknames from the <em>Identities</em> option in the <em>Settings</em> menu.</p></qt>"));
 
50
    nicknameCombobox->setWhatsThis(i18n("<qt><p>This shows your current nick, and any alternatives you have set up.  If you select or type in a different nickname, then a request will be sent to the IRC server to change your nick.  If the server allows it, the new nickname will be selected.  If you type in a new nickname, you need to press 'Enter' at the end.</p><p>You can add change the alternative nicknames from the <em>Identities</em> option in the <em>File</em> menu.</p></qt>"));
50
51
 
51
52
    awayLabel=new QLabel(i18n("(away)"), commandLineBox);
52
53
    awayLabel->hide();
63
64
    connect(statusInput,SIGNAL (submit()),this,SLOT(statusTextEntered()) );
64
65
    connect(statusInput,SIGNAL (textPasted(const QString&)),this,SLOT(textPasted(const QString&)) );
65
66
    connect(getTextView(), SIGNAL(textPasted(bool)), statusInput, SLOT(paste(bool)));
 
67
    connect(getTextView(), SIGNAL(popupCommand(int)), this, SLOT(popupCommand(int)));
66
68
 
67
69
    connect(nicknameCombobox,SIGNAL (activated(int)),this,SLOT(nicknameComboboxChanged()));
68
70
    Q_ASSERT(nicknameCombobox->lineEdit());       //it should be editedable.  if we design it so it isn't, remove these lines.
76
78
{
77
79
}
78
80
 
79
 
void StatusPanel::cycle()
 
81
void StatusPanel::serverSaysClose()
80
82
{
81
 
    if (m_server) m_server->cycle();
 
83
    closeYourself(false);
82
84
}
83
85
 
84
86
void StatusPanel::setNickname(const QString& newNickname)
108
110
        QString output(outList[index]);
109
111
 
110
112
        // encoding stuff is done in Server()
111
 
        Konversation::OutputFilterResult result = m_server->getOutputFilter()->parse(m_server->getNickname(), output, QString(), this);
 
113
        Konversation::OutputFilterResult result = m_server->getOutputFilter()->parse(m_server->getNickname(), output, QString());
112
114
 
113
115
        if(!result.output.isEmpty())
114
116
        {
121
123
 
122
124
void StatusPanel::statusTextEntered()
123
125
{
124
 
    QString line = sterilizeUnicode(statusInput->toPlainText());
125
 
 
 
126
    QString line=sterilizeUnicode(statusInput->toPlainText());
126
127
    statusInput->clear();
127
128
 
128
 
    if (!line.isEmpty()) sendStatusText(line);
 
129
    if(line.toLower()==Preferences::self()->commandChar()+"clear") textView->clear();
 
130
    else
 
131
    {
 
132
        if(line.length()) sendStatusText(line);
 
133
    }
129
134
}
130
135
 
131
136
void StatusPanel::textPasted(const QString& text)
146
151
 
147
152
void StatusPanel::updateAppearance()
148
153
{
149
 
    if (Preferences::self()->showNicknameBox())
150
 
    {
151
 
        if (Preferences::self()->customTextFont())
152
 
            nicknameCombobox->setFont(Preferences::self()->textFont());
153
 
        else
154
 
            nicknameCombobox->setFont(KGlobalSettings::generalFont());
155
 
 
156
 
        nicknameCombobox->show();
157
 
    }
158
 
    else
159
 
        nicknameCombobox->hide();
 
154
    QColor fg, bg;
 
155
 
 
156
    if (Preferences::self()->inputFieldsBackgroundColor())
 
157
    {
 
158
        fg = Preferences::self()->color(Preferences::ChannelMessage);
 
159
        bg = Preferences::self()->color(Preferences::TextViewBackground);
 
160
    }
 
161
    else
 
162
    {
 
163
        fg = palette().windowText().color();
 
164
        bg = palette().base().color();
 
165
    }
 
166
 
 
167
    QPalette statusInputPalette(statusInput->palette());
 
168
    statusInputPalette.setColor(QPalette::WindowText, fg);
 
169
    statusInputPalette.setColor(QPalette::Text, fg);
 
170
    statusInputPalette.setColor(QPalette::Base, bg);
 
171
    statusInput->setPalette(statusInputPalette);
 
172
 
 
173
 
 
174
    if (Preferences::self()->customTextFont())
 
175
    {
 
176
        statusInput->setFont(Preferences::self()->textFont());
 
177
        nicknameCombobox->setFont(Preferences::self()->textFont());
 
178
    }
 
179
    else
 
180
    {
 
181
        statusInput->setFont(KGlobalSettings::generalFont());
 
182
        nicknameCombobox->setFont(KGlobalSettings::generalFont());
 
183
    }
 
184
 
 
185
    showNicknameBox(Preferences::self()->showNicknameBox());
160
186
 
161
187
    ChatWindow::updateAppearance();
162
188
}
223
249
{
224
250
    int result;
225
251
 
 
252
    //FIXME: Show "Do you really want to close ..." warnings in
 
253
    // disconnected state instead of closing directly. Can't do
 
254
    // that due to string freeze at the moment.
226
255
    if (confirm && !m_server->isConnected())
227
256
    {
228
257
        result = KMessageBox::warningContinueCancel(
253
282
        m_server = 0;
254
283
        return true;
255
284
    }
256
 
    else
257
 
    {
258
 
        m_recreationScheduled = false;
259
 
 
260
 
        m_server->abortScheduledRecreation();
261
 
    }
262
 
 
263
285
    return false;
264
286
}
265
287
 
325
347
void StatusPanel::serverOnline(bool online)
326
348
{
327
349
    //statusInput->setEnabled(online);
 
350
    getTextView()->setNickAndChannelContextMenusEnabled(online);
328
351
    nicknameCombobox->setEnabled(online);
329
352
}
330
353
 
 
354
void StatusPanel::showNicknameBox(bool show)
 
355
{
 
356
    if(show)
 
357
    {
 
358
        nicknameCombobox->show();
 
359
    }
 
360
    else
 
361
    {
 
362
        nicknameCombobox->hide();
 
363
    }
 
364
}
 
365
 
331
366
void StatusPanel::setServer(Server* server)
332
367
{
333
368
    ChatWindow::setServer(server);
334
369
    nicknameCombobox->setModel(m_server->nickListModel());
335
370
}
336
371
 
 
372
void StatusPanel::popupCommand(int command)
 
373
{
 
374
    switch(command)
 
375
    {
 
376
        case Konversation::Join:
 
377
            m_server->queue("JOIN " + getTextView()->currentChannel());
 
378
            break;
 
379
        case Konversation::Topic:
 
380
            m_server->requestTopic(getTextView()->currentChannel());
 
381
            break;
 
382
        case Konversation::Names:
 
383
            m_server->queue("NAMES " + getTextView()->currentChannel(), Server::LowPriority);
 
384
            break;
 
385
    }
 
386
}
 
387
 
337
388
#include "statuspanel.moc"