bool MainWindow::IsOKToCloseDocument() { if (fDoc && fDoc->fDirty) { int res = QMessageBox::warning(this, tr("Papagayo"), tr("The document has been modified.\n" "Do you want to save your changes?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); if (res == QMessageBox::Yes) { onFileSave(); if (fDoc->fDirty) return false; else return true; } else if (res == QMessageBox::No) { return true; } else if (res == QMessageBox::Cancel) { return false; } } return true; }
void EditorTabs::onFileSaveAll() { for (int i = 0; i < tabBar()->count(); i++) { onFileSave(i); } }
AS_NAMESPACE_START EditorTabs::EditorTabs(QWidget *parent) : QTabWidget(parent), _finder(nullptr) { _connections << connect(parent, SIGNAL(editCopy()), this, SLOT(onEditCopy())); _connections << connect(parent, SIGNAL(editCut()), this, SLOT(onEditCut())); _connections << connect(parent, SIGNAL(editFind()), this, SLOT(onEditFind())); _connections << connect(parent, SIGNAL(editGoto()), this, SLOT(onEditGoto())); _connections << connect(parent, SIGNAL(editPaste()), this, SLOT(onEditPaste())); _connections << connect(parent, SIGNAL(editRedo()), this, SLOT(onEditRedo())); _connections << connect(parent, SIGNAL(editReplace()), this, SLOT(onEditReplace())); _connections << connect(parent, SIGNAL(editUndo()), this, SLOT(onEditUndo())); _connections << connect(parent, SIGNAL(fileClose()), this, SLOT(onFileClose())); _connections << connect(parent, SIGNAL(fileCloseAll()), this, SLOT(onFileCloseAll())); _connections << connect(parent, SIGNAL(fileOpen(QString)), this, SLOT(onFileOpen(QString))); _connections << connect(parent, SIGNAL(fileSave()), this, SLOT(onFileSave())); _connections << connect(parent, SIGNAL(fileSaveAll()), this, SLOT(onFileSaveAll())); _connections << connect(this, &QTabWidget::tabCloseRequested, this, &EditorTabs::onTabCloseRequested); _connections << connect(tabBar(), &QTabBar::tabMoved, this, &EditorTabs::onTabMoved); _connections << connect(this, &EditorTabs::currentChanged, this, &EditorTabs::onCurrentChanged); _connections << connect(this, SIGNAL(fileChanged(QString)), parent, SLOT(onFileChanged(QString))); _connections << connect(this, SIGNAL(fileSaved(QString)), parent, SLOT(onFileSaved(QString))); setMovable(true); setTabsClosable(true); }
void MainWindow::onFileSaveAs() { if (!fDoc) return; QSettings settings; QString name = tr("Untitled.pgo"); if (!fDoc->fPath.isEmpty()) { name = fDoc->fPath; } else { QDir dir(settings.value("default_dir", "").toString()); name = dir.absoluteFilePath(name); } QString filePath = QFileDialog::getSaveFileName(this, tr("Save"), name, tr("Papgayo files (*.pgo)")); if (filePath.isEmpty()) return; QFileInfo info(filePath); settings.setValue("default_dir", info.dir().absolutePath()); fDoc->fPath = filePath; onFileSave(); }
void EditorTabs::onFileSave() { int i; if ((i = currentIndex()) >= 0) { onFileSave(i); } }
bool DiffAnalystWindow::initViewToolBar() { QIconSet icon; bool ret=false; // //////////////////////////////////////////////////////////////////// // FILE TOOLBAR m_pFileTools = new QToolBar (this, "File Toolbar"); if(m_pFileTools == NULL) return false; icon = QIconSet (QPixmap(XpmFileNew)); m_ToolsToolId [TM_FILENEW] = new QToolButton( icon, "New Diff Session", QString::null, this, SLOT(onFileNew()), m_pFileTools); icon = QIconSet (QPixmap(XpmFileOpen)); m_ToolsToolId [TM_FILEOPEN] = new QToolButton( icon, "Open Diff Session", QString::null, this, SLOT(onFileOpen()), m_pFileTools); icon = QIconSet (QPixmap(XpmFileSave)); m_ToolsToolId [TM_FILESAVE] = new QToolButton( icon, "Save Diff Session", QString::null, this, SLOT(onFileSave()), m_pFileTools); m_ToolsToolId [TM_FILESAVE]->setEnabled(false); // //////////////////////////////////////////////////////////////////// // VIEW TOOLBAR m_pViewTools = new QToolBar (this, "View Toolbar"); if(m_pViewTools == NULL) return false; icon = QIconSet (QPixmap(viewconfig)); m_ToolsToolId [TM_EDITVIEWS] = new QToolButton( icon, "View Management", QString::null, this, SLOT(onViewManage()), m_pViewTools); // //////////////////////////////////////////////////////////////////// // TOOLS TOOLBAR m_pToolTools = new QToolBar (this, "Tools Toolbar"); if(m_pToolTools == NULL) return false; icon = QIconSet (QPixmap((const char**)disassemblyIcon)); m_ToolsToolId [TM_TOOLDASM] = new QToolButton( icon, "Show/Hide Disassembly", QString::null, this, SLOT(onToggleDasmView()), m_pToolTools); icon = QIconSet (QPixmap((const char**)propertyIcon)); m_ToolsToolId [TM_TOOLPROP] = new QToolButton( icon,"Show/Hide Property", QString::null, this, SLOT(onToggleProp()), m_pToolTools); // //////////////////////////////////////////////////////////////////// moveDockWindow (m_pViewTools, Qt::DockTop); ret = true; return ret; }
/* ///////////////////////////////////////////////////////////////////////////// * Menu "File save as" action */ void TTCutMainWindow::onFileSaveAs() { if (!TTCut::isVideoOpen) return; TTCut::projectFileName = ttChangeFileExt(mpegStream->fileName(), "prj"); QFileInfo prjFileInfo(QDir(TTCut::lastDirPath), TTCut::projectFileName); TTCut::projectFileName = QFileDialog::getSaveFileName( this, tr("Save project-file as"), prjFileInfo.absoluteFilePath(), "Project(*.prj)" ); if (!TTCut::projectFileName.isEmpty()) { QFileInfo fInfo(TTCut::projectFileName); TTCut::lastDirPath = fInfo.absolutePath(); onFileSave(); } }
void MyFracWindow::createActions() { KAction* actionSave = KStdAction::save(this, SLOT(onFileSave()), actionCollection()); actionSave->setText(i18n("&Save Image...")); KStdAction::quit(kapp, SLOT(quit()), actionCollection()); KStdAction::copy(this, SLOT(onEditCopy()), actionCollection()); new KAction(i18n("&Edit Gradient..."), "frgradedit", CTRL+Key_E, this, SLOT(onGradientEdit()), actionCollection(), "grad_edit"); new KAction(i18n("&Invert Gradient"), "frgradinv", CTRL+Key_X, this, SLOT(onGradientInvert()), actionCollection(), "grad_inv"); _actionMandelbrot = KStdAction::up(this, SLOT(setMandelbrotMode()), actionCollection()); _actionMandelbrot->setText(i18n("&To Mandelbrot")); KStdAction::home(this, SLOT(onDefaultView()), actionCollection()); _actionBack = KStdAction::back(this, SLOT(onViewBack()), actionCollection()); _actionForward = KStdAction::forward(this, SLOT(onViewForward()), actionCollection()); createStandardStatusBarAction(); setStandardToolBarMenuEnabled(true); _actionParams = new KToggleAction(i18n("Show Parameters"), SmallIconSet("frparams"), 0, _dockParams, SLOT(changeHideShowState()), actionCollection(), "show_params"); _actionDisplay = new KToggleAction(i18n("Show Display"), SmallIconSet("frdisplay"), 0, _dockDisplay, SLOT(changeHideShowState()), actionCollection(), "show_display"); _actionPreview = new KToggleAction(i18n("Show Preview"), SmallIconSet("viewmag"), 0, _dockPreview, SLOT(changeHideShowState()), actionCollection(), "show_preview"); #if KDE_IS_VERSION(3,2,90) _actionParams->setCheckedState(i18n("Hide Parameters")); _actionDisplay->setCheckedState(i18n("Hide Display")); _actionPreview->setCheckedState(i18n("Hide Preview")); #endif KStdAction::keyBindings(guiFactory(), SLOT(configureShortcuts()), actionCollection()); KStdAction::configureToolbars(this, SLOT(configureToolbars()), actionCollection()); connect(dockManager, SIGNAL(change()), this, SLOT(updateShowActions())); updateShowActions(); }
/*----------------------------------------------------------------------------*/ bool MainWindow::midifiedQuestion() { if(m_messageFile->isModified()) { switch(QMessageBox::question(this, tr("Data modified"), tr("Data was modified. Do you whant to save message file ?"), QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard, QMessageBox::Cancel)) { case QMessageBox::Save: onFileSave(); return !m_messageFile->isModified(); case QMessageBox::Discard: m_messageFile->setModified(false); return true; case QMessageBox::Cancel: default: return false; } return false; } return true; }
/*----------------------------------------------------------------------------*/ void MainWindow::onFileSaveAs() { m_fileName.clear(); onFileSave(); }
/* ///////////////////////////////////////////////////////////////////////////// * Application main window constructor */ TTCutMainWindow::TTCutMainWindow() : QMainWindow() { // setup Qt Designer UI setupUi( this ); // images // -------------------------------------------------------------------------- TTCut::imgDownArrow = new QPixmap( downarrow_18_xpm ); TTCut::imgUpArrow = new QPixmap( uparrow_18_xpm ); TTCut::imgDelete = new QPixmap( cancel_18_xpm ); TTCut::imgFileOpen24 = new QPixmap( fileopen_24_xpm ); TTCut::imgFileNew = new QPixmap( filenew_16_xpm ); TTCut::imgFileOpen = new QPixmap( fileopen_16_xpm ); TTCut::imgFileSave = new QPixmap( filesave_16_xpm );; TTCut::imgFileSaveAs = new QPixmap( filesaveas_16_xpm ); TTCut::imgSaveImage = new QPixmap( saveimage_16_xpm ); TTCut::imgSettings = new QPixmap( settings_16_xpm ); TTCut::imgSettings18 = new QPixmap( settings_18_xpm ); TTCut::imgExit = new QPixmap( exit_16_xpm ); TTCut::imgPlay = new QPixmap( play_18_xpm ); TTCut::imgStop = new QPixmap( stop_18_xpm ); TTCut::imgSearch = new QPixmap( search_18_xpm ); TTCut::imgChapter = new QPixmap( chapter_18_xpm ); TTCut::imgPreview = new QPixmap( preview_18_xpm ); TTCut::imgCutAV = new QPixmap( cutav_18_xpm ); TTCut::imgCutAudio = new QPixmap( cutaudio_18_xpm ); TTCut::imgGoTo = new QPixmap( goto_18_xpm ); TTCut::imgMarker = new QPixmap( note_18_xpm ); TTCut::imgClock = new QPixmap( clock_16_xpm ); TTCut::imgApply = new QPixmap( apply_18_xpm ); TTCut::imgAddToList = new QPixmap( addtolist_18_xpm ); TTCut::imgFileClose = new QPixmap( fileclose_18_xpm ); setFocusPolicy(Qt::StrongFocus); // Message logger instance log = TTMessageLogger::getInstance(); // Get the current Qt version at runtime log->infoMsg(oName, "TTCut-Version: %s", qPrintable(TTCut::versionString)); log->infoMsg(oName, "Qt-Version: %s", qVersion()); #if QT_VERSION < 0x040100 // TODO: Show message box and abort session log->errorMsg(oName, "Qt-Version >= 4.1.0 required"); #endif // Settings TTCut::recentFileList.clear(); settings = new TTCutSettings(); settings->readSettings(); log->enableLogFile(TTCut::createLogFile); log->setLogModeConsole(TTCut::logModeConsole); log->setLogModeExtended(TTCut::logModeExtended); // Audio list audioList = new TTAudioListData(); audioFileInfo->setListData(audioList); // Mux list and mplex provider (later by plugin) muxListData = new TTMuxListData(); mplexProvider = new TTMplexProvider(); // no navigation navigationEnabled( false ); // init cutListData = NULL; mpegStream = NULL; TTCut::isVideoOpen = false; TTCut::projectFileName = ""; // Signal and slot connections // // Connect signals from main menu // -------------------------------------------------------------------------- connect(actionOpenVideo, SIGNAL(triggered()), videoFileInfo, SLOT(onFileOpen())); connect(actionOpenAudio, SIGNAL(triggered()), audioFileInfo, SLOT(onFileOpen())); connect(actionFileNew, SIGNAL(triggered()), SLOT(onFileNew())); connect(actionFileOpen, SIGNAL(triggered()), SLOT(onFileOpen())); connect(actionFileSave, SIGNAL(triggered()), SLOT(onFileSave())); connect(actionFileSaveAs, SIGNAL(triggered()), SLOT(onFileSaveAs())); connect(actionExit, SIGNAL(triggered()), SLOT(onFileExit())); connect(actionSaveCurrentFrame, SIGNAL(triggered()), SLOT(onActionSave())); connect(actionSettings, SIGNAL(triggered()), SLOT(onActionSettings())); connect(actionAbout, SIGNAL(triggered()), SLOT(onHelpAbout())); // recent files for (int i = 0; i < MaxRecentFiles; ++i) { recentFileAction[i] = new QAction(this); recentFileAction[i]->setVisible(false); menuRecentProjects->addAction(recentFileAction[i]); connect(recentFileAction[i], SIGNAL(triggered()), SLOT(onFileRecent())); } updateRecentFileActions(); // Connect signals from video and audio info // -------------------------------------------------------------------------- connect(videoFileInfo, SIGNAL(fileOpened(QString)), SLOT(onReadVideoStream(QString))); connect(audioFileInfo, SIGNAL(fileOpened(QString)), SLOT(onReadAudioStream(QString))); // Connect signals from navigation widget // -------------------------------------------------------------------------- connect(navigation, SIGNAL(prevIFrame()), currentFrame, SLOT(onPrevIFrame())); connect(navigation, SIGNAL(nextIFrame()), currentFrame, SLOT(onNextIFrame())); connect(navigation, SIGNAL(prevPFrame()), currentFrame, SLOT(onPrevPFrame())); connect(navigation, SIGNAL(nextPFrame()), currentFrame, SLOT(onNextPFrame())); connect(navigation, SIGNAL(prevBFrame()), currentFrame, SLOT(onPrevBFrame())); connect(navigation, SIGNAL(nextBFrame()), currentFrame, SLOT(onNextBFrame())); connect(navigation, SIGNAL(setCutOut(int)), currentFrame, SLOT(onSetCutOut(int))); connect(navigation, SIGNAL(setCutOut(int)), cutOutFrame, SLOT(onGotoCutOut(int))); connect(navigation, SIGNAL(setCutIn(int)), currentFrame, SLOT(onSetCutIn(int))); connect(navigation, SIGNAL(gotoCutIn(int)), currentFrame, SLOT(onGotoCutIn(int))); connect(navigation, SIGNAL(gotoCutOut(int)), currentFrame, SLOT(onGotoCutOut(int))); connect(navigation, SIGNAL(addCutRange(int, int)), cutList, SLOT(onAddEntry(int, int))); connect(navigation, SIGNAL(gotoMarker(int)), currentFrame, SLOT(onGotoMarker(int))); connect(navigation, SIGNAL(moveNumSteps(int)), currentFrame, SLOT(onMoveNumSteps(int))); connect(navigation, SIGNAL(moveToHome()), currentFrame, SLOT(onMoveToHome())); connect(navigation, SIGNAL(moveToEnd()), currentFrame, SLOT(onMoveToEnd())); // Connect signal from video slider // -------------------------------------------------------------------------- connect(streamNavigator, SIGNAL(sliderValueChanged(int)), SLOT(onVideoSliderChanged(int))); // Connect signals from cut-out frame widget // -------------------------------------------------------------------------- connect(cutOutFrame, SIGNAL(equalFrameFound(int)), currentFrame, SLOT(onGotoFrame(int))); connect(cutOutFrame, SIGNAL(newCutOutFramePos(int)), cutList, SLOT(onEditCutOut(int))); // Connect signals from current frame widget // -------------------------------------------------------------------------- connect(currentFrame, SIGNAL(newFramePosition(int)), SLOT(onNewFramePos(int))); // Connect signals from cut list widget // -------------------------------------------------------------------------- connect(cutList, SIGNAL(entrySelected(int)), cutOutFrame, SLOT(onGotoCutOut(int))); connect(cutList, SIGNAL(entryEdit(const TTCutListDataItem&)), navigation, SLOT(onEditCut(const TTCutListDataItem&))); connect(cutList, SIGNAL(gotoCutIn(int)), currentFrame, SLOT(onGotoFrame(int))); connect(cutList, SIGNAL(gotoCutOut(int)), currentFrame, SLOT(onGotoFrame(int))); connect(cutList, SIGNAL(refreshDisplay()), streamNavigator, SLOT(onRefreshDisplay())); connect(cutList, SIGNAL(previewCut(int)), SLOT(onPreviewCut(int))); connect(cutList, SIGNAL(audioVideoCut(int)), SLOT(onAudioVideoCut(int))); connect(cutList, SIGNAL(audioCut(int)), SLOT(onAudioCut(int))); }
void Plugin::postLoad() { Q_ASSERT(_layoutManager); Q_ASSERT(mainWindow); IonLayout::ZoneDefinition def; def.name = "central"; def.orientation = Qt::Vertical; def.parentPath = ""; def.after = "left"; def.before = "right"; def.hideIfEmpty = false; def.sizeWeight = 700; def.childrenClosable = true; def.subZonesContainerType = IonLayout::ZoneDefinition::Boxed; def.widgetsContainerType = IonLayout::ZoneDefinition::Tabbed; _layoutManager->addZone(def); def.name = "central_footer"; def.orientation = Qt::Vertical; def.parentPath = "central"; def.after = "central"; def.before = ""; def.hideIfEmpty = true; def.sizeWeight = 1; def.childrenClosable = false; def.subZonesContainerType = IonLayout::ZoneDefinition::Tabbed; def.widgetsContainerType = IonLayout::ZoneDefinition::Boxed; _layoutManager->addZone(def); def.name = "left"; def.orientation = Qt::Vertical; def.parentPath = ""; def.after = ""; def.before = "central"; def.hideIfEmpty = false; def.sizeWeight = 200; def.childrenClosable = false; def.subZonesContainerType = IonLayout::ZoneDefinition::Split; def.widgetsContainerType = IonLayout::ZoneDefinition::Tabbed; _layoutManager->addZone(def); def.name = "leftbottom"; def.orientation = Qt::Vertical; def.parentPath = "left"; def.after = "left"; def.before = ""; def.hideIfEmpty = true; def.sizeWeight = 150; def.childrenClosable = false; def.subZonesContainerType = IonLayout::ZoneDefinition::Split; def.widgetsContainerType = IonLayout::ZoneDefinition::Tabbed; _layoutManager->addZone(def); def.name = "right"; def.orientation = Qt::Vertical; def.parentPath = ""; def.after = "central"; def.before = ""; def.hideIfEmpty = true; def.sizeWeight = 150; def.childrenClosable = false; def.subZonesContainerType = IonLayout::ZoneDefinition::Split; def.widgetsContainerType = IonLayout::ZoneDefinition::Tabbed; _layoutManager->addZone(def); Private::FileTreeWidget *fileTree = new Private::FileTreeWidget(); _layoutManager->add("left", fileTree); connect(fileTree, SIGNAL(fileActivated(QString, int)), this, SLOT(openFile(QString, int))); getEditorWidgetBuilder()->registerComponentFactory("text", new Private::DefaultLineNumberAreaFactory()); QMenuBar *menuBar = mainWindow->menuBar(); QMenu *fileMenu = menuBar->addMenu("&File"); fileMenu->addAction("&Save", this, SLOT(onFileSave()), QKeySequence(Qt::CTRL + Qt::Key_S)); fileMenu->addAction("&Close", this, SLOT(onFileClose()), QKeySequence(Qt::CTRL + Qt::Key_W)); QMenu *editMenu = menuBar->addMenu("&Edit"); editMenu->addAction("&Find", this, SLOT(onEditSearch()), QKeySequence(Qt::CTRL + Qt::Key_F)); editMenu->addAction("Find &Next", this, SLOT(onEditSearchNext()), QKeySequence(Qt::CTRL + Qt::Key_G)); editMenu->addAction("Find &Previous", this, SLOT(onEditSearchPrev()), QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G)); _searchPanel = new SearchPanel(); _searchPanel->setEditorPlugin(this); _layoutManager->add("central/central_footer", _searchPanel); }
bool DiffAnalystWindow::initMenuBar() { bool ret=false; // //////////////////////////////////////////////////////////////////// // FILE m_pFileMenu = new QPopupMenu (this); if(m_pFileMenu == NULL) return false; menuBar ()->insertItem ("&File", m_pFileMenu); // New m_pFileMenu->insertItem (QIconSet (QPixmap (XpmFileNew)), "&New Session Wizard", this, SLOT (onFileNew ()), CTRL + Key_N); // Open m_pFileMenu->insertItem (QIconSet (QPixmap (XpmFileOpen)), "&Open", this, SLOT (onFileOpen ()), CTRL + Key_O); // ------------------- m_pFileMenu->insertSeparator (); // Save m_SaveId = m_pFileMenu->insertItem (QIconSet (QPixmap (XpmFileSave)), "&Save", this, SLOT (onFileSave ()), CTRL + Key_S); m_pFileMenu->setItemEnabled (m_SaveId, false); // Save As m_SaveAsId = m_pFileMenu->insertItem (QIconSet(QPixmap()), "Save &As", this, SLOT (onFileSaveAs ()), CTRL + Key_A); m_pFileMenu->setItemEnabled (m_SaveAsId, false); // ------------------- // m_pFileMenu->insertSeparator (); // export data // m_ExportDataId = m_pFileMenu->insertItem ("&Export...", this, // SLOT (onExportData ())); // m_pFileMenu->setItemEnabled (m_ExportDataId, false); // ------------------- m_pFileMenu->insertSeparator (); // Close m_CloseId = m_pFileMenu->insertItem ("&Close", this, SLOT (onFileClose ()), CTRL + Key_W); m_CloseAllId = m_pFileMenu->insertItem ("Close Al&l", this, SLOT (onCloseAllWindows ())); // Quit m_pFileMenu->insertItem ("&Quit", this, SLOT (close ()), CTRL + Key_Q); QObject::connect (qApp, SIGNAL (aboutToQuit ()), this, SLOT (onAboutToQuit ())); // //////////////////////////////////////////////////////////////////// // SETTINGS // m_pSettingsMenu = new QPopupMenu (this); // if(m_pSettingsMenu == NULL) return false; // menuBar ()->insertItem ("&Settings", m_pSettingsMenu); // ///////////////////////////////////////////////////////////////////// // TOOLS m_pToolsMenu = new QPopupMenu (this); if(m_pToolsMenu == NULL) return false; m_pToolsMenu->setCheckable (TRUE); connect (m_pToolsMenu, SIGNAL (aboutToShow ()), this, SLOT (toolsMenuAboutToShow ())); menuBar ()->insertItem ("&Tools", m_pToolsMenu); // ///////////////////////////////////////////////////////////////////// // VIEW m_pViewMenu = new QPopupMenu (this); if(m_pViewMenu == NULL) return false; menuBar ()->insertItem ("&View", m_pViewMenu); // View Management m_ViewManageId = m_pViewMenu->insertItem (QPixmap(viewconfig),"&View Management", this, SLOT (onViewManage ())); // ///////////////////////////////////////////////////////////////////// // WINDOWS m_pWindowsMenu = new QPopupMenu (this); if(m_pWindowsMenu == NULL) return false; connect (m_pWindowsMenu, SIGNAL (aboutToShow ()), this, SLOT (onWindowsMenuAboutToShow ())); menuBar ()->insertItem ("&Windows", m_pWindowsMenu); // ///////////////////////////////////////////////////////////////////// // HELPS m_pHelpMenu = new QPopupMenu (this); if(m_pHelpMenu == NULL) return false; menuBar ()->insertItem ("&Help", m_pHelpMenu); m_pHelpMenu->insertItem ("&About", this, SLOT (onHelpAbout ()), Key_F1); m_pHelpMenu->insertItem ("&Help", this, SLOT (onHelpContents ())); ret = true; return ret; }// DiffAnalystWindow::initMenuBar