From 238983ed0d16e3c62ab9be49dc96cb41b945bb33 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sun, 26 Feb 2017 20:30:38 +0800 Subject: [PATCH] refine all messages --- src/dialog/vdirinfodialog.cpp | 2 +- src/dialog/vfileinfodialog.cpp | 2 +- src/dialog/vinsertimagedialog.cpp | 2 +- src/dialog/vnewnotebookdialog.cpp | 4 ++-- src/dialog/vsettingsdialog.cpp | 9 +++++---- src/hgmarkdownhighlighter.cpp | 2 +- src/utils/vutils.cpp | 16 ++++++++-------- src/vconfigmanager.cpp | 6 +++--- src/vdirectory.cpp | 18 +++++++++--------- src/vdirectorytree.cpp | 20 ++++++++++---------- src/vedittab.cpp | 20 ++++++++++---------- src/veditwindow.cpp | 2 +- src/vfile.cpp | 2 +- src/vfilelist.cpp | 4 ++-- src/vmainwindow.cpp | 16 ++++++++-------- src/vmarkdownconverter.cpp | 2 +- src/vmdeditoperations.cpp | 8 ++++---- src/vnotebook.cpp | 2 +- src/vnotebookselector.cpp | 2 +- src/vsingleinstanceguard.cpp | 6 +++--- src/vstyleparser.cpp | 10 +++++----- 21 files changed, 78 insertions(+), 77 deletions(-) diff --git a/src/dialog/vdirinfodialog.cpp b/src/dialog/vdirinfodialog.cpp index a667d812..87d2687f 100644 --- a/src/dialog/vdirinfodialog.cpp +++ b/src/dialog/vdirinfodialog.cpp @@ -18,7 +18,7 @@ void VDirInfoDialog::setupUI() if (!info.isEmpty()) { infoLabel = new QLabel(info); } - nameLabel = new QLabel(tr("&Name:")); + nameLabel = new QLabel(tr("Directory &name:")); nameEdit = new QLineEdit(defaultName); nameEdit->selectAll(); nameLabel->setBuddy(nameEdit); diff --git a/src/dialog/vfileinfodialog.cpp b/src/dialog/vfileinfodialog.cpp index f2d3eee3..fdae507f 100644 --- a/src/dialog/vfileinfodialog.cpp +++ b/src/dialog/vfileinfodialog.cpp @@ -18,7 +18,7 @@ void VFileInfoDialog::setupUI() if (!info.isEmpty()) { infoLabel = new QLabel(info); } - nameLabel = new QLabel(tr("&Name:")); + nameLabel = new QLabel(tr("Note &name:")); nameEdit = new QLineEdit(defaultName); nameEdit->selectAll(); nameLabel->setBuddy(nameEdit); diff --git a/src/dialog/vinsertimagedialog.cpp b/src/dialog/vinsertimagedialog.cpp index bf80b316..5e8065a6 100644 --- a/src/dialog/vinsertimagedialog.cpp +++ b/src/dialog/vinsertimagedialog.cpp @@ -90,7 +90,7 @@ QString VInsertImageDialog::getPathInput() const void VInsertImageDialog::handleBrowseBtnClicked() { static QString lastPath = QDir::homePath(); - QString filePath = QFileDialog::getOpenFileName(this, tr("Select the image to be inserted"), + QString filePath = QFileDialog::getOpenFileName(this, tr("Select The Image To Be Inserted"), lastPath, tr("Images (*.png *.xpm *.jpg *.bmp *.gif)")); if (filePath.isNull() || filePath.isEmpty()) { return; diff --git a/src/dialog/vnewnotebookdialog.cpp b/src/dialog/vnewnotebookdialog.cpp index 650bed8c..c01e8206 100644 --- a/src/dialog/vnewnotebookdialog.cpp +++ b/src/dialog/vnewnotebookdialog.cpp @@ -33,7 +33,7 @@ void VNewNotebookDialog::setupUI() importCheck = new QCheckBox(tr("Import existing notebook"), this); importCheck->setChecked(true); - importCheck->setToolTip(tr("When checked, VNote won't create a new config file if there already exists one.")); + importCheck->setToolTip(tr("When checked, VNote won't create a new config file if there already exists one")); QGridLayout *topLayout = new QGridLayout(); topLayout->addWidget(nameLabel, 0, 0); @@ -77,7 +77,7 @@ QString VNewNotebookDialog::getPathInput() const void VNewNotebookDialog::handleBrowseBtnClicked() { - QString dirPath = QFileDialog::getExistingDirectory(this, tr("Select a directory as the path of the notebook"), + QString dirPath = QFileDialog::getExistingDirectory(this, tr("Select A Directory For The Notebook"), QDir::homePath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); pathEdit->setText(dirPath); } diff --git a/src/dialog/vsettingsdialog.cpp b/src/dialog/vsettingsdialog.cpp index c945488a..c24ebf8e 100644 --- a/src/dialog/vsettingsdialog.cpp +++ b/src/dialog/vsettingsdialog.cpp @@ -38,7 +38,7 @@ void VSettingsDialog::loadConfiguration() return; err: VUtils::showMessage(QMessageBox::Warning, tr("Warning"), - QString("Failed to load configuration."), "", + QString("Fail to load configuration."), "", QMessageBox::Ok, QMessageBox::Ok, NULL); QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection); } @@ -57,7 +57,7 @@ void VSettingsDialog::saveConfiguration() return; err: VUtils::showMessage(QMessageBox::Warning, tr("Warning"), - QString("Failed to save configuration. Please try it again."), "", + QString("Fail to save configuration. Please try it again."), "", QMessageBox::Ok, QMessageBox::Ok, NULL); } @@ -66,7 +66,7 @@ const QVector VGeneralTab::c_availableLangs = { "System", "English", "C VGeneralTab::VGeneralTab(QWidget *p_parent) : QWidget(p_parent), m_langChanged(false) { - QLabel *langLabel = new QLabel(tr("Language:")); + QLabel *langLabel = new QLabel(tr("&Language:")); m_langCombo = new QComboBox(this); m_langCombo->addItem(tr("System"), "System"); auto langs = VUtils::getAvailableLanguages(); @@ -75,6 +75,7 @@ VGeneralTab::VGeneralTab(QWidget *p_parent) } connect(m_langCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(handleIndexChange(int))); + langLabel->setBuddy(m_langCombo); QFormLayout *optionLayout = new QFormLayout(); optionLayout->addRow(langLabel, m_langCombo); @@ -120,7 +121,7 @@ bool VGeneralTab::loadLanguage() } } if (!found) { - qWarning() << "invalid language configuration (use default value)"; + qWarning() << "invalid language configuration (using default value)"; m_langCombo->setCurrentIndex(0); } return true; diff --git a/src/hgmarkdownhighlighter.cpp b/src/hgmarkdownhighlighter.cpp index 95bbfb12..68409b63 100644 --- a/src/hgmarkdownhighlighter.cpp +++ b/src/hgmarkdownhighlighter.cpp @@ -241,7 +241,7 @@ void HGMarkdownHighlighter::parse() parseInternal(); if (highlightingStyles.isEmpty()) { - qWarning() << "error: HighlightingStyles is not set"; + qWarning() << "HighlightingStyles is not set"; return; } initBlockHighlightFromResult(nrBlocks); diff --git a/src/utils/vutils.cpp b/src/utils/vutils.cpp index d601ff0c..c15a7c45 100644 --- a/src/utils/vutils.cpp +++ b/src/utils/vutils.cpp @@ -10,7 +10,7 @@ #include #include -const QVector> VUtils::c_availableLanguages = {QPair("en_US", "Englisth (US)"), +const QVector> VUtils::c_availableLanguages = {QPair("en_US", "Englisth(US)"), QPair("zh_CN", "Chinese")}; VUtils::VUtils() @@ -21,7 +21,7 @@ QString VUtils::readFileFromDisk(const QString &filePath) { QFile file(filePath); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qWarning() << "error: fail to read file" << filePath; + qWarning() << "fail to read file" << filePath; return QString(); } QString fileText(file.readAll()); @@ -34,7 +34,7 @@ bool VUtils::writeFileToDisk(const QString &filePath, const QString &text) { QFile file(filePath); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - qWarning() << "error: fail to open file" << filePath << "to write to"; + qWarning() << "fail to open file" << filePath << "to write"; return false; } QTextStream stream(&file); @@ -62,7 +62,7 @@ QRgb VUtils::QRgbFromString(const QString &str) if (ret) { return qRgb(red, green, blue); } - qWarning() << "error: fail to construct QRgb from string" << str; + qWarning() << "fail to construct QRgb from string" << str; return QRgb(); } @@ -194,12 +194,12 @@ bool VUtils::copyFile(const QString &p_srcFilePath, const QString &p_destFilePat if (p_isCut) { QFile file(srcPath); if (!file.rename(destPath)) { - qWarning() << "error: fail to copy file" << srcPath << destPath; + qWarning() << "fail to copy file" << srcPath << destPath; return false; } } else { if (!QFile::copy(srcPath, destPath)) { - qWarning() << "error: fail to copy file" << srcPath << destPath; + qWarning() << "fail to copy file" << srcPath << destPath; return false; } } @@ -219,7 +219,7 @@ bool VUtils::copyDirectory(const QString &p_srcDirPath, const QString &p_destDir QDir parentDir(VUtils::basePathFromPath(p_destDirPath)); QString dirName = VUtils::fileNameFromPath(p_destDirPath); if (!parentDir.mkdir(dirName)) { - qWarning() << QString("failed to create target directory %1: already exists").arg(p_destDirPath); + qWarning() << QString("fail to create target directory %1: already exists").arg(p_destDirPath); return false; } @@ -247,7 +247,7 @@ bool VUtils::copyDirectory(const QString &p_srcDirPath, const QString &p_destDir // Delete the src dir if p_isCut if (p_isCut) { if (!srcDir.removeRecursively()) { - qWarning() << "failed to remove directory" << p_srcDirPath; + qWarning() << "fail to remove directory" << p_srcDirPath; return false; } } diff --git a/src/vconfigmanager.cpp b/src/vconfigmanager.cpp index 25845304..080f627d 100644 --- a/src/vconfigmanager.cpp +++ b/src/vconfigmanager.cpp @@ -165,7 +165,7 @@ QJsonObject VConfigManager::readDirectoryConfig(const QString &path) qDebug() << "read config file:" << configFile; QFile config(configFile); if (!config.open(QIODevice::ReadOnly)) { - qWarning() << "error: fail to read directory configuration file:" + qWarning() << "fail to read directory configuration file:" << configFile; return QJsonObject(); } @@ -188,7 +188,7 @@ bool VConfigManager::writeDirectoryConfig(const QString &path, const QJsonObject qDebug() << "write config file:" << configFile; QFile config(configFile); if (!config.open(QIODevice::WriteOnly)) { - qWarning() << "error: fail to open directory configuration file for write:" + qWarning() << "fail to open directory configuration file for write:" << configFile; return false; } @@ -204,7 +204,7 @@ bool VConfigManager::deleteDirectoryConfig(const QString &path) QFile config(configFile); if (!config.remove()) { - qWarning() << "error: fail to delete directory configuration file:" + qWarning() << "fail to delete directory configuration file:" << configFile; return false; } diff --git a/src/vdirectory.cpp b/src/vdirectory.cpp index e680d2cd..5059f6a5 100644 --- a/src/vdirectory.cpp +++ b/src/vdirectory.cpp @@ -117,7 +117,7 @@ VDirectory *VDirectory::createSubDirectory(const QString &p_name) QString path = retrivePath(); QDir dir(path); if (!dir.mkdir(p_name)) { - qWarning() << "failed to create directory" << p_name << "under" << path; + qWarning() << "fail to create directory" << p_name << "under" << path; return NULL; } @@ -210,7 +210,7 @@ VFile *VDirectory::createFile(const QString &p_name) QString filePath = QDir(path).filePath(p_name); QFile file(filePath); if (!file.open(QIODevice::WriteOnly)) { - qWarning() << "failed to create file" << p_name; + qWarning() << "fail to create file" << p_name; return NULL; } file.close(); @@ -330,7 +330,7 @@ void VDirectory::deleteSubDirectory(VDirectory *p_subDir) p_subDir->close(); QDir dir(dirPath); if (!dir.removeRecursively()) { - qWarning() << "failed to remove" << dirPath << "recursively"; + qWarning() << "fail to remove" << dirPath << "recursively"; } else { qDebug() << "deleted" << dirPath; } @@ -370,7 +370,7 @@ int VDirectory::removeSubDirectory(VDirectory *p_dir) Q_ASSERT(deleted); dirJson["sub_directories"] = subDirArray; if (!VConfigManager::writeDirectoryConfig(path, dirJson)) { - qWarning() << "failed to update configuration in" << path; + qWarning() << "fail to update configuration in" << path; } return index; } @@ -409,7 +409,7 @@ int VDirectory::removeFile(VFile *p_file) Q_ASSERT(deleted); dirJson["files"] = subFileArray; if (!VConfigManager::writeDirectoryConfig(path, dirJson)) { - qWarning() << "failed to update configuration in" << path; + qWarning() << "fail to update configuration in" << path; } return index; } @@ -435,7 +435,7 @@ bool VDirectory::rename(const QString &p_name) QDir dir(parentPath); QString name = m_name; if (!dir.rename(m_name, p_name)) { - qWarning() << "failed to rename directory" << m_name << "to" << p_name; + qWarning() << "fail to rename directory" << m_name << "to" << p_name; return false; } m_name = p_name; @@ -522,8 +522,8 @@ VFile *VDirectory::copyFile(VDirectory *p_destDir, const QString &p_destName, nrPasted++; } else { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), - QString("Failed to copy image %1.").arg(images[i]), - tr("Please check if there already exists a file with the same name and manually copy it."), + QString("Fail to copy image %1.").arg(images[i]), + tr("Please check if there already exists a file with the same name and then manually copy it."), QMessageBox::Ok, QMessageBox::Ok, NULL); } } @@ -591,7 +591,7 @@ void VDirectory::reorderFiles(int p_first, int p_last, int p_destStart) Q_ASSERT(p_destStart >= 0 && p_destStart <= m_files.size()); if (!reorderFilesInConfig(p_first, p_last, p_destStart)) { - qWarning() << "failed to reorder files in config" << p_first << p_last << p_destStart; + qWarning() << "fail to reorder files in config" << p_first << p_last << p_destStart; return; } diff --git a/src/vdirectorytree.cpp b/src/vdirectorytree.cpp index e4059de2..f9db456c 100644 --- a/src/vdirectorytree.cpp +++ b/src/vdirectorytree.cpp @@ -65,7 +65,7 @@ void VDirectoryTree::initActions() pasteAct = new QAction(QIcon(":/resources/icons/paste.svg"), tr("&Paste"), this); - pasteAct->setStatusTip(tr("Paste directories")); + pasteAct->setStatusTip(tr("Paste directories under this directory")); connect(pasteAct, &QAction::triggered, this, &VDirectoryTree::pasteDirectoriesInCurDir); } @@ -91,7 +91,7 @@ void VDirectoryTree::setNotebook(VNotebook *p_notebook) } if (!m_notebook->open()) { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), - QString("Failed to open notebook %1").arg(m_notebook->getName()), "", + QString("Fail to open notebook %1.").arg(m_notebook->getName()), "", QMessageBox::Ok, QMessageBox::Ok, this); clear(); return; @@ -134,7 +134,7 @@ void VDirectoryTree::updateDirectoryTreeOne(QTreeWidgetItem *p_parent, int depth VDirectory *dir = getVDirectory(p_parent); if (!dir->open()) { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), - QString("Failed to open directory %1").arg(dir->getName()), "", + QString("Fail to open directory %1.").arg(dir->getName()), "", QMessageBox::Ok, QMessageBox::Ok, this); return; } @@ -296,7 +296,7 @@ void VDirectoryTree::newSubDirectory() VDirectory *curDir = getVDirectory(curItem); QString info = QString("Create sub-directory under %1.").arg(curDir->getName()); - QString text("&Directory name:"); + QString text("Directory &name:"); QString defaultText("new_directory"); do { @@ -311,7 +311,7 @@ void VDirectoryTree::newSubDirectory() VDirectory *subDir = curDir->createSubDirectory(name); if (!subDir) { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), - QString("Failed to create directory %1.").arg(name), "", + QString("Fail to create directory %1.").arg(name), "", QMessageBox::Ok, QMessageBox::Ok, this); return; } @@ -328,7 +328,7 @@ void VDirectoryTree::newRootDirectory() return; } QString info = QString("Create root directory in notebook %1.").arg(m_notebook->getName()); - QString text("&Directory name:"); + QString text("Directory &name:"); QString defaultText("new_directory"); VDirectory *rootDir = m_notebook->getRootDir(); do { @@ -343,7 +343,7 @@ void VDirectoryTree::newRootDirectory() VDirectory *subDir = rootDir->createSubDirectory(name); if (!subDir) { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), - QString("Failed to create directory %1.").arg(name), "", + QString("Fail to create directory %1.").arg(name), "", QMessageBox::Ok, QMessageBox::Ok, this); return; } @@ -410,7 +410,7 @@ void VDirectoryTree::editDirectoryInfo() } if (!curDir->rename(name)) { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), - QString("Failed to rename directory %1.").arg(curName), "", + QString("Fail to rename directory %1.").arg(curName), "", QMessageBox::Ok, QMessageBox::Ok, this); return; } @@ -552,8 +552,8 @@ bool VDirectoryTree::copyDirectory(VDirectory *p_destDir, const QString &p_destN emit directoryUpdated(destDir); } else { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), - QString("Failed to copy directory %1.").arg(srcName), - QString("Please check if there alread exists a directory with the same name"), + QString("Fail to copy directory %1.").arg(srcName), + QString("Please check if there alread exists a directory with the same name."), QMessageBox::Ok, QMessageBox::Ok, this); } diff --git a/src/vedittab.cpp b/src/vedittab.cpp index 0221d0c9..1ee11d2f 100644 --- a/src/vedittab.cpp +++ b/src/vedittab.cpp @@ -79,7 +79,7 @@ void VEditTab::setupUI() webPreviewer = NULL; break; default: - qWarning() << "error: unknown doc type" << int(m_file->getDocType()); + qWarning() << "unknown doc type" << int(m_file->getDocType()); Q_ASSERT(false); } } @@ -119,7 +119,7 @@ void VEditTab::showFileReadMode() scrollPreviewToHeader(outlineIndex); break; default: - qWarning() << "error: unknown doc type" << int(m_file->getDocType()); + qWarning() << "unknown doc type" << int(m_file->getDocType()); Q_ASSERT(false); } noticeStatusChanged(); @@ -221,7 +221,7 @@ void VEditTab::readFile() // Nothing to do if user cancel this action return; default: - qWarning() << "error: wrong return value from QMessageBox:" << ret; + qWarning() << "wrong return value from QMessageBox:" << ret; return; } } @@ -240,7 +240,7 @@ bool VEditTab::saveFile() QString filePath = m_file->retrivePath(); if (!QFile(filePath).exists()) { qWarning() << filePath << "being written has been removed"; - VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to save note"), + VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to save note."), QString("%1 being written has been removed.").arg(filePath), QMessageBox::Ok, QMessageBox::Ok, this); return false; @@ -248,7 +248,7 @@ bool VEditTab::saveFile() m_textEditor->saveFile(); ret = m_file->save(); if (!ret) { - VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to save note"), + VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to save note."), QString("Fail to write to disk when saving a note. Please try it again."), QMessageBox::Ok, QMessageBox::Ok, this); m_textEditor->setModified(true); @@ -312,11 +312,11 @@ void VEditTab::updateTocFromHtml(const QString &tocHtml) if (xml.name() == "ul") { parseTocUl(xml, headers, 1); } else { - qWarning() << "error: TOC HTML does not start with