void MainWindow::closeEvent(QCloseEvent *) { QSettings ini( getIniPath(), QSettings::IniFormat ); ini.setValue( ui->splitter->objectName(), ui->splitter->saveState() ); ini.setValue( "State", saveState() ); ini.setValue( "Geometry", saveGeometry() ); qApp->quit(); }
bool Wizard::UnshieldWorker::setupSettings() { // Create Morrowind.ini settings map if (getIniPath().isEmpty()) return false; QFile file(getIniPath()); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { emit error(tr("Failed to open Morrowind configuration file!"), tr("Opening %1 failed: %2.").arg(getIniPath(), file.errorString())); return false; } QTextStream stream(&file); stream.setCodec(mIniCodec); mIniSettings.readFile(stream); return true; }
bool Wizard::UnshieldWorker::writeSettings() { if (getIniPath().isEmpty()) return false; QFile file(getIniPath()); if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { emit error(tr("Failed to open Morrowind configuration file!"), tr("Opening %1 failed: %2.").arg(getIniPath(), file.errorString())); return false; } QTextStream stream(&file); stream.setCodec(mIniCodec); if (!mIniSettings.writeFile(getIniPath(), stream)) { emit error(tr("Failed to write Morrowind configuration file!"), tr("Writing to %1 failed: %2.").arg(getIniPath(), file.errorString())); return false; } return true; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->scrollArea->installEventFilter( this ); connect( ui->actionOpen, SIGNAL( triggered() ), SLOT( open() ) ); connect( ui->actionQuit, SIGNAL( triggered() ), SLOT( close() ) ); // Расшифровываем qr коды zxing.setDecoder( QZXing::DecoderFormat_QR_CODE ); QSettings ini( getIniPath(), QSettings::IniFormat ); ui->splitter->restoreState( ini.value( ui->splitter->objectName() ).toByteArray() ); restoreState( ini.value( "State" ).toByteArray() ); restoreGeometry( ini.value( "Geometry" ).toByteArray() ); }
void setIniInt(LPCTSTR lpKeyName, int nValue) { TCHAR value[128]; _itow_s(nValue,value,128,10); WritePrivateProfileString( _T("properties"), lpKeyName, value, getIniPath()); }
int getIniInt(LPCTSTR lpKeyName, int nDefault) { return GetPrivateProfileInt( _T("properties"), lpKeyName, nDefault, getIniPath()); }