// set default values void Config::setDefaultSettings() { setSaveDir(getDirNameDefault()); setSaveFileName(DEF_SAVE_NAME); setSaveFormat(DEF_SAVE_FORMAT); setDefDelay(DEF_DELAY); setImageQuality(DEF_IMG_QUALITY); setDateTimeInFilename(DEF_DATETIME_FILENAME); setDateTimeTpl(DEF_DATETIME_TPL); setAutoCopyFilenameOnSaving(DEF_FILENAME_TO_CLB); setAutoSave(DEF_AUTO_SAVE); setAutoSaveFirst(DEF_AUTO_SAVE_FIRST); setTrayMessages(DEF_TRAY_MESS_TYPE); setIncludeCursor(DEF_INCLUDE_CURSOR); setZoomAroundMouse(DEF_ZOOM_AROUND_MOUSE); setCloseInTray(DEF_CLOSE_IN_TRAY); setTimeTrayMess(DEF_TIME_TRAY_MESS); setAllowMultipleInstance(DEF_ALLOW_COPIES); // TODO - make set windows size without hardcode values // setRestoredWndSize(DEF_WND_WIDTH, DEF_WND_HEIGHT); setShowTrayIcon(DEF_SHOW_TRAY); setEnableExtView(DEF_ENABLE_EXT_VIEWER); _shortcuts->setDefaultSettings(); setNoDecoration(DEF_X11_NODECOR); setDelay(DEF_DELAY); quint8 countModules = Core::instance()->modules()->count(); for (int i = 0; i < countModules; ++i) Core::instance()->modules()->getModule(i)->defaultSettings(); }
/** Retrieves the firmware from the device */ void deviceWidget::downloadFirmware() { if (!m_dfu->devices[deviceID].Readable) { myDevice->statusLabel->setText(QString("Device not readable!")); return; } myDevice->retrieveButton->setEnabled(false); filename = setSaveFileName(); if (filename.isEmpty()) { status("Empty filename", STATUSICON_FAIL); return; } status("Downloading firmware from device", STATUSICON_RUNNING); connect(m_dfu, SIGNAL(progressUpdated(int)), this, SLOT(setProgress(int))); connect(m_dfu, SIGNAL(downloadFinished()), this, SLOT(downloadFinished())); downloadedFirmware.clear(); // Empty the byte array bool ret = m_dfu->DownloadFirmware(&downloadedFirmware,deviceID); if(!ret) { status("Could not start download!", STATUSICON_FAIL); return; } status("Download started, please wait", STATUSICON_RUNNING); }
int Dialog::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: setInteger(); break; case 1: setDouble(); break; case 2: setItem(); break; case 3: setText(); break; case 4: setColor(); break; case 5: setFont(); break; case 6: setExistingDirectory(); break; case 7: setOpenFileName(); break; case 8: setOpenFileNames(); break; case 9: setSaveFileName(); break; case 10: criticalMessage(); break; case 11: informationMessage(); break; case 12: questionMessage(); break; case 13: warningMessage(); break; case 14: errorMessage(); break; default: ; } _id -= 15; } return _id; }
/** Retrieves the firmware from the device */ void DeviceWidget::downloadFirmware() { // clear progress bar now // this avoids displaying an error message and the progress at 100% at the same time setProgress(0); updateButtons(false); if (!m_dfu->devices[deviceID].Readable) { myDevice->statusLabel->setText(QString("Device not readable!")); status("Device not readable!", STATUSICON_FAIL); updateButtons(true); return; } filename = setSaveFileName(); if (filename.isEmpty()) { status("Empty filename", STATUSICON_FAIL); updateButtons(true); return; } status("Starting firmware download", STATUSICON_RUNNING); emit downloadStarted(); connect(m_dfu, SIGNAL(progressUpdated(int)), this, SLOT(setProgress(int))); connect(m_dfu, SIGNAL(downloadFinished()), this, SLOT(downloadFinished())); downloadedFirmware.clear(); // Empty the byte array bool ret = m_dfu->DownloadFirmware(&downloadedFirmware,deviceID); if (!ret) { emit downloadEnded(false); status("Could not start download!", STATUSICON_FAIL); updateButtons(true); return; } status("Downloading, please wait...", STATUSICON_RUNNING); return; }
// load all settings from conf file void Config::loadSettings() { _settings->beginGroup("Base"); setSaveDir(_settings->value(KEY_SAVEDIR, getDirNameDefault()).toString() ); setSaveFileName(_settings->value(KEY_SAVENAME,DEF_SAVE_NAME).toString()); setSaveFormat(_settings->value(KEY_SAVEFORMAT, DEF_SAVE_FORMAT).toString()); setDefDelay(_settings->value(KEY_DELAY, DEF_DELAY).toInt()); setDefScreenshotType(screenshotTypeFromString(_settings->value(QLatin1String(KEY_SCREENSHOT_TYPE_DEF)).toString())); setAutoCopyFilenameOnSaving(_settings->value(KEY_FILENAME_TO_CLB, DEF_FILENAME_TO_CLB).toInt()); setDateTimeInFilename(_settings->value(KEY_FILENAMEDATE, DEF_DATETIME_FILENAME).toBool()); setDateTimeTpl(_settings->value(KEY_DATETIME_TPL, DEF_DATETIME_TPL).toString()); setAutoSave(_settings->value(KEY_AUTOSAVE, DEF_AUTO_SAVE).toBool()); setAutoSaveFirst(_settings->value(KEY_AUTOSAVE_FIRST, DEF_AUTO_SAVE_FIRST).toBool()); setNoDecoration(_settings->value(KEY_NODECOR, DEF_X11_NODECOR).toBool()); setImageQuality(_settings->value(KEY_IMG_QUALITY, DEF_IMG_QUALITY).toInt()); setIncludeCursor(_settings->value(KEY_INCLUDE_CURSOR, DEF_INCLUDE_CURSOR).toBool()); _settings->endGroup(); _settings->beginGroup("Display"); setTrayMessages(_settings->value(KEY_TRAYMESSAGES, DEF_TRAY_MESS_TYPE).toInt()); setTimeTrayMess(_settings->value(KEY_TIME_NOTIFY, DEF_TIME_TRAY_MESS).toInt( )); setZoomAroundMouse(_settings->value(KEY_ZOOMBOX, DEF_ZOOM_AROUND_MOUSE).toBool()); // TODO - make set windows size without hardcode values setRestoredWndSize(_settings->value(KEY_WND_WIDTH, DEF_WND_WIDTH).toInt(), _settings->value(KEY_WND_HEIGHT, DEF_WND_HEIGHT).toInt()); setShowTrayIcon(_settings->value(KEY_SHOW_TRAY, DEF_SHOW_TRAY).toBool()); _settings->endGroup(); _settings->beginGroup("System"); setCloseInTray(_settings->value(KEY_CLOSE_INTRAY, DEF_CLOSE_IN_TRAY).toBool()); setAllowMultipleInstance(_settings->value(KEY_ALLOW_COPIES, DEF_ALLOW_COPIES).toBool()); setEnableExtView(_settings->value(KEY_ENABLE_EXT_VIEWER, DEF_ENABLE_EXT_VIEWER).toBool()); _settings->endGroup(); setDelay(getDefDelay()); _shortcuts->loadSettings(); }
bool CProjectSettings::CloseProjectSettings() { // check bool if settings have changed if ( IsChangedSinceLastSave ) { // popup to ask if save - yes/no/(cancel) int answer = AfxMessageBox( "Do you want to save the changes in the project?", MB_YESNOCANCEL ); // do what the user clicked if (answer == IDCANCEL) { // Cancel: we dont want to do anything... return FALSE; } else if ( answer == IDYES ) { // get the filename StdString fileName = getSaveFileName(); // check if it is a valid path if ( fileName.length() == 0 ) { // Selecting a file StdString typeExtension( _T("gdsprj") ); StdString filterStr = "GDS project files (*." + typeExtension + ")|*." + typeExtension + "||"; CFileDialog myFileDialog(FALSE, typeExtension, NULL, OFN_ENABLESIZING|OFN_EXPLORER|OFN_OVERWRITEPROMPT, filterStr); // set the file selector default dir to project dir myFileDialog.m_ofn.lpstrInitialDir = GetDirectory(); // Adding it to the listBox if ( myFileDialog.DoModal() == IDOK ) { // get the selected file with path fileName = myFileDialog.GetPathName(); // saving the filename in the object as well setSaveFileName( fileName ); } else { // the user clicked cancel: exiting save dialog return FALSE; } } // send message to make projectloader serialize us. CHashString hszProjectLoader(_T("CProjectLoadSave")); CHashString hszNewParticleSaveFilepath( fileName ); static DWORD msgHash_SaveFile = CHashString(_T("SaveFile")).GetUniqueID(); DWORD result = EngineGetToolBox()->SendMessage(msgHash_SaveFile, sizeof(TCHAR *), (void *)hszNewParticleSaveFilepath.GetString(), 0, &hszProjectLoader); // mark settings as saved IsChangedSinceLastSave = FALSE; } else { // we are here, if the user clicked NO SAVE // then we don't save anything, but return TRUE // that will lead to close GDS return TRUE; } } // Closing project destroys consistency SetSettingsStateConsistency( FALSE ); return TRUE; }
Dialog::Dialog(QWidget *parent) : QWidget(parent) { QVBoxLayout *mainLayout = new QVBoxLayout(this); QToolBox *toolbox = new QToolBox; mainLayout->addWidget(toolbox); errorMessageDialog = new QErrorMessage(this); int frameStyle = QFrame::Sunken | QFrame::Panel; integerLabel = new QLabel; integerLabel->setFrameStyle(frameStyle); QPushButton *integerButton = new QPushButton(tr("QInputDialog::get&Int()")); doubleLabel = new QLabel; doubleLabel->setFrameStyle(frameStyle); QPushButton *doubleButton = new QPushButton(tr("QInputDialog::get&Double()")); itemLabel = new QLabel; itemLabel->setFrameStyle(frameStyle); QPushButton *itemButton = new QPushButton(tr("QInputDialog::getIte&m()")); textLabel = new QLabel; textLabel->setFrameStyle(frameStyle); QPushButton *textButton = new QPushButton(tr("QInputDialog::get&Text()")); multiLineTextLabel = new QLabel; multiLineTextLabel->setFrameStyle(frameStyle); QPushButton *multiLineTextButton = new QPushButton(tr("QInputDialog::get&MultiLineText()")); colorLabel = new QLabel; colorLabel->setFrameStyle(frameStyle); QPushButton *colorButton = new QPushButton(tr("QColorDialog::get&Color()")); fontLabel = new QLabel; fontLabel->setFrameStyle(frameStyle); QPushButton *fontButton = new QPushButton(tr("QFontDialog::get&Font()")); directoryLabel = new QLabel; directoryLabel->setFrameStyle(frameStyle); QPushButton *directoryButton = new QPushButton(tr("QFileDialog::getE&xistingDirectory()")); openFileNameLabel = new QLabel; openFileNameLabel->setFrameStyle(frameStyle); QPushButton *openFileNameButton = new QPushButton(tr("QFileDialog::get&OpenFileName()")); openFileNamesLabel = new QLabel; openFileNamesLabel->setFrameStyle(frameStyle); QPushButton *openFileNamesButton = new QPushButton(tr("QFileDialog::&getOpenFileNames()")); saveFileNameLabel = new QLabel; saveFileNameLabel->setFrameStyle(frameStyle); QPushButton *saveFileNameButton = new QPushButton(tr("QFileDialog::get&SaveFileName()")); criticalLabel = new QLabel; criticalLabel->setFrameStyle(frameStyle); QPushButton *criticalButton = new QPushButton(tr("QMessageBox::critica&l()")); informationLabel = new QLabel; informationLabel->setFrameStyle(frameStyle); QPushButton *informationButton = new QPushButton(tr("QMessageBox::i&nformation()")); questionLabel = new QLabel; questionLabel->setFrameStyle(frameStyle); QPushButton *questionButton = new QPushButton(tr("QMessageBox::&question()")); warningLabel = new QLabel; warningLabel->setFrameStyle(frameStyle); QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()")); errorLabel = new QLabel; errorLabel->setFrameStyle(frameStyle); QPushButton *errorButton = new QPushButton(tr("QErrorMessage::showM&essage()")); connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger())); connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble())); connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem())); connect(textButton, SIGNAL(clicked()), this, SLOT(setText())); connect(multiLineTextButton, SIGNAL(clicked()), this, SLOT(setMultiLineText())); connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor())); connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(directoryButton, SIGNAL(clicked()), this, SLOT(setExistingDirectory())); connect(openFileNameButton, SIGNAL(clicked()), this, SLOT(setOpenFileName())); connect(openFileNamesButton, SIGNAL(clicked()), this, SLOT(setOpenFileNames())); connect(saveFileNameButton, SIGNAL(clicked()), this, SLOT(setSaveFileName())); connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); connect(informationButton, SIGNAL(clicked()), this, SLOT(informationMessage())); connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage())); connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage())); connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage())); QWidget *page = new QWidget; QGridLayout *layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->setColumnMinimumWidth(1, 250); layout->addWidget(integerButton, 0, 0); layout->addWidget(integerLabel, 0, 1); layout->addWidget(doubleButton, 1, 0); layout->addWidget(doubleLabel, 1, 1); layout->addWidget(itemButton, 2, 0); layout->addWidget(itemLabel, 2, 1); layout->addWidget(textButton, 3, 0); layout->addWidget(textLabel, 3, 1); layout->addWidget(multiLineTextButton, 4, 0); layout->addWidget(multiLineTextLabel, 4, 1); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0); toolbox->addItem(page, tr("Input Dialogs")); const QString doNotUseNativeDialog = tr("Do not use native dialog"); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(colorButton, 0, 0); layout->addWidget(colorLabel, 0, 1); colorDialogOptionsWidget = new DialogOptionsWidget; colorDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QColorDialog::DontUseNativeDialog); colorDialogOptionsWidget->addCheckBox(tr("Show alpha channel") , QColorDialog::ShowAlphaChannel); colorDialogOptionsWidget->addCheckBox(tr("No buttons") , QColorDialog::NoButtons); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0); layout->addWidget(colorDialogOptionsWidget, 2, 0, 1 ,2); toolbox->addItem(page, tr("Color Dialog")); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(fontButton, 0, 0); layout->addWidget(fontLabel, 0, 1); fontDialogOptionsWidget = new DialogOptionsWidget; fontDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFontDialog::DontUseNativeDialog); fontDialogOptionsWidget->addCheckBox(tr("No buttons") , QFontDialog::NoButtons); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0); layout->addWidget(fontDialogOptionsWidget, 2, 0, 1 ,2); toolbox->addItem(page, tr("Font Dialog")); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(directoryButton, 0, 0); layout->addWidget(directoryLabel, 0, 1); layout->addWidget(openFileNameButton, 1, 0); layout->addWidget(openFileNameLabel, 1, 1); layout->addWidget(openFileNamesButton, 2, 0); layout->addWidget(openFileNamesLabel, 2, 1); layout->addWidget(saveFileNameButton, 3, 0); layout->addWidget(saveFileNameLabel, 3, 1); fileDialogOptionsWidget = new DialogOptionsWidget; fileDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFileDialog::DontUseNativeDialog); fileDialogOptionsWidget->addCheckBox(tr("Show directories only"), QFileDialog::ShowDirsOnly); fileDialogOptionsWidget->addCheckBox(tr("Do not resolve symlinks"), QFileDialog::DontResolveSymlinks); fileDialogOptionsWidget->addCheckBox(tr("Do not confirm overwrite"), QFileDialog::DontConfirmOverwrite); fileDialogOptionsWidget->addCheckBox(tr("Do not use sheet"), QFileDialog::DontUseSheet); fileDialogOptionsWidget->addCheckBox(tr("Readonly"), QFileDialog::ReadOnly); fileDialogOptionsWidget->addCheckBox(tr("Hide name filter details"), QFileDialog::HideNameFilterDetails); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 4, 0); layout->addWidget(fileDialogOptionsWidget, 5, 0, 1 ,2); toolbox->addItem(page, tr("File Dialogs")); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(criticalButton, 0, 0); layout->addWidget(criticalLabel, 0, 1); layout->addWidget(informationButton, 1, 0); layout->addWidget(informationLabel, 1, 1); layout->addWidget(questionButton, 2, 0); layout->addWidget(questionLabel, 2, 1); layout->addWidget(warningButton, 3, 0); layout->addWidget(warningLabel, 3, 1); layout->addWidget(errorButton, 4, 0); layout->addWidget(errorLabel, 4, 1); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0); toolbox->addItem(page, tr("Message Boxes")); setWindowTitle(tr("Standard Dialogs")); }
Dialog::Dialog(QWidget *parent) : QDialog(parent) { errorMessageDialog = new QErrorMessage(this); int frameStyle = QFrame::Sunken | QFrame::Panel; integerLabel = new QLabel; integerLabel->setFrameStyle(frameStyle); QPushButton *integerButton = new QPushButton(tr("QInputDialog::get&Integer()")); doubleLabel = new QLabel; doubleLabel->setFrameStyle(frameStyle); QPushButton *doubleButton = new QPushButton(tr("QInputDialog::get&Double()")); itemLabel = new QLabel; itemLabel->setFrameStyle(frameStyle); QPushButton *itemButton = new QPushButton(tr("QInputDialog::getIte&m()")); textLabel = new QLabel; textLabel->setFrameStyle(frameStyle); QPushButton *textButton = new QPushButton(tr("QInputDialog::get&Text()")); colorLabel= new QLabel; colorLabel->setFrameStyle(frameStyle); QPushButton *colorButton = new QPushButton(tr("QColorDialog::get&Color()")); fontLabel = new QLabel; fontLabel->setFrameStyle(frameStyle); QPushButton *fontButton = new QPushButton(tr("QFontDialog::get&Font()")); directoryLabel = new QLabel; directoryLabel->setFrameStyle(frameStyle); QPushButton *directoryButton = new QPushButton(tr("QFileDialog::getE&xistingDirectory()")); openFileNameLabel = new QLabel; openFileNameLabel->setFrameStyle(frameStyle); QPushButton *openFileNameButton = new QPushButton(tr("QFileDialog::get&OpenFileName()")); openFileNamesLabel = new QLabel; openFileNamesLabel->setFrameStyle(frameStyle); QPushButton *openFileNamesButton = new QPushButton(tr("QFileDialog::&getOpenFileNames()")); saveFileNameLabel = new QLabel; saveFileNameLabel->setFrameStyle(frameStyle); QPushButton *saveFileNameButton = new QPushButton(tr("QFileDialog::get&SaveFileName()")); criticalLabel = new QLabel; criticalLabel->setFrameStyle(frameStyle); QPushButton *criticalButton = new QPushButton(tr("QMessageBox::critica&l()")); informationLabel = new QLabel; informationLabel->setFrameStyle(frameStyle); QPushButton *informationButton = new QPushButton(tr("QMessageBox::i&nformation()")); questionLabel = new QLabel; questionLabel->setFrameStyle(frameStyle); QPushButton *questionButton = new QPushButton(tr("QMessageBox::&question()")); warningLabel = new QLabel; warningLabel->setFrameStyle(frameStyle); QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()")); errorLabel = new QLabel; errorLabel->setFrameStyle(frameStyle); QPushButton *errorButton = new QPushButton(tr("QMessageBox::&error()")); connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger())); connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble())); connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem())); connect(textButton, SIGNAL(clicked()), this, SLOT(setText())); connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor())); connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(directoryButton, SIGNAL(clicked()), this, SLOT(setExistingDirectory())); connect(openFileNameButton, SIGNAL(clicked()), this, SLOT(setOpenFileName())); connect(openFileNamesButton, SIGNAL(clicked()), this, SLOT(setOpenFileNames())); connect(saveFileNameButton, SIGNAL(clicked()), this, SLOT(setSaveFileName())); connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); connect(informationButton, SIGNAL(clicked()), this, SLOT(informationMessage())); connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage())); connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage())); connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage())); native = new QCheckBox(this); native->setText("Use native file dialog"); native->setChecked(true); #ifndef Q_WS_WIN #ifndef Q_OS_MAC native->hide(); #endif #endif QGridLayout *layout = new QGridLayout; layout->setColumnStretch(1, 1); layout->setColumnMinimumWidth(1, 250); layout->addWidget(integerButton, 0, 0); layout->addWidget(integerLabel, 0, 1); layout->addWidget(doubleButton, 1, 0); layout->addWidget(doubleLabel, 1, 1); layout->addWidget(itemButton, 2, 0); layout->addWidget(itemLabel, 2, 1); layout->addWidget(textButton, 3, 0); layout->addWidget(textLabel, 3, 1); layout->addWidget(colorButton, 4, 0); layout->addWidget(colorLabel, 4, 1); layout->addWidget(fontButton, 5, 0); layout->addWidget(fontLabel, 5, 1); layout->addWidget(directoryButton, 6, 0); layout->addWidget(directoryLabel, 6, 1); layout->addWidget(openFileNameButton, 7, 0); layout->addWidget(openFileNameLabel, 7, 1); layout->addWidget(openFileNamesButton, 8, 0); layout->addWidget(openFileNamesLabel, 8, 1); layout->addWidget(saveFileNameButton, 9, 0); layout->addWidget(saveFileNameLabel, 9, 1); layout->addWidget(criticalButton, 10, 0); layout->addWidget(criticalLabel, 10, 1); layout->addWidget(informationButton, 11, 0); layout->addWidget(informationLabel, 11, 1); layout->addWidget(questionButton, 12, 0); layout->addWidget(questionLabel, 12, 1); layout->addWidget(warningButton, 13, 0); layout->addWidget(warningLabel, 13, 1); layout->addWidget(errorButton, 14, 0); layout->addWidget(errorLabel, 14, 1); layout->addWidget(native, 15, 0); setLayout(layout); setWindowTitle("Standard Dialogs"); }