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

Multi-window capabilities for all chats and menus

This commit is contained in:
TheSpiritXIII 2015-06-16 14:25:19 -04:00 committed by tux3
parent 60c18d07a6
commit 22fcc3f7a0
28 changed files with 458 additions and 656 deletions

View File

@ -495,7 +495,8 @@ SOURCES += \
src/widget/friendlistlayout.cpp \ src/widget/friendlistlayout.cpp \
src/widget/genericchatitemlayout.cpp \ src/widget/genericchatitemlayout.cpp \
src/widget/categorywidget.cpp \ src/widget/categorywidget.cpp \
src/widget/tool/removefrienddialog.cpp src/widget/tool/removefrienddialog.cpp \
src/widget/contentlayout.cpp
HEADERS += \ HEADERS += \
src/audio/audio.h \ src/audio/audio.h \
@ -539,4 +540,5 @@ HEADERS += \
src/widget/friendlistlayout.h \ src/widget/friendlistlayout.h \
src/widget/genericchatitemlayout.h \ src/widget/genericchatitemlayout.h \
src/widget/categorywidget.h \ src/widget/categorywidget.h \
src/widget/contentlayout.h \
src/widget/tool/removefrienddialog.h src/widget/tool/removefrienddialog.h

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>775</width> <width>775</width>
<height>537</height> <height>420</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -1288,555 +1288,6 @@ QSplitter:handle{
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="mainPanel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>170</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<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>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>170</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<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>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>170</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<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>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="mainHead" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>57</height>
</size>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="mainHLine">
<property name="minimumSize">
<size>
<width>0</width>
<height>1</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>193</red>
<green>193</green>
<blue>193</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>193</red>
<green>193</green>
<blue>193</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</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>375</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -174,6 +174,7 @@ void Settings::loadGlobal()
globalAutoAcceptDir = s.value("globalAutoAcceptDir", globalAutoAcceptDir = s.value("globalAutoAcceptDir",
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory) QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
).toString(); ).toString();
separateWindow = s.value("separateWindow", false).toBool();
groupchatPosition = s.value("groupchatPosition", true).toBool(); groupchatPosition = s.value("groupchatPosition", true).toBool();
s.endGroup(); s.endGroup();
@ -375,6 +376,7 @@ void Settings::saveGlobal()
s.setValue("notifySound", notifySound); s.setValue("notifySound", notifySound);
s.setValue("groupAlwaysNotify", groupAlwaysNotify); s.setValue("groupAlwaysNotify", groupAlwaysNotify);
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging); s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
s.setValue("separateWindow", separateWindow);
s.setValue("groupchatPosition", groupchatPosition); s.setValue("groupchatPosition", groupchatPosition);
s.setValue("autoSaveEnabled", autoSaveEnabled); s.setValue("autoSaveEnabled", autoSaveEnabled);
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir); s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
@ -1324,6 +1326,18 @@ void Settings::setCompactLayout(bool value)
compactLayout = value; compactLayout = value;
} }
bool Settings::getSeparateWindow() const
{
QMutexLocker locker{&bigLock};
return separateWindow;
}
void Settings::setSeparateWindow(bool value)
{
QMutexLocker locker{&bigLock};
separateWindow = value;
}
bool Settings::getGroupchatPosition() const bool Settings::getGroupchatPosition() const
{ {
QMutexLocker locker{&bigLock}; QMutexLocker locker{&bigLock};

View File

@ -237,6 +237,9 @@ public:
bool getCompactLayout() const; bool getCompactLayout() const;
void setCompactLayout(bool compact); void setCompactLayout(bool compact);
bool getSeparateWindow() const;
void setSeparateWindow(bool value);
bool getGroupchatPosition() const; bool getGroupchatPosition() const;
void setGroupchatPosition(bool value); void setGroupchatPosition(bool value);
@ -295,6 +298,7 @@ private:
bool fauxOfflineMessaging; bool fauxOfflineMessaging;
bool compactLayout; bool compactLayout;
bool groupchatPosition; bool groupchatPosition;
bool separateWindow;
bool enableIPv6; bool enableIPv6;
QString translation; QString translation;
bool makeToxPortable; bool makeToxPortable;

View File

@ -0,0 +1,124 @@
/*
Copyright © 2015 by The qTox Project
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox 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.
qTox 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
#include "contentlayout.h"
#include "src/persistence/settings.h"
#include "style.h"
#include <QStyleFactory>
#include <QFrame>
ContentLayout::ContentLayout()
: QVBoxLayout()
{
init();
}
ContentLayout::ContentLayout(QWidget *parent)
: QVBoxLayout(parent)
{
init();
QPalette palette = parent->palette();
palette.setBrush(QPalette::WindowText, QColor(0, 0, 0));
palette.setBrush(QPalette::Button, QColor(255, 255, 255));
palette.setBrush(QPalette::Light, QColor(255, 255, 255));
palette.setBrush(QPalette::Midlight, QColor(255, 255, 255));
palette.setBrush(QPalette::Dark, QColor(127, 127, 127));
palette.setBrush(QPalette::Mid, QColor(170, 170, 170));
palette.setBrush(QPalette::Text, QColor(0, 0, 0));
palette.setBrush(QPalette::BrightText, QColor(255, 255, 255));
palette.setBrush(QPalette::ButtonText, QColor(0, 0, 0));
palette.setBrush(QPalette::Base, QColor(255, 255, 255));
palette.setBrush(QPalette::Window, QColor(255, 255, 255));
palette.setBrush(QPalette::Shadow, QColor(0, 0, 0));
palette.setBrush(QPalette::AlternateBase, QColor(255, 255, 255));
palette.setBrush(QPalette::ToolTipBase, QColor(255, 255, 220));
palette.setBrush(QPalette::ToolTipText, QColor(0, 0, 0));
palette.setBrush(QPalette::Disabled, QPalette::WindowText, QColor(127, 127, 127));
palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127));
palette.setBrush(QPalette::Disabled, QPalette::ButtonText, QColor(127, 127, 127));
parent->setPalette(palette);
}
ContentLayout::~ContentLayout()
{
clear();
mainHead->deleteLater();
mainContent->deleteLater();
}
void ContentLayout::clear()
{
QLayoutItem* item;
while ((item = mainHead->layout()->takeAt(0)) != 0)
{
item->widget()->hide();
item->widget()->setParent(nullptr);
}
while ((item = mainContent->layout()->takeAt(0)) != 0)
{
item->widget()->hide();
item->widget()->setParent(nullptr);
}
}
void ContentLayout::init()
{
setMargin(0);
setSpacing(0);
mainHead = new QWidget();
mainHead->setLayout(new QVBoxLayout);
mainHead->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
mainHead->layout()->setMargin(0);
mainHead->layout()->setSpacing(0);
mainHead->setMouseTracking(true);
mainHLine = new QFrame();
mainHLine->setFrameShape(QFrame::HLine);
mainHLine->setFrameShadow(QFrame::Plain);
QPalette palette = mainHLine->palette();
palette.setBrush(QPalette::WindowText, QBrush(QColor(193, 193, 193)));
palette.setBrush(QPalette::WindowText, QBrush(QColor(193, 193, 193)));
mainHLine->setPalette(palette);
mainContent = new QWidget();
mainContent->setLayout(new QVBoxLayout);
mainContent->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
if (QStyleFactory::keys().contains(Settings::getInstance().getStyle())
&& Settings::getInstance().getStyle() != "None")
{
mainHead->setStyle(QStyleFactory::create(Settings::getInstance().getStyle()));
mainContent->setStyle(QStyleFactory::create(Settings::getInstance().getStyle()));
}
#ifndef Q_OS_MAC
mainHead->setStyleSheet(Style::getStylesheet(":ui/settings/mainHead.css"));
mainContent->setStyleSheet(Style::getStylesheet(":ui/settings/mainContent.css"));
#endif
addWidget(mainHead);
addWidget(mainHLine);
addWidget(mainContent);
}

View File

@ -0,0 +1,44 @@
/*
Copyright © 2015 by The qTox Project
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox 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.
qTox 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONTENTLAYOUT_H
#define CONTENTLAYOUT_H
#include <QBoxLayout>
class QFrame;
class ContentLayout : public QVBoxLayout
{
public:
ContentLayout();
ContentLayout(QWidget* parent);
~ContentLayout();
void clear();
QWidget* mainContent;
QFrame* mainHLine;
QWidget* mainHead;
private:
void init();
};
#endif // CONTENTLAYOUT_H

View File

@ -22,9 +22,9 @@
#include <QFont> #include <QFont>
#include <QMessageBox> #include <QMessageBox>
#include <QErrorMessage> #include <QErrorMessage>
#include <QApplication>
#include <QClipboard> #include <QClipboard>
#include <tox/tox.h> #include <tox/tox.h>
#include "ui_mainwindow.h"
#include "src/nexus.h" #include "src/nexus.h"
#include "src/core/core.h" #include "src/core/core.h"
#include "src/core/cdata.h" #include "src/core/cdata.h"
@ -32,6 +32,7 @@
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
#include "src/widget/gui.h" #include "src/widget/gui.h"
#include "src/widget/translator.h" #include "src/widget/translator.h"
#include "src/widget/contentlayout.h"
AddFriendForm::AddFriendForm() AddFriendForm::AddFriendForm()
{ {
@ -66,10 +67,20 @@ AddFriendForm::~AddFriendForm()
main->deleteLater(); main->deleteLater();
} }
void AddFriendForm::show(Ui::MainWindow &ui) bool AddFriendForm::isShown() const
{ {
ui.mainContent->layout()->addWidget(main); if (main->isVisible())
ui.mainHead->layout()->addWidget(head); {
return true;
}
return false;
}
void AddFriendForm::show(ContentLayout* contentLayout)
{
contentLayout->mainContent->layout()->addWidget(main);
contentLayout->mainHead->layout()->addWidget(head);
main->show(); main->show();
head->show(); head->show();
setIdFromClipboard(); setIdFromClipboard();

View File

@ -26,7 +26,7 @@
#include <QTextEdit> #include <QTextEdit>
#include <QPushButton> #include <QPushButton>
namespace Ui {class MainWindow;} class ContentLayout;
class AddFriendForm : public QObject class AddFriendForm : public QObject
{ {
@ -37,7 +37,8 @@ public:
AddFriendForm& operator=(const AddFriendForm&) = delete; AddFriendForm& operator=(const AddFriendForm&) = delete;
~AddFriendForm(); ~AddFriendForm();
void show(Ui::MainWindow &ui); bool isShown() const;
void show(ContentLayout* contentLayout);
QString getMessage() const; QString getMessage() const;
signals: signals:

View File

@ -1009,9 +1009,9 @@ void ChatForm::setFriendTyping(bool isTyping)
text->setText("<div class=typing>" + QString("%1 is typing").arg(f->getDisplayedName()) + "</div>"); text->setText("<div class=typing>" + QString("%1 is typing").arg(f->getDisplayedName()) + "</div>");
} }
void ChatForm::show(Ui::MainWindow &ui) void ChatForm::show(ContentLayout* contentLayout)
{ {
GenericChatForm::show(ui); GenericChatForm::show(contentLayout);
if (callConfirm) if (callConfirm)
callConfirm->show(); callConfirm->show();

View File

@ -27,7 +27,6 @@
#include <QTimer> #include <QTimer>
#include <QElapsedTimer> #include <QElapsedTimer>
class Friend; class Friend;
class FileTransferInstance; class FileTransferInstance;
class NetCamView; class NetCamView;
@ -50,7 +49,7 @@ public:
void setFriendTyping(bool isTyping); void setFriendTyping(bool isTyping);
OfflineMsgEngine* getOfflineMsgEngine(); OfflineMsgEngine* getOfflineMsgEngine();
virtual void show(Ui::MainWindow &ui) final override; virtual void show(ContentLayout* contentLayout) final override;
signals: signals:
void sendFile(uint32_t friendId, QString, QString, long long); void sendFile(uint32_t friendId, QString, QString, long long);

View File

@ -18,9 +18,9 @@
*/ */
#include "filesform.h" #include "filesform.h"
#include "ui_mainwindow.h"
#include "src/widget/widget.h" #include "src/widget/widget.h"
#include "src/widget/translator.h" #include "src/widget/translator.h"
#include "src/widget/contentlayout.h"
#include <QFileInfo> #include <QFileInfo>
FilesForm::FilesForm() FilesForm::FilesForm()
@ -54,10 +54,20 @@ FilesForm::~FilesForm()
head->deleteLater(); head->deleteLater();
} }
void FilesForm::show(Ui::MainWindow& ui) bool FilesForm::isShown() const
{ {
ui.mainContent->layout()->addWidget(&main); if (main.isVisible())
ui.mainHead->layout()->addWidget(head); {
return true;
}
return false;
}
void FilesForm::show(ContentLayout* contentLayout)
{
contentLayout->mainContent->layout()->addWidget(&main);
contentLayout->mainHead->layout()->addWidget(head);
main.show(); main.show();
head->show(); head->show();
} }

View File

@ -26,7 +26,7 @@
#include <QLabel> #include <QLabel>
#include <QVBoxLayout> #include <QVBoxLayout>
namespace Ui {class MainWindow;} class ContentLayout;
class QListWidget; class QListWidget;
class FilesForm : public QObject class FilesForm : public QObject
@ -37,7 +37,8 @@ public:
FilesForm(); FilesForm();
~FilesForm(); ~FilesForm();
void show(Ui::MainWindow &ui); bool isShown() const;
void show(ContentLayout* contentLayout);
public slots: public slots:
void onFileDownloadComplete(const QString& path); void onFileDownloadComplete(const QString& path);

View File

@ -18,7 +18,6 @@
*/ */
#include "genericchatform.h" #include "genericchatform.h"
#include "ui_mainwindow.h"
#include <QFileDialog> #include <QFileDialog>
#include <QHBoxLayout> #include <QHBoxLayout>
@ -42,6 +41,9 @@
#include "src/chatlog/content/timestamp.h" #include "src/chatlog/content/timestamp.h"
#include "src/widget/tool/flyoutoverlaywidget.h" #include "src/widget/tool/flyoutoverlaywidget.h"
#include "src/widget/translator.h" #include "src/widget/translator.h"
#include "src/widget/contentlayout.h"
#include "src/widget/tool/croppinglabel.h"
#include <QPushButton>
GenericChatForm::GenericChatForm(QWidget *parent) GenericChatForm::GenericChatForm(QWidget *parent)
: QWidget(parent) : QWidget(parent)
@ -255,10 +257,10 @@ void GenericChatForm::setName(const QString &newName)
nameLabel->setToolTip(newName); // for overlength names nameLabel->setToolTip(newName); // for overlength names
} }
void GenericChatForm::show(Ui::MainWindow &ui) void GenericChatForm::show(ContentLayout* contentLayout)
{ {
ui.mainContent->layout()->addWidget(this); contentLayout->mainContent->layout()->addWidget(this);
ui.mainHead->layout()->addWidget(headWidget); contentLayout->mainHead->layout()->addWidget(headWidget);
headWidget->show(); headWidget->show();
QWidget::show(); QWidget::show();
} }

View File

@ -40,10 +40,7 @@ class ChatLog;
class MaskablePixmapWidget; class MaskablePixmapWidget;
class Widget; class Widget;
class FlyoutOverlayWidget; class FlyoutOverlayWidget;
class ContentLayout;
namespace Ui {
class MainWindow;
}
class GenericChatForm : public QWidget class GenericChatForm : public QWidget
{ {
@ -54,7 +51,7 @@ public:
void setName(const QString &newName); void setName(const QString &newName);
virtual void show() final{} virtual void show() final{}
virtual void show(Ui::MainWindow &ui); virtual void show(ContentLayout* contentLayout);
ChatMessage::Ptr addMessage(const ToxId& author, const QString &message, bool isAction, const QDateTime &datetime, bool isSent); ChatMessage::Ptr addMessage(const ToxId& author, const QString &message, bool isAction, const QDateTime &datetime, bool isSent);
ChatMessage::Ptr addSelfMessage(const QString &message, bool isAction, const QDateTime &datetime, bool isSent); ChatMessage::Ptr addSelfMessage(const QString &message, bool isAction, const QDateTime &datetime, bool isSent);

View File

@ -21,11 +21,11 @@
#include "src/nexus.h" #include "src/nexus.h"
#include "ui_profileform.h" #include "ui_profileform.h"
#include "profileform.h" #include "profileform.h"
#include "ui_mainwindow.h"
#include "src/widget/form/settingswidget.h" #include "src/widget/form/settingswidget.h"
#include "src/widget/maskablepixmapwidget.h" #include "src/widget/maskablepixmapwidget.h"
#include "src/widget/form/setpassworddialog.h" #include "src/widget/form/setpassworddialog.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
#include "src/widget/contentlayout.h"
#include "src/widget/tool/croppinglabel.h" #include "src/widget/tool/croppinglabel.h"
#include "src/widget/widget.h" #include "src/widget/widget.h"
#include "src/widget/gui.h" #include "src/widget/gui.h"
@ -134,10 +134,10 @@ ProfileForm::~ProfileForm()
head->deleteLater(); head->deleteLater();
} }
void ProfileForm::show(Ui::MainWindow &ui) void ProfileForm::show(ContentLayout* contentLayout)
{ {
ui.mainHead->layout()->addWidget(head); contentLayout->mainHead->layout()->addWidget(head);
ui.mainContent->layout()->addWidget(this); contentLayout->mainContent->layout()->addWidget(this);
head->show(); head->show();
QWidget::show(); QWidget::show();
prFileLabelUpdate(); prFileLabelUpdate();

View File

@ -30,10 +30,10 @@
class CroppingLabel; class CroppingLabel;
class Core; class Core;
class MaskablePixmapWidget; class MaskablePixmapWidget;
class ContentLayout;
namespace Ui { namespace Ui {
class IdentitySettings; class IdentitySettings;
class MainWindow;
} }
class ClickableTE : public QLineEdit class ClickableTE : public QLineEdit
@ -54,7 +54,7 @@ public:
ProfileForm(QWidget *parent = nullptr); ProfileForm(QWidget *parent = nullptr);
~ProfileForm(); ~ProfileForm();
virtual void show() final{} virtual void show() final{}
void show(Ui::MainWindow &ui); void show(ContentLayout* contentLayout);
signals: signals:
void userNameChanged(QString); void userNameChanged(QString);

View File

@ -87,6 +87,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->groupAlwaysNotify->setChecked(Settings::getInstance().getGroupAlwaysNotify()); bodyUI->groupAlwaysNotify->setChecked(Settings::getInstance().getGroupAlwaysNotify());
bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging()); bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging());
bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout()); bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout());
bodyUI->cbSeparateWindow->setChecked(Settings::getInstance().getSeparateWindow());
bodyUI->cbGroupchatPosition->setChecked(Settings::getInstance().getGroupchatPosition()); bodyUI->cbGroupchatPosition->setChecked(Settings::getInstance().getGroupchatPosition());
for (auto entry : SmileyPack::listSmileyPacks()) for (auto entry : SmileyPack::listSmileyPacks())
@ -179,6 +180,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &GeneralForm::onReconnectClicked); connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &GeneralForm::onReconnectClicked);
connect(bodyUI->cbFauxOfflineMessaging, &QCheckBox::stateChanged, this, &GeneralForm::onFauxOfflineMessaging); connect(bodyUI->cbFauxOfflineMessaging, &QCheckBox::stateChanged, this, &GeneralForm::onFauxOfflineMessaging);
connect(bodyUI->cbCompactLayout, &QCheckBox::stateChanged, this, &GeneralForm::onCompactLayout); connect(bodyUI->cbCompactLayout, &QCheckBox::stateChanged, this, &GeneralForm::onCompactLayout);
connect(bodyUI->cbSeparateWindow, &QCheckBox::stateChanged, this, &GeneralForm::onSeparateWindowChanged);
connect(bodyUI->cbGroupchatPosition, &QCheckBox::stateChanged, this, &GeneralForm::onGroupchatPositionChanged); connect(bodyUI->cbGroupchatPosition, &QCheckBox::stateChanged, this, &GeneralForm::onGroupchatPositionChanged);
// prevent stealing mouse whell scroll // prevent stealing mouse whell scroll
@ -430,6 +432,12 @@ void GeneralForm::onCompactLayout()
emit parent->compactToggled(bodyUI->cbCompactLayout->isChecked()); emit parent->compactToggled(bodyUI->cbCompactLayout->isChecked());
} }
void GeneralForm::onSeparateWindowChanged()
{
Settings::getInstance().setSeparateWindow(bodyUI->cbSeparateWindow->isChecked());
emit parent->separateWindowToggled(bodyUI->cbSeparateWindow->isChecked());
}
void GeneralForm::onGroupchatPositionChanged() void GeneralForm::onGroupchatPositionChanged()
{ {
Settings::getInstance().setGroupchatPosition(bodyUI->cbGroupchatPosition->isChecked()); Settings::getInstance().setGroupchatPosition(bodyUI->cbGroupchatPosition->isChecked());

View File

@ -67,6 +67,7 @@ private slots:
void onSetGroupAlwaysNotify(); void onSetGroupAlwaysNotify();
void onFauxOfflineMessaging(); void onFauxOfflineMessaging();
void onCompactLayout(); void onCompactLayout();
void onSeparateWindowChanged();
void onGroupchatPositionChanged(); void onGroupchatPositionChanged();
void onThemeColorChanged(int); void onThemeColorChanged(int);

View File

@ -374,6 +374,13 @@ instead of system taskbar.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="cbSeparateWindow">
<property name="text">
<string>Use separate windows for friend list.</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="cbGroupchatPosition"> <widget class="QCheckBox" name="cbGroupchatPosition">
<property name="toolTip"> <property name="toolTip">

View File

@ -19,7 +19,6 @@
#include "settingswidget.h" #include "settingswidget.h"
#include "src/widget/widget.h" #include "src/widget/widget.h"
#include "ui_mainwindow.h"
#include "src/video/camerasource.h" #include "src/video/camerasource.h"
#include "src/widget/form/settings/generalform.h" #include "src/widget/form/settings/generalform.h"
#include "src/widget/form/settings/privacyform.h" #include "src/widget/form/settings/privacyform.h"
@ -27,12 +26,14 @@
#include "src/widget/form/settings/advancedform.h" #include "src/widget/form/settings/advancedform.h"
#include "src/widget/form/settings/aboutform.h" #include "src/widget/form/settings/aboutform.h"
#include "src/widget/translator.h" #include "src/widget/translator.h"
#include "src/widget/contentlayout.h"
#include <QTabWidget> #include <QTabWidget>
#include <QLabel>
SettingsWidget::SettingsWidget(QWidget* parent) SettingsWidget::SettingsWidget(QWidget* parent)
: QWidget(parent) : QWidget(parent)
{ {
body = new QWidget(this); body = new QWidget();
QVBoxLayout* bodyLayout = new QVBoxLayout(); QVBoxLayout* bodyLayout = new QVBoxLayout();
body->setLayout(bodyLayout); body->setLayout(bodyLayout);
@ -86,10 +87,20 @@ void SettingsWidget::showAbout()
onTabChanged(settingsWidgets->count() - 1); onTabChanged(settingsWidgets->count() - 1);
} }
void SettingsWidget::show(Ui::MainWindow& ui) bool SettingsWidget::isShown() const
{ {
ui.mainContent->layout()->addWidget(body); if (body->isVisible())
ui.mainHead->layout()->addWidget(head); {
return true;
}
return false;
}
void SettingsWidget::show(ContentLayout* contentLayout)
{
contentLayout->mainContent->layout()->addWidget(body);
contentLayout->mainHead->layout()->addWidget(head);
body->show(); body->show();
head->show(); head->show();
onTabChanged(settingsWidgets->currentIndex()); onTabChanged(settingsWidgets->currentIndex());

View File

@ -32,8 +32,7 @@ class PrivacyForm;
class AVForm; class AVForm;
class QLabel; class QLabel;
class QTabWidget; class QTabWidget;
class ContentLayout;
namespace Ui {class MainWindow;}
class SettingsWidget : public QWidget class SettingsWidget : public QWidget
{ {
@ -42,7 +41,8 @@ public:
SettingsWidget(QWidget* parent = nullptr); SettingsWidget(QWidget* parent = nullptr);
~SettingsWidget(); ~SettingsWidget();
void show(Ui::MainWindow &ui); bool isShown() const;
void show(ContentLayout* contentLayout);
void setBodyHeadStyle(QString style); void setBodyHeadStyle(QString style);
void showAbout(); void showAbout();
@ -50,6 +50,7 @@ public:
signals: signals:
void setShowSystemTray(bool newValue); void setShowSystemTray(bool newValue);
void compactToggled(bool compact); void compactToggled(bool compact);
void separateWindowToggled(bool separateWindow);
void groupchatPositionToggled(bool groupchatPosition); void groupchatPositionToggled(bool groupchatPosition);
private slots: private slots:

View File

@ -304,10 +304,16 @@ void FriendWidget::search(const QString &searchString, bool hide)
circleWidget->search(searchString); circleWidget->search(searchString);
} }
void FriendWidget::setChatForm(Ui::MainWindow &ui) bool FriendWidget::chatFormIsSet() const
{ {
Friend* f = FriendList::findFriend(friendId); Friend* f = FriendList::findFriend(friendId);
f->getChatForm()->show(ui); return f->getChatForm()->isVisible();
}
void FriendWidget::setChatForm(ContentLayout* contentLayout)
{
Friend* f = FriendList::findFriend(friendId);
f->getChatForm()->show(contentLayout);
} }
void FriendWidget::resetEventFlags() void FriendWidget::resetEventFlags()

View File

@ -32,7 +32,8 @@ public:
virtual void setAsActiveChatroom() override; virtual void setAsActiveChatroom() override;
virtual void setAsInactiveChatroom() override; virtual void setAsInactiveChatroom() override;
virtual void updateStatusLight() override; virtual void updateStatusLight() override;
virtual void setChatForm(Ui::MainWindow &) override; virtual bool chatFormIsSet() const override;
virtual void setChatForm(ContentLayout* contentLayout) override;
virtual void resetEventFlags() override; virtual void resetEventFlags() override;
virtual QString getStatusString() override; virtual QString getStatusString() override;
void search(const QString &searchString, bool hide = false); void search(const QString &searchString, bool hide = false);

View File

@ -26,10 +26,7 @@ class CroppingLabel;
class MaskablePixmapWidget; class MaskablePixmapWidget;
class QVBoxLayout; class QVBoxLayout;
class QHBoxLayout; class QHBoxLayout;
class ContentLayout;
namespace Ui {
class MainWindow;
}
class GenericChatroomWidget : public GenericChatItemWidget class GenericChatroomWidget : public GenericChatItemWidget
{ {
@ -40,7 +37,8 @@ public:
virtual void setAsActiveChatroom() = 0; virtual void setAsActiveChatroom() = 0;
virtual void setAsInactiveChatroom() = 0; virtual void setAsInactiveChatroom() = 0;
virtual void updateStatusLight() = 0; virtual void updateStatusLight() = 0;
virtual void setChatForm(Ui::MainWindow &) = 0; virtual bool chatFormIsSet() const = 0;
virtual void setChatForm(ContentLayout* contentLayout) = 0;
virtual void resetEventFlags() = 0; virtual void resetEventFlags() = 0;
virtual QString getStatusString() = 0; virtual QString getStatusString() = 0;

View File

@ -137,10 +137,16 @@ void GroupWidget::editName()
nameLabel->editBegin(); nameLabel->editBegin();
} }
void GroupWidget::setChatForm(Ui::MainWindow &ui) bool GroupWidget::chatFormIsSet() const
{ {
Group* g = GroupList::findGroup(groupId); Group* g = GroupList::findGroup(groupId);
g->getChatForm()->show(ui); return g->getChatForm()->isVisible();
}
void GroupWidget::setChatForm(ContentLayout* contentLayout)
{
Group* g = GroupList::findGroup(groupId);
g->getChatForm()->show(contentLayout);
} }
void GroupWidget::resetEventFlags() void GroupWidget::resetEventFlags()

View File

@ -30,7 +30,8 @@ public:
virtual void setAsInactiveChatroom() final override; virtual void setAsInactiveChatroom() final override;
virtual void setAsActiveChatroom() final override; virtual void setAsActiveChatroom() final override;
virtual void updateStatusLight() final override; virtual void updateStatusLight() final override;
virtual void setChatForm(Ui::MainWindow &) final override; virtual bool chatFormIsSet() const final override;
virtual void setChatForm(ContentLayout* contentLayout) override;
virtual void resetEventFlags() final override; virtual void resetEventFlags() final override;
virtual QString getStatusString() final override; virtual QString getStatusString() final override;
void setName(const QString& name); void setName(const QString& name);

View File

@ -18,6 +18,7 @@
*/ */
#include "widget.h" #include "widget.h"
#include "contentlayout.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "src/core/core.h" #include "src/core/core.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
@ -68,6 +69,7 @@
#include <QList> #include <QList>
#include <QDesktopServices> #include <QDesktopServices>
#include <QProcess> #include <QProcess>
#include <QWindow>
#include <tox/tox.h> #include <tox/tox.h>
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
@ -113,11 +115,6 @@ void Widget::init()
offlineMsgTimer = new QTimer(); offlineMsgTimer = new QTimer();
offlineMsgTimer->start(15000); offlineMsgTimer->start(15000);
//restore window state
restoreGeometry(Settings::getInstance().getWindowGeometry());
restoreState(Settings::getInstance().getWindowState());
ui->mainSplitter->restoreState(Settings::getInstance().getSplitterState());
statusOnline = new QAction(this); statusOnline = new QAction(this);
statusOnline->setIcon(getStatusIcon(Status::Online, 10, 10)); statusOnline->setIcon(getStatusIcon(Status::Online, 10, 10));
connect(statusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline())); connect(statusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
@ -176,7 +173,7 @@ void Widget::init()
ui->searchContactFilterBox->setMenu(filterMenu); ui->searchContactFilterBox->setMenu(filterMenu);
ui->mainContent->setLayout(new QVBoxLayout()); /*ui->mainContent->setLayout(new QVBoxLayout());
ui->mainHead->setLayout(new QVBoxLayout()); ui->mainHead->setLayout(new QVBoxLayout());
ui->mainHead->layout()->setMargin(0); ui->mainHead->layout()->setMargin(0);
ui->mainHead->layout()->setSpacing(0); ui->mainHead->layout()->setSpacing(0);
@ -186,11 +183,11 @@ void Widget::init()
{ {
ui->mainHead->setStyle(QStyleFactory::create(Settings::getInstance().getStyle())); ui->mainHead->setStyle(QStyleFactory::create(Settings::getInstance().getStyle()));
ui->mainContent->setStyle(QStyleFactory::create(Settings::getInstance().getStyle())); ui->mainContent->setStyle(QStyleFactory::create(Settings::getInstance().getStyle()));
} }*/
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
ui->mainHead->setStyleSheet(Style::getStylesheet(":ui/settings/mainHead.css")); //ui->mainHead->setStyleSheet(Style::getStylesheet(":ui/settings/mainHead.css"));
ui->mainContent->setStyleSheet(Style::getStylesheet(":ui/settings/mainContent.css")); //ui->mainContent->setStyleSheet(Style::getStylesheet(":ui/settings/mainContent.css"));
ui->statusHead->setStyleSheet(Style::getStylesheet(":/ui/window/statusPanel.css")); ui->statusHead->setStyleSheet(Style::getStylesheet(":/ui/window/statusPanel.css"));
ui->statusPanel->setStyleSheet(Style::getStylesheet(":/ui/window/statusPanel.css")); ui->statusPanel->setStyleSheet(Style::getStylesheet(":/ui/window/statusPanel.css"));
#endif #endif
@ -331,15 +328,25 @@ void Widget::init()
}); });
#endif #endif
addFriendForm->show(*ui); contentLayout = nullptr;
setWindowTitle(tr("Add friend")); onSeparateWindowChanged(Settings::getInstance().getSeparateWindow(), false);
if (contentLayout != nullptr)
onAddClicked();
ui->addButton->setCheckable(true); ui->addButton->setCheckable(true);
ui->transferButton->setCheckable(true); ui->transferButton->setCheckable(true);
ui->settingsButton->setCheckable(true); ui->settingsButton->setCheckable(true);
setActiveToolMenuButton(Widget::AddButton); setActiveToolMenuButton(Widget::AddButton);
//restore window state
restoreGeometry(Settings::getInstance().getWindowGeometry());
restoreState(Settings::getInstance().getWindowState());
ui->mainSplitter->restoreState(Settings::getInstance().getSplitterState());
connect(settingsWidget, &SettingsWidget::compactToggled, contactListWidget, &FriendListWidget::onCompactChanged); connect(settingsWidget, &SettingsWidget::compactToggled, contactListWidget, &FriendListWidget::onCompactChanged);
connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged); connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged);
connect(settingsWidget, &SettingsWidget::separateWindowToggled, this, &Widget::onSeparateWindowClicked);
#if (AUTOUPDATE_ENABLED) #if (AUTOUPDATE_ENABLED)
if (Settings::getInstance().getCheckUpdates()) if (Settings::getInstance().getCheckUpdates())
AutoUpdater::checkUpdatesAsyncInteractive(); AutoUpdater::checkUpdatesAsyncInteractive();
@ -404,13 +411,13 @@ Widget::~Widget()
if (icon) if (icon)
icon->hide(); icon->hide();
hideMainForms();
delete profileForm; delete profileForm;
delete settingsWidget; delete settingsWidget;
delete addFriendForm; delete addFriendForm;
delete filesForm; delete filesForm;
delete timer; delete timer;
delete offlineMsgTimer; delete offlineMsgTimer;
delete contentLayout;
FriendList::clear(); FriendList::clear();
GroupList::clear(); GroupList::clear();
@ -517,6 +524,51 @@ void Widget::onStatusSet(Status status)
updateIcons(); updateIcons();
} }
void Widget::onSeparateWindowClicked(bool separate)
{
onSeparateWindowChanged(separate, true);
}
void Widget::onSeparateWindowChanged(bool separate, bool clicked)
{
if (!separate)
{
QWindowList windowList = QGuiApplication::topLevelWindows();
for (QWindow* window : windowList)
{
qDebug() << window->objectName();
if (window->objectName() == "detachedWindow")
window->close();
}
QWidget* contentWidget = new QWidget(this);
contentWidget->setObjectName("yolo");
contentLayout = new ContentLayout(contentWidget);
ui->mainSplitter->addWidget(contentWidget);
clicked = true;
setMinimumWidth(775);
}
else
{
if (contentLayout != nullptr)
{
contentLayout->parentWidget()->hide();
contentLayout->parentWidget()->deleteLater();
contentLayout->deleteLater();
contentLayout = nullptr;
}
setMinimumWidth(ui->tooliconsZone->sizeHint().width());
if (clicked)
resize(ui->statusPanel->width(), height());
}
if (clicked)
onSettingsClicked();
}
void Widget::setWindowTitle(const QString& title) void Widget::setWindowTitle(const QString& title)
{ {
QString tmp = title; QString tmp = title;
@ -533,11 +585,21 @@ void Widget::forceShow()
void Widget::onAddClicked() void Widget::onAddClicked()
{ {
hideMainForms(); if (Settings::getInstance().getSeparateWindow())
addFriendForm->show(*ui); {
setWindowTitle(tr("Add friend")); if (!addFriendForm->isShown())
setActiveToolMenuButton(Widget::AddButton); {
activeChatroomWidget = nullptr; addFriendForm->show(createContentDialog(tr("Add friend")));
setActiveToolMenuButton(Widget::None);
}
}
else
{
hideMainForms(nullptr);
addFriendForm->show(contentLayout);
setWindowTitle(tr("Add friend"));
setActiveToolMenuButton(Widget::AddButton);
}
} }
void Widget::onGroupClicked() void Widget::onGroupClicked()
@ -547,11 +609,21 @@ void Widget::onGroupClicked()
void Widget::onTransferClicked() void Widget::onTransferClicked()
{ {
hideMainForms(); if (Settings::getInstance().getSeparateWindow())
filesForm->show(*ui); {
setWindowTitle(tr("File transfers")); if (!filesForm->isShown())
setActiveToolMenuButton(Widget::TransferButton); {
activeChatroomWidget = nullptr; filesForm->show(createContentDialog(tr("File transfers")));
setActiveToolMenuButton(Widget::None);
}
}
else
{
hideMainForms(nullptr);
filesForm->show(contentLayout);
setWindowTitle(tr("File transfers"));
setActiveToolMenuButton(Widget::TransferButton);
}
} }
void Widget::confirmExecutableOpen(const QFileInfo file) void Widget::confirmExecutableOpen(const QFileInfo file)
@ -626,33 +698,39 @@ void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
void Widget::onSettingsClicked() void Widget::onSettingsClicked()
{ {
hideMainForms(); if (Settings::getInstance().getSeparateWindow())
settingsWidget->show(*ui); {
setWindowTitle(tr("Settings")); if (!settingsWidget->isShown())
setActiveToolMenuButton(Widget::SettingButton); {
activeChatroomWidget = nullptr; settingsWidget->show(createContentDialog(tr("Settings")));
setActiveToolMenuButton(Widget::None);
}
}
else
{
hideMainForms(nullptr);
settingsWidget->show(contentLayout);
setWindowTitle(tr("Settings"));
setActiveToolMenuButton(Widget::SettingButton);
}
} }
void Widget::showProfile() // onAvatarClicked, onUsernameClicked void Widget::showProfile() // onAvatarClicked, onUsernameClicked
{ {
hideMainForms(); hideMainForms(nullptr);
profileForm->show(*ui); profileForm->show(contentLayout);
setWindowTitle(tr("Profile")); setWindowTitle(tr("Profile"));
activeChatroomWidget = nullptr;
} }
void Widget::hideMainForms() void Widget::hideMainForms(GenericChatroomWidget* chatroomWidget)
{ {
setActiveToolMenuButton(Widget::None); setActiveToolMenuButton(Widget::None);
QLayoutItem* item; contentLayout->clear();
while ((item = ui->mainHead->layout()->takeAt(0)) != 0)
item->widget()->hide();
while ((item = ui->mainContent->layout()->takeAt(0)) != 0)
item->widget()->hide();
if (activeChatroomWidget != nullptr) if (activeChatroomWidget != nullptr)
activeChatroomWidget->setAsInactiveChatroom(); activeChatroomWidget->setAsInactiveChatroom();
activeChatroomWidget = chatroomWidget;
} }
void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUsername) void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUsername)
@ -860,21 +938,23 @@ void Widget::onFriendDisplayChanged(FriendWidget *friendWidget, Status s)
void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget) void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget)
{ {
hideMainForms(); if (Settings::getInstance().getSeparateWindow())
{
if (activeChatroomWidget != nullptr) if (!widget->chatFormIsSet())
activeChatroomWidget->setAsInactiveChatroom(); widget->setChatForm(createContentDialog(widget->getName()));
activeChatroomWidget = widget; }
else
widget->setAsActiveChatroom(); {
widget->setChatForm(*ui); widget->setChatForm(contentLayout);
setWindowTitle(widget->getName()); setWindowTitle(widget->getName());
widget->resetEventFlags(); widget->setAsActiveChatroom();
widget->updateStatusLight(); widget->resetEventFlags();
QString windowTitle = widget->getName(); widget->updateStatusLight();
if (!widget->getStatusString().isNull()) QString windowTitle = widget->getName();
windowTitle += " (" + widget->getStatusString() + ")"; if (!widget->getStatusString().isNull())
setWindowTitle(windowTitle); windowTitle += " (" + widget->getStatusString() + ")";
setWindowTitle(windowTitle);
}
} }
void Widget::onFriendMessageReceived(int friendId, const QString& message, bool isAction) void Widget::onFriendMessageReceived(int friendId, const QString& message, bool isAction)
@ -1017,7 +1097,7 @@ void Widget::removeFriend(Friend* f, bool fake)
Nexus::getCore()->removeFriend(f->getFriendID(), fake); Nexus::getCore()->removeFriend(f->getFriendID(), fake);
delete f; delete f;
if (ui->mainHead->layout()->isEmpty()) if (contentLayout->mainHead->layout()->isEmpty())
onAddClicked(); onAddClicked();
contactListWidget->reDraw(); contactListWidget->reDraw();
@ -1041,6 +1121,23 @@ void Widget::clearContactsList()
removeGroup(g, true); removeGroup(g, true);
} }
ContentLayout* Widget::createContentDialog(const QString &title) const
{
QDialog* dialog = new QDialog();
ContentLayout* contentLayout = new ContentLayout(dialog);
dialog->setObjectName("detached");
dialog->setLayout(contentLayout);
dialog->layout()->setMargin(0);
dialog->layout()->setSpacing(0);
dialog->setMinimumSize(775, 420);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setWindowTitle(title);
dialog->show();
return contentLayout;
}
void Widget::copyFriendIdToClipboard(int friendId) void Widget::copyFriendIdToClipboard(int friendId)
{ {
Friend* f = FriendList::findFriend(friendId); Friend* f = FriendList::findFriend(friendId);
@ -1172,7 +1269,7 @@ void Widget::removeGroup(Group* g, bool fake)
GroupList::removeGroup(g->getGroupId(), fake); GroupList::removeGroup(g->getGroupId(), fake);
Nexus::getCore()->removeGroup(g->getGroupId(), fake); Nexus::getCore()->removeGroup(g->getGroupId(), fake);
delete g; delete g;
if (ui->mainHead->layout()->isEmpty()) if (contentLayout->mainHead->layout()->isEmpty())
onAddClicked(); onAddClicked();
contactListWidget->reDraw(); contactListWidget->reDraw();

View File

@ -51,6 +51,7 @@ class SettingsWidget;
class AddFriendForm; class AddFriendForm;
class CircleWidget; class CircleWidget;
class QActionGroup; class QActionGroup;
class ContentLayout;
class Widget final : public QMainWindow class Widget final : public QMainWindow
{ {
@ -68,6 +69,7 @@ public:
bool getIsWindowMinimized(); bool getIsWindowMinimized();
void updateIcons(); void updateIcons();
void clearContactsList(); void clearContactsList();
ContentLayout* createContentDialog(const QString& title) const;
static void confirmExecutableOpen(const QFileInfo file); static void confirmExecutableOpen(const QFileInfo file);
@ -87,6 +89,8 @@ public:
public slots: public slots:
void onSettingsClicked(); void onSettingsClicked();
void onSeparateWindowClicked(bool separate);
void onSeparateWindowChanged(bool separate, bool clicked);
void setWindowTitle(const QString& title); void setWindowTitle(const QString& title);
void forceShow(); void forceShow();
void onConnected(); void onConnected();
@ -185,7 +189,7 @@ private:
private: private:
void setActiveToolMenuButton(ActiveToolMenuButton newActiveButton); void setActiveToolMenuButton(ActiveToolMenuButton newActiveButton);
void hideMainForms(); void hideMainForms(GenericChatroomWidget* chatroomWidget);
Group *createGroup(int groupId); Group *createGroup(int groupId);
void removeFriend(Friend* f, bool fake = false); void removeFriend(Friend* f, bool fake = false);
void removeGroup(Group* g, bool fake = false); void removeGroup(Group* g, bool fake = false);
@ -225,6 +229,7 @@ private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
QSplitter *centralLayout; QSplitter *centralLayout;
QPoint dragPosition; QPoint dragPosition;
ContentLayout* contentLayout;
AddFriendForm *addFriendForm; AddFriendForm *addFriendForm;
ProfileForm *profileForm; ProfileForm *profileForm;
SettingsWidget *settingsWidget; SettingsWidget *settingsWidget;