Beispiel #1
0
void HistoryConfig::viewChanged(QWidget *w)
{
    int cur = cmbStyle->currentItem();
    if (cur < 0)
        return;
    if (w == preview){
        if (!m_styles[cur].bCustom)
            return;
        if (m_bDirty){
            m_styles[cur].text = unquoteText(edtStyle->text());
            fillPreview();
        }
    }else{
        QString xsl;
        if (m_styles[cur].text.isEmpty()){
            string name = STYLES;
            name += QFile::encodeName(m_styles[cur].name);
            name += EXT;
            name = m_styles[cur].bCustom ? user_file(name.c_str()) : app_file(name.c_str());
            QFile f(QFile::decodeName(name.c_str()));
            if (f.open(IO_ReadOnly)){
                name = "";
                name.append(f.size(), '\x00');
                f.readBlock((char*)(name.c_str()), f.size());
                xsl = QString::fromUtf8(name.c_str());
            }else{
                log(L_WARN, "Can't open %s", name.c_str());
            }
        }else{
            xsl = m_styles[cur].text;
        }
        edtStyle->setText(quoteString(xsl));
        QTimer::singleShot(0, this, SLOT(sync()));
    }
}
Beispiel #2
0
void ChatPage::on_historyList_currentRowChanged(int currentRow)
{
    if (currentRow != -1) {
        ChatStyleInfo info = ui.historyStyle->itemData(ui.historyStyle->currentIndex(),Qt::UserRole).value<ChatStyleInfo>();

        QString author = info.authorName;
        if (info.authorEmail.isEmpty() == false) {
            author += " (" + info.authorEmail + ")";
        }
        whileBlocking(ui.historyAuthor)->setText(author);
        whileBlocking(ui.historyDescription)->setText(info.styleDescription);

        QStringList variants;
        ChatStyle::getAvailableVariants(info.stylePath, variants);
        whileBlocking(ui.historyComboBoxVariant)->clear();
        whileBlocking(ui.historyComboBoxVariant)->setEnabled(variants.size() != 0);
        whileBlocking(ui.historyComboBoxVariant)->addItems(variants);

        /* try to find "Standard" */
        int index = ui.historyComboBoxVariant->findText(VARIANT_STANDARD);
        if (index != -1) {
            whileBlocking(ui.historyComboBoxVariant)->setCurrentIndex(index);
        } else {
            whileBlocking(ui.historyComboBoxVariant)->setCurrentIndex(0);
        }
    } else {
        whileBlocking(ui.historyAuthor)->clear();
        whileBlocking(ui.historyDescription)->clear();
        whileBlocking(ui.historyComboBoxVariant)->clear();
        whileBlocking(ui.historyComboBoxVariant)->setDisabled(true);
    }

    fillPreview(ui.historyStyle, ui.historyComboBoxVariant, ui.historyPreview);
}
Beispiel #3
0
void ChatPage::on_privateList_currentRowChanged(int currentRow)
{
    if (currentRow != -1) {
        QListWidgetItem *item = ui.privateList->item(currentRow);
        ChatStyleInfo info = item->data(Qt::UserRole).value<ChatStyleInfo>();

        QString author = info.authorName;
        if (info.authorEmail.isEmpty() == false) {
            author += " (" + info.authorEmail + ")";
        }
        ui.privateAuthor->setText(author);
        ui.privateDescription->setText(info.styleDescription);

        QStringList variants;
        ChatStyle::getAvailableVariants(info.stylePath, variants);
        ui.privateComboBoxVariant->clear();
        ui.privateComboBoxVariant->setEnabled(variants.size() != 0);
        ui.privateComboBoxVariant->addItems(variants);

        /* try to find "Standard" */
        int index = ui.privateComboBoxVariant->findText(VARIANT_STANDARD);
        if (index != -1) {
            ui.privateComboBoxVariant->setCurrentIndex(index);
        } else {
            ui.privateComboBoxVariant->setCurrentIndex(0);
        }
    } else {
        ui.privateAuthor->clear();
        ui.privateDescription->clear();
        ui.privateComboBoxVariant->clear();
        ui.privateComboBoxVariant->setDisabled(true);
    }

    fillPreview(ui.privateList, ui.privateComboBoxVariant, ui.privatePreview);
}
/* show our results */
static void
doDialog (void)
{
  GtkWidget *dialog;
  GtkWidget *vbox;
  GtkWidget *hbox;
  GtkWidget *frame;
  GtkWidget *preview;

  gimp_ui_init (PLUG_IN_BINARY, TRUE);

  dialog = gimp_dialog_new (_("Colorcube Analysis"), PLUG_IN_ROLE,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC,

                            GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,

                            NULL);

  gimp_window_set_transient (GTK_WINDOW (dialog));

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      vbox, TRUE, TRUE, 0);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);

  /* use preview for histogram window */
  preview = gimp_preview_area_new ();
  gtk_widget_set_size_request (preview, PREWIDTH, PREHEIGHT);
  gtk_container_add (GTK_CONTAINER (frame), preview);

  /* output results */
  doLabel (vbox, _("Image dimensions: %d × %d"), width, height);

  if (uniques == 0)
    doLabel (vbox, _("No colors"));
  else if (uniques == 1)
    doLabel (vbox, _("Only one unique color"));
  else
    doLabel (vbox, _("Number of unique colors: %d"), uniques);

  /* show stuff */
  gtk_widget_show_all (dialog);

  fillPreview (preview);

  gimp_dialog_run (GIMP_DIALOG (dialog));

  gtk_widget_destroy (dialog);
}
Beispiel #5
0
void HistoryConfig::styleSelected(int n)
{
    if (n == m_cur)
        return;
    if (m_bDirty && (m_cur >= 0))
        m_styles[m_cur].text = unquoteText(edtStyle->text());
    m_cur = n;
    bool bCustom = m_styles[n].bCustom;
    btnRename->setEnabled(bCustom);
    btnDelete->setEnabled(bCustom);
    edtStyle->setReadOnly(!bCustom);
    fillPreview();
}
Beispiel #6
0
void HistoryConfig::apply()
{
    bool bChanged = false;
    for (unsigned i = 0; i < m_styles.size(); i++){
        if (m_styles[i].text.isEmpty() || !m_styles[i].bCustom)
            continue;
        if ((int)i == cmbStyle->currentItem())
            bChanged = true;
        string name = STYLES;
        name += QFile::encodeName(m_styles[i].name);
        name += EXT;
        name = user_file(name.c_str());
        QFile f(QFile::decodeName(name.c_str()));
        if (f.open(IO_WriteOnly | IO_Truncate)){
            string s;
            s = m_styles[i].text.utf8();
            f.writeBlock(s.c_str(), s.length());
        }else{
            log(L_WARN, "Can't create %s", name.c_str());
        }
    }
    int cur = cmbStyle->currentItem();
    if ((cur >= 0) && (m_styles[cur].name != QFile::decodeName(CorePlugin::m_plugin->getHistoryStyle()))){
        CorePlugin::m_plugin->setHistoryStyle(QFile::encodeName(m_styles[cur].name));
        bChanged = true;
    }
    delete CorePlugin::m_plugin->historyXSL;
    CorePlugin::m_plugin->historyXSL = new XSL(m_styles[cur].name);

    if (chkOwn->isChecked() != CorePlugin::m_plugin->getOwnColors()){
        bChanged = true;
        CorePlugin::m_plugin->setOwnColors(chkOwn->isChecked());
    }
    if (chkSmile->isChecked() != CorePlugin::m_plugin->getUseSmiles()){
        bChanged = true;
        CorePlugin::m_plugin->setUseSmiles(chkSmile->isChecked());
    }
    CorePlugin::m_plugin->setHistoryPage(atol(cmbPage->lineEdit()->text().latin1()));
    if (bChanged){
        Event e(EventHistoryConfig);
        e.process();
        fillPreview();
    }
    HistoryUserData *data = (HistoryUserData*)(getContacts()->getUserData(CorePlugin::m_plugin->history_data_id));
	data->CutDays = chkDays->isChecked();
	data->CutSize = chkSize->isChecked();
	data->Days    = atol(edtDays->text());
	data->MaxSize = atol(edtSize->text());
}
Beispiel #7
0
void HistoryConfig::toggled(bool)
{
    if (tabStyle->currentPage() == preview)
        fillPreview();
}
Beispiel #8
0
void HistoryConfig::apply()
{
    bool bChanged = false;
    for (unsigned i = 0; i < m_styles.size(); i++){
        if (m_styles[i].text.isEmpty() || !m_styles[i].bCustom)
            continue;
        if ((int)i == cmbStyle->currentItem())
            bChanged = true;
        string name = STYLES;
        name += QFile::encodeName(m_styles[i].name);
        name += EXT;
        name = user_file(name.c_str());
        QFile f(QFile::decodeName((name + BACKUP_SUFFIX).c_str())); // use backup file for this ...
        if (f.open(IO_WriteOnly | IO_Truncate)){
            string s;
            s = m_styles[i].text.utf8();
            f.writeBlock(s.c_str(), s.length());

            const int status = f.status();
#if QT_VERSION >= 0x030200
            const QString errorMessage = f.errorString();
#else
	    const QString errorMessage = "write file fail";
#endif
            f.close();
            if (status != IO_Ok) {
                log(L_ERROR, "IO error during writting to file %s : %s", (const char*)f.name().local8Bit(), (const char*)errorMessage.local8Bit());
            } else {
                // rename to normal file
                QFileInfo fileInfo(f.name());
                QString desiredFileName = QFile::decodeName(name.c_str());
                if (!fileInfo.dir().rename(fileInfo.fileName(), desiredFileName)) {
                    log(L_ERROR, "Can't rename file %s to %s", (const char*)fileInfo.fileName().local8Bit(), (const char*)desiredFileName.local8Bit());
                }
            }
        }else{
            log(L_WARN, "Can't create %s", name.c_str());
        }
    }
    int cur = cmbStyle->currentItem();
    if ((cur >= 0) && (m_styles[cur].name != QFile::decodeName(CorePlugin::m_plugin->getHistoryStyle()))){
        CorePlugin::m_plugin->setHistoryStyle(QFile::encodeName(m_styles[cur].name));
        bChanged = true;
    }
    delete CorePlugin::m_plugin->historyXSL;
    CorePlugin::m_plugin->historyXSL = new XSL(m_styles[cur].name);

    if (chkOwn->isChecked() != CorePlugin::m_plugin->getOwnColors()){
        bChanged = true;
        CorePlugin::m_plugin->setOwnColors(chkOwn->isChecked());
    }
    if (chkSmile->isChecked() != CorePlugin::m_plugin->getUseSmiles()){
        bChanged = true;
        CorePlugin::m_plugin->setUseSmiles(chkSmile->isChecked());
    }
    CorePlugin::m_plugin->setHistoryPage(atol(cmbPage->lineEdit()->text().latin1()));
    if (bChanged){
        Event e(EventHistoryConfig);
        e.process();
        fillPreview();
    }
    HistoryUserData *data = (HistoryUserData*)(getContacts()->getUserData(CorePlugin::m_plugin->history_data_id));
    data->CutDays = chkDays->isChecked();
    data->CutSize = chkSize->isChecked();
    data->Days    = atol(edtDays->text());
    data->MaxSize = atol(edtSize->text());
}
Beispiel #9
0
void ChatPage::on_historyComboBoxVariant_currentIndexChanged(int /*index*/)
{
    fillPreview(ui.historyStyle, ui.historyComboBoxVariant, ui.historyPreview);
}
Beispiel #10
0
void ChatPage::on_privateComboBoxVariant_currentIndexChanged(int /*index*/)
{
    fillPreview(ui.privateStyle, ui.privateComboBoxVariant, ui.privatePreview);
}
Beispiel #11
0
void ChatPage::on_publicComboBoxVariant_currentIndexChanged(int /*index*/)
{
    fillPreview(ui.publicStyle, ui.publicComboBoxVariant, ui.publicPreview);
}