void KexiImageContextMenu::insertFromFile() { // QWidget *focusWidget = qApp->focusWidget(); #ifdef Q_WS_WIN QString recentDir; QString fileName = QFileDialog::getOpenFileName( KFileDialog::getStartURL(":LastVisitedImagePath", recentDir).path(), convertKFileDialogFilterToQFileDialogFilter(KImageIO::pattern(KImageIO::Reading)), this, 0, i18n("Insert Image From File")); KURL url; if (!fileName.isEmpty()) url.setPath( fileName ); #else KURL url( KFileDialog::getImageOpenURL( ":LastVisitedImagePath", this, i18n("Insert Image From File")) ); // QString fileName = url.isLocalFile() ? url.path() : url.prettyURL(); //! @todo download the file if remote, then set fileName properly #endif if (!url.isValid()) { //focus the app again because to avoid annoying the user with unfocused main window if (qApp->mainWidget()) { //focusWidget->raise(); //focusWidget->setFocus(); qApp->mainWidget()->raise(); } return; } kexipluginsdbg << "fname=" << url.prettyURL() << endl; #ifdef Q_WS_WIN //save last visited path // KURL url(fileName); if (url.isLocalFile()) KRecentDirs::add(":LastVisitedImagePath", url.directory()); #endif emit insertFromFileRequested(url); if (qApp->mainWidget()) { // focusWidget->raise(); // focusWidget->setFocus(); qApp->mainWidget()->raise(); } }
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 }