mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
use "image" as the default image title
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
a3926631e2
commit
59611872d4
@ -6,7 +6,7 @@
|
|||||||
VInsertImageDialog::VInsertImageDialog(const QString &title, const QString &defaultImageTitle,
|
VInsertImageDialog::VInsertImageDialog(const QString &title, const QString &defaultImageTitle,
|
||||||
const QString &defaultPath, QWidget *parent)
|
const QString &defaultPath, QWidget *parent)
|
||||||
: QDialog(parent), title(title), defaultImageTitle(defaultImageTitle), defaultPath(defaultPath),
|
: QDialog(parent), title(title), defaultImageTitle(defaultImageTitle), defaultPath(defaultPath),
|
||||||
image(NULL), browseable(true)
|
image(NULL)
|
||||||
{
|
{
|
||||||
setupUI();
|
setupUI();
|
||||||
|
|
||||||
@ -126,12 +126,14 @@ void VInsertImageDialog::setImage(const QImage &image)
|
|||||||
enableOkButton();
|
enableOkButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VInsertImageDialog::setBrowseable(bool browseable)
|
void VInsertImageDialog::setBrowseable(bool browseable, bool visible)
|
||||||
{
|
{
|
||||||
this->browseable = browseable;
|
pathEdit->setReadOnly(!browseable);
|
||||||
pathLabel->setVisible(browseable);
|
browseBtn->setEnabled(browseable);
|
||||||
pathEdit->setVisible(browseable);
|
|
||||||
browseBtn->setVisible(browseable);
|
pathLabel->setVisible(visible);
|
||||||
|
pathEdit->setVisible(visible);
|
||||||
|
browseBtn->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VInsertImageDialog::imageDownloaded(const QByteArray &data)
|
void VInsertImageDialog::imageDownloaded(const QByteArray &data)
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
|
|
||||||
void setImage(const QImage &image);
|
void setImage(const QImage &image);
|
||||||
QImage getImage() const;
|
QImage getImage() const;
|
||||||
void setBrowseable(bool browseable);
|
void setBrowseable(bool browseable, bool visible = false);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void imageDownloaded(const QByteArray &data);
|
void imageDownloaded(const QByteArray &data);
|
||||||
@ -48,7 +48,6 @@ private:
|
|||||||
QString defaultImageTitle;
|
QString defaultImageTitle;
|
||||||
QString defaultPath;
|
QString defaultPath;
|
||||||
QImage *image;
|
QImage *image;
|
||||||
bool browseable;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VINSERTIMAGEDIALOG_H
|
#endif // VINSERTIMAGEDIALOG_H
|
||||||
|
@ -515,7 +515,7 @@ void VMainWindow::importNoteFromFile()
|
|||||||
{
|
{
|
||||||
static QString lastPath = QDir::homePath();
|
static QString lastPath = QDir::homePath();
|
||||||
QStringList files = QFileDialog::getOpenFileNames(this,
|
QStringList files = QFileDialog::getOpenFileNames(this,
|
||||||
tr("Select files(HTML or Markdown) to be imported as notes"),
|
tr("Select Files(HTML or Markdown) To Import"),
|
||||||
lastPath);
|
lastPath);
|
||||||
if (files.isEmpty()) {
|
if (files.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include "vfile.h"
|
#include "vfile.h"
|
||||||
#include "vmdedit.h"
|
#include "vmdedit.h"
|
||||||
|
|
||||||
|
const QString VMdEditOperations::c_defaultImageTitle = "image";
|
||||||
|
|
||||||
VMdEditOperations::VMdEditOperations(VEdit *p_editor, VFile *p_file)
|
VMdEditOperations::VMdEditOperations(VEdit *p_editor, VFile *p_file)
|
||||||
: VEditOperations(p_editor, p_file)
|
: VEditOperations(p_editor, p_file)
|
||||||
{
|
{
|
||||||
@ -35,8 +37,8 @@ bool VMdEditOperations::insertImageFromMimeData(const QMimeData *source)
|
|||||||
if (image.isNull()) {
|
if (image.isNull()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
VInsertImageDialog dialog(tr("Insert image from clipboard"), tr("image_title"),
|
VInsertImageDialog dialog(tr("Insert Image From Clipboard"),
|
||||||
"", (QWidget *)m_editor);
|
c_defaultImageTitle, "", (QWidget *)m_editor);
|
||||||
dialog.setBrowseable(false);
|
dialog.setBrowseable(false);
|
||||||
dialog.setImage(image);
|
dialog.setImage(image);
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
@ -110,15 +112,16 @@ bool VMdEditOperations::insertImageFromURL(const QUrl &imageUrl)
|
|||||||
qWarning() << "error: image is null";
|
qWarning() << "error: image is null";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
title = "Insert image from file";
|
title = "Insert Image From File";
|
||||||
} else {
|
} else {
|
||||||
imagePath = imageUrl.toString();
|
imagePath = imageUrl.toString();
|
||||||
title = "Insert image from network";
|
title = "Insert Image From Network";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VInsertImageDialog dialog(title, QObject::tr("image_title"), imagePath, (QWidget *)m_editor);
|
VInsertImageDialog dialog(title, c_defaultImageTitle,
|
||||||
dialog.setBrowseable(false);
|
imagePath, (QWidget *)m_editor);
|
||||||
|
dialog.setBrowseable(false, true);
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
dialog.setImage(image);
|
dialog.setImage(image);
|
||||||
} else {
|
} else {
|
||||||
@ -161,8 +164,8 @@ bool VMdEditOperations::insertURLFromMimeData(const QMimeData *source)
|
|||||||
|
|
||||||
bool VMdEditOperations::insertImage()
|
bool VMdEditOperations::insertImage()
|
||||||
{
|
{
|
||||||
VInsertImageDialog dialog(tr("Insert Image From File"), tr("image_title"),
|
VInsertImageDialog dialog(tr("Insert Image From File"),
|
||||||
"", (QWidget *)m_editor);
|
c_defaultImageTitle, "", (QWidget *)m_editor);
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
QString title = dialog.getImageTitleInput();
|
QString title = dialog.getImageTitleInput();
|
||||||
QString imagePath = dialog.getPathInput();
|
QString imagePath = dialog.getPathInput();
|
||||||
|
@ -46,6 +46,8 @@ private:
|
|||||||
bool suffixNumAllowed(const QList<QString> &p_seq);
|
bool suffixNumAllowed(const QList<QString> &p_seq);
|
||||||
|
|
||||||
QTimer *m_pendingTimer;
|
QTimer *m_pendingTimer;
|
||||||
|
|
||||||
|
static const QString c_defaultImageTitle;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VMDEDITOPERATIONS_H
|
#endif // VMDEDITOPERATIONS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user