Skip to content

Commit

Permalink
Working on colors
Browse files Browse the repository at this point in the history
  • Loading branch information
ea4k committed Jan 4, 2025
1 parent 42e3c4f commit 2cfe514
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 93 deletions.
55 changes: 6 additions & 49 deletions src/awards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,58 +1185,15 @@ Returns a valid format IOTA if possible and "" in other cases.
*/
}

void Awards::setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default)
void Awards::setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default)
{
//qDebug() << Q_FUNC_INFO << ": " << _newOne << "/" << _needed << "/" << _worked << "/" << _confirmed << "/" << _default;

defaultColor = QColor(_default.toUpper());
neededColor = QColor(_needed.toUpper());
workedColor = QColor(_worked.toUpper());
confirmedColor = QColor(_confirmed.toUpper());
newOneColor = QColor(_newOne.toUpper());

if (defaultColor.isValid())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
defaultColor.fromString(QAnyStringView((_default.toUpper()))); //To be replaced by .fromString in Qt6.6
#else
defaultColor.setNamedColor(_default.toUpper()); //To be replaced by .fromString in Qt6.6
#endif
}

if (neededColor.isValid())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
neededColor.fromString(QAnyStringView((_needed.toUpper()))); //To be replaced by .fromString in Qt6.6
#else
neededColor.setNamedColor(_needed.toUpper()); //To be replaced by .fromString in Qt6.6
#endif
}

if (confirmedColor.isValid())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
confirmedColor.fromString(QAnyStringView((_confirmed.toUpper()))); //To be replaced by .fromString in Qt6.6
#else
confirmedColor.setNamedColor(_confirmed.toUpper()); //To be replaced by .fromString in Qt6.6
#endif
}
if (newOneColor.isValid())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
newOneColor.fromString(QAnyStringView((_newOne.toUpper()))); //To be replaced by .fromString in Qt6.6
#else
newOneColor.setNamedColor(_newOne.toUpper()); //To be replaced by .fromString in Qt6.6
#endif
}
if (workedColor.isValid())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
workedColor.fromString(QAnyStringView((_worked.toUpper())));
#else
workedColor.setNamedColor(_worked.toUpper());
#endif
}
defaultColor = _default;
neededColor = _needed;
workedColor = _worked;
confirmedColor = _confirmed;
newOneColor = _newOne;
}

QColor Awards::getDefaultColor()
Expand Down
2 changes: 1 addition & 1 deletion src/awards.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Awards : public QObject {
QString getDXCCStatusBand2(const int _dxcc, const int _band, const int _logNumber=0); // Returns -, W or C (Not worked, worked, Confirmed)
QString getDXCCStatusBand(const int _dxcc, const int _band); // Returns -, W or C (Not worked, worked, Confirmed)

void setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default);
void setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default);
QColor getQRZDXStatusColor(EntityStatus _entitystatus); // Receives Entity, band, mode & log
QColor getDefaultColor();

Expand Down
37 changes: 20 additions & 17 deletions src/dxcluster/dxcluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,14 @@ void DXClusterWidget::setCurrentLog(const int _log)
}
}

void DXClusterWidget::addItemToClusterList(const QString &text, const QColor &color)
{
QListWidgetItem *item = new QListWidgetItem();
item->setForeground(QBrush(color));
item->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
item->setText(text);
dxClusterListWidget->insertItem(0, item);
}

void DXClusterWidget::slotClusterDataArrived()
{
Expand Down Expand Up @@ -379,13 +387,10 @@ void DXClusterWidget::slotClusterDataArrived()
dxSpotColor = awards->getDefaultColor();
}

//qDebug() << Q_FUNC_INFO << " - While 70";
qDebug() << Q_FUNC_INFO << " - While 70 - Color: " << dxSpotColor.name(QColor::HexRgb);

addItemToClusterList(dxClusterString, dxSpotColor);

QListWidgetItem *item = new QListWidgetItem();
item->setForeground(QBrush(dxSpotColor));
item->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
item->setText(dxClusterString);
dxClusterListWidget->insertItem(0,item);

//qDebug() << Q_FUNC_INFO << " - END";
}
Expand All @@ -403,10 +408,7 @@ void DXClusterWidget::slotClusterSocketConnected()
{
//qDebug() << Q_FUNC_INFO;

QListWidgetItem *item = new QListWidgetItem();
item->setForeground(QBrush(awards->getDefaultColor()));
item->setText(tr("Connected to server"));
dxClusterListWidget->insertItem(0,item);
addItemToClusterList(tr("Connected to server"), awards->getDefaultColor());

// dxClusterSpotItem * item = new dxClusterSpotItem(dxclusterListWidget, i18n("Connected to server"), awards->getDefaultColor());
dxClusterConnected = true;
Expand Down Expand Up @@ -453,11 +455,9 @@ void DXClusterWidget::slotClusterSocketConnected()

void DXClusterWidget::slotClusterSocketConnectionClosed()
{
//qDebug() << Q_FUNC_INFO;
QListWidgetItem *item = new QListWidgetItem();
item->setForeground(QBrush(awards->getDefaultColor()));
item->setText(tr("Connection closed by the server"));
dxClusterListWidget->insertItem(0,item);
//qDebug() << Q_FUNC_INFO;
addItemToClusterList(tr("Connection closed by the server"), awards->getDefaultColor());

dxClusterConnected = false;
dxClusterAlreadyConnected = false;
sendButton->setText(tr("Connect"));
Expand Down Expand Up @@ -515,9 +515,9 @@ void DXClusterWidget::slotClusterInputTextChanged()
}
}

void DXClusterWidget::setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default)
void DXClusterWidget::setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default)
{
//qDebug() << Q_FUNC_INFO << ": " << _newOne << "/" << _needed << "/" << _worked << "/" << _confirmed << "/" << _default;
qDebug() << Q_FUNC_INFO << ": " << _newOne.name(QColor::HexRgb) << "/" << _needed.name(QColor::HexRgb) << "/" << _worked.name(QColor::HexRgb) << "/" << _confirmed.name(QColor::HexRgb) << "/" << _default.name(QColor::HexRgb);
// Just to pass the colors to the awards class
awards->setColors(_newOne, _needed, _worked, _confirmed, _default);
}
Expand Down Expand Up @@ -767,6 +767,9 @@ void DXClusterWidget::loadSettings()
{
//qDebug() << Q_FUNC_INFO << " - Start";
QSettings settings(util->getCfgFile (), QSettings::IniFormat);



QString aux = settings.value("DXClusterServerToUse").toString ();

if (aux.contains(':'))
Expand Down
5 changes: 3 additions & 2 deletions src/dxcluster/dxcluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class DXClusterWidget : public QWidget
//DXClusterWidget(DataProxy_SQLite *dp, const QString &clusterToConnect, const int portToConnect, QWidget *parent );
void init();
~DXClusterWidget();
void setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default);

void setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default);
void setDXClusterSpotConfig(bool _showhf, bool _showvhf, bool _showwarc, bool _showworked, bool _showconfirmed, bool _showann, bool _showwwv, bool _showwcy );
//void setDXClusterServer(const QString &clusterToConnect, const int portToConnect);
void setCurrentLog(const int _log);
Expand Down Expand Up @@ -91,7 +92,7 @@ private slots:

private:
//void TESTADDSPOT(); // Just a test spot

void addItemToClusterList(const QString &text, const QColor &color); // Adds a message to the list
void createActions();
void connectToDXCluster();
//QStringList readItem(QListWidgetItem * _stringSpot);
Expand Down
2 changes: 1 addition & 1 deletion src/infowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void InfoWidget::clear()
clearInfoFromLocators();
}

void InfoWidget::setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default)
void InfoWidget::setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default)
{
awards->setColors (_newOne, _needed, _worked, _confirmed, _default);
clearBandLabels();
Expand Down
2 changes: 1 addition & 1 deletion src/infowidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class InfoWidget : public QWidget
void createUI();
void clear();
void setCurrentLog(const int _log);
void setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default);
void setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default);
void setImperialSystem (const bool _imp);
void showInfo(const int _entity);
void showDistanceAndBearing(const QString &_locLocal, const QString &_loc2);
Expand Down
47 changes: 32 additions & 15 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ void MainWindow::init_variables()
palBlack.setColor(QPalette::Text, Qt::black);

clublogAnswer = -1;
qDebug() << Q_FUNC_INFO << " - Changing colors to default";
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
defaultColor.fromString(QAnyStringView("slategrey")); //To be replaced by .fromString in Qt6.6
neededColor.fromString(QAnyStringView("yellow"));
Expand All @@ -411,7 +412,7 @@ void MainWindow::init_variables()
confirmedColor.setNamedColor("red");
newOneColor.setNamedColor("green");
#endif
//qDebug() << Q_FUNC_INFO << " - END";
qDebug() << Q_FUNC_INFO << " - END";
}

void MainWindow::checkDebugFile()
Expand Down Expand Up @@ -3495,11 +3496,22 @@ void MainWindow::slotOpenWiki()
logEvent(Q_FUNC_INFO, "END", Debug);
}

void MainWindow::setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default)
{
qDebug() << Q_FUNC_INFO << "Confirmed: " << _newOne.name(QColor::HexRgb) << " / Needed: " << _needed.name(QColor::HexRgb) <<
" / Worked: " << _worked.name(QColor::HexRgb) << " / Confirmed: " << _confirmed.name(QColor::HexRgb) <<
" / Default: " << _default.name(QColor::HexRgb);
searchWidget->setColors(_newOne, _needed, _worked, _confirmed, _default);
awards->setColors (_newOne, _needed, _worked, _confirmed, _default);
mapWindow->setColors (_worked, _confirmed, _default);
dxClusterWidget->setColors (_newOne, _needed, _worked, _confirmed, _default);
infoWidget->setColors(_newOne, _needed, _worked, _confirmed, _default);
}

bool MainWindow::applySettings()
{
//qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << " - NewOneColor: " << newOneColor.name(QColor::HexRgb);

if ((useDefaultLogFileName) && (defaultADIFLogFile.length()>0))
{
useDefaultLogFileName = true;
Expand All @@ -3508,14 +3520,11 @@ bool MainWindow::applySettings()
{
useDefaultLogFileName = false;
}

checkIfNewBandOrMode ();
infoWidget->setImperialSystem(imperialSystem);
infoLabel2->setText(world->getEntityName(currentEntity));
infoWidget->showEntityInfo(currentEntity);
searchWidget->setColors(newOneColor.name(QColor::HexRgb), neededColor.name(QColor::HexRgb), workedColor.name(QColor::HexRgb), confirmedColor.name(QColor::HexRgb), defaultColor.name(QColor::HexRgb));
awards->setColors (newOneColor.name(QColor::HexRgb), neededColor.name(QColor::HexRgb), workedColor.name(QColor::HexRgb), confirmedColor.name(QColor::HexRgb), defaultColor.name(QColor::HexRgb));
mapWindow->setColors (workedColor, confirmedColor, defaultColor);
dxClusterWidget->setColors (newOneColor.name(QColor::HexRgb), neededColor.name(QColor::HexRgb), workedColor.name(QColor::HexRgb), confirmedColor.name(QColor::HexRgb), defaultColor.name(QColor::HexRgb));
dxClusterWidget->setDXClusterSpotConfig(dxClusterShowHF, dxClusterShowVHF, dxClusterShowWARC, dxClusterShowWorked, dxClusterShowConfirmed, dxClusterShowAnn, dxClusterShowWWV, dxClusterShowWCY );
setMainWindowTitle();
dxClusterWidget->setMyQRZ(stationCallsign);
Expand All @@ -3531,7 +3540,7 @@ bool MainWindow::applySettings()
searchWidget->setVersion(softwareVersion);
searchWidget->setCurrentLog(currentLog);
infoWidget->setCurrentLog(currentLog);
infoWidget->setColors(newOneColor.name(QColor::HexRgb), neededColor.name(QColor::HexRgb), workedColor.name(QColor::HexRgb), confirmedColor.name(QColor::HexRgb), defaultColor.name(QColor::HexRgb));


satTabWidget->refreshData();
adifLoTWExportWidget->setLogNumber (currentLog);
Expand Down Expand Up @@ -6566,7 +6575,7 @@ bool MainWindow::loadSettings()
readActiveBands (settings.value("Bands", listAux).toStringList ());
settings.endGroup ();

//qDebug() << Q_FUNC_INFO << " - 40 - logview";
//qDebug() << Q_FUNC_INFO << " - 40 - logview";setColors
logWindow->setColumns(settings.value ("LogViewFields").toStringList ());
//qDebug() << Q_FUNC_INFO << " - 41 - logs";

Expand All @@ -6589,25 +6598,33 @@ bool MainWindow::loadSettings()
//qDebug() << Q_FUNC_INFO << " - 60 - colors";
settings.beginGroup ("Colors");

#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
//qDebug() << Q_FUNC_INFO << " - 61 - NewOneColor: " << settings.value("NewOneColor").toString();
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
qDebug() << Q_FUNC_INFO << " - 61 - NewOneColor: " << settings.value("NewOneColor").toString();
if (QColor::isValidColor(settings.value("NewOneColor").toString()))
{
qDebug() << Q_FUNC_INFO << " - Color is valid: ";
}
else
{
qDebug() << Q_FUNC_INFO << " - Color is NOT valid: ";
}
newOneColor.fromString(QAnyStringView((settings.value ("NewOneColor", "#FF0000").toString ())));
//newOneColor.setNamedColor(settings.value ("NewOneColor", "#FF0000").toString ());
//qDebug() << Q_FUNC_INFO << " - 61 - NewOneColor-2: " << newOneColor.name(QColor::HexRgb);
qDebug() << Q_FUNC_INFO << " - 62 - NewOneColor: " << settings.value("NewOneColor").toString();
neededColor.fromString(QAnyStringView((settings.value ("NeededColor","#FF8C00").toString ())));
workedColor.fromString(QAnyStringView((settings.value ("WorkedColor", "#FFD700").toString ())));
confirmedColor.fromString(QAnyStringView((settings.value ("ConfirmedColor", "#32CD32").toString ())));
defaultColor.fromString(QAnyStringView((settings.value ("DefaultColor", "#00BFFF").toString ())));
#else
qDebug() << Q_FUNC_INFO << " - 61-2 - NewOneColor: " << settings.value("NewOneColor").toString();
newOneColor.setNamedColor(settings.value ("NewOneColor", "#FF0000").toString ());
neededColor.setNamedColor(settings.value ("NeededColor","#FF8C00").toString ());
workedColor.setNamedColor(settings.value ("WorkedColor", "#FFD700").toString ());
confirmedColor.setNamedColor(settings.value ("ConfirmedColor", "#32CD32").toString ());
defaultColor.setNamedColor(settings.value ("DefaultColor", "#00BFFF").toString ());
#endif


#endif
settings.endGroup ();
setColors(newOneColor, neededColor, workedColor, confirmedColor, defaultColor);

setupDialog->loadDarkMode ();

//qDebug() << Q_FUNC_INFO << " - 70 - misc";
Expand Down
2 changes: 1 addition & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private slots:
void fileExportEQSL2(const QString &_call, QList<int> _qsos);
//void fileExportADIF(const QString &_st, const QString &_grid, const QDate &_startDate, const QDate &_endDate);
void fileExportADIF2(const QString &_call, QList<int> _qsos);

void setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default);
bool callTQSL(const QString &_filename, const QString &_call);
void showNumberOfSavedQSO(const QString &_fn, const int _n);
//QString getCallToUseForLoTWExportUpload();
Expand Down
2 changes: 1 addition & 1 deletion src/searchmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void SearchModel::setFilterString(const QString &_st)
select();
}

void SearchModel::setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default)
void SearchModel::setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default)
{
//qDebug() << "DXClusterWidget::setColors: " << _newOne << "/" << _needed << "/" << _worked << "/" << _confirmed << "/" << _default;
// Just to pass the colors to the awards class
Expand Down
2 changes: 1 addition & 1 deletion src/searchmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SearchModel : public QSqlRelationalTableModel
void setFilterString(const QString &_st);
void setStationCallsignInHeader(const bool _s);
void update();
void setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default);
void setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default);
void setDXCCColumn(const int _i);
void setBandIdColumn(const int _i);
void setModeIdColumn(const int _i);
Expand Down
2 changes: 1 addition & 1 deletion src/searchwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ void SearchWidget::slotToolSearchNeededQSLRequested()
searchWindow->slotToolSearchQSL(3);
}

void SearchWidget::setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default)
void SearchWidget::setColors(const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default)
{
//qDebug() << "DXClusterWidget::setColors: " << _newOne << "/" << _needed << "/" << _worked << "/" << _confirmed << "/" << _default;
// Just to pass the colors to the awards class
Expand Down
2 changes: 1 addition & 1 deletion src/searchwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SearchWidget : public QWidget
void setStationCallsign(const QString &_st);
void setCallToSearch (const QString &_st);
void searchToolNeededQSLToSend();
void setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default);
void setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default);
void refresh();

public slots:
Expand Down
2 changes: 1 addition & 1 deletion src/searchwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ void SearchWindow::colorTheList()
}
*/

void SearchWindow::setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default)
void SearchWindow::setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default)
{
//qDebug() << "DXClusterWidget::setColors: " << _newOne << "/" << _needed << "/" << _worked << "/" << _confirmed << "/" << _default;
// Just to pass the colors to the awards class
Expand Down
2 changes: 1 addition & 1 deletion src/searchwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SearchWindow : public QWidget
QList<int> getSelectedQSOs();
void setNeedingQSL(bool const _q);
void slotToolSearchQSL(const int actionQSL);
void setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default);
void setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default);



Expand Down

0 comments on commit 2cfe514

Please sign in to comment.