pisdr windows drives support
git-svn-id: svn://db.shs.com.ru/pip@57 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
122
utils/system_daemon/shared.cpp
Normal file
122
utils/system_daemon/shared.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
#include "shared.h"
|
||||
|
||||
extern PIScreen screen;
|
||||
|
||||
|
||||
class DlgWatcher: public PIThread {
|
||||
PIOBJECT(DlgWatcher)
|
||||
public:
|
||||
DlgWatcher() {close = ok = false;}
|
||||
EVENT_HANDLER2(void, tileEvent, PIScreenTile * , tile, PIScreenTypes::TileEvent, e) {
|
||||
if (e.type == TileButtons::ButtonSelected) {
|
||||
ok = e.data.toInt() == 0;
|
||||
close = true;
|
||||
}
|
||||
}
|
||||
EVENT_HANDLER1(void, keyPressed, PIKbdListener::KeyEvent, key) {
|
||||
if (key.key == PIKbdListener::Return) {
|
||||
ok = true;
|
||||
close = true;
|
||||
}
|
||||
if (key.key == PIKbdListener::Esc) {
|
||||
ok = false;
|
||||
close = true;
|
||||
}
|
||||
}
|
||||
bool ok;
|
||||
bool close;
|
||||
};
|
||||
|
||||
|
||||
PIString askNewDir() {
|
||||
PIScreenTile dlg;
|
||||
dlg.setMargins(1, 1, 1, 1);
|
||||
dlg.spacing = 1;
|
||||
dlg.back_format.color_back = Yellow;
|
||||
TileSimple * lbl = new TileSimple();
|
||||
TileInput * input = new TileInput();
|
||||
TileButtons * btns = new TileButtons();
|
||||
lbl->back_format.color_back = Yellow;
|
||||
btns->back_format.color_back = Yellow;
|
||||
lbl->content << TileSimple::Row("Enter new directory name:", CellFormat(Black, Transparent));
|
||||
btns->content << TileButtons::Button(" Ok ", CellFormat());
|
||||
btns->content << TileButtons::Button("Cancel", CellFormat());
|
||||
dlg.addTile(lbl);
|
||||
dlg.addTile(input);
|
||||
dlg.addTile(btns);
|
||||
DlgWatcher w;
|
||||
CONNECTU(&screen, keyPressed, &w, keyPressed)
|
||||
CONNECTU(&screen, tileEvent, &w, tileEvent)
|
||||
screen.setDialogTile(&dlg);
|
||||
while (!w.close) {
|
||||
PIKbdListener::instance()->readKeyboard();
|
||||
piMSleep(10);
|
||||
}
|
||||
if (!w.ok) return PIString();
|
||||
return input->text;
|
||||
}
|
||||
|
||||
|
||||
bool askQuestion(const PIString & t) {
|
||||
PIScreenTile dlg;
|
||||
dlg.setMargins(1, 1, 1, 1);
|
||||
dlg.spacing = 1;
|
||||
dlg.back_format.color_back = Yellow;
|
||||
TileSimple * lbl = new TileSimple();
|
||||
TileButtons * btns = new TileButtons();
|
||||
lbl->back_format.color_back = Yellow;
|
||||
btns->back_format.color_back = Yellow;
|
||||
lbl->content << TileSimple::Row(t, CellFormat(Black, Transparent));
|
||||
btns->content << TileButtons::Button(" Ok ", CellFormat());
|
||||
btns->content << TileButtons::Button("Cancel", CellFormat());
|
||||
dlg.addTile(lbl);
|
||||
dlg.addTile(btns);
|
||||
DlgWatcher w;
|
||||
CONNECTU(&screen, keyPressed, &w, keyPressed)
|
||||
CONNECTU(&screen, tileEvent, &w, tileEvent)
|
||||
screen.setDialogTile(&dlg);
|
||||
while (!w.close) {
|
||||
PIKbdListener::instance()->readKeyboard();
|
||||
piMSleep(10);
|
||||
}
|
||||
return w.ok;
|
||||
}
|
||||
|
||||
|
||||
void showInfo(const PIString & t) {
|
||||
PIScreenTile dlg;
|
||||
dlg.setMargins(1, 1, 1, 1);
|
||||
dlg.spacing = 1;
|
||||
dlg.back_format.color_back = Yellow;
|
||||
TileSimple * lbl = new TileSimple();
|
||||
TileButtons * btns = new TileButtons();
|
||||
lbl->back_format.color_back = Yellow;
|
||||
btns->back_format.color_back = Yellow;
|
||||
lbl->content << TileSimple::Row(t, CellFormat(Black, Transparent));
|
||||
btns->content << TileButtons::Button(" Ok ", CellFormat());
|
||||
dlg.addTile(lbl);
|
||||
dlg.addTile(btns);
|
||||
DlgWatcher w;
|
||||
CONNECTU(&screen, keyPressed, &w, keyPressed)
|
||||
CONNECTU(&screen, tileEvent, &w, tileEvent)
|
||||
screen.setDialogTile(&dlg);
|
||||
while (!w.close) {
|
||||
PIKbdListener::instance()->readKeyboard();
|
||||
piMSleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void removeFiles(const PIDir & dir, PIStringList l) {
|
||||
l.removeOne("..");
|
||||
PIString ap = dir.absolutePath();
|
||||
piForeachC (PIString & s, l) {
|
||||
PIFile::FileInfo fi = PIFile::fileInfo(ap + PIDir::separator + s);
|
||||
if (fi.isDir()) {
|
||||
PIVector<PIFile::FileInfo> el = PIDir::allEntries(fi.path);
|
||||
piForeachCR (PIFile::FileInfo & e, el)
|
||||
PIFile::remove(e.path);
|
||||
}
|
||||
PIFile::remove(fi.path);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user