void DesktopViewProxy::fileSave() { if(DocumentManager::instance()->isTemporaryFile()) { if(d->desktopWindow->saveDocument(d->desktopWindow->activeView()->document(), true)) { DocumentManager::instance()->recentFileManager()->addRecent(DocumentManager::instance()->document()->url().toLocalFile()); DocumentManager::instance()->settingsManager()->setCurrentFile(DocumentManager::instance()->document()->url().toLocalFile()); DocumentManager::instance()->setTemporaryFile(false); emit documentSaved(); } } else { DocumentManager::instance()->save(); emit documentSaved(); } }
void DocumentManager::delayedSaveAs() { d->document->saveAs(QUrl::fromLocalFile(d->saveAsFilename)); d->settingsManager->setCurrentFile(d->saveAsFilename); d->recentFileManager->addRecent(d->saveAsFilename); emit documentSaved(); }
bool DocumentWindow::saveDocument(const QString& path) { const bool samePath = m_path == path; const QString oldPath = m_path; if (m_synchronized && samePath) { return true; } const QFile::FileError saving = m_document.saveToFile(path); if (saving != QFile::NoError) { showPopup(tr("Error"), tr("Failed to save to file: %1").arg(path)); return false; } if (!samePath) { m_path = path; } m_synchronized = true; setWindowTitle(separateName(m_path)); emit documentSaved(path); if (!samePath) { emit documentClosed(oldPath); } return true; }
void Document::setChanged(bool b) { changed_ = b; if (changed_) emit documentChanged(); else emit documentSaved(); }
DesktopViewProxy::DesktopViewProxy(MainWindow* mainWindow, KisMainWindow* parent) : QObject(parent) , d(new Private(mainWindow, parent)) { Q_ASSERT(parent); // "There MUST be a KisMainWindow assigned, otherwise everything will blow up"); // Hide this one... as it doesn't work at all well and release happens :P QAction* closeAction = d->desktopWindow->actionCollection()->action("file_close"); closeAction->setVisible(false); // Concept is simple - simply steal all the actions we require to work differently, and reconnect them to local functions QAction* newAction = d->desktopWindow->actionCollection()->action("file_new"); newAction->disconnect(d->desktopWindow); connect(newAction, SIGNAL(triggered(bool)), this, SLOT(fileNew())); QAction* openAction = d->desktopWindow->actionCollection()->action("file_open"); openAction->disconnect(d->desktopWindow); connect(openAction, SIGNAL(triggered(bool)), this, SLOT(fileOpen())); QAction* saveAction = d->desktopWindow->actionCollection()->action("file_save"); saveAction->disconnect(d->desktopWindow); connect(saveAction, SIGNAL(triggered(bool)), this, SLOT(fileSave())); QAction* saveasAction = d->desktopWindow->actionCollection()->action("file_save_as"); saveasAction->disconnect(d->desktopWindow); connect(saveasAction, SIGNAL(triggered(bool)), this, SLOT(fileSaveAs())); QAction* reloadAction = d->desktopWindow->actionCollection()->action("file_reload_file"); reloadAction->disconnect(d->desktopWindow); connect(reloadAction, SIGNAL(triggered(bool)), this, SLOT(reload())); QAction* loadExistingAsNewAction = d->desktopWindow->actionCollection()->action("file_import_file"); //Hide the "Load existing as new" action. It serves little purpose and currently //does the same as open. We cannot just remove it from the action collection though //since that causes a crash in KisMainWindow. loadExistingAsNewAction->setVisible(false); // Recent files need a touch more work, as they aren't simply an action. KRecentFilesAction* recent = qobject_cast<KRecentFilesAction*>(d->desktopWindow->actionCollection()->action("file_open_recent")); recent->disconnect(d->desktopWindow); connect(recent, SIGNAL(urlSelected(QUrl)), this, SLOT(slotFileOpenRecent(QUrl))); recent->clear(); recent->loadEntries(KGlobal::config()->group("RecentFiles")); connect(d->desktopWindow, SIGNAL(documentSaved()), this, SIGNAL(documentSaved())); // XXX: Shortcut editor is untested in Gemini since refactoring. connect(KisActionRegistry::instance(), SIGNAL(shortcutsUpdated()), this, SLOT(updateShortcuts())); }
bool DocumentManager::save() { if (d->document->save()) { d->recentFileManager->addRecent(d->document->url().toLocalFile()); d->settingsManager->setCurrentFile(d->document->url().toLocalFile()); emit documentSaved(); return true; } return false; }
KisSketchView::KisSketchView(QDeclarativeItem* parent) : QDeclarativeItem(parent) , d(new Private(this)) { // this is just an interaction overlay, the contents are painted on the sceneview background setFlag(QGraphicsItem::ItemHasNoContents, true); setAcceptTouchEvents(true); setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); setAcceptHoverEvents(true); grabGesture(Qt::PanGesture); //grabGesture(Qt::PinchGesture); KoZoomMode::setMinimumZoom(0.1); KoZoomMode::setMaximumZoom(16.0); d->timer = new QTimer(this); d->timer->setSingleShot(true); connect(d->timer, SIGNAL(timeout()), this, SLOT(resetDocumentPosition())); d->loadedTimer = new QTimer(this); d->loadedTimer->setSingleShot(true); d->loadedTimer->setInterval(100); connect(d->loadedTimer, SIGNAL(timeout()), SIGNAL(loadingFinished())); d->savedTimer = new QTimer(this); d->savedTimer->setSingleShot(true); d->savedTimer->setInterval(100); connect(d->savedTimer, SIGNAL(timeout()), SIGNAL(savingFinished())); connect(DocumentManager::instance(), SIGNAL(aboutToDeleteDocument()), SLOT(documentAboutToBeDeleted())); connect(DocumentManager::instance(), SIGNAL(documentChanged()), SLOT(documentChanged())); connect(DocumentManager::instance()->progressProxy(), SIGNAL(valueChanged(int)), SIGNAL(progress(int))); connect(DocumentManager::instance(), SIGNAL(documentSaved()), d->savedTimer, SLOT(start())); if (DocumentManager::instance()->document()) documentChanged(); }
void DocumentManager::setTemporaryFile(bool temp) { d->temporaryFile = temp; emit documentSaved(); }
//----------------------------------------------------------------------------- // Function: save() //----------------------------------------------------------------------------- bool TabDocument::save() { setModified(false); emit documentSaved(this); return true; }
KisView2::KisView2(KisPart2 *part, KisDoc2 * doc, QWidget * parent) : KoView(part, doc, parent), m_d(new KisView2Private()) { setXMLFile("krita.rc"); setFocusPolicy(Qt::NoFocus); if (mainWindow()) { mainWindow()->setDockNestingEnabled(true); actionCollection()->addAction(KStandardAction::KeyBindings, "keybindings", mainWindow()->guiFactory(), SLOT(configureShortcuts())); } m_d->doc = doc; m_d->part = part; m_d->viewConverter = new KisCoordinatesConverter(); KisCanvasController *canvasController = new KisCanvasController(this, actionCollection()); canvasController->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); canvasController->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); canvasController->setDrawShadow(false); canvasController->setCanvasMode(KoCanvasController::Infinite); KisConfig cfg; canvasController->setZoomWithWheel(cfg.zoomWithWheel()); canvasController->setVastScrolling(cfg.vastScrolling()); m_d->canvasController = canvasController; m_d->resourceProvider = new KisCanvasResourceProvider(this); m_d->resourceProvider->resetDisplayProfile(QApplication::desktop()->screenNumber(this)); KConfigGroup grp(KGlobal::config(), "krita/crashprevention"); if (grp.readEntry("CreatingCanvas", false)) { KisConfig cfg; cfg.setUseOpenGL(false); } grp.writeEntry("CreatingCanvas", true); m_d->canvas = new KisCanvas2(m_d->viewConverter, this, doc->shapeController()); grp.writeEntry("CreatingCanvas", false); connect(m_d->resourceProvider, SIGNAL(sigDisplayProfileChanged(const KoColorProfile*)), m_d->canvas, SLOT(slotSetDisplayProfile(const KoColorProfile*))); m_d->canvasController->setCanvas(m_d->canvas); m_d->resourceProvider->setResourceManager(m_d->canvas->resourceManager()); createManagers(); createActions(); m_d->controlFrame = new KisControlFrame(this); Q_ASSERT(m_d->canvasController); KoToolManager::instance()->addController(m_d->canvasController); KoToolManager::instance()->registerTools(actionCollection(), m_d->canvasController); // krita/krita.rc must also be modified to add actions to the menu entries m_d->saveIncremental = new KAction(i18n("Save Incremental &Version"), this); m_d->saveIncremental->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_S)); actionCollection()->addAction("save_incremental_version", m_d->saveIncremental); connect(m_d->saveIncremental, SIGNAL(triggered()), this, SLOT(slotSaveIncremental())); m_d->saveIncrementalBackup = new KAction(i18n("Save Incremental Backup"), this); m_d->saveIncrementalBackup->setShortcut(Qt::Key_F4); actionCollection()->addAction("save_incremental_backup", m_d->saveIncrementalBackup); connect(m_d->saveIncrementalBackup, SIGNAL(triggered()), this, SLOT(slotSaveIncrementalBackup())); connect(shell(), SIGNAL(documentSaved()), this, SLOT(slotDocumentSaved())); if (koDocument()->localFilePath().isNull()) { m_d->saveIncremental->setEnabled(false); m_d->saveIncrementalBackup->setEnabled(false); } m_d->totalRefresh = new KAction(i18n("Total Refresh"), this); actionCollection()->addAction("total_refresh", m_d->totalRefresh); m_d->totalRefresh->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_R)); connect(m_d->totalRefresh, SIGNAL(triggered()), this, SLOT(slotTotalRefresh())); m_d->createTemplate = new KAction( i18n( "&Create Template From Image..." ), this); actionCollection()->addAction("createTemplate", m_d->createTemplate); connect(m_d->createTemplate, SIGNAL(triggered()), this, SLOT(slotCreateTemplate())); m_d->mirrorCanvas = new KToggleAction(i18n("Mirror View"), this); m_d->mirrorCanvas->setChecked(false); actionCollection()->addAction("mirror_canvas", m_d->mirrorCanvas); m_d->mirrorCanvas->setShortcut(QKeySequence(Qt::Key_M)); connect(m_d->mirrorCanvas, SIGNAL(toggled(bool)),m_d->canvasController, SLOT(mirrorCanvas(bool))); KAction *rotateCanvasRight = new KAction(i18n("Rotate Canvas Right"), this); actionCollection()->addAction("rotate_canvas_right", rotateCanvasRight); rotateCanvasRight->setShortcut(QKeySequence("Ctrl+]")); connect(rotateCanvasRight, SIGNAL(triggered()),m_d->canvasController, SLOT(rotateCanvasRight15())); KAction *rotateCanvasLeft = new KAction(i18n("Rotate Canvas Left"), this); actionCollection()->addAction("rotate_canvas_left", rotateCanvasLeft); rotateCanvasLeft->setShortcut(QKeySequence("Ctrl+[")); connect(rotateCanvasLeft, SIGNAL(triggered()),m_d->canvasController, SLOT(rotateCanvasLeft15())); KAction *resetCanvasTransformations = new KAction(i18n("Reset Canvas Transformations"), this); actionCollection()->addAction("reset_canvas_transformations", resetCanvasTransformations); resetCanvasTransformations->setShortcut(QKeySequence("Ctrl+'")); connect(resetCanvasTransformations, SIGNAL(triggered()),m_d->canvasController, SLOT(resetCanvasTransformations())); KToggleAction *tAction = new KToggleAction(i18n("Show Status Bar"), this); tAction->setCheckedState(KGuiItem(i18n("Hide Status Bar"))); tAction->setChecked(true); tAction->setToolTip(i18n("Shows or hides the status bar")); actionCollection()->addAction("showStatusBar", tAction); connect(tAction, SIGNAL(toggled(bool)), this, SLOT(showStatusBar(bool))); tAction = new KToggleAction(i18n("Show Canvas Only"), this); tAction->setCheckedState(KGuiItem(i18n("Return to Window"))); tAction->setToolTip(i18n("Shows just the canvas or the whole window")); QList<QKeySequence> shortcuts; shortcuts << QKeySequence(Qt::Key_Tab); tAction->setShortcuts(shortcuts); tAction->setChecked(false); actionCollection()->addAction("view_show_just_the_canvas", tAction); connect(tAction, SIGNAL(toggled(bool)), this, SLOT(showJustTheCanvas(bool))); //Workaround, by default has the same shortcut as mirrorCanvas KAction* action = dynamic_cast<KAction*>(actionCollection()->action("format_italic")); if (action) { action->setShortcut(QKeySequence(), KAction::DefaultShortcut); action->setShortcut(QKeySequence(), KAction::ActiveShortcut); } //Workaround, by default has the same shortcut as hide/show dockers action = dynamic_cast<KAction*>(shell()->actionCollection()->action("view_toggledockers")); if (action) { action->setShortcut(QKeySequence(), KAction::DefaultShortcut); action->setShortcut(QKeySequence(), KAction::ActiveShortcut); } if (shell()) { KoToolBoxFactory toolBoxFactory(m_d->canvasController); shell()->createDockWidget(&toolBoxFactory); connect(canvasController, SIGNAL(toolOptionWidgetsChanged(QList<QWidget*>)), shell()->dockerManager(), SLOT(newOptionWidgets(QList<QWidget*>))); shell()->dockerManager()->setIcons(false); } m_d->statusBar = new KisStatusBar(this); connect(m_d->canvasController->proxyObject, SIGNAL(documentMousePositionChanged(QPointF)), m_d->statusBar, SLOT(documentMousePositionChanged(QPointF))); connect(m_d->nodeManager, SIGNAL(sigNodeActivated(KisNodeSP)), m_d->resourceProvider, SLOT(slotNodeActivated(KisNodeSP))); connect(m_d->nodeManager, SIGNAL(sigNodeActivated(KisNodeSP)), m_d->controlFrame->paintopBox(), SLOT(slotCurrentNodeChanged(KisNodeSP))); connect(m_d->nodeManager, SIGNAL(sigNodeActivated(KisNodeSP)), m_d->doc->image(), SLOT(requestStrokeEnd())); connect(KoToolManager::instance(), SIGNAL(inputDeviceChanged(KoInputDevice)), m_d->controlFrame->paintopBox(), SLOT(slotInputDeviceChanged(KoInputDevice))); connect(KoToolManager::instance(), SIGNAL(changedTool(KoCanvasController*,int)), m_d->controlFrame->paintopBox(), SLOT(slotToolChanged(KoCanvasController*,int))); // 25 px is a distance that works well for Tablet and Mouse events qApp->setStartDragDistance(25); show(); loadPlugins(); // Wait for the async image to have loaded connect(m_d->doc, SIGNAL(sigLoadingFinished()), this, SLOT(slotLoadingFinished())); if (!m_d->doc->isLoading() || m_d->doc->image()) { slotLoadingFinished(); } connect(m_d->canvasController, SIGNAL(documentSizeChanged()), m_d->zoomManager, SLOT(slotScrollAreaSizeChanged())); setAcceptDrops(true); KConfigGroup group(KGlobal::config(), "krita/shortcuts"); foreach(KActionCollection *collection, KActionCollection::allCollections()) { collection->setConfigGroup("krita/shortcuts"); collection->readSettings(&group); }