removed broken custom window decoration
189
mainwindow.ui
|
@ -37,193 +37,6 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<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>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tbMenu">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>15</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="LTitle">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>134</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbMin">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbMax">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbClose">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="mainSplitter">
|
||||
<property name="sizePolicy">
|
||||
|
@ -1221,7 +1034,7 @@ QSplitter:handle{
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>288</width>
|
||||
<height>371</height>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
||||
|
|
|
@ -130,7 +130,6 @@ void Settings::load()
|
|||
timestampFormat = s.value("timestampFormat", "hh:mm").toString();
|
||||
minimizeOnClose = s.value("minimizeOnClose", false).toBool();
|
||||
useNativeStyle = s.value("nativeStyle", false).toBool();
|
||||
useNativeDecoration = s.value("nativeDecoration", true).toBool();
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("State");
|
||||
|
@ -230,7 +229,6 @@ void Settings::save(QString path)
|
|||
s.setValue("timestampFormat", timestampFormat);
|
||||
s.setValue("minimizeOnClose", minimizeOnClose);
|
||||
s.setValue("nativeStyle", useNativeStyle);
|
||||
s.setValue("nativeDecoration", useNativeDecoration);
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("State");
|
||||
|
@ -478,16 +476,6 @@ void Settings::setUseNativeStyle(bool value)
|
|||
useNativeStyle = value;
|
||||
}
|
||||
|
||||
bool Settings::getUseNativeDecoration() const
|
||||
{
|
||||
return useNativeDecoration;
|
||||
}
|
||||
|
||||
void Settings::setUseNativeDecoration(bool value)
|
||||
{
|
||||
useNativeDecoration = value;
|
||||
}
|
||||
|
||||
QByteArray Settings::getWindowGeometry() const
|
||||
{
|
||||
return windowGeometry;
|
||||
|
|
|
@ -121,9 +121,6 @@ public:
|
|||
bool getUseNativeStyle() const;
|
||||
void setUseNativeStyle(bool value);
|
||||
|
||||
bool getUseNativeDecoration() const;
|
||||
void setUseNativeDecoration(bool value);
|
||||
|
||||
QByteArray getWindowGeometry() const;
|
||||
void setWindowGeometry(const QByteArray &value);
|
||||
|
||||
|
@ -170,7 +167,6 @@ private:
|
|||
int emojiFontPointSize;
|
||||
bool minimizeOnClose;
|
||||
bool useNativeStyle;
|
||||
bool useNativeDecoration;
|
||||
QByteArray windowGeometry;
|
||||
QByteArray windowState;
|
||||
QByteArray splitterState;
|
||||
|
|
12
res.qrc
|
@ -84,18 +84,6 @@
|
|||
<file>ui/videoButton/videoButtonYellowPressed.png</file>
|
||||
<file>img/group_dark.png</file>
|
||||
<file>ui/window/applicationIcon.png</file>
|
||||
<file>ui/window/closeButton.png</file>
|
||||
<file>ui/window/closeButtonHover.png</file>
|
||||
<file>ui/window/closeButtonPressed.png</file>
|
||||
<file>ui/window/maximizeButton.png</file>
|
||||
<file>ui/window/maximizeButtonHover.png</file>
|
||||
<file>ui/window/maximizeButtonPressed.png</file>
|
||||
<file>ui/window/minimizeButton.png</file>
|
||||
<file>ui/window/minimizeButtonHover.png</file>
|
||||
<file>ui/window/minimizeButtonPressed.png</file>
|
||||
<file>ui/window/restoreButton.png</file>
|
||||
<file>ui/window/restoreButtonHover.png</file>
|
||||
<file>ui/window/restoreButtonPressed.png</file>
|
||||
<file>ui/friendList/friendList.css</file>
|
||||
<file>ui/window/window.css</file>
|
||||
<file>img/status/dot_busy.png</file>
|
||||
|
|
Before Width: | Height: | Size: 385 B |
Before Width: | Height: | Size: 370 B |
Before Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 401 B |
Before Width: | Height: | Size: 401 B |
Before Width: | Height: | Size: 402 B |
Before Width: | Height: | Size: 371 B |
Before Width: | Height: | Size: 371 B |
Before Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 401 B |
Before Width: | Height: | Size: 401 B |
Before Width: | Height: | Size: 402 B |
|
@ -163,7 +163,7 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
|||
connect(Core::getInstance(), SIGNAL(fileTransferBrokenUnbroken(ToxFile, bool)), fileTrans, SLOT(onFileTransferBrokenUnbroken(ToxFile, bool)));
|
||||
|
||||
Widget* w = Widget::getInstance();
|
||||
if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow())
|
||||
if (!w->isFriendWidgetCurActiveWidget(f)|| w->isMinimized() || !w->isActiveWindow())
|
||||
{
|
||||
w->newMessageAlert();
|
||||
f->hasNewEvents=true;
|
||||
|
@ -204,7 +204,7 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
|
|||
}
|
||||
|
||||
Widget* w = Widget::getInstance();
|
||||
if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow())
|
||||
if (!w->isFriendWidgetCurActiveWidget(f)|| w->isMinimized() || !w->isActiveWindow())
|
||||
{
|
||||
w->newMessageAlert();
|
||||
f->hasNewEvents=true;
|
||||
|
|
|
@ -77,28 +77,17 @@ void GroupWidget::updateStatusLight()
|
|||
{
|
||||
Group *g = GroupList::findGroup(groupId);
|
||||
|
||||
if (Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
if (g->hasNewMessages == 0)
|
||||
{
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
||||
} else {
|
||||
if (g->userWasMentioned == 0)
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
||||
else
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
||||
}
|
||||
} else {
|
||||
if (g->hasNewMessages == 0)
|
||||
{
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g->userWasMentioned == 0)
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_groupchat_newmessages.png"));
|
||||
else
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_groupchat_notification.png"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GroupWidget::setChatForm(Ui::MainWindow &ui)
|
||||
|
|
|
@ -62,55 +62,8 @@ Widget::Widget(QWidget *parent)
|
|||
restoreState(Settings::getInstance().getWindowState());
|
||||
ui->mainSplitter->restoreState(Settings::getInstance().getSplitterState());
|
||||
|
||||
if (Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
ui->titleBar->hide();
|
||||
this->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ui->friendList->setObjectName("friendList");
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
ui->friendList->setStyleSheet(Style::getStylesheet(":ui/friendList/friendList.css"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setObjectName("activeWindow");
|
||||
this->setStyleSheet(Style::getStylesheet(":ui/window/window.css"));
|
||||
ui->statusPanel->setStyleSheet(QString(""));
|
||||
ui->friendList->setStyleSheet(QString(""));
|
||||
|
||||
ui->friendList->setObjectName("friendList");
|
||||
ui->friendList->setStyleSheet(Style::getStylesheet(":ui/friendList/friendList.css"));
|
||||
|
||||
ui->tbMenu->setIcon(QIcon(":ui/window/applicationIcon.png"));
|
||||
ui->pbMin->setObjectName("minimizeButton");
|
||||
ui->pbMax->setObjectName("maximizeButton");
|
||||
ui->pbClose->setObjectName("closeButton");
|
||||
|
||||
setWindowFlags(Qt::CustomizeWindowHint);
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
|
||||
addAction(ui->actionClose);
|
||||
|
||||
connect(ui->pbMin, SIGNAL(clicked()), this, SLOT(minimizeBtnClicked()));
|
||||
connect(ui->pbMax, SIGNAL(clicked()), this, SLOT(maximizeBtnClicked()));
|
||||
connect(ui->pbClose, SIGNAL(clicked()), this, SLOT(close()));
|
||||
|
||||
m_titleMode = FullTitle;
|
||||
moveWidget = false;
|
||||
inResizeZone = false;
|
||||
allowToResize = false;
|
||||
resizeVerSup = false;
|
||||
resizeHorEsq = false;
|
||||
resizeDiagSupEsq = false;
|
||||
resizeDiagSupDer = false;
|
||||
|
||||
if (isMaximized())
|
||||
{
|
||||
showMaximized();
|
||||
ui->pbMax->setObjectName("restoreButton");
|
||||
}
|
||||
}
|
||||
|
||||
isWindowMinimized = 0;
|
||||
|
||||
profilePicture = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||
profilePicture->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||
|
@ -225,8 +178,6 @@ Widget::~Widget()
|
|||
coreThread->terminate();
|
||||
delete core;
|
||||
|
||||
hideMainForms();
|
||||
|
||||
for (Friend* f : FriendList::friendList)
|
||||
delete f;
|
||||
FriendList::friendList.clear();
|
||||
|
@ -485,8 +436,8 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
|
|||
f->widget->updateStatusLight();
|
||||
|
||||
// Workaround widget style after returning to list
|
||||
if (f->widget->isActive())
|
||||
f->widget->setAsActiveChatroom();
|
||||
// if (f->widget->isActive())
|
||||
// f->widget->setAsActiveChatroom();
|
||||
}
|
||||
|
||||
void Widget::onFriendStatusMessageChanged(int friendId, const QString& message)
|
||||
|
@ -535,7 +486,7 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool
|
|||
|
||||
if (activeChatroomWidget != nullptr)
|
||||
{
|
||||
if ((static_cast<GenericChatroomWidget*>(f->widget) != activeChatroomWidget) || isWindowMinimized || !isActiveWindow())
|
||||
if ((static_cast<GenericChatroomWidget*>(f->widget) != activeChatroomWidget) || isMinimized() || !isActiveWindow())
|
||||
{
|
||||
f->hasNewEvents = 1;
|
||||
newMessageAlert();
|
||||
|
@ -619,7 +570,7 @@ void Widget::onGroupMessageReceived(int groupnumber, int friendgroupnumber, cons
|
|||
|
||||
g->chatForm->addGroupMessage(message, friendgroupnumber);
|
||||
|
||||
if ((static_cast<GenericChatroomWidget*>(g->widget) != activeChatroomWidget) || isWindowMinimized || !isActiveWindow())
|
||||
if ((static_cast<GenericChatroomWidget*>(g->widget) != activeChatroomWidget) || isMinimized() || !isActiveWindow())
|
||||
{
|
||||
g->hasNewMessages = 1;
|
||||
if (message.contains(core->getUsername(), Qt::CaseInsensitive))
|
||||
|
@ -712,368 +663,18 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
|
|||
|
||||
bool Widget::event(QEvent * e)
|
||||
{
|
||||
|
||||
if( e->type() == QEvent::WindowStateChange )
|
||||
if (e->type() == QEvent::WindowActivate)
|
||||
{
|
||||
if(windowState().testFlag(Qt::WindowMinimized) == true)
|
||||
{
|
||||
isWindowMinimized = 1;
|
||||
}
|
||||
}
|
||||
else if (e->type() == QEvent::WindowActivate)
|
||||
{
|
||||
if (!Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
this->setObjectName("activeWindow");
|
||||
this->style()->polish(this);
|
||||
}
|
||||
isWindowMinimized = 0;
|
||||
if (activeChatroomWidget != nullptr)
|
||||
{
|
||||
activeChatroomWidget->resetEventFlags();
|
||||
activeChatroomWidget->updateStatusLight();
|
||||
}
|
||||
}
|
||||
else if (e->type() == QEvent::WindowDeactivate && !Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
this->setObjectName("inactiveWindow");
|
||||
this->style()->polish(this);
|
||||
}
|
||||
else if (e->type() == QEvent::MouseMove && !Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
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);
|
||||
else if (xMouse >= wWidth - PIXELS_TO_ACT or allowToResize)
|
||||
{
|
||||
inResizeZone = true;
|
||||
|
||||
if (yMouse >= wHeight - PIXELS_TO_ACT)
|
||||
{
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
resizeWindow(k);
|
||||
}
|
||||
else if (yMouse <= PIXELS_TO_ACT)
|
||||
{
|
||||
setCursor(Qt::SizeBDiagCursor);
|
||||
resizeWindow(k);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
inResizeZone = false;
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
e->accept();
|
||||
}
|
||||
|
||||
return QWidget::event(e);
|
||||
}
|
||||
|
||||
void Widget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (!Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
if (e->button() == Qt::LeftButton)
|
||||
{
|
||||
if (inResizeZone)
|
||||
{
|
||||
allowToResize = true;
|
||||
|
||||
if (e->pos().y() <= PIXELS_TO_ACT)
|
||||
{
|
||||
if (e->pos().x() <= PIXELS_TO_ACT)
|
||||
resizeDiagSupEsq = true;
|
||||
else if (e->pos().x() >= geometry().width() - PIXELS_TO_ACT)
|
||||
resizeDiagSupDer = true;
|
||||
else
|
||||
resizeVerSup = true;
|
||||
}
|
||||
else if (e->pos().x() <= PIXELS_TO_ACT)
|
||||
resizeHorEsq = true;
|
||||
}
|
||||
else if (e->pos().x() >= PIXELS_TO_ACT and e->pos().x() < ui->titleBar->geometry().width()
|
||||
and e->pos().y() >= PIXELS_TO_ACT and e->pos().y() < ui->titleBar->geometry().height())
|
||||
{
|
||||
moveWidget = true;
|
||||
dragPosition = e->globalPos() - frameGeometry().topLeft();
|
||||
}
|
||||
}
|
||||
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
if (!Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
moveWidget = false;
|
||||
allowToResize = false;
|
||||
resizeVerSup = false;
|
||||
resizeHorEsq = false;
|
||||
resizeDiagSupEsq = false;
|
||||
resizeDiagSupDer = false;
|
||||
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
{
|
||||
if (!Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
if (e->pos().x() < ui->tbMenu->geometry().right() and e->pos().y() < ui->tbMenu->geometry().bottom()
|
||||
and e->pos().x() >= ui->tbMenu->geometry().x() and e->pos().y() >= ui->tbMenu->geometry().y()
|
||||
and ui->tbMenu->isVisible())
|
||||
close();
|
||||
else if (e->pos().x() < ui->titleBar->geometry().width()
|
||||
and e->pos().y() < ui->titleBar->geometry().height()
|
||||
and m_titleMode != FullScreenMode)
|
||||
maximizeBtnClicked();
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::paintEvent (QPaintEvent *)
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init (this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive (QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
|
||||
void Widget::moveWindow(QMouseEvent *e)
|
||||
{
|
||||
if (!Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
if (e->buttons() & Qt::LeftButton)
|
||||
{
|
||||
move(e->globalPos() - dragPosition);
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::resizeWindow(QMouseEvent *e)
|
||||
{
|
||||
if (!Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
if (allowToResize)
|
||||
{
|
||||
int xMouse = e->pos().x();
|
||||
int yMouse = e->pos().y();
|
||||
int wWidth = geometry().width();
|
||||
int wHeight = geometry().height();
|
||||
|
||||
if (cursor().shape() == Qt::SizeVerCursor)
|
||||
{
|
||||
if (resizeVerSup)
|
||||
{
|
||||
int newY = geometry().y() + yMouse;
|
||||
int newHeight = wHeight - yMouse;
|
||||
|
||||
if (newHeight > minimumSizeHint().height())
|
||||
{
|
||||
resize(wWidth, newHeight);
|
||||
move(geometry().x(), newY);
|
||||
}
|
||||
}
|
||||
else
|
||||
resize(wWidth, yMouse+1);
|
||||
}
|
||||
else if (cursor().shape() == Qt::SizeHorCursor)
|
||||
{
|
||||
if (resizeHorEsq)
|
||||
{
|
||||
int newX = geometry().x() + xMouse;
|
||||
int newWidth = wWidth - xMouse;
|
||||
|
||||
if (newWidth > minimumSizeHint().width())
|
||||
{
|
||||
resize(newWidth, wHeight);
|
||||
move(newX, geometry().y());
|
||||
}
|
||||
}
|
||||
else
|
||||
resize(xMouse, wHeight);
|
||||
}
|
||||
else if (cursor().shape() == Qt::SizeBDiagCursor)
|
||||
{
|
||||
int newX = 0;
|
||||
int newWidth = 0;
|
||||
int newY = 0;
|
||||
int newHeight = 0;
|
||||
|
||||
if (resizeDiagSupDer)
|
||||
{
|
||||
newX = geometry().x();
|
||||
newWidth = xMouse;
|
||||
newY = geometry().y() + yMouse;
|
||||
newHeight = wHeight - yMouse;
|
||||
}
|
||||
else
|
||||
{
|
||||
newX = geometry().x() + xMouse;
|
||||
newWidth = wWidth - xMouse;
|
||||
newY = geometry().y();
|
||||
newHeight = yMouse;
|
||||
}
|
||||
|
||||
if (newWidth >= minimumSizeHint().width() and newHeight >= minimumSizeHint().height())
|
||||
{
|
||||
resize(newWidth, newHeight);
|
||||
move(newX, newY);
|
||||
}
|
||||
else if (newWidth >= minimumSizeHint().width())
|
||||
{
|
||||
resize(newWidth, wHeight);
|
||||
move(newX, geometry().y());
|
||||
}
|
||||
else if (newHeight >= minimumSizeHint().height())
|
||||
{
|
||||
resize(wWidth, newHeight);
|
||||
move(geometry().x(), newY);
|
||||
}
|
||||
}
|
||||
else if (cursor().shape() == Qt::SizeFDiagCursor)
|
||||
{
|
||||
if (resizeDiagSupEsq)
|
||||
{
|
||||
int newX = geometry().x() + xMouse;
|
||||
int newWidth = wWidth - xMouse;
|
||||
int newY = geometry().y() + yMouse;
|
||||
int newHeight = wHeight - yMouse;
|
||||
|
||||
if (newWidth >= minimumSizeHint().width() and newHeight >= minimumSizeHint().height())
|
||||
{
|
||||
resize(newWidth, newHeight);
|
||||
move(newX, newY);
|
||||
}
|
||||
else if (newWidth >= minimumSizeHint().width())
|
||||
{
|
||||
resize(newWidth, wHeight);
|
||||
move(newX, geometry().y());
|
||||
}
|
||||
else if (newHeight >= minimumSizeHint().height())
|
||||
{
|
||||
resize(wWidth, newHeight);
|
||||
move(geometry().x(), newY);
|
||||
}
|
||||
}
|
||||
else
|
||||
resize(xMouse+1, yMouse+1);
|
||||
}
|
||||
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setCentralWidget(QWidget *widget, const QString &widgetName)
|
||||
{
|
||||
connect(widget, SIGNAL(cancelled()), this, SLOT(close()));
|
||||
|
||||
centralLayout->addWidget(widget);
|
||||
//ui->centralWidget->setLayout(centralLayout);
|
||||
ui->LTitle->setText(widgetName);
|
||||
}
|
||||
|
||||
void Widget::setTitlebarMode(const TitleMode &flag)
|
||||
{
|
||||
m_titleMode = flag;
|
||||
|
||||
switch (m_titleMode)
|
||||
{
|
||||
case CleanTitle:
|
||||
ui->tbMenu->setHidden(true);
|
||||
ui->pbMin->setHidden(true);
|
||||
ui->pbMax->setHidden(true);
|
||||
ui->pbClose->setHidden(true);
|
||||
break;
|
||||
case OnlyCloseButton:
|
||||
ui->tbMenu->setHidden(true);
|
||||
ui->pbMin->setHidden(true);
|
||||
ui->pbMax->setHidden(true);
|
||||
break;
|
||||
case MenuOff:
|
||||
ui->tbMenu->setHidden(true);
|
||||
break;
|
||||
case MaxMinOff:
|
||||
ui->pbMin->setHidden(true);
|
||||
ui->pbMax->setHidden(true);
|
||||
break;
|
||||
case FullScreenMode:
|
||||
ui->pbMax->setHidden(true);
|
||||
showMaximized();
|
||||
break;
|
||||
case MaximizeModeOff:
|
||||
ui->pbMax->setHidden(true);
|
||||
break;
|
||||
case MinimizeModeOff:
|
||||
ui->pbMin->setHidden(true);
|
||||
break;
|
||||
case FullTitle:
|
||||
ui->tbMenu->setVisible(true);
|
||||
ui->pbMin->setVisible(true);
|
||||
ui->pbMax->setVisible(true);
|
||||
ui->pbClose->setVisible(true);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
ui->tbMenu->setVisible(true);
|
||||
ui->pbMin->setVisible(true);
|
||||
ui->pbMax->setVisible(true);
|
||||
ui->pbClose->setVisible(true);
|
||||
break;
|
||||
}
|
||||
ui->LTitle->setVisible(true);
|
||||
}
|
||||
|
||||
void Widget::setTitlebarMenu(QMenu *menu, const QString &icon)
|
||||
{
|
||||
ui->tbMenu->setMenu(menu);
|
||||
ui->tbMenu->setIcon(QIcon(icon));
|
||||
}
|
||||
|
||||
void Widget::maximizeBtnClicked()
|
||||
{
|
||||
if (isFullScreen() or isMaximized())
|
||||
{
|
||||
ui->pbMax->setIcon(QIcon(":/ui/images/app_max.png"));
|
||||
setWindowState(windowState() & ~Qt::WindowFullScreen & ~Qt::WindowMaximized);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->pbMax->setIcon(QIcon(":/ui/images/app_rest.png"));
|
||||
setWindowState(windowState() | Qt::WindowFullScreen | Qt::WindowMaximized);
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::minimizeBtnClicked()
|
||||
{
|
||||
if (isMinimized())
|
||||
{
|
||||
setWindowState(windowState() & ~Qt::WindowMinimized);
|
||||
}
|
||||
else
|
||||
{
|
||||
setWindowState(windowState() | Qt::WindowMinimized);
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setStatusOnline()
|
||||
{
|
||||
core->setStatus(Status::Online);
|
||||
|
@ -1089,21 +690,6 @@ void Widget::setStatusBusy()
|
|||
core->setStatus(Status::Busy);
|
||||
}
|
||||
|
||||
bool Widget::eventFilter(QObject *, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::Wheel)
|
||||
{
|
||||
QWheelEvent * whlEvnt = static_cast< QWheelEvent * >( event );
|
||||
whlEvnt->angleDelta().setX(0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Widget::getIsWindowMinimized()
|
||||
{
|
||||
return static_cast<bool>(isWindowMinimized);
|
||||
}
|
||||
|
||||
void Widget::onMessageSendResult(int friendId, const QString& message, int messageId)
|
||||
{
|
||||
Q_UNUSED(message)
|
||||
|
|
|
@ -46,9 +46,6 @@ class Widget : public QMainWindow
|
|||
|
||||
public:
|
||||
explicit Widget(QWidget *parent = 0);
|
||||
enum TitleMode { CleanTitle = 0, OnlyCloseButton, MenuOff, MaxMinOff, FullScreenMode, MaximizeModeOff, MinimizeModeOff, FullTitle };
|
||||
void setTitlebarMode(const TitleMode &flag);
|
||||
void setTitlebarMenu(QMenu *menu, const QString &icon = "");
|
||||
void setCentralWidget(QWidget *widget, const QString &widgetName);
|
||||
QString getUsername();
|
||||
Core* getCore();
|
||||
|
@ -71,8 +68,6 @@ signals:
|
|||
void statusMessageChanged(const QString& statusMessage);
|
||||
|
||||
private slots:
|
||||
void maximizeBtnClicked();
|
||||
void minimizeBtnClicked();
|
||||
void onConnected();
|
||||
void onDisconnected();
|
||||
void onStatusSet(Status status);
|
||||
|
@ -108,32 +103,15 @@ private slots:
|
|||
void onMessageSendResult(int friendId, const QString& message, int messageId);
|
||||
void onGroupSendResult(int groupId, const QString& message, int result);
|
||||
|
||||
protected slots:
|
||||
void moveWindow(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
void hideMainForms();
|
||||
virtual bool event(QEvent * e);
|
||||
Group* createGroup(int groupId);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QSplitter *centralLayout;
|
||||
QPoint dragPosition;
|
||||
TitleMode m_titleMode;
|
||||
bool moveWidget;
|
||||
bool inResizeZone;
|
||||
bool allowToResize;
|
||||
bool resizeVerSup;
|
||||
bool resizeHorEsq;
|
||||
bool resizeDiagSupEsq;
|
||||
bool resizeDiagSupDer;
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
void paintEvent (QPaintEvent *);
|
||||
void resizeWindow(QMouseEvent *e);
|
||||
bool event(QEvent *event);
|
||||
int isWindowMinimized;
|
||||
Core* core;
|
||||
QThread* coreThread;
|
||||
AddFriendForm friendForm;
|
||||
|
@ -145,7 +123,6 @@ private:
|
|||
Camera* camera;
|
||||
MaskablePixmapWidget* profilePicture;
|
||||
bool notify(QObject *receiver, QEvent *event);
|
||||
bool eventFilter(QObject *, QEvent *event);
|
||||
};
|
||||
|
||||
#endif // WIDGET_H
|
||||
|
|