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

put back the not so native window decoration, status panel respects

friendlist width, some tweaks to the layout
This commit is contained in:
krepa098 2014-08-11 13:56:52 +02:00
parent 921b8478f6
commit c9d04748dd
6 changed files with 104 additions and 157 deletions

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>882</width>
<height>600</height>
<width>716</width>
<height>543</height>
</rect>
</property>
<property name="minimumSize">
@ -232,6 +232,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
@ -536,6 +542,9 @@ QSplitter:handle{
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>6</number>
</property>
<property name="childrenCollapsible">
<bool>false</bool>
</property>
@ -546,18 +555,6 @@ QSplitter:handle{
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>225</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1920</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
@ -1030,12 +1027,6 @@ QSplitter:handle{
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>225</width>
<height>60</height>
</size>
</property>
<property name="palette">
<palette>
<active>
@ -2076,17 +2067,11 @@ QSplitter:handle{
<item>
<widget class="AdjustingScrollArea" name="friendList">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" 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::LeftToRight</enum>
</property>
@ -2107,10 +2092,11 @@ QSplitter:handle{
<rect>
<x>0</x>
<y>0</y>
<width>501</width>
<height>430</height>
<width>335</width>
<height>379</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5"/>
</widget>
</widget>
</item>
@ -2120,17 +2106,11 @@ QSplitter:handle{
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>225</width>
<height>35</height>
</size>
</property>
<property name="palette">
<palette>
<active>
@ -2597,22 +2577,6 @@ QSplitter:handle{
</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">
@ -2639,22 +2603,6 @@ QSplitter:handle{
</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">
@ -2687,22 +2635,6 @@ QSplitter:handle{
</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">
@ -2742,17 +2674,11 @@ QSplitter:handle{
</widget>
<widget class="QWidget" name="mainPanel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>375</width>
<height>0</height>
</size>
</property>
<property name="palette">
<palette>
<active>
@ -3301,7 +3227,7 @@ QSplitter:handle{
<rect>
<x>0</x>
<y>0</y>
<width>882</width>
<width>716</width>
<height>24</height>
</rect>
</property>

View File

@ -18,18 +18,24 @@
#include <QEvent>
#include <QLayout>
#include <QDebug>
AdjustingScrollArea::AdjustingScrollArea(QWidget *parent) :
QScrollArea(parent)
{
}
void AdjustingScrollArea::resizeEvent(QResizeEvent *ev)
{
if (widget())
{
widget()->setMinimumWidth(width());
}
updateGeometry();
QScrollArea::resizeEvent(ev);
}
QSize AdjustingScrollArea::sizeHint() const
{
if (widget())
return widget()->sizeHint();
return QScrollArea::sizeHint();
}

View File

@ -26,6 +26,7 @@ public:
explicit AdjustingScrollArea(QWidget *parent = 0);
virtual void resizeEvent(QResizeEvent *ev);
virtual QSize sizeHint() const override;
signals:
public slots:

View File

@ -25,6 +25,7 @@
FriendWidget::FriendWidget(int FriendId, QString id)
: friendId(FriendId)
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
this->setMouseTracking(true);
this->setAutoFillBackground(true);
this->setFixedHeight(55);
@ -52,6 +53,9 @@ FriendWidget::FriendWidget(int FriendId, QString id)
pal3.setColor(QPalette::Background, QColor(65,65,65,255));
this->setPalette(pal3);
name.setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
statusMessage.setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
textLayout.addStretch();
textLayout.addWidget(&name);
textLayout.addWidget(&statusMessage);
@ -67,6 +71,13 @@ FriendWidget::FriendWidget(int FriendId, QString id)
layout.addSpacing(5);
isActiveWidget = 0;
layout.invalidate();
layout.update();
layout.activate();
updateGeometry();
qDebug() << "friend" << minimumSizeHint();
}
void FriendWidget::mouseReleaseEvent (QMouseEvent*)

View File

@ -56,44 +56,54 @@ Widget::Widget(QWidget *parent)
restoreGeometry(Settings::getInstance().getWindowGeometry());
restoreState(Settings::getInstance().getWindowState());
ui->titleBar->hide();
layout()->setContentsMargins(0, 0, 0, 0);
ui->friendList->setObjectName("friendList");
ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css"));
setStyleSheet(Style::get(":ui/window/window.css"));
//ui->statusPanel->setStyleSheet(QString(""));
//ui->friendList->setStyleSheet(QString(""));
ui->friendList->setObjectName("friendList");
ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css"));
ui->tbMenu->setIcon(QIcon(":ui/window/applicationIcon.png"));
ui->pbMin->setObjectName("minimizeButton");
ui->pbMax->setObjectName("maximizeButton");
ui->pbClose->setObjectName("closeButton");
if (!Settings::getInstance().getUseNativeDecoration())
if (Settings::getInstance().getUseNativeDecoration())
{
ui->titleBar->hide();
this->layout()->setContentsMargins(0, 0, 0, 0);
ui->friendList->setObjectName("friendList");
ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css"));
}
else
{
this->setObjectName("activeWindow");
this->setStyleSheet(Style::get(":ui/window/window.css"));
ui->statusPanel->setStyleSheet(QString(""));
ui->friendList->setStyleSheet(QString(""));
ui->friendList->setObjectName("friendList");
ui->friendList->setStyleSheet(Style::get(":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");
}
}
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;
isWindowMinimized = 0;
ui->mainContent->setLayout(new QVBoxLayout());
@ -102,9 +112,11 @@ Widget::Widget(QWidget *parent)
ui->mainHead->layout()->setSpacing(0);
QWidget* friendListWidget = new QWidget();
//friendListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
friendListWidget->setLayout(new QVBoxLayout());
friendListWidget->layout()->setSpacing(0);
friendListWidget->layout()->setMargin(0);
friendListWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
ui->friendList->setWidget(friendListWidget);
// delay setting username and message until Core inits
@ -112,7 +124,6 @@ Widget::Widget(QWidget *parent)
ui->nameLabel->label->setStyleSheet("QLabel { color : white; font-size: 11pt; font-weight:bold;}");
//ui->statusLabel->setText(core->getStatusMessage());
ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}");
ui->friendList->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
ui->statusButton->setStyleSheet(Style::get(":/ui/statusButton/statusButton.css"));
@ -125,13 +136,6 @@ Widget::Widget(QWidget *parent)
setStatusBusy->setIcon(QIcon(":ui/statusButton/dot_busy.png"));
ui->statusButton->setMenu(statusButtonMenu);
// 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);
@ -140,11 +144,11 @@ Widget::Widget(QWidget *parent)
ui->pbClose->setMouseTracking(true);
ui->statusHead->setMouseTracking(true);
ui->friendList->viewport()->installEventFilter(this);
//ui->friendList->viewport()->installEventFilter(this);
// QList<int> currentSizes = ui->centralWidget->sizes();
// currentSizes[0] = 225;
// ui->centralWidget->setSizes(currentSizes);
// disable proportional scaling
ui->centralWidget->setStretchFactor(0,0);
ui->centralWidget->setStretchFactor(1,1);
ui->statusButton->setObjectName("offline");
ui->statusButton->style()->polish(ui->statusButton);
@ -617,7 +621,7 @@ void Widget::onGroupMessageReceived(int groupnumber, int friendgroupnumber, cons
newMessageAlert();
g->hasNewMessages = 1;
g->userWasMentioned = 1;
if (useNativeTheme)
if (Settings::getInstance().getUseNativeDecoration())
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
else
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat_notification.png"));
@ -626,7 +630,7 @@ void Widget::onGroupMessageReceived(int groupnumber, int friendgroupnumber, cons
if (g->hasNewMessages == 0)
{
g->hasNewMessages = 1;
if (useNativeTheme)
if (Settings::getInstance().getUseNativeDecoration())
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
else
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat_newmessages.png"));
@ -673,7 +677,7 @@ void Widget::onGroupWidgetClicked(GroupWidget* widget)
{
g->hasNewMessages = 0;
g->userWasMentioned = 0;
if (useNativeTheme)
if (Settings::getInstance().getUseNativeDecoration())
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
else
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
@ -712,7 +716,7 @@ Group *Widget::createGroup(int groupId)
QWidget* widget = ui->friendList->widget();
QLayout* layout = widget->layout();
layout->addWidget(newgroup->widget);
if (!useNativeTheme)
if (!Settings::getInstance().getUseNativeDecoration())
newgroup->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
connect(newgroup->widget, SIGNAL(groupWidgetClicked(GroupWidget*)), this, SLOT(onGroupWidgetClicked(GroupWidget*)));
@ -758,7 +762,7 @@ bool Widget::event(QEvent * e)
}
else if (e->type() == QEvent::WindowActivate)
{
if (!useNativeTheme)
if (!Settings::getInstance().getUseNativeDecoration())
{
this->setObjectName("activeWindow");
this->style()->polish(this);
@ -775,18 +779,18 @@ bool Widget::event(QEvent * e)
Group* g = GroupList::findGroup(activeGroupWidget->groupId);
g->hasNewMessages = 0;
g->userWasMentioned = 0;
if (useNativeTheme)
if (Settings::getInstance().getUseNativeDecoration())
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
else
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
}
}
else if (e->type() == QEvent::WindowDeactivate && !useNativeTheme)
else if (e->type() == QEvent::WindowDeactivate && !Settings::getInstance().getUseNativeDecoration())
{
this->setObjectName("inactiveWindow");
this->style()->polish(this);
}
else if (e->type() == QEvent::MouseMove && !useNativeTheme)
else if (e->type() == QEvent::MouseMove && !Settings::getInstance().getUseNativeDecoration())
{
QMouseEvent *k = (QMouseEvent *)e;
int xMouse = k->pos().x();
@ -831,7 +835,7 @@ bool Widget::event(QEvent * e)
void Widget::mousePressEvent(QMouseEvent *e)
{
if (!useNativeTheme)
if (!Settings::getInstance().getUseNativeDecoration())
{
if (e->button() == Qt::LeftButton)
{
@ -865,7 +869,7 @@ void Widget::mousePressEvent(QMouseEvent *e)
void Widget::mouseReleaseEvent(QMouseEvent *e)
{
if (!useNativeTheme)
if (!Settings::getInstance().getUseNativeDecoration())
{
moveWidget = false;
allowToResize = false;
@ -880,7 +884,7 @@ void Widget::mouseReleaseEvent(QMouseEvent *e)
void Widget::mouseDoubleClickEvent(QMouseEvent *e)
{
if (!useNativeTheme)
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()
@ -904,7 +908,7 @@ void Widget::paintEvent (QPaintEvent *)
void Widget::moveWindow(QMouseEvent *e)
{
if (!useNativeTheme)
if (!Settings::getInstance().getUseNativeDecoration())
{
if (e->buttons() & Qt::LeftButton)
{
@ -916,7 +920,7 @@ void Widget::moveWindow(QMouseEvent *e)
void Widget::resizeWindow(QMouseEvent *e)
{
if (!useNativeTheme)
if (!Settings::getInstance().getUseNativeDecoration())
{
if (allowToResize)
{

View File

@ -58,7 +58,6 @@ public:
void newMessageAlert();
bool isFriendWidgetCurActiveWidget(Friend* f);
void updateFriendStatusLights(int friendId);
int useNativeTheme;
~Widget();
virtual void closeEvent(QCloseEvent *event);