summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTasuku Suzuki <tasuku.suzuki@signal-slot.co.jp>2022-03-30 00:03:47 +0900
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-29 18:54:27 +0000
commitfd9fe04b4e0c53d070659579ee9e0479173ef114 (patch)
tree9a15b731b192553a14dee544ba87564f78f73a71
parent468bf8d77ee00ab1b225e6f4f6640f7ca805f880 (diff)
Qt Designer: make icon theme selectable
Add icon name list from the spec. http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec- latest.html Change-Id: Ia664fc1e192512eacad377e30ecd4f1dfcb79f77 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 3d9adfb948260215e1d6e5d16fd9ef5a64f51d0e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/designer/src/lib/CMakeLists.txt1
-rw-r--r--src/designer/src/lib/shared/icon-naming-spec.txt309
-rw-r--r--src/designer/src/lib/shared/iconselector.cpp58
3 files changed, 339 insertions, 29 deletions
diff --git a/src/designer/src/lib/CMakeLists.txt b/src/designer/src/lib/CMakeLists.txt
index 45a6a4969..50a672ffb 100644
--- a/src/designer/src/lib/CMakeLists.txt
+++ b/src/designer/src/lib/CMakeLists.txt
@@ -348,6 +348,7 @@ qt_internal_add_resource(Designer "qtgradienteditor"
)
set(shared_resource_files
"shared/defaultgradients.xml"
+ "shared/icon-naming-spec.txt"
"shared/templates/forms/240x320/Dialog_with_Buttons_Bottom.ui"
"shared/templates/forms/240x320/Dialog_with_Buttons_Right.ui"
"shared/templates/forms/320x240/Dialog_with_Buttons_Bottom.ui"
diff --git a/src/designer/src/lib/shared/icon-naming-spec.txt b/src/designer/src/lib/shared/icon-naming-spec.txt
new file mode 100644
index 000000000..e9b854769
--- /dev/null
+++ b/src/designer/src/lib/shared/icon-naming-spec.txt
@@ -0,0 +1,309 @@
+# https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
+
+# Table 2. Standard Action Icons
+address-book-new
+application-exit
+appointment-new
+call-start
+call-stop
+contact-new
+document-new
+document-open
+document-open-recent
+document-page-setup
+document-print
+document-print-preview
+document-properties
+document-revert
+document-save
+document-save-as
+document-send
+edit-clear
+edit-copy
+edit-cut
+edit-delete
+edit-find
+edit-find-replace
+edit-paste
+edit-redo
+edit-select-all
+edit-undo
+folder-new
+format-indent-less
+format-indent-more
+format-justify-center
+format-justify-fill
+format-justify-left
+format-justify-right
+format-text-direction-ltr
+format-text-direction-rtl
+format-text-bold
+format-text-italic
+format-text-underline
+format-text-strikethrough
+go-bottom
+go-down
+go-first
+go-home
+go-jump
+go-last
+go-next
+go-previous
+go-top
+go-up
+help-about
+help-contents
+help-faq
+insert-image
+insert-link
+insert-object
+insert-text
+list-add
+list-remove
+mail-forward
+mail-mark-important
+mail-mark-junk
+mail-mark-notjunk
+mail-mark-read
+mail-mark-unread
+mail-message-new
+mail-reply-all
+mail-reply-sender
+mail-send
+mail-send-receive
+media-eject
+media-playback-pause
+media-playback-start
+media-playback-stop
+media-record
+media-seek-backward
+media-seek-forward
+media-skip-backward
+media-skip-forward
+object-flip-horizontal
+object-flip-vertical
+object-rotate-left
+object-rotate-right
+process-stop
+system-lock-screen
+system-log-out
+system-run
+system-search
+system-reboot
+system-shutdown
+tools-check-spelling
+view-fullscreen
+view-refresh
+view-restore
+view-sort-ascending
+view-sort-descending
+window-close
+window-new
+zoom-fit-best
+zoom-in
+zoom-original
+zoom-out
+
+# Table 3. Standard Animation Icons
+process-working
+
+# Table 4. Standard Application Icons
+accessories-calculator
+accessories-character-map
+accessories-dictionary
+accessories-text-editor
+help-browser
+multimedia-volume-control
+preferences-desktop-accessibility
+preferences-desktop-font
+preferences-desktop-keyboard
+preferences-desktop-locale
+preferences-desktop-multimedia
+preferences-desktop-screensaver
+preferences-desktop-theme
+preferences-desktop-wallpaper
+system-file-manager
+system-software-install
+system-software-update
+utilities-system-monitor
+utilities-terminal
+
+# Table 5. Standard Category Icons
+applications-accessories
+applications-development
+applications-engineering
+applications-games
+applications-graphics
+applications-internet
+applications-multimedia
+applications-office
+applications-other
+applications-science
+applications-system
+applications-utilities
+preferences-desktop
+preferences-desktop-peripherals
+preferences-desktop-personal
+preferences-other
+preferences-system
+preferences-system-network
+system-help
+
+# Table 6. Standard Device Icons
+audio-card
+audio-input-microphone
+battery
+camera-photo
+camera-video
+camera-web
+computer
+drive-harddisk
+drive-optical
+drive-removable-media
+input-gaming
+input-keyboard
+input-mouse
+input-tablet
+media-flash
+media-floppy
+media-optical
+media-tape
+modem
+multimedia-player
+network-wired
+network-wireless
+pda
+phone
+printer
+scanner
+video-display
+
+# Table 7. Standard Emblem Icons
+emblem-default
+emblem-documents
+emblem-downloads
+emblem-favorite
+emblem-important
+emblem-mail
+emblem-photos
+emblem-readonly
+emblem-shared
+emblem-symbolic-link
+emblem-synchronized
+emblem-system
+emblem-unreadable
+
+# Table 8. Standard Emotion Icons
+face-angel
+face-angry
+face-cool
+face-crying
+face-devilish
+face-embarrassed
+face-kiss
+face-laugh
+face-monkey
+face-plain
+face-raspberry
+face-sad
+face-sick
+face-smile
+face-smile-big
+face-smirk
+face-surprise
+face-tired
+face-uncertain
+face-wink
+face-worried
+
+# Table 9. Standard International Icons
+flag-aa
+
+# Table 10. Standard MIME Type Icons
+application-x-executable
+audio-x-generic
+font-x-generic
+image-x-generic
+package-x-generic
+text-html
+text-x-generic
+text-x-generic-template
+text-x-script
+video-x-generic
+x-office-address-book
+x-office-calendar
+x-office-document
+x-office-presentation
+x-office-spreadsheet
+
+# Table 11. Standard Place Icons
+folder
+folder-remote
+network-server
+network-workgroup
+start-here
+user-bookmarks
+user-desktop
+user-home
+user-trash
+
+# Table 12. Standard Status Icons
+appointment-missed
+appointment-soon
+audio-volume-high
+audio-volume-low
+audio-volume-medium
+audio-volume-muted
+battery-caution
+battery-low
+dialog-error
+dialog-information
+dialog-password
+dialog-question
+dialog-warning
+folder-drag-accept
+folder-open
+folder-visiting
+image-loading
+image-missing
+mail-attachment
+mail-unread
+mail-read
+mail-replied
+mail-signed
+mail-signed-verified
+media-playlist-repeat
+media-playlist-shuffle
+network-error
+network-idle
+network-offline
+network-receive
+network-transmit
+network-transmit-receive
+printer-error
+printer-printing
+security-high
+security-medium
+security-low
+software-update-available
+software-update-urgent
+sync-error
+sync-synchronizing
+task-due
+task-past-due
+user-available
+user-away
+user-idle
+user-offline
+user-trash-full
+weather-clear
+weather-clear-night
+weather-few-clouds
+weather-few-clouds-night
+weather-fog
+weather-overcast
+weather-severe-alert
+weather-showers
+weather-showers-scattered
+weather-snow
+weather-storm
diff --git a/src/designer/src/lib/shared/iconselector.cpp b/src/designer/src/lib/shared/iconselector.cpp
index fa3f86708..95182979c 100644
--- a/src/designer/src/lib/shared/iconselector.cpp
+++ b/src/designer/src/lib/shared/iconselector.cpp
@@ -58,6 +58,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qlist.h>
+#include <QtCore/qstringlistmodel.h>
QT_BEGIN_NAMESPACE
@@ -510,35 +511,34 @@ void IconSelector::setPixmapCache(DesignerPixmapCache *pixmapCache)
// --- IconThemeEditor
-// Validator for theme line edit, accepts empty or non-blank strings.
-class BlankSuppressingValidator : public QValidator {
-public:
- explicit BlankSuppressingValidator(QObject * parent = nullptr) : QValidator(parent) {}
-
- State validate(QString &input, int &pos) const override
- {
- const int blankPos = input.indexOf(QLatin1Char(' '));
- if (blankPos != -1) {
- pos = blankPos;
- return Invalid;
- }
- return Acceptable;
- }
-};
-
struct IconThemeEditorPrivate {
IconThemeEditorPrivate();
const QPixmap m_emptyPixmap;
- QLineEdit *m_themeLineEdit;
+ QComboBox *m_themeComboBox;
QLabel *m_themeLabel;
+ QStringListModel *m_themeModel;
};
IconThemeEditorPrivate::IconThemeEditorPrivate() :
m_emptyPixmap(emptyPixmap()),
- m_themeLineEdit(new QLineEdit),
- m_themeLabel(new QLabel)
-{
+ m_themeComboBox(new QComboBox),
+ m_themeLabel(new QLabel),
+ m_themeModel(new QStringListModel)
+{
+ QStringList iconNames;
+ QFile file(QStringLiteral(":/qt-project.org/designer/icon-naming-spec.txt"));
+ if (file.open(QIODevice::ReadOnly)) {
+ while (!file.atEnd()) {
+ const auto line = file.readLine().trimmed();
+ if (line.isEmpty() || line.startsWith('#'))
+ continue;
+ iconNames.append(QString::fromUtf8(line));
+ }
+ file.close();
+ }
+ std::sort(iconNames.begin(), iconNames.end());
+ m_themeModel->setStringList(iconNames);
}
IconThemeEditor::IconThemeEditor(QWidget *parent, bool wantResetButton) :
@@ -558,11 +558,11 @@ IconThemeEditor::IconThemeEditor(QWidget *parent, bool wantResetButton) :
themeLabelVLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
mainHLayout->addLayout(themeLabelVLayout);
- d->m_themeLineEdit = new QLineEdit;
- d->m_themeLineEdit->setValidator(new BlankSuppressingValidator(d->m_themeLineEdit));
- connect(d->m_themeLineEdit, &QLineEdit::textChanged, this, &IconThemeEditor::slotChanged);
- connect(d->m_themeLineEdit, &QLineEdit::textEdited, this, &IconThemeEditor::edited);
- mainHLayout->addWidget(d->m_themeLineEdit);
+ d->m_themeComboBox->setModel(d->m_themeModel);
+ d->m_themeComboBox->setCurrentIndex(-1);
+ connect(d->m_themeComboBox, &QComboBox::currentTextChanged, this, &IconThemeEditor::slotChanged);
+ connect(d->m_themeComboBox, &QComboBox::currentTextChanged, this, &IconThemeEditor::edited);
+ mainHLayout->addWidget(d->m_themeComboBox);
if (wantResetButton) {
QToolButton *themeResetButton = new QToolButton;
@@ -572,14 +572,14 @@ IconThemeEditor::IconThemeEditor(QWidget *parent, bool wantResetButton) :
}
setLayout(mainHLayout);
- setFocusProxy(d->m_themeLineEdit);
+ setFocusProxy(d->m_themeComboBox);
}
IconThemeEditor::~IconThemeEditor() = default;
void IconThemeEditor::reset()
{
- d->m_themeLineEdit->clear();
+ d->m_themeComboBox->setCurrentIndex(-1);
emit edited(QString());
}
@@ -602,12 +602,12 @@ void IconThemeEditor::updatePreview(const QString &t)
QString IconThemeEditor::theme() const
{
- return d->m_themeLineEdit->text();
+ return d->m_themeComboBox->currentText();
}
void IconThemeEditor::setTheme(const QString &t)
{
- d->m_themeLineEdit->setText(t);
+ d->m_themeComboBox->setCurrentText(t);
}
} // qdesigner_internal