本文整理汇总了C++中Preferences::getDefaultEditor方法的典型用法代码示例。如果您正苦于以下问题:C++ Preferences::getDefaultEditor方法的具体用法?C++ Preferences::getDefaultEditor怎么用?C++ Preferences::getDefaultEditor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preferences
的用法示例。
在下文中一共展示了Preferences::getDefaultEditor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: editScript
void PlaylistDialog::editScript()
{
Preferences *pPref = Preferences::get_instance();
if( pPref->getDefaultEditor().isEmpty() ){
QMessageBox::information ( this, "Hydrogen", trUtf8 ( "No Default Editor Set. Please set your Default Editor\nDo not use a console based Editor\nSorry, but this will not work for the moment." ) );
static QString lastUsedDir = "/usr/bin/";
QFileDialog fd(this);
fd.setFileMode ( QFileDialog::ExistingFile );
fd.setDirectory ( lastUsedDir );
fd.setWindowTitle ( trUtf8 ( "Set your Default Editor" ) );
QString filename;
if ( fd.exec() == QDialog::Accepted ){
filename = fd.selectedFiles().first();
pPref->setDefaultEditor( filename );
}
}
QTreeWidgetItem* pPlaylistItem = m_pPlaylistTree->currentItem();
if ( pPlaylistItem == NULL ){
QMessageBox::information ( this, "Hydrogen", trUtf8 ( "No Song selected!" ) );
return;
}
QString selected;
selected = pPlaylistItem->text ( 1 );
QString filename = pPref->getDefaultEditor() + " " + selected + "&";
if( !QFile( selected ).exists() ){
QMessageBox::information ( this, "Hydrogen", trUtf8 ( "No Script selected!" ));
return;
}
char *file;
file = new char[ filename.length() + 1 ];
strcpy( file , filename.toAscii() );
int ret = std::system( file );
delete [] file;
return;
}
示例2: newScript
void PlaylistDialog::newScript()
{
Preferences *pPref = Preferences::get_instance();
QString sDirectory = ( Preferences::get_instance()->getDataDirectory() + "scripts/");
QFileDialog fd(this);
fd.setFileMode ( QFileDialog::AnyFile );
fd.setFilter ( trUtf8 ( "Hydrogen Scripts (*.sh)" ) );
fd.setAcceptMode ( QFileDialog::AcceptSave );
fd.setWindowTitle ( trUtf8 ( "New Script" ) );
fd.setDirectory ( sDirectory );
QString defaultFilename;
defaultFilename += ".sh";
fd.selectFile ( defaultFilename );
QString filename;
if ( fd.exec() != QDialog::Accepted ) return;
filename = fd.selectedFiles().first();
if( filename.contains(" ", Qt::CaseInsensitive)){
QMessageBox::information ( this, "Hydrogen", trUtf8 ( "Script name or path to the script contains whitespaces.\nIMPORTANT\nThe path to the script and the scriptname must without whitespaces.") );
return;
}
QFile chngPerm ( filename );
if (!chngPerm.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out(&chngPerm);
out << "#!/bin/sh\n\n#have phun";
chngPerm.close();
if (chngPerm.exists() ) {
chngPerm.setPermissions( QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner );
QMessageBox::information ( this, "Hydrogen", trUtf8 ( "WARNING, the new file is executable by the owner of the file!" ) );
}
if( pPref->getDefaultEditor().isEmpty() ){
QMessageBox::information ( this, "Hydrogen", trUtf8 ( "No Default Editor Set. Please set your Default Editor\nDo not use a console based Editor\nSorry, but this will not work for the moment." ) );
static QString lastUsedDir = "/usr/bin/";
QFileDialog fd(this);
fd.setFileMode ( QFileDialog::ExistingFile );
fd.setDirectory ( lastUsedDir );
fd.setWindowTitle ( trUtf8 ( "Set your Default Editor" ) );
QString filename;
if ( fd.exec() == QDialog::Accepted ){
filename = fd.selectedFiles().first();
pPref->setDefaultEditor( filename );
}
}
QString openfile = pPref->getDefaultEditor() + " " + filename + "&";
char *ofile;
ofile = new char[openfile.length() + 1];
strcpy(ofile, openfile.toAscii());
int ret = std::system( ofile );
delete [] ofile;
return;
}