void MainWindow::openDeleteCategory(){ deleteCategoryDialog dialog(this, m_database); dialog.exec(); ui->comboBox_categorie->clear(); this->genrateCategorie(); }
void MainWindow::open() { FindFileDialog dialog(textViewer, assistant); dialog.exec(); }
void NoteCanvas::menu(const QPoint&) { Q3PopupMenu m(0); Q3PopupMenu fontsubm(0); m.insertItem(new MenuTitle(TR("Note"), m.font()), -1); m.insertSeparator(); m.insertItem(TR("Upper"), 0); m.insertItem(TR("Lower"), 1); m.insertItem(TR("Go up"), 7); m.insertItem(TR("Go down"), 8); m.insertSeparator(); m.insertItem(TR("Edit"), 2); m.insertSeparator(); m.insertItem(TR("Color of text"), 6); m.insertItem(TR("Font"), &fontsubm); init_font_menu(fontsubm, the_canvas(), 10); m.insertItem(TR("Edit drawing settings"), 3); if (linked()) { m.insertSeparator(); m.insertItem(TR("Select linked items"), 4); } m.insertSeparator(); m.insertItem(TR("Remove from diagram"),5); int index = m.exec(QCursor::pos()); switch (index) { case 0: upper(); modified(); // call package_modified() return; case 1: lower(); modified(); // call package_modified() return; case 7: z_up(); modified(); // call package_modified() return; case 8: z_down(); modified(); // call package_modified() return; case 2: open(); // modified then package_modified already called return; case 3: edit_drawing_settings(); return; case 4: the_canvas()->unselect_all(); select_associated(); return; case 5: delete_it(); break; case 6: for (;;) { ColorSpecVector co(1); co[0].set(TR("color"), &fg_c); SettingsDialog dialog(0, &co, TRUE, FALSE, TR("Text color dialog")); dialog.raise(); if (dialog.exec() != QDialog::Accepted) return; // force son reaffichage hide(); show(); canvas()->update(); if (!dialog.redo()) break; else package_modified(); } break; default: if (index >= 10) { itsfont = (UmlFont) (index - 10); modified(); } return; } package_modified(); }
bool EditConfigWindow::editParameter(ConfigMap::Parameter& parameter) { EditParameterDialog dialog(parameter, this); return dialog.exec() == 1; }
void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) { const GameListItem *iso = GetSelectedISO(); if (!iso) return; wxString path; std::string FileName, FilePath, FileExtension; SplitPath(iso->GetFileName(), &FilePath, &FileName, &FileExtension); do { if (iso->IsCompressed()) { wxString FileType; if (iso->GetPlatform() == GameListItem::WII_DISC) FileType = _("All Wii ISO files (iso)") + "|*.iso"; else FileType = _("All GameCube GCM files (gcm)") + "|*.gcm"; path = wxFileSelector( _("Save decompressed GCM/ISO"), StrToWxStr(FilePath), StrToWxStr(FileName) + FileType.After('*'), wxEmptyString, FileType + "|" + wxGetTranslation(wxALL_FILES), wxFD_SAVE, this); } else { path = wxFileSelector( _("Save compressed GCM/ISO"), StrToWxStr(FilePath), StrToWxStr(FileName) + ".gcz", wxEmptyString, _("All compressed GC/Wii ISO files (gcz)") + wxString::Format("|*.gcz|%s", wxGetTranslation(wxALL_FILES)), wxFD_SAVE, this); } if (!path) return; } while (wxFileExists(path) && wxMessageBox( wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"), path.c_str()), _("Confirm File Overwrite"), wxYES_NO) == wxNO); bool all_good = false; { wxProgressDialog dialog( iso->IsCompressed() ? _("Decompressing ISO") : _("Compressing ISO"), _("Working..."), 1000, this, wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME | wxPD_SMOOTH ); if (iso->IsCompressed()) all_good = DiscIO::DecompressBlobToFile(iso->GetFileName(), WxStrToStr(path), &CompressCB, &dialog); else all_good = DiscIO::CompressFileToBlob(iso->GetFileName(), WxStrToStr(path), (iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0, 16384, &CompressCB, &dialog); } if (!all_good) WxUtils::ShowErrorDialog(_("Dolphin was unable to complete the requested action.")); Update(); }
CStarNetSet::CStarNetSet(wxWindow* parent, int id, const wxString& title, const wxString& band, const wxString& callsign, const wxString& logoff, const wxString& info, const wxString& permanent, unsigned int userTimeout, unsigned int groupTimeout, STARNET_CALLSIGN_SWITCH callsignSwitch, bool txMsgSwitch, const wxString& reflector) : #else CStarNetSet::CStarNetSet(wxWindow* parent, int id, const wxString& title, const wxString& band, const wxString& callsign, const wxString& logoff, const wxString& info, const wxString& permanent, unsigned int userTimeout, unsigned int groupTimeout, STARNET_CALLSIGN_SWITCH callsignSwitch, bool txMsgSwitch) : #endif wxPanel(parent, id), m_title(title), m_band(NULL), m_callsign(NULL), m_logoff(NULL), m_info(NULL), m_permanent(NULL), m_userTimeout(NULL), m_groupTimeout(NULL), m_callsignSwitch(NULL), m_txMsgSwitch(NULL) #if defined(DEXTRA_LINK) || defined(DCS_LINK) ,m_reflector(NULL) #endif { wxFlexGridSizer* sizer = new wxFlexGridSizer(3); wxStaticText* bandLabel = new wxStaticText(this, -1, _("Band")); sizer->Add(bandLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); m_band = new wxChoice(this, -1, wxDefaultPosition, wxSize(BAND_WIDTH, -1)); m_band->Append(wxT("A")); m_band->Append(wxT("B")); m_band->Append(wxT("C")); m_band->Append(wxT("D")); sizer->Add(m_band, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); bool res = m_band->SetStringSelection(band); if (!res) m_band->SetSelection(0); wxStaticText* dummy1Label = new wxStaticText(this, -1, wxEmptyString); sizer->Add(dummy1Label, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); wxStaticText* callsignLabel = new wxStaticText(this, -1, _("Group Call")); sizer->Add(callsignLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); wxString call = callsign; call.Truncate(LONG_CALLSIGN_LENGTH); m_callsign = new CCallsignTextCtrl(this, -1, call, wxDefaultPosition, wxSize(CALLSIGN_WIDTH, -1)); m_callsign->SetMaxLength(LONG_CALLSIGN_LENGTH); sizer->Add(m_callsign, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); wxStaticText* dummy2Label = new wxStaticText(this, -1, wxEmptyString); sizer->Add(dummy2Label, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); wxStaticText* logoffLabel = new wxStaticText(this, -1, _("Logoff Call")); sizer->Add(logoffLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); call = logoff; call.Truncate(LONG_CALLSIGN_LENGTH); m_logoff = new CCallsignTextCtrl(this, -1, call, wxDefaultPosition, wxSize(CALLSIGN_WIDTH, -1)); m_logoff->SetMaxLength(LONG_CALLSIGN_LENGTH); sizer->Add(m_logoff, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); wxStaticText* dummy3Label = new wxStaticText(this, -1, wxEmptyString); sizer->Add(dummy3Label, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); wxStaticText* infoLabel = new wxStaticText(this, -1, _("Information")); sizer->Add(infoLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); m_info = new wxTextCtrl(this, -1, info, wxDefaultPosition, wxSize(INFO_WIDTH, -1)); m_info->SetMaxLength(INFO_LENGTH); sizer->Add(m_info, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); wxStaticText* dummy4Label = new wxStaticText(this, -1, wxEmptyString); sizer->Add(dummy4Label, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); wxStaticText* permanentLabel = new wxStaticText(this, -1, _("Permanent Calls")); sizer->Add(permanentLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); call = permanent; call.Truncate(LONG_CALLSIGN_LENGTH); m_permanent = new CCallsignTextCtrl(this, -1, call, wxDefaultPosition, wxSize(INFO_WIDTH, -1)); sizer->Add(m_permanent, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); wxStaticText* dummy4ALabel = new wxStaticText(this, -1, wxEmptyString); sizer->Add(dummy4ALabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); wxStaticText* userTimeoutLabel = new wxStaticText(this, -1, _("User Timeout")); sizer->Add(userTimeoutLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); m_userTimeout = new wxChoice(this, -1, wxDefaultPosition, wxSize(TIMEOUT_WIDTH, -1)); m_userTimeout->Append(_("Never")); m_userTimeout->Append(_("30 mins")); m_userTimeout->Append(_("60 mins")); m_userTimeout->Append(_("120 mins")); m_userTimeout->Append(_("180 mins")); m_userTimeout->Append(_("240 mins")); m_userTimeout->Append(_("300 mins")); sizer->Add(m_userTimeout, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); switch (userTimeout) { case 0U: m_userTimeout->SetSelection(0); break; case 30U: m_userTimeout->SetSelection(1); break; case 60U: m_userTimeout->SetSelection(2); break; case 120U: m_userTimeout->SetSelection(3); break; case 180U: m_userTimeout->SetSelection(4); break; case 240U: m_userTimeout->SetSelection(5); break; default: m_userTimeout->SetSelection(6); break; } wxStaticText* dummy5Label = new wxStaticText(this, -1, wxEmptyString); sizer->Add(dummy5Label, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); wxStaticText* groupTimeoutLabel = new wxStaticText(this, -1, _("Group Timeout")); sizer->Add(groupTimeoutLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); m_groupTimeout = new wxChoice(this, -1, wxDefaultPosition, wxSize(TIMEOUT_WIDTH, -1)); m_groupTimeout->Append(_("Never")); m_groupTimeout->Append(_("30 mins")); m_groupTimeout->Append(_("60 mins")); m_groupTimeout->Append(_("120 mins")); m_groupTimeout->Append(_("180 mins")); m_groupTimeout->Append(_("240 mins")); m_groupTimeout->Append(_("300 mins")); sizer->Add(m_groupTimeout, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); switch (groupTimeout) { case 0U: m_groupTimeout->SetSelection(0); break; case 30U: m_groupTimeout->SetSelection(1); break; case 60U: m_groupTimeout->SetSelection(2); break; case 120U: m_groupTimeout->SetSelection(3); break; case 180U: m_groupTimeout->SetSelection(4); break; case 240U: m_groupTimeout->SetSelection(5); break; default: m_groupTimeout->SetSelection(6); break; } wxStaticText* dummy6Label = new wxStaticText(this, -1, wxEmptyString); sizer->Add(dummy6Label, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); wxStaticText* callsignSwitchLabel = new wxStaticText(this, -1, _("MYCALL Setting")); sizer->Add(callsignSwitchLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); m_callsignSwitch = new wxChoice(this, -1, wxDefaultPosition, wxSize(CALLSIGN_WIDTH, -1)); m_callsignSwitch->Append(_("Group")); m_callsignSwitch->Append(_("User")); sizer->Add(m_callsignSwitch, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); switch (callsignSwitch) { case SCS_GROUP_CALLSIGN: m_callsignSwitch->SetSelection(0); break; case SCS_USER_CALLSIGN: m_callsignSwitch->SetSelection(1); break; default: m_callsignSwitch->SetSelection(0); break; } wxStaticText* dummy7Label = new wxStaticText(this, -1, wxEmptyString); sizer->Add(dummy7Label, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); wxStaticText* txMsgSwitchLabel = new wxStaticText(this, -1, _("TX Message")); sizer->Add(txMsgSwitchLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); m_txMsgSwitch = new wxChoice(this, -1, wxDefaultPosition, wxSize(CALLSIGN_WIDTH, -1)); m_txMsgSwitch->Append(_("Off")); m_txMsgSwitch->Append(_("On")); sizer->Add(m_txMsgSwitch, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); m_txMsgSwitch->SetSelection(txMsgSwitch ? 1 : 0); wxStaticText* dummy8Label = new wxStaticText(this, -1, wxEmptyString); sizer->Add(dummy8Label, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); #if defined(DEXTRA_LINK) wxStaticText* reflectorLabel = new wxStaticText(this, -1, _("Reflector")); sizer->Add(reflectorLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); m_reflector = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH1, -1)); m_reflector->Append(_("None")); wxFileName fileName(wxFileName::GetHomeDir(), DEXTRA_HOSTS_FILE_NAME); if (!fileName.IsFileReadable()) { wxLogMessage(wxT("File %s not readable"), fileName.GetFullPath().c_str()); #if defined(__WINDOWS__) fileName.Assign(::wxGetCwd(), DEXTRA_HOSTS_FILE_NAME); #else fileName.Assign(wxT(DATA_DIR), DEXTRA_HOSTS_FILE_NAME); #endif if (!fileName.IsFileReadable()) wxLogMessage(wxT("File %s not readable"), fileName.GetFullPath().c_str()); } CHostFile file(fileName.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) m_reflector->Append(file.getName(i)); sizer->Add(m_reflector, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); if (reflector.IsEmpty()) { m_reflector->SetSelection(0); } else { wxString name = reflector; name.SetChar(LONG_CALLSIGN_LENGTH - 1U, wxT(' ')); bool res = m_reflector->SetStringSelection(name); if (!res) m_reflector->SetSelection(0); } m_channel = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH2, -1)); m_channel->Append(wxT("A")); m_channel->Append(wxT("B")); m_channel->Append(wxT("C")); m_channel->Append(wxT("D")); m_channel->Append(wxT("E")); sizer->Add(m_channel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); res = m_channel->SetStringSelection(reflector.Right(1U)); if (!res) m_channel->SetSelection(0); #endif #if defined(DCS_LINK) wxStaticText* reflectorLabel = new wxStaticText(this, -1, _("Reflector")); sizer->Add(reflectorLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); m_reflector = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH1, -1)); m_reflector->Append(_("None")); wxFileName fileName(wxFileName::GetHomeDir(), DCS_HOSTS_FILE_NAME); if (!fileName.IsFileReadable()) { wxLogMessage(wxT("File %s not readable"), fileName.GetFullPath().c_str()); #if defined(__WINDOWS__) fileName.Assign(::wxGetCwd(), DCS_HOSTS_FILE_NAME); #else fileName.Assign(wxT(DATA_DIR), DCS_HOSTS_FILE_NAME); #endif if (!fileName.IsFileReadable()) wxLogMessage(wxT("File %s not readable"), fileName.GetFullPath().c_str()); } CHostFile file(fileName.GetFullPath(), false); for (unsigned int i = 0U; i < file.getCount(); i++) m_reflector->Append(file.getName(i)); sizer->Add(m_reflector, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); if (reflector.IsEmpty()) { m_reflector->SetSelection(0); } else { wxString name = reflector; name.SetChar(LONG_CALLSIGN_LENGTH - 1U, wxT(' ')); bool res = m_reflector->SetStringSelection(name); if (!res) m_reflector->SetSelection(0); } m_channel = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH2, -1)); m_channel->Append(wxT("A")); m_channel->Append(wxT("B")); m_channel->Append(wxT("C")); m_channel->Append(wxT("D")); m_channel->Append(wxT("E")); m_channel->Append(wxT("F")); m_channel->Append(wxT("G")); m_channel->Append(wxT("H")); m_channel->Append(wxT("I")); m_channel->Append(wxT("J")); m_channel->Append(wxT("K")); m_channel->Append(wxT("L")); m_channel->Append(wxT("M")); m_channel->Append(wxT("N")); m_channel->Append(wxT("O")); m_channel->Append(wxT("P")); m_channel->Append(wxT("Q")); m_channel->Append(wxT("R")); m_channel->Append(wxT("S")); m_channel->Append(wxT("T")); m_channel->Append(wxT("U")); m_channel->Append(wxT("V")); m_channel->Append(wxT("W")); m_channel->Append(wxT("X")); m_channel->Append(wxT("Y")); m_channel->Append(wxT("Z")); sizer->Add(m_channel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); res = m_channel->SetStringSelection(reflector.Right(1U)); if (!res) m_channel->SetSelection(0); #endif SetAutoLayout(true); SetSizer(sizer); } CStarNetSet::~CStarNetSet() { } bool CStarNetSet::Validate() { int n = m_band->GetCurrentSelection(); if (n == wxNOT_FOUND) { wxMessageDialog dialog(this, _("The StarNet Band is not set"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } n = m_userTimeout->GetCurrentSelection(); if (n == wxNOT_FOUND) { wxMessageDialog dialog(this, _("The StarNet user timeout is not set"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } n = m_groupTimeout->GetCurrentSelection(); if (n == wxNOT_FOUND) { wxMessageDialog dialog(this, _("The StarNet group timeout is not set"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } n = m_callsignSwitch->GetCurrentSelection(); if (n == wxNOT_FOUND) { wxMessageDialog dialog(this, _("The MYCALL Setting is not set"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } n = m_txMsgSwitch->GetCurrentSelection(); if (n == wxNOT_FOUND) { wxMessageDialog dialog(this, _("The TX Message switch is not set"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } #if defined(DEXTRA_LINK) || defined(DCS_LINK) n = m_reflector->GetCurrentSelection(); if (n == wxNOT_FOUND) { wxMessageDialog dialog(this, _("The StarNet reflector link is not set"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } #endif return true; }
// }}} // {{{ void MainFrame::OnPreferences(wxCommandEvent &event) void MainFrame::OnPreferences(wxCommandEvent &event) { PrefDialog dialog(this, -1, _("Preferences")); dialog.ShowModal(); }
// Portable installations are assumed to be run in either administrator rights mode, or run // from "insecure media" such as a removable flash drive. In these cases, the default path for // PCSX2 user documents becomes ".", which is the current working directory. // // Portable installation mode is typically enabled via the presence of an INI file in the // same directory that PCSX2 is installed to. // wxConfigBase* Pcsx2App::TestForPortableInstall() { InstallationMode = InstallMode_Registered; const wxFileName portableIniFile( GetPortableIniPath() ); const wxDirName portableDocsFolder( portableIniFile.GetPath() ); if (Startup.PortableMode || portableIniFile.FileExists()) { wxString FilenameStr = portableIniFile.GetFullPath(); if (Startup.PortableMode) Console.WriteLn( L"(UserMode) Portable mode requested via commandline switch!" ); else Console.WriteLn( L"(UserMode) Found portable install ini @ %s", WX_STR(FilenameStr) ); // Just because the portable ini file exists doesn't mean we can actually run in portable // mode. In order to determine our read/write permissions to the PCSX2, we must try to // modify the configured documents folder, and catch any ensuing error. std::unique_ptr<wxFileConfig> conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) ); conf_portable->SetRecordDefaults(false); while( true ) { wxString accessFailedStr, createFailedStr; if (TestUserPermissionsRights( portableDocsFolder, createFailedStr, accessFailedStr )) break; wxDialogWithHelpers dialog( NULL, AddAppName(_("Portable mode error - %s")) ); wxTextCtrl* scrollText = new wxTextCtrl( &dialog, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_MULTILINE | wxTE_WORDWRAP ); if (!createFailedStr.IsEmpty()) scrollText->AppendText( createFailedStr + L"\n" ); if (!accessFailedStr.IsEmpty()) scrollText->AppendText( accessFailedStr + L"\n" ); dialog += dialog.Heading( _("PCSX2 has been installed as a portable application but cannot run due to the following errors:" ) ); dialog += scrollText | pxExpand.Border(wxALL, 16); dialog += 6; dialog += dialog.Text( GetMsg_PortableModeRights() ); // [TODO] : Add url for platform-relevant user permissions tutorials? (low priority) wxWindowID result = pxIssueConfirmation( dialog, MsgButtons().Retry().Cancel().Custom(_("Switch to User Documents Mode"), "switchmode") ); switch (result) { case wxID_CANCEL: throw Exception::StartupAborted( L"User canceled portable mode due to insufficient user access/permissions." ); case wxID_RETRY: // do nothing (continues while loop) break; case pxID_CUSTOM: wxDialogWithHelpers dialog2( NULL, AddAppName(_("%s is switching to local install mode.")) ); dialog2 += dialog2.Heading( _("Try to remove the file called \"portable.ini\" from your installation directory manually." ) ); dialog2 += 6; pxIssueConfirmation( dialog2, MsgButtons().OK() ); return NULL; } } // Success -- all user-based folders have write access. PCSX2 should be able to run error-free! // Force-set the custom documents mode, and set the InstallationMode = InstallMode_Portable; DocsFolderMode = DocsFolder_Custom; CustomDocumentsFolder = portableDocsFolder; return conf_portable.release(); } return NULL; }
void CloudView::showServerStatusDialog() { ServerStatusDialog dialog(this); dialog.exec(); }
void MainWindow::on_actionAbout_triggered() { std::unique_ptr<AboutDialog> dialog(new AboutDialog(this)); dialog->exec(); }
void MainWindow::on_actionInsertRow_triggered() { std::unique_ptr<InsertRowDialog> dialog(new InsertRowDialog(this)); connect(dialog.get(), SIGNAL(rowReady(QString, int)), this, SLOT(onRowReady(QString, int))); dialog->exec(); }
void KnobGui::linkTo(int dimension) { KnobPtr thisKnob = getKnob(); assert(thisKnob); EffectInstance* isEffect = dynamic_cast<EffectInstance*>(thisKnob->getHolder()); if (!isEffect) { return; } for (int i = 0; i < thisKnob->getDimension(); ++i) { if (i == dimension || dimension == -1) { std::string expr = thisKnob->getExpression(dimension); if (!expr.empty()) { Dialogs::errorDialog(tr("Param Link").toStdString(),tr("This parameter already has an expression set, edit or clear it.").toStdString()); return; } } } LinkToKnobDialog dialog( shared_from_this(),_imp->copyRightClickMenu->parentWidget() ); if ( dialog.exec() ) { KnobPtr otherKnob = dialog.getSelectedKnobs(); if (otherKnob) { if ( !thisKnob->isTypeCompatible(otherKnob) ) { Dialogs::errorDialog( tr("Param Link").toStdString(), tr("Types incompatibles!").toStdString() ); return; } for (int i = 0; i < thisKnob->getDimension(); ++i) { std::pair<int,KnobPtr > existingLink = thisKnob->getMaster(i); if (existingLink.second) { std::string err( tr("Cannot link ").toStdString() ); err.append( thisKnob->getLabel() ); err.append( " \n " + tr("because the knob is already linked to ").toStdString() ); err.append( existingLink.second->getLabel() ); Dialogs::errorDialog(tr("Param Link").toStdString(), err); return; } } EffectInstance* otherEffect = dynamic_cast<EffectInstance*>(otherKnob->getHolder()); if (!otherEffect) { return; } std::stringstream expr; boost::shared_ptr<NodeCollection> thisCollection = isEffect->getNode()->getGroup(); NodeGroup* otherIsGroup = dynamic_cast<NodeGroup*>(otherEffect); if (otherIsGroup == thisCollection.get()) { expr << "thisGroup"; // make expression generic if possible } else { expr << otherEffect->getNode()->getFullyQualifiedName(); } expr << "." << otherKnob->getName() << ".get()"; if (otherKnob->getDimension() > 1) { expr << "[dimension]"; } thisKnob->beginChanges(); for (int i = 0; i < thisKnob->getDimension(); ++i) { if (i == dimension || dimension == -1) { thisKnob->setExpression(i, expr.str(), false, false); } } thisKnob->endChanges(); thisKnob->getHolder()->getApp()->triggerAutoSave(); } } }
void ClassDiagramView::add_related_elements(DiagramItem * di, QString what, bool inh, bool assoc) { BrowserNodeList l; RelatedElementsDialog dialog(di->get_bn(), what, inh, assoc, l); dialog.raise(); if ((dialog.exec() == QDialog::Accepted) && !l.isEmpty()) { QApplication::setOverrideCursor(Qt::waitCursor); DiagramItemList items(canvas()->allItems()); Q3PtrDict<DiagramItem> drawn; get_drawn(items, drawn); history_save(); history_protected = TRUE; int xmax = canvas()->width() - Diagram_Margin; int ymax = canvas()->height() - Diagram_Margin; QRect re = di->rect(); int x = re.x(); int y = re.bottom() + Diagram_Margin; int future_y = y; Q3PtrListIterator<BrowserNode> it(l); BrowserNode * bn; for (; (bn = it.current()) != 0; ++it) { if (drawn[bn->get_data()] == 0) { DiagramCanvas * dc; switch (bn->get_type()) { case UmlClass: dc = new CdClassCanvas(bn, the_canvas(), x, y); break; case UmlPackage: dc = new PackageCanvas(bn, the_canvas(), x, y, 0); break; default: continue; } drawn.replace(dc->get_bn()->get_data(), dc); if ((x + dc->width()) > xmax) dc->move(x = Diagram_Margin, y = future_y); if (y + dc->height() > ymax) { dc->move(x = Diagram_Margin, y = Diagram_Margin); future_y = y + dc->height() + Diagram_Margin; } else { int bot = y + dc->height() + Diagram_Margin; if (bot > future_y) future_y = bot; } x = x + dc->width() + Diagram_Margin; dc->show(); dc->upper(); } } canvas()->update(); history_protected = FALSE; window()->package_modified(); QApplication::restoreOverrideCursor(); } }
void MainWindow::openShowInput() { ShowInputDialog dialog(this, m_database); dialog.exec(); }
void PathChooser::slotBrowse() { emit beforeBrowsing(); QString predefined = path(); if ((predefined.isEmpty() || !QFileInfo(predefined).isDir()) && !m_d->m_initialBrowsePathOverride.isNull()) { predefined = m_d->m_initialBrowsePathOverride; if (!QFileInfo(predefined).isDir()) predefined.clear(); } // Prompt for a file/dir QString newPath; switch (m_d->m_acceptingKind) { case PathChooser::Directory: case PathChooser::ExistingDirectory: newPath = QFileDialog::getExistingDirectory(this, makeDialogTitle(tr("Choose Directory")), predefined); break; case PathChooser::ExistingCommand: case PathChooser::Command: newPath = QFileDialog::getOpenFileName(this, makeDialogTitle(tr("Choose Executable")), predefined, m_d->m_dialogFilter); break; case PathChooser::File: // fall through newPath = QFileDialog::getOpenFileName(this, makeDialogTitle(tr("Choose File")), predefined, m_d->m_dialogFilter); break; case PathChooser::Any: { QFileDialog dialog(this); dialog.setFileMode(QFileDialog::AnyFile); dialog.setWindowTitle(makeDialogTitle(tr("Choose File"))); QFileInfo fi(predefined); if (fi.exists()) dialog.setDirectory(fi.absolutePath()); // FIXME: fix QFileDialog so that it filters properly: lib*.a dialog.setNameFilter(m_d->m_dialogFilter); if (dialog.exec() == QDialog::Accepted) { // probably loop here until the *.framework dir match QStringList paths = dialog.selectedFiles(); if (!paths.isEmpty()) newPath = paths.at(0); } break; } default: break; } // Delete trailing slashes unless it is "/"|"\\", only if (!newPath.isEmpty()) { newPath = QDir::toNativeSeparators(newPath); if (newPath.size() > 1 && newPath.endsWith(QDir::separator())) newPath.truncate(newPath.size() - 1); setPath(newPath); } emit browsingFinished(); m_d->m_lineEdit->triggerChanged(); }
void PharmacyReceipt::on_printButton_clicked() { QPrinter printer( QPrinter::PrinterResolution ); QPrintDialog dialog( &printer, this ); if ( dialog.exec() == QDialog::Accepted ) print( &printer ); }
Common::Error Sword2Engine::run() { // Get some falling RAM and put it in your pocket, never let it slip // away _debugger = NULL; _sound = NULL; _fontRenderer = NULL; _screen = NULL; _mouse = NULL; _logic = NULL; _resman = NULL; _memory = NULL; initGraphics(640, 480, true); _screen = new Screen(this, 640, 480); // Create the debugger as early as possible (but not before the // screen object!) so that errors can be displayed in it. In // particular, we want errors about missing files to be clearly // visible to the user. _debugger = new Debugger(this); _memory = new MemoryManager(this); _resman = new ResourceManager(this); if (!_resman->init()) return Common::kUnknownError; _logic = new Logic(this); _fontRenderer = new FontRenderer(this); _sound = new Sound(this); _mouse = new Mouse(this); registerDefaultSettings(); readSettings(); initStartMenu(); // During normal gameplay, we care neither about mouse button releases // nor the scroll wheel. setInputEventFilter(RD_LEFTBUTTONUP | RD_RIGHTBUTTONUP | RD_WHEELUP | RD_WHEELDOWN); setupPersistentResources(); initialiseFontResourceFlags(); if (_features & GF_DEMO) _logic->writeVar(DEMO, 1); else _logic->writeVar(DEMO, 0); if (_saveSlot != -1) { if (saveExists(_saveSlot)) restoreGame(_saveSlot); else { RestoreDialog dialog(this); if (!dialog.runModal()) startGame(); } } else if (!_bootParam && saveExists() && !isPsx()) { // Initial load/restart panel disabled in PSX int32 pars[2] = { 221, FX_LOOP }; // version because of missing panel resources bool result; _mouse->setMouse(NORMAL_MOUSE_ID); _logic->fnPlayMusic(pars); StartDialog dialog(this); result = (dialog.runModal() != 0); // If the game is started from the beginning, the cutscene // player will kill the music for us. Otherwise, the restore // will either have killed the music, or done a crossfade. if (shouldQuit()) return Common::kNoError; if (result) startGame(); } else startGame(); _screen->initialiseRenderCycle(); while (1) { _debugger->onFrame(); // Handle GMM Loading if (_gmmLoadSlot != -1) { // Hide mouse cursor and fade screen _mouse->hideMouse(); _screen->fadeDown(); // Clean up and load game _logic->_router->freeAllRouteMem(); // TODO: manage error handling restoreGame(_gmmLoadSlot); // Reset load slot _gmmLoadSlot = -1; // Show mouse _mouse->addHuman(); } KeyboardEvent *ke = keyboardEvent(); if (ke) { if ((ke->kbd.hasFlags(Common::KBD_CTRL) && ke->kbd.keycode == Common::KEYCODE_d) || ke->kbd.ascii == '#' || ke->kbd.ascii == '~') { _debugger->attach(); } else if (ke->kbd.hasFlags(0) || ke->kbd.hasFlags(Common::KBD_SHIFT)) { switch (ke->kbd.keycode) { case Common::KEYCODE_p: if (isPaused()) { _screen->dimPalette(false); pauseEngine(false); } else { pauseEngine(true); _screen->dimPalette(true); } break; #if 0 // Disabled because of strange rumors about the // credits running spontaneously every few // minutes. case Common::KEYCODE_c: if (!_logic->readVar(DEMO) && !_mouse->isChoosing()) { ScreenInfo *screenInfo = _screen->getScreenInfo(); _logic->fnPlayCredits(NULL); screenInfo->new_palette = 99; } break; #endif default: break; } } } // skip GameCycle if we're paused if (!isPaused()) { _gameCycle++; gameCycle(); } // We can't use this as termination condition for the loop, // because we want the break to happen before updating the // screen again. if (shouldQuit()) break; // creates the debug text blocks _debugger->buildDebugText(); _screen->buildDisplay(); } return Common::kNoError; }
void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event)) { MyDialog dialog( wxT("Test") ); dialog.ShowModal(); }
void IECommandExecutor::DispatchCommand() { LOG(TRACE) << "Entering IECommandExecutor::DispatchCommand"; Response response(this->session_id_); CommandHandlerMap::const_iterator found_iterator = this->command_handlers_.find(this->current_command_.command_type()); if (found_iterator == this->command_handlers_.end()) { LOG(WARN) << "Unable to find command handler for " << this->current_command_.command_type(); response.SetErrorResponse(501, "Command not implemented"); } else { BrowserHandle browser; int status_code = SUCCESS; if (this->current_command_.command_type() != webdriver::CommandType::NewSession) { // There should never be a modal dialog or alert to check for if the command // is the "newSession" command. status_code = this->GetCurrentBrowser(&browser); if (status_code == SUCCESS) { bool alert_is_active = false; HWND alert_handle = browser->GetActiveDialogWindowHandle(); if (alert_handle != NULL) { // Found a window handle, make sure it's an actual alert, // and not a showModalDialog() window. vector<char> window_class_name(34); ::GetClassNameA(alert_handle, &window_class_name[0], 34); if (strcmp(ALERT_WINDOW_CLASS, &window_class_name[0]) == 0) { alert_is_active = true; } else { LOG(WARN) << "Found alert handle does not have a window class consistent with an alert"; } } else { LOG(DEBUG) << "No alert handle is found"; } if (alert_is_active) { Alert dialog(browser, alert_handle); std::string command_type = this->current_command_.command_type(); if (command_type == webdriver::CommandType::GetAlertText || command_type == webdriver::CommandType::SendKeysToAlert || command_type == webdriver::CommandType::AcceptAlert || command_type == webdriver::CommandType::DismissAlert) { LOG(DEBUG) << "Alert is detected, and the sent command is valid"; } else { LOG(DEBUG) << "Unexpected alert is detected, and the sent command is invalid when an alert is present"; std::string alert_text = dialog.GetText(); if (this->unexpected_alert_behavior_ == ACCEPT_UNEXPECTED_ALERTS) { LOG(DEBUG) << "Automatically accepting the alert"; dialog.Accept(); } else if (this->unexpected_alert_behavior_ == DISMISS_UNEXPECTED_ALERTS || command_type == webdriver::CommandType::Quit) { // If a quit command was issued, we should not ignore an unhandled // alert, even if the alert behavior is set to "ignore". LOG(DEBUG) << "Automatically dismissing the alert"; if (dialog.is_standard_alert()) { dialog.Dismiss(); } else { // The dialog was non-standard. The most common case of this is // an onBeforeUnload dialog, which must be accepted to continue. dialog.Accept(); } } if (command_type != webdriver::CommandType::Quit) { // To keep pace with what Firefox does, we'll return the text of the // alert in the error response. Json::Value response_value; response_value["message"] = "Modal dialog present"; response_value["alert"]["text"] = alert_text; response.SetResponse(EMODALDIALOGOPENED, response_value); this->serialized_response_ = response.Serialize(); return; } else { LOG(DEBUG) << "Quit command was issued. Continuing with command after automatically closing alert."; } } } } else { LOG(WARN) << "Unable to find current browser"; } } CommandHandlerHandle command_handler = found_iterator->second; command_handler->Execute(*this, this->current_command_, &response); status_code = this->GetCurrentBrowser(&browser); if (status_code == SUCCESS) { this->is_waiting_ = browser->wait_required(); if (this->is_waiting_) { if (this->page_load_timeout_ >= 0) { this->wait_timeout_ = clock() + (this->page_load_timeout_ / 1000 * CLOCKS_PER_SEC); } ::PostMessage(this->m_hWnd, WD_WAIT, NULL, NULL); } } else { if (this->current_command_.command_type() != webdriver::CommandType::Quit) { LOG(WARN) << "Unable to get current browser"; } } } this->serialized_response_ = response.Serialize(); }
bool CBOINCGUIApp::OnInit() { // Initialize globals #ifdef SANDBOX g_use_sandbox = true; #else g_use_sandbox = false; #endif s_bSkipExitConfirmation = false; m_bFilterEvents = false; m_bAboutDialogIsOpen = false; // Initialize class variables m_pLocale = NULL; m_pSkinManager = NULL; m_pFrame = NULL; m_pDocument = NULL; m_pTaskBarIcon = NULL; m_pEventLog = NULL; #ifdef __WXMAC__ m_pMacDockIcon = NULL; #endif m_strBOINCMGRExecutableName = wxEmptyString; m_strBOINCMGRRootDirectory = wxEmptyString; m_strBOINCMGRDataDirectory = wxEmptyString; m_strHostNameArg = wxEmptyString; m_strPasswordArg = wxEmptyString; m_iRPCPortArg = GUI_RPC_PORT; m_strBOINCArguments = wxEmptyString; m_bGUIVisible = true; m_bDebugSkins = false; m_bMultipleInstancesOK = false; m_bBOINCMGRAutoStarted = false; m_iBOINCMGRDisableAutoStart = 0; m_iShutdownCoreClient = 0; m_iDisplayExitDialog = 1; m_iGUISelected = BOINC_SIMPLEGUI; m_bSafeMessageBoxDisplayed = 0; #ifdef __WXMSW__ m_hClientLibraryDll = NULL; #endif // Initialize local variables int iErrorCode = 0; int iSelectedLanguage = 0; bool bOpenEventLog = false; wxString strDesiredSkinName = wxEmptyString; wxString strDialogMessage = wxEmptyString; bool success = false; // Configure wxWidgets platform specific code #ifdef __WXMSW__ wxSystemOptions::SetOption(wxT("msw.staticbox.optimized-paint"), 0); #endif #ifdef __WXMAC__ // In wxMac-2.8.7, default wxListCtrl::RefreshItem() does not work // so use traditional generic implementation. // This has been fixed in wxMac-2.8.8, but the Mac native implementation: // - takes 3 times the CPU time as the Mac generic version. // - seems to always redraw entire control even if asked to refresh only one row. // - causes major flicker of progress bars, (probably due to full redraws.) wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), 1); AEInstallEventHandler( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP((AEEventHandlerProcPtr)QuitAppleEventHandler), 0, false ); // Cache the current process serial number GetCurrentProcess(&m_psnCurrentProcess); #endif // Commandline parsing is done in wxApp::OnInit() if (!wxApp::OnInit()) { return false; } if (g_use_sandbox) { wxCHANGE_UMASK(2); // Set file creation mask to be writable by both user and group // Our umask will be inherited by all our child processes } // Setup application and company information SetAppName(wxT("BOINC Manager")); SetVendorName(wxT("Space Sciences Laboratory, U.C. Berkeley")); // Initialize the configuration storage module m_pConfig = new wxConfig(GetAppName()); wxConfigBase::Set(m_pConfig); wxASSERT(m_pConfig); // Restore Application State m_pConfig->SetPath(wxT("/")); m_pConfig->Read(wxT("AutomaticallyShutdownClient"), &m_iShutdownCoreClient, 0L); m_pConfig->Read(wxT("DisplayShutdownClientDialog"), &m_iDisplayExitDialog, 1L); m_pConfig->Read(wxT("DisableAutoStart"), &m_iBOINCMGRDisableAutoStart, 0L); m_pConfig->Read(wxT("Language"), &iSelectedLanguage, 0L); m_pConfig->Read(wxT("GUISelection"), &m_iGUISelected, BOINC_SIMPLEGUI); m_pConfig->Read(wxT("EventLogOpen"), &bOpenEventLog); // Should we abort the BOINC Manager startup process? if (m_bBOINCMGRAutoStarted && m_iBOINCMGRDisableAutoStart) { return false; } // Detect where BOINC Manager executable name. DetectExecutableName(); // Detect where BOINC Manager was installed too. DetectRootDirectory(); // Detect where the BOINC Data files are. DetectDataDirectory(); // Switch the current directory to the BOINC Data directory if (!GetDataDirectory().IsEmpty()) { success = wxSetWorkingDirectory(GetDataDirectory()); if (!success) { if (!g_use_sandbox) { if (!wxDirExists(GetDataDirectory())) { success = wxMkdir(GetDataDirectory(), 0777); // Does nothing if dir exists } } } } if (!success) iErrorCode = -1016; // Initialize the BOINC Diagnostics Framework int dwDiagnosticsFlags = BOINC_DIAG_DUMPCALLSTACKENABLED | BOINC_DIAG_HEAPCHECKENABLED | BOINC_DIAG_MEMORYLEAKCHECKENABLED | #if defined(__WXMSW__) || defined(__WXMAC__) BOINC_DIAG_REDIRECTSTDERR | BOINC_DIAG_REDIRECTSTDOUT | #endif BOINC_DIAG_TRACETOSTDOUT; diagnostics_init( dwDiagnosticsFlags, "stdoutgui", "stderrgui" ); // Enable Logging and Trace Masks m_pLog = new wxLogBOINC(); wxLog::SetActiveTarget(m_pLog); m_pLog->AddTraceMask(wxT("Function Start/End")); m_pLog->AddTraceMask(wxT("Function Status")); // Initialize the internationalization module #ifdef __WXMSW__ // On Windows, set all locales for this thread on a per-thread basis _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); #endif m_pLocale = new wxLocale(); wxASSERT(m_pLocale); // Look for the localization files by absolute and relative locations. // preference given to the absolute location. m_pLocale->Init(iSelectedLanguage); if (!m_strBOINCMGRRootDirectory.IsEmpty()) { m_pLocale->AddCatalogLookupPathPrefix( wxString(m_strBOINCMGRRootDirectory + wxT("locale")) ); } m_pLocale->AddCatalogLookupPathPrefix(wxT("locale")); m_pLocale->AddCatalog(wxT("BOINC-Manager")); m_pLocale->AddCatalog(wxT("BOINC-Client")); m_pLocale->AddCatalog(wxT("BOINC-Web")); InitSupportedLanguages(); language = m_pLocale->GetCanonicalName(); // Note: JAWS for Windows will only speak the context-sensitive // help if you use this help provider: wxHelpProvider::Set(new wxHelpControllerHelpProvider()); // Enable known image types wxInitAllImageHandlers(); // Initialize the skin manager m_pSkinManager = new CSkinManager(m_bDebugSkins); wxASSERT(m_pSkinManager); // Load desired manager skin m_pConfig->Read(wxT("Skin"), &strDesiredSkinName, m_pSkinManager->GetDefaultSkinName()); m_pSkinManager->ReloadSkin(strDesiredSkinName); #ifdef SANDBOX // Make sure owners, groups and permissions are correct for the current setting of g_use_sandbox char path_to_error[MAXPATHLEN]; path_to_error[0] = '\0'; if (!iErrorCode) { #if (defined(__WXMAC__) && defined(_DEBUG)) // TODO: implement this for other platforms // GDB can't attach to applications which are running as a different user // or group, so fix up data with current user and group during debugging if (check_security(g_use_sandbox, true, NULL, 0)) { CreateBOINCUsersAndGroups(); SetBOINCDataOwnersGroupsAndPermissions(); SetBOINCAppOwnersGroupsAndPermissions(NULL); } #endif iErrorCode = check_security( g_use_sandbox, true, path_to_error, sizeof(path_to_error) ); } if (iErrorCode) { ShowApplication(true); if (iErrorCode == -1099) { strDialogMessage.Printf( _("You currently are not authorized to manage the client.\n\nTo run %s as this user, please:\n - reinstall %s answering \"Yes\" to the question about\n non-administrative users\n or\n - contact your administrator to add you to the 'boinc_master'\n user group."), m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(), m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str() ); } else { strDialogMessage.Printf( _("%s ownership or permissions are not set properly; please reinstall %s.\n(Error code %d"), m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(), m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(), iErrorCode ); if (path_to_error[0]) { strDialogMessage += _(" at "); strDialogMessage += wxString::FromUTF8(path_to_error); } strDialogMessage += _(")"); fprintf(stderr, "%s\n", (const char*)strDialogMessage.utf8_str()); } wxMessageDialog* pDlg = new wxMessageDialog( NULL, strDialogMessage, m_pSkinManager->GetAdvanced()->GetApplicationName(), wxOK ); pDlg->ShowModal(); if (pDlg) pDlg->Destroy(); return false; } #endif // SANDBOX #ifdef __WXMSW__ // Perform any last minute checks that should keep the manager // from starting up. wxString strRebootPendingFile = GetRootDirectory() + wxFileName::GetPathSeparator() + wxT("RebootPending.txt"); if (wxFile::Exists(strRebootPendingFile)) { wxMessageDialog dialog( NULL, _("A reboot is required in order for BOINC to run properly.\nPlease reboot your computer and try again."), _("BOINC Manager"), wxOK|wxICON_ERROR ); dialog.ShowModal(); return false; } #endif // Detect if BOINC Manager is already running, if so, bring it into the // foreground and then exit. if (!m_bMultipleInstancesOK) { if (DetectDuplicateInstance()) { return false; } } // Initialize the main document m_pDocument = new CMainDocument(); wxASSERT(m_pDocument); m_pDocument->OnInit(); // Is there a condition in which the Simple GUI should not be used? if (BOINC_SIMPLEGUI == m_iGUISelected) { // Screen too small? if (wxGetDisplaySize().GetHeight() < 600) { m_iGUISelected = BOINC_ADVANCEDGUI; } } // Initialize the task bar icon m_pTaskBarIcon = new CTaskBarIcon( m_pSkinManager->GetAdvanced()->GetApplicationName(), #ifdef __WXMSW__ new wxIcon(wxICON(BOINCGUIAPP)), #else m_pSkinManager->GetAdvanced()->GetApplicationIcon(), #endif m_pSkinManager->GetAdvanced()->GetApplicationDisconnectedIcon(), m_pSkinManager->GetAdvanced()->GetApplicationSnoozeIcon() #ifdef __WXMAC__ , wxTBI_CUSTOM_STATUSITEM #endif ); #ifdef __WXMAC__ m_pMacDockIcon = new CTaskBarIcon( m_pSkinManager->GetAdvanced()->GetApplicationName(), m_pSkinManager->GetAdvanced()->GetApplicationIcon(), m_pSkinManager->GetAdvanced()->GetApplicationDisconnectedIcon(), m_pSkinManager->GetAdvanced()->GetApplicationSnoozeIcon() , wxTBI_DOCK ); wxASSERT(m_pMacDockIcon); #endif wxASSERT(m_pTaskBarIcon); // Startup the System Idle Detection code IdleTrackerAttach(); #ifdef __WXMAC__ ProcessSerialNumber psn; ProcessInfoRec pInfo; OSStatus err; memset(&pInfo, 0, sizeof(pInfo)); pInfo.processInfoLength = sizeof( ProcessInfoRec ); err = GetProcessInformation(&m_psnCurrentProcess, &pInfo); if (!err) { psn = pInfo.processLauncher; memset(&pInfo, 0, sizeof(pInfo)); pInfo.processInfoLength = sizeof( ProcessInfoRec ); err = GetProcessInformation(&psn, &pInfo); } // Don't open main window if we were started automatically at login if (pInfo.processSignature == 'lgnw') { // Login Window app m_bGUIVisible = false; // If the system was just started, we usually get a "Connection // failed" error if we try to connect too soon, so delay a bit. sleep(10); } #endif // Show the UI SetActiveGUI(m_iGUISelected, m_bGUIVisible); if (!m_bGUIVisible) { #ifdef __WXMAC__ // We don't call Hide() or Show(false) for the main frame // under wxCocoa 2.9.5 because it bounces the Dock icon // (as in notification.) We work around this by moving // the main window/frame off screen here. // The position will be restored in one of these methods: // CBOINCGUIApp::OnActivateApp(), CSimpleFrame::SaveState() // or CAdvancedFrame::SaveWindowDimensions(). if (m_pFrame) { m_pFrame->MoveFrameOffScreen(); m_pFrame->Show(); } #endif ShowApplication(false); } if (bOpenEventLog) { DisplayEventLog(m_bGUIVisible); if (m_bGUIVisible && m_pFrame) { m_pFrame->Raise(); } } return true; }
bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) { sm_abortIt = false; sm_abortWindow = NULL; if (!printout) { sm_lastError = wxPRINTER_ERROR; return false; } if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) m_printDialogData.SetMaxPage(9999); // Create a suitable device context wxPrinterDC *dc = NULL; if (prompt) { wxMacPrintDialog dialog(parent, & m_printDialogData); if (dialog.ShowModal() == wxID_OK) { dc = wxDynamicCast(dialog.GetPrintDC(), wxPrinterDC); wxASSERT(dc); m_printDialogData = dialog.GetPrintDialogData(); } } else { dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; } // May have pressed cancel. if (!dc || !dc->IsOk()) { delete dc; return false; } // on the mac we have always pixels as addressing mode with 72 dpi printout->SetPPIScreen(72, 72); PMResolution res; PMPrinter printer; wxOSXPrintData* nativeData = (wxOSXPrintData*) (m_printDialogData.GetPrintData().GetNativeData()); if (PMSessionGetCurrentPrinter(nativeData->GetPrintSession(), &printer) == noErr) { if (PMPrinterGetOutputResolution( printer, nativeData->GetPrintSettings(), &res) == -9589 /* kPMKeyNotFound */ ) { res.hRes = res.vRes = 300; } } else { // fallback res.hRes = res.vRes = 300; } printout->SetPPIPrinter(int(res.hRes), int(res.vRes)); // Set printout parameters printout->SetDC(dc); int w, h; dc->GetSize(&w, &h); printout->SetPageSizePixels((int)w, (int)h); printout->SetPaperRectPixels(dc->GetPaperRect()); wxCoord mw, mh; dc->GetSizeMM(&mw, &mh); printout->SetPageSizeMM((int)mw, (int)mh); // Create an abort window wxBeginBusyCursor(); printout->OnPreparePrinting(); // Get some parameters from the printout, if defined int fromPage, toPage; int minPage, maxPage; printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); if (maxPage == 0) { sm_lastError = wxPRINTER_ERROR; return false; } // Only set min and max, because from and to will be // set by the user m_printDialogData.SetMinPage(minPage); m_printDialogData.SetMaxPage(maxPage); printout->OnBeginPrinting(); bool keepGoing = true; if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) { wxEndBusyCursor(); wxMessageBox(wxT("Could not start printing."), wxT("Print Error"), wxOK, parent); } int pn; for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); pn++) { if (sm_abortIt) { break; } else { dc->StartPage(); keepGoing = printout->OnPrintPage(pn); dc->EndPage(); } } printout->OnEndDocument(); printout->OnEndPrinting(); if (sm_abortWindow) { sm_abortWindow->Show(false); wxDELETE(sm_abortWindow); } wxEndBusyCursor(); delete dc; return true; }
void TimetableGenerateForm::stopHighest() { if(!simulation_running){ return; } simulation_running=false; myMutex.lock(); gen.abortOptimization=true; myMutex.unlock(); myMutex.lock(); Solution& c=highestStageSolution; //needed to find the conflicts strings QString tmp; c.fitness(gt.rules, &tmp); TimetableExport::getStudentsTimetable(c); TimetableExport::getTeachersTimetable(c); TimetableExport::getRoomsTimetable(c); //update the string representing the conflicts conflictsStringTitle=TimetableGenerateForm::tr("Conflicts", "Title of dialog"); conflictsString=""; conflictsString+=TimetableGenerateForm::tr("Total conflicts:"); conflictsString+=" "; conflictsString+=CustomFETString::number(c.conflictsTotal); conflictsString+="\n"; conflictsString+=TimetableGenerateForm::tr("Conflicts listing (in decreasing order):"); conflictsString+="\n"; foreach(QString t, c.conflictsDescriptionList) conflictsString+=t+"\n"; TimetableExport::writeHighestStageResults(this); QString s=TimetableGenerateForm::tr("Simulation interrupted! FET could not find a timetable." " Maybe you can consider lowering the constraints."); s+=" "; QString kk; kk=FILE_SEP; if(INPUT_FILENAME_XML=="") kk.append("unnamed"); else{ kk.append(INPUT_FILENAME_XML.right(INPUT_FILENAME_XML.length()-INPUT_FILENAME_XML.lastIndexOf(FILE_SEP)-1)); if(kk.right(4)==".fet") kk=kk.left(kk.length()-4); } kk.append("-highest"); s+=TimetableGenerateForm::tr("The partial highest-stage results were saved in the directory %1") .arg(QDir::toNativeSeparators(OUTPUT_DIR+FILE_SEP+"timetables"+kk)); s+="\n\n"; s+=TimetableGenerateForm::tr("Additional information relating impossible to schedule activities:"); s+="\n\n"; s+=tr("FET managed to schedule correctly the first %1 most difficult activities." " You can see initial order of placing the activities in the generate dialog. The activity which might cause problems" " might be the next activity in the initial order of evaluation. This activity is listed below:") .arg(maxActivitiesPlaced); s+="\n\n"; s+=tr("Please check constraints related to following possibly problematic activity (or teacher(s), or students set(s)):"); s+="\n"; s+="-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "; s+="\n"; if(maxActivitiesPlaced>=0 && maxActivitiesPlaced<gt.rules.nInternalActivities && initialOrderOfActivitiesIndices[maxActivitiesPlaced]>=0 && initialOrderOfActivitiesIndices[maxActivitiesPlaced]<gt.rules.nInternalActivities){ int ai=initialOrderOfActivitiesIndices[maxActivitiesPlaced]; s+=TimetableGenerateForm::tr("Id: %1 (%2)", "%1 is id of activity, %2 is detailed description of activity") .arg(gt.rules.internalActivitiesList[ai].id) .arg(getActivityDetailedDescription(gt.rules, gt.rules.internalActivitiesList[ai].id)); } else s+=tr("Difficult activity cannot be computed - please report possible bug"); s+="\n"; myMutex.unlock(); //show the message in a dialog QDialog dialog(this); dialog.setWindowTitle(TimetableGenerateForm::tr("Generation stopped (highest stage)", "The title of a dialog, meaning that the generation of the timetable was stopped " "and highest stage timetable written.")); QVBoxLayout* vl=new QVBoxLayout(&dialog); QPlainTextEdit* te=new QPlainTextEdit(); te->setPlainText(s); te->setReadOnly(true); QPushButton* pb=new QPushButton(TimetableGenerateForm::tr("OK")); QHBoxLayout* hl=new QHBoxLayout(0); hl->addStretch(1); hl->addWidget(pb); vl->addWidget(te); vl->addLayout(hl); connect(pb, SIGNAL(clicked()), &dialog, SLOT(close())); dialog.resize(700,500); centerWidgetOnScreen(&dialog); restoreFETDialogGeometry(&dialog, settingsName); setParentAndOtherThings(&dialog, this); dialog.exec(); saveFETDialogGeometry(&dialog, settingsName); startPushButton->setEnabled(true); stopPushButton->setDisabled(true); stopHighestPushButton->setDisabled(true); closePushButton->setEnabled(true); writeResultsPushButton->setDisabled(true); writeHighestStagePushButton->setDisabled(true); seeImpossiblePushButton->setDisabled(true); }
/** * Opens and inits all sound sample files. */ void SoundManager::openSampleFiles() { // Floppy and demo versions have no sample files, except for the Discworld 2 demo if (_vm->getFeatures() & GF_FLOPPY || (IsDemo && !TinselV2)) return; TinselFile f; if (_sampleIndex) // already allocated return; // open sample index file in binary mode if (f.open(_vm->getSampleIndex(sampleLanguage))) { // get length of index file f.seek(0, SEEK_END); // move to end of file _sampleIndexLen = f.pos(); // get file pointer f.seek(0, SEEK_SET); // back to beginning if (_sampleIndex == NULL) { // allocate a buffer for the indices _sampleIndex = (uint32 *)malloc(_sampleIndexLen); // make sure memory allocated if (_sampleIndex == NULL) { // disable samples if cannot alloc buffer for indices // TODO: Disabled sound if we can't load the sample index? return; } } // load data if (f.read(_sampleIndex, _sampleIndexLen) != (uint32)_sampleIndexLen) // file must be corrupt if we get to here error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); // close the file f.close(); // convert file size to size in DWORDs _sampleIndexLen /= sizeof(uint32); #ifdef SCUMM_BIG_ENDIAN // Convert all ids from LE to native format for (int i = 0; i < _sampleIndexLen; ++i) { _sampleIndex[i] = SWAP_BYTES_32(_sampleIndex[i]); } #endif // Detect format of soundfile by looking at 1st sample-index switch (TO_BE_32(_sampleIndex[0])) { case MKID_BE('MP3 '): debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected MP3 sound-data"); _soundMode = kMP3Mode; break; case MKID_BE('OGG '): debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected OGG sound-data"); _soundMode = kVorbisMode; break; case MKID_BE('FLAC'): debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected FLAC sound-data"); _soundMode = kFLACMode; break; default: debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected original sound-data"); break; } // Normally the 1st sample-index points to nothing at all _sampleIndex[0] = 0; } else { char buf[50]; sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleIndex(sampleLanguage)); GUI::MessageDialog dialog(buf, "OK"); dialog.runModal(); error(CANNOT_FIND_FILE, _vm->getSampleIndex(sampleLanguage)); } // open sample file in binary mode if (!_sampleStream.open(_vm->getSampleFile(sampleLanguage))) { char buf[50]; sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleFile(sampleLanguage)); GUI::MessageDialog dialog(buf, "OK"); dialog.runModal(); error(CANNOT_FIND_FILE, _vm->getSampleFile(sampleLanguage)); } /* // gen length of the largest sample sampleBuffer.size = _sampleStream.readUint32LE(); if (_sampleStream.eos() || _sampleStream.err()) error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); */ }
void TimetableGenerateForm::impossibleToSolve() { if(!simulation_running){ return; } simulation_running=false; myMutex.lock(); gen.abortOptimization=true; myMutex.unlock(); myMutex.lock(); Solution& c=gen.c; //needed to find the conflicts strings QString tmp; c.fitness(gt.rules, &tmp); TimetableExport::getStudentsTimetable(c); TimetableExport::getTeachersTimetable(c); TimetableExport::getRoomsTimetable(c); //update the string representing the conflicts conflictsStringTitle=TimetableGenerateForm::tr("Conflicts", "Title of dialog"); conflictsString=""; conflictsString+=TimetableGenerateForm::tr("Total conflicts:"); conflictsString+=" "; conflictsString+=CustomFETString::number(c.conflictsTotal); conflictsString+="\n"; conflictsString+=TimetableGenerateForm::tr("Conflicts listing (in decreasing order):"); conflictsString+="\n"; foreach(QString t, c.conflictsDescriptionList) conflictsString+=t+"\n"; TimetableExport::writeSimulationResults(this); QString s=TimetableGenerateForm::tr("Simulation impossible! Maybe you can consider lowering the constraints."); s+=" "; QString kk; kk=FILE_SEP; if(INPUT_FILENAME_XML=="") kk.append("unnamed"); else{ kk.append(INPUT_FILENAME_XML.right(INPUT_FILENAME_XML.length()-INPUT_FILENAME_XML.lastIndexOf(FILE_SEP)-1)); if(kk.right(4)==".fet") kk=kk.left(kk.length()-4); } kk.append("-single"); s+=TimetableGenerateForm::tr("The partial results were saved in the directory %1") .arg(QDir::toNativeSeparators(OUTPUT_DIR+FILE_SEP+"timetables"+kk)); s+="\n\n"; s+=TimetableGenerateForm::tr("Additional information relating impossible to schedule activities:"); s+="\n\n"; s+=TimetableGenerateForm::tr("Please check the constraints related to the " "activity below, which might be impossible to schedule:"); s+="\n\n"; for(int i=0; i<gen.nDifficultActivities; i++){ int ai=gen.difficultActivities[i]; s+=TimetableGenerateForm::tr("No: %1").arg(i+1); s+=", "; s+=TimetableGenerateForm::tr("Id: %1 (%2)", "%1 is id of activity, %2 is detailed description of activity") .arg(gt.rules.internalActivitiesList[ai].id) .arg(getActivityDetailedDescription(gt.rules, gt.rules.internalActivitiesList[ai].id)); s+="\n"; } myMutex.unlock(); //show the message in a dialog QDialog dialog(this); dialog.setWindowTitle(TimetableGenerateForm::tr("Generation impossible", "The title of a dialog, meaning that the generation of the timetable is impossible.")); QVBoxLayout* vl=new QVBoxLayout(&dialog); QPlainTextEdit* te=new QPlainTextEdit(); te->setPlainText(s); te->setReadOnly(true); QPushButton* pb=new QPushButton(TimetableGenerateForm::tr("OK")); QHBoxLayout* hl=new QHBoxLayout(0); hl->addStretch(1); hl->addWidget(pb); vl->addWidget(te); vl->addLayout(hl); connect(pb, SIGNAL(clicked()), &dialog, SLOT(close())); dialog.resize(700,500); centerWidgetOnScreen(&dialog); restoreFETDialogGeometry(&dialog, settingsName); setParentAndOtherThings(&dialog, this); dialog.exec(); saveFETDialogGeometry(&dialog, settingsName); startPushButton->setEnabled(true); stopPushButton->setDisabled(true); stopHighestPushButton->setDisabled(true); closePushButton->setEnabled(true); writeResultsPushButton->setDisabled(true); writeHighestStagePushButton->setDisabled(true); seeImpossiblePushButton->setDisabled(true); }
void CGameListCtrl::ScanForISOs() { ClearIsoFiles(); CFileSearch::XStringVector Directories(SConfig::GetInstance().m_ISOFolder); if (SConfig::GetInstance().m_RecursiveISOFolder) { for (u32 i = 0; i < Directories.size(); i++) { File::FSTEntry FST_Temp; File::ScanDirectoryTree(Directories[i], FST_Temp); for (auto& Entry : FST_Temp.children) { if (Entry.isDirectory) { bool duplicate = false; for (auto& Directory : Directories) { if (Directory == Entry.physicalName) { duplicate = true; break; } } if (!duplicate) Directories.push_back(Entry.physicalName); } } } } CFileSearch::XStringVector Extensions; if (SConfig::GetInstance().m_ListGC) Extensions.push_back("*.gcm"); if (SConfig::GetInstance().m_ListWii || SConfig::GetInstance().m_ListGC) { Extensions.push_back("*.iso"); Extensions.push_back("*.ciso"); Extensions.push_back("*.gcz"); Extensions.push_back("*.wbfs"); } if (SConfig::GetInstance().m_ListWad) Extensions.push_back("*.wad"); CFileSearch FileSearch(Extensions, Directories); const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames(); if (rFilenames.size() > 0) { wxProgressDialog dialog( _("Scanning for ISOs"), _("Scanning..."), (int)rFilenames.size() - 1, this, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME | wxPD_SMOOTH // - makes updates as small as possible (down to 1px) ); for (u32 i = 0; i < rFilenames.size(); i++) { std::string FileName; SplitPath(rFilenames[i], nullptr, &FileName, nullptr); // Update with the progress (i) and the message dialog.Update(i, wxString::Format(_("Scanning %s"), StrToWxStr(FileName))); if (dialog.WasCancelled()) break; auto iso_file = std::make_unique<GameListItem>(rFilenames[i]); if (iso_file->IsValid()) { bool list = true; switch(iso_file->GetPlatform()) { case GameListItem::WII_DISC: if (!SConfig::GetInstance().m_ListWii) list = false; break; case GameListItem::WII_WAD: if (!SConfig::GetInstance().m_ListWad) list = false; break; default: if (!SConfig::GetInstance().m_ListGC) list = false; break; } switch(iso_file->GetCountry()) { case DiscIO::IVolume::COUNTRY_TAIWAN: if (!SConfig::GetInstance().m_ListTaiwan) list = false; case DiscIO::IVolume::COUNTRY_KOREA: if (!SConfig::GetInstance().m_ListKorea) list = false; break; case DiscIO::IVolume::COUNTRY_JAPAN: if (!SConfig::GetInstance().m_ListJap) list = false; break; case DiscIO::IVolume::COUNTRY_USA: if (!SConfig::GetInstance().m_ListUsa) list = false; break; case DiscIO::IVolume::COUNTRY_FRANCE: if (!SConfig::GetInstance().m_ListFrance) list = false; break; case DiscIO::IVolume::COUNTRY_ITALY: if (!SConfig::GetInstance().m_ListItaly) list = false; break; default: if (!SConfig::GetInstance().m_ListPal) list = false; break; } if (list) m_ISOFiles.push_back(iso_file.release()); } } } if (SConfig::GetInstance().m_ListDrives) { const std::vector<std::string> drives = cdio_get_devices(); for (const auto& drive : drives) { auto gli = std::make_unique<GameListItem>(drive); if (gli->IsValid()) m_ISOFiles.push_back(gli.release()); } } std::sort(m_ISOFiles.begin(), m_ISOFiles.end()); }
bool DefaultDetail::IsValid() { #if 1 wxColour REQUIRED_COL = wxColour(230, 250, 255); wxColour VALID_COL = wxColour(255, 255, 255); wxColour NOT_VALID_COL = wxColour(255, 255, 135); wxGrid* grid = GetView(); int maxrows = GetNumberRows(); int maxcols = GetNumberCols(); bool m_valid = true; int error_count = 0; int first_error_row = -1; int first_error_col = -1; wxProgressDialog dialog(VALIDATING_DETAIL_PROCESS_TITLE, VALIDATING_DETAIL_PROCESS_MESSAGES, maxrows, GetView(), wxPD_AUTO_HIDE | wxPD_APP_MODAL ); for (int i=0; i<maxrows; i++) { //------ dialog update if ( i % (maxrows/20 + 1) == 0 ) { dialog.Update(i); } for (int j=0; j<maxcols; j++) { ElementDescriptor* ed = GetColumnDescriptor(j); wxString value = GetValue(i, j); // ----- convert to Upper Case if ( ed->GetType().Cmp("text") == 0 ) { SetValue(i, j, value.Upper()); } //------ remove last <CR> or <LF> if ( (GetValue(i, j).Last() == '\r') || (GetValue(i, j).Last() == '\n')) { SetValue(i, j, GetValue(i, j).RemoveLast()); } //------ parsing dates if ( (ed->GetType().Cmp("date")==0)||(ed->GetType().Cmp("longdate")==0) ) { wxDateTime date; if ( value.Cmp(" / / ")==0 ) { grid->SetCellValue(i, j, ""); } else if ( date.ParseFormat(value, "%m/%d/%Y") ) { grid->SetCellValue(i, j, date.Format("%m/%d/%Y")); }; } //------ Verification if ( !ed->IsValid( GetValue(i, j) ) ) { grid->SetCellBackgroundColour(i, j, NOT_VALID_COL); m_valid = false; error_count++; if ( error_count > MAX_ERRORS ) { break; } } else { if ( grid->GetCellBackgroundColour(i, j) == NOT_VALID_COL ) { if ( ed->IsRequired() ) { grid->SetCellBackgroundColour(i, j, REQUIRED_COL); } else { grid->SetCellBackgroundColour(i, j, VALID_COL); } } } //------ goto first error if ( (error_count == 1) && (first_error_row == -1) && (first_error_col == -1)) { first_error_row = i; first_error_row = j; grid->SetGridCursor(i, j); grid->MakeCellVisible(i, j); } } if ( error_count > MAX_ERRORS ) { break; } } dialog.Update(maxrows); grid->ForceRefresh(); if ( error_count > MAX_ERRORS ) { wxMessageBox(VALIDATING_DETAIL_TOO_MUCH_ERRORS, VALIDATING_DETAIL_TOO_MUCH_ERRORS_TITLE, wxOK | wxCENTRE | wxICON_EXCLAMATION ); } return m_valid; #else return true; #endif };
void MainMenu::menu_action(MenuItem* item) { switch (item->id) { case MNID_STARTGAME: // World selection menu MenuManager::instance().push_menu(MenuStorage::WORLDSET_MENU); break; case MNID_ADDONS: // Add-ons Menu MenuManager::instance().push_menu(MenuStorage::ADDON_MENU); break; case MNID_CREDITS: MenuManager::instance().clear_menu_stack(); if(g_config->transitions_enabled) { ScreenManager::current()->push_screen(std::unique_ptr<Screen>(new TextScroller("credits.txt")), std::unique_ptr<ScreenFade>(new FadeOut(0.5))); } else { ScreenManager::current()->push_screen(std::unique_ptr<Screen>(new TextScroller("credits.txt"))); } break; case MNID_QUITMAINMENU: if (true) { // instantly exit the game MenuManager::instance().clear_menu_stack(); if(g_config->transitions_enabled) { ScreenManager::current()->quit(std::unique_ptr<ScreenFade>(new FadeOut(0.25))); } else { ScreenManager::current()->quit(); } SoundManager::current()->stop_music(0.25); } else { // confirmation dialog std::unique_ptr<Dialog> dialog(new Dialog); dialog->set_text(_("Do you really want to quit SuperTux?")); dialog->add_cancel_button(_("Cancel")); dialog->add_default_button(_("Quit SuperTux"), [] { MenuManager::instance().clear_menu_stack(); if(g_config->transitions_enabled) { ScreenManager::current()->quit(std::unique_ptr<ScreenFade>(new FadeOut(0.25))); } else { ScreenManager::current()->quit(); } SoundManager::current()->stop_music(0.25); }); MenuManager::instance().set_dialog(std::move(dialog)); } break; } }
bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) { int itemsCount = 0; bool nextcmd = false; MODULE* currentModule = GetBoard()->m_Modules; if( GetScreen()->m_BlockLocate.GetCount() ) { // Set the SELECTED flag of all preselected items, and clear preselect list ClearMarkItems( currentModule ); PICKED_ITEMS_LIST* list = &GetScreen()->m_BlockLocate.GetItems(); for( unsigned ii = 0, e = list->GetCount(); ii < e; ++ii ) { BOARD_ITEM* item = (BOARD_ITEM*) list->GetPickedItem( ii ); item->SetFlags( SELECTED ); ++itemsCount; } GetScreen()->m_BlockLocate.ClearItemsList(); } switch( GetScreen()->m_BlockLocate.GetCommand() ) { case BLOCK_IDLE: DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); break; case BLOCK_DRAG: // Drag case BLOCK_DRAG_ITEM: // Drag a given item (not used here) case BLOCK_MOVE: // Move case BLOCK_COPY: // Copy case BLOCK_COPY_AND_INCREMENT: // Specific to duplicate with increment command // Find selected items if we didn't already set them manually if( itemsCount == 0 ) itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) { nextcmd = true; if( m_canvas->IsMouseCaptured() ) { m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); } GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); m_canvas->Refresh( true ); } break; case BLOCK_MOVE_EXACT: itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) { wxPoint translation; double rotation = 0; DIALOG_MOVE_EXACT dialog( this, translation, rotation ); int ret = dialog.ShowModal(); if( ret == wxID_OK ) { SaveCopyInUndoList( currentModule, UR_MODEDIT ); const wxPoint blockCentre = GetScreen()->m_BlockLocate.Centre(); MoveMarkedItemsExactly( currentModule, blockCentre, translation, rotation ); } } break; case BLOCK_PRESELECT_MOVE: // Move with preselection list nextcmd = true; m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); break; case BLOCK_DELETE: // Delete itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) SaveCopyInUndoList( currentModule, UR_MODEDIT ); DeleteMarkedItems( currentModule ); break; case BLOCK_SAVE: // Save case BLOCK_PASTE: break; case BLOCK_ROTATE: itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) SaveCopyInUndoList( currentModule, UR_MODEDIT ); RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); break; case BLOCK_MIRROR_X: case BLOCK_MIRROR_Y: case BLOCK_FLIP: // mirror itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) SaveCopyInUndoList( currentModule, UR_MODEDIT ); MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); break; case BLOCK_ZOOM: // Window Zoom Window_Zoom( GetScreen()->m_BlockLocate ); break; case BLOCK_ABORT: break; case BLOCK_SELECT_ITEMS_ONLY: break; } if( !nextcmd ) { if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY ) { ClearMarkItems( currentModule ); } GetScreen()->ClearBlockCommand(); SetCurItem( NULL ); m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false ); m_canvas->Refresh( true ); } return nextcmd; }
void VegetationTool::grassTexture() { DialogGrassTexture dialog(base,base_io,assets,this); dialog.exec(); }
void Archive::save(Basket *basket, bool withSubBaskets, const QString &destination) { QDir dir; KProgressDialog dialog(0, i18n("Save as Basket Archive"), i18n("Saving as basket archive. Please wait..."), /*Not modal, for password dialogs!*/false); dialog.showCancelButton(false); dialog.setAutoClose(true); dialog.show(); QProgressBar *progress = dialog.progressBar(); progress->setRange(0,/*Preparation:*/1 + /*Finishing:*/1 + /*Basket:*/1 + /*SubBaskets:*/(withSubBaskets ? Global::bnpView->basketCount(Global::bnpView->listViewItemForBasket(basket)) : 0)); progress->setValue(0); // Create the temporary folder: QString tempFolder = Global::savesFolder() + "temp-archive/"; dir.mkdir(tempFolder); // Create the temporary archive file: QString tempDestination = tempFolder + "temp-archive.tar.gz"; KTar tar(tempDestination, "application/x-gzip"); tar.open(QIODevice::WriteOnly); tar.writeDir("baskets", "", ""); progress->setValue(progress->value()+1); // Preparation finished kDebug() << "Preparation finished out of " << progress->maximum(); // Copy the baskets data into the archive: QStringList backgrounds; Archive::saveBasketToArchive(basket, withSubBaskets, &tar, backgrounds, tempFolder, progress); // Create a Small baskets.xml Document: QDomDocument document("basketTree"); QDomElement root = document.createElement("basketTree"); document.appendChild(root); Global::bnpView->saveSubHierarchy(Global::bnpView->listViewItemForBasket(basket), document, root, withSubBaskets); Basket::safelySaveToFile(tempFolder + "baskets.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + document.toString()); tar.addLocalFile(tempFolder + "baskets.xml", "baskets/baskets.xml"); dir.remove(tempFolder + "baskets.xml"); // Save a Small tags.xml Document: QList<Tag*> tags; listUsedTags(basket, withSubBaskets, tags); Tag::saveTagsTo(tags, tempFolder + "tags.xml"); tar.addLocalFile(tempFolder + "tags.xml", "tags.xml"); dir.remove(tempFolder + "tags.xml"); // Save Tag Emblems (in case they are loaded on a computer that do not have those icons): QString tempIconFile = tempFolder + "icon.png"; for (Tag::List::iterator it = tags.begin(); it != tags.end(); ++it) { State::List states = (*it)->states(); for (State::List::iterator it2 = states.begin(); it2 != states.end(); ++it2) { State *state = (*it2); QPixmap icon = KIconLoader::global()->loadIcon( state->emblem(), KIconLoader::Small, 16, KIconLoader::DefaultState, QStringList(), 0L, true ); if (!icon.isNull()) { icon.save(tempIconFile, "PNG"); QString iconFileName = state->emblem().replace('/', '_'); tar.addLocalFile(tempIconFile, "tag-emblems/" + iconFileName); } } } dir.remove(tempIconFile); // Finish Tar.Gz Exportation: tar.close(); // Computing the File Preview: Basket *previewBasket = basket; // FIXME: Use the first non-empty basket! QPixmap previewPixmap(previewBasket->visibleWidth(), previewBasket->visibleHeight()); QPainter painter(&previewPixmap); // Save old state, and make the look clean ("smile, you are filmed!"): NoteSelection *selection = previewBasket->selectedNotes(); previewBasket->unselectAll(); Note *focusedNote = previewBasket->focusedNote(); previewBasket->setFocusedNote(0); previewBasket->doHoverEffects(0, Note::None); // Take the screenshot: previewBasket->drawContents(&painter, 0, 0, previewPixmap.width(), previewPixmap.height()); // Go back to the old look: previewBasket->selectSelection(selection); previewBasket->setFocusedNote(focusedNote); previewBasket->doHoverEffects(); // End and save our splandid painting: painter.end(); QImage previewImage = previewPixmap.toImage(); const int PREVIEW_SIZE = 256; previewImage = previewImage.scaled(PREVIEW_SIZE, PREVIEW_SIZE, Qt::KeepAspectRatio); previewImage.save(tempFolder + "preview.png", "PNG"); // Finaly Save to the Real Destination file: QFile file(destination); if (file.open(QIODevice::WriteOnly)) { ulong previewSize = QFile(tempFolder + "preview.png").size(); ulong archiveSize = QFile(tempDestination).size(); QTextStream stream(&file); stream.setCodec("ISO-8859-1"); stream << "BasKetNP:archive\n" << "version:0.6.1\n" // << "read-compatible:0.6.1\n" // << "write-compatible:0.6.1\n" << "preview*:" << previewSize << "\n"; stream.flush(); // Copy the Preview File: const unsigned long BUFFER_SIZE = 1024; char *buffer = new char[BUFFER_SIZE]; long sizeRead; QFile previewFile(tempFolder + "preview.png"); if (previewFile.open(QIODevice::ReadOnly)) { while ((sizeRead = previewFile.read(buffer, BUFFER_SIZE)) > 0) file.write(buffer, sizeRead); } stream << "archive*:" << archiveSize << "\n"; stream.flush(); // Copy the Archive File: QFile archiveFile(tempDestination); if (archiveFile.open(QIODevice::ReadOnly)) { while ((sizeRead = archiveFile.read(buffer, BUFFER_SIZE)) > 0) file.write(buffer, sizeRead); } // Clean Up: delete buffer; buffer = 0; file.close(); } progress->setValue(progress->value()+1); // Finishing finished kDebug() << "Finishing finished"; // Clean Up Everything: dir.remove(tempFolder + "preview.png"); dir.remove(tempDestination); dir.rmdir(tempFolder); }