initial commit
This commit is contained in:
+2
-2
@@ -15,8 +15,8 @@ public:
|
||||
cCheckBox(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *ev) override;
|
||||
void leaveEvent(QEvent *ev) override;
|
||||
void enterEvent(QEvent *ev);
|
||||
void leaveEvent(QEvent *ev);
|
||||
|
||||
signals:
|
||||
void windowEntered();
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "cfont.h"
|
||||
|
||||
cFont::cFont(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef CFONT_H
|
||||
#define CFONT_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class cFont : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit cFont(QObject *parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // CFONT_H
|
||||
+45
-1
@@ -39,7 +39,33 @@ void cFontView::setText(const QString& text)
|
||||
|
||||
void cFontView::setFont(const QFont& font)
|
||||
{
|
||||
ui->m_lpFontName->setText(font.family());
|
||||
// qDebug() << "family: " << font.family();
|
||||
// qDebug() << "capitalization: " << font.capitalization();
|
||||
// qDebug() << "defaultFamily: " << font.defaultFamily();
|
||||
// qDebug() << "families: " << font.families();
|
||||
// qDebug() << "family: " << font.family();
|
||||
// qDebug() << "fixedPitch: " << font.fixedPitch();
|
||||
// qDebug() << "hintingPreference: " << font.hintingPreference();
|
||||
// qDebug() << "italic: " << font.italic();
|
||||
// qDebug() << "kerning: " << font.kerning();
|
||||
// qDebug() << "key: " << font.key();
|
||||
// qDebug() << "letterSpacing: " << font.letterSpacing();
|
||||
// qDebug() << "letterSpacingType: " << font.letterSpacingType();
|
||||
// qDebug() << "overline: " << font.overline();
|
||||
// qDebug() << "stretch: " << font.stretch();
|
||||
// qDebug() << "strikeOut: " << font.strikeOut();
|
||||
// qDebug() << "style: " << font.style();
|
||||
// qDebug() << "styleHint: " << font.styleHint();
|
||||
// qDebug() << "styleName: " << font.styleName();
|
||||
// qDebug() << "styleStrategy: " << font.styleStrategy();
|
||||
// qDebug() << "toString: " << font.toString();
|
||||
// qDebug() << "underline: " << font.underline();
|
||||
// qDebug() << "weight: " << font.weight();
|
||||
// qDebug() << "wordSpacing: " << font.wordSpacing();
|
||||
// qDebug() << "substitutions: " << font.substitutions();
|
||||
// qDebug() << "--------------------";
|
||||
|
||||
ui->m_lpFontName->setText(font.family() + "(" + font.styleName() + ")");
|
||||
ui->m_lpSampleText->setFont(font);
|
||||
}
|
||||
|
||||
@@ -89,3 +115,21 @@ void cFontView::windowLeft()
|
||||
{
|
||||
ui->m_lpFontName->setStyleSheet("QCheckBox { background-color: " + color2rgba(m_defaultColor) + "; }");
|
||||
}
|
||||
|
||||
cFontViewList::cFontViewList(QObject* parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void cFontViewList::add(cFontView* fontView)
|
||||
{
|
||||
this->append(fontView);
|
||||
}
|
||||
|
||||
void cFontViewList::clearAll()
|
||||
{
|
||||
for(int i = 0;i < count();i++)
|
||||
delete at(i);
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
+19
@@ -6,6 +6,8 @@
|
||||
#include <QColor>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include <QList>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cFontView;
|
||||
@@ -42,4 +44,21 @@ public slots:
|
||||
void windowLeft();
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cFontView*)
|
||||
|
||||
class cFontViewList : public QObject, public QList<cFontView*>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cFontViewList(QObject* parent = nullptr);
|
||||
|
||||
void add(cFontView* fontView);
|
||||
void clearAll();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // CFONTVIEW_H
|
||||
|
||||
@@ -15,8 +15,8 @@ public:
|
||||
cLabel(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *ev) override;
|
||||
void leaveEvent(QEvent *ev) override;
|
||||
void enterEvent(QEvent *ev);
|
||||
void leaveEvent(QEvent *ev);
|
||||
|
||||
signals:
|
||||
void windowEntered();
|
||||
|
||||
+74
-20
@@ -1,9 +1,8 @@
|
||||
#include "cmainwindow.h"
|
||||
#include "ui_cmainwindow.h"
|
||||
|
||||
#include "cfontview.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QStyle>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@@ -11,25 +10,17 @@
|
||||
cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cMainWindow),
|
||||
m_lpSplashScreen(lpSplashScreen)
|
||||
m_splashScreen(lpSplashScreen),
|
||||
m_progressBar(nullptr),
|
||||
m_fileMenu(nullptr),
|
||||
m_fileToolBar(nullptr),
|
||||
m_fileNewAction(nullptr)
|
||||
|
||||
{
|
||||
initUI();
|
||||
createActions();
|
||||
|
||||
// m_fontDatabase.addApplicationFont("C:\\Temp\\Fonts\\a song for jennifer.ttf");
|
||||
// m_fontDatabase.addApplicationFont("C:\\Temp\\Fonts\\Grunge Handwriting.ttf");
|
||||
|
||||
QStringList families = m_fontDatabase.families();
|
||||
|
||||
for(const QString& family : families)
|
||||
{
|
||||
cFontView* lpFontView = new cFontView(this);
|
||||
lpFontView->setText(family);
|
||||
lpFontView->setFont(QFont(family, 16));
|
||||
lpFontView->setBackground(Qt::white);
|
||||
lpFontView->setForeground(Qt::black);
|
||||
ui->m_lpLayout->addWidget(lpFontView);
|
||||
}
|
||||
loadSystemFonts(m_splashScreen);
|
||||
}
|
||||
|
||||
cMainWindow::~cMainWindow()
|
||||
@@ -71,9 +62,15 @@ void cMainWindow::initUI()
|
||||
move(iX, iY);
|
||||
}
|
||||
|
||||
// m_lpProgressBar = new QProgressBar(this);
|
||||
// m_lpProgressBar->setVisible(false);
|
||||
// ui->m_lpStatusBar->addPermanentWidget(m_lpProgressBar);
|
||||
m_progressBar = new QProgressBar(this);
|
||||
m_progressBar->setVisible(false);
|
||||
ui->m_statusBar->addPermanentWidget(m_progressBar);
|
||||
|
||||
QIcon::setThemeName("TangoMFK");
|
||||
qDebug() << QIcon::themeName();
|
||||
qDebug() << QIcon::themeSearchPaths();
|
||||
qDebug() << QIcon::hasThemeIcon("document-open");
|
||||
qDebug() << "done";
|
||||
}
|
||||
|
||||
void cMainWindow::createActions()
|
||||
@@ -93,6 +90,17 @@ void cMainWindow::createContextActions()
|
||||
|
||||
void cMainWindow::createFileActions()
|
||||
{
|
||||
m_fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
m_fileToolBar = addToolBar(tr("File Actions"));
|
||||
|
||||
const QIcon newIcon = QIcon::fromTheme("document-new");
|
||||
m_fileNewAction = m_fileMenu->addAction(newIcon, tr("&New"), this, &cMainWindow::onFileNew);
|
||||
m_fileToolBar->addAction(m_fileNewAction);
|
||||
m_fileNewAction->setPriority(QAction::LowPriority);
|
||||
m_fileNewAction->setShortcut(QKeySequence::New);
|
||||
|
||||
ui->m_mainToolBar->addAction(m_fileNewAction);
|
||||
|
||||
// m_lpFileToolBar = addToolBar("file");
|
||||
|
||||
// const QIcon openIcon = QIcon::fromTheme("document-open");
|
||||
@@ -122,3 +130,49 @@ void cMainWindow::createFileActions()
|
||||
// const QIcon stopIcon = QIcon::fromTheme("process-stop");
|
||||
// m_lpStopAction = m_lpActionToolBar->addAction(stopIcon, tr("&Stop"), this, &cMainWindow::onStop);
|
||||
}
|
||||
|
||||
void cMainWindow::loadSystemFonts(cSplashScreen* splashScreen)
|
||||
{
|
||||
m_fontViewList.clearAll();
|
||||
|
||||
QStringList families = m_fontDatabase.families();
|
||||
int cnt = 0;
|
||||
|
||||
if(splashScreen)
|
||||
splashScreen->setMax(families.count());
|
||||
else
|
||||
m_progressBar->setMaximum(families.count());
|
||||
|
||||
for(const QString& family : families)
|
||||
{
|
||||
if(splashScreen)
|
||||
{
|
||||
splashScreen->setProgress(cnt);
|
||||
splashScreen->showStatusMessage("loading " + family + " ...");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_progressBar->setValue(cnt);
|
||||
ui->m_statusBar->showMessage("loading " + family + " ...");
|
||||
}
|
||||
|
||||
cFontView* lpFontView = new cFontView(this);
|
||||
lpFontView->setText("The quick brown fox jumps over the lazy dog");
|
||||
lpFontView->setFont(QFont(family, 16));
|
||||
lpFontView->setBackground(Qt::white);
|
||||
lpFontView->setForeground(Qt::black);
|
||||
ui->m_fontListLayout->addWidget(lpFontView);
|
||||
|
||||
m_fontViewList.add(lpFontView);
|
||||
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if(!splashScreen)
|
||||
ui->m_statusBar->showMessage("done.", 2000);
|
||||
}
|
||||
|
||||
void cMainWindow::onFileNew()
|
||||
{
|
||||
loadSystemFonts();
|
||||
}
|
||||
|
||||
+17
-1
@@ -4,9 +4,12 @@
|
||||
|
||||
#include "csplashscreen.h"
|
||||
|
||||
#include "cfontview.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QFontDatabase>
|
||||
#include <QCloseEvent>
|
||||
#include <QProgressBar>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -23,15 +26,28 @@ public:
|
||||
|
||||
private:
|
||||
Ui::cMainWindow* ui;
|
||||
cSplashScreen* m_lpSplashScreen;
|
||||
cSplashScreen* m_splashScreen;
|
||||
QProgressBar* m_progressBar;
|
||||
QFontDatabase m_fontDatabase;
|
||||
|
||||
QMenu* m_fileMenu;
|
||||
QToolBar* m_fileToolBar;
|
||||
QAction* m_fileNewAction;
|
||||
|
||||
cFontViewList m_fontViewList;
|
||||
|
||||
void initUI();
|
||||
void createActions();
|
||||
void createFileActions();
|
||||
void createContextActions();
|
||||
|
||||
void loadSystemFonts(cSplashScreen* splashScreen = nullptr);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
private slots:
|
||||
void onFileNew();
|
||||
|
||||
};
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
+13
-5
@@ -16,7 +16,7 @@
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="m_lpFontList">
|
||||
<widget class="QScrollArea" name="m_fontList">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -26,12 +26,12 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>780</width>
|
||||
<height>539</height>
|
||||
<height>527</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="m_lpLayout">
|
||||
<layout class="QGridLayout" name="m_fontListLayout">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
@@ -56,7 +56,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<widget class="QMenuBar" name="m_menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -66,7 +66,15 @@
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="m_mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="m_statusBar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
+11
-11
@@ -10,8 +10,8 @@
|
||||
|
||||
cSplashScreen::cSplashScreen(const QPixmap& pixmap, QFont& font) :
|
||||
QSplashScreen(pixmap),
|
||||
m_iMax(100),
|
||||
m_iProgress(0)
|
||||
m_max(100),
|
||||
m_progress(0)
|
||||
{
|
||||
setFont(font);
|
||||
m_textDocument.setDefaultFont(font);
|
||||
@@ -19,13 +19,13 @@ cSplashScreen::cSplashScreen(const QPixmap& pixmap, QFont& font) :
|
||||
|
||||
void cSplashScreen::setMax(qint32 max)
|
||||
{
|
||||
m_iMax = max;
|
||||
m_max = max;
|
||||
}
|
||||
|
||||
void cSplashScreen::drawContents(QPainter *painter)
|
||||
{
|
||||
painter->translate(m_rect.topLeft());
|
||||
m_textDocument.setHtml(m_szMessage);
|
||||
m_textDocument.setHtml(m_message);
|
||||
m_textDocument.drawContents(painter);
|
||||
|
||||
QStyleOptionProgressBar pbstyle;
|
||||
@@ -33,8 +33,8 @@ void cSplashScreen::drawContents(QPainter *painter)
|
||||
pbstyle.state = QStyle::State_Enabled;
|
||||
pbstyle.textVisible = false;
|
||||
pbstyle.minimum = 0;
|
||||
pbstyle.maximum = m_iMax;
|
||||
pbstyle.progress = m_iProgress;
|
||||
pbstyle.maximum = m_max;
|
||||
pbstyle.progress = m_progress;
|
||||
pbstyle.invertedAppearance = false;
|
||||
pbstyle.rect = QRect(0, 330, 390, 10); // Where is it.
|
||||
|
||||
@@ -44,14 +44,14 @@ void cSplashScreen::drawContents(QPainter *painter)
|
||||
|
||||
void cSplashScreen::showStatusMessage(const QString& message)
|
||||
{
|
||||
m_szMessage = message;
|
||||
showMessage(m_szMessage);
|
||||
m_message = message;
|
||||
showMessage(m_message);
|
||||
}
|
||||
|
||||
void cSplashScreen::addStatusMessage(const QString& message)
|
||||
{
|
||||
m_szMessage.append(message);
|
||||
showMessage(m_szMessage);
|
||||
m_message.append(message);
|
||||
showMessage(m_message);
|
||||
}
|
||||
|
||||
void cSplashScreen::setMessageRect(QRect rect)
|
||||
@@ -62,6 +62,6 @@ void cSplashScreen::setMessageRect(QRect rect)
|
||||
|
||||
void cSplashScreen::setProgress(int value)
|
||||
{
|
||||
m_iProgress = value;
|
||||
m_progress = value;
|
||||
update();
|
||||
}
|
||||
|
||||
+5
-5
@@ -60,11 +60,11 @@ public:
|
||||
void setMax(qint32 max);
|
||||
|
||||
private:
|
||||
QTextDocument m_textDocument; /*!< TODO: describe */
|
||||
QString m_szMessage; /*!< TODO: describe */
|
||||
QRect m_rect; /*!< TODO: describe */
|
||||
qint32 m_iMax; /*!< TODO: describe */
|
||||
qint32 m_iProgress; /*!< TODO: describe */
|
||||
QTextDocument m_textDocument; /*!< TODO: describe */
|
||||
QString m_message; /*!< TODO: describe */
|
||||
QRect m_rect; /*!< TODO: describe */
|
||||
qint32 m_max; /*!< TODO: describe */
|
||||
qint32 m_progress; /*!< TODO: describe */
|
||||
public slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -17,6 +17,9 @@ CONFIG += c++11
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
|
||||
#LIBS += -LC:\dev\3rdParty\exiv2\lib -lexiv2.dll -LC:\dev\3rdParty\libraw\lib -lraw -lws2_32
|
||||
LIBS += -lgdi32
|
||||
|
||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
@@ -24,6 +27,7 @@ DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
|
||||
SOURCES += \
|
||||
ccheckbox.cpp \
|
||||
cfont.cpp \
|
||||
cfontview.cpp \
|
||||
clabel.cpp \
|
||||
common.cpp \
|
||||
@@ -33,6 +37,7 @@ SOURCES += \
|
||||
|
||||
HEADERS += \
|
||||
ccheckbox.h \
|
||||
cfont.h \
|
||||
cfontview.h \
|
||||
clabel.h \
|
||||
cmainwindow.h \
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
<qresource prefix="/">
|
||||
<file>images/splash.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/icons/TangoMFK">
|
||||
<file alias="index.theme">images/tango/index.theme</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[Icon Theme]
|
||||
Name=tango
|
||||
Comment=Original tango icons
|
||||
Inherits=default
|
||||
Directories=16x16,22x22,32x32
|
||||
|
||||
[16x16]
|
||||
Size=16
|
||||
|
||||
[22x22]
|
||||
Size=22
|
||||
|
||||
[32x32]
|
||||
Size=32
|
||||
Reference in New Issue
Block a user