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

Merge branch 'pr1393'

This commit is contained in:
Dubslow 2015-03-25 11:32:05 -05:00
commit 14a565bc3a
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA
8 changed files with 68 additions and 10 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

@ -241,6 +241,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();
@ -411,6 +412,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);
@ -962,6 +964,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

@ -207,6 +207,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);
@ -328,6 +331,7 @@ private:
int firstColumnHandlePos;
int secondColumnHandlePosFromRight;
QString timestampFormat;
QString dateFormat;
bool statusChangeNotificationEnabled;
// Privacy
@ -360,6 +364,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

@ -187,7 +187,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

@ -35,6 +35,9 @@ static QStringList locales = {"bg", "de", "en", "es", "fr", "hr", "hu", "it", "l
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"};
// http://doc.qt.io/qt-4.8/qdate.html#fromString
static QStringList dateFormats = {"yyyy-MM-dd", "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"))
{
@ -101,15 +104,33 @@ 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);
QLocale ql;
QStringList datestamps;
dateFormats.append(ql.dateFormat());
dateFormats.append(ql.dateFormat(QLocale::LongFormat));
dateFormats.removeDuplicates();
timeFormats.append(ql.timeFormat());
timeFormats.append(ql.timeFormat(QLocale::LongFormat));
timeFormats.removeDuplicates();
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());
@ -146,6 +167,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);
@ -249,6 +271,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

@ -591,6 +591,16 @@ will be sent to them when they appear online to you.</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="dateformatLabel">
<property name="text">
<string>Date format:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="dateFormats"/>
</item>
</layout>
</item>
</layout>