[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 59b8e4e: [ftinspect] Add file dialogs.
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master 59b8e4e: [ftinspect] Add file dialogs. |
Date: |
Tue, 03 May 2016 20:13:19 +0000 |
branch: master
commit 59b8e4e8392a645cbdbc092d09a3bd9a8411319a
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
[ftinspect] Add file dialogs.
* src/ftinspect.h: Include some more Qt headers.
(MainGUI): Add `fontFileNames' and `currentFontFileIndex'.
Add actions to load and close font files.
* src/ftinspect.cpp (MainGUI::loadFonts, MainGUI::closeFont): New
methods.
(MainGUI::createActions, MainGUI::createMenus,
MainGUI::setDefaults): Updated.
---
ChangeLog | 13 +++++++++++++
src/ftinspect.cpp | 41 +++++++++++++++++++++++++++++++++++++++++
src/ftinspect.h | 9 +++++++++
3 files changed, 63 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 520c27f..cbfe334 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2016-05-03 Werner Lemberg <address@hidden>
+ [ftinspect] Add file dialogs.
+
+ * src/ftinspect.h: Include some more Qt headers.
+ (MainGUI): Add `fontFileNames' and `currentFontFileIndex'.
+ Add actions to load and close font files.
+
+ * src/ftinspect.cpp (MainGUI::loadFonts, MainGUI::closeFont): New
+ methods.
+ (MainGUI::createActions, MainGUI::createMenus,
+ MainGUI::setDefaults): Updated.
+
+2016-05-03 Werner Lemberg <address@hidden>
+
[ftinspect] Better code.
* src/ftinspect.h (QComboBoxx): New class, derived from `QComboBox';
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index 7402b0c..ef1d2c7 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -150,6 +150,35 @@ MainGUI::about()
void
+MainGUI::loadFonts()
+{
+ QStringList files = QFileDialog::getOpenFileNames(
+ this,
+ tr("Load one or more fonts"),
+ QDir::homePath(),
+ "",
+ NULL,
+ QFileDialog::ReadOnly);
+ fontFileNames += files;
+
+ if (!fontFileNames.isEmpty() && currentFontFileIndex == -1)
+ currentFontFileIndex = 0;
+}
+
+
+void
+MainGUI::closeFont()
+{
+ if (currentFontFileIndex >= 0)
+ fontFileNames.removeAt(currentFontFileIndex);
+ if (currentFontFileIndex >= fontFileNames.size())
+ currentFontFileIndex--;
+
+ // XXX trigger redisplay
+}
+
+
+void
MainGUI::checkHintingMode()
{
int index = hintingModeComboBoxx->currentIndex();
@@ -518,6 +547,14 @@ MainGUI::createConnections()
void
MainGUI::createActions()
{
+ loadFontsAct = new QAction(tr("&Load Fonts"), this);
+ loadFontsAct->setShortcuts(QKeySequence::Open);
+ connect(loadFontsAct, SIGNAL(triggered()), this, SLOT(loadFonts()));
+
+ closeFontAct = new QAction(tr("&Close Font"), this);
+ closeFontAct->setShortcuts(QKeySequence::Close);
+ connect(closeFontAct, SIGNAL(triggered()), this, SLOT(closeFont()));
+
exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
@@ -534,6 +571,8 @@ void
MainGUI::createMenus()
{
menuFile = menuBar()->addMenu(tr("&File"));
+ menuFile->addAction(loadFontsAct);
+ menuFile->addAction(closeFontAct);
menuFile->addAction(exitAct);
menuHelp = menuBar()->addMenu(tr("&Help"));
@@ -560,6 +599,8 @@ MainGUI::clearStatusBar()
void
MainGUI::setDefaults()
{
+ currentFontFileIndex = -1;
+
// XXX only dummy values right now
hintingModeComboBoxx->setCurrentIndex(HintingMode_TrueType_v35);
diff --git a/src/ftinspect.h b/src/ftinspect.h
index 87e2418..c96b476 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -14,7 +14,9 @@
#include <QCloseEvent>
#include <QComboBox>
#include <QDesktopWidget>
+#include <QDir>
#include <QDoubleSpinBox>
+#include <QFileDialog>
#include <QGraphicsView>
#include <QHBoxLayout>
#include <QLabel>
@@ -113,11 +115,18 @@ private slots:
void checkHintingMode();
void checkShowPoints();
void checkUnits();
+ void closeFont();
+ void loadFonts();
private:
+ QStringList fontFileNames;
+ int currentFontFileIndex;
+
QAction *aboutAct;
QAction *aboutQtAct;
+ QAction *closeFontAct;
QAction *exitAct;
+ QAction *loadFontsAct;
QCheckBox *blueZoneHintingCheckBox;
QCheckBox *horizontalHintingCheckBox;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 59b8e4e: [ftinspect] Add file dialogs.,
Werner LEMBERG <=