summaryrefslogtreecommitdiffstats
path: root/abs/core/mythinstall/MythVantage-app/mythbeselect/installdialog.cpp
blob: 6d1920f0461c491891b1dc99065bc34e6ba5a0c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#include <qapplication.h>
#include <unistd.h>
#include <fstream>
#include <sys/wait.h>   // For WIFEXITED on Mac OS X

#include "mythcontext.h"
#include "mythdbcon.h"
#include "lcddevice.h"
#include "tv.h"
#include "programinfo.h"
#include "uitypes.h"
#include "remoteutil.h"
#include "installdialog.h"
#include "libmyth/dialogbox.h"
#include <qvaluevector.h>
#include <stdlib.h>
#define UPDATE_STATUS_INTERVAL   5000
#define UPDATE_SCREEN_INTERVAL   5000
QStringList belist;
BEvector beveclist (100);
QString BECommand;
int retval;
int runstuff(QStringList hostlist,BEvector Bea,QString bcmd ){
belist=hostlist;
beveclist = Bea;
BECommand=bcmd;

WelcomeDialog *mythWelcome = new WelcomeDialog(gContext->GetMainWindow(),
                                                    "welcome_screen", "bpopup-",
                                                "welcome_screen");
        mythWelcome->exec();
       delete mythWelcome;
       return (0);
}


WelcomeDialog::WelcomeDialog(MythMainWindow *parent,
                            QString window_name,
                            QString theme_filename,
                            const char* name)
:MythThemedDialog(parent, window_name, theme_filename, name)
{
    gContext->addListener(this);
    m_timeFormat = gContext->GetSetting("TimeFormat", "h:mm AP");
    wireUpTheme();
    assignFirstFocus();
    popup = NULL;
    showPopup();
}


int WelcomeDialog::exec()
{
    return MythDialog::exec();
}



void WelcomeDialog::keyPressEvent(QKeyEvent *e)
{
    bool handled = false;

    QStringList actions;
    gContext->GetMainWindow()->TranslateKeyPress("Welcome", e, actions);

    for (unsigned int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = true;
        if (action == "ESCAPE")
        {
            return; // eat escape key
        }
        else if (action == "MENU")
        {
            showPopup();
        }
        else if (action == "NEXTVIEW")
        {
           accept();
        }
        else if (action == "SELECT")
        {
            activateCurrent();
       }
        else
            handled = false;
    }

    if (!handled)
        MythThemedDialog::keyPressEvent(e);
}

UITextType* WelcomeDialog::getTextType(QString name)
{
    UITextType* type = getUITextType(name);

    if (!type)
    {
        cout << "ERROR: Failed to find '" << name <<  "' UI element in theme file\n"
            << "Bailing out!" << endl;
        exit(0);
    }
    return type;
}

void WelcomeDialog::wireUpTheme()
{
    m_status_text = getTextType("status_text");
    m_recording_text = getTextType("recording_text");
    m_scheduled_text = getTextType("scheduled_text");
    m_time_text = getTextType("time_text");
    m_date_text = getTextType("date_text");
    m_warning_text = getTextType("conflicts_text");
    m_warning_text->hide();
    buildFocusList();
}

void WelcomeDialog::closeDialog()
{
cout <<"close dialog" <<endl;
    done(1);
}

WelcomeDialog::~WelcomeDialog()
{
    gContext->removeListener(this);

    if (m_updateStatusTimer)
        delete m_updateStatusTimer;

    if (m_updateScreenTimer)
        delete m_updateScreenTimer;

    if (m_timeTimer)
        delete m_timeTimer;
}

void WelcomeDialog::updateTime(void)
{
    QString s="";
    m_date_text->SetText(s);
}

void WelcomeDialog::updateStatus(void)
{
    updateStatusMessage();
}

void WelcomeDialog::updateScreen(void)
{
    m_recording_text->SetText(recording_text);
    m_scheduled_text->SetText(scheduled_text);
    m_status_text->SetText("");
    m_updateScreenTimer->start(UPDATE_SCREEN_INTERVAL, true);

}

void WelcomeDialog::updateAll(void)
{
    updateRecordingList();
    updateScheduledList();
}

bool WelcomeDialog::updateRecordingList()
{
    return true;
}

bool WelcomeDialog::updateScheduledList()
{


    updateStatus();
    updateScreen();
    return true;
}

void WelcomeDialog::updateStatusMessage(void)
{

}

void WelcomeDialog::showPopup(void)
{
    if (popup)
        return;
            DialogCode retitem = MythPopupBox::ShowButtonPopup(gContext->GetMainWindow(),
                                    QString("JobQueuePopup"),
                                    QObject::tr("Select Backend to " + BECommand ),
                                            belist,kDialogCodeButton0);
            retval = retitem - kDialogCodeListStart;
           cout << beveclist[retval] << endl;
          cancelPopup();
          dorestart( BECommand , beveclist[retval] );
 }



void WelcomeDialog::cancelPopup(void)
{
      if (!popup)
       return;
      popup->hide();
     popup->deleteLater();
    popup = NULL;
    setActiveWindow();
}

void dorestart (QString command , QString behost)
{
cout  << command  << behost  << endl;
system("/usr/bin/backend_control.sh  " +  command + "  " + behost );
exit(0);
}