forked from qt-creator/qt-creator
Iconlister, a tool to create a catalouge of graphical assets
Change-Id: I39d009c41daaa07a61465ee29b3a5be32a32275e Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
1248
src/tools/iconlister/iconlister.cpp
Normal file
1248
src/tools/iconlister/iconlister.cpp
Normal file
File diff suppressed because it is too large
Load Diff
81
src/tools/iconlister/iconlister.h
Normal file
81
src/tools/iconlister/iconlister.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QIcon>
|
||||
|
||||
struct IconInfo
|
||||
{
|
||||
QIcon icon;
|
||||
QString id;
|
||||
QString idContext;
|
||||
QString description;
|
||||
};
|
||||
|
||||
class IconLister
|
||||
{
|
||||
public:
|
||||
IconLister() = default;
|
||||
|
||||
enum ThemeKind {
|
||||
ThemeKindDark,
|
||||
ThemeKindLight
|
||||
};
|
||||
|
||||
static void setCreatorTheme(ThemeKind themeKind);
|
||||
static void generateJson();
|
||||
static void generateIcons(ThemeKind theme, int dpr);
|
||||
|
||||
private:
|
||||
void addAutoTestIcons();
|
||||
void addCoreIcons();
|
||||
void addDiffEditorIcons();
|
||||
void addHelpIcons();
|
||||
void addUtilsIcons();
|
||||
void addProjectExplorerIcons();
|
||||
void addDebuggerIcons();
|
||||
void addCPlusPlusIcons();
|
||||
void addQmlDesignerIcons();
|
||||
void addProfilerTimelineIcons();
|
||||
void addWizardIcons();
|
||||
void addWelcomeIcons();
|
||||
|
||||
void addAndroidIcons();
|
||||
void addIosIcons();
|
||||
void addBareMetalIcons();
|
||||
void addQnxIcons();
|
||||
void addWinRTIcons();
|
||||
void addBoot2QtIcons();
|
||||
void addVxWorksIcons();
|
||||
|
||||
void addAllIcons();
|
||||
|
||||
void saveJson() const;
|
||||
void saveIcons(ThemeKind theme, int dpr) const;
|
||||
|
||||
QList<IconInfo> m_icons;
|
||||
};
|
41
src/tools/iconlister/iconlister.pro
Normal file
41
src/tools/iconlister/iconlister.pro
Normal file
@@ -0,0 +1,41 @@
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
iconlister.cpp
|
||||
|
||||
HEADERS += \
|
||||
iconlister.h
|
||||
|
||||
QTC_LIB_DEPENDS += \
|
||||
utils \
|
||||
cplusplus
|
||||
|
||||
QTC_PLUGIN_DEPENDS += \
|
||||
autotest \
|
||||
coreplugin \
|
||||
debugger \
|
||||
projectexplorer \
|
||||
qmldesigner \
|
||||
diffeditor
|
||||
|
||||
include(../../../qtcreator.pri)
|
||||
|
||||
RESOURCES += \
|
||||
$$IDE_SOURCE_TREE/tests/manual/widgets/crumblepath/tst_crumblepath.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/autotest/autotest.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/debugger/debugger.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/help/help.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/diffeditor/diffeditor.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/qmldesigner/components/componentcore/componentcore.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/qmldesigner/components/formeditor/formeditor.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/qmldesigner/components/navigator/navigator.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/qmldesigner/components/resources/resources.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/welcome/welcome.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/baremetal/baremetal.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/ios/ios.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/android/android.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/qnx/qnx.qrc \
|
||||
$$IDE_SOURCE_TREE/src/plugins/winrt/winrt.qrc \
|
||||
$$IDE_SOURCE_TREE/src/libs/timeline/qml/timeline.qrc \
|
||||
|
||||
DEFINES += \
|
||||
IDE_SOURCE_TREE='\\"$$IDE_SOURCE_TREE\\"'
|
108
src/tools/iconlister/main.cpp
Normal file
108
src/tools/iconlister/main.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
|
||||
#include "iconlister.h"
|
||||
|
||||
enum AppMode {
|
||||
GenerateAll,
|
||||
GenerateJson,
|
||||
GenerateIconsLowDpiLight,
|
||||
GenerateIconsLowDpiDark,
|
||||
GenerateIconsHighDpiLight,
|
||||
GenerateIconsHighDpiDark
|
||||
};
|
||||
|
||||
AppMode appModeForString(const char* string)
|
||||
{
|
||||
AppMode appMode;
|
||||
if (strcmp(string, "GenerateJson") == 0)
|
||||
appMode = GenerateJson;
|
||||
else if (strcmp(string, "GenerateIconsLowDpiLight") == 0)
|
||||
appMode = GenerateIconsLowDpiLight;
|
||||
else if (strcmp(string, "GenerateIconsLowDpiDark") == 0)
|
||||
appMode = GenerateIconsLowDpiDark;
|
||||
else if (strcmp(string, "GenerateIconsHighDpiLight") == 0)
|
||||
appMode = GenerateIconsHighDpiLight;
|
||||
else
|
||||
appMode = GenerateIconsHighDpiDark;
|
||||
return appMode;
|
||||
}
|
||||
|
||||
int launchSubProcesses(const QString &command)
|
||||
{
|
||||
for (auto launchAppMode : {
|
||||
"GenerateJson",
|
||||
"GenerateIconsLowDpiLight",
|
||||
"GenerateIconsLowDpiDark",
|
||||
"GenerateIconsHighDpiLight",
|
||||
"GenerateIconsHighDpiDark"}) {
|
||||
qDebug() << "Launching step:" << launchAppMode;
|
||||
const int result =
|
||||
QProcess::execute(command, {QString::fromLatin1(launchAppMode)});
|
||||
if (result != 0)
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void exportData(AppMode appMode)
|
||||
{
|
||||
if (appMode == GenerateJson) {
|
||||
IconLister::generateJson();
|
||||
} else {
|
||||
const int dpr = appMode ==
|
||||
GenerateIconsHighDpiLight || appMode == GenerateIconsHighDpiDark
|
||||
? 2 : 1;
|
||||
const IconLister::ThemeKind theme =
|
||||
appMode == GenerateIconsLowDpiLight || appMode == GenerateIconsHighDpiLight
|
||||
? IconLister::ThemeKindLight : IconLister::ThemeKindDark;
|
||||
IconLister::generateIcons(theme, dpr);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const AppMode appMode = (argc <= 1)
|
||||
? GenerateAll : appModeForString(argv[1]);
|
||||
|
||||
const bool highDpi =
|
||||
appMode == GenerateIconsHighDpiLight || appMode == GenerateIconsHighDpiDark;
|
||||
|
||||
qputenv("QT_SCALE_FACTOR", QByteArray(highDpi ? "2" : "1"));
|
||||
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, highDpi);
|
||||
QApplication app(argc, argv);
|
||||
|
||||
if (appMode == GenerateAll)
|
||||
return launchSubProcesses(QString::fromLocal8Bit(argv[0]));
|
||||
else
|
||||
exportData(appMode);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user