OpenRecent::OpenRecent(QWidget *parent) : QDialog(parent), ui(new Ui::OpenRecent), itemModel(0), exitEarly(false) { ui->setupUi(this); connect(ui->browseBtn, SIGNAL(clicked()), this, SLOT(browseForFile())); connect(this, SIGNAL(accepted()), this, SLOT(processAccepted())); connect(this, SIGNAL(rejected()), this, SLOT(processRejected())); connect(ui->fileLineEdit, SIGNAL(textChanged(QString)), this, SLOT(processFileNameChanged(QString))); recentFiles = RecentFile::recentFilesList(); // Use the last used directory for opening an image file or the user's // home as base path. recentPath = QSettings().value("recentPath", QDir::homePath()).toString(); // Don't show recent files list if there aren't any. if (recentFiles.size() == 0) { ui->recentFilesListView->hide(); ui->recentFilesListViewLabel->hide(); this->resize(sizeHint().width(), minimumHeight()); // trigger update ui->fileLineEdit->setText(QString()); } else { initRecentFilesUi(); } }
void OpenRecent::browseForFileOnce() { if (exitEarly) { return; } if (0 == recentFiles.size()) { exitEarly = true; setResult(Rejected); browseForFile(); if (! getSelectedFile().isEmpty()) { setResult(Accepted); } } }
void CtrlrMIDIBuffer::loadTextFile(const File fileToOpen) { if (fileToOpen == File::nonexistent) { lastFile = browseForFile("*.syx;*.bin;*.dat;*.*"); } else { lastFile = fileToOpen; } MemoryBlock data; data.loadFromHexString (lastFile.loadFileAsString()); reloadEditor (lastFile.loadFileAsString(), true); }
void CtrlrMIDIBuffer::loadBinFile(const File fileToOpen) { _DBG("CtrlrMIDIBuffer::loadBinFile"); if (fileToOpen == File::nonexistent) { lastFile = browseForFile("*.syx;*.bin;*.dat;*.*"); } else { lastFile = fileToOpen; } lastFile.loadFileAsData (data); reloadEditor (String::toHexString (data.getData(), data.getSize()), true); }
void midicctrack::patternfileloader() { ccpatternbuffer patternloadstruct; char filePath[MAXPATHLEN * 2]; int pathLen; std::string filename; FILE * pFile; filename = browseForFile (".cpt"); if (filename != "NULL") { // Construct a command line if we weren't supplied with one getcwd (filePath, MAXPATHLEN); pathLen = strlen (filePath); strcpy (filePath + pathLen, filename.c_str()); pFile = fopen ( filePath , "r" ); fread((char *)&patternloadstruct, sizeof(ccpatternbuffer), 1, pFile); patternnumber = patternloadstruct.patternnumber; int x, y; for ( x = 0; x < 8; x++ ) { for( y = 0; y < 256; y++ ) { patterns[x][y] = patternloadstruct.patterns[x][y]; } patternlengths[x] = patternloadstruct.patternlengths[x]; } fclose (pFile); } clearbottomscreen(); }
//--------------------------------------------------------------------------------- int main(void) { //--------------------------------------------------------------------------------- struct stat st; // Enable VBlank for Vblank Interrupt Wait irqInit(); irqEnable(IRQ_VBLANK); videoSetMode(0); //not using the main screen // Subscreen as a console videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankH(VRAM_H_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(15); BG_PALETTE_SUB[0]=0; BG_PALETTE_SUB[255]=0xffff; consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(15), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); iprintf ("Init'ing FAT..."); if (fatInitDefault()) { iprintf ("okay\n"); } else { iprintf ("fail!\n"); stop(); } if (stat (DEFAULT_FILE, &st) >= 0) { iprintf ("Running %s\n", DEFAULT_FILE); runNdsFile (DEFAULT_FILE); } else { std::string filename = browseForFile (".nds"); iprintf ("Running %s\n", filename.c_str()); runNdsFile (filename.c_str()); } iprintf ("Start failed\n"); stop(); return 0; }
void midicctrack::settingsfileloader() { ccsettingsbuffer settingsloadstruct; char filePath[MAXPATHLEN * 2]; int pathLen; std::string filename; FILE * pFile; filename = browseForFile (".cst"); if (filename != "NULL") { // Construct a command line if we weren't supplied with one getcwd (filePath, MAXPATHLEN); pathLen = strlen (filePath); strcpy (filePath + pathLen, filename.c_str()); pFile = fopen ( filePath , "r" ); fread((char *)&settingsloadstruct, sizeof(ccsettingsbuffer), 1, pFile); settingsnumber = settingsloadstruct.settingsnumber; midichannel = settingsloadstruct.midichannel; for (int i = 0; i < 8; i ++) { midiccnumbers[i] = settingsloadstruct.midiccnumbers[i]; } fclose (pFile); } clearbottomscreen(); }
int TCST::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: button1Clicked(); break; case 1: registerButtonClicked(); break; case 2: browseForLocation(); break; case 3: browseForFile(); break; case 4: connectToServer(); break; case 5: sendRequest(); break; case 6: sendFile(); break; case 7: updateLabels(); break; case 8: confirmFile(); break; case 9: displayError((*reinterpret_cast< QAbstractSocket::SocketError(*)>(_a[1]))); break; case 10: connectionClosedByServer(); break; case 11: sessionOpened(); break; case 12: reloadMenu(); break; case 13: registerWithServer(); break; case 14: printStatus(); break; case 15: reconnect(); break; default: ; } _id -= 16; } return _id; }
AccountPage::AccountPage( BackupWizard * parent ) : QWizardPage( parent ), file( new QLineEdit( this ) ), login( new QLineEdit( this ) ), password( new QLineEdit( this ) ), host( new QLineEdit( "", this ) ), tarsnap( nullptr ), makeKey( new QPushButton( tr( "&Make new key" ), this ) ), processStatus( new QLabel( "", this ) ), cacheDirectory( new QLineEdit( parent->initialCacheDirectory(), this ) ), complete(false) { setTitle( "Host Key" ); setSubTitle( "Make or select host key" ); connect( file, SIGNAL(textChanged(const QString &)), this, SLOT(checkPathNames()) ); connect( cacheDirectory, SIGNAL(textChanged(const QString &)), this, SLOT(checkPathNames()) ); if ( cacheDirectory->text().isEmpty() ) { struct passwd * pw = getpwuid(geteuid()); if ( pw && pw->pw_uid ) cacheDirectory->setText( QString::fromUtf8( pw->pw_dir ) + "/.cache/tarsnap" ); else cacheDirectory->setText( "/var/lib/tarsnap/cache" ); } login->setPlaceholderText( tr( "Email address" ) ); password->setPlaceholderText( tr( "tarsnap.com password" ) ); password->setEchoMode( QLineEdit::Password ); char buf[1024]; ::gethostname( buf, 1023 ); buf[1023] = 0; host->setText( QString::fromAscii( buf ) ); file->setText( parent->initialKeyFile() ); if ( file->text().isEmpty() ) { // have to have some default... struct passwd * pw = getpwuid(geteuid()); if ( pw ) file->setText( QString::fromUtf8( pw->pw_dir ) + "/" + host->text() + ".tarsnapkey" ); else file->setText( "/tmp/" + host->text() + ".tarsnapkey" ); } registerField( "keyFile", file ); registerField( "host", host ); registerField( "cacheDirectory", cacheDirectory ); connect( makeKey, SIGNAL(clicked()), this, SLOT(act()) ); enableMakeKey(); connect( login, SIGNAL(textChanged(const QString &)), this, SLOT(enableMakeKey()) ); connect( password, SIGNAL(textChanged(const QString &)), this, SLOT(enableMakeKey()) ); QGridLayout * l = new QGridLayout( this ); l->addWidget( new QLabel( tr( "Key file" ), this ), 0, 0, 1, 1, Qt::AlignLeft ); l->addWidget( file, 0, 1, 1, 1 ); QPushButton * b = new QPushButton( tr( "..." ), this ); connect( b, SIGNAL(clicked()), this, SLOT(browseForFile()) ); l->addWidget( b, 0, 2, 1, 1 ); QLabel * howto = new QLabel( tr( "<html>" "If you don't have a host key yet, you have to register at " "<a href=https://tarsnap.com/register.cgi>tarsnap.com</a> and " "choose a password. In that case, please follow " "the link and register, and add enough funds to pay for the first " "backup.<p>" "The email address and password " "are needed to create the host key, and the host name so you can " "back up several hosts using one tarsnap account.<p>" "The key is stored only in the file you specify. " "The email address is stored on tarsnap.com. " "The password is not stored anywere.</html>" ), this ); howto->setWordWrap( true ); howto->setOpenExternalLinks( true ); l->addWidget( howto, 1, 1, 1, 1 ); l->addWidget( new QLabel( tr( "Email" ), this ), 2, 0, 1, 1, Qt::AlignLeft ); l->addWidget( login, 2, 1, 1, 1 ); l->addWidget( new QLabel( tr( "Password" ), this ), 3, 0, 1, 1, Qt::AlignLeft ); l->addWidget( password, 3, 1, 1, 1 ); l->addWidget( new QLabel( tr( "Backup host" ), this ), 4, 0, 1, 1, Qt::AlignLeft ); l->addWidget( host, 4, 1, 1, 1 ); QHBoxLayout * processLayout = new QHBoxLayout(); l->addLayout( processLayout, 5, 1, 1, 1, Qt::AlignLeft ); processLayout->addWidget( makeKey ); processLayout->addWidget( processStatus, 2 ); l->addWidget( new QLabel( tr( "<html>Tarsnap caches information about what " "it has uploaded in a local directory." "</html" ), this ), 6, 1, 1, 2, Qt::AlignLeft ); l->addWidget( new QLabel( tr( "Cache" ), this ), 7, 0, 1, 1, Qt::AlignLeft ); l->addWidget( cacheDirectory, 7, 1, 1, 1 ); b = new QPushButton( tr( "..." ), this ); connect( b, SIGNAL(clicked()), this, SLOT(browseForCache()) ); l->addWidget( b, 7, 2, 1, 1 ); }