0001-Add-functionality-to-auto-generate-sender-colors.patch
| src/qtui/settingspages/chatviewsettingspage.cpp | ||
|---|---|---|
| 41 | 41 |
ui.autoMarkerLine->setToolTip(tr("You need at 0.6 quasselcore to use this feature"));
|
| 42 | 42 |
} |
| 43 | 43 | |
| 44 |
connect(ui.generateSenderColors, SIGNAL(clicked()), this, SLOT(generateColors())); |
|
| 44 | 45 |
initAutoWidgets(); |
| 45 | 46 |
} |
| 46 | 47 | |
| ... | ... | |
| 49 | 50 |
QtUi::style()->generateSettingsQss(); |
| 50 | 51 |
QtUi::style()->reload(); |
| 51 | 52 |
} |
| 53 | ||
| 54 | ||
| 55 |
void ChatViewSettingsPage::generateColors() {
|
|
| 56 |
//based on http://doc.trolltech.com/qq/qq26-adaptivecoloring.html |
|
| 57 |
UiSettings settings("");
|
|
| 58 |
QColor foreground = settings.value("/QtUiStyle/Colors/ChannelMsg").value<QColor>();
|
|
| 59 |
QColor background = settings.value("/QtUiStyle/Colors/ChatViewBackground").value<QColor>();
|
|
| 60 |
const int numColors = 0x0f; |
|
| 61 | ||
| 62 |
int backgroundHue = background.hue(); |
|
| 63 |
if (backgroundHue == -1) backgroundHue = 90; |
|
| 64 | ||
| 65 |
const int foregroundHue = foreground.hue(); |
|
| 66 |
const int MIN_DELTA = 35; |
|
| 67 |
for (int i=0; i<=numColors; i++) {
|
|
| 68 |
int hue = backgroundHue; |
|
| 69 |
hue += (i * 360) / numColors; |
|
| 70 |
hue %= 360; |
|
| 71 |
int value = qMax(foreground.value(), background.value()); |
|
| 72 |
int saturation = 240; |
|
| 73 | ||
| 74 |
if (qAbs(hue - foregroundHue) < MIN_DELTA || |
|
| 75 |
qAbs(hue - backgroundHue) < MIN_DELTA) {
|
|
| 76 |
value /= 2; |
|
| 77 |
} |
|
| 78 |
qWarning() << hue << saturation << value; |
|
| 79 |
QColor color = QColor::fromHsv(hue, saturation, value); |
|
| 80 |
ColorButton *button = findChild<ColorButton*>(QString("senderColor%1").arg(QString::number(i), 2, '0'));
|
|
| 81 |
button->setColor(color); |
|
| 82 |
} |
|
| 83 |
} |
|
| src/qtui/settingspages/chatviewsettingspage.h | ||
|---|---|---|
| 37 | 37 |
public slots: |
| 38 | 38 |
void save(); |
| 39 | 39 | |
| 40 |
private slots: |
|
| 41 |
void generateColors(); |
|
| 42 | ||
| 40 | 43 |
private: |
| 41 | 44 |
Ui::ChatViewSettingsPage ui; |
| 42 | 45 | |
| src/qtui/settingspages/chatviewsettingspage.ui | ||
|---|---|---|
| 6 | 6 |
<rect> |
| 7 | 7 |
<x>0</x> |
| 8 | 8 |
<y>0</y> |
| 9 |
<width>486</width>
|
|
| 10 |
<height>492</height>
|
|
| 9 |
<width>484</width>
|
|
| 10 |
<height>490</height>
|
|
| 11 | 11 |
</rect> |
| 12 | 12 |
</property> |
| 13 | 13 |
<property name="windowTitle"> |
| ... | ... | |
| 712 | 712 |
</layout> |
| 713 | 713 |
</item> |
| 714 | 714 |
<item> |
| 715 |
<widget class="QPushButton" name="generateSenderColors"> |
|
| 716 |
<property name="text"> |
|
| 717 |
<string>Generate automatically from foreground and background...</string> |
|
| 718 |
</property> |
|
| 719 |
</widget> |
|
| 720 |
</item> |
|
| 721 |
<item> |
|
| 715 | 722 |
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
| 716 | 723 |
<item> |
| 717 | 724 |
<widget class="QLabel" name="label_9"> |
| 718 |
- |
|