Subversion Repositories tpanel

Rev

Rev 71 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 71 Rev 111
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2021 by Andreas Theofilu <andreas@theosys.at>
2
 * Copyright (C) 2021, 2022 by Andreas Theofilu <andreas@theosys.at>
3
 *
3
 *
4
 * This program is free software; you can redistribute it and/or modify
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
7
 * (at your option) any later version.
Line 22... Line 22...
22
#include "tqkeypad.h"
22
#include "tqkeypad.h"
23
#include "ui_keypad.h"
23
#include "ui_keypad.h"
24
#include "terror.h"
24
#include "terror.h"
25
#include "tresources.h"
25
#include "tresources.h"
26
#include "tconfig.h"
26
#include "tconfig.h"
-
 
27
#include "tpagemanager.h"
-
 
28
 
-
 
29
extern TPageManager *gPageManager;              //!< The pointer to the global defined main class.
27
 
30
 
28
TQKeypad::TQKeypad(const std::string& init, const std::string& prompt, QWidget *parent, bool priv)
31
TQKeypad::TQKeypad(const std::string& init, const std::string& prompt, QWidget *parent, bool priv)
29
    : QDialog(parent),
32
    : QDialog(parent),
30
      TSystemSound(TConfig::getSystemPath(TConfig::SOUNDS)),
33
      TSystemSound(TConfig::getSystemPath(TConfig::SOUNDS)),
31
      ui(new Ui::TQKeypad),
34
      ui(new Ui::TQKeypad),
Line 144... Line 147...
144
        case Ui::KEYP_Dot:      mText += "."; break;
147
        case Ui::KEYP_Dot:      mText += "."; break;
145
        case Ui::KEYP_DoubleDot:mText += ":"; break;
148
        case Ui::KEYP_DoubleDot:mText += ":"; break;
146
        case Ui::KEYP_Clear:    mText.clear(); break;
149
        case Ui::KEYP_Clear:    mText.clear(); break;
147
    }
150
    }
148
 
151
 
-
 
152
    if (mMaxLen > 0 && mText.length() > (size_t)mMaxLen)
-
 
153
        mText = mText.substr(0, mMaxLen);
-
 
154
 
149
    if (!mPrivate)
155
    if (!mPrivate)
150
        ui->label_TextLine->setText(mText.c_str());
156
        ui->label_TextLine->setText(mText.c_str());
151
    else
157
    else
152
        ui->label_TextLine->setText(fillString('*', mText.length()).c_str());
158
        ui->label_TextLine->setText(fillString('*', mText.length()).c_str());
153
 
159
 
Line 155... Line 161...
155
    {
161
    {
156
        std::string snd = getTouchFeedbackSound();
162
        std::string snd = getTouchFeedbackSound();
157
        MSG_DEBUG("Playing sound: " << snd);
163
        MSG_DEBUG("Playing sound: " << snd);
158
        QSound::play(snd.c_str());
164
        QSound::play(snd.c_str());
159
    }
165
    }
-
 
166
 
-
 
167
    if (gPageManager && gPageManager->getPassThrough() && !mText.empty() &&
-
 
168
        key != Ui::KEYP_Clear)
-
 
169
    {
-
 
170
        size_t pos = mText.length() - 1;
-
 
171
        gPageManager->sendKeyStroke(mText[pos]);
-
 
172
    }
-
 
173
}
-
 
174
 
-
 
175
void TQKeypad::setString(const std::string& str)
-
 
176
{
-
 
177
    DECL_TRACER("TQKeypad::setString(const string& str)");
-
 
178
 
-
 
179
    mText += str;
-
 
180
 
-
 
181
    if (mMaxLen > 0 && mText.length() > (size_t)mMaxLen)
-
 
182
        mText = mText.substr(0, mMaxLen);
-
 
183
 
-
 
184
    if (!mPrivate)
-
 
185
        ui->label_TextLine->setText(mText.c_str());
-
 
186
    else
-
 
187
        ui->label_TextLine->setText(fillString('*', mText.length()).c_str());
160
}
188
}
161
 
189
 
162
int TQKeypad::scale(int value)
190
int TQKeypad::scale(int value)
163
{
191
{
164
    if (value <= 0 || mScaleFactor == 1.0)
192
    if (value <= 0 || mScaleFactor == 1.0)