Advertisement
Guest User

psi+ themes

a guest
Apr 28th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.33 KB | None | 0 0
  1. diff --git a/src/options/opt_theme.cpp b/src/options/opt_theme.cpp
  2. index 173b4473..027805f2 100644
  3. --- a/src/options/opt_theme.cpp
  4. +++ b/src/options/opt_theme.cpp
  5. @@ -59,10 +59,6 @@ QWidget *OptionsTabAppearanceTheme::widget()
  6.     PsiThemeViewDelegate *vd = new PsiThemeViewDelegate(d->themeView);
  7.     d->themeView->setItemDelegate(vd);
  8.     d->themeView->setModel(themesModel);
  9. -   int sw = provider->screenshotWidth();
  10. -   if (sw) {
  11. -       d->themeView->setFixedWidth(sw);
  12. -   }
  13.     connect(d->themeView->selectionModel(),
  14.             SIGNAL(currentChanged(QModelIndex, QModelIndex)),
  15.             SIGNAL(dataChanged()));
  16. diff --git a/src/options/opt_theme.ui b/src/options/opt_theme.ui
  17. index e526e20d..955e8ab1 100644
  18. --- a/src/options/opt_theme.ui
  19. +++ b/src/options/opt_theme.ui
  20. @@ -19,19 +19,6 @@
  21.       <item>
  22.        <widget class="QListView" name="themeView"/>
  23.       </item>
  24. -     <item>
  25. -      <spacer name="horizontalSpacer_2">
  26. -       <property name="orientation">
  27. -        <enum>Qt::Horizontal</enum>
  28. -       </property>
  29. -       <property name="sizeHint" stdset="0">
  30. -        <size>
  31. -         <width>40</width>
  32. -         <height>20</height>
  33. -        </size>
  34. -       </property>
  35. -      </spacer>
  36. -     </item>
  37.      </layout>
  38.     </item>
  39.     <item>
  40. diff --git a/src/psithememodel.cpp b/src/psithememodel.cpp
  41. index 9720b43a..5195929a 100644
  42. --- a/src/psithememodel.cpp
  43. +++ b/src/psithememodel.cpp
  44. @@ -125,6 +125,7 @@ void PsiThemeModel::setType(const QString &type)
  45.                         //endResetModel();
  46.                     }
  47.                 });
  48. +               sort(Qt::AscendingOrder);
  49.             }
  50.         }
  51.     }
  52. diff --git a/src/psithemeviewdelegate.cpp b/src/psithemeviewdelegate.cpp
  53. index 81e4e9e5..4ce83a8c 100644
  54. --- a/src/psithemeviewdelegate.cpp
  55. +++ b/src/psithemeviewdelegate.cpp
  56. @@ -31,6 +31,10 @@ void PsiThemeViewDelegate::paint(QPainter *painter,
  57.  {
  58.     QPixmap screenshot = index.data(PsiThemeModel::ScreenshotRole).value<QPixmap>();
  59.     QPixmap texture = IconsetFactory::iconPixmap("psi/themeTitleTexture");
  60. +   QPixmap statusIcon("://iconsets/system/default/ok.png");
  61. +   bool isSelected = option.state & QStyle::State_Selected;
  62. +   int statusIconW = isSelected ? 16 : 0;
  63. +   int statusIconH = statusIconW;
  64.     int texturew = texture.width();
  65.     int textureh = texture.height();
  66.  
  67. @@ -54,7 +58,7 @@ void PsiThemeViewDelegate::paint(QPainter *painter,
  68.     QFontMetrics fm(f);
  69.     QString text = index.data(PsiThemeModel::TitleRole).toString();
  70.     QSize textSize = fm.size(Qt::TextSingleLine, text);
  71. -   int tw = textSize.width() + 10;
  72. +   int tw = textSize.width() + 10 + (isSelected ? statusIconW + 4: 0); //4 - icon offset
  73.     int y = option.rect.top();
  74.     int vw = option.rect.width();
  75.  
  76. @@ -62,10 +66,11 @@ void PsiThemeViewDelegate::paint(QPainter *painter,
  77.     painter->drawPixmap(vw - tw - texturew, y, texturew, textureh, texture);
  78.     painter->drawPixmap(vw - tw, y, tw, textureh, texture.copy(texturew - 1, 0, 1, textureh).scaled(tw, textureh));
  79.  
  80. -
  81. -   painter->setPen(option.state & QStyle::State_Selected? Qt::white : QColor(170, 170, 170));
  82. +   painter->setPen(isSelected ? Qt::white : QColor(170, 170, 170));
  83.     QRect txtr(vw - tw, y, tw, textureh-5); // 5 shadow size?
  84.     painter->drawText(txtr, Qt::AlignCenter, text);
  85. +   if (statusIconW > 0)
  86. +       painter->drawPixmap(vw - tw - 4, y, statusIconW, statusIconH, statusIcon); //4 - icon offset
  87.  }
  88.  
  89.  QSize PsiThemeViewDelegate::sizeHint(const QStyleOptionViewItem &option,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement