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/genericchatitemlayout.cpp \
src/widget/categorywidget.cpp \
src/widget/tool/removefrienddialog.cpp
src/widget/tool/removefrienddialog.cpp \
src/widget/contentlayout.cpp
HEADERS += \
src/audio/audio.h \
@ -539,4 +540,5 @@ HEADERS += \
src/widget/friendlistlayout.h \
src/widget/genericchatitemlayout.h \
src/widget/categorywidget.h \
src/widget/contentlayout.h \
src/widget/tool/removefrienddialog.h

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>775</width>
<height>537</height>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
@ -1288,555 +1288,6 @@ QSplitter:handle{
</item>
</layout>
</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>
</item>
</layout>

View File

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

View File

@ -237,6 +237,9 @@ public:
bool getCompactLayout() const;
void setCompactLayout(bool compact);
bool getSeparateWindow() const;
void setSeparateWindow(bool value);
bool getGroupchatPosition() const;
void setGroupchatPosition(bool value);
@ -295,6 +298,7 @@ private:
bool fauxOfflineMessaging;
bool compactLayout;
bool groupchatPosition;
bool separateWindow;
bool enableIPv6;
QString translation;
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 <QMessageBox>
#include <QErrorMessage>
#include <QApplication>
#include <QClipboard>
#include <tox/tox.h>
#include "ui_mainwindow.h"
#include "src/nexus.h"
#include "src/core/core.h"
#include "src/core/cdata.h"
@ -32,6 +32,7 @@
#include "src/persistence/settings.h"
#include "src/widget/gui.h"
#include "src/widget/translator.h"
#include "src/widget/contentlayout.h"
AddFriendForm::AddFriendForm()
{
@ -66,10 +67,20 @@ AddFriendForm::~AddFriendForm()
main->deleteLater();
}
void AddFriendForm::show(Ui::MainWindow &ui)
bool AddFriendForm::isShown() const
{
ui.mainContent->layout()->addWidget(main);
ui.mainHead->layout()->addWidget(head);
if (main->isVisible())
{
return true;
}
return false;
}
void AddFriendForm::show(ContentLayout* contentLayout)
{
contentLayout->mainContent->layout()->addWidget(main);
contentLayout->mainHead->layout()->addWidget(head);
main->show();
head->show();
setIdFromClipboard();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -40,10 +40,7 @@ class ChatLog;
class MaskablePixmapWidget;
class Widget;
class FlyoutOverlayWidget;
namespace Ui {
class MainWindow;
}
class ContentLayout;
class GenericChatForm : public QWidget
{
@ -54,7 +51,7 @@ public:
void setName(const QString &newName);
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 addSelfMessage(const QString &message, bool isAction, const QDateTime &datetime, bool isSent);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -304,10 +304,16 @@ void FriendWidget::search(const QString &searchString, bool hide)
circleWidget->search(searchString);
}
void FriendWidget::setChatForm(Ui::MainWindow &ui)
bool FriendWidget::chatFormIsSet() const
{
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()

View File

@ -32,7 +32,8 @@ public:
virtual void setAsActiveChatroom() override;
virtual void setAsInactiveChatroom() 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 QString getStatusString() override;
void search(const QString &searchString, bool hide = false);

View File

@ -26,10 +26,7 @@ class CroppingLabel;
class MaskablePixmapWidget;
class QVBoxLayout;
class QHBoxLayout;
namespace Ui {
class MainWindow;
}
class ContentLayout;
class GenericChatroomWidget : public GenericChatItemWidget
{
@ -40,7 +37,8 @@ public:
virtual void setAsActiveChatroom() = 0;
virtual void setAsInactiveChatroom() = 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 QString getStatusString() = 0;

View File

@ -137,10 +137,16 @@ void GroupWidget::editName()
nameLabel->editBegin();
}
void GroupWidget::setChatForm(Ui::MainWindow &ui)
bool GroupWidget::chatFormIsSet() const
{
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()

View File

@ -30,7 +30,8 @@ public:
virtual void setAsInactiveChatroom() final override;
virtual void setAsActiveChatroom() 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 QString getStatusString() final override;
void setName(const QString& name);

View File

@ -18,6 +18,7 @@
*/
#include "widget.h"
#include "contentlayout.h"
#include "ui_mainwindow.h"
#include "src/core/core.h"
#include "src/persistence/settings.h"
@ -68,6 +69,7 @@
#include <QList>
#include <QDesktopServices>
#include <QProcess>
#include <QWindow>
#include <tox/tox.h>
#ifdef Q_OS_MAC
@ -113,11 +115,6 @@ void Widget::init()
offlineMsgTimer = new QTimer();
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->setIcon(getStatusIcon(Status::Online, 10, 10));
connect(statusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
@ -176,7 +173,7 @@ void Widget::init()
ui->searchContactFilterBox->setMenu(filterMenu);
ui->mainContent->setLayout(new QVBoxLayout());
/*ui->mainContent->setLayout(new QVBoxLayout());
ui->mainHead->setLayout(new QVBoxLayout());
ui->mainHead->layout()->setMargin(0);
ui->mainHead->layout()->setSpacing(0);
@ -186,11 +183,11 @@ void Widget::init()
{
ui->mainHead->setStyle(QStyleFactory::create(Settings::getInstance().getStyle()));
ui->mainContent->setStyle(QStyleFactory::create(Settings::getInstance().getStyle()));
}
}*/
#ifndef Q_OS_MAC
ui->mainHead->setStyleSheet(Style::getStylesheet(":ui/settings/mainHead.css"));
ui->mainContent->setStyleSheet(Style::getStylesheet(":ui/settings/mainContent.css"));
//ui->mainHead->setStyleSheet(Style::getStylesheet(":ui/settings/mainHead.css"));
//ui->mainContent->setStyleSheet(Style::getStylesheet(":ui/settings/mainContent.css"));
ui->statusHead->setStyleSheet(Style::getStylesheet(":/ui/window/statusPanel.css"));
ui->statusPanel->setStyleSheet(Style::getStylesheet(":/ui/window/statusPanel.css"));
#endif
@ -331,15 +328,25 @@ void Widget::init()
});
#endif
addFriendForm->show(*ui);
setWindowTitle(tr("Add friend"));
contentLayout = nullptr;
onSeparateWindowChanged(Settings::getInstance().getSeparateWindow(), false);
if (contentLayout != nullptr)
onAddClicked();
ui->addButton->setCheckable(true);
ui->transferButton->setCheckable(true);
ui->settingsButton->setCheckable(true);
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::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged);
connect(settingsWidget, &SettingsWidget::separateWindowToggled, this, &Widget::onSeparateWindowClicked);
#if (AUTOUPDATE_ENABLED)
if (Settings::getInstance().getCheckUpdates())
AutoUpdater::checkUpdatesAsyncInteractive();
@ -404,13 +411,13 @@ Widget::~Widget()
if (icon)
icon->hide();
hideMainForms();
delete profileForm;
delete settingsWidget;
delete addFriendForm;
delete filesForm;
delete timer;
delete offlineMsgTimer;
delete contentLayout;
FriendList::clear();
GroupList::clear();
@ -517,6 +524,51 @@ void Widget::onStatusSet(Status status)
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)
{
QString tmp = title;
@ -533,11 +585,21 @@ void Widget::forceShow()
void Widget::onAddClicked()
{
hideMainForms();
addFriendForm->show(*ui);
setWindowTitle(tr("Add friend"));
setActiveToolMenuButton(Widget::AddButton);
activeChatroomWidget = nullptr;
if (Settings::getInstance().getSeparateWindow())
{
if (!addFriendForm->isShown())
{
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()
@ -547,11 +609,21 @@ void Widget::onGroupClicked()
void Widget::onTransferClicked()
{
hideMainForms();
filesForm->show(*ui);
setWindowTitle(tr("File transfers"));
setActiveToolMenuButton(Widget::TransferButton);
activeChatroomWidget = nullptr;
if (Settings::getInstance().getSeparateWindow())
{
if (!filesForm->isShown())
{
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)
@ -626,33 +698,39 @@ void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
void Widget::onSettingsClicked()
{
hideMainForms();
settingsWidget->show(*ui);
setWindowTitle(tr("Settings"));
setActiveToolMenuButton(Widget::SettingButton);
activeChatroomWidget = nullptr;
if (Settings::getInstance().getSeparateWindow())
{
if (!settingsWidget->isShown())
{
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
{
hideMainForms();
profileForm->show(*ui);
hideMainForms(nullptr);
profileForm->show(contentLayout);
setWindowTitle(tr("Profile"));
activeChatroomWidget = nullptr;
}
void Widget::hideMainForms()
void Widget::hideMainForms(GenericChatroomWidget* chatroomWidget)
{
setActiveToolMenuButton(Widget::None);
QLayoutItem* item;
while ((item = ui->mainHead->layout()->takeAt(0)) != 0)
item->widget()->hide();
while ((item = ui->mainContent->layout()->takeAt(0)) != 0)
item->widget()->hide();
contentLayout->clear();
if (activeChatroomWidget != nullptr)
activeChatroomWidget->setAsInactiveChatroom();
activeChatroomWidget = chatroomWidget;
}
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)
{
hideMainForms();
if (activeChatroomWidget != nullptr)
activeChatroomWidget->setAsInactiveChatroom();
activeChatroomWidget = widget;
widget->setAsActiveChatroom();
widget->setChatForm(*ui);
setWindowTitle(widget->getName());
widget->resetEventFlags();
widget->updateStatusLight();
QString windowTitle = widget->getName();
if (!widget->getStatusString().isNull())
windowTitle += " (" + widget->getStatusString() + ")";
setWindowTitle(windowTitle);
if (Settings::getInstance().getSeparateWindow())
{
if (!widget->chatFormIsSet())
widget->setChatForm(createContentDialog(widget->getName()));
}
else
{
widget->setChatForm(contentLayout);
setWindowTitle(widget->getName());
widget->setAsActiveChatroom();
widget->resetEventFlags();
widget->updateStatusLight();
QString windowTitle = widget->getName();
if (!widget->getStatusString().isNull())
windowTitle += " (" + widget->getStatusString() + ")";
setWindowTitle(windowTitle);
}
}
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);
delete f;
if (ui->mainHead->layout()->isEmpty())
if (contentLayout->mainHead->layout()->isEmpty())
onAddClicked();
contactListWidget->reDraw();
@ -1041,6 +1121,23 @@ void Widget::clearContactsList()
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)
{
Friend* f = FriendList::findFriend(friendId);
@ -1172,7 +1269,7 @@ void Widget::removeGroup(Group* g, bool fake)
GroupList::removeGroup(g->getGroupId(), fake);
Nexus::getCore()->removeGroup(g->getGroupId(), fake);
delete g;
if (ui->mainHead->layout()->isEmpty())
if (contentLayout->mainHead->layout()->isEmpty())
onAddClicked();
contactListWidget->reDraw();

View File

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