OpenToonz - An open-source full-featured 2D animation creation software
C
numpad for palette shortcut
shun_iwasawa4635d82930a0
diff --git a/toonz/sources/common/tvrender/tpalette.cpp b/toonz/sources/common/tvrender/tpalette.cppindex e3019080f..dbdf592e8 100644--- a/toonz/sources/common/tvrender/tpalette.cpp+++ b/toonz/sources/common/tvrender/tpalette.cpp@@ -168,7 +168,8 @@ TPalette::TPalette(), m_dirtyFlag(false), m_mutex(QMutex::Recursive), m_isLocked(false)- , m_askOverwriteFlag(false) {+ , m_askOverwriteFlag(false)+ , m_shortcutScopeIndex(0) {QString tempName(QObject::tr("colors"));std::wstring pageName = tempName.toStdWString();Page *page = addPage(pageName);@@ -851,9 +852,10 @@ void TPalette::assign(const TPalette *src, bool isFromStudioPalette) {j->second = j->second->clone();m_styleAnimationTable[cit->first] = cit->second;}- m_globalName = src->getGlobalName();- m_shortcuts = src->m_shortcuts;- m_currentFrame = src->m_currentFrame;+ m_globalName = src->getGlobalName();+ m_shortcuts = src->m_shortcuts;+ m_currentFrame = src->m_currentFrame;+ m_shortcutScopeIndex = src->m_shortcutScopeIndex;// setDirtyFlag(true);}@@ -1053,22 +1055,26 @@ void TPalette::clearKeyframe(int styleId, int frame) {//-------------------------------------------------------------------int TPalette::getShortcutValue(int key) const {- assert('0' <= key && key <= '9');- std::map<int, int>::const_iterator it;- it = m_shortcuts.find(key);- if (it == m_shortcuts.end()) return -1;- int styleId = it->second;- return 0 <= styleId && styleId < getStyleCount() ? styleId : -1;+ assert(Qt::Key_0 <= key && key <= Qt::Key_9);++ int shortcutIndex = (key == Qt::Key_0) ? 9 : key - Qt::Key_1;+ int indexInPage = m_shortcutScopeIndex * 10 + shortcutIndex;+ // shortcut is available only in the first page+ return getPage(0)->getStyleId(indexInPage);}//-------------------------------------------------------------------int TPalette::getStyleShortcut(int styleId) const {assert(0 <= styleId && styleId < getStyleCount());- std::map<int, int>::const_iterator it;- for (it = m_shortcuts.begin(); it != m_shortcuts.end(); ++it)- if (it->second == styleId) return it->first;- return -1;++ Page *page = getStylePage(styleId);+ // shortcut is available only in the first page+ if (!page || page->getIndex() != 0) return -1;+ int indexInPage = page->search(styleId);+ int shortcutIndex = indexInPage - m_shortcutScopeIndex * 10;+ if (shortcutIndex < 0 || shortcutIndex > 9) return -1;+ return (shortcutIndex == 9) ? Qt::Key_0 : Qt::Key_1 + shortcutIndex;}//-------------------------------------------------------------------@@ -1088,3 +1094,12 @@ void TPalette::setShortcutValue(int key, int styleId) {m_shortcuts[key] = styleId;}}++//-------------------------------------------------------------------++void TPalette::nextShortcutScope() {+ if ((m_shortcutScopeIndex + 1) * 10 < getPage(0)->getStyleCount())+ m_shortcutScopeIndex += 1;+ else+ m_shortcutScopeIndex = 0;+}\ No newline at end of filediff --git a/toonz/sources/include/tools/tooloptions.h b/toonz/sources/include/tools/tooloptions.hindex b06a86df7..abded9675 100644--- a/toonz/sources/include/tools/tooloptions.h+++ b/toonz/sources/include/tools/tooloptions.h@@ -647,7 +647,9 @@ public slots:void onToolChanged();void onStageObjectChange();- // signals:+signals:+ // used in ComboViewer to handle Tab focus+ void newPanelCreated();// void toolOptionChange();};diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.hindex 968fe06f7..ed3fa2c21 100644--- a/toonz/sources/include/toonz/preferences.h+++ b/toonz/sources/include/toonz/preferences.h@@ -290,6 +290,11 @@ public:return m_multiLayerStylePickerEnabled;}+ void enableUseNumpadForSwitchingStyles(bool on);+ bool isUseNumpadForSwitchingStylesEnabled() const {+ return m_useNumpadForSwitchingStyles;+ }+// Xsheet tabvoid setXsheetStep(int step); //!< Sets the step used for the <I>next/prev@@ -494,6 +499,8 @@ private:std::string m_layerNameEncoding = "SJIS"; // Fixed to SJIS for now. You can// add interface if you wanna// change encoding.+ // whether to use numpad and tab key shortcut for selecting styles+ bool m_useNumpadForSwitchingStyles;private:Preferences();diff --git a/toonz/sources/include/toonz/tscenehandle.h b/toonz/sources/include/toonz/tscenehandle.hindex bc8ded561..75ad8cf4b 100644--- a/toonz/sources/include/toonz/tscenehandle.h+++ b/toonz/sources/include/toonz/tscenehandle.h@@ -52,7 +52,9 @@ public:}void notifyNameSceneChange() { emit nameSceneChanged(); }- void notifyPreferenceChanged() { emit preferenceChanged(); }+ void notifyPreferenceChanged(const QString &prefName) {+ emit preferenceChanged(prefName);+ }void notifyPixelUnitSelected(bool on) { emit pixelUnitSelected(on); }@@ -76,7 +78,7 @@ signals:void castChanged();void castFolderAdded(const TFilePath &path);void nameSceneChanged();- void preferenceChanged();+ void preferenceChanged(const QString &prefName);void pixelUnitSelected(bool on);};diff --git a/toonz/sources/include/toonzqt/paletteviewergui.h b/toonz/sources/include/toonzqt/paletteviewergui.hindex 390722c22..1d88c1c13 100644--- a/toonz/sources/include/toonzqt/paletteviewergui.h+++ b/toonz/sources/include/toonzqt/paletteviewergui.h@@ -199,6 +199,8 @@ protected:void zoomInChip();void zoomOutChip();+ bool hasShortcut(int indexInPage);+protected slots:void toggleLink();diff --git a/toonz/sources/include/tpalette.h b/toonz/sources/include/tpalette.hindex bf16794cc..e25b5415b 100644--- a/toonz/sources/include/tpalette.h+++ b/toonz/sources/include/tpalette.h@@ -211,6 +211,9 @@ private://! The confirmation dialog will not be opened unless the palette is edited//! again,//! even if the palette's dirtyflag is true.++ int m_shortcutScopeIndex;+public:TPalette();~TPalette();@@ -417,6 +420,8 @@ between RGBA color components.m_isLocked = lock;}+ void nextShortcutScope();+public:// Deprecated functionsdiff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cppindex f19ee3bed..d333ad4f6 100644--- a/toonz/sources/tnztools/tooloptions.cpp+++ b/toonz/sources/tnztools/tooloptions.cpp@@ -2340,6 +2340,7 @@ un po' di codice... */m_panels[tool] = panel;layout()->addWidget(panel);+ emit newPanelCreated();} else {// il panel c'e' gia'.panel = it->second;diff --git a/toonz/sources/toonz/comboviewerpane.cpp b/toonz/sources/toonz/comboviewerpane.cppindex 6a10ad947..8a05db105 100644--- a/toonz/sources/toonz/comboviewerpane.cpp+++ b/toonz/sources/toonz/comboviewerpane.cpp@@ -189,6 +189,9 @@ ComboViewerPanel::ComboViewerPanel(QWidget *parent, Qt::WFlags flags)SLOT(update()));ret = ret && connect(app->getCurrentScene(), SIGNAL(sceneSwitched()), this,SLOT(onSceneSwitched()));+ ret = ret && connect(m_toolOptions, SIGNAL(newPanelCreated()), this,+ SLOT(updateTabFocus()));+assert(ret);// note: initializeTitleBar() refers to m_sceneViewer@@ -388,9 +391,9 @@ void ComboViewerPanel::showEvent(QShowEvent *) {ret = ret && connect(app->getCurrentTool(), SIGNAL(toolSwitched()),m_sceneViewer, SLOT(onToolSwitched()));- ret = ret && connect(sceneHandle, SIGNAL(preferenceChanged()), m_flipConsole,- SLOT(onPreferenceChanged()));- m_flipConsole->onPreferenceChanged();+ ret = ret && connect(sceneHandle, SIGNAL(preferenceChanged(const QString &)),+ this, SLOT(onPreferenceChanged(const QString &)));+ onPreferenceChanged("");assert(ret);@@ -781,3 +784,38 @@ bool ComboViewerPanel::isFrameAlreadyCached(int frame) {}//-----------------------------------------------------------------------------++void ComboViewerPanel::onPreferenceChanged(const QString &prefName) {+ // if no name specified (on showEvent), then process all updates+ if (prefName == "BlankCount" || prefName == "BlankColor" ||+ prefName.isEmpty())+ m_flipConsole->onPreferenceChanged();++ if (prefName == "NumpadForSwitchingStyles" || prefName.isEmpty())+ updateTabFocus();+}++//-----------------------------------------------------------------------------++void ComboViewerPanel::updateTabFocus() {+ QList<QWidget *> widgets = findChildren<QWidget *>();+ if (Preferences::instance()->isUseNumpadForSwitchingStylesEnabled()) {+ // disable tab focus+ foreach (QWidget *widget, widgets) {+ Qt::FocusPolicy policy = widget->focusPolicy();+ if (policy == Qt::TabFocus || policy == Qt::StrongFocus ||+ policy == Qt::WheelFocus) {+ m_childrenFocusPolicies[widget] = policy;+ widget->setFocusPolicy((policy == Qt::TabFocus) ? Qt::NoFocus+ : Qt::ClickFocus);+ }+ }+ } else {+ // revert tab focus+ QHashIterator<QWidget *, Qt::FocusPolicy> i(m_childrenFocusPolicies);+ while (i.hasNext()) {+ i.next();+ i.key()->setFocusPolicy(i.value());+ }+ }+}\ No newline at end of filediff --git a/toonz/sources/toonz/comboviewerpane.h b/toonz/sources/toonz/comboviewerpane.hindex 8f935caa2..c68643811 100644--- a/toonz/sources/toonz/comboviewerpane.h+++ b/toonz/sources/toonz/comboviewerpane.h@@ -55,6 +55,8 @@ class ComboViewerPanel final : public TPanel, public FlipConsoleOwner {TPanelTitleBarButton *m_previewButton;TPanelTitleBarButton *m_subcameraPreviewButton;+ QHash<QWidget *, Qt::FocusPolicy> m_childrenFocusPolicies;+public:#if QT_VERSION >= 0x050500ComboViewerPanel(QWidget *parent = 0, Qt::WindowFlags flags = 0);@@ -118,6 +120,9 @@ protected slots:void onSceneSwitched();void enableFullPreview(bool enabled);void enableSubCameraPreview(bool enabled);++ void onPreferenceChanged(const QString &prefName);+ void updateTabFocus();};#endifdiff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cppindex f61fbc3b7..6c02e7dfe 100644--- a/toonz/sources/toonz/preferencespopup.cpp+++ b/toonz/sources/toonz/preferencespopup.cpp@@ -331,7 +331,7 @@ void PreferencesPopup::onChunkSizeChanged() {void PreferencesPopup::onBlankCountChanged() {if (m_blanksCount && m_blankColor)m_pref->setBlankValues(m_blanksCount->getValue(), m_blankColor->getColor());- TApp::instance()->getCurrentScene()->notifyPreferenceChanged();+ TApp::instance()->getCurrentScene()->notifyPreferenceChanged("BlankCount");}//-----------------------------------------------------------------------------@@ -350,7 +350,7 @@ void PreferencesPopup::onBlankColorChanged(const TPixel32 &, bool isDragging) {if (m_blanksCount && m_blankColor)m_pref->setBlankValues(m_blanksCount->getValue(), m_blankColor->getColor());- TApp::instance()->getCurrentScene()->notifyPreferenceChanged();+ TApp::instance()->getCurrentScene()->notifyPreferenceChanged("BlankColor");}//-----------------------------------------------------------------------------@@ -871,6 +871,45 @@ void PreferencesPopup::onFfmpegTimeoutChanged() {m_pref->setFfmpegTimeout(m_ffmpegTimeout->getValue());}+//-----------------------------------------------------------------------------++void PreferencesPopup::onUseNumpadForSwitchingStylesClicked(bool checked) {+ if (checked) {+ // check if there are any commands with numpadkey shortcuts+ CommandManager *cm = CommandManager::instance();+ QList<QAction *> actionsList;+ for (int key = Qt::Key_0; key <= Qt::Key_9; key++) {+ std::string str = QKeySequence(key).toString().toStdString();+ QAction *action = cm->getActionFromShortcut(str);+ if (action) actionsList.append(action);+ }+ QAction *tabAction = cm->getActionFromShortcut("Tab");+ if (tabAction) actionsList.append(tabAction);+ // if there are actions using numpad shortcuts, notify to release them.+ if (!actionsList.isEmpty()) {+ QString msgStr =+ tr("Numpad keys are assigned to the following commands.\nIs it OK to "+ "release these shortcuts?");+ for (int a = 0; a < actionsList.size(); a++) {+ msgStr += "\n" + actionsList.at(a)->iconText() + " (" ++ actionsList.at(a)->shortcut().toString() + ")";+ }+ int ret = DVGui::MsgBox(msgStr, tr("OK"), tr("Cancel"), 1);+ if (ret == 2 || ret == 0) { // canceled+ m_useNumpadForSwitchingStyles->setChecked(false);+ return;+ } else { // accepted, then release shortcuts+ for (int a = 0; a < actionsList.size(); a++)+ cm->setShortcut(actionsList[a], "");+ }+ }+ }+ m_pref->enableUseNumpadForSwitchingStyles(checked);+ // emit signal to update Palette and Viewer+ TApp::instance()->getCurrentScene()->notifyPreferenceChanged(+ "NumpadForSwitchingStyles");+}+//**********************************************************************************// PrefencesPopup's constructor//**********************************************************************************@@ -1026,6 +1065,8 @@ PreferencesPopup::PreferencesPopup()new CheckBox(tr("Use the TLV Savebox to Limit Filling Operations"), this);CheckBox *minimizeSaveboxAfterEditingCB =new CheckBox(tr("Minimize Savebox after Editing"), this);+ m_useNumpadForSwitchingStyles =+ new CheckBox(tr("Use Numpad and Tab keys for Switching Styles"), this);//--- Xsheet ------------------------------categoryList->addItem(tr("Xsheet"));@@ -1220,6 +1261,8 @@ PreferencesPopup::PreferencesPopup()minimizeSaveboxAfterEditingCB->setChecked(m_pref->isMinimizeSaveboxAfterEditing());useSaveboxToLimitFillingOpCB->setChecked(m_pref->getFillOnlySavebox());+ m_useNumpadForSwitchingStyles->setChecked(+ m_pref->isUseNumpadForSwitchingStylesEnabled());QStringList scanLevelTypes;scanLevelTypes << "tif"@@ -1642,6 +1685,9 @@ PreferencesPopup::PreferencesPopup()Qt::AlignLeft | Qt::AlignVCenter);drawingFrameLay->addWidget(multiLayerStylePickerCB, 0,Qt::AlignLeft | Qt::AlignVCenter);+ drawingFrameLay->addWidget(m_useNumpadForSwitchingStyles, 0,+ Qt::AlignLeft | Qt::AlignVCenter);+drawingFrameLay->addStretch(1);}drawingBox->setLayout(drawingFrameLay);@@ -1972,6 +2018,8 @@ PreferencesPopup::PreferencesPopup()SLOT(onDefLevelParameterChanged()));ret = ret && connect(m_defLevelDpi, SIGNAL(valueChanged()),SLOT(onDefLevelParameterChanged()));+ ret = ret && connect(m_useNumpadForSwitchingStyles, SIGNAL(clicked(bool)),+ SLOT(onUseNumpadForSwitchingStylesClicked(bool)));//--- Xsheet ----------------------ret = ret && connect(xsheetAutopanDuringPlaybackCB, SIGNAL(stateChanged(int)),diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.hindex 7677d2272..616582a7c 100644--- a/toonz/sources/toonz/preferencespopup.h+++ b/toonz/sources/toonz/preferencespopup.h@@ -68,7 +68,8 @@ private:QPushButton *m_addLevelFormat, *m_removeLevelFormat, *m_editLevelFormat;DVGui::CheckBox *m_inksOnly, *m_enableVersionControl, *m_levelsBackup,- *m_onionSkinVisibility, *m_pixelsOnlyCB, *m_onionSkinDuringPlayback;+ *m_onionSkinVisibility, *m_pixelsOnlyCB, *m_onionSkinDuringPlayback,+ *m_useNumpadForSwitchingStyles;DVGui::FileField *m_ffmpegPathFileFld;@@ -155,6 +156,7 @@ private slots:void onShowKeyframesOnCellAreaChanged(int);void onFfmpegPathChanged();void onFfmpegTimeoutChanged();+ void onUseNumpadForSwitchingStylesClicked(bool);};//**********************************************************************************diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cppindex 17f3f3d46..6bed2c5bb 100644--- a/toonz/sources/toonz/sceneviewerevents.cpp+++ b/toonz/sources/toonz/sceneviewerevents.cpp@@ -15,6 +15,10 @@#include "ruler.h"#include "comboviewerpane.h"+// TnzQt includes+#include "toonzqt/tselectionhandle.h"+#include "toonzqt/styleselection.h"+// TnzTools includes#include "tools/cursors.h"#include "tools/toolhandle.h"@@ -753,6 +757,38 @@ void SceneViewer::keyPressEvent(QKeyEvent *event) {tool->setViewer(this);+ if (Preferences::instance()->isUseNumpadForSwitchingStylesEnabled() &&+ (!isTextToolActive)) {+ if (Qt::Key_0 <= key && key <= Qt::Key_9) {+ TPaletteHandle *ph =+ TApp::instance()->getPaletteController()->getCurrentLevelPalette();++ TPalette *palette = ph->getPalette();+ if (palette) {+ int styleId = palette->getShortcutValue(key);+ if (styleId >= 0) {+ ph->setStyleIndex(styleId);+ TStyleSelection *selection = dynamic_cast<TStyleSelection *>(+ TApp::instance()->getCurrentSelection()->getSelection());+ if (selection) selection->selectNone();+ }+ }+ event->accept();+ return;+ } else if (key == Qt::Key_Tab) {+ TPaletteHandle *ph =+ TApp::instance()->getPaletteController()->getCurrentLevelPalette();++ TPalette *palette = ph->getPalette();+ if (palette) {+ palette->nextShortcutScope();+ ph->notifyPaletteChanged();+ }+ event->accept();+ return;+ }+ }+if (key == Qt::Key_Shift)modifiers |= Qt::SHIFT;else if (key == Qt::Key_Control)diff --git a/toonz/sources/toonz/viewerpane.cpp b/toonz/sources/toonz/viewerpane.cppindex 819a466fc..f10ad1a84 100644--- a/toonz/sources/toonz/viewerpane.cpp+++ b/toonz/sources/toonz/viewerpane.cpp@@ -259,9 +259,9 @@ void SceneViewerPanel::showEvent(QShowEvent *) {ret = ret && connect(app->getCurrentTool(), SIGNAL(toolSwitched()),m_sceneViewer, SLOT(onToolSwitched()));- ret = ret && connect(sceneHandle, SIGNAL(preferenceChanged()), m_flipConsole,- SLOT(onPreferenceChanged()));- m_flipConsole->onPreferenceChanged();+ ret = ret && connect(sceneHandle, SIGNAL(preferenceChanged(const QString &)),+ this, SLOT(onPreferenceChanged(const QString &)));+ onPreferenceChanged("");assert(ret);@@ -601,3 +601,37 @@ void SceneViewerPanel::onFrameTypeChanged() {updateFrameRange();updateFrameMarkers();}++//-----------------------------------------------------------------------------++void SceneViewerPanel::onPreferenceChanged(const QString &prefName) {+ // if no name specified (on showEvent), then process all updates+ if (prefName == "BlankCount" || prefName == "BlankColor" ||+ prefName.isEmpty())+ m_flipConsole->onPreferenceChanged();++ if (prefName == "NumpadForSwitchingStyles" || prefName.isEmpty()) {+ QList<QWidget *> widgets = findChildren<QWidget *>();+ if (Preferences::instance()->isUseNumpadForSwitchingStylesEnabled()) {+ // disable tab key+ foreach (QWidget *widget, widgets) {+ Qt::FocusPolicy policy = widget->focusPolicy();+ if (policy == Qt::TabFocus || policy == Qt::StrongFocus ||+ policy == Qt::WheelFocus) {+ m_childrenFocusPolicies[widget] = policy;+ widget->setFocusPolicy((policy == Qt::TabFocus) ? Qt::NoFocus+ : Qt::ClickFocus);+ }+ }+ } else {+ // revert tab focus+ QHashIterator<QWidget *, Qt::FocusPolicy> i(m_childrenFocusPolicies);+ while (i.hasNext()) {+ i.next();+ i.key()->setFocusPolicy(i.value());+ }+ }+ }+}++//-----------------------------------------------------------------------------diff --git a/toonz/sources/toonz/viewerpane.h b/toonz/sources/toonz/viewerpane.hindex d308604a3..168089183 100644--- a/toonz/sources/toonz/viewerpane.h+++ b/toonz/sources/toonz/viewerpane.h@@ -38,6 +38,8 @@ class SceneViewerPanel final : public TPanel, public FlipConsoleOwner {TPanelTitleBarButton *m_subcameraPreviewButton;bool m_onionSkinActive = false;+ QHash<QWidget *, Qt::FocusPolicy> m_childrenFocusPolicies;+public:#if QT_VERSION >= 0x050500SceneViewerPanel(QWidget *parent = 0, Qt::WindowFlags flags = 0);@@ -75,6 +77,7 @@ protected slots:void onPlayingStatusChanged(bool playing);void enableFullPreview(bool enabled);void enableSubCameraPreview(bool enabled);+ void onPreferenceChanged(const QString &prefName);};#endifdiff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cppindex 886e841db..9af590c03 100644--- a/toonz/sources/toonzlib/preferences.cpp+++ b/toonz/sources/toonzlib/preferences.cpp@@ -23,6 +23,7 @@// Qt includes#include <QSettings>#include <QStringList>+#include <QAction>// boost includes#include <boost/bind.hpp>@@ -288,7 +289,8 @@ Preferences::Preferences(), m_paletteTypeOnLoadRasterImageAsColorModel(0), m_showKeyframesOnXsheetCellArea(true), m_precompute(true)- , m_ffmpegTimeout(30) {+ , m_ffmpegTimeout(30)+ , m_useNumpadForSwitchingStyles(false) {TCamera camera;m_defLevelType = PLI_XSHLEVEL;m_defLevelWidth = camera.getSize().lx;@@ -547,6 +549,8 @@ Preferences::Preferences()if (ffmpegPath != "") m_ffmpegPath = ffmpegPath;setFfmpegPath(m_ffmpegPath.toStdString());getValue(*m_settings, "ffmpegTimeout", m_ffmpegTimeout);+ getValue(*m_settings, "useNumpadForSwitchingStyles",+ m_useNumpadForSwitchingStyles);}//-----------------------------------------------------------------@@ -1260,3 +1264,10 @@ int Preferences::matchLevelFormat(const TFilePath &fp) const {return (lft != m_levelFormats.end()) ? lft - m_levelFormats.begin() : -1;}++//-----------------------------------------------------------------++void Preferences::enableUseNumpadForSwitchingStyles(bool on) {+ m_useNumpadForSwitchingStyles = on;+ m_settings->setValue("useNumpadForSwitchingStyles", on ? "1" : "0");+}\ No newline at end of filediff --git a/toonz/sources/toonzqt/paletteviewergui.cpp b/toonz/sources/toonzqt/paletteviewergui.cppindex b22622cf1..43f0e81c6 100644--- a/toonz/sources/toonzqt/paletteviewergui.cpp+++ b/toonz/sources/toonzqt/paletteviewergui.cpp@@ -454,7 +454,7 @@ void PageViewer::drawColorName(QPainter &p, QRect &nameRect, TColorStyle *style,name += " " + toQString(g.first) + ":" + QString::number(g.second);if (style->getFlags() != 0) name += "(autopaint)";- p.drawText(nameRect.adjusted(6, 4, -6, -4), name);+ p.drawText(nameRect.adjusted(8, 4, -6, -4), name);QColor borderCol(getTextColor());borderCol.setAlphaF(0.3);@@ -587,6 +587,17 @@ void PageViewer::paintEvent(QPaintEvent *e) {QRect nameRect = getColorNameRect(i);drawColorName(p, nameRect, style, styleIndex);+ // if numpad shortcut is activated, draw shortcut scope+ if (Preferences::instance()->isUseNumpadForSwitchingStylesEnabled() &&+ palette->getStyleShortcut(styleIndex) >= 0) {+ p.setPen(QPen(QColor(0, 0, 0, 128), 2));+ p.drawLine(nameRect.topLeft() + QPoint(2, 1),+ nameRect.bottomLeft() + QPoint(2, 0));+ p.setPen(QPen(QColor(255, 255, 255, 128), 2));+ p.drawLine(nameRect.topLeft() + QPoint(4, 1),+ nameRect.bottomLeft() + QPoint(4, 0));+ }+// selezioneif (m_styleSelection->isSelected(m_page->getIndex(), i)) {p.setPen(Qt::white);@@ -622,10 +633,36 @@ void PageViewer::paintEvent(QPaintEvent *e) {TColorStyle *style = m_page->getStyle(i);int styleIndex = m_page->getStyleId(i);+ // if numpad shortcut is activated, draw shortcut scope+ if (Preferences::instance()->isUseNumpadForSwitchingStylesEnabled() &&+ palette->getStyleShortcut(styleIndex) >= 0) {+ QRect itemRect = getItemRect(i);+ // paint dark+ p.setPen(Qt::NoPen);+ p.setBrush(QColor(0, 0, 0, 64));+ p.drawRect(itemRect);+ // check the neighbours and draw light lines+ p.setPen(QPen(QColor(255, 255, 255, 128), 2));+ // top+ if (!hasShortcut(i - m_chipPerRow))+ p.drawLine(itemRect.topLeft(), itemRect.topRight() - QPoint(1, 0));+ // left+ if (i % m_chipPerRow == 0 || !hasShortcut(i - 1))+ p.drawLine(itemRect.topLeft() + QPoint(0, 1), itemRect.bottomLeft());+ // bottom+ if (!hasShortcut(i + m_chipPerRow))+ p.drawLine(itemRect.bottomLeft() + QPoint(1, 0),+ itemRect.bottomRight());+ // right+ if ((i + 1) % m_chipPerRow == 0 || !hasShortcut(i + 1))+ p.drawLine(itemRect.topRight(),+ itemRect.bottomRight() - QPoint(0, 1));+ }+// draw white frame if the style is selected or currentif (m_styleSelection->isSelected(m_page->getIndex(), i) ||currentStyleIndex == styleIndex) {- QRect itemRect = getItemRect(i).adjusted(-1, -2, 1, 2);+ QRect itemRect = getItemRect(i).adjusted(0, -1, 0, 1);p.setPen(Qt::NoPen);p.setBrush(Qt::white);p.drawRoundRect(itemRect, 7, 25);@@ -1389,6 +1426,15 @@ void PageViewer::eraseToggleLink() {m_styleSelection->eraseToggleLink();}+//-----------------------------------------------------------------------------++bool PageViewer::hasShortcut(int indexInPage) {+ if (!m_page) return false;+ if (indexInPage < 0 || indexInPage >= m_page->getStyleCount()) return false;+ int styleIndex = m_page->getStyleId(indexInPage);+ return (m_page->getPalette()->getStyleShortcut(styleIndex) >= 0);+}+//=============================================================================/*! \class PaletteViewerGUI::PaletteTabBar\brief The PaletteTabBar class provides a bar with tab to show