freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 74abe30 17/41: [ftinspect] Support opening file


From: Werner Lemberg
Subject: [freetype2-demos] master 74abe30 17/41: [ftinspect] Support opening files via command-line.
Date: Mon, 3 Oct 2022 11:27:02 -0400 (EDT)

branch: master
commit 74abe305386f2ad63ae0bf919b364f2be3bc6387
Author: Charlie Jiang <w@chariri.moe>
Commit: Werner Lemberg <wl@gnu.org>

    [ftinspect] Support opening files via command-line.
    
    * src/ftinspect/engine/fontfilemanager.cpp,
      src/ftinspect/engine/fontfilemanager.hpp:
      Add `loadFromCommandLine` func.
    
    * src/ftinspect/maingui.cpp, src/ftinspect/maingui.hpp:
      Add and call `loadCommandLine` func.
---
 src/ftinspect/engine/fontfilemanager.cpp | 12 ++++++++++++
 src/ftinspect/engine/fontfilemanager.hpp |  3 ++-
 src/ftinspect/maingui.cpp                | 12 +++++++++++-
 src/ftinspect/maingui.hpp                |  2 ++
 4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/ftinspect/engine/fontfilemanager.cpp 
b/src/ftinspect/engine/fontfilemanager.cpp
index c995624..9b44fce 100644
--- a/src/ftinspect/engine/fontfilemanager.cpp
+++ b/src/ftinspect/engine/fontfilemanager.cpp
@@ -153,6 +153,18 @@ FontFileManager::timerStart()
 }
 
 
+void
+FontFileManager::loadFromCommandLine()
+{
+  // TODO: To support more complicated command line, we need to move this away
+  // and use `QCommandLineParser`
+  auto args = QCoreApplication::arguments();
+  if (!args.empty())
+    args.removeFirst();
+  append(args, true);
+}
+
+
 void
 FontFileManager::onWatcherFire()
 {
diff --git a/src/ftinspect/engine/fontfilemanager.hpp 
b/src/ftinspect/engine/fontfilemanager.hpp
index a13714e..06a8f52 100644
--- a/src/ftinspect/engine/fontfilemanager.hpp
+++ b/src/ftinspect/engine/fontfilemanager.hpp
@@ -32,7 +32,8 @@ public:
   QFileInfo& operator[](int index);
   void updateWatching(int index);
   void timerStart();
-  
+  void loadFromCommandLine();
+
 signals:
   void currentFileChanged();
 
diff --git a/src/ftinspect/maingui.cpp b/src/ftinspect/maingui.cpp
index db13014..b797a00 100644
--- a/src/ftinspect/maingui.cpp
+++ b/src/ftinspect/maingui.cpp
@@ -24,7 +24,9 @@ MainGUI::MainGUI(Engine* engine)
   readSettings();
   setUnifiedTitleAndToolBarOnMac(true);
 
-  show();
+  show(); // place this before `loadCommandLine` so alerts from loading
+          // won't be covered.
+  loadCommandLine();
 }
 
 
@@ -106,6 +108,14 @@ MainGUI::openFonts(QStringList const& fileNames)
 }
 
 
+void
+MainGUI::loadCommandLine()
+{
+  engine_->fontFileManager().loadFromCommandLine();
+  tripletSelector_->repopulateFonts();
+}
+
+
 void
 MainGUI::onTripletChanged()
 {
diff --git a/src/ftinspect/maingui.hpp b/src/ftinspect/maingui.hpp
index cfe03aa..cffc071 100644
--- a/src/ftinspect/maingui.hpp
+++ b/src/ftinspect/maingui.hpp
@@ -99,6 +99,8 @@ private:
 
   void readSettings();
   void writeSettings();
+
+  void loadCommandLine();
 };
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]