Add stylesheets and general improvements

This commit is contained in:
Alexander Bock
2015-07-04 13:22:03 +02:00
parent 16ccd7550f
commit 1510aca448
6 changed files with 379 additions and 103 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.0)
project(libtorrent)
set (SOVERSION "8")
set (VERSION "1.0.5")
set(SOVERSION "8")
set(VERSION "1.0.5")
set(sources
web_connection_base
+20 -10
View File
@@ -43,26 +43,36 @@ InfoWidget::InfoWidget(QString name, int totalBytes)
setFixedHeight(100);
QGridLayout* layout = new QGridLayout;
layout->setVerticalSpacing(0);
//layout->setVerticalSpacing(0);
layout->setHorizontalSpacing(10);
layout->setContentsMargins(0, 0, 0, 0);
_name = new QLabel(name);
layout->addWidget(_name, 0, 0);
_name->setObjectName("Name");
//_name->setMaximumWidth(300);
_name->setFixedWidth(450);
layout->addWidget(_name, 0, 0, 1, 2);
layout->setRowStretch(1, 10);
_bytes = new QLabel("");
layout->addWidget(_bytes, 1, 0);
_bytes->setObjectName("Bytes");
layout->addWidget(_bytes, 2, 0);
_progress = new QProgressBar;
layout->addWidget(_progress, 1, 1);
_progress->setTextVisible(false);
_progress->setFixedWidth(285);
layout->addWidget(_progress, 2, 1);
_messagesLeft = new QLabel("");
_messagesLeft->setObjectName("MessageLeft");
_messagesCenter = new QLabel("");
_messagesCenter->setObjectName("MessageCenter");
_messagesRight = new QLabel("");
layout->addWidget(_messagesLeft, 2, 0, 1, 2);
layout->addWidget(_messagesCenter, 2, 0, 1, 2, Qt::AlignCenter);
layout->addWidget(_messagesRight, 2, 0, 1, 2, Qt::AlignRight);
_messagesRight->setObjectName("MessageRight");
layout->addWidget(_messagesLeft, 3, 0, 1, 2);
layout->addWidget(_messagesCenter, 3, 0, 1, 2, Qt::AlignCenter);
layout->addWidget(_messagesRight, 3, 0, 1, 2, Qt::AlignRight);
setLayout(layout);
}
@@ -99,13 +109,13 @@ void InfoWidget::update(libtorrent::torrent_status s) {
if (bytesPerSecond > 0 && remainingBytes > 0) {
float seconds = static_cast<float>(remainingBytes) / bytesPerSecond;
QString left = "Time remaining %1 s";
QString left = "Remaining: %1 s";
_messagesLeft->setText(left.arg(static_cast<int>(seconds)));
QString center = "Peers: %1 (%2) | Seeds: %3 (%4)";
_messagesCenter->setText(center.arg(s.num_peers).arg(s.list_peers).arg(s.num_seeds).arg(s.list_seeds));
QString right = "Download Rate: %1 KiB/s";
QString right = "%1 KiB/s";
_messagesRight->setText(right.arg(bytesPerSecond / 1024));
}
else
+328 -83
View File
@@ -24,131 +24,376 @@
#include <QApplication>
#include <QFile>
#include "mainwindow.h"
//static const QString style = R"style(
//QWidget {
// background-color: rgb(80, 80, 80);
// font-family: Helvetica;
#include <ghoul/filesystem/filesystem>
// Copyright 2013 Emanuel Claesson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*/
//
///*
// COLOR_DARK = #191919
// COLOR_MEDIUM = #353535
// COLOR_MEDLIGHT = #5A5A5A
// COLOR_LIGHT = #DDDDDD
// COLOR_ACCENT = #3D7848
//*/
//
//* {
// background: #191919;
// color: #DDDDDD;
// border: 1px solid #5A5A5A;
//}
//
//QWidget::item:selected {
// background: #3D7848;
//}
//
//QCheckBox, QRadioButton {
// border: none;
//}
//
//QRadioButton::indicator, QCheckBox::indicator {
// width: 13px;
// height: 13px;
//}
//
//QRadioButton::indicator::unchecked, QCheckBox::indicator::unchecked {
// border: 1px solid #5A5A5A;
// background: none;
//}
//
//QRadioButton::indicator:unchecked:hover, QCheckBox::indicator:unchecked:hover {
// border: 1px solid #DDDDDD;
//}
//
//QRadioButton::indicator::checked, QCheckBox::indicator::checked {
// border: 1px solid #5A5A5A;
// background: #5A5A5A;
//}
//
//QRadioButton::indicator:checked:hover, QCheckBox::indicator:checked:hover {
// border: 1px solid #DDDDDD;
// background: #DDDDDD;
//}
//
//QGroupBox {
// background-color: qlineargradient(
// x1: 0, y1: 0, x2: 0, y2: 1,
// stop: 0 #858585,
// stop: 1 #959595);
// border: 2px solid gray;
// border-radius: 5px;
// margin-top: 4ex;
// font-size: bold 12px;
// margin-top: 6px;
//}
//
//QGroupBox::title {
// background-color: #E0E0E0;
// border: 2px solid gray;
// border-radius: 5px;
// subcontrol-origin: margin;
// subcontrol-position: top center;
// padding: 0 10px;
// top: -7px;
// left: 7px;
//}
//
//QLineEdit {
// color: lightgray;
//QScrollBar {
// border: 1px solid #5A5A5A;
// background: #191919;
//}
//
//QScrollBar:horizontal {
// height: 15px;
// margin: 0px 0px 0px 32px;
//}
//
//QScrollBar:vertical {
// width: 15px;
// margin: 32px 0px 0px 0px;
//}
//
//QScrollBar::handle {
// background: #353535;
// border: 1px solid #5A5A5A;
//}
//
//QScrollBar::handle:horizontal {
// border-width: 0px 1px 0px 1px;
//}
//
//QScrollBar::handle:vertical {
// border-width: 1px 0px 1px 0px;
//}
//
//QScrollBar::handle:horizontal {
// min-width: 20px;
//}
//
//QScrollBar::handle:vertical {
// min-height: 20px;
//}
//
//QScrollBar::add-line, QScrollBar::sub-line {
// background:#353535;
// border: 1px solid #5A5A5A;
// subcontrol-origin: margin;
//}
//
//QScrollBar::add-line {
// position: absolute;
//}
//
//QScrollBar::add-line:horizontal {
// width: 15px;
// subcontrol-position: left;
// left: 15px;
//}
//
//QScrollBar::add-line:vertical {
// height: 15px;
// subcontrol-position: top;
// top: 15px;
//}
//
//QScrollBar::sub-line:horizontal {
// width: 15px;
// subcontrol-position: top left;
//}
//
//QScrollBar::sub-line:vertical {
// height: 15px;
// subcontrol-position: top;
//}
//
//QScrollBar:left-arrow, QScrollBar::right-arrow, QScrollBar::up-arrow, QScrollBar::down-arrow {
// border: 1px solid #5A5A5A;
// width: 3px;
// height: 3px;
//}
//
//QScrollBar::add-page, QScrollBar::sub-page {
// background: none;
//}
//
//QAbstractButton:hover {
// background: #353535;
//}
//
//QAbstractButton:pressed {
// background: #5A5A5A;
//}
//
//QAbstractItemView {
// show-decoration-selected: 1;
// selection-background-color: #3D7848;
// selection-color: #DDDDDD;
// alternate-background-color: #353535;
//}
//
//QHeaderView {
// border: 1px solid #5A5A5A;
//}
//
//QHeaderView::section {
// background: #191919;
// border: 1px solid #5A5A5A;
// padding: 4px;
//}
//
//QHeaderView::section:selected, QHeaderView::section::checked {
// background: #353535;
//}
//
//QTableView {
// gridline-color: #5A5A5A;
//}
//
//QTabBar {
// margin-left: 2px;
//}
//
//QTabBar::tab {
// border-radius: 0px;
// padding: 4px;
// margin: 4px;
//}
//
//QTabBar::tab:selected {
// background: #353535;
//}
//
//QComboBox::down-arrow {
// border: 1px solid #5A5A5A;
// background: #353535;
//}
//
//QComboBox::drop-down {
// border: 1px solid #5A5A5A;
// background: #353535;
//}
//
//QComboBox::down-arrow {
// width: 3px;
// height: 3px;
// border: 1px solid #5A5A5A;
//}
//
//QAbstractSpinBox {
// padding-right: 15px;
//}
//
//QAbstractSpinBox::up-button, QAbstractSpinBox::down-button {
// border: 1px solid #5A5A5A;
// background: #353535;
// subcontrol-origin: border;
//}
//
//QAbstractSpinBox::up-arrow, QAbstractSpinBox::down-arrow {
// width: 3px;
// height: 3px;
// border: 1px solid #5A5A5A;
//}
//
//QSlider {
// border: none;
//}
//
//QSlider::groove:horizontal {
// border: 1px solid #999999;
// height: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
// background: qlineargradient(
// x1:0, y1:0, x2:1, y2:0,
// stop:0 #c4c4c4,
// stop:0.5 #555555,
// stop:1 #c4c4c4
// );
// margin: 2px 0;
// height: 5px;
// margin: 4px 0px 4px 0px;
//}
//
//QSlider::groove:vertical {
// width: 5px;
// margin: 0px 4px 0px 4px;
//}
//
//QSlider::handle {
// border: 1px solid #5A5A5A;
// background: #353535;
//}
//
//QSlider::handle:horizontal {
// background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
// border: 1px solid #5c5c5c;
// width: 18px;
// margin: -2px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
// border-radius: 3px;
// width: 15px;
// margin: -4px 0px -4px 0px;
//}
//
//QPushButton {
// background-color: lightgray;
// border-style: outset;
// border-width: 0.5px;
// border-radius: 5px;
// border-color: black;
// font: bold 12px;
// min-width: 10em;
//QSlider::handle:vertical {
// height: 15px;
// margin: 0px -4px 0px -4px;
//}
//
//QPushButton#connection {
// background-color: lightgreen;
//QSlider::add-page:vertical, QSlider::sub-page:horizontal {
// background: #3D7848;
//}
//
//QPushButton#connection:pressed {
// background-color: green;
//QSlider::sub-page:vertical, QSlider::add-page:horizontal {
// background: #353535;
//}
//
//
//QPushButton#pause, QPushButton#play {
// padding: 5px;
//QLabel {
// border: none;
//}
//
//QPushButton#pause:pressed, QPushButton#play:pressed, QPushButton:pressed {
// background-color: darkgray;
// border-style: inset;
//QProgressBar {
// text-align: center;
//}
//
//QCombobox {
// border: 1px solid gray;
// border-radius: 3px;
// padding: 1px 18px 1px 3px;
// min-width: 6em;
//QProgressBar::chunk {
// width: 1px;
// background-color: #3D7848;
//}
//
//QComboBox:editable {
// background: lightgrey;
//QMenu::separator {
// background: #353535;
//}
//
//QComboBox QAbstractItemView {
// border: 2px solid darkgray;
// border-radius: 5px;
// background-color: #a8a8a8;
// selection-background-color: #a8a8a8;
//)style";
//static const QString style = R"style(
//QWidget {
// font-family: Helvetica;
//}
//
//QLabel#label {
// font-size: 13px;
// background-color: transparent;
// font-variant: small-caps;
//QWidget#MainWindow, QTextEdit, QWidget#SyncWidget, QWidget#DownloadArea {
// background-color: rgb(40, 40, 40);
//}
//
//QLabel#value {
// font-family: monospace;
// font-weight: bold;
// font-size: 14px;
// background-color: transparent;
//QTextEdit, QLabel, QComboBox, QCheckBox {
// color: white;
// font-size: 12px;
//}
//
//QWidget#background {
// background-color: transparent;
//}
//
//QTextEdit {
// font-family: monospace;
// border-width: 2px 2px 0px 0px;
// border-style: solid;
// background-color: rgb(60, 60, 60);
//}
//QPushButton {
// background-color:
// qlineargradient(
// x1: 0, y1: 0, x2: 0, y2: 1,
// stop: 0 white,
// stop: 1 #505050
// );
// border-style: solid;
// border-color: black;
// border-width: 1px;
// font-size: 11px;
// min-height: 17.5px;
//}
//QComboBox {
// background-color: rgb(60, 60, 60);
// min-height: 20px;
//}
//QComboBox:focus, QComboBox:focus QAbstractItemView {
// color: white;
// background-color: rgb(60, 60, 60);
// selection-background-color: rgb(75, 75, 75);
//}
//QCheckBox {
// border: none;
//}
//QCheckBox::indicator {
// width: 13px;
// height: 13px;
//}
//QCheckBox::indicator::unchecked {
// border: 1px solid #5A5A5A;
// background: transparent;
//}
//QCheckBox::indicator:unchecked:hover {
// border: 1px solid #DDDDDD;
//}
//QCheckBox::indicator::checked {
// border: 1px solid #666666;
// background: #666666;
//}
//QCheckBox::indicator:checked:hover {
// border: 1px solid #DDDDDD;
// background: #555555;
//}
//QGroupBox, QScrollArea {
// border: 0px;
//}
//)style";
int main(int argc, char** argv) {
QApplication app(argc, argv);
// app.setStyleSheet(style);
MainWindow window;
auto setStyle = [](const ghoul::filesystem::File& f) {
QFile file(QString::fromStdString(f.path()));
file.open(QIODevice::ReadOnly);
QTextStream in(&file);
QString style = in.readAll();
qApp->setStyleSheet(style);
};
ghoul::filesystem::File f("stylesheet.css", false, setStyle);
setStyle(f);
window.show();
return app.exec();
+13 -2
View File
@@ -79,19 +79,28 @@ MainWindow::MainWindow()
, _shortcutWidget(nullptr)
, _syncWidget(nullptr)
{
setObjectName("MainWindow");
setFixedSize(WindowSize);
//setContentsMargins(0, 0, 0, 0);
QGridLayout* layout = new QGridLayout;
layout->setContentsMargins(0, 0, 0, 0);
QLabel* image = new QLabel;
//image->setContentsMargins(0, 0, 0, 0);
image->setObjectName("Image");
QPixmap p = QPixmap(":/images/header.png");
image->setPixmap(p.scaledToWidth(WindowSize.width()));
layout->addWidget(image, 0, 0, 1, 2);
_informationWidget = new QTextEdit(this);
_informationWidget->setReadOnly(true);
_informationWidget->setEnabled(false);
layout->addWidget(_informationWidget, 1, 0, 2, 1);
layout->setRowStretch(1, 10);
layout->setColumnStretch(0, 4);
layout->setColumnStretch(1, 5);
QWidget* container = new QWidget;
{
@@ -104,11 +113,13 @@ MainWindow::MainWindow()
this, SLOT(shortcutButtonPressed())
);
layout->addWidget(shortcutButton, 0, 1);
layout->setRowStretch(1, 10);
QLabel* sceneSelectionLabel = new QLabel("Scenes:");
layout->addWidget(sceneSelectionLabel, 1, 0);
layout->addWidget(sceneSelectionLabel, 2, 0);
_scenes = new QComboBox;
layout->addWidget(_scenes);
layout->addWidget(_scenes, 2, 1);
container->setLayout(layout);
}
+13 -4
View File
@@ -74,7 +74,7 @@ namespace {
const std::string VersionKey = "Version";
const bool OverwriteFiles = false;
const bool CleanInfoWidgets = true;
const bool CleanInfoWidgets = false;
}
SyncWidget::SyncWidget(QWidget* parent, Qt::WindowFlags f)
@@ -82,9 +82,11 @@ SyncWidget::SyncWidget(QWidget* parent, Qt::WindowFlags f)
, _sceneLayout(nullptr)
, _session(new libtorrent::session)
{
setObjectName("SyncWidget");
setFixedSize(500, 500);
QBoxLayout* layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
{
QGroupBox* sceneBox = new QGroupBox;
_sceneLayout = new QGridLayout;
@@ -92,7 +94,8 @@ SyncWidget::SyncWidget(QWidget* parent, Qt::WindowFlags f)
layout->addWidget(sceneBox);
}
{
QPushButton* syncButton = new QPushButton("Synchronize Scenes");
QPushButton* syncButton = new QPushButton("Synchronize Data");
syncButton->setObjectName("SyncButton");
QObject::connect(
syncButton, SIGNAL(clicked(bool)),
this, SLOT(syncButtonPressed())
@@ -106,6 +109,7 @@ SyncWidget::SyncWidget(QWidget* parent, Qt::WindowFlags f)
area->setWidgetResizable(true);
QWidget* w = new QWidget;
w->setObjectName("DownloadArea");
area->setWidget(w);
_downloadLayout = new QVBoxLayout(w);
@@ -213,7 +217,6 @@ void SyncWidget::setSceneFiles(QMap<QString, QString> sceneFiles) {
const QString& sceneName = keys[i];
QCheckBox* checkbox = new QCheckBox(sceneName);
checkbox->setChecked(true);
_sceneLayout->addWidget(checkbox, i / nColumns, i % nColumns);
@@ -326,7 +329,13 @@ void SyncWidget::handleTorrentFiles() {
}
if (_torrentInfoWidgetMap.find(h) == _torrentInfoWidgetMap.end()) {
InfoWidget* w = new InfoWidget(f.file, h.status().total_wanted);
QString fileString = f.file;
QString t = QString(".torrent");
fileString.replace(fileString.indexOf(t), t.size(), "");
fileString = f.module + "/" + fileString;
InfoWidget* w = new InfoWidget(fileString, h.status().total_wanted);
_downloadLayout->insertWidget(_downloadLayout->count() - 1, w);
_torrentInfoWidgetMap[h] = w;
}
+2 -1
View File
@@ -33,9 +33,10 @@ function (include_external_library target_name library_name path)
target_link_libraries(${target_name} ${library_name})
target_include_directories(${target_name} PUBLIC SYSTEM ${INCLUDE_DIR})
set_property(TARGET ${library_name} PROPERTY FOLDER "External")
target_compile_options(${library_name} PUBLIC "/MP")
if (OPENSPACE_DISABLE_EXTERNAL_WARNINGS)
if (MSVC)
target_compile_options(${library_name} PUBLIC "/W0" "/MP")
target_compile_options(${library_name} PUBLIC "/W0")
else ()
target_compile_options(${library_name} PUBLIC "-w")
endif ()