1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

closes tux3/qtox#1368 - settings to change dateformat

This commit is contained in:
agilob 2015-03-14 20:15:56 +00:00
parent ac9b327fe7
commit 4cf62bdefa
No known key found for this signature in database
GPG Key ID: 34568050DBCCB997
8 changed files with 62 additions and 12 deletions

View File

@ -104,11 +104,11 @@ HistoryKeeper::HistoryKeeper(GenericDdInterface *db_) :
*/
// for old tables:
QSqlQuery ans = db->exec("select seq from sqlite_sequence where name=\"history\";");
QSqlQuery ans = db->exec("SELECT seq FROM sqlite_sequence WHERE name=\"history\";");
if (ans.first())
{
int idMax = ans.value(0).toInt();
QSqlQuery ret = db->exec("select seq from sqlite_sequence where name=\"sent_status\";");
QSqlQuery ret = db->exec("SELECT seq FROM sqlite_sequence WHERE name=\"sent_status\";");
int idCur = 0;
if (ret.first())
{
@ -128,7 +128,7 @@ HistoryKeeper::HistoryKeeper(GenericDdInterface *db_) :
setSyncType(Settings::getInstance().getDbSyncType());
messageID = 0;
QSqlQuery sqlAnswer = db->exec("select seq from sqlite_sequence where name=\"history\";");
QSqlQuery sqlAnswer = db->exec("SELECT seq FROM sqlite_sequence WHERE name=\"history\";");
if (sqlAnswer.first())
messageID = sqlAnswer.value(0).toLongLong();
}

View File

@ -239,6 +239,7 @@ void Settings::load()
firstColumnHandlePos = s.value("firstColumnHandlePos", 50).toInt();
secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt();
timestampFormat = s.value("timestampFormat", "hh:mm").toString();
dateFormat = s.value("dateFormat", "dd-MM-yyyy").toString();
minimizeOnClose = s.value("minimizeOnClose", false).toBool();
minimizeToTray = s.value("minimizeToTray", false).toBool();
lightTrayIcon = s.value("lightTrayIcon", false).toBool();
@ -407,6 +408,7 @@ void Settings::saveGlobal(QString path)
s.setValue("firstColumnHandlePos", firstColumnHandlePos);
s.setValue("secondColumnHandlePosFromRight", secondColumnHandlePosFromRight);
s.setValue("timestampFormat", timestampFormat);
s.setValue("dateFormat", dateFormat);
s.setValue("minimizeOnClose", minimizeOnClose);
s.setValue("minimizeToTray", minimizeToTray);
s.setValue("lightTrayIcon", lightTrayIcon);
@ -948,6 +950,18 @@ void Settings::setTimestampFormat(const QString &format)
emit timestampFormatChanged();
}
const QString &Settings::getDateFormat() const
{
return dateFormat;
}
void Settings::setDateFormat(const QString &format)
{
dateFormat = format;
emit dateFormatChanged();
}
QString Settings::getEmojiFontFamily() const
{
return emojiFontFamily;

View File

@ -204,6 +204,9 @@ public:
const QString &getTimestampFormat() const;
void setTimestampFormat(const QString &format);
const QString &getDateFormat() const;
void setDateFormat(const QString &format);
bool isMinimizeOnCloseEnabled() const;
void setMinimizeOnClose(bool newValue);
@ -320,6 +323,7 @@ private:
int firstColumnHandlePos;
int secondColumnHandlePosFromRight;
QString timestampFormat;
QString dateFormat;
bool statusChangeNotificationEnabled;
// Privacy
@ -352,6 +356,7 @@ signals:
void smileyPackChanged();
void emojiFontChanged();
void timestampFormatChanged();
void dateFormatChanged();
void compactLayoutChanged();
};

View File

@ -826,10 +826,11 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
// Show the date every new day
QDateTime msgDateTime = it.timestamp.toLocalTime();
QDate msgDate = msgDateTime.date();
if (msgDate > lastDate)
{
lastDate = msgDate;
historyMessages.append(ChatMessage::createChatInfoMessage(msgDate.toString(), ChatMessage::INFO, QDateTime()));
historyMessages.append(ChatMessage::createChatInfoMessage(msgDate.toString(Settings::getInstance().getDateFormat()), ChatMessage::INFO, QDateTime()));
}
// Show each messages

View File

@ -173,7 +173,7 @@ void ProfileForm::setToxId(const QString& id)
void ProfileForm::onAvatarClicked()
{
QString filename = QFileDialog::getOpenFileName(this,
QString filename = QFileDialog::getOpenFileName(0,
tr("Choose a profile picture"),
QDir::homePath(),
Nexus::getSupportedImageFilter());

View File

@ -33,7 +33,10 @@
static QStringList locales = {"bg", "de", "en", "es", "fr", "hr", "hu", "it", "lt", "mannol", "nl", "pirate", "pl", "pt", "ru", "sl", "fi", "sv", "uk", "zh"};
static QStringList langs = {"Български", "Deutsch", "English", "Español", "Français", "Hrvatski", "Magyar", "Italiano", "Lietuvių", "mannol", "Nederlands", "Pirate", "Polski", "Português", "Русский", "Slovenščina", "Suomi", "Svenska", "Українська", "简体中文"};
static QStringList timeFormats = {"hh:mm AP", "hh:mm", "hh:mm:ss AP", "hh:mm:ss"};
static const QStringList timeFormats = {"hh:mm AP", "hh:mm", "hh:mm:ss AP", "hh:mm:ss"};
// http://doc.qt.io/qt-4.8/qdate.html#fromString
static const QStringList dateFormats = {"dd-MM-yyyy", "d-MM-yyyy", "dddd d-MM-yyyy", "dddd d-MM", "dddd dd MMMM"};
GeneralForm::GeneralForm(SettingsWidget *myParent) :
GenericForm(tr("General"), QPixmap(":/img/settings/general.png"))
{
@ -98,15 +101,25 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->emoticonSize->setValue(Settings::getInstance().getEmojiFontPointSize());
QStringList timestamps;
timestamps << QString("%1 - %2").arg(timeFormats[0],QTime::currentTime().toString(timeFormats[0]))
<< QString("%1 - %2").arg(timeFormats[1],QTime::currentTime().toString(timeFormats[1]))
<< QString("%1 - %2").arg(timeFormats[2],QTime::currentTime().toString(timeFormats[2]))
<< QString("%1 - %2").arg(timeFormats[3],QTime::currentTime().toString(timeFormats[3]));
foreach (QString timestamp, timeFormats) {
timestamps << QString("%1 - %2").arg(timestamp, QTime::currentTime().toString(timestamp));
}
bodyUI->timestamp->addItems(timestamps);
QStringList datestamps;
foreach (QString datestamp, dateFormats) {
datestamps << QString("%1 - %2").arg(datestamp, QDate::currentDate().toString(datestamp));
}
bodyUI->dateFormats->addItems(datestamps);
bodyUI->timestamp->setCurrentText(QString("%1 - %2").arg(Settings::getInstance().getTimestampFormat(),
QTime::currentTime().toString(Settings::getInstance().getTimestampFormat()))
); //idiot proof enough?
);
bodyUI->dateFormats->setCurrentText(QString("%1 - %2").arg(Settings::getInstance().getDateFormat(),
QDate::currentDate().toString(Settings::getInstance().getDateFormat()))
);
bodyUI->autoAwaySpinBox->setValue(Settings::getInstance().getAutoAwayTime());
bodyUI->cbEnableUDP->setChecked(!Settings::getInstance().getForceTCP());
@ -142,6 +155,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
connect(bodyUI->themeColorCBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onThemeColorChanged(int)));
connect(bodyUI->emoticonSize, SIGNAL(editingFinished()), this, SLOT(onEmoticonSizeChanged()));
connect(bodyUI->timestamp, SIGNAL(currentIndexChanged(int)), this, SLOT(onTimestampSelected(int)));
connect(bodyUI->dateFormats, SIGNAL(currentIndexChanged(int)), this, SLOT(onDateFormatSelected(int)));
//connection
connect(bodyUI->cbEnableIPv6, &QCheckBox::stateChanged, this, &GeneralForm::onEnableIPv6Updated);
connect(bodyUI->cbEnableUDP, &QCheckBox::stateChanged, this, &GeneralForm::onUDPUpdated);
@ -242,6 +256,11 @@ void GeneralForm::onTimestampSelected(int index)
Settings::getInstance().setTimestampFormat(timeFormats.at(index));
}
void GeneralForm::onDateFormatSelected(int index)
{
Settings::getInstance().setDateFormat(dateFormats.at(index));
}
void GeneralForm::onAutoAwayChanged()
{
int minutes = bodyUI->autoAwaySpinBox->value();

View File

@ -46,6 +46,7 @@ private slots:
void onEmoticonSizeChanged();
void onStyleSelected(QString style);
void onTimestampSelected(int index);
void onDateFormatSelected(int index);
void onSetStatusChange();
void onAutoAwayChanged();
void onUseEmoticonsChange();

View File

@ -38,7 +38,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-214</y>
<y>0</y>
<width>539</width>
<height>838</height>
</rect>
@ -571,6 +571,16 @@ will be sent to them when they will appear online to you.</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="dateformatLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="dateFormats"/>
</item>
</layout>
</item>
</layout>