alopatindev / qfontviewer

Font viewer with character table
https://qfontviewer.sourceforge.net
GNU General Public License v3.0
4 stars 2 forks source link

Suggestion: Add cmakefile #3

Open milnak opened 4 months ago

milnak commented 4 months ago

I added a cmakefile and was able to build and run this on Windows. Here's the diff. I built using VS Build Tools and vcpkg. LEt me know if you prefer a PR.

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..29e0566
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+builds/
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..8386ff8
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,37 @@
+# https://doc.qt.io/qt-5/cmake-get-started.html
+cmake_minimum_required(VERSION 3.5)
+
+project(
+  qfontviewer
+  VERSION 1.0.0
+  LANGUAGES CXX)
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(CMAKE_VERSION VERSION_LESS "3.7.0")
+  set(CMAKE_INCLUDE_CURRENT_DIR ON)
+endif()
+
+find_package(
+  Qt5
+  COMPONENTS Widgets
+  REQUIRED)
+
+add_executable(
+  qfontviewer
+  chardialog.ui
+  chardialog.cpp
+  charstable.cpp
+  lineeditautoclean.cpp
+  mainwindow.ui
+  mainwindow.cpp
+  settingsdialog.ui
+  settingsdialog.cpp
+  main.cpp)
+
+target_link_libraries(qfontviewer Qt5::Widgets)
diff --git a/charstable.cpp b/charstable.cpp
index 94f5183..26679a3 100644
--- a/charstable.cpp
+++ b/charstable.cpp
@@ -119,11 +119,6 @@ QString CharsTable::textChar(uint codepoint)
     }
 }

-inline QString CharsTable::xmlDecimal(uint key, bool escape)
-{
-    return QString(escape ? "&#%1;" : "&#%1;").arg(key);
-}
-
 void CharsTable::goToChar(const QString & character)
 {
     QVector<uint> codepoints = character.toUcs4();
diff --git a/charstable.h b/charstable.h
index 3d03019..73e4ce2 100644
--- a/charstable.h
+++ b/charstable.h
@@ -51,7 +51,10 @@ public slots:
     void setSubset(QFontDatabase::WritingSystem subset);
     static QString unicodeChar(uint key);
     static QString utf8Char(uint ch);
-    inline static QString xmlDecimal(uint key, bool escape = false);
+    inline static QString xmlDecimal(uint key, bool escape = false)
+    {
+        return QString(escape ? "&amp;#%1;" : "&#%1;").arg(key);
+    }
     uint currentKey() { return key; }
     QString currentChar() { return CharsTable::textChar(key); }
     void goToChar(uint character);
milnak commented 4 months ago

Presumably this would enable a Mac build (on your TODO) as well.