void KexiImageContextMenu::saveAs() { QString origFilename, fileExtension; bool dataIsEmpty = false; emit aboutToSaveAsRequested(origFilename, fileExtension, dataIsEmpty); if (dataIsEmpty) { kdWarning() << "KexiImageContextMenu::saveAs(): no data!" << endl; return; } if (!origFilename.isEmpty()) origFilename = QString("/") + origFilename; if (fileExtension.isEmpty()) { // PNG data is the default fileExtension = "png"; } #ifdef Q_WS_WIN QString recentDir; QString fileName = QFileDialog::getSaveFileName( KFileDialog::getStartURL(":LastVisitedImagePath", recentDir).path() + origFilename, convertKFileDialogFilterToQFileDialogFilter(KImageIO::pattern(KImageIO::Writing)), this, 0, i18n("Save Image to File")); #else //! @todo add originalFileName! (requires access to KRecentDirs) QString fileName = KFileDialog::getSaveFileName( ":LastVisitedImagePath", KImageIO::pattern(KImageIO::Writing), this, i18n("Save Image to File")); #endif if (fileName.isEmpty()) return; if (QFileInfo(fileName).extension().isEmpty()) fileName += (QString(".")+fileExtension); kdDebug() << fileName << endl; KURL url; url.setPath( fileName ); #ifdef Q_WS_WIN //save last visited path if (url.isLocalFile()) KRecentDirs::add(":LastVisitedImagePath", url.directory()); #endif QFile f(fileName); if (f.exists() && KMessageBox::Yes != KMessageBox::warningYesNo(this, "<qt>"+i18n("File \"%1\" already exists." "<p>Do you want to replace it with a new one?") .arg(QDir::convertSeparators(fileName))+"</qt>",0, KGuiItem(i18n("&Replace")), KGuiItem(i18n("&Don't Replace")))) { return; } //! @todo use KURL? emit saveAsRequested(fileName); }
KexiDBImageBox::KexiDBImageBox(bool designMode, QWidget *parent) : KexiFrame(parent /* Qt 4 not neede: , Qt::WNoAutoErase*/) , KexiFormDataItemInterface() , m_alignment(Qt::AlignAuto | Qt::AlignTop) //2.0 moved to FormWidgetInterface , m_designMode(designMode) , m_readOnly(false) , m_scaledContents(false) , m_smoothTransformation(true) , m_keepAspectRatio(true) , m_insideSetData(false) , m_setFocusOnButtonAfterClosingPopup(false) // , m_lineWidthChanged(false) , m_paintEventEnabled(true) , m_dropDownButtonVisible(true) , m_insideSetPalette(false) { setDesignMode(designMode); installEventFilter(this); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QPalette pal(palette()); pal.setBrush(backgroundRole(), QBrush(Qt::transparent)); KexiFrame::setPalette(pal); //setup context menu m_contextMenu = new KexiImageContextMenu(this); m_contextMenu->installEventFilter(this); if (designMode) { m_chooser = 0; } else { m_chooser = new KexiDropDownButton(this); m_chooser->setFocusPolicy(Qt::StrongFocus); m_chooser->setMenu(m_contextMenu); setFocusProxy(m_chooser); m_chooser->installEventFilter(this); // m_chooser->setPalette(qApp->palette()); // hlyr->addWidget(m_chooser); } setFrameShape(QFrame::Box); setFrameShadow(QFrame::Plain); setFrameColor(palette().color(QPalette::Foreground)); m_paletteBackgroundColorChanged = false; //set this here, not before connect(m_contextMenu, SIGNAL(updateActionsAvailabilityRequested(bool&,bool&)), this, SLOT(slotUpdateActionsAvailabilityRequested(bool&,bool&))); connect(m_contextMenu, SIGNAL(insertFromFileRequested(KUrl)), this, SLOT(handleInsertFromFileAction(KUrl))); connect(m_contextMenu, SIGNAL(saveAsRequested(QString)), this, SLOT(handleSaveAsAction(QString))); connect(m_contextMenu, SIGNAL(cutRequested()), this, SLOT(handleCutAction())); connect(m_contextMenu, SIGNAL(copyRequested()), this, SLOT(handleCopyAction())); connect(m_contextMenu, SIGNAL(pasteRequested()), this, SLOT(handlePasteAction())); connect(m_contextMenu, SIGNAL(clearRequested()), this, SLOT(clear())); connect(m_contextMenu, SIGNAL(showPropertiesRequested()), this, SLOT(handleShowPropertiesAction())); // connect(m_contextMenu, SIGNAL(aboutToHide()), this, SLOT(slotAboutToHidePopupMenu())); // if (m_chooser) { //we couldn't use m_chooser->setPopup() because of drawing problems // connect(m_chooser, SIGNAL(pressed()), this, SLOT(slotChooserPressed())); // connect(m_chooser, SIGNAL(released()), this, SLOT(slotChooserReleased())); // connect(m_chooser, SIGNAL(toggled(bool)), this, SLOT(slotToggled(bool))); // } KexiFrame::setLineWidth(0); setDataSource(QString()); //to initialize popup menu and actions availability }
TextEditor::TextEditor(QObject *qml, RecentFiles *recentfiles, QObject *parent) : QObject(parent) { currentFolder = "file:///home/user"; newFolder = currentFolder; //currentFolder = QDesktopServices::storageLocation(QDesktopServices::HomeLocation); //qDebug() << currentFolder; currentFile = tr(UNTITLED); currentContent = ""; recentFiles = recentfiles; // connect QML signals to TextEditor slots connect(qml, SIGNAL(menuOpenClicked(QString)), this, SLOT(menuOpenClicked(QString))); connect(qml, SIGNAL(toolSaveClicked(QString)), this, SLOT(toolSaveClicked(QString))); connect(qml, SIGNAL(toolRecentClicked()), this, SLOT(toolRecentClicked())); connect(qml, SIGNAL(menuSaveAsClicked()), this, SLOT(menuSaveAsClicked())); connect(qml, SIGNAL(saveAsRequested(QString,QString)), this, SLOT(saveAsRequested(QString,QString))); connect(qml, SIGNAL(newFolderChanged(QString)), this, SLOT(newFolderChanged(QString))); connect(qml, SIGNAL(fileOpenRequested(QString)), this, SLOT(fileOpenRequested(QString))); connect(qml, SIGNAL(saveAsConfirmed(QString)), this, SLOT(saveAsConfirmed(QString))); connect(qml, SIGNAL(newOrOpenConfirmed(QString)), this, SLOT(newOrOpenConfirmed(QString))); connect(qml, SIGNAL(openRecentConfirmed()), this, SLOT(openRecentConfirmed())); connect(qml, SIGNAL(menuQuitClicked(QString)), this, SLOT(menuQuitClicked(QString))); connect(qml, SIGNAL(saveBeforeClosed(QString)), this, SLOT(saveBeforeClosed(QString))); connect(qml, SIGNAL(menuNewClicked(QString)), this, SLOT(menuNewClicked(QString))); connect(qml, SIGNAL(recentFileClicked(QString,QString,QString)), this, SLOT(recentFileClicked(QString,QString,QString))); // connect TextEditor signals to QML signals connect(this, SIGNAL(browseRequested(QString,bool)), qml, SLOT(browseRequested(QString,bool))); connect(this, SIGNAL(recentRequested()), qml, SLOT(recentRequested())); connect(this, SIGNAL(openCompleted(QString,QString,QString)), qml, SLOT(openCompleted(QString,QString,QString))); connect(this, SIGNAL(openFailed(QString,QString)), qml, SLOT(openFailed(QString,QString))); connect(this, SIGNAL(saveCompleted()), qml, SLOT(saveCompleted())); connect(this, SIGNAL(saveFailed(QString,QString)), qml, SLOT(saveFailed(QString,QString))); connect(this, SIGNAL(saveAsCompleted(QString,QString)), qml, SLOT(saveAsCompleted(QString,QString))); connect(this, SIGNAL(saveAsToBeConfirmed(QString)), qml, SLOT(saveAsToBeConfirmed(QString))); connect(this, SIGNAL(newOrOpenToBeConfirmed(QString,QString)), qml, SLOT(newOrOpenToBeConfirmed(QString,QString))); connect(this, SIGNAL(openRecentToBeConfirmed(QString)), qml, SLOT(openRecentToBeConfirmed(QString))); connect(this, SIGNAL(appCloseToBeConfirmed(QString)), qml, SLOT(appCloseToBeConfirmed(QString))); connect(this, SIGNAL(appToBeClosed()), qml, SLOT(appToBeClosed())); connect(this, SIGNAL(editorCleared(QString,QString)), qml, SLOT(editorCleared(QString,QString))); }