Messagelib

statusbarlabeltoggledstate.cpp
1/*
2 SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "statusbarlabeltoggledstate.h"
8#include "messagecomposer_debug.h"
9#include <QMouseEvent>
10using namespace MessageComposer;
11StatusBarLabelToggledState::StatusBarLabelToggledState(QWidget *parent)
12 : QLabel(parent)
13{
14 setTextFormat(Qt::PlainText);
15}
16
17StatusBarLabelToggledState::~StatusBarLabelToggledState() = default;
18
19void StatusBarLabelToggledState::setStateString(const QString &toggled, const QString &untoggled)
20{
21 if (toggled.isEmpty() && untoggled.isEmpty()) {
22 qCWarning(MESSAGECOMPOSER_LOG) << " State string is empty. Need to fix it";
23 }
24 mToggled = toggled;
25 mUnToggled = untoggled;
26 updateLabel();
27}
28
29void StatusBarLabelToggledState::setToggleMode(bool state)
30{
31 if (mToggleMode != state) {
32 mToggleMode = state;
33 Q_EMIT toggleModeChanged(mToggleMode);
34 updateLabel();
35 }
36}
37
38bool StatusBarLabelToggledState::toggleMode() const
39{
40 return mToggleMode;
41}
42
43void StatusBarLabelToggledState::updateLabel()
44{
45 if (mToggleMode) {
46 setText(mToggled);
47 } else {
48 setText(mUnToggled);
49 }
50}
51
52void StatusBarLabelToggledState::mousePressEvent(QMouseEvent *ev)
53{
55 if (ev->button() == Qt::LeftButton) {
56 setToggleMode(!mToggleMode);
57 }
58}
59
60#include "moc_statusbarlabeltoggledstate.cpp"
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
void setText(const QString &)
Q_EMITQ_EMIT
T qobject_cast(QObject *object)
bool isEmpty() const const
LeftButton
PlainText
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:49:06 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.