1 /*
2     SPDX-License-Identifier: GPL-2.0-or-later
3 
4     SPDX-FileCopyrightText: 2004, 2009 Peter Simonsson <peter.simonsson@gmail.com>
5     SPDX-FileCopyrightText: 2006-2008 Eike Hein <hein@kde.org>
6 */
7 
8 #include "awaylabel.h"
9 
10 #include <QAction>
11 
12 #include <QInputDialog>
13 #include <KLocalizedString>
14 
AwayLabel(QWidget * parent)15 AwayLabel::AwayLabel(QWidget *parent)
16     : QLabel(i18n("(away)"), parent)
17 {
18     this->setContextMenuPolicy(Qt::ActionsContextMenu);
19     auto *action = new QAction(i18n("&Unaway"),this);
20     connect(action, &QAction::triggered, this, &AwayLabel::unaway);
21     this->addAction(action);
22     action = new QAction(i18n("&Change away message..."),this);
23     connect(action, &QAction::triggered, this, &AwayLabel::changeAwayMessage);
24     this->addAction(action);
25 }
26 
~AwayLabel()27 AwayLabel::~AwayLabel()
28 {
29 }
30 
changeAwayMessage()31 void AwayLabel::changeAwayMessage()
32 {
33     QString awayMessage = QInputDialog::getText(this, i18n("Change away message"),i18n("Enter new away message:"));
34     if (!awayMessage.isEmpty())
35         Q_EMIT awayMessageChanged(awayMessage);
36 }
37 
38 
39