mirror of https://github.com/vitalif/openscad
#1065 Show progress dialog while building font cache
parent
3d0749b619
commit
1aef9f2758
|
@ -81,6 +81,9 @@ const std::string &FontInfo::get_file() const
|
|||
}
|
||||
|
||||
FontCache * FontCache::self = NULL;
|
||||
FontCache::ProgressHandlerFunc *FontCache::start_cb = NULL;
|
||||
FontCache::ProgressHandlerFunc *FontCache::end_cb = NULL;
|
||||
void *FontCache::cb_userdata = NULL;
|
||||
const std::string FontCache::DEFAULT_FONT("XXX");
|
||||
|
||||
FontCache::FontCache()
|
||||
|
@ -131,8 +134,9 @@ FontCache::FontCache()
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: Caching happens here. This would be a good place to notify the user
|
||||
if (FontCache::start_cb) FontCache::start_cb(FontCache::cb_userdata);
|
||||
FcConfigBuildFonts(this->config);
|
||||
if (FontCache::end_cb) FontCache::end_cb(FontCache::cb_userdata);
|
||||
|
||||
// For use by LibraryInfo
|
||||
FcStrList *dirs = FcConfigGetFontDirs(this->config);
|
||||
|
@ -162,6 +166,13 @@ FontCache * FontCache::instance()
|
|||
return self;
|
||||
}
|
||||
|
||||
void FontCache::registerProgressHandler(ProgressHandlerFunc *start, ProgressHandlerFunc *end, void *userdata)
|
||||
{
|
||||
FontCache::start_cb = start;
|
||||
FontCache::end_cb = end;
|
||||
FontCache::cb_userdata = userdata;
|
||||
}
|
||||
|
||||
void FontCache::register_font_file(const std::string &path)
|
||||
{
|
||||
if (!FcConfigAppFontAddFile(this->config, reinterpret_cast<const FcChar8 *> (path.c_str()))) {
|
||||
|
|
|
@ -75,11 +75,17 @@ public:
|
|||
FontInfoList *list_fonts() const;
|
||||
|
||||
static FontCache *instance();
|
||||
|
||||
typedef void (ProgressHandlerFunc)(void *userdata);
|
||||
static void registerProgressHandler(ProgressHandlerFunc *start, ProgressHandlerFunc *end, void *userdata = NULL);
|
||||
private:
|
||||
typedef std::pair<FT_Face, time_t> cache_entry_t;
|
||||
typedef std::map<std::string, cache_entry_t> cache_t;
|
||||
|
||||
static FontCache *self;
|
||||
static ProgressHandlerFunc *start_cb;
|
||||
static ProgressHandlerFunc *end_cb;
|
||||
static void *cb_userdata;
|
||||
|
||||
bool init_ok;
|
||||
cache_t cache;
|
||||
|
|
|
@ -105,6 +105,7 @@ mark_domains(CDT &cdt)
|
|||
*/
|
||||
PolySet *Polygon2d::tessellate() const
|
||||
{
|
||||
PRINTDB("Polygon2d::tessellate(): %d outlines", this->outlines().size());
|
||||
PolySet *polyset = new PolySet(*this);
|
||||
|
||||
Polygon2DCGAL::CDT cdt; // Uses a constrained Delaunay triangulator.
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "nodedumper.h"
|
||||
#include "stackcheck.h"
|
||||
#include "CocoaUtils.h"
|
||||
#include "FontCache.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -577,6 +578,22 @@ bool QtUseGUI()
|
|||
return useGUI;
|
||||
}
|
||||
|
||||
|
||||
#include <QProgressDialog>
|
||||
QProgressDialog *fontCacheProgress = NULL;
|
||||
|
||||
void fontCacheStart(void *userdata)
|
||||
{
|
||||
fontCacheProgress = new QProgressDialog("Fontconfig needs to update its font cache.\nThis can take up to a couple of minutes.", QString(), 0, 0);
|
||||
fontCacheProgress->show();
|
||||
}
|
||||
|
||||
void fontCacheEnd(void *userdata)
|
||||
{
|
||||
delete fontCacheProgress;
|
||||
fontCacheProgress = NULL;
|
||||
}
|
||||
|
||||
int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, char ** argv)
|
||||
{
|
||||
#ifdef Q_OS_MACX
|
||||
|
@ -607,6 +624,10 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
|
|||
const QString &app_path = app.applicationDirPath();
|
||||
PlatformUtils::registerApplicationPath(app_path.toLocal8Bit().constData());
|
||||
|
||||
FontCache::registerProgressHandler(fontCacheStart, fontCacheEnd);
|
||||
|
||||
|
||||
|
||||
parser_init();
|
||||
|
||||
QSettings settings;
|
||||
|
|
Loading…
Reference in New Issue