From af4623695c0b2f8c930435c9d0da871d1cce70da Mon Sep 17 00:00:00 2001 From: krepa098 Date: Sun, 10 Aug 2014 18:14:50 +0200 Subject: [PATCH 1/6] styling cleanup --- qtox.pro | 6 +- settings.cpp | 24 +++++ settings.h | 8 ++ style.cpp | 19 ++++ style.h | 14 +++ widget/form/chatform.cpp | 82 ++-------------- widget/widget.cpp | 207 ++++++++++++++++----------------------- 7 files changed, 160 insertions(+), 200 deletions(-) create mode 100644 style.cpp create mode 100644 style.h diff --git a/qtox.pro b/qtox.pro index 707599b6c..9f13b9176 100644 --- a/qtox.pro +++ b/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 diff --git a/settings.cpp b/settings.cpp index 2639731c5..83c85e63d 100644 --- a/settings.cpp +++ b/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; diff --git a/settings.h b/settings.h index 95e16620f..eafd2aa58 100644 --- a/settings.h +++ b/settings.h @@ -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; diff --git a/style.cpp b/style.cpp new file mode 100644 index 000000000..3a8cb1142 --- /dev/null +++ b/style.cpp @@ -0,0 +1,19 @@ +#include "style.h" +#include "settings.h" + +#include +#include + +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(); +} diff --git a/style.h b/style.h new file mode 100644 index 000000000..37ec89828 --- /dev/null +++ b/style.h @@ -0,0 +1,14 @@ +#ifndef STYLE_H +#define STYLE_H + +#include + +class Style +{ +public: + static QString get(const QString& filename); +private: + Style(); +}; + +#endif // STYLE_H diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 903a50d19..62ad56318 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -21,6 +21,7 @@ #include "widget/widget.h" #include "widget/filetransfertwidget.h" #include "widget/emoticonswidget.h" +#include "style.h" #include #include #include @@ -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); diff --git a/widget/widget.cpp b/widget/widget.cpp index 890b0447a..519d69d94 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -25,6 +25,7 @@ #include "group.h" #include "widget/groupwidget.h" #include "widget/form/groupchatform.h" +#include "style.h" #include #include #include @@ -45,98 +46,54 @@ 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(); + ui->titleBar->hide(); + layout()->setContentsMargins(0, 0, 0, 0); + ui->friendList->setObjectName("friendList"); + ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css")); - if (useNativeTheme) + setStyleSheet(Style::get(":ui/window/window.css")); + //ui->statusPanel->setStyleSheet(QString("")); + //ui->friendList->setStyleSheet(QString("")); + + ui->friendList->setObjectName("friendList"); + ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css")); + + ui->tbMenu->setIcon(QIcon(":ui/window/applicationIcon.png")); + ui->pbMin->setObjectName("minimizeButton"); + ui->pbMax->setObjectName("maximizeButton"); + ui->pbClose->setObjectName("closeButton"); + + if (!Settings::getInstance().getUseNativeDecoration()) { - 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) {} - 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("")); - - 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->tbMenu->setIcon(QIcon(":ui/window/applicationIcon.png")); - ui->pbMin->setObjectName("minimizeButton"); - ui->pbMax->setObjectName("maximizeButton"); - ui->pbClose->setObjectName("closeButton"); - setWindowFlags(Qt::CustomizeWindowHint); setWindowFlags(Qt::FramelessWindowHint); + } - addAction(ui->actionClose); + addAction(ui->actionClose); - connect(ui->pbMin, SIGNAL(clicked()), this, SLOT(minimizeBtnClicked())); - connect(ui->pbMax, SIGNAL(clicked()), this, SLOT(maximizeBtnClicked())); - connect(ui->pbClose, SIGNAL(clicked()), this, SLOT(close())); + connect(ui->pbMin, SIGNAL(clicked()), this, SLOT(minimizeBtnClicked())); + connect(ui->pbMax, SIGNAL(clicked()), this, SLOT(maximizeBtnClicked())); + connect(ui->pbClose, SIGNAL(clicked()), this, SLOT(close())); - m_titleMode = FullTitle; - moveWidget = false; - inResizeZone = false; - allowToResize = false; - resizeVerSup = false; - resizeHorEsq = false; - resizeDiagSupEsq = false; - resizeDiagSupDer = false; + m_titleMode = FullTitle; + moveWidget = false; + inResizeZone = false; + allowToResize = false; + resizeVerSup = false; + resizeHorEsq = false; + resizeDiagSupEsq = false; + resizeDiagSupDer = false; QSettings settings(Settings::getInstance().getSettingsDirPath() + '/' + "windowSettings.ini", QSettings::IniFormat); QRect geo = settings.value("geometry").toRect(); - if (geo.height() > 0 and geo.x() < QApplication::desktop()->width() and geo.width() > 0 and geo.y() < QApplication::desktop()->height()) - this->setGeometry(geo); + if (geo.height() > 0 and geo.x() < QApplication::desktop()->width() and geo.width() > 0 and geo.y() < QApplication::desktop()->height()) + this->setGeometry(geo); - if (settings.value("maximized").toBool()) - { - showMaximized(); - ui->pbMax->setObjectName("restoreButton"); - } - - QList widgets = this->findChildren(); - - foreach (QWidget *widget, widgets) - { - widget->setMouseTracking(true); - } + if (settings.value("maximized").toBool()) + { + showMaximized(); + ui->pbMax->setObjectName("restoreButton"); } isWindowMinimized = 0; @@ -174,11 +131,11 @@ Widget::Widget(QWidget *parent) : ui->statusButton->setMenu(statusButtonMenu); - this->setMouseTracking(true); +// this->setMouseTracking(true); - QList widgets = this->findChildren(); - foreach (QWidget *widget, widgets) - widget->setMouseTracking(true); +// QList widgets = this->findChildren(); +// foreach (QWidget *widget, widgets) +// widget->setMouseTracking(true); ui->titleBar->setMouseTracking(true); ui->LTitle->setMouseTracking(true); @@ -1116,47 +1073,47 @@ void Widget::setTitlebarMode(const TitleMode &flag) switch (m_titleMode) { - case CleanTitle: - ui->tbMenu->setHidden(true); - ui->pbMin->setHidden(true); - ui->pbMax->setHidden(true); - ui->pbClose->setHidden(true); - break; - case OnlyCloseButton: - ui->tbMenu->setHidden(true); - ui->pbMin->setHidden(true); - ui->pbMax->setHidden(true); - break; - case MenuOff: - ui->tbMenu->setHidden(true); - break; - case MaxMinOff: - ui->pbMin->setHidden(true); - ui->pbMax->setHidden(true); - break; - case FullScreenMode: - ui->pbMax->setHidden(true); - showMaximized(); - break; - case MaximizeModeOff: - ui->pbMax->setHidden(true); - break; - case MinimizeModeOff: - ui->pbMin->setHidden(true); - break; - case FullTitle: - ui->tbMenu->setVisible(true); - ui->pbMin->setVisible(true); - ui->pbMax->setVisible(true); - ui->pbClose->setVisible(true); - break; - break; - default: - ui->tbMenu->setVisible(true); - ui->pbMin->setVisible(true); - ui->pbMax->setVisible(true); - ui->pbClose->setVisible(true); - break; + case CleanTitle: + ui->tbMenu->setHidden(true); + ui->pbMin->setHidden(true); + ui->pbMax->setHidden(true); + ui->pbClose->setHidden(true); + break; + case OnlyCloseButton: + ui->tbMenu->setHidden(true); + ui->pbMin->setHidden(true); + ui->pbMax->setHidden(true); + break; + case MenuOff: + ui->tbMenu->setHidden(true); + break; + case MaxMinOff: + ui->pbMin->setHidden(true); + ui->pbMax->setHidden(true); + break; + case FullScreenMode: + ui->pbMax->setHidden(true); + showMaximized(); + break; + case MaximizeModeOff: + ui->pbMax->setHidden(true); + break; + case MinimizeModeOff: + ui->pbMin->setHidden(true); + break; + case FullTitle: + ui->tbMenu->setVisible(true); + ui->pbMin->setVisible(true); + ui->pbMax->setVisible(true); + ui->pbClose->setVisible(true); + break; + break; + default: + ui->tbMenu->setVisible(true); + ui->pbMin->setVisible(true); + ui->pbMax->setVisible(true); + ui->pbClose->setVisible(true); + break; } ui->LTitle->setVisible(true); } From 921b8478f64d471fa8c08541c1efe932bdb11fbf Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 11 Aug 2014 10:00:08 +0200 Subject: [PATCH 2/6] removed "the super ugly hack", Widget derives from QMainWindow --- mainwindow.ui | 3336 +++++++++++++++++++++++++++++++ qtox.pro | 9 +- settings.cpp | 24 + settings.h | 8 + style.cpp | 16 + style.h | 16 + widget.ui | 3341 -------------------------------- widget/adjustingscrollarea.cpp | 35 + widget/adjustingscrollarea.h | 35 + widget/form/addfriendform.cpp | 2 +- widget/form/addfriendform.h | 4 +- widget/form/chatform.cpp | 2 +- widget/form/chatform.h | 4 +- widget/form/filesform.cpp | 2 +- widget/form/filesform.h | 4 +- widget/form/groupchatform.cpp | 2 +- widget/form/groupchatform.h | 4 +- widget/form/settingsform.cpp | 2 +- widget/form/settingsform.h | 4 +- widget/friendwidget.cpp | 6 - widget/friendwidget.h | 1 - widget/groupwidget.cpp | 6 - widget/groupwidget.h | 6 +- widget/widget.cpp | 75 +- widget/widget.h | 15 +- 25 files changed, 3522 insertions(+), 3437 deletions(-) create mode 100644 mainwindow.ui delete mode 100644 widget.ui create mode 100644 widget/adjustingscrollarea.cpp create mode 100644 widget/adjustingscrollarea.h diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 000000000..c4a3e92d7 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,3336 @@ + + + MainWindow + + + + 0 + 0 + 882 + 600 + + + + + 640 + 420 + + + + qTox + + + + :/img/icon.png:/img/icon.png + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 23 + + + + + 16777215 + 23 + + + + + 4 + + + 5 + + + 0 + + + 1 + + + 0 + + + + + + 16 + 16 + + + + + 16 + 16 + + + + + 16 + 16 + + + + QToolButton::InstantPopup + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 15 + 1 + + + + + + + + + 100 + 22 + + + + + 16777215 + 22 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 134 + 20 + + + + + + + + + 22 + 22 + + + + + 22 + 22 + + + + + 22 + 22 + + + + true + + + + + + + + 22 + 22 + + + + + 22 + 22 + + + + + 22 + 22 + + + + true + + + + + + + + 22 + 22 + + + + + 22 + 22 + + + + + 22 + 22 + + + + true + + + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + true + + + false + + + QSplitter{ + color: rgb(255, 255, 255); + background-color: rgb(255, 255, 255); + alternate-background-color: rgb(255, 255, 255); + border-color: rgb(255, 255, 255); + gridline-color: rgb(255, 255, 255); + selection-color: rgb(255, 255, 255); + selection-background-color: rgb(255, 255, 255); +} +QSplitter:handle{ + color: rgb(255, 255, 255); + background-color: rgb(255, 255, 255); +} + + + Qt::Horizontal + + + false + + + + + 0 + 0 + + + + + 225 + 0 + + + + + 1920 + 16777215 + + + + + + + + + 255 + 255 + 255 + + + + + + + 28 + 28 + 28 + + + + + + + 42 + 42 + 42 + + + + + + + 35 + 35 + 35 + + + + + + + 14 + 14 + 14 + + + + + + + 18 + 18 + 18 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 28 + 28 + 28 + + + + + + + 0 + 0 + 0 + + + + + + + 14 + 14 + 14 + + + + + + + 28 + 28 + 28 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 28 + 28 + 28 + + + + + + + 42 + 42 + 42 + + + + + + + 35 + 35 + 35 + + + + + + + 14 + 14 + 14 + + + + + + + 18 + 18 + 18 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 28 + 28 + 28 + + + + + + + 0 + 0 + 0 + + + + + + + 14 + 14 + 14 + + + + + + + 28 + 28 + 28 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 14 + 14 + 14 + + + + + + + 28 + 28 + 28 + + + + + + + 42 + 42 + 42 + + + + + + + 35 + 35 + 35 + + + + + + + 14 + 14 + 14 + + + + + + + 18 + 18 + 18 + + + + + + + 14 + 14 + 14 + + + + + + + 255 + 255 + 255 + + + + + + + 14 + 14 + 14 + + + + + + + 28 + 28 + 28 + + + + + + + 28 + 28 + 28 + + + + + + + 0 + 0 + 0 + + + + + + + 28 + 28 + 28 + + + + + + + 28 + 28 + 28 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + true + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + true + + + + 0 + 0 + + + + + 225 + 60 + + + + + + + + + 255 + 255 + 255 + + + + + + + 28 + 28 + 28 + + + + + + + 42 + 42 + 42 + + + + + + + 35 + 35 + 35 + + + + + + + 14 + 14 + 14 + + + + + + + 18 + 18 + 18 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 28 + 28 + 28 + + + + + + + 0 + 0 + 0 + + + + + + + 14 + 14 + 14 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 28 + 28 + 28 + + + + + + + 42 + 42 + 42 + + + + + + + 35 + 35 + 35 + + + + + + + 14 + 14 + 14 + + + + + + + 18 + 18 + 18 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 28 + 28 + 28 + + + + + + + 0 + 0 + 0 + + + + + + + 14 + 14 + 14 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 14 + 14 + 14 + + + + + + + 28 + 28 + 28 + + + + + + + 42 + 42 + 42 + + + + + + + 35 + 35 + 35 + + + + + + + 14 + 14 + 14 + + + + + + + 18 + 18 + 18 + + + + + + + 14 + 14 + 14 + + + + + + + 255 + 255 + 255 + + + + + + + 14 + 14 + 14 + + + + + + + 28 + 28 + 28 + + + + + + + 28 + 28 + 28 + + + + + + + 0 + 0 + 0 + + + + + + + 28 + 28 + 28 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + true + + + + + + 0 + + + + + + 40 + 40 + + + + + 40 + 40 + + + + + + + :/img/contact.png + + + true + + + + + + + 0 + + + + + true + + + + 1 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 11 + 75 + true + + + + Your name + + + + + + + + 1 + 0 + + + + + + + + + 193 + 193 + 193 + + + + + + + 193 + 193 + 193 + + + + + + + + + 193 + 193 + 193 + + + + + + + 193 + 193 + 193 + + + + + + + + + 14 + 14 + 14 + + + + + + + 14 + 14 + 14 + + + + + + + + + 8 + + + + Your status + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + 0 + 0 + + + + + 20 + 40 + + + + Qt::NoFocus + + + + + + + 10 + 10 + + + + false + + + false + + + false + + + true + + + + + + + + + + + + + 0 + 0 + + + + + 225 + 0 + + + + Qt::LeftToRight + + + true + + + QFrame::NoFrame + + + Qt::ScrollBarAlwaysOff + + + true + + + + + 0 + 0 + 501 + 430 + + + + + + + + + true + + + + 0 + 0 + + + + + 225 + 35 + + + + + + + + + 255 + 255 + 255 + + + + + + + 28 + 28 + 28 + + + + + + + 42 + 42 + 42 + + + + + + + 35 + 35 + 35 + + + + + + + 14 + 14 + 14 + + + + + + + 18 + 18 + 18 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 28 + 28 + 28 + + + + + + + 0 + 0 + 0 + + + + + + + 14 + 14 + 14 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 28 + 28 + 28 + + + + + + + 42 + 42 + 42 + + + + + + + 35 + 35 + 35 + + + + + + + 14 + 14 + 14 + + + + + + + 18 + 18 + 18 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 28 + 28 + 28 + + + + + + + 0 + 0 + 0 + + + + + + + 14 + 14 + 14 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 14 + 14 + 14 + + + + + + + 28 + 28 + 28 + + + + + + + 42 + 42 + 42 + + + + + + + 35 + 35 + 35 + + + + + + + 14 + 14 + 14 + + + + + + + 18 + 18 + 18 + + + + + + + 14 + 14 + 14 + + + + + + + 255 + 255 + 255 + + + + + + + 14 + 14 + 14 + + + + + + + 28 + 28 + 28 + + + + + + + 28 + 28 + 28 + + + + + + + 0 + 0 + 0 + + + + + + + 28 + 28 + 28 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + true + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 55 + 35 + + + + + 55 + 35 + + + + Qt::NoFocus + + + Add friends + + + + + + + :/img/add.png:/img/add.png + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 500 + 20 + + + + + + + + + 55 + 35 + + + + Qt::NoFocus + + + Create a group chat + + + + + + + :/img/group.png:/img/group.png + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 500 + 20 + + + + + + + + + 55 + 35 + + + + + 55 + 35 + + + + Qt::NoFocus + + + View completed file transfers + + + + + + + :/img/transfer.png:/img/transfer.png + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 500 + 20 + + + + + + + + + 55 + 35 + + + + + 55 + 35 + + + + Qt::NoFocus + + + Change your settings + + + + + + + :/img/settings.png:/img/settings.png + + + true + + + + + + + + + + + + 1 + 0 + + + + + 375 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 127 + 127 + 127 + + + + + + + 170 + 170 + 170 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 127 + 127 + 127 + + + + + + + 170 + 170 + 170 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 127 + 127 + 127 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 127 + 127 + 127 + + + + + + + 170 + 170 + 170 + + + + + + + 127 + 127 + 127 + + + + + + + 255 + 255 + 255 + + + + + + + 127 + 127 + 127 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + true + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 60 + + + + + 16777215 + 60 + + + + true + + + + + + + + 0 + 1 + + + + + 16777215 + 1 + + + + + + + + + 193 + 193 + 193 + + + + + + + + + 193 + 193 + 193 + + + + + + + + + 127 + 127 + 127 + + + + + + + + QFrame::HLine + + + QFrame::Plain + + + + + + + + 0 + 0 + + + + + 375 + 0 + + + + + + + + + + + + + true + + + + 0 + 0 + 882 + 24 + + + + + + + Close + + + Ctrl+Q + + + + + + EditableLabelWidget + QLabel +
widget/tool/editablelabelwidget.h
+
+ + AdjustingScrollArea + QScrollArea +
widget/adjustingscrollarea.h
+ 1 +
+
+ + + + +
diff --git a/qtox.pro b/qtox.pro index 9f13b9176..1ebaad38f 100644 --- a/qtox.pro +++ b/qtox.pro @@ -25,7 +25,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = qtox TEMPLATE = app -FORMS += widget.ui +FORMS += \ + mainwindow.ui CONFIG += c++11 TRANSLATIONS = translations/de.ts \ @@ -86,7 +87,8 @@ HEADERS += widget/form/addfriendform.h \ widget/tool/clickablelabel.h \ smileypack.h \ widget/emoticonswidget.h \ - style.h + style.h \ + widget/adjustingscrollarea.h SOURCES += \ widget/form/addfriendform.cpp \ @@ -121,4 +123,5 @@ SOURCES += \ widget/tool/clickablelabel.cpp \ smileypack.cpp \ widget/emoticonswidget.cpp \ - style.cpp + style.cpp \ + widget/adjustingscrollarea.cpp diff --git a/settings.cpp b/settings.cpp index 83c85e63d..19e9e1f93 100644 --- a/settings.cpp +++ b/settings.cpp @@ -104,6 +104,8 @@ void Settings::load() minimizeOnClose = s.value("minimizeOnClose", false).toBool(); useNativeStyle = s.value("nativeStyle", false).toBool(); useNativeDecoration = s.value("nativeDecoration", true).toBool(); + windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray(); + windowState = s.value("windowState", QByteArray()).toByteArray(); s.endGroup(); s.beginGroup("Privacy"); @@ -162,6 +164,8 @@ void Settings::save(QString path) s.setValue("minimizeOnClose", minimizeOnClose); s.setValue("nativeStyle", useNativeStyle); s.setValue("nativeDecoration", useNativeDecoration); + s.setValue("windowGeometry", windowGeometry); + s.setValue("windowState", windowState); s.endGroup(); s.beginGroup("Privacy"); @@ -359,6 +363,26 @@ void Settings::setUseNativeDecoration(bool value) useNativeDecoration = value; } +QByteArray Settings::getWindowGeometry() const +{ + return windowGeometry; +} + +void Settings::setWindowGeometry(const QByteArray &value) +{ + windowGeometry = value; +} + +QByteArray Settings::getWindowState() const +{ + return windowState; +} + +void Settings::setWindowState(const QByteArray &value) +{ + windowState = value; +} + bool Settings::isMinimizeOnCloseEnabled() const { return minimizeOnClose; diff --git a/settings.h b/settings.h index eafd2aa58..a514350d5 100644 --- a/settings.h +++ b/settings.h @@ -118,6 +118,12 @@ public: bool getUseNativeDecoration() const; void setUseNativeDecoration(bool value); + QByteArray getWindowGeometry() const; + void setWindowGeometry(const QByteArray &value); + + QByteArray getWindowState() const; + void setWindowState(const QByteArray &value); + private: Settings(); Settings(Settings &settings) = delete; @@ -155,6 +161,8 @@ private: bool minimizeOnClose; bool useNativeStyle; bool useNativeDecoration; + QByteArray windowGeometry; + QByteArray windowState; // ChatView int firstColumnHandlePos; diff --git a/style.cpp b/style.cpp index 3a8cb1142..609dcc277 100644 --- a/style.cpp +++ b/style.cpp @@ -1,3 +1,19 @@ +/* + Copyright (C) 2014 by Project Tox + + This file is part of qTox, a Qt-based graphical interface for Tox. + + This program 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. + This program 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 COPYING file for more details. +*/ + #include "style.h" #include "settings.h" diff --git a/style.h b/style.h index 37ec89828..77a09ce25 100644 --- a/style.h +++ b/style.h @@ -1,3 +1,19 @@ +/* + Copyright (C) 2014 by Project Tox + + This file is part of qTox, a Qt-based graphical interface for Tox. + + This program 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. + This program 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 COPYING file for more details. +*/ + #ifndef STYLE_H #define STYLE_H diff --git a/widget.ui b/widget.ui deleted file mode 100644 index 3fd6e03bd..000000000 --- a/widget.ui +++ /dev/null @@ -1,3341 +0,0 @@ - - - Widget - - - - 0 - 0 - 640 - 420 - - - - - 640 - 420 - - - - - 16777215 - 16777215 - - - - Tox - - - - :/img/icon.png:/img/icon.png - - - - 2 - - - 1 - - - 2 - - - 2 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 23 - - - - - 16777215 - 23 - - - - - 4 - - - 5 - - - 0 - - - 1 - - - 0 - - - - - - 16 - 16 - - - - - 16 - 16 - - - - - 16 - 16 - - - - QToolButton::InstantPopup - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 15 - 1 - - - - - - - - - 100 - 22 - - - - - 16777215 - 22 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 134 - 20 - - - - - - - - - 22 - 22 - - - - - 22 - 22 - - - - - 22 - 22 - - - - true - - - - - - - - 22 - 22 - - - - - 22 - 22 - - - - - 22 - 22 - - - - true - - - - - - - - 22 - 22 - - - - - 22 - 22 - - - - - 22 - 22 - - - - true - - - - - - - - - - - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - true - - - false - - - QSplitter{ - color: rgb(255, 255, 255); - background-color: rgb(255, 255, 255); - alternate-background-color: rgb(255, 255, 255); - border-color: rgb(255, 255, 255); - gridline-color: rgb(255, 255, 255); - selection-color: rgb(255, 255, 255); - selection-background-color: rgb(255, 255, 255); -} -QSplitter:handle{ - color: rgb(255, 255, 255); - background-color: rgb(255, 255, 255); -} - - - Qt::Horizontal - - - false - - - - - 0 - 0 - - - - - 225 - 0 - - - - - 1920 - 16777215 - - - - - - - - - 255 - 255 - 255 - - - - - - - 28 - 28 - 28 - - - - - - - 42 - 42 - 42 - - - - - - - 35 - 35 - 35 - - - - - - - 14 - 14 - 14 - - - - - - - 18 - 18 - 18 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - 14 - 14 - 14 - - - - - - - 28 - 28 - 28 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 28 - 28 - 28 - - - - - - - 42 - 42 - 42 - - - - - - - 35 - 35 - 35 - - - - - - - 14 - 14 - 14 - - - - - - - 18 - 18 - 18 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - 14 - 14 - 14 - - - - - - - 28 - 28 - 28 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 14 - 14 - 14 - - - - - - - 28 - 28 - 28 - - - - - - - 42 - 42 - 42 - - - - - - - 35 - 35 - 35 - - - - - - - 14 - 14 - 14 - - - - - - - 18 - 18 - 18 - - - - - - - 14 - 14 - 14 - - - - - - - 255 - 255 - 255 - - - - - - - 14 - 14 - 14 - - - - - - - 28 - 28 - 28 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 28 - 28 - 28 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - true - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - true - - - - 0 - 0 - - - - - 225 - 60 - - - - - - - - - 255 - 255 - 255 - - - - - - - 28 - 28 - 28 - - - - - - - 42 - 42 - 42 - - - - - - - 35 - 35 - 35 - - - - - - - 14 - 14 - 14 - - - - - - - 18 - 18 - 18 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - 14 - 14 - 14 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 28 - 28 - 28 - - - - - - - 42 - 42 - 42 - - - - - - - 35 - 35 - 35 - - - - - - - 14 - 14 - 14 - - - - - - - 18 - 18 - 18 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - 14 - 14 - 14 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 14 - 14 - 14 - - - - - - - 28 - 28 - 28 - - - - - - - 42 - 42 - 42 - - - - - - - 35 - 35 - 35 - - - - - - - 14 - 14 - 14 - - - - - - - 18 - 18 - 18 - - - - - - - 14 - 14 - 14 - - - - - - - 255 - 255 - 255 - - - - - - - 14 - 14 - 14 - - - - - - - 28 - 28 - 28 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - true - - - - - - 0 - - - - - - 40 - 40 - - - - - 40 - 40 - - - - - - - :/img/contact.png - - - true - - - - - - - 0 - - - - - true - - - - 1 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 11 - 75 - true - - - - Your name - - - - - - - - 1 - 0 - - - - - - - - - 193 - 193 - 193 - - - - - - - 193 - 193 - 193 - - - - - - - - - 193 - 193 - 193 - - - - - - - 193 - 193 - 193 - - - - - - - - - 14 - 14 - 14 - - - - - - - 14 - 14 - 14 - - - - - - - - - 8 - - - - Your status - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - - 20 - 40 - - - - Qt::NoFocus - - - - - - - 10 - 10 - - - - false - - - false - - - false - - - true - - - - - - - - - - - - - 0 - 0 - - - - - 225 - 0 - - - - Qt::RightToLeft - - - true - - - QFrame::NoFrame - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 255 - 299 - - - - - - - - - true - - - - 0 - 0 - - - - - 225 - 35 - - - - - - - - - 255 - 255 - 255 - - - - - - - 28 - 28 - 28 - - - - - - - 42 - 42 - 42 - - - - - - - 35 - 35 - 35 - - - - - - - 14 - 14 - 14 - - - - - - - 18 - 18 - 18 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - 14 - 14 - 14 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 28 - 28 - 28 - - - - - - - 42 - 42 - 42 - - - - - - - 35 - 35 - 35 - - - - - - - 14 - 14 - 14 - - - - - - - 18 - 18 - 18 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - 14 - 14 - 14 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 14 - 14 - 14 - - - - - - - 28 - 28 - 28 - - - - - - - 42 - 42 - 42 - - - - - - - 35 - 35 - 35 - - - - - - - 14 - 14 - 14 - - - - - - - 18 - 18 - 18 - - - - - - - 14 - 14 - 14 - - - - - - - 255 - 255 - 255 - - - - - - - 14 - 14 - 14 - - - - - - - 28 - 28 - 28 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - true - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 55 - 35 - - - - - 55 - 35 - - - - Qt::NoFocus - - - Add friends - - - - - - - :/img/add.png:/img/add.png - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Maximum - - - - 500 - 20 - - - - - - - - - 55 - 35 - - - - Qt::NoFocus - - - Create a group chat - - - - - - - :/img/group.png:/img/group.png - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Maximum - - - - 500 - 20 - - - - - - - - - 55 - 35 - - - - - 55 - 35 - - - - Qt::NoFocus - - - View completed file transfers - - - - - - - :/img/transfer.png:/img/transfer.png - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Maximum - - - - 500 - 20 - - - - - - - - - 55 - 35 - - - - - 55 - 35 - - - - Qt::NoFocus - - - Change your settings - - - - - - - :/img/settings.png:/img/settings.png - - - true - - - - - - - - - - - - 1 - 0 - - - - - 375 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 127 - - - - - - - 170 - 170 - 170 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 127 - - - - - - - 170 - 170 - 170 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 127 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 127 - - - - - - - 170 - 170 - 170 - - - - - - - 127 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 127 - 127 - 127 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - true - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 60 - - - - - 16777215 - 60 - - - - true - - - - - - - - 0 - 1 - - - - - 16777215 - 1 - - - - - - - - - 193 - 193 - 193 - - - - - - - - - 193 - 193 - 193 - - - - - - - - - 127 - 127 - 127 - - - - - - - - QFrame::HLine - - - QFrame::Plain - - - - - - - - 0 - 0 - - - - - 375 - 0 - - - - - - - - - - - - Close - - - Ctrl+Q - - - - - - - EditableLabelWidget - QLabel -
widget/tool/editablelabelwidget.h
-
-
- - - - - - actionClose - triggered() - Widget - close() - - - -1 - -1 - - - 69 - 61 - - - - -
diff --git a/widget/adjustingscrollarea.cpp b/widget/adjustingscrollarea.cpp new file mode 100644 index 000000000..02e5b8746 --- /dev/null +++ b/widget/adjustingscrollarea.cpp @@ -0,0 +1,35 @@ +/* + Copyright (C) 2014 by Project Tox + + This file is part of qTox, a Qt-based graphical interface for Tox. + + This program 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. + This program 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 COPYING file for more details. +*/ + +#include "adjustingscrollarea.h" + +#include +#include + +AdjustingScrollArea::AdjustingScrollArea(QWidget *parent) : + QScrollArea(parent) +{ +} + +void AdjustingScrollArea::resizeEvent(QResizeEvent *ev) +{ + if (widget()) + { + widget()->setMinimumWidth(width()); + } + + QScrollArea::resizeEvent(ev); +} diff --git a/widget/adjustingscrollarea.h b/widget/adjustingscrollarea.h new file mode 100644 index 000000000..de6a85ac3 --- /dev/null +++ b/widget/adjustingscrollarea.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2014 by Project Tox + + This file is part of qTox, a Qt-based graphical interface for Tox. + + This program 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. + This program 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 COPYING file for more details. +*/ + +#ifndef ADJUSTINGSCROLLAREA_H +#define ADJUSTINGSCROLLAREA_H + +#include + +class AdjustingScrollArea : public QScrollArea +{ + Q_OBJECT +public: + explicit AdjustingScrollArea(QWidget *parent = 0); + + virtual void resizeEvent(QResizeEvent *ev); +signals: + +public slots: + +}; + +#endif // ADJUSTINGSCROLLAREA_H diff --git a/widget/form/addfriendform.cpp b/widget/form/addfriendform.cpp index d83e9b5b3..9d09e0682 100644 --- a/widget/form/addfriendform.cpp +++ b/widget/form/addfriendform.cpp @@ -57,7 +57,7 @@ AddFriendForm::~AddFriendForm() main->deleteLater(); } -void AddFriendForm::show(Ui::Widget &ui) +void AddFriendForm::show(Ui::MainWindow &ui) { ui.mainContent->layout()->addWidget(main); ui.mainHead->layout()->addWidget(head); diff --git a/widget/form/addfriendform.h b/widget/form/addfriendform.h index 7f2263827..0edcf2214 100644 --- a/widget/form/addfriendform.h +++ b/widget/form/addfriendform.h @@ -17,7 +17,7 @@ #ifndef ADDFRIENDFORM_H #define ADDFRIENDFORM_H -#include "ui_widget.h" +#include "ui_mainwindow.h" #include #include @@ -33,7 +33,7 @@ public: AddFriendForm(); ~AddFriendForm(); - void show(Ui::Widget& ui); + void show(Ui::MainWindow &ui); bool isToxId(const QString& value) const; void showWarning(const QString& message) const; QString getMessage() const; diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 62ad56318..f5c1487a8 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -137,7 +137,7 @@ ChatForm::~ChatForm() delete netcam; } -void ChatForm::show(Ui::Widget &ui) +void ChatForm::show(Ui::MainWindow &ui) { ui.mainContent->layout()->addWidget(main); ui.mainHead->layout()->addWidget(head); diff --git a/widget/form/chatform.h b/widget/form/chatform.h index 064e05b29..3354629d6 100644 --- a/widget/form/chatform.h +++ b/widget/form/chatform.h @@ -28,7 +28,7 @@ #include #include "widget/tool/chattextedit.h" -#include "ui_widget.h" +#include "ui_mainwindow.h" #include "core.h" #include "widget/netcamview.h" @@ -43,7 +43,7 @@ class ChatForm : public QObject public: ChatForm(Friend* chatFriend); ~ChatForm(); - void show(Ui::Widget& ui); + void show(Ui::MainWindow &ui); void setName(QString newName); void setStatusMessage(QString newMessage); void addFriendMessage(QString message); diff --git a/widget/form/filesform.cpp b/widget/form/filesform.cpp index 14ffe5fe0..6d69c1f5a 100644 --- a/widget/form/filesform.cpp +++ b/widget/form/filesform.cpp @@ -50,7 +50,7 @@ FilesForm::~FilesForm() // I'm not too bummed about removing it } -void FilesForm::show(Ui::Widget& ui) +void FilesForm::show(Ui::MainWindow& ui) { ui.mainContent->layout()->addWidget(&main); ui.mainHead->layout()->addWidget(head); diff --git a/widget/form/filesform.h b/widget/form/filesform.h index f8fb51105..0f1a2b1d8 100644 --- a/widget/form/filesform.h +++ b/widget/form/filesform.h @@ -17,7 +17,7 @@ #ifndef FILESFORM_H #define FILESFORM_H -#include "ui_widget.h" +#include "ui_mainwindow.h" #include #include @@ -37,7 +37,7 @@ public: FilesForm(); ~FilesForm(); - void show(Ui::Widget& ui); + void show(Ui::MainWindow &ui); public slots: void onFileDownloadComplete(const QString& path); diff --git a/widget/form/groupchatform.cpp b/widget/form/groupchatform.cpp index f3f12afcf..919c457d7 100644 --- a/widget/form/groupchatform.cpp +++ b/widget/form/groupchatform.cpp @@ -142,7 +142,7 @@ GroupChatForm::~GroupChatForm() delete main; } -void GroupChatForm::show(Ui::Widget &ui) +void GroupChatForm::show(Ui::MainWindow &ui) { ui.mainContent->layout()->addWidget(main); ui.mainHead->layout()->addWidget(head); diff --git a/widget/form/groupchatform.h b/widget/form/groupchatform.h index b4ac9a5ce..af008476a 100644 --- a/widget/form/groupchatform.h +++ b/widget/form/groupchatform.h @@ -27,7 +27,7 @@ #include #include "widget/tool/chattextedit.h" -#include "ui_widget.h" +#include "ui_mainwindow.h" // Spacing in px inserted when the author of the last message changes #define AUTHOR_CHANGE_SPACING 5 @@ -40,7 +40,7 @@ class GroupChatForm : public QObject public: GroupChatForm(Group* chatGroup); ~GroupChatForm(); - void show(Ui::Widget& ui); + void show(Ui::MainWindow &ui); void setName(QString newName); void addGroupMessage(QString message, int peerId); void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm")); diff --git a/widget/form/settingsform.cpp b/widget/form/settingsform.cpp index 822cae675..193fac4a1 100644 --- a/widget/form/settingsform.cpp +++ b/widget/form/settingsform.cpp @@ -93,7 +93,7 @@ void SettingsForm::setFriendAddress(const QString& friendAddress) id.setText(friendAddress); } -void SettingsForm::show(Ui::Widget &ui) +void SettingsForm::show(Ui::MainWindow &ui) { name.setText(ui.nameLabel->text()); statusText.setText(ui.statusLabel->text()); diff --git a/widget/form/settingsform.h b/widget/form/settingsform.h index db5a395cf..0c8f59ee4 100644 --- a/widget/form/settingsform.h +++ b/widget/form/settingsform.h @@ -28,7 +28,7 @@ #include #include #include "widget/tool/clickablelabel.h" -#include "ui_widget.h" +#include "ui_mainwindow.h" #include "widget/selfcamview.h" class SettingsForm : public QObject @@ -38,7 +38,7 @@ public: SettingsForm(); ~SettingsForm(); - void show(Ui::Widget& ui); + void show(Ui::MainWindow &ui); public slots: void setFriendAddress(const QString& friendAddress); diff --git a/widget/friendwidget.cpp b/widget/friendwidget.cpp index 845bf816c..a430288a0 100644 --- a/widget/friendwidget.cpp +++ b/widget/friendwidget.cpp @@ -27,7 +27,6 @@ FriendWidget::FriendWidget(int FriendId, QString id) { this->setMouseTracking(true); this->setAutoFillBackground(true); - this->setFixedWidth(225); this->setFixedHeight(55); this->setLayout(&layout); layout.setSpacing(0); @@ -70,11 +69,6 @@ FriendWidget::FriendWidget(int FriendId, QString id) isActiveWidget = 0; } -void FriendWidget::setNewFixedWidth(int newWidth) -{ - this->setFixedWidth(newWidth); -} - void FriendWidget::mouseReleaseEvent (QMouseEvent*) { emit friendWidgetClicked(this); diff --git a/widget/friendwidget.h b/widget/friendwidget.h index 091f78c69..6afcdc1aa 100644 --- a/widget/friendwidget.h +++ b/widget/friendwidget.h @@ -34,7 +34,6 @@ public: void leaveEvent(QEvent* event); void setAsActiveChatroom(); void setAsInactiveChatroom(); - void setNewFixedWidth(int newWidth); signals: void friendWidgetClicked(FriendWidget* widget); diff --git a/widget/groupwidget.cpp b/widget/groupwidget.cpp index 6eb995031..7a138e28a 100644 --- a/widget/groupwidget.cpp +++ b/widget/groupwidget.cpp @@ -27,7 +27,6 @@ GroupWidget::GroupWidget(int GroupId, QString Name) this->setMouseTracking(true); this->setAutoFillBackground(true); this->setLayout(&layout); - this->setFixedWidth(225); this->setFixedHeight(55); layout.setSpacing(0); layout.setMargin(0); @@ -72,11 +71,6 @@ GroupWidget::GroupWidget(int GroupId, QString Name) isActiveWidget = 0; } -void GroupWidget::setNewFixedWidth(int newWidth) -{ - this->setFixedWidth(newWidth); -} - void GroupWidget::mouseReleaseEvent (QMouseEvent*) { emit groupWidgetClicked(this); diff --git a/widget/groupwidget.h b/widget/groupwidget.h index fe66a2371..ab2cf8929 100644 --- a/widget/groupwidget.h +++ b/widget/groupwidget.h @@ -33,7 +33,8 @@ public: void contextMenuEvent(QContextMenuEvent * event); void enterEvent(QEvent* event); void leaveEvent(QEvent* event); - + void setAsInactiveChatroom(); + void setAsActiveChatroom(); signals: void groupWidgetClicked(GroupWidget* widget); @@ -44,9 +45,6 @@ public: QLabel avatar, name, nusers, statusPic; QHBoxLayout layout; QVBoxLayout textLayout; - void setAsInactiveChatroom(); - void setAsActiveChatroom(); - void setNewFixedWidth(int newWidth); private: QColor lastColor; diff --git a/widget/widget.cpp b/widget/widget.cpp index 519d69d94..c7d6eda88 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -15,7 +15,7 @@ */ #include "widget.h" -#include "ui_widget.h" +#include "ui_mainwindow.h" #include "settings.h" #include "friend.h" #include "friendlist.h" @@ -41,11 +41,21 @@ Widget *Widget::instance{nullptr}; -Widget::Widget(QWidget *parent) : - QWidget(parent), ui(new Ui::Widget), activeFriendWidget{nullptr}, activeGroupWidget{nullptr} +Widget::Widget(QWidget *parent) + : QMainWindow(parent), + ui(new Ui::MainWindow), + activeFriendWidget{nullptr}, + activeGroupWidget{nullptr} { ui->setupUi(this); + ui->statusbar->hide(); + ui->menubar->hide(); + + //restore window state + restoreGeometry(Settings::getInstance().getWindowGeometry()); + restoreState(Settings::getInstance().getWindowState()); + ui->titleBar->hide(); layout()->setContentsMargins(0, 0, 0, 0); ui->friendList->setObjectName("friendList"); @@ -84,29 +94,17 @@ Widget::Widget(QWidget *parent) : resizeDiagSupEsq = false; resizeDiagSupDer = false; - QSettings settings(Settings::getInstance().getSettingsDirPath() + '/' + "windowSettings.ini", QSettings::IniFormat); - QRect geo = settings.value("geometry").toRect(); - - if (geo.height() > 0 and geo.x() < QApplication::desktop()->width() and geo.width() > 0 and geo.y() < QApplication::desktop()->height()) - this->setGeometry(geo); - - if (settings.value("maximized").toBool()) - { - showMaximized(); - ui->pbMax->setObjectName("restoreButton"); - } - isWindowMinimized = 0; ui->mainContent->setLayout(new QVBoxLayout()); ui->mainHead->setLayout(new QVBoxLayout()); ui->mainHead->layout()->setMargin(0); ui->mainHead->layout()->setSpacing(0); + QWidget* friendListWidget = new QWidget(); friendListWidget->setLayout(new QVBoxLayout()); friendListWidget->layout()->setSpacing(0); friendListWidget->layout()->setMargin(0); - friendListWidget->setLayoutDirection(Qt::LeftToRight); ui->friendList->setWidget(friendListWidget); // delay setting username and message until Core inits @@ -116,10 +114,7 @@ Widget::Widget(QWidget *parent) : ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}"); ui->friendList->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - QFile f1(":/ui/statusButton/statusButton.css"); - f1.open(QFile::ReadOnly | QFile::Text); - QTextStream statusButtonStylesheetStream(&f1); - ui->statusButton->setStyleSheet(statusButtonStylesheetStream.readAll()); + ui->statusButton->setStyleSheet(Style::get(":/ui/statusButton/statusButton.css")); QMenu *statusButtonMenu = new QMenu(ui->statusButton); QAction* setStatusOnline = statusButtonMenu->addAction(tr("Online","Button to set your status to 'Online'")); @@ -147,9 +142,9 @@ Widget::Widget(QWidget *parent) : ui->friendList->viewport()->installEventFilter(this); - QList currentSizes = ui->centralWidget->sizes(); - currentSizes[0] = 225; - ui->centralWidget->setSizes(currentSizes); +// QList currentSizes = ui->centralWidget->sizes(); +// currentSizes[0] = 225; +// ui->centralWidget->setSizes(currentSizes); ui->statusButton->setObjectName("offline"); ui->statusButton->style()->polish(ui->statusButton); @@ -198,7 +193,6 @@ Widget::Widget(QWidget *parent) : connect(this, &Widget::friendRequested, core, &Core::requestFriendship); connect(this, &Widget::friendRequestAccepted, core, &Core::acceptFriendRequest); - connect(ui->centralWidget, SIGNAL(splitterMoved(int,int)),this, SLOT(splitterMoved(int,int))); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(onAddClicked())); connect(ui->groupButton, SIGNAL(clicked()), this, SLOT(onGroupClicked())); connect(ui->transferButton, SIGNAL(clicked()), this, SLOT(onTransferClicked())); @@ -236,10 +230,6 @@ Widget::~Widget() for (Group* g : GroupList::groupList) delete g; GroupList::groupList.clear(); - QSettings settings(Settings::getInstance().getSettingsDirPath() + '/' + "windowSettings.ini", QSettings::IniFormat); - settings.setValue("geometry", geometry()); - settings.setValue("maximized", isMaximized()); - settings.setValue("useNativeTheme", useNativeTheme); delete ui; } @@ -250,27 +240,16 @@ Widget* Widget::getInstance() return instance; } -//Super ugly hack to enable resizable friend widgets -//There should be a way to set them to resize automagicly, but I can't seem to find it. -void Widget::splitterMoved(int, int) -{ - updateFriendListWidth(); -} - QThread* Widget::getCoreThread() { return coreThread; } -void Widget::updateFriendListWidth() +void Widget::closeEvent(QCloseEvent *event) { - int newWidth = ui->friendList->width(); - for (Friend* f : FriendList::friendList) - if (f->widget != nullptr) - f->widget->setNewFixedWidth(newWidth); - for (Group* g : GroupList::groupList) - if (g->widget != nullptr) - g->widget->setNewFixedWidth(newWidth); + Settings::getInstance().setWindowGeometry(saveGeometry()); + Settings::getInstance().setWindowState(saveState()); + QWidget::closeEvent(event); } QString Widget::getUsername() @@ -432,7 +411,6 @@ void Widget::addFriend(int friendId, const QString &userId) QWidget* widget = ui->friendList->widget(); QLayout* layout = widget->layout(); layout->addWidget(newfriend->widget); - updateFriendListWidth(); connect(newfriend->widget, SIGNAL(friendWidgetClicked(FriendWidget*)), this, SLOT(onFriendWidgetClicked(FriendWidget*))); connect(newfriend->widget, SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int))); connect(newfriend->widget, SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int))); @@ -736,7 +714,7 @@ Group *Widget::createGroup(int groupId) layout->addWidget(newgroup->widget); if (!useNativeTheme) newgroup->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png")); - updateFriendListWidth(); + connect(newgroup->widget, SIGNAL(groupWidgetClicked(GroupWidget*)), this, SLOT(onGroupWidgetClicked(GroupWidget*))); connect(newgroup->widget, SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int))); connect(newgroup->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendGroupMessage(int,QString))); @@ -768,12 +746,6 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f) return true; } -void Widget::resizeEvent(QResizeEvent *) -{ - updateFriendListWidth(); -} - - bool Widget::event(QEvent * e) { @@ -944,7 +916,6 @@ void Widget::moveWindow(QMouseEvent *e) void Widget::resizeWindow(QMouseEvent *e) { - updateFriendListWidth(); if (!useNativeTheme) { if (allowToResize) diff --git a/widget/widget.h b/widget/widget.h index 9db9057b5..0980cff69 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -18,7 +18,7 @@ #define WIDGET_H #include -#include +#include #include #include #include @@ -31,7 +31,7 @@ #define PIXELS_TO_ACT 7 namespace Ui { -class Widget; +class MainWindow; } class GroupWidget; @@ -39,7 +39,7 @@ struct FriendWidget; class Group; struct Friend; -class Widget : public QWidget +class Widget : public QMainWindow { Q_OBJECT @@ -60,7 +60,8 @@ public: void updateFriendStatusLights(int friendId); int useNativeTheme; ~Widget(); - void updateFriendListWidth(); + + virtual void closeEvent(QCloseEvent *event); signals: void friendRequestAccepted(const QString& userId); @@ -70,9 +71,6 @@ signals: void usernameChanged(const QString& username); void statusMessageChanged(const QString& statusMessage); -protected: - void resizeEvent(QResizeEvent *); - private slots: void maximizeBtnClicked(); void minimizeBtnClicked(); @@ -108,7 +106,6 @@ private slots: void removeFriend(int friendId); void copyFriendIdToClipboard(int friendId); void removeGroup(int groupId); - void splitterMoved(int pos, int index); void setStatusOnline(); void setStatusAway(); void setStatusBusy(); @@ -121,7 +118,7 @@ private: Group* createGroup(int groupId); private: - Ui::Widget *ui; + Ui::MainWindow *ui; QSplitter *centralLayout; QPoint dragPosition; TitleMode m_titleMode; From c9d04748dd38278a15456cf8048153d6afd598e1 Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 11 Aug 2014 13:56:52 +0200 Subject: [PATCH 3/6] put back the not so native window decoration, status panel respects friendlist width, some tweaks to the layout --- mainwindow.ui | 112 ++++++------------------------ widget/adjustingscrollarea.cpp | 16 +++-- widget/adjustingscrollarea.h | 1 + widget/friendwidget.cpp | 11 +++ widget/widget.cpp | 120 +++++++++++++++++---------------- widget/widget.h | 1 - 6 files changed, 104 insertions(+), 157 deletions(-) diff --git a/mainwindow.ui b/mainwindow.ui index c4a3e92d7..3509b23d6 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 882 - 600 + 716 + 543 @@ -232,6 +232,12 @@ 0 + + + 16777215 + 16777215 + + @@ -536,6 +542,9 @@ QSplitter:handle{ Qt::Horizontal + + 6 + false @@ -546,18 +555,6 @@ QSplitter:handle{ 0 - - - 225 - 0 - - - - - 1920 - 16777215 - - @@ -1030,12 +1027,6 @@ QSplitter:handle{ 0 - - - 225 - 60 - - @@ -2076,17 +2067,11 @@ QSplitter:handle{ - + 0 0 - - - 225 - 0 - - Qt::LeftToRight @@ -2107,10 +2092,11 @@ QSplitter:handle{ 0 0 - 501 - 430 + 335 + 379 + @@ -2120,17 +2106,11 @@ QSplitter:handle{ true - + 0 0 - - - 225 - 35 - - @@ -2597,22 +2577,6 @@ QSplitter:handle{ - - - - Qt::Horizontal - - - QSizePolicy::Maximum - - - - 500 - 20 - - - - @@ -2639,22 +2603,6 @@ QSplitter:handle{ - - - - Qt::Horizontal - - - QSizePolicy::Maximum - - - - 500 - 20 - - - - @@ -2687,22 +2635,6 @@ QSplitter:handle{ - - - - Qt::Horizontal - - - QSizePolicy::Maximum - - - - 500 - 20 - - - - @@ -2742,17 +2674,11 @@ QSplitter:handle{ - - 1 + + 0 0 - - - 375 - 0 - - @@ -3301,7 +3227,7 @@ QSplitter:handle{ 0 0 - 882 + 716 24 diff --git a/widget/adjustingscrollarea.cpp b/widget/adjustingscrollarea.cpp index 02e5b8746..f83db5024 100644 --- a/widget/adjustingscrollarea.cpp +++ b/widget/adjustingscrollarea.cpp @@ -18,18 +18,24 @@ #include #include +#include AdjustingScrollArea::AdjustingScrollArea(QWidget *parent) : QScrollArea(parent) { + } void AdjustingScrollArea::resizeEvent(QResizeEvent *ev) { - if (widget()) - { - widget()->setMinimumWidth(width()); - } - + updateGeometry(); QScrollArea::resizeEvent(ev); } + +QSize AdjustingScrollArea::sizeHint() const +{ + if (widget()) + return widget()->sizeHint(); + + return QScrollArea::sizeHint(); +} diff --git a/widget/adjustingscrollarea.h b/widget/adjustingscrollarea.h index de6a85ac3..a1645cbba 100644 --- a/widget/adjustingscrollarea.h +++ b/widget/adjustingscrollarea.h @@ -26,6 +26,7 @@ public: explicit AdjustingScrollArea(QWidget *parent = 0); virtual void resizeEvent(QResizeEvent *ev); + virtual QSize sizeHint() const override; signals: public slots: diff --git a/widget/friendwidget.cpp b/widget/friendwidget.cpp index a430288a0..782e541fd 100644 --- a/widget/friendwidget.cpp +++ b/widget/friendwidget.cpp @@ -25,6 +25,7 @@ FriendWidget::FriendWidget(int FriendId, QString id) : friendId(FriendId) { + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); this->setMouseTracking(true); this->setAutoFillBackground(true); this->setFixedHeight(55); @@ -52,6 +53,9 @@ FriendWidget::FriendWidget(int FriendId, QString id) pal3.setColor(QPalette::Background, QColor(65,65,65,255)); this->setPalette(pal3); + name.setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + statusMessage.setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + textLayout.addStretch(); textLayout.addWidget(&name); textLayout.addWidget(&statusMessage); @@ -67,6 +71,13 @@ FriendWidget::FriendWidget(int FriendId, QString id) layout.addSpacing(5); isActiveWidget = 0; + + layout.invalidate(); + layout.update(); + layout.activate(); + updateGeometry(); + + qDebug() << "friend" << minimumSizeHint(); } void FriendWidget::mouseReleaseEvent (QMouseEvent*) diff --git a/widget/widget.cpp b/widget/widget.cpp index c7d6eda88..e9281a891 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -56,44 +56,54 @@ Widget::Widget(QWidget *parent) restoreGeometry(Settings::getInstance().getWindowGeometry()); restoreState(Settings::getInstance().getWindowState()); - ui->titleBar->hide(); - layout()->setContentsMargins(0, 0, 0, 0); - ui->friendList->setObjectName("friendList"); - ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css")); - - setStyleSheet(Style::get(":ui/window/window.css")); - //ui->statusPanel->setStyleSheet(QString("")); - //ui->friendList->setStyleSheet(QString("")); - - ui->friendList->setObjectName("friendList"); - ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css")); - - ui->tbMenu->setIcon(QIcon(":ui/window/applicationIcon.png")); - ui->pbMin->setObjectName("minimizeButton"); - ui->pbMax->setObjectName("maximizeButton"); - ui->pbClose->setObjectName("closeButton"); - - if (!Settings::getInstance().getUseNativeDecoration()) + if (Settings::getInstance().getUseNativeDecoration()) { + ui->titleBar->hide(); + this->layout()->setContentsMargins(0, 0, 0, 0); + + ui->friendList->setObjectName("friendList"); + ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css")); + } + else + { + this->setObjectName("activeWindow"); + this->setStyleSheet(Style::get(":ui/window/window.css")); + ui->statusPanel->setStyleSheet(QString("")); + ui->friendList->setStyleSheet(QString("")); + + ui->friendList->setObjectName("friendList"); + ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css")); + + ui->tbMenu->setIcon(QIcon(":ui/window/applicationIcon.png")); + ui->pbMin->setObjectName("minimizeButton"); + ui->pbMax->setObjectName("maximizeButton"); + ui->pbClose->setObjectName("closeButton"); + setWindowFlags(Qt::CustomizeWindowHint); setWindowFlags(Qt::FramelessWindowHint); + + addAction(ui->actionClose); + + connect(ui->pbMin, SIGNAL(clicked()), this, SLOT(minimizeBtnClicked())); + connect(ui->pbMax, SIGNAL(clicked()), this, SLOT(maximizeBtnClicked())); + connect(ui->pbClose, SIGNAL(clicked()), this, SLOT(close())); + + m_titleMode = FullTitle; + moveWidget = false; + inResizeZone = false; + allowToResize = false; + resizeVerSup = false; + resizeHorEsq = false; + resizeDiagSupEsq = false; + resizeDiagSupDer = false; + + if (isMaximized()) + { + showMaximized(); + ui->pbMax->setObjectName("restoreButton"); + } } - addAction(ui->actionClose); - - connect(ui->pbMin, SIGNAL(clicked()), this, SLOT(minimizeBtnClicked())); - connect(ui->pbMax, SIGNAL(clicked()), this, SLOT(maximizeBtnClicked())); - connect(ui->pbClose, SIGNAL(clicked()), this, SLOT(close())); - - m_titleMode = FullTitle; - moveWidget = false; - inResizeZone = false; - allowToResize = false; - resizeVerSup = false; - resizeHorEsq = false; - resizeDiagSupEsq = false; - resizeDiagSupDer = false; - isWindowMinimized = 0; ui->mainContent->setLayout(new QVBoxLayout()); @@ -102,9 +112,11 @@ Widget::Widget(QWidget *parent) ui->mainHead->layout()->setSpacing(0); QWidget* friendListWidget = new QWidget(); + //friendListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); friendListWidget->setLayout(new QVBoxLayout()); friendListWidget->layout()->setSpacing(0); friendListWidget->layout()->setMargin(0); + friendListWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); ui->friendList->setWidget(friendListWidget); // delay setting username and message until Core inits @@ -112,7 +124,6 @@ Widget::Widget(QWidget *parent) ui->nameLabel->label->setStyleSheet("QLabel { color : white; font-size: 11pt; font-weight:bold;}"); //ui->statusLabel->setText(core->getStatusMessage()); ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}"); - ui->friendList->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); ui->statusButton->setStyleSheet(Style::get(":/ui/statusButton/statusButton.css")); @@ -125,13 +136,6 @@ Widget::Widget(QWidget *parent) setStatusBusy->setIcon(QIcon(":ui/statusButton/dot_busy.png")); ui->statusButton->setMenu(statusButtonMenu); - -// this->setMouseTracking(true); - -// QList widgets = this->findChildren(); -// foreach (QWidget *widget, widgets) -// widget->setMouseTracking(true); - ui->titleBar->setMouseTracking(true); ui->LTitle->setMouseTracking(true); ui->tbMenu->setMouseTracking(true); @@ -140,11 +144,11 @@ Widget::Widget(QWidget *parent) ui->pbClose->setMouseTracking(true); ui->statusHead->setMouseTracking(true); - ui->friendList->viewport()->installEventFilter(this); + //ui->friendList->viewport()->installEventFilter(this); -// QList currentSizes = ui->centralWidget->sizes(); -// currentSizes[0] = 225; -// ui->centralWidget->setSizes(currentSizes); + // disable proportional scaling + ui->centralWidget->setStretchFactor(0,0); + ui->centralWidget->setStretchFactor(1,1); ui->statusButton->setObjectName("offline"); ui->statusButton->style()->polish(ui->statusButton); @@ -617,7 +621,7 @@ void Widget::onGroupMessageReceived(int groupnumber, int friendgroupnumber, cons newMessageAlert(); g->hasNewMessages = 1; g->userWasMentioned = 1; - if (useNativeTheme) + if (Settings::getInstance().getUseNativeDecoration()) g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png")); else g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat_notification.png")); @@ -626,7 +630,7 @@ void Widget::onGroupMessageReceived(int groupnumber, int friendgroupnumber, cons if (g->hasNewMessages == 0) { g->hasNewMessages = 1; - if (useNativeTheme) + if (Settings::getInstance().getUseNativeDecoration()) g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png")); else g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat_newmessages.png")); @@ -673,7 +677,7 @@ void Widget::onGroupWidgetClicked(GroupWidget* widget) { g->hasNewMessages = 0; g->userWasMentioned = 0; - if (useNativeTheme) + if (Settings::getInstance().getUseNativeDecoration()) g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online.png")); else g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png")); @@ -712,7 +716,7 @@ Group *Widget::createGroup(int groupId) QWidget* widget = ui->friendList->widget(); QLayout* layout = widget->layout(); layout->addWidget(newgroup->widget); - if (!useNativeTheme) + if (!Settings::getInstance().getUseNativeDecoration()) newgroup->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png")); connect(newgroup->widget, SIGNAL(groupWidgetClicked(GroupWidget*)), this, SLOT(onGroupWidgetClicked(GroupWidget*))); @@ -758,7 +762,7 @@ bool Widget::event(QEvent * e) } else if (e->type() == QEvent::WindowActivate) { - if (!useNativeTheme) + if (!Settings::getInstance().getUseNativeDecoration()) { this->setObjectName("activeWindow"); this->style()->polish(this); @@ -775,18 +779,18 @@ bool Widget::event(QEvent * e) Group* g = GroupList::findGroup(activeGroupWidget->groupId); g->hasNewMessages = 0; g->userWasMentioned = 0; - if (useNativeTheme) + if (Settings::getInstance().getUseNativeDecoration()) g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online.png")); else g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png")); } } - else if (e->type() == QEvent::WindowDeactivate && !useNativeTheme) + else if (e->type() == QEvent::WindowDeactivate && !Settings::getInstance().getUseNativeDecoration()) { this->setObjectName("inactiveWindow"); this->style()->polish(this); } - else if (e->type() == QEvent::MouseMove && !useNativeTheme) + else if (e->type() == QEvent::MouseMove && !Settings::getInstance().getUseNativeDecoration()) { QMouseEvent *k = (QMouseEvent *)e; int xMouse = k->pos().x(); @@ -831,7 +835,7 @@ bool Widget::event(QEvent * e) void Widget::mousePressEvent(QMouseEvent *e) { - if (!useNativeTheme) + if (!Settings::getInstance().getUseNativeDecoration()) { if (e->button() == Qt::LeftButton) { @@ -865,7 +869,7 @@ void Widget::mousePressEvent(QMouseEvent *e) void Widget::mouseReleaseEvent(QMouseEvent *e) { - if (!useNativeTheme) + if (!Settings::getInstance().getUseNativeDecoration()) { moveWidget = false; allowToResize = false; @@ -880,7 +884,7 @@ void Widget::mouseReleaseEvent(QMouseEvent *e) void Widget::mouseDoubleClickEvent(QMouseEvent *e) { - if (!useNativeTheme) + if (!Settings::getInstance().getUseNativeDecoration()) { if (e->pos().x() < ui->tbMenu->geometry().right() and e->pos().y() < ui->tbMenu->geometry().bottom() and e->pos().x() >= ui->tbMenu->geometry().x() and e->pos().y() >= ui->tbMenu->geometry().y() @@ -904,7 +908,7 @@ void Widget::paintEvent (QPaintEvent *) void Widget::moveWindow(QMouseEvent *e) { - if (!useNativeTheme) + if (!Settings::getInstance().getUseNativeDecoration()) { if (e->buttons() & Qt::LeftButton) { @@ -916,7 +920,7 @@ void Widget::moveWindow(QMouseEvent *e) void Widget::resizeWindow(QMouseEvent *e) { - if (!useNativeTheme) + if (!Settings::getInstance().getUseNativeDecoration()) { if (allowToResize) { diff --git a/widget/widget.h b/widget/widget.h index 0980cff69..a31e8e6f2 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -58,7 +58,6 @@ public: void newMessageAlert(); bool isFriendWidgetCurActiveWidget(Friend* f); void updateFriendStatusLights(int friendId); - int useNativeTheme; ~Widget(); virtual void closeEvent(QCloseEvent *event); From 6bb85c65b856d6412a05a7699983906f252206f3 Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 11 Aug 2014 14:07:27 +0200 Subject: [PATCH 4/6] save/restore status of the splitter --- mainwindow.ui | 2 +- settings.cpp | 12 ++++++++++++ settings.h | 4 ++++ widget/widget.cpp | 6 ++++-- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mainwindow.ui b/mainwindow.ui index 3509b23d6..8622e3d68 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -225,7 +225,7 @@ - + 0 diff --git a/settings.cpp b/settings.cpp index 19e9e1f93..7d7571a14 100644 --- a/settings.cpp +++ b/settings.cpp @@ -106,6 +106,7 @@ void Settings::load() useNativeDecoration = s.value("nativeDecoration", true).toBool(); windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray(); windowState = s.value("windowState", QByteArray()).toByteArray(); + splitterState = s.value("splitterState", QByteArray()).toByteArray(); s.endGroup(); s.beginGroup("Privacy"); @@ -166,6 +167,7 @@ void Settings::save(QString path) s.setValue("nativeDecoration", useNativeDecoration); s.setValue("windowGeometry", windowGeometry); s.setValue("windowState", windowState); + s.setValue("splitterState", splitterState); s.endGroup(); s.beginGroup("Privacy"); @@ -383,6 +385,16 @@ void Settings::setWindowState(const QByteArray &value) windowState = value; } +QByteArray Settings::getSplitterState() const +{ + return splitterState; +} + +void Settings::setSplitterState(const QByteArray &value) +{ + splitterState = value; +} + bool Settings::isMinimizeOnCloseEnabled() const { return minimizeOnClose; diff --git a/settings.h b/settings.h index a514350d5..c32203f41 100644 --- a/settings.h +++ b/settings.h @@ -124,6 +124,9 @@ public: QByteArray getWindowState() const; void setWindowState(const QByteArray &value); + QByteArray getSplitterState() const; + void setSplitterState(const QByteArray &value); + private: Settings(); Settings(Settings &settings) = delete; @@ -163,6 +166,7 @@ private: bool useNativeDecoration; QByteArray windowGeometry; QByteArray windowState; + QByteArray splitterState; // ChatView int firstColumnHandlePos; diff --git a/widget/widget.cpp b/widget/widget.cpp index e9281a891..6b4353368 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -55,6 +55,7 @@ Widget::Widget(QWidget *parent) //restore window state restoreGeometry(Settings::getInstance().getWindowGeometry()); restoreState(Settings::getInstance().getWindowState()); + ui->mainSplitter->restoreState(Settings::getInstance().getSplitterState()); if (Settings::getInstance().getUseNativeDecoration()) { @@ -147,8 +148,8 @@ Widget::Widget(QWidget *parent) //ui->friendList->viewport()->installEventFilter(this); // disable proportional scaling - ui->centralWidget->setStretchFactor(0,0); - ui->centralWidget->setStretchFactor(1,1); + ui->mainSplitter->setStretchFactor(0,0); + ui->mainSplitter->setStretchFactor(1,1); ui->statusButton->setObjectName("offline"); ui->statusButton->style()->polish(ui->statusButton); @@ -253,6 +254,7 @@ void Widget::closeEvent(QCloseEvent *event) { Settings::getInstance().setWindowGeometry(saveGeometry()); Settings::getInstance().setWindowState(saveState()); + Settings::getInstance().setSplitterState(ui->mainSplitter->saveState()); QWidget::closeEvent(event); } From 0d748b93d603a1894ecf131503b1a517e0422bb9 Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 11 Aug 2014 17:06:57 +0200 Subject: [PATCH 5/6] consider scrollbar's width --- widget/adjustingscrollarea.cpp | 6 +++++- widget/widget.cpp | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/widget/adjustingscrollarea.cpp b/widget/adjustingscrollarea.cpp index f83db5024..bb273fa90 100644 --- a/widget/adjustingscrollarea.cpp +++ b/widget/adjustingscrollarea.cpp @@ -18,6 +18,7 @@ #include #include +#include #include AdjustingScrollArea::AdjustingScrollArea(QWidget *parent) : @@ -35,7 +36,10 @@ void AdjustingScrollArea::resizeEvent(QResizeEvent *ev) QSize AdjustingScrollArea::sizeHint() const { if (widget()) - return widget()->sizeHint(); + { + int scrollbarWidth = verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0; + return widget()->sizeHint() + QSize(scrollbarWidth, 0); + } return QScrollArea::sizeHint(); } diff --git a/widget/widget.cpp b/widget/widget.cpp index 6b4353368..38c047259 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -113,7 +113,6 @@ Widget::Widget(QWidget *parent) ui->mainHead->layout()->setSpacing(0); QWidget* friendListWidget = new QWidget(); - //friendListWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); friendListWidget->setLayout(new QVBoxLayout()); friendListWidget->layout()->setSpacing(0); friendListWidget->layout()->setMargin(0); From 1c27b55470d319f17b980be31c955dcb9d00a30c Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 11 Aug 2014 17:23:41 +0200 Subject: [PATCH 6/6] use Style::get --- widget/emoticonswidget.cpp | 7 ++----- widget/filetransfertwidget.cpp | 23 +++++---------------- widget/form/groupchatform.cpp | 37 +++++----------------------------- 3 files changed, 12 insertions(+), 55 deletions(-) diff --git a/widget/emoticonswidget.cpp b/widget/emoticonswidget.cpp index b2796c999..bab7abe8d 100644 --- a/widget/emoticonswidget.cpp +++ b/widget/emoticonswidget.cpp @@ -16,6 +16,7 @@ #include "emoticonswidget.h" #include "smileypack.h" +#include "style.h" #include #include @@ -26,11 +27,7 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) : QMenu(parent) { - QFile f(":/ui/emoticonWidget/emoticonWidget.css"); - f.open(QFile::ReadOnly | QFile::Text); - QString pageButtonCss = f.readAll(); - setStyleSheet(pageButtonCss); - + setStyleSheet(Style::get(":/ui/emoticonWidget/emoticonWidget.css")); setLayout(&layout); layout.addWidget(&stack); diff --git a/widget/filetransfertwidget.cpp b/widget/filetransfertwidget.cpp index e90d8b2d0..36027257f 100644 --- a/widget/filetransfertwidget.cpp +++ b/widget/filetransfertwidget.cpp @@ -18,6 +18,7 @@ #include "widget.h" #include "core.h" #include "math.h" +#include "style.h" #include #include #include @@ -36,10 +37,7 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File) QFont prettysmall; prettysmall.setPixelSize(10); this->setObjectName("default"); - QFile f0(":/ui/fileTransferWidget/fileTransferWidget.css"); - f0.open(QFile::ReadOnly | QFile::Text); - QTextStream fileTransfertWidgetStylesheet(&f0); - this->setStyleSheet(fileTransfertWidgetStylesheet.readAll()); + this->setStyleSheet(Style::get(":/ui/fileTransferWidget/fileTransferWidget.css")); QPalette greybg; greybg.setColor(QPalette::Window, QColor(209,209,209)); greybg.setColor(QPalette::Base, QColor(150,150,150)); @@ -71,20 +69,9 @@ FileTransfertWidget::FileTransfertWidget(ToxFile File) buttonWidget->setAutoFillBackground(true); buttonWidget->setLayout(buttonLayout); - QFile f1(":/ui/stopFileButton/style.css"); - f1.open(QFile::ReadOnly | QFile::Text); - QTextStream stopFileButtonStylesheetStream(&f1); - stopFileButtonStylesheet = stopFileButtonStylesheetStream.readAll(); - - QFile f2(":/ui/pauseFileButton/style.css"); - f2.open(QFile::ReadOnly | QFile::Text); - QTextStream pauseFileButtonStylesheetStream(&f2); - pauseFileButtonStylesheet = pauseFileButtonStylesheetStream.readAll(); - - QFile f3(":/ui/acceptFileButton/style.css"); - f3.open(QFile::ReadOnly | QFile::Text); - QTextStream acceptFileButtonStylesheetStream(&f3); - acceptFileButtonStylesheet = acceptFileButtonStylesheetStream.readAll(); + stopFileButtonStylesheet = Style::get(":/ui/stopFileButton/style.css"); + pauseFileButtonStylesheet = Style::get(":/ui/pauseFileButton/style.css"); + acceptFileButtonStylesheet = Style::get(":/ui/acceptFileButton/style.css"); topright->setStyleSheet(stopFileButtonStylesheet); if (File.direction == ToxFile::SENDING) diff --git a/widget/form/groupchatform.cpp b/widget/form/groupchatform.cpp index 919c457d7..e5e630ae1 100644 --- a/widget/form/groupchatform.cpp +++ b/widget/form/groupchatform.cpp @@ -20,6 +20,7 @@ #include "widget/widget.h" #include "friend.h" #include "friendlist.h" +#include "style.h" #include #include #include @@ -55,16 +56,8 @@ GroupChatForm::GroupChatForm(Group* chatGroup) namesList->setFont(small); 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); + + chatArea->setStyleSheet(Style::get(":/ui/chatArea/chatArea.css")); chatArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); chatArea->setWidgetResizable(true); chatArea->setContextMenuPolicy(Qt::CustomContextMenu); @@ -73,35 +66,15 @@ GroupChatForm::GroupChatForm(Group* chatGroup) mainChatLayout->setColumnStretch(1,1); mainChatLayout->setSpacing(10); - - 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->setObjectName("group"); - msgEdit->setStyleSheet(msgEditStylesheet); + msgEdit->setStyleSheet(Style::get(":/ui/msgEdit/msgEdit.css")); msgEdit->setFixedHeight(50); msgEdit->setFrameStyle(QFrame::NoFrame); mainChatLayout->setColumnStretch(1,1); mainChatLayout->setHorizontalSpacing(10); - 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")); sendButton->setFixedSize(50, 50); main->setLayout(mainLayout);