"Fossies" - the Fresh Open Source Software Archive

Member "MP3Diags-unstable-1.5.01/src/PaletteDlgImpl.cpp" (10 Feb 2019, 4101 Bytes) of package /linux/privat/MP3Diags-unstable-1.5.01.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "PaletteDlgImpl.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.3.04_vs_1.5.01.

    1 /***************************************************************************
    2  *   MP3 Diags - diagnosis, repairs and tag editing for MP3 files          *
    3  *                                                                         *
    4  *   Copyright (C) 2009 by Marian Ciobanu                                  *
    5  *   ciobi@inbox.com                                                       *
    6  *                                                                         *
    7  *   This program is free software; you can redistribute it and/or modify  *
    8  *   it under the terms of the GNU General Public License version 2 as     *
    9  *   published by the Free Software Foundation.                            *
   10  *                                                                         *
   11  *   This program is distributed in the hope that it will be useful,       *
   12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   14  *   GNU General Public License for more details.                          *
   15  *                                                                         *
   16  *   You should have received a copy of the GNU General Public License     *
   17  *   along with this program; if not, write to the                         *
   18  *   Free Software Foundation, Inc.,                                       *
   19  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
   20  ***************************************************************************/
   21 
   22 
   23 #include  <QColorDialog>
   24 #include  <QPainter>
   25 #include  <QAction>
   26 
   27 #include  "PaletteDlgImpl.h"
   28 
   29 #include  "TagEditorDlgImpl.h"
   30 #include  "Helpers.h"
   31 
   32 PaletteDlgImpl::PaletteDlgImpl(CommonData* pCommonData, QWidget* pParent) : QDialog(pParent, getNoResizeWndFlags()), Ui::PaletteDlg(), m_pCommonData(pCommonData) // not a "thread window", but doesn't need resizing anyway
   33 {
   34     setupUi(this);
   35 
   36     m_vpColButtons.push_back(m_pCol0B);
   37     m_vpColButtons.push_back(m_pCol1B);
   38     m_vpColButtons.push_back(m_pCol2B);
   39     m_vpColButtons.push_back(m_pCol3B);
   40     m_vpColButtons.push_back(m_pCol4B);
   41     m_vpColButtons.push_back(m_pCol5B);
   42     m_vpColButtons.push_back(m_pCol6B);
   43 
   44     for (int i = 0; i < cSize(m_vpColButtons); ++i)
   45     {
   46         setBtnColor(i);
   47     }
   48 
   49     { QAction* p (new QAction(this)); p->setShortcut(QKeySequence("F1")); connect(p, SIGNAL(triggered()), this, SLOT(onHelp())); addAction(p); }
   50 }
   51 
   52 PaletteDlgImpl::~PaletteDlgImpl()
   53 {
   54 }
   55 
   56 /*$SPECIALIZATION$*/
   57 
   58 void PaletteDlgImpl::on_m_pOkB_clicked()
   59 {
   60     accept();
   61 }
   62 
   63 
   64 void PaletteDlgImpl::setBtnColor(int n)
   65 {
   66     /*QPalette pal (m_vpColButtons[n]->palette());
   67     //QPalette pal (m_pCol0B->palette());
   68     pal.setBrush(QPalette::Button, m_pCommonData->m_vTagEdtColors.at(n));
   69     pal.setBrush(QPalette::Window, m_pCommonData->m_vTagEdtColors[n]);
   70     //pal.setBrush(QPalette::Midlight, QColor(255, 0, 0));
   71     //pal.setBrush(QPalette::Dark, QColor(255, 0, 0));
   72     //pal.setBrush(QPalette::Mid, QColor(255, 0, 0));
   73     //pal.setBrush(QPalette::Shadow, QColor(255, 0, 0));
   74     m_vpColButtons[n]->setPalette(pal);*/
   75 
   76     int f (QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, m_vpColButtons.at(n)) + 2); //ttt2 hard-coded "2"
   77     int w (m_vpColButtons[n]->width() - f), h (m_vpColButtons[n]->height() - f);
   78     QPixmap pic (w, h);
   79     QPainter pntr (&pic);
   80     pntr.fillRect(0, 0, w, h, m_pCommonData->m_vTagEdtColors.at(n));
   81 
   82     m_vpColButtons[n]->setIcon(pic);
   83     m_vpColButtons[n]->setIconSize(QSize(w, h));
   84 
   85 /*    QPixmap pic (21, 21);
   86     QPainter pntr (&pic);
   87     QRect r (0, 0, 21, 21);
   88     pntr.fillRect(r, QColor(255, 255, 0));
   89     pntr.drawText(r, Qt::AlignCenter, "i");
   90 
   91     m_vpColButtons[n]->setIcon(pic);
   92     m_vpColButtons[n]->setIconSize(QSize(21, 21));*/
   93 }
   94 
   95 void PaletteDlgImpl::onButtonClicked(int n)
   96 {
   97     QColor c (QColorDialog::getColor(m_pCommonData->m_vTagEdtColors.at(n), this));
   98     if (!c.isValid()) { return; }
   99     m_pCommonData->m_vTagEdtColors[n] = c;
  100     setBtnColor(n);
  101 }
  102 
  103 
  104 
  105 void PaletteDlgImpl::onHelp()
  106 {
  107     //openHelp("index.html");
  108 }
  109