mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge PR57
This commit is contained in:
commit
0a41c0d712
11
core.cpp
11
core.cpp
|
@ -39,14 +39,14 @@ Core::Core(Camera* cam) :
|
|||
{
|
||||
toxTimer = new QTimer(this);
|
||||
toxTimer->setSingleShot(true);
|
||||
saveTimer = new QTimer(this);
|
||||
saveTimer->start(TOX_SAVE_INTERVAL);
|
||||
//saveTimer = new QTimer(this);
|
||||
//saveTimer->start(TOX_SAVE_INTERVAL);
|
||||
//fileTimer = new QTimer(this);
|
||||
//fileTimer->start(TOX_FILE_INTERVAL);
|
||||
bootstrapTimer = new QTimer(this);
|
||||
bootstrapTimer->start(TOX_BOOTSTRAP_INTERVAL);
|
||||
connect(toxTimer, &QTimer::timeout, this, &Core::process);
|
||||
connect(saveTimer, &QTimer::timeout, this, &Core::saveConfiguration);
|
||||
//connect(saveTimer, &QTimer::timeout, this, &Core::saveConfiguration); //Disable save timer in favor of saving on events
|
||||
//connect(fileTimer, &QTimer::timeout, this, &Core::fileHeartbeat);
|
||||
connect(bootstrapTimer, &QTimer::timeout, this, &Core::onBootstrapTimer);
|
||||
connect(&Settings::getInstance(), &Settings::dhtServerListChanged, this, &Core::bootstrapDht);
|
||||
|
@ -317,6 +317,7 @@ void Core::acceptFriendRequest(const QString& userId)
|
|||
if (friendId == -1) {
|
||||
emit failedToAddFriend(userId);
|
||||
} else {
|
||||
saveConfiguration();
|
||||
emit friendAdded(friendId, userId);
|
||||
}
|
||||
}
|
||||
|
@ -537,6 +538,7 @@ void Core::removeFriend(int friendId)
|
|||
if (tox_del_friend(tox, friendId) == -1) {
|
||||
emit failedToRemoveFriend(friendId);
|
||||
} else {
|
||||
saveConfiguration();
|
||||
emit friendRemoved(friendId);
|
||||
}
|
||||
}
|
||||
|
@ -553,6 +555,7 @@ void Core::setUsername(const QString& username)
|
|||
if (tox_set_name(tox, cUsername.data(), cUsername.size()) == -1) {
|
||||
emit failedToSetUsername(username);
|
||||
} else {
|
||||
saveConfiguration();
|
||||
emit usernameSet(username);
|
||||
}
|
||||
}
|
||||
|
@ -564,6 +567,7 @@ void Core::setStatusMessage(const QString& message)
|
|||
if (tox_set_status_message(tox, cMessage.data(), cMessage.size()) == -1) {
|
||||
emit failedToSetStatusMessage(message);
|
||||
} else {
|
||||
saveConfiguration();
|
||||
emit statusMessageSet(message);
|
||||
}
|
||||
}
|
||||
|
@ -587,6 +591,7 @@ void Core::setStatus(Status status)
|
|||
}
|
||||
|
||||
if (tox_set_user_status(tox, userstatus) == 0) {
|
||||
saveConfiguration();
|
||||
emit statusSet(status);
|
||||
} else {
|
||||
emit failedToSetStatus(status);
|
||||
|
|
3
core.h
3
core.h
|
@ -119,6 +119,8 @@ public:
|
|||
void quitGroupChat(int groupId) const;
|
||||
void dispatchVideoFrame(vpx_image img) const;
|
||||
|
||||
void saveConfiguration();
|
||||
|
||||
public slots:
|
||||
void start();
|
||||
void process();
|
||||
|
@ -261,7 +263,6 @@ private:
|
|||
void onBootstrapTimer();
|
||||
|
||||
void loadConfiguration();
|
||||
void saveConfiguration();
|
||||
void loadFriends();
|
||||
static void sendAllFileData(Core* core, ToxFile* file);
|
||||
|
||||
|
|
1
friend.h
1
friend.h
|
@ -22,6 +22,7 @@ public:
|
|||
ChatForm* chatForm;
|
||||
int hasNewMessages;
|
||||
Status friendStatus;
|
||||
QPixmap avatar;
|
||||
};
|
||||
|
||||
#endif // FRIEND_H
|
||||
|
|
316
widget.ui
316
widget.ui
|
@ -10,6 +10,12 @@
|
|||
<height>320</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>640</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1920</width>
|
||||
|
@ -23,10 +29,7 @@
|
|||
<iconset resource="res.qrc">
|
||||
<normaloff>:/img/icon.png</normaloff>:/img/icon.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
|
@ -39,8 +42,17 @@
|
|||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="titleBar" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
|
@ -220,20 +232,94 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="centralWidget" native="true">
|
||||
<property name="enabled">
|
||||
<item row="1" column="0">
|
||||
<widget class="QSplitter" name="centralWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Window">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Window">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Window">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="statusPanel" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>225</width>
|
||||
|
@ -242,7 +328,7 @@
|
|||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>225</width>
|
||||
<width>1920</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -700,9 +786,18 @@
|
|||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="statusHead" native="true">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<width>225</width>
|
||||
<height>60</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -1124,15 +1219,14 @@
|
|||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QLabel" name="profilePicture">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="profilePicture">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
|
@ -1155,18 +1249,14 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="EditableLabelWidget" name="nameLabel">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>10</y>
|
||||
<width>101</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
|
@ -1593,15 +1683,9 @@
|
|||
<string>Your name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="EditableLabelWidget" name="statusLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>30</y>
|
||||
<width>101</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
|
@ -1675,15 +1759,27 @@
|
|||
<string>Your status</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="ClickableLabel" name="statImg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>10</y>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1920</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ClickableLabel" name="statImg">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
|
@ -1696,11 +1792,14 @@
|
|||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>img/status/dot_away_2x.png</pixmap>
|
||||
<pixmap resource="res.qrc">:/img/status/dot_away_2x.png</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
|
@ -1709,14 +1808,26 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<zorder>profilePicture</zorder>
|
||||
<zorder>statImg</zorder>
|
||||
<zorder>nameLabel</zorder>
|
||||
<zorder>statusLabel</zorder>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="friendList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>225</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
|
@ -1734,18 +1845,27 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>225</width>
|
||||
<width>258</width>
|
||||
<height>199</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QWidget" name="tooliconsZone" native="true">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<width>225</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -2188,6 +2308,9 @@
|
|||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -2200,6 +2323,22 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="groupButton">
|
||||
<property name="minimumSize">
|
||||
|
@ -2208,6 +2347,9 @@
|
|||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -2220,6 +2362,22 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="transferButton">
|
||||
<property name="minimumSize">
|
||||
|
@ -2234,6 +2392,9 @@
|
|||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -2246,6 +2407,22 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="settingsButton">
|
||||
<property name="minimumSize">
|
||||
|
@ -2260,6 +2437,9 @@
|
|||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -2277,9 +2457,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QWidget" name="mainPanel" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>375</width>
|
||||
|
@ -2713,6 +2897,12 @@
|
|||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="mainHead" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
|
@ -2791,9 +2981,15 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="mainContent" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<width>375</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -2801,8 +2997,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -23,6 +23,7 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File)
|
|||
setAutoFillBackground(true);
|
||||
|
||||
setMinimumSize(250,58);
|
||||
setMaximumHeight(58);
|
||||
setLayout(mainLayout);
|
||||
mainLayout->setMargin(0);
|
||||
|
||||
|
|
|
@ -75,6 +75,8 @@ void AddFriendForm::onSendTriggered()
|
|||
showWarning(tr("Please fill in a valid Tox ID","Tox ID of the friend you're sending a friend request to"));
|
||||
} else if (isToxId(id)) {
|
||||
emit friendRequested(id, getMessage());
|
||||
this->toxId.setText("");
|
||||
this->message.setText("");
|
||||
} else {
|
||||
id = id.replace("@", "._tox.");
|
||||
dns.setName(id);
|
||||
|
|
|
@ -11,11 +11,12 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
{
|
||||
this->setMouseTracking(true);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setLayout(&layout);
|
||||
this->setFixedWidth(225);
|
||||
this->setFixedHeight(55);
|
||||
this->setLayout(&layout);
|
||||
layout.setSpacing(0);
|
||||
layout.setMargin(0);
|
||||
layout.setStretchFactor(this, 100);
|
||||
textLayout.setSpacing(0);
|
||||
textLayout.setMargin(0);
|
||||
|
||||
|
@ -53,6 +54,11 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
isActiveWidget = 0;
|
||||
}
|
||||
|
||||
void FriendWidget::setNewFixedWidth(int newWidth)
|
||||
{
|
||||
this->setFixedWidth(newWidth);
|
||||
}
|
||||
|
||||
void FriendWidget::mouseReleaseEvent (QMouseEvent*)
|
||||
{
|
||||
emit friendWidgetClicked(this);
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
void leaveEvent(QEvent* event);
|
||||
void setAsActiveChatroom();
|
||||
void setAsInactiveChatroom();
|
||||
void setNewFixedWidth(int newWidth);
|
||||
|
||||
signals:
|
||||
void friendWidgetClicked(FriendWidget* widget);
|
||||
|
|
|
@ -56,6 +56,11 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
|||
isActiveWidget = 0;
|
||||
}
|
||||
|
||||
void GroupWidget::setNewFixedWidth(int newWidth)
|
||||
{
|
||||
this->setFixedWidth(newWidth);
|
||||
}
|
||||
|
||||
void GroupWidget::mouseReleaseEvent (QMouseEvent*)
|
||||
{
|
||||
emit groupWidgetClicked(this);
|
||||
|
@ -163,5 +168,5 @@ void GroupWidget::setAsInactiveChatroom()
|
|||
QPalette pal3;
|
||||
pal3.setColor(QPalette::Background, QColor(65,65,65,255));
|
||||
this->setPalette(pal3);
|
||||
avatar.setPixmap(QPixmap("img/group.png"));
|
||||
avatar.setPixmap(QPixmap(":img/group.png"));
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
QVBoxLayout textLayout;
|
||||
void setAsInactiveChatroom();
|
||||
void setAsActiveChatroom();
|
||||
void setNewFixedWidth(int newWidth);
|
||||
|
||||
private:
|
||||
QColor lastColor;
|
||||
|
|
|
@ -38,7 +38,6 @@ Widget::Widget(QWidget *parent) :
|
|||
if (useNativeTheme)
|
||||
{
|
||||
ui->titleBar->hide();
|
||||
//setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
|
||||
this->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QString friendListStylesheet = "";
|
||||
|
@ -89,13 +88,6 @@ Widget::Widget(QWidget *parent) :
|
|||
setWindowFlags(Qt::CustomizeWindowHint);
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setMouseTracking(true);
|
||||
ui->titleBar->setMouseTracking(true);
|
||||
ui->LTitle->setMouseTracking(true);
|
||||
ui->tbMenu->setMouseTracking(true);
|
||||
ui->pbMin->setMouseTracking(true);
|
||||
ui->pbMax->setMouseTracking(true);
|
||||
ui->pbClose->setMouseTracking(true);
|
||||
|
||||
addAction(ui->actionClose);
|
||||
|
||||
|
@ -116,7 +108,7 @@ Widget::Widget(QWidget *parent) :
|
|||
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())
|
||||
setGeometry(geo);
|
||||
this->setGeometry(geo);
|
||||
|
||||
if (settings.value("maximized").toBool())
|
||||
{
|
||||
|
@ -134,7 +126,7 @@ Widget::Widget(QWidget *parent) :
|
|||
|
||||
isWindowMinimized = 0;
|
||||
|
||||
centralLayout = new QHBoxLayout(ui->centralWidget);
|
||||
//centralLayout = new QSplitter(ui->centralWidget);
|
||||
|
||||
|
||||
ui->mainContent->setLayout(new QVBoxLayout());
|
||||
|
@ -146,6 +138,7 @@ Widget::Widget(QWidget *parent) :
|
|||
friendListWidget->layout()->setSpacing(0);
|
||||
friendListWidget->layout()->setMargin(0);
|
||||
friendListWidget->setLayoutDirection(Qt::LeftToRight);
|
||||
//friendListWidget->
|
||||
ui->friendList->setWidget(friendListWidget);
|
||||
|
||||
ui->nameLabel->setText(Settings::getInstance().getUsername());
|
||||
|
@ -153,6 +146,25 @@ Widget::Widget(QWidget *parent) :
|
|||
ui->statusLabel->setText(Settings::getInstance().getStatusMessage());
|
||||
ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}");
|
||||
ui->friendList->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
ui->centralWidget->setStyleSheet("QSplitter{background-color: white;}");
|
||||
|
||||
this->setMouseTracking(true);
|
||||
|
||||
QList<QWidget*> widgets = this->findChildren<QWidget*>();
|
||||
foreach (QWidget *widget, widgets)
|
||||
widget->setMouseTracking(true);
|
||||
|
||||
ui->titleBar->setMouseTracking(true);
|
||||
ui->LTitle->setMouseTracking(true);
|
||||
ui->tbMenu->setMouseTracking(true);
|
||||
ui->pbMin->setMouseTracking(true);
|
||||
ui->pbMax->setMouseTracking(true);
|
||||
ui->pbClose->setMouseTracking(true);
|
||||
ui->statusHead->setMouseTracking(true);
|
||||
|
||||
QList<int> currentSizes = ui->centralWidget->sizes();
|
||||
currentSizes[0] = 225;
|
||||
ui->centralWidget->setSizes(currentSizes);
|
||||
|
||||
camera = new Camera;
|
||||
camview = new SelfCamView(camera);
|
||||
|
@ -194,6 +206,7 @@ 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()));
|
||||
|
@ -214,6 +227,7 @@ Widget::Widget(QWidget *parent) :
|
|||
|
||||
Widget::~Widget()
|
||||
{
|
||||
core->saveConfiguration();
|
||||
instance = nullptr;
|
||||
coreThread->exit();
|
||||
coreThread->wait();
|
||||
|
@ -233,7 +247,6 @@ Widget::~Widget()
|
|||
settings.setValue("maximized", isMaximized());
|
||||
settings.setValue("useNativeTheme", useNativeTheme);
|
||||
delete ui;
|
||||
delete centralLayout;
|
||||
}
|
||||
|
||||
Widget* Widget::getInstance()
|
||||
|
@ -243,6 +256,23 @@ 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();
|
||||
}
|
||||
|
||||
void Widget::updateFriendListWidth()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
QString Widget::getUsername()
|
||||
{
|
||||
|
@ -380,6 +410,7 @@ 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)));
|
||||
|
@ -400,6 +431,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
connect(core, &Core::avEnding, newfriend->chatForm, &ChatForm::onAvEnding);
|
||||
connect(core, &Core::avRequestTimeout, newfriend->chatForm, &ChatForm::onAvRequestTimeout);
|
||||
connect(core, &Core::avPeerTimeout, newfriend->chatForm, &ChatForm::onAvPeerTimeout);
|
||||
core->saveConfiguration();
|
||||
}
|
||||
|
||||
void Widget::addFriendFailed(const QString&)
|
||||
|
@ -541,6 +573,7 @@ void Widget::onFriendRequestReceived(const QString& userId, const QString& messa
|
|||
void Widget::removeFriend(int friendId)
|
||||
{
|
||||
Friend* f = FriendList::findFriend(friendId);
|
||||
f->widget->setAsInactiveChatroom();
|
||||
if (f->widget == activeFriendWidget)
|
||||
activeFriendWidget = nullptr;
|
||||
FriendList::removeFriend(friendId);
|
||||
|
@ -557,7 +590,6 @@ void Widget::copyFriendIdToClipboard(int friendId)
|
|||
{
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(f->userId, QClipboard::Clipboard);
|
||||
clipboard->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -643,6 +675,7 @@ void Widget::onGroupWidgetClicked(GroupWidget* widget)
|
|||
void Widget::removeGroup(int groupId)
|
||||
{
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
g->widget->setAsInactiveChatroom();
|
||||
if (g->widget == activeGroupWidget)
|
||||
activeGroupWidget = nullptr;
|
||||
GroupList::removeGroup(groupId);
|
||||
|
@ -671,6 +704,7 @@ Group *Widget::createGroup(int groupId)
|
|||
QWidget* widget = ui->friendList->widget();
|
||||
QLayout* layout = widget->layout();
|
||||
layout->addWidget(newgroup->widget);
|
||||
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)));
|
||||
|
@ -702,80 +736,15 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Widget::mouseMoveEvent(QMouseEvent *e)
|
||||
void Widget::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
if (!useNativeTheme)
|
||||
{
|
||||
int xMouse = e->pos().x();
|
||||
int yMouse = e->pos().y();
|
||||
int wWidth = this->geometry().width();
|
||||
int wHeight = this->geometry().height();
|
||||
|
||||
if (moveWidget)
|
||||
{
|
||||
inResizeZone = false;
|
||||
moveWindow(e);
|
||||
}
|
||||
else if (allowToResize)
|
||||
resizeWindow(e);
|
||||
//right
|
||||
else if (xMouse >= wWidth - PIXELS_TO_ACT or allowToResize)
|
||||
{
|
||||
inResizeZone = true;
|
||||
|
||||
if (yMouse >= wHeight - PIXELS_TO_ACT)
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
else if (yMouse <= PIXELS_TO_ACT)
|
||||
setCursor(Qt::SizeBDiagCursor);
|
||||
else
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
|
||||
resizeWindow(e);
|
||||
}
|
||||
//left
|
||||
else if (xMouse <= PIXELS_TO_ACT or allowToResize)
|
||||
{
|
||||
inResizeZone = true;
|
||||
|
||||
if (yMouse >= wHeight - PIXELS_TO_ACT)
|
||||
setCursor(Qt::SizeBDiagCursor);
|
||||
else if (yMouse <= PIXELS_TO_ACT)
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
else
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
|
||||
resizeWindow(e);
|
||||
}
|
||||
//bottom edge
|
||||
else if ((yMouse >= wHeight - PIXELS_TO_ACT) or allowToResize)
|
||||
{
|
||||
inResizeZone = true;
|
||||
setCursor(Qt::SizeVerCursor);
|
||||
|
||||
resizeWindow(e);
|
||||
}
|
||||
//Cursor part top
|
||||
else if (yMouse <= PIXELS_TO_ACT or allowToResize)
|
||||
{
|
||||
inResizeZone = true;
|
||||
setCursor(Qt::SizeVerCursor);
|
||||
|
||||
resizeWindow(e);
|
||||
}
|
||||
else
|
||||
{
|
||||
inResizeZone = false;
|
||||
setCursor(Qt::ArrowCursor);
|
||||
updateFriendListWidth();
|
||||
}
|
||||
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
bool Widget::event(QEvent * e)
|
||||
{
|
||||
|
||||
if( e->type() == QEvent::WindowStateChange )
|
||||
{
|
||||
if(windowState().testFlag(Qt::WindowMinimized) == true)
|
||||
|
@ -802,7 +771,7 @@ bool Widget::event(QEvent * e)
|
|||
Group* g = GroupList::findGroup(activeGroupWidget->groupId);
|
||||
g->hasNewMessages = 0;
|
||||
g->userWasMentioned = 0;
|
||||
g->widget->statusPic.setPixmap(QPixmap("img/status/dot_groupchat.png"));
|
||||
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
|
||||
}
|
||||
}
|
||||
else if (e->type() == QEvent::WindowDeactivate && !useNativeTheme)
|
||||
|
@ -810,6 +779,73 @@ bool Widget::event(QEvent * e)
|
|||
this->setObjectName("inactiveWindow");
|
||||
this->style()->polish(this);
|
||||
}
|
||||
else if (e->type() == QEvent::MouseMove && !useNativeTheme)
|
||||
{
|
||||
QMouseEvent *k = (QMouseEvent *)e;
|
||||
int xMouse = k->pos().x();
|
||||
int yMouse = k->pos().y();
|
||||
int wWidth = this->geometry().width();
|
||||
int wHeight = this->geometry().height();
|
||||
|
||||
if (moveWidget)
|
||||
{
|
||||
inResizeZone = false;
|
||||
moveWindow(k);
|
||||
}
|
||||
else if (allowToResize)
|
||||
resizeWindow(k);
|
||||
//right
|
||||
else if (xMouse >= wWidth - PIXELS_TO_ACT or allowToResize)
|
||||
{
|
||||
inResizeZone = true;
|
||||
|
||||
if (yMouse >= wHeight - PIXELS_TO_ACT)
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
else if (yMouse <= PIXELS_TO_ACT)
|
||||
setCursor(Qt::SizeBDiagCursor);
|
||||
else
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
|
||||
resizeWindow(k);
|
||||
}
|
||||
//left
|
||||
else if (xMouse <= PIXELS_TO_ACT or allowToResize)
|
||||
{
|
||||
inResizeZone = true;
|
||||
|
||||
if (yMouse >= wHeight - PIXELS_TO_ACT)
|
||||
setCursor(Qt::SizeBDiagCursor);
|
||||
else if (yMouse <= PIXELS_TO_ACT)
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
else
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
|
||||
resizeWindow(k);
|
||||
}
|
||||
//bottom edge
|
||||
else if ((yMouse >= wHeight - PIXELS_TO_ACT) or allowToResize)
|
||||
{
|
||||
inResizeZone = true;
|
||||
setCursor(Qt::SizeVerCursor);
|
||||
|
||||
resizeWindow(k);
|
||||
}
|
||||
//Cursor part top
|
||||
else if (yMouse <= PIXELS_TO_ACT or allowToResize)
|
||||
{
|
||||
inResizeZone = true;
|
||||
setCursor(Qt::SizeVerCursor);
|
||||
|
||||
resizeWindow(k);
|
||||
}
|
||||
else
|
||||
{
|
||||
inResizeZone = false;
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
e->accept();
|
||||
}
|
||||
|
||||
return QWidget::event(e);
|
||||
}
|
||||
|
@ -901,6 +937,7 @@ void Widget::moveWindow(QMouseEvent *e)
|
|||
|
||||
void Widget::resizeWindow(QMouseEvent *e)
|
||||
{
|
||||
updateFriendListWidth();
|
||||
if (!useNativeTheme)
|
||||
{
|
||||
if (allowToResize)
|
||||
|
@ -1019,7 +1056,7 @@ void Widget::setCentralWidget(QWidget *widget, const QString &widgetName)
|
|||
connect(widget, SIGNAL(cancelled()), this, SLOT(close()));
|
||||
|
||||
centralLayout->addWidget(widget);
|
||||
ui->centralWidget->setLayout(centralLayout);
|
||||
//ui->centralWidget->setLayout(centralLayout);
|
||||
ui->LTitle->setText(widgetName);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
void updateFriendStatusLights(int friendId);
|
||||
int useNativeTheme;
|
||||
~Widget();
|
||||
void updateFriendListWidth();
|
||||
|
||||
signals:
|
||||
void friendRequestAccepted(const QString& userId);
|
||||
|
@ -53,6 +54,9 @@ signals:
|
|||
void usernameChanged(const QString& username);
|
||||
void statusMessageChanged(const QString& statusMessage);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void maximizeBtnClicked();
|
||||
void minimizeBtnClicked();
|
||||
|
@ -89,6 +93,7 @@ private slots:
|
|||
void copyFriendIdToClipboard(int friendId);
|
||||
void removeGroup(int groupId);
|
||||
void onStatusImgClicked();
|
||||
void splitterMoved(int pos, int index);
|
||||
|
||||
protected slots:
|
||||
void moveWindow(QMouseEvent *e);
|
||||
|
@ -99,7 +104,7 @@ private:
|
|||
|
||||
private:
|
||||
Ui::Widget *ui;
|
||||
QHBoxLayout *centralLayout;
|
||||
QSplitter *centralLayout;
|
||||
QPoint dragPosition;
|
||||
TitleMode m_titleMode;
|
||||
bool moveWidget;
|
||||
|
@ -109,7 +114,6 @@ private:
|
|||
bool resizeHorEsq;
|
||||
bool resizeDiagSupEsq;
|
||||
bool resizeDiagSupDer;
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
|
@ -127,6 +131,7 @@ private:
|
|||
int isFriendWidgetActive, isGroupWidgetActive;
|
||||
SelfCamView* camview;
|
||||
Camera* camera;
|
||||
bool notify(QObject *receiver, QEvent *event);
|
||||
};
|
||||
|
||||
#endif // WIDGET_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user