fixed app icons

error handling
v0.1
master v0.1
Tibor 9 months ago
parent 015ada883e
commit c72989a9a8
  1. 2
      NNotes.pro
  2. 43
      config.cpp
  3. 12
      main.cpp
  4. 2
      nnotes.example.cfg
  5. 2
      qml.qrc

@ -36,7 +36,7 @@ HEADERS += \
log.h \
notehandler.h
win32:RC_ICONS += appicon.ico
win32:RC_ICONS += res/appicon.ico
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/3rdparty/config4cpp/lib/ -lconfig4cpp
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/3rdparty/config4cpp/lib/ -lconfig4cpp

@ -1,8 +1,11 @@
#include "config.h"
#include <QFile>
#include <QMessageBox>
#include <QOperatingSystemVersion>
#define QSTR(x) QObject::tr(x)
namespace tai {
config::config(std::vector<QString> const& options)
{
@ -11,6 +14,34 @@ config::config(std::vector<QString> const& options)
std::string scope {};
std::string filename { "nnotes.cfg" };
if (!QFile::exists(filename.c_str())) {
QMessageBox box {
QMessageBox::Warning,
QSTR("Configuration file not found"),
QSTR("The NNotes configuration file could not be found. Trying to generate config file from nnotes.example.cfg.")
};
box.setModal(true);
box.exec();
LOG_WRN("Unable to find nnotes.cfg. Trying to copy from nnotes.example.cfg.");
if (!QFile::copy("nnotes.example.cfg", filename.c_str())) {
QMessageBox box {
QMessageBox::Critical,
QSTR("File operation error"),
QSTR("The application was unable to copy the nnotes.example.cfg to nnotes.cfg. Exiting.")
};
box.setModal(true);
box.exec();
LOG_FTL("Unable to copy nnotes.example.cfg -> nnotes.cfg.");
LOG_FTL("Exiting.");
assert(false);
exit(-1);
}
}
try {
_config->parse(filename.c_str());
@ -23,6 +54,14 @@ config::config(std::vector<QString> const& options)
LOG_INF("Parsed " + std::to_string(_options.size()) + " config options.");
LOG_INF("Configuration parsing complete.");
} catch (config4cpp::ConfigurationException const& ce) {
QMessageBox box {
QMessageBox::Critical,
QSTR("Critical application error"),
QSTR("Unable to read from config file. Please make sure nnotes.cfg exists in your NNotes root directory. Exiting.")
};
box.setModal(true);
box.exec();
LOG_FTL("Unable to read from config file: " + std::string(ce.c_str()));
LOG_FTL("Exiting.");
@ -76,8 +115,8 @@ QString config::getNextcloudFolder()
QString ncConfigPath {};
if (QOperatingSystemVersion::currentType() == QOperatingSystemVersion::Windows) {
QString appdata { qgetenv("APPDATA") };
ncConfigPath = appdata.append("\\Nextcloud\\nextcloud.cfg");
QString const appdata { qgetenv("APPDATA") };
ncConfigPath = appdata + "\\Nextcloud\\nextcloud.cfg";
}
else if (QOperatingSystemVersion::currentType() == QOperatingSystemVersion::MacOS) {
// TODO what are the Nextcloud paths for MacOS?

@ -94,13 +94,13 @@ int main(int argc, char *argv[])
// Read from folder
QString notesFolder { conf->getNextcloudFolder() + QDir::separator() + "Notes" };
QString notesFolder { conf->getNextcloudFolder() };
if (notesFolder.isEmpty()) {
QMessageBox box {
QMessageBox::Warning,
QSTR("Nextcloud configuration not found"),
QSTR("Your Nextcloud configuration file couldn't be found. Trying to read path from nnotes.cfg...")
QSTR("Nextcloud folder not found"),
QSTR("NNotes was unable to autodiscover the Nextcloud path and will now try to read it from nnotes.cfg in your NNotes root directory.")
};
box.setModal(true);
box.exec();
@ -111,11 +111,15 @@ int main(int argc, char *argv[])
QMessageBox box {
QMessageBox::Warning,
QSTR("Path not provided"),
QSTR("The path to your Nextcloud folder hasn't been configured yet in your nnotes.cfg file. Please set it using File -> Change Nextcloud folder.")
QSTR("The path to your Nextcloud folder hasn't been configured yet in your nnotes.cfg file, thus your view will be empty.\nPlease set the correct directory path using\n\nFile -> Change Nextcloud folder...\n\nor exit the application and manually set it in the nnotes.cfg file in your NNotes root directory.")
};
box.setModal(true);
box.exec();
notesFolder = "/examplePath";
}
notesFolder.append(QDir::separator()).append("Notes");
}
// Get the notes

@ -1,3 +1,3 @@
# general
# nextcloud folder path (absolute)
path = "/path/to/my/nextcloud_folder";
path = "";

@ -4,7 +4,7 @@
<file>NoteTreeView.qml</file>
<file>DirectoryDialog.qml</file>
<file>res/add.png</file>
<file>res/appicon.ico</file>
<file>res/notes.png</file>
<file>res/appicon.ico</file>
</qresource>
</RCC>

Loading…
Cancel
Save