?? colordlg.cpp
字號:
/*
qpegps is a program for displaying a map centered at the current longitude/
latitude as read from a gps receiver.
Copyright (C) 2002 Ralf Haselmeier <Ralf.Haselmeier@gmx.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "colordlg.h"
ColorDlg::ColorDlg(
QValueList<QColor> * sc, QStringList * isl, QWidget * parent,
const char * name, bool modal, WFlags f)
: QDialog(parent, name, modal, f), selectedColors(sc)
{
qColorPtrList.append(new QColor(Qt::black));
qColorPtrList.append(new QColor(Qt::white));
qColorPtrList.append(new QColor(Qt::darkGray));
qColorPtrList.append(new QColor(Qt::gray));
qColorPtrList.append(new QColor(Qt::lightGray));
qColorPtrList.append(new QColor(Qt::red));
qColorPtrList.append(new QColor(Qt::green));
qColorPtrList.append(new QColor(Qt::blue));
qColorPtrList.append(new QColor(Qt::cyan));
qColorPtrList.append(new QColor(Qt::magenta));
qColorPtrList.append(new QColor(Qt::yellow));
qColorPtrList.append(new QColor(Qt::darkRed));
qColorPtrList.append(new QColor(Qt::darkGreen));
qColorPtrList.append(new QColor(Qt::darkBlue));
qColorPtrList.append(new QColor(Qt::darkCyan));
qColorPtrList.append(new QColor(Qt::darkMagenta));
qColorPtrList.append(new QColor(Qt::darkYellow));
qColorPtrList.append(new QColor(Qt::color0));
qColorPtrList.append(new QColor(Qt::color1));
QVBox * vBox = new QVBox(this);
QButtonGroup * colorBG = new QButtonGroup(vBox);
colorBG->setFrameShape(QFrame::NoFrame);
QGridLayout * grid = new QGridLayout(colorBG, 4, 5, 2);
for ( uint i = 0; i < 19; ++i ) {
QPushButton * pb = new QPushButton("", colorBG);
pb->setBackgroundColor(*qColorPtrList.at(i));
pb->setFlat(true);
grid->addWidget(pb, i / 5, i % 5);
}
QHBox * hBox = new QHBox(vBox);
itemCB = new QListBox(hBox);
itemCB->insertStringList(*isl);
colorIndicatorL = new QLabel(tr(" selected color "), hBox);
//colorIndicatorL->setBackgroundColor(*qColorPtrList.at(0));
resize(parent->geometry().size());
vBox->resize(geometry().size());
connect( colorBG, SIGNAL(clicked(int)), SLOT(setColor(int)) );
connect( itemCB, SIGNAL(highlighted(int)), SLOT(setInd(int)) );
itemCB->setCurrentItem(0);
}
void ColorDlg::setColor(int colorIdx)
{
colorIndicatorL->setBackgroundColor(*qColorPtrList.at(colorIdx));
(*selectedColors)[itemCB->currentItem()] = *qColorPtrList.at(colorIdx);
}
void ColorDlg::setInd(int itemIdx)
{
colorIndicatorL->setBackgroundColor((*selectedColors)[itemIdx]);
}
// end of file
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -