mirror of
https://gitflic.ru/project/astankevich/mtpview.git
synced 2024-11-23 06:58:25 +01:00
Show Alert dialog on MTP errors. Fix indentation.
This commit is contained in:
parent
247a1b1b87
commit
ec4df22b57
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
(Objects.mtpview)
|
||||
objects.*
|
||||
mtpview
|
||||
mtpview.hpkg
|
||||
pkg/apps/mtpview
|
||||
|
5
App.cpp
5
App.cpp
@ -243,18 +243,22 @@ int init_mtp (/*int argc, char **argv*/)
|
||||
switch(err) {
|
||||
case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
|
||||
fprintf(stdout, " No raw devices found.\n");
|
||||
mainwin->showErrorAlert("No raw devices found. Be sure device connected and configured transfer mode.");
|
||||
return 0;
|
||||
case LIBMTP_ERROR_CONNECTING:
|
||||
fprintf(stderr, "Detect: There has been an error connecting. Exiting\n");
|
||||
mainwin->showErrorAlert("There has been an error connecting.");
|
||||
return 1;
|
||||
case LIBMTP_ERROR_MEMORY_ALLOCATION:
|
||||
fprintf(stderr, "Detect: Encountered a Memory Allocation Error. Exiting\n");
|
||||
mainwin->showErrorAlert("Encountered a Memory Allocation Error.");
|
||||
return 1;
|
||||
case LIBMTP_ERROR_NONE:
|
||||
break;
|
||||
case LIBMTP_ERROR_GENERAL:
|
||||
default:
|
||||
fprintf(stderr, "Unknown connection error.\n");
|
||||
mainwin->showErrorAlert("Unknown connection error.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -269,6 +273,7 @@ int init_mtp (/*int argc, char **argv*/)
|
||||
device = LIBMTP_Open_Raw_Device_Uncached(&rawdevices[i]);
|
||||
if (device == NULL) {
|
||||
fprintf(stderr, "Unable to open raw device %d\n", i);
|
||||
mainwin->showErrorAlert("Unable to open raw device.");
|
||||
continue;
|
||||
}
|
||||
detected_device = device;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <ListItem.h>
|
||||
#include <ScrollView.h>
|
||||
#include <Path.h>
|
||||
#include <Alert.h>
|
||||
|
||||
//extern LIBMTP_mtpdevice_t * detected_device;
|
||||
//extern App *app;
|
||||
@ -242,3 +243,12 @@ MainWindow::MessageReceived(BMessage *msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::showErrorAlert(const char * message) {
|
||||
BAlert* alert = new BAlert("MTP Error", message,
|
||||
"Ok", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
|
||||
B_WARNING_ALERT);
|
||||
alert->SetShortcut(0, B_ESCAPE);
|
||||
int32 button_index = alert->Go();
|
||||
//Quit(); //Leads to crash
|
||||
}
|
||||
|
32
MainWindow.h
32
MainWindow.h
@ -10,10 +10,10 @@
|
||||
class FileItem: public BStringItem
|
||||
{
|
||||
public:
|
||||
FileItem(LIBMTP_mtpdevice_t * device, int id, BString filename, bool isFile, int depth);
|
||||
inline int fileId(){return fId;}
|
||||
inline bool isFile(){return fIsFile;}
|
||||
inline LIBMTP_mtpdevice_t * device(){return this->fDevice;}
|
||||
FileItem(LIBMTP_mtpdevice_t * device, int id, BString filename, bool isFile, int depth);
|
||||
inline int fileId(){return fId;}
|
||||
inline bool isFile(){return fIsFile;}
|
||||
inline LIBMTP_mtpdevice_t * device(){return this->fDevice;}
|
||||
private:
|
||||
int fId;
|
||||
bool fIsFile;
|
||||
@ -23,19 +23,19 @@ private:
|
||||
class MainWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
MainWindow(void);
|
||||
void MessageReceived(BMessage *msg);
|
||||
inline BOutlineListView * listView(){return this->fListView;};
|
||||
|
||||
MainWindow(void);
|
||||
void MessageReceived(BMessage *msg);
|
||||
inline BOutlineListView * listView(){return this->fListView;};
|
||||
void showErrorAlert(const char * message);
|
||||
private:
|
||||
BOutlineListView *fListView;
|
||||
BButton *download;
|
||||
BButton *upload;
|
||||
BFilePanel* openPanel;
|
||||
BFilePanel* savePanel;
|
||||
BMessenger * messenger;
|
||||
|
||||
FileItem * selectedItem;
|
||||
BOutlineListView *fListView;
|
||||
BButton *download;
|
||||
BButton *upload;
|
||||
BFilePanel* openPanel;
|
||||
BFilePanel* savePanel;
|
||||
BMessenger * messenger;
|
||||
|
||||
FileItem * selectedItem;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user