mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
removed "the super ugly hack", Widget derives from QMainWindow
This commit is contained in:
parent
af4623695c
commit
921b8478f6
3336
mainwindow.ui
Normal file
3336
mainwindow.ui
Normal file
File diff suppressed because it is too large
Load Diff
9
qtox.pro
9
qtox.pro
|
@ -25,7 +25,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|||
|
||||
TARGET = qtox
|
||||
TEMPLATE = app
|
||||
FORMS += widget.ui
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
CONFIG += c++11
|
||||
|
||||
TRANSLATIONS = translations/de.ts \
|
||||
|
@ -86,7 +87,8 @@ HEADERS += widget/form/addfriendform.h \
|
|||
widget/tool/clickablelabel.h \
|
||||
smileypack.h \
|
||||
widget/emoticonswidget.h \
|
||||
style.h
|
||||
style.h \
|
||||
widget/adjustingscrollarea.h
|
||||
|
||||
SOURCES += \
|
||||
widget/form/addfriendform.cpp \
|
||||
|
@ -121,4 +123,5 @@ SOURCES += \
|
|||
widget/tool/clickablelabel.cpp \
|
||||
smileypack.cpp \
|
||||
widget/emoticonswidget.cpp \
|
||||
style.cpp
|
||||
style.cpp \
|
||||
widget/adjustingscrollarea.cpp
|
||||
|
|
24
settings.cpp
24
settings.cpp
|
@ -104,6 +104,8 @@ void Settings::load()
|
|||
minimizeOnClose = s.value("minimizeOnClose", false).toBool();
|
||||
useNativeStyle = s.value("nativeStyle", false).toBool();
|
||||
useNativeDecoration = s.value("nativeDecoration", true).toBool();
|
||||
windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray();
|
||||
windowState = s.value("windowState", QByteArray()).toByteArray();
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("Privacy");
|
||||
|
@ -162,6 +164,8 @@ void Settings::save(QString path)
|
|||
s.setValue("minimizeOnClose", minimizeOnClose);
|
||||
s.setValue("nativeStyle", useNativeStyle);
|
||||
s.setValue("nativeDecoration", useNativeDecoration);
|
||||
s.setValue("windowGeometry", windowGeometry);
|
||||
s.setValue("windowState", windowState);
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("Privacy");
|
||||
|
@ -359,6 +363,26 @@ void Settings::setUseNativeDecoration(bool value)
|
|||
useNativeDecoration = value;
|
||||
}
|
||||
|
||||
QByteArray Settings::getWindowGeometry() const
|
||||
{
|
||||
return windowGeometry;
|
||||
}
|
||||
|
||||
void Settings::setWindowGeometry(const QByteArray &value)
|
||||
{
|
||||
windowGeometry = value;
|
||||
}
|
||||
|
||||
QByteArray Settings::getWindowState() const
|
||||
{
|
||||
return windowState;
|
||||
}
|
||||
|
||||
void Settings::setWindowState(const QByteArray &value)
|
||||
{
|
||||
windowState = value;
|
||||
}
|
||||
|
||||
bool Settings::isMinimizeOnCloseEnabled() const
|
||||
{
|
||||
return minimizeOnClose;
|
||||
|
|
|
@ -118,6 +118,12 @@ public:
|
|||
bool getUseNativeDecoration() const;
|
||||
void setUseNativeDecoration(bool value);
|
||||
|
||||
QByteArray getWindowGeometry() const;
|
||||
void setWindowGeometry(const QByteArray &value);
|
||||
|
||||
QByteArray getWindowState() const;
|
||||
void setWindowState(const QByteArray &value);
|
||||
|
||||
private:
|
||||
Settings();
|
||||
Settings(Settings &settings) = delete;
|
||||
|
@ -155,6 +161,8 @@ private:
|
|||
bool minimizeOnClose;
|
||||
bool useNativeStyle;
|
||||
bool useNativeDecoration;
|
||||
QByteArray windowGeometry;
|
||||
QByteArray windowState;
|
||||
|
||||
// ChatView
|
||||
int firstColumnHandlePos;
|
||||
|
|
16
style.cpp
16
style.cpp
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre 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 3 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 COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "style.h"
|
||||
#include "settings.h"
|
||||
|
||||
|
|
16
style.h
16
style.h
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre 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 3 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 COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef STYLE_H
|
||||
#define STYLE_H
|
||||
|
||||
|
|
35
widget/adjustingscrollarea.cpp
Normal file
35
widget/adjustingscrollarea.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre 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 3 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 COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "adjustingscrollarea.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QLayout>
|
||||
|
||||
AdjustingScrollArea::AdjustingScrollArea(QWidget *parent) :
|
||||
QScrollArea(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void AdjustingScrollArea::resizeEvent(QResizeEvent *ev)
|
||||
{
|
||||
if (widget())
|
||||
{
|
||||
widget()->setMinimumWidth(width());
|
||||
}
|
||||
|
||||
QScrollArea::resizeEvent(ev);
|
||||
}
|
35
widget/adjustingscrollarea.h
Normal file
35
widget/adjustingscrollarea.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre 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 3 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 COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef ADJUSTINGSCROLLAREA_H
|
||||
#define ADJUSTINGSCROLLAREA_H
|
||||
|
||||
#include <QScrollArea>
|
||||
|
||||
class AdjustingScrollArea : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AdjustingScrollArea(QWidget *parent = 0);
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *ev);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // ADJUSTINGSCROLLAREA_H
|
|
@ -57,7 +57,7 @@ AddFriendForm::~AddFriendForm()
|
|||
main->deleteLater();
|
||||
}
|
||||
|
||||
void AddFriendForm::show(Ui::Widget &ui)
|
||||
void AddFriendForm::show(Ui::MainWindow &ui)
|
||||
{
|
||||
ui.mainContent->layout()->addWidget(main);
|
||||
ui.mainHead->layout()->addWidget(head);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#ifndef ADDFRIENDFORM_H
|
||||
#define ADDFRIENDFORM_H
|
||||
|
||||
#include "ui_widget.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
AddFriendForm();
|
||||
~AddFriendForm();
|
||||
|
||||
void show(Ui::Widget& ui);
|
||||
void show(Ui::MainWindow &ui);
|
||||
bool isToxId(const QString& value) const;
|
||||
void showWarning(const QString& message) const;
|
||||
QString getMessage() const;
|
||||
|
|
|
@ -137,7 +137,7 @@ ChatForm::~ChatForm()
|
|||
delete netcam;
|
||||
}
|
||||
|
||||
void ChatForm::show(Ui::Widget &ui)
|
||||
void ChatForm::show(Ui::MainWindow &ui)
|
||||
{
|
||||
ui.mainContent->layout()->addWidget(main);
|
||||
ui.mainHead->layout()->addWidget(head);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <QPoint>
|
||||
|
||||
#include "widget/tool/chattextedit.h"
|
||||
#include "ui_widget.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "core.h"
|
||||
#include "widget/netcamview.h"
|
||||
|
||||
|
@ -43,7 +43,7 @@ class ChatForm : public QObject
|
|||
public:
|
||||
ChatForm(Friend* chatFriend);
|
||||
~ChatForm();
|
||||
void show(Ui::Widget& ui);
|
||||
void show(Ui::MainWindow &ui);
|
||||
void setName(QString newName);
|
||||
void setStatusMessage(QString newMessage);
|
||||
void addFriendMessage(QString message);
|
||||
|
|
|
@ -50,7 +50,7 @@ FilesForm::~FilesForm()
|
|||
// I'm not too bummed about removing it
|
||||
}
|
||||
|
||||
void FilesForm::show(Ui::Widget& ui)
|
||||
void FilesForm::show(Ui::MainWindow& ui)
|
||||
{
|
||||
ui.mainContent->layout()->addWidget(&main);
|
||||
ui.mainHead->layout()->addWidget(head);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#ifndef FILESFORM_H
|
||||
#define FILESFORM_H
|
||||
|
||||
#include "ui_widget.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QTabWidget>
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
FilesForm();
|
||||
~FilesForm();
|
||||
|
||||
void show(Ui::Widget& ui);
|
||||
void show(Ui::MainWindow &ui);
|
||||
|
||||
public slots:
|
||||
void onFileDownloadComplete(const QString& path);
|
||||
|
|
|
@ -142,7 +142,7 @@ GroupChatForm::~GroupChatForm()
|
|||
delete main;
|
||||
}
|
||||
|
||||
void GroupChatForm::show(Ui::Widget &ui)
|
||||
void GroupChatForm::show(Ui::MainWindow &ui)
|
||||
{
|
||||
ui.mainContent->layout()->addWidget(main);
|
||||
ui.mainHead->layout()->addWidget(head);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <QTime>
|
||||
|
||||
#include "widget/tool/chattextedit.h"
|
||||
#include "ui_widget.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
// Spacing in px inserted when the author of the last message changes
|
||||
#define AUTHOR_CHANGE_SPACING 5
|
||||
|
@ -40,7 +40,7 @@ class GroupChatForm : public QObject
|
|||
public:
|
||||
GroupChatForm(Group* chatGroup);
|
||||
~GroupChatForm();
|
||||
void show(Ui::Widget& ui);
|
||||
void show(Ui::MainWindow &ui);
|
||||
void setName(QString newName);
|
||||
void addGroupMessage(QString message, int peerId);
|
||||
void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm"));
|
||||
|
|
|
@ -93,7 +93,7 @@ void SettingsForm::setFriendAddress(const QString& friendAddress)
|
|||
id.setText(friendAddress);
|
||||
}
|
||||
|
||||
void SettingsForm::show(Ui::Widget &ui)
|
||||
void SettingsForm::show(Ui::MainWindow &ui)
|
||||
{
|
||||
name.setText(ui.nameLabel->text());
|
||||
statusText.setText(ui.statusLabel->text());
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <QTextEdit>
|
||||
#include <QComboBox>
|
||||
#include "widget/tool/clickablelabel.h"
|
||||
#include "ui_widget.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "widget/selfcamview.h"
|
||||
|
||||
class SettingsForm : public QObject
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
SettingsForm();
|
||||
~SettingsForm();
|
||||
|
||||
void show(Ui::Widget& ui);
|
||||
void show(Ui::MainWindow &ui);
|
||||
|
||||
public slots:
|
||||
void setFriendAddress(const QString& friendAddress);
|
||||
|
|
|
@ -27,7 +27,6 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
{
|
||||
this->setMouseTracking(true);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setFixedWidth(225);
|
||||
this->setFixedHeight(55);
|
||||
this->setLayout(&layout);
|
||||
layout.setSpacing(0);
|
||||
|
@ -70,11 +69,6 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
isActiveWidget = 0;
|
||||
}
|
||||
|
||||
void FriendWidget::setNewFixedWidth(int newWidth)
|
||||
{
|
||||
this->setFixedWidth(newWidth);
|
||||
}
|
||||
|
||||
void FriendWidget::mouseReleaseEvent (QMouseEvent*)
|
||||
{
|
||||
emit friendWidgetClicked(this);
|
||||
|
|
|
@ -34,7 +34,6 @@ public:
|
|||
void leaveEvent(QEvent* event);
|
||||
void setAsActiveChatroom();
|
||||
void setAsInactiveChatroom();
|
||||
void setNewFixedWidth(int newWidth);
|
||||
|
||||
signals:
|
||||
void friendWidgetClicked(FriendWidget* widget);
|
||||
|
|
|
@ -27,7 +27,6 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
|||
this->setMouseTracking(true);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setLayout(&layout);
|
||||
this->setFixedWidth(225);
|
||||
this->setFixedHeight(55);
|
||||
layout.setSpacing(0);
|
||||
layout.setMargin(0);
|
||||
|
@ -72,11 +71,6 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
|||
isActiveWidget = 0;
|
||||
}
|
||||
|
||||
void GroupWidget::setNewFixedWidth(int newWidth)
|
||||
{
|
||||
this->setFixedWidth(newWidth);
|
||||
}
|
||||
|
||||
void GroupWidget::mouseReleaseEvent (QMouseEvent*)
|
||||
{
|
||||
emit groupWidgetClicked(this);
|
||||
|
|
|
@ -33,7 +33,8 @@ public:
|
|||
void contextMenuEvent(QContextMenuEvent * event);
|
||||
void enterEvent(QEvent* event);
|
||||
void leaveEvent(QEvent* event);
|
||||
|
||||
void setAsInactiveChatroom();
|
||||
void setAsActiveChatroom();
|
||||
|
||||
signals:
|
||||
void groupWidgetClicked(GroupWidget* widget);
|
||||
|
@ -44,9 +45,6 @@ public:
|
|||
QLabel avatar, name, nusers, statusPic;
|
||||
QHBoxLayout layout;
|
||||
QVBoxLayout textLayout;
|
||||
void setAsInactiveChatroom();
|
||||
void setAsActiveChatroom();
|
||||
void setNewFixedWidth(int newWidth);
|
||||
|
||||
private:
|
||||
QColor lastColor;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
#include "widget.h"
|
||||
#include "ui_widget.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "settings.h"
|
||||
#include "friend.h"
|
||||
#include "friendlist.h"
|
||||
|
@ -41,11 +41,21 @@
|
|||
|
||||
Widget *Widget::instance{nullptr};
|
||||
|
||||
Widget::Widget(QWidget *parent) :
|
||||
QWidget(parent), ui(new Ui::Widget), activeFriendWidget{nullptr}, activeGroupWidget{nullptr}
|
||||
Widget::Widget(QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
activeFriendWidget{nullptr},
|
||||
activeGroupWidget{nullptr}
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->statusbar->hide();
|
||||
ui->menubar->hide();
|
||||
|
||||
//restore window state
|
||||
restoreGeometry(Settings::getInstance().getWindowGeometry());
|
||||
restoreState(Settings::getInstance().getWindowState());
|
||||
|
||||
ui->titleBar->hide();
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
ui->friendList->setObjectName("friendList");
|
||||
|
@ -84,29 +94,17 @@ Widget::Widget(QWidget *parent) :
|
|||
resizeDiagSupEsq = false;
|
||||
resizeDiagSupDer = false;
|
||||
|
||||
QSettings settings(Settings::getInstance().getSettingsDirPath() + '/' + "windowSettings.ini", QSettings::IniFormat);
|
||||
QRect geo = settings.value("geometry").toRect();
|
||||
|
||||
if (geo.height() > 0 and geo.x() < QApplication::desktop()->width() and geo.width() > 0 and geo.y() < QApplication::desktop()->height())
|
||||
this->setGeometry(geo);
|
||||
|
||||
if (settings.value("maximized").toBool())
|
||||
{
|
||||
showMaximized();
|
||||
ui->pbMax->setObjectName("restoreButton");
|
||||
}
|
||||
|
||||
isWindowMinimized = 0;
|
||||
|
||||
ui->mainContent->setLayout(new QVBoxLayout());
|
||||
ui->mainHead->setLayout(new QVBoxLayout());
|
||||
ui->mainHead->layout()->setMargin(0);
|
||||
ui->mainHead->layout()->setSpacing(0);
|
||||
|
||||
QWidget* friendListWidget = new QWidget();
|
||||
friendListWidget->setLayout(new QVBoxLayout());
|
||||
friendListWidget->layout()->setSpacing(0);
|
||||
friendListWidget->layout()->setMargin(0);
|
||||
friendListWidget->setLayoutDirection(Qt::LeftToRight);
|
||||
ui->friendList->setWidget(friendListWidget);
|
||||
|
||||
// delay setting username and message until Core inits
|
||||
|
@ -116,10 +114,7 @@ Widget::Widget(QWidget *parent) :
|
|||
ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}");
|
||||
ui->friendList->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
QFile f1(":/ui/statusButton/statusButton.css");
|
||||
f1.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream statusButtonStylesheetStream(&f1);
|
||||
ui->statusButton->setStyleSheet(statusButtonStylesheetStream.readAll());
|
||||
ui->statusButton->setStyleSheet(Style::get(":/ui/statusButton/statusButton.css"));
|
||||
|
||||
QMenu *statusButtonMenu = new QMenu(ui->statusButton);
|
||||
QAction* setStatusOnline = statusButtonMenu->addAction(tr("Online","Button to set your status to 'Online'"));
|
||||
|
@ -147,9 +142,9 @@ Widget::Widget(QWidget *parent) :
|
|||
|
||||
ui->friendList->viewport()->installEventFilter(this);
|
||||
|
||||
QList<int> currentSizes = ui->centralWidget->sizes();
|
||||
currentSizes[0] = 225;
|
||||
ui->centralWidget->setSizes(currentSizes);
|
||||
// QList<int> currentSizes = ui->centralWidget->sizes();
|
||||
// currentSizes[0] = 225;
|
||||
// ui->centralWidget->setSizes(currentSizes);
|
||||
|
||||
ui->statusButton->setObjectName("offline");
|
||||
ui->statusButton->style()->polish(ui->statusButton);
|
||||
|
@ -198,7 +193,6 @@ Widget::Widget(QWidget *parent) :
|
|||
connect(this, &Widget::friendRequested, core, &Core::requestFriendship);
|
||||
connect(this, &Widget::friendRequestAccepted, core, &Core::acceptFriendRequest);
|
||||
|
||||
connect(ui->centralWidget, SIGNAL(splitterMoved(int,int)),this, SLOT(splitterMoved(int,int)));
|
||||
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(onAddClicked()));
|
||||
connect(ui->groupButton, SIGNAL(clicked()), this, SLOT(onGroupClicked()));
|
||||
connect(ui->transferButton, SIGNAL(clicked()), this, SLOT(onTransferClicked()));
|
||||
|
@ -236,10 +230,6 @@ Widget::~Widget()
|
|||
for (Group* g : GroupList::groupList)
|
||||
delete g;
|
||||
GroupList::groupList.clear();
|
||||
QSettings settings(Settings::getInstance().getSettingsDirPath() + '/' + "windowSettings.ini", QSettings::IniFormat);
|
||||
settings.setValue("geometry", geometry());
|
||||
settings.setValue("maximized", isMaximized());
|
||||
settings.setValue("useNativeTheme", useNativeTheme);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
@ -250,27 +240,16 @@ Widget* Widget::getInstance()
|
|||
return instance;
|
||||
}
|
||||
|
||||
//Super ugly hack to enable resizable friend widgets
|
||||
//There should be a way to set them to resize automagicly, but I can't seem to find it.
|
||||
void Widget::splitterMoved(int, int)
|
||||
{
|
||||
updateFriendListWidth();
|
||||
}
|
||||
|
||||
QThread* Widget::getCoreThread()
|
||||
{
|
||||
return coreThread;
|
||||
}
|
||||
|
||||
void Widget::updateFriendListWidth()
|
||||
void Widget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
int newWidth = ui->friendList->width();
|
||||
for (Friend* f : FriendList::friendList)
|
||||
if (f->widget != nullptr)
|
||||
f->widget->setNewFixedWidth(newWidth);
|
||||
for (Group* g : GroupList::groupList)
|
||||
if (g->widget != nullptr)
|
||||
g->widget->setNewFixedWidth(newWidth);
|
||||
Settings::getInstance().setWindowGeometry(saveGeometry());
|
||||
Settings::getInstance().setWindowState(saveState());
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
QString Widget::getUsername()
|
||||
|
@ -432,7 +411,6 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
QWidget* widget = ui->friendList->widget();
|
||||
QLayout* layout = widget->layout();
|
||||
layout->addWidget(newfriend->widget);
|
||||
updateFriendListWidth();
|
||||
connect(newfriend->widget, SIGNAL(friendWidgetClicked(FriendWidget*)), this, SLOT(onFriendWidgetClicked(FriendWidget*)));
|
||||
connect(newfriend->widget, SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
|
||||
connect(newfriend->widget, SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));
|
||||
|
@ -736,7 +714,7 @@ Group *Widget::createGroup(int groupId)
|
|||
layout->addWidget(newgroup->widget);
|
||||
if (!useNativeTheme)
|
||||
newgroup->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
|
||||
updateFriendListWidth();
|
||||
|
||||
connect(newgroup->widget, SIGNAL(groupWidgetClicked(GroupWidget*)), this, SLOT(onGroupWidgetClicked(GroupWidget*)));
|
||||
connect(newgroup->widget, SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
|
||||
connect(newgroup->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendGroupMessage(int,QString)));
|
||||
|
@ -768,12 +746,6 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Widget::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
updateFriendListWidth();
|
||||
}
|
||||
|
||||
|
||||
bool Widget::event(QEvent * e)
|
||||
{
|
||||
|
||||
|
@ -944,7 +916,6 @@ void Widget::moveWindow(QMouseEvent *e)
|
|||
|
||||
void Widget::resizeWindow(QMouseEvent *e)
|
||||
{
|
||||
updateFriendListWidth();
|
||||
if (!useNativeTheme)
|
||||
{
|
||||
if (allowToResize)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#define WIDGET_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QWidget>
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMenu>
|
||||
|
@ -31,7 +31,7 @@
|
|||
#define PIXELS_TO_ACT 7
|
||||
|
||||
namespace Ui {
|
||||
class Widget;
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class GroupWidget;
|
||||
|
@ -39,7 +39,7 @@ struct FriendWidget;
|
|||
class Group;
|
||||
struct Friend;
|
||||
|
||||
class Widget : public QWidget
|
||||
class Widget : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -60,7 +60,8 @@ public:
|
|||
void updateFriendStatusLights(int friendId);
|
||||
int useNativeTheme;
|
||||
~Widget();
|
||||
void updateFriendListWidth();
|
||||
|
||||
virtual void closeEvent(QCloseEvent *event);
|
||||
|
||||
signals:
|
||||
void friendRequestAccepted(const QString& userId);
|
||||
|
@ -70,9 +71,6 @@ signals:
|
|||
void usernameChanged(const QString& username);
|
||||
void statusMessageChanged(const QString& statusMessage);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void maximizeBtnClicked();
|
||||
void minimizeBtnClicked();
|
||||
|
@ -108,7 +106,6 @@ private slots:
|
|||
void removeFriend(int friendId);
|
||||
void copyFriendIdToClipboard(int friendId);
|
||||
void removeGroup(int groupId);
|
||||
void splitterMoved(int pos, int index);
|
||||
void setStatusOnline();
|
||||
void setStatusAway();
|
||||
void setStatusBusy();
|
||||
|
@ -121,7 +118,7 @@ private:
|
|||
Group* createGroup(int groupId);
|
||||
|
||||
private:
|
||||
Ui::Widget *ui;
|
||||
Ui::MainWindow *ui;
|
||||
QSplitter *centralLayout;
|
||||
QPoint dragPosition;
|
||||
TitleMode m_titleMode;
|
||||
|
|
Loading…
Reference in New Issue
Block a user