From 5026e9bb416657918b102ec10f495ddfc7f445ce Mon Sep 17 00:00:00 2001 From: kibergus Date: Mon, 13 Dec 2010 21:11:17 +0000 Subject: [PATCH] =?utf8?q?Patch=20from=20Pali=20Roh=C3=A1r=20for=20simplifie?= =?utf8?q?d=20interface=20when=20handling=20simple=20reply.=20Code=20refacto?= =?utf8?q?ring.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: file:///svnroot/ussd-widget/trunk@45 d197f4d6-dc93-42ad-8354-0da1f58e353f --- ussd4all/debian/changelog | 12 ++- ussd4all/src/qussd.cpp | 245 +++++++++++++-------------------------------- ussd4all/src/ussdd | 2 +- 3 files changed, 77 insertions(+), 182 deletions(-) diff --git a/ussd4all/debian/changelog b/ussd4all/debian/changelog index 88c6fa2..8d3efa4 100644 --- a/ussd4all/debian/changelog +++ b/ussd4all/debian/changelog @@ -1,6 +1,12 @@ -ussd4all (0.0.4-1) unstable; urgency=low +ussd4all (0.0.6-1) unstable; urgency=low - * Word wrap in qussd. Text can be copyed. Better pnatd initialization in - ussdquery.py. + * Patch from Pali Rohár for simplified interface when handling simple reply. + Code refactoring. + -- Alexey Guseynov Tue, 03 July 2010 16:21:05 +0003 + +ussd4all (0.0.5-1) unstable; urgency=low + + * Fixed black font in qussd when launched by ussdd. ussdd doesn't launch + qussd if message is empty. -- Alexey Guseynov Tue, 03 July 2010 16:21:05 +0003 diff --git a/ussd4all/src/qussd.cpp b/ussd4all/src/qussd.cpp index 2da8ebe..d2b37c0 100644 --- a/ussd4all/src/qussd.cpp +++ b/ussd4all/src/qussd.cpp @@ -1,6 +1,8 @@ #include +#include #include #include +#include #define PROCESSING "Processing..." @@ -9,26 +11,7 @@ class QUssd : public QMainWindow { public: QUssd(QString message, bool lock = false) { - number = ""; - - QActionGroup *filterGroup = new QActionGroup(this); - filterGroup->setExclusive(true); - - actPortrait = new QAction(tr("Portrait"), filterGroup); - actPortrait->setCheckable(true); - - actLandscape = new QAction(tr("Landscape"), filterGroup); - actLandscape->setCheckable(true); - - actAuto = new QAction(tr("Auto"), filterGroup); - actAuto->setCheckable(true); - actAuto->setChecked(true); - - menuBar()->addActions(filterGroup->actions()); - - connect(actPortrait, SIGNAL(changed()), this, SLOT(setOrientation())); - connect(actLandscape, SIGNAL(changed()), this, SLOT(setOrientation())); - connect(actAuto, SIGNAL(changed()), this, SLOT(setOrientation())); + initOrientation(); replyLabel = new QTextEdit(message); replyLabel->setMinimumWidth(400); @@ -39,11 +22,9 @@ class QUssd : public QMainWindow { pal.setColor(QPalette::Base, Qt::transparent); pal.setColor(QPalette::Text, pal.color(QPalette::ButtonText)); replyLabel->setPalette(pal); -// replyLabel->setTextBackgroundColor(Qt::black); -// replyLabel->setTextColor(Qt::white); replyLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); - numberLabel = new QLabel(""); + numberLabel = new QLabel(); numberLabel->setMinimumWidth(400); numberLabel->setMaximumHeight(100); numberLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); @@ -71,78 +52,28 @@ class QUssd : public QMainWindow { numberPad = new QGridLayout(); numberPad->setSpacing(2); - padBtn1 = new QPushButton("1"); - connect(padBtn1, SIGNAL(clicked()), this, SLOT(add1())); - padBtn1->setMaximumWidth(150); - padBtn1->setMaximumHeight(72); - padBtn1->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtn1, 0, 0); - padBtn2 = new QPushButton("2"); - connect(padBtn2, SIGNAL(clicked()), this, SLOT(add2())); - padBtn2->setMaximumWidth(150); - padBtn2->setMaximumHeight(72); - padBtn2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtn2, 0, 1); - padBtn3 = new QPushButton("3"); - connect(padBtn3, SIGNAL(clicked()), this, SLOT(add3())); - padBtn3->setMaximumWidth(150); - padBtn3->setMaximumHeight(72); - padBtn3->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtn3, 0, 2); - padBtn4 = new QPushButton("4"); - connect(padBtn4, SIGNAL(clicked()), this, SLOT(add4())); - padBtn4->setMaximumWidth(150); - padBtn4->setMaximumHeight(72); - padBtn4->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtn4, 1, 0); - padBtn5 = new QPushButton("5"); - connect(padBtn5, SIGNAL(clicked()), this, SLOT(add5())); - padBtn5->setMaximumWidth(150); - padBtn5->setMaximumHeight(72); - padBtn5->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtn5, 1, 1); - padBtn6 = new QPushButton("6"); - connect(padBtn6, SIGNAL(clicked()), this, SLOT(add6())); - padBtn6->setMaximumWidth(150); - padBtn6->setMaximumHeight(72); - padBtn6->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtn6, 1, 2); - padBtn7 = new QPushButton("7"); - connect(padBtn7, SIGNAL(clicked()), this, SLOT(add7())); - padBtn7->setMaximumWidth(150); - padBtn7->setMaximumHeight(72); - padBtn7->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtn7, 2, 0); - padBtn8 = new QPushButton("8"); - connect(padBtn8, SIGNAL(clicked()), this, SLOT(add8())); - padBtn8->setMaximumWidth(150); - padBtn8->setMaximumHeight(72); - padBtn8->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtn8, 2, 1); - padBtn9 = new QPushButton("9"); - connect(padBtn9, SIGNAL(clicked()), this, SLOT(add9())); - padBtn9->setMaximumWidth(150); - padBtn9->setMaximumHeight(72); - padBtn9->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtn9, 2, 2); + QSignalMapper *signalMapper = new QSignalMapper(this); + + numberPad->addWidget(createButton("1", signalMapper), 0, 0); + numberPad->addWidget(createButton("2", signalMapper), 0, 1); + numberPad->addWidget(createButton("3", signalMapper), 0, 2); + numberPad->addWidget(createButton("4", signalMapper), 1, 0); + numberPad->addWidget(createButton("5", signalMapper), 1, 1); + numberPad->addWidget(createButton("6", signalMapper), 1, 2); + numberPad->addWidget(createButton("7", signalMapper), 2, 0); + numberPad->addWidget(createButton("8", signalMapper), 2, 1); + numberPad->addWidget(createButton("9", signalMapper), 2, 2); + numberPad->addWidget(createButton("0", signalMapper), 3, 1); + numberPad->addWidget(createButton("#", signalMapper), 3, 2); + + connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(appendToNumber(QString))); + padBtnStar = new QPushButton("*+"); connect(padBtnStar, SIGNAL(clicked()), this, SLOT(addStar())); padBtnStar->setMaximumWidth(150); padBtnStar->setMaximumHeight(72); padBtnStar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); numberPad->addWidget(padBtnStar, 3, 0); - padBtn0 = new QPushButton("0"); - connect(padBtn0, SIGNAL(clicked()), this, SLOT(add0())); - padBtn0->setMaximumWidth(150); - padBtn0->setMaximumHeight(72); - padBtn0->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtn0, 3, 1); - padBtnGrid = new QPushButton("#"); - connect(padBtnGrid, SIGNAL(clicked()), this, SLOT(addGrid())); - padBtnGrid->setMaximumWidth(150); - padBtnGrid->setMaximumHeight(72); - padBtnGrid->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - numberPad->addWidget(padBtnGrid, 3, 2); centralWidget = new QWidget; setCentralWidget(centralWidget); @@ -163,7 +94,38 @@ class QUssd : public QMainWindow { delete USSDquery; } - public slots: + private slots: + QPushButton* createButton(QString caption, QSignalMapper *signalMapper) { + QPushButton *button = new QPushButton(caption); + signalMapper->setMapping(button, "caption"); + connect(button, SIGNAL(clicked()), signalMapper, SLOT (map())); + button->setMaximumWidth(150); + button->setMaximumHeight(72); + button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + return button; + } + + void initOrientation() { + QActionGroup *filterGroup = new QActionGroup(this); + filterGroup->setExclusive(true); + + actPortrait = new QAction(tr("Portrait"), filterGroup); + actPortrait->setCheckable(true); + + actLandscape = new QAction(tr("Landscape"), filterGroup); + actLandscape->setCheckable(true); + + actAuto = new QAction(tr("Auto"), filterGroup); + actAuto->setCheckable(true); + actAuto->setChecked(true); + + menuBar()->addActions(filterGroup->actions()); + + connect(actPortrait, SIGNAL(changed()), this, SLOT(setOrientation())); + connect(actLandscape, SIGNAL(changed()), this, SLOT(setOrientation())); + connect(actAuto, SIGNAL(changed()), this, SLOT(setOrientation())); + } + void restartUSSD( int, QProcess::ExitStatus) { replyLabel->setText(QString("Error: ")+QString::fromUtf8(reply)); reply = ""; @@ -224,79 +186,9 @@ class QUssd : public QMainWindow { } } - void add1 () { - if (number != tr(PROCESSING)) { - number += "1"; - setNumber(); - } - } - - void add2 () { + void appendToNumber (QString str) { if (number != tr(PROCESSING)) { - number += "2"; - setNumber(); - } - } - - void add3 () { - if (number != tr(PROCESSING)) { - number += "3"; - setNumber(); - } - } - - void add4 () { - if (number != tr(PROCESSING)) { - number += "4"; - setNumber(); - } - } - - void add5 () { - if (number != tr(PROCESSING)) { - number += "5"; - setNumber(); - } - } - - void add6 () { - if (number != tr(PROCESSING)) { - number += "6"; - setNumber(); - } - } - - void add7 () { - if (number != tr(PROCESSING)) { - number += "7"; - setNumber(); - } - } - - void add8 () { - if (number != tr(PROCESSING)) { - number += "8"; - setNumber(); - } - } - - void add9 () { - if (number != tr(PROCESSING)) { - number += "9"; - setNumber(); - } - } - - void add0 () { - if (number != tr(PROCESSING)) { - number += "0"; - setNumber(); - } - } - - void addGrid () { - if (number != tr(PROCESSING)) { - number += "#"; + number += str; setNumber(); } } @@ -343,30 +235,20 @@ class QUssd : public QMainWindow { numberLabel->setText(QString("

")+number+"

"); } - QTextEdit *replyLabel; - QLabel *numberLabel; QAction *actPortrait; QAction *actLandscape; QAction *actAuto; + QTextEdit *replyLabel; + QLabel *numberLabel; + QVBoxLayout *indicationLayout; QHBoxLayout *btnLayout; QGridLayout *numberPad; QGridLayout *mainLayout; QWidget* centralWidget; - QPushButton *padBtn1; - QPushButton *padBtn2; - QPushButton *padBtn3; - QPushButton *padBtn4; - QPushButton *padBtn5; - QPushButton *padBtn6; - QPushButton *padBtn7; - QPushButton *padBtn8; - QPushButton *padBtn9; - QPushButton *padBtn0; QPushButton *padBtnStar; - QPushButton *padBtnGrid; QPushButton *padDel; QPushButton *padSend; @@ -389,10 +271,17 @@ int main(int argc, char *argv[]) { if (argc >=3 && !strcmp(argv[2], "lock")) lock = true; - QUssd w(message, lock); - w.show(); + // If no reply is expected just show notification box + if (!lock && !message.isEmpty()) { + QMessageBox box(QMessageBox::NoIcon, QString::fromUtf8(dgettext("rtcom-call-ui", "call_ti_message")), message, QMessageBox::Ok); + box.button(QMessageBox::Ok)->setText(QString::fromUtf8(dgettext("hildon-libs", "wdgt_bd_done"))); + return box.exec(); + } else { + QUssd w(message, lock); + w.show(); - return app.exec(); + return app.exec(); + } } #include "qussd.moc" diff --git a/ussd4all/src/ussdd b/ussd4all/src/ussdd index aea4720..58d4e86 100755 --- a/ussd4all/src/ussdd +++ b/ussd4all/src/ussdd @@ -12,7 +12,7 @@ skip = False; def ussd_released (message, str): global skip - if not skip and not message.empty(): + if not skip and len(message) != 0: subprocess.Popen(["qussd", message]) skip = False return True -- 1.7.9.5