mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
styling cleanup
This commit is contained in:
parent
8c32699608
commit
af4623695c
6
qtox.pro
6
qtox.pro
|
@ -85,7 +85,8 @@ HEADERS += widget/form/addfriendform.h \
|
|||
widget/netcamview.h \
|
||||
widget/tool/clickablelabel.h \
|
||||
smileypack.h \
|
||||
widget/emoticonswidget.h
|
||||
widget/emoticonswidget.h \
|
||||
style.h
|
||||
|
||||
SOURCES += \
|
||||
widget/form/addfriendform.cpp \
|
||||
|
@ -119,4 +120,5 @@ SOURCES += \
|
|||
widget/netcamview.cpp \
|
||||
widget/tool/clickablelabel.cpp \
|
||||
smileypack.cpp \
|
||||
widget/emoticonswidget.cpp
|
||||
widget/emoticonswidget.cpp \
|
||||
style.cpp
|
||||
|
|
24
settings.cpp
24
settings.cpp
|
@ -102,6 +102,8 @@ void Settings::load()
|
|||
secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt();
|
||||
timestampFormat = s.value("timestampFormat", "hh:mm").toString();
|
||||
minimizeOnClose = s.value("minimizeOnClose", false).toBool();
|
||||
useNativeStyle = s.value("nativeStyle", false).toBool();
|
||||
useNativeDecoration = s.value("nativeDecoration", true).toBool();
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("Privacy");
|
||||
|
@ -158,6 +160,8 @@ void Settings::save(QString path)
|
|||
s.setValue("secondColumnHandlePosFromRight", secondColumnHandlePosFromRight);
|
||||
s.setValue("timestampFormat", timestampFormat);
|
||||
s.setValue("minimizeOnClose", minimizeOnClose);
|
||||
s.setValue("nativeStyle", useNativeStyle);
|
||||
s.setValue("nativeDecoration", useNativeDecoration);
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("Privacy");
|
||||
|
@ -335,6 +339,26 @@ void Settings::setEmojiFontFamily(const QString &value)
|
|||
emit emojiFontChanged();
|
||||
}
|
||||
|
||||
bool Settings::getUseNativeStyle() const
|
||||
{
|
||||
return useNativeStyle;
|
||||
}
|
||||
|
||||
void Settings::setUseNativeStyle(bool value)
|
||||
{
|
||||
useNativeStyle = value;
|
||||
}
|
||||
|
||||
bool Settings::getUseNativeDecoration() const
|
||||
{
|
||||
return useNativeDecoration;
|
||||
}
|
||||
|
||||
void Settings::setUseNativeDecoration(bool value)
|
||||
{
|
||||
useNativeDecoration = value;
|
||||
}
|
||||
|
||||
bool Settings::isMinimizeOnCloseEnabled() const
|
||||
{
|
||||
return minimizeOnClose;
|
||||
|
|
|
@ -112,6 +112,12 @@ public:
|
|||
bool isTypingNotificationEnabled() const;
|
||||
void setTypingNotification(bool enabled);
|
||||
|
||||
bool getUseNativeStyle() const;
|
||||
void setUseNativeStyle(bool value);
|
||||
|
||||
bool getUseNativeDecoration() const;
|
||||
void setUseNativeDecoration(bool value);
|
||||
|
||||
private:
|
||||
Settings();
|
||||
Settings(Settings &settings) = delete;
|
||||
|
@ -147,6 +153,8 @@ private:
|
|||
QString emojiFontFamily;
|
||||
int emojiFontPointSize;
|
||||
bool minimizeOnClose;
|
||||
bool useNativeStyle;
|
||||
bool useNativeDecoration;
|
||||
|
||||
// ChatView
|
||||
int firstColumnHandlePos;
|
||||
|
|
19
style.cpp
Normal file
19
style.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include "style.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
||||
QString Style::get(const QString &filename)
|
||||
{
|
||||
if (!Settings::getInstance().getUseNativeStyle())
|
||||
{
|
||||
QFile file(filename);
|
||||
if (file.open(QFile::ReadOnly | QFile::Text))
|
||||
return file.readAll();
|
||||
else
|
||||
qWarning() << "Style " << filename << " not found";
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
14
style.h
Normal file
14
style.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef STYLE_H
|
||||
#define STYLE_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class Style
|
||||
{
|
||||
public:
|
||||
static QString get(const QString& filename);
|
||||
private:
|
||||
Style();
|
||||
};
|
||||
|
||||
#endif // STYLE_H
|
|
@ -21,6 +21,7 @@
|
|||
#include "widget/widget.h"
|
||||
#include "widget/filetransfertwidget.h"
|
||||
#include "widget/emoticonswidget.h"
|
||||
#include "style.h"
|
||||
#include <QFont>
|
||||
#include <QTime>
|
||||
#include <QScrollBar>
|
||||
|
@ -53,16 +54,8 @@ ChatForm::ChatForm(Friend* chatFriend)
|
|||
avatar->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||
|
||||
chatAreaWidget->setLayout(mainChatLayout);
|
||||
QString chatAreaStylesheet = "";
|
||||
try
|
||||
{
|
||||
QFile f(":/ui/chatArea/chatArea.css");
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream chatAreaStylesheetStream(&f);
|
||||
chatAreaStylesheet = chatAreaStylesheetStream.readAll();
|
||||
}
|
||||
catch (int e) {}
|
||||
chatArea->setStyleSheet(chatAreaStylesheet);
|
||||
chatAreaWidget->setStyleSheet(Style::get(":/ui/chatArea/chatArea.css"));
|
||||
|
||||
chatArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
chatArea->setWidgetResizable(true);
|
||||
chatArea->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
@ -73,76 +66,19 @@ ChatForm::ChatForm(Friend* chatFriend)
|
|||
|
||||
footButtonsSmall->setSpacing(2);
|
||||
|
||||
QString msgEditStylesheet = "";
|
||||
try
|
||||
{
|
||||
QFile f(":/ui/msgEdit/msgEdit.css");
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream msgEditStylesheetStream(&f);
|
||||
msgEditStylesheet = msgEditStylesheetStream.readAll();
|
||||
}
|
||||
catch (int e) {}
|
||||
msgEdit->setStyleSheet(msgEditStylesheet);
|
||||
msgEdit->setStyleSheet(Style::get(":/ui/msgEdit/msgEdit.css"));
|
||||
msgEdit->setFixedHeight(50);
|
||||
msgEdit->setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
QString sendButtonStylesheet = "";
|
||||
try
|
||||
{
|
||||
QFile f(":/ui/sendButton/sendButton.css");
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream sendButtonStylesheetStream(&f);
|
||||
sendButtonStylesheet = sendButtonStylesheetStream.readAll();
|
||||
}
|
||||
catch (int e) {}
|
||||
sendButton->setStyleSheet(sendButtonStylesheet);
|
||||
sendButton->setStyleSheet(Style::get(":/ui/sendButton/sendButton.css"));
|
||||
fileButton->setStyleSheet(Style::get(":/ui/fileButton/fileButton.css"));
|
||||
emoteButton->setStyleSheet(Style::get(":/ui/emoteButton/emoteButton.css"));
|
||||
|
||||
QString fileButtonStylesheet = "";
|
||||
try
|
||||
{
|
||||
QFile f(":/ui/fileButton/fileButton.css");
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream fileButtonStylesheetStream(&f);
|
||||
fileButtonStylesheet = fileButtonStylesheetStream.readAll();
|
||||
}
|
||||
catch (int e) {}
|
||||
fileButton->setStyleSheet(fileButtonStylesheet);
|
||||
|
||||
|
||||
QString emoteButtonStylesheet = "";
|
||||
try
|
||||
{
|
||||
QFile f(":/ui/emoteButton/emoteButton.css");
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream emoteButtonStylesheetStream(&f);
|
||||
emoteButtonStylesheet = emoteButtonStylesheetStream.readAll();
|
||||
}
|
||||
catch (int e) {}
|
||||
emoteButton->setStyleSheet(emoteButtonStylesheet);
|
||||
|
||||
QString callButtonStylesheet = "";
|
||||
try
|
||||
{
|
||||
QFile f(":/ui/callButton/callButton.css");
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream callButtonStylesheetStream(&f);
|
||||
callButtonStylesheet = callButtonStylesheetStream.readAll();
|
||||
}
|
||||
catch (int e) {}
|
||||
callButton->setObjectName("green");
|
||||
callButton->setStyleSheet(callButtonStylesheet);
|
||||
callButton->setStyleSheet(Style::get(":/ui/callButton/callButton.css"));
|
||||
|
||||
QString videoButtonStylesheet = "";
|
||||
try
|
||||
{
|
||||
QFile f(":/ui/videoButton/videoButton.css");
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream videoButtonStylesheetStream(&f);
|
||||
videoButtonStylesheet = videoButtonStylesheetStream.readAll();
|
||||
}
|
||||
catch (int e) {}
|
||||
videoButton->setObjectName("green");
|
||||
videoButton->setStyleSheet(videoButtonStylesheet);
|
||||
videoButton->setStyleSheet(Style::get(":/ui/videoButton/videoButton.css"));
|
||||
|
||||
main->setLayout(mainLayout);
|
||||
mainLayout->addWidget(chatArea);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "group.h"
|
||||
#include "widget/groupwidget.h"
|
||||
#include "widget/form/groupchatform.h"
|
||||
#include "style.h"
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include <QSound>
|
||||
|
@ -45,64 +46,28 @@ Widget::Widget(QWidget *parent) :
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QSettings settings(Settings::getInstance().getSettingsDirPath() + '/' + "windowSettings.ini", QSettings::IniFormat);
|
||||
if (!settings.contains("useNativeTheme"))
|
||||
useNativeTheme = 1;
|
||||
else
|
||||
useNativeTheme = settings.value("useNativeTheme").toInt();
|
||||
|
||||
if (useNativeTheme)
|
||||
{
|
||||
ui->titleBar->hide();
|
||||
this->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QString friendListStylesheet = "";
|
||||
try
|
||||
{
|
||||
QFile f(":ui/friendList/friendList.css");
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream friendListStylesheetStream(&f);
|
||||
friendListStylesheet = friendListStylesheetStream.readAll();
|
||||
}
|
||||
catch (int e) {}
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
ui->friendList->setObjectName("friendList");
|
||||
ui->friendList->setStyleSheet(friendListStylesheet);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString windowStylesheet = "";
|
||||
try
|
||||
{
|
||||
QFile f(":ui/window/window.css");
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream windowStylesheetStream(&f);
|
||||
windowStylesheet = windowStylesheetStream.readAll();
|
||||
}
|
||||
catch (int e) {}
|
||||
this->setObjectName("activeWindow");
|
||||
this->setStyleSheet(windowStylesheet);
|
||||
ui->statusPanel->setStyleSheet(QString(""));
|
||||
ui->friendList->setStyleSheet(QString(""));
|
||||
ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css"));
|
||||
|
||||
setStyleSheet(Style::get(":ui/window/window.css"));
|
||||
//ui->statusPanel->setStyleSheet(QString(""));
|
||||
//ui->friendList->setStyleSheet(QString(""));
|
||||
|
||||
QString friendListStylesheet = "";
|
||||
try
|
||||
{
|
||||
QFile f(":ui/friendList/friendList.css");
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream friendListStylesheetStream(&f);
|
||||
friendListStylesheet = friendListStylesheetStream.readAll();
|
||||
}
|
||||
catch (int e) {}
|
||||
ui->friendList->setObjectName("friendList");
|
||||
ui->friendList->setStyleSheet(friendListStylesheet);
|
||||
ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css"));
|
||||
|
||||
ui->tbMenu->setIcon(QIcon(":ui/window/applicationIcon.png"));
|
||||
ui->pbMin->setObjectName("minimizeButton");
|
||||
ui->pbMax->setObjectName("maximizeButton");
|
||||
ui->pbClose->setObjectName("closeButton");
|
||||
|
||||
if (!Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
setWindowFlags(Qt::CustomizeWindowHint);
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
}
|
||||
|
||||
addAction(ui->actionClose);
|
||||
|
||||
|
@ -131,14 +96,6 @@ Widget::Widget(QWidget *parent) :
|
|||
ui->pbMax->setObjectName("restoreButton");
|
||||
}
|
||||
|
||||
QList<QWidget*> widgets = this->findChildren<QWidget*>();
|
||||
|
||||
foreach (QWidget *widget, widgets)
|
||||
{
|
||||
widget->setMouseTracking(true);
|
||||
}
|
||||
}
|
||||
|
||||
isWindowMinimized = 0;
|
||||
|
||||
ui->mainContent->setLayout(new QVBoxLayout());
|
||||
|
@ -174,11 +131,11 @@ Widget::Widget(QWidget *parent) :
|
|||
ui->statusButton->setMenu(statusButtonMenu);
|
||||
|
||||
|
||||
this->setMouseTracking(true);
|
||||
// this->setMouseTracking(true);
|
||||
|
||||
QList<QWidget*> widgets = this->findChildren<QWidget*>();
|
||||
foreach (QWidget *widget, widgets)
|
||||
widget->setMouseTracking(true);
|
||||
// QList<QWidget*> widgets = this->findChildren<QWidget*>();
|
||||
// foreach (QWidget *widget, widgets)
|
||||
// widget->setMouseTracking(true);
|
||||
|
||||
ui->titleBar->setMouseTracking(true);
|
||||
ui->LTitle->setMouseTracking(true);
|
||||
|
|
Loading…
Reference in New Issue
Block a user