void TagColorEditor::itemChanged(QTableWidgetItem *item) { uchar *colors = Global::tagColors(); int row = item->row(); int colm = item->column(); if (colm == 0) { QColor clr; clr.setNamedColor(item->data(Qt::DisplayRole).toString()); item->setData(Qt::DecorationRole, clr); colors[4*(row+1)+0] = clr.red(); colors[4*(row+1)+1] = clr.green(); colors[4*(row+1)+2] = clr.blue(); } else { double opv = item->data(Qt::DisplayRole).toDouble(); int op = opv*255; op = qMin(op, 255); colors[4*(row+1)+3] = op; } emit tagColorChanged(); }
void TagColorEditor::newTagsClicked() { QStringList items; items << "Random"; items << "Library"; bool ok; QString str; str = QInputDialog::getItem(0, "Colors", "Colors", items, 0, false, // text is not editable &ok); if (!ok) return; if (str == "Library") newColorSet(1); else newColorSet(QTime::currentTime().msec()); emit tagColorChanged(); }
void TagColorEditor::cellDoubleClicked(int row, int col) { if (row == 0 && col > 0) return; QTableWidgetItem *item = table->item(row, col); uchar *colors = Global::tagColors(); //int index = row*8 + col; int index = 0; if (row > 0) index = 1 + (row-1)*5 + col; QColor clr = QColor(colors[4*index+0], colors[4*index+1], colors[4*index+2]); clr = DColorDialog::getColor(clr); if (!clr.isValid()) return; colors[4*index+0] = clr.red(); colors[4*index+1] = clr.green(); colors[4*index+2] = clr.blue(); item->setData(Qt::DisplayRole, QString("%1").arg(index)); item->setBackground(clr); emit tagColorChanged(); }
QWidget * PstoPlugin::options() { PreferencesWidget * preferences_widget = new PreferencesWidget( username_color, post_id_color, tag_color, quote_color, message_color ); connect(preferences_widget, SIGNAL(destroyed()), this, SLOT(onOptionsClose())); connect(preferences_widget, SIGNAL(usernameColorChanged(QColor)), this, SLOT(usernameColorChanged(QColor))); connect(preferences_widget, SIGNAL(postColorChanged(QColor)), this, SLOT(postColorChanged(QColor))); connect(preferences_widget, SIGNAL(tagColorChanged(QColor)), this, SLOT(tagColorChanged(QColor))); connect(preferences_widget, SIGNAL(quoteColorChanged(QColor)), this, SLOT(quoteColorChanged(QColor))); connect(preferences_widget, SIGNAL(messageColorChanged(QColor)), this, SLOT(messageColorChanged(QColor))); return preferences_widget; }
void TagColorEditor::newTagsClicked() { QStringList items; items << "Random"; items << "Library"; // bool ok; // QString str; // str = QInputDialog::getItem(0, // "Colors", // "Colors", // items, // 0, // false, // text is not editable // &ok); // // if (!ok) // return; QString text(items.value(0)); QInputDialog dialog(this, 0); dialog.move(QCursor::pos()); dialog.setWindowTitle("Colors"); dialog.setLabelText("Colors"); dialog.setComboBoxItems(items); dialog.setTextValue(text); dialog.setComboBoxEditable(false); dialog.setInputMethodHints(Qt::ImhNone); int ret = dialog.exec(); if (!ret) return; QString str = dialog.textValue(); if (str == "Library") newColorSet(1); else newColorSet(QTime::currentTime().msec()); emit tagColorChanged(); }