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

Merge branch 'pr871'

This commit is contained in:
Dubslow 2014-12-01 14:15:03 -06:00
commit 3fe91d3563
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA
2 changed files with 41 additions and 14 deletions

View File

@ -73,7 +73,16 @@ Widget::Widget(QWidget *parent)
void Widget::init() void Widget::init()
{ {
ui->setupUi(this); ui->setupUi(this);
idleTimer = new QTimer();
idleTimer->setSingleShot(true);
setIdleTimer(Settings::getInstance().getAutoAwayTime());
//restore window state
restoreGeometry(Settings::getInstance().getWindowGeometry());
restoreState(Settings::getInstance().getWindowState());
ui->mainSplitter->restoreState(Settings::getInstance().getSplitterState());
if (QSystemTrayIcon::isSystemTrayAvailable()) if (QSystemTrayIcon::isSystemTrayAvailable())
{ {
icon = new QSystemTrayIcon(this); icon = new QSystemTrayIcon(this);
@ -123,15 +132,6 @@ void Widget::init()
ui->statusbar->hide(); ui->statusbar->hide();
ui->menubar->hide(); ui->menubar->hide();
idleTimer = new QTimer();
idleTimer->setSingleShot(true);
setIdleTimer(Settings::getInstance().getAutoAwayTime());
//restore window state
restoreGeometry(Settings::getInstance().getWindowGeometry());
restoreState(Settings::getInstance().getWindowState());
ui->mainSplitter->restoreState(Settings::getInstance().getSplitterState());
layout()->setContentsMargins(0, 0, 0, 0); layout()->setContentsMargins(0, 0, 0, 0);
ui->friendList->setStyleSheet(Style::resolve(Style::getStylesheet(":ui/friendList/friendList.css"))); ui->friendList->setStyleSheet(Style::resolve(Style::getStylesheet(":ui/friendList/friendList.css")));
@ -257,6 +257,7 @@ void Widget::init()
connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked())); connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked()));
connect(ui->nameLabel, SIGNAL(textChanged(QString, QString)), this, SLOT(onUsernameChanged(QString, QString))); connect(ui->nameLabel, SIGNAL(textChanged(QString, QString)), this, SLOT(onUsernameChanged(QString, QString)));
connect(ui->statusLabel, SIGNAL(textChanged(QString, QString)), this, SLOT(onStatusMessageChanged(QString, QString))); connect(ui->statusLabel, SIGNAL(textChanged(QString, QString)), this, SLOT(onStatusMessageChanged(QString, QString)));
connect(ui->mainSplitter, &QSplitter::splitterMoved, this, &Widget::onSplitterMoved);
connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked())); connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked()));
connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline())); connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway())); connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
@ -336,9 +337,8 @@ void Widget::closeEvent(QCloseEvent *event)
} }
else else
{ {
Settings::getInstance().setWindowGeometry(saveGeometry()); saveWindowGeometry();
Settings::getInstance().setWindowState(saveState()); saveSplitterGeometry();
Settings::getInstance().setSplitterState(ui->mainSplitter->saveState());
QWidget::closeEvent(event); QWidget::closeEvent(event);
} }
} }
@ -354,6 +354,12 @@ void Widget::changeEvent(QEvent *event)
} }
} }
void Widget::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
saveWindowGeometry();
}
QString Widget::detectProfile() QString Widget::detectProfile()
{ {
QDir dir(Settings::getSettingsDirPath()); QDir dir(Settings::getSettingsDirPath());
@ -1157,6 +1163,23 @@ void Widget::onSetShowSystemTray(bool newValue){
icon->setVisible(newValue); icon->setVisible(newValue);
} }
void Widget::saveWindowGeometry()
{
Settings::getInstance().setWindowGeometry(saveGeometry());
Settings::getInstance().setWindowState(saveState());
}
void Widget::saveSplitterGeometry()
{
Settings::getInstance().setSplitterState(ui->mainSplitter->saveState());
}
void Widget::onSplitterMoved(int pos, int index)
{
Q_UNUSED(pos);
Q_UNUSED(index);
saveSplitterGeometry();
}
QMessageBox::StandardButton Widget::showWarningMsgBox(const QString& title, const QString& msg, QMessageBox::StandardButtons buttons) QMessageBox::StandardButton Widget::showWarningMsgBox(const QString& title, const QString& msg, QMessageBox::StandardButtons buttons)
{ {

View File

@ -72,7 +72,8 @@ public:
virtual void closeEvent(QCloseEvent *event); virtual void closeEvent(QCloseEvent *event);
virtual void changeEvent(QEvent *event); virtual void changeEvent(QEvent *event);
virtual void resizeEvent(QResizeEvent *event);
void clearAllReceipts(); void clearAllReceipts();
void reloadTheme(); void reloadTheme();
@ -132,6 +133,7 @@ private slots:
void onUserAway(); void onUserAway();
void getPassword(QString info, int passtype, uint8_t* salt); void getPassword(QString info, int passtype, uint8_t* salt);
void onSetShowSystemTray(bool newValue); void onSetShowSystemTray(bool newValue);
void onSplitterMoved(int pos, int index);
private: private:
void init(); void init();
@ -140,6 +142,8 @@ private:
Group* createGroup(int groupId); Group* createGroup(int groupId);
void removeFriend(Friend* f, bool fake = false); void removeFriend(Friend* f, bool fake = false);
void removeGroup(Group* g, bool fake = false); void removeGroup(Group* g, bool fake = false);
void saveWindowGeometry();
void saveSplitterGeometry();
QString askProfiles(); QString askProfiles();
QString detectProfile(); QString detectProfile();
QSystemTrayIcon *icon; QSystemTrayIcon *icon;