Browse Source

Restructured resources, added fonts and fixed small issues

Ivan Arkhipov 5 years ago
parent
commit
e201fe8388

+ 3 - 2
Legacy_v2.pro

@@ -14,7 +14,7 @@ TARGET = Legacy_v2
 TEMPLATE = app
 
 CXXFLAGS += -O2 -fno-stack-limit
-
+CONFIG += resources_big
 
 # The following define makes your compiler emit warnings if you use
 # any feature of Qt which has been marked as deprecated (the exact warnings
@@ -64,7 +64,8 @@ FORMS += \
     gui/helpwidget.ui
 
 RESOURCES += \
-        res.qrc
+    backgrounds.qrc \
+    common.qrc
 
 win32:RC_ICONS = $$PWD/assets/appicon.ico
 

+ 13 - 0
backgrounds.qrc

@@ -0,0 +1,13 @@
+<RCC>
+    <qresource prefix="/">
+        <file>assets/backgrounds/bg1.png</file>
+        <file>assets/backgrounds/bg2.png</file>
+        <file>assets/backgrounds/bg3.png</file>
+        <file>assets/backgrounds/bg4.png</file>
+        <file>assets/backgrounds/bg5.png</file>
+        <file>assets/backgrounds/bg6.png</file>
+        <file>assets/backgrounds/bg7.png</file>
+        <file>assets/backgrounds/bg8.png</file>
+        <file>assets/backgrounds/bg9.png</file>
+    </qresource>
+</RCC>

+ 24 - 0
common.qrc

@@ -0,0 +1,24 @@
+<RCC>
+    <qresource prefix="/">
+        <file>assets/fonts/trajan.ttf</file>
+        <file>assets/fonts/viking.ttf</file>
+        <file>assets/status/critical.png</file>
+        <file>assets/status/error.png</file>
+        <file>assets/status/info.png</file>
+        <file>assets/status/ok.png</file>
+        <file>assets/status/warning.png</file>
+        <file>assets/buttons/close.png</file>
+        <file>assets/buttons/folder.png</file>
+        <file>assets/buttons/gray-button-hi.png</file>
+        <file>assets/buttons/green-button-hi.png</file>
+        <file>assets/buttons/minimize.png</file>
+        <file>assets/buttons/off.png</file>
+        <file>assets/buttons/on.png</file>
+        <file>assets/buttons/onoff.png</file>
+        <file>assets/buttons/onoff1.png</file>
+        <file>assets/buttons/orange-button-hi.png</file>
+        <file>assets/buttons/question.png</file>
+        <file>assets/appicon.ico</file>
+        <file>assets/teksty-photo-normal.png</file>
+    </qresource>
+</RCC>

+ 16 - 8
gui/mainwindow.cpp

@@ -11,6 +11,7 @@
 #include <QMessageBox>
 #include <QDesktopWidget>
 #include <QtConcurrent/QtConcurrent>
+#include <QFontDatabase>
 
 MainWindow::MainWindow(LegacyApp *app, QWidget *parent) :
     QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint), app(app),
@@ -21,6 +22,10 @@ MainWindow::MainWindow(LegacyApp *app, QWidget *parent) :
 void MainWindow::Init() {
     ui->setupUi(this);
 
+    QResource::registerResource(QApplication::applicationDirPath() + "/res/data009.gtr");
+    QFontDatabase::addApplicationFont(":/assets/fonts/trajan.ttf");
+    QFontDatabase::addApplicationFont(":/assets/fonts/viking.ttf");
+
     status_frame = new StatusWidget(app, this);
     ui->content_layout->addWidget(status_frame);
 
@@ -43,7 +48,7 @@ void MainWindow::Init() {
     updateGeometry();
 
     qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
-    background = new QPixmap(":/assets/bg" + QString::number(qrand() % MAX_PIXMAP_ID + 1) + ".png");
+    background = new QPixmap(":/assets/backgrounds/bg" + QString::number(qrand() % MAX_PIXMAP_ID + 1) + ".png");
     setupWindowBackgroundAndMask();
     setupMenuHoverWidget();
 
@@ -75,16 +80,19 @@ void MainWindow::resizeEvent(QResizeEvent * event)
     int width = event->size().width();
     int height = event->size().height();
 
-    ui->menu_widget->move(width * 420 / 1239, height * 55 / 810);
-    ui->menu_widget->resize(width * 770 / 1239, height * 60 / 810);
+    ui->menu_widget->move(width * 675 / 2000, height * 80 / 1296);
+    ui->menu_widget->resize(width * 1260 / 2000, height * 90 / 1296);
 
-    ui->content_area->move(width * 15 / 1239, height * 160 / 810);
-    ui->content_area->resize(width * 1210 / 1239, height * 650 / 810);
+    ui->content_area->move(width * 25 / 2000, height * 250 / 1296);
+    ui->content_area->resize(width * 1950 / 2000, height * 1000 / 1296);
     setupWindowBackgroundAndMask();
 }
 
 void MainWindow::randomChangeBackground()
 {
+    if (!qApp)
+        return;
+
     qDebug() << "Starting background update";
 
     if (fade_animation_timer.isActive()) {
@@ -98,7 +106,7 @@ void MainWindow::randomChangeBackground()
     if (!next_pixmap)
         next_pixmap = new QPixmap();
 
-    next_pixmap->load(":/assets/bg" + QString::number(next_pixmap_id) + ".png");
+    next_pixmap->load(":/assets/backgrounds/bg" + QString::number(next_pixmap_id) + ".png");
     qDebug() << "Next pixmap id" << next_pixmap_id << "!";
 
     if (next_pixmap->isNull()) {
@@ -115,7 +123,7 @@ void MainWindow::randomChangeBackground()
             QPainter painter;
             painter.begin(background);
             painter.setOpacity(next_pixmap_opacity);
-            painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
+            painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
             painter.drawPixmap(0,0, *next_pixmap);
             painter.end();
 
@@ -170,7 +178,7 @@ void MainWindow::onHoverMenuentry()
 
 void MainWindow::setupWindowBackgroundAndMask()
 {
-    QPixmap maskPix = background->scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
+    QPixmap maskPix = background->scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
     setMask(maskPix.mask());
 
     QPalette palette;

+ 2 - 2
gui/mainwindow.h

@@ -91,10 +91,10 @@ private:
     QTimer fade_animation_timer;
     double next_pixmap_opacity;
 
-    const int MAX_PIXMAP_ID = 9;
+    const int MAX_PIXMAP_ID = 2;
 
     const size_t common_font_size = 15;
-    const size_t title_font_size = 16;
+    const size_t title_font_size = 17;
     const size_t supertitle_font_size = 32;
     const size_t bigbutton_font_size = 22;
 };

+ 37 - 12
gui/mainwindow.ui

@@ -42,7 +42,7 @@
     <bool>false</bool>
    </property>
    <property name="styleSheet">
-    <string notr="true">border-image: url(:/assets/bg2.png);</string>
+    <string notr="true">border-image: url(:/assets/backgrounds/bg1.png);</string>
    </property>
    <widget class="QWidget" name="content_area" native="true">
     <property name="geometry">
@@ -86,8 +86,8 @@
    <widget class="QWidget" name="menu_widget" native="true">
     <property name="geometry">
      <rect>
-      <x>290</x>
-      <y>50</y>
+      <x>300</x>
+      <y>40</y>
       <width>571</width>
       <height>51</height>
      </rect>
@@ -137,6 +137,11 @@
          <height>0</height>
         </size>
        </property>
+       <property name="font">
+        <font>
+         <family>Trajan Pro 3</family>
+        </font>
+       </property>
        <property name="mouseTracking">
         <bool>true</bool>
        </property>
@@ -147,7 +152,7 @@
         <string notr="true">color:rgb(255, 255, 255);</string>
        </property>
        <property name="text">
-        <string>  СТАТУС  </string>
+        <string>статус</string>
        </property>
        <property name="scaledContents">
         <bool>true</bool>
@@ -174,6 +179,11 @@
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
+       <property name="font">
+        <font>
+         <family>Trajan Pro 3</family>
+        </font>
+       </property>
        <property name="mouseTracking">
         <bool>true</bool>
        </property>
@@ -181,7 +191,7 @@
         <string notr="true">color:rgb(255, 255, 255);</string>
        </property>
        <property name="text">
-        <string>  НАСТРОЙКИ  </string>
+        <string>настройки</string>
        </property>
        <property name="scaledContents">
         <bool>true</bool>
@@ -208,6 +218,11 @@
          <height>0</height>
         </size>
        </property>
+       <property name="font">
+        <font>
+         <family>Trajan Pro 3</family>
+        </font>
+       </property>
        <property name="mouseTracking">
         <bool>true</bool>
        </property>
@@ -215,7 +230,7 @@
         <string notr="true">color:rgb(255, 255, 255)</string>
        </property>
        <property name="text">
-        <string notr="true">  РУСИФИКАЦИЯ  </string>
+        <string notr="true"> русификация </string>
        </property>
        <property name="scaledContents">
         <bool>true</bool>
@@ -242,6 +257,11 @@
          <height>0</height>
         </size>
        </property>
+       <property name="font">
+        <font>
+         <family>Trajan Pro 3</family>
+        </font>
+       </property>
        <property name="mouseTracking">
         <bool>true</bool>
        </property>
@@ -249,7 +269,7 @@
         <string notr="true">color:rgb(255, 255, 255);</string>
        </property>
        <property name="text">
-        <string>  НОВОСТИ  </string>
+        <string>новости</string>
        </property>
        <property name="scaledContents">
         <bool>true</bool>
@@ -276,6 +296,11 @@
          <height>0</height>
         </size>
        </property>
+       <property name="font">
+        <font>
+         <family>Trajan Pro 3</family>
+        </font>
+       </property>
        <property name="mouseTracking">
         <bool>true</bool>
        </property>
@@ -286,7 +311,7 @@
         <string notr="true">color:rgb(255, 255, 255);</string>
        </property>
        <property name="text">
-        <string>  ПОМОЩЬ  </string>
+        <string>помощь</string>
        </property>
        <property name="scaledContents">
         <bool>true</bool>
@@ -338,9 +363,9 @@
            </size>
           </property>
           <property name="styleSheet">
-           <string notr="true">QPushButton#minimizeButton {border-image: url(:/assets/minimize.png) 0 0 0 0 stretch stretch; border: 0px;}
+           <string notr="true">QPushButton#minimizeButton {border-image: url(:/assets/buttons/minimize.png) 0 0 0 0 stretch stretch; border: 0px;}
 
-QPushButton#minimizeButton:hover {border-image: url(:/assets/minimize.png) 0 0 0 0 stretch stretch; border: 1px;}
+QPushButton#minimizeButton:hover {border-image: url(:/assets/buttons/minimize.png) 0 0 0 0 stretch stretch; border: 1px;}
 
 </string>
           </property>
@@ -358,9 +383,9 @@ QPushButton#minimizeButton:hover {border-image: url(:/assets/minimize.png) 0 0 0
            </size>
           </property>
           <property name="styleSheet">
-           <string notr="true">QPushButton#closeButton { border-image: url(:/assets/close.png) 0 0 0 0 stretch stretch; }
+           <string notr="true">QPushButton#closeButton { border-image: url(:/assets/buttons/close.png) 0 0 0 0 stretch stretch; }
 
-QPushButton#closeButton:hover { border-image: url(:/assets/close.png) 0 0 0 0 stretch stretch; border:1px;}</string>
+QPushButton#closeButton:hover { border-image: url(:/assets/buttons/close.png) 0 0 0 0 stretch stretch; border:1px;}</string>
           </property>
           <property name="text">
            <string>Х</string>

+ 17 - 5
gui/newswidget.cpp

@@ -65,6 +65,9 @@ void NewsWidget::updateNews()
             setImgToNewsPiece(i, img_pixmap);
         });
     }
+
+    QSpacerItem* verticalSpacer = new QSpacerItem(20, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
+    ui->news_layout->addItem(verticalSpacer, news_list.size(), 0);
 }
 
 void NewsWidget::constructNewsPiece(int piece_id, QString title, QString text, QString news_src)
@@ -83,6 +86,7 @@ void NewsWidget::constructNewsPiece(int piece_id, QString title, QString text, Q
     sizePolicy.setHorizontalStretch(0);
     sizePolicy.setVerticalStretch(0);
     sizePolicy.setHeightForWidth(news_piece->sizePolicy().hasHeightForWidth());
+
     news_piece->setSizePolicy(sizePolicy);
     news_piece->setStyleSheet(QLatin1String("QWidget{\n"
                                             "border-radius: 20px;\n"
@@ -97,6 +101,8 @@ void NewsWidget::constructNewsPiece(int piece_id, QString title, QString text, Q
 
     QGridLayout* news_piece_layout = new QGridLayout(news_piece);
     news_piece_layout->setObjectName(QStringLiteral("news_piece_layout"));
+    news_piece_layout->setContentsMargins(11, 11, 11, 11);
+    news_piece_layout->setSpacing(15);
 
     QLabel* iconLabel = new QLabel(news_piece);
     iconLabel->setObjectName(QStringLiteral("news_icon_") + QString::number(piece_id));
@@ -104,26 +110,31 @@ void NewsWidget::constructNewsPiece(int piece_id, QString title, QString text, Q
     sizePolicy1.setHorizontalStretch(0);
     sizePolicy1.setVerticalStretch(0);
     sizePolicy1.setHeightForWidth(iconLabel->sizePolicy().hasHeightForWidth());
+
     iconLabel->setSizePolicy(sizePolicy1);
     iconLabel->setMinimumSize(QSize(60, 60));
     iconLabel->setMaximumSize(QSize(60, 60));
     iconLabel->setPixmap(QPixmap(QString::fromUtf8(":/assets/appicon.ico")).scaled(60, 60));
 
+    iconLabel->setStyleSheet("border-radius: 10px;");
+
     news_piece_layout->addWidget(iconLabel, 0, 0, 2, 1);
 
     QLabel* titleLabel = new QLabel(news_piece);
     titleLabel->setObjectName(QStringLiteral("titleLabel_title"));
     sizePolicy.setHeightForWidth(titleLabel->sizePolicy().hasHeightForWidth());
     titleLabel->setSizePolicy(sizePolicy);
+
     QFont font;
-    font.setFamily(QStringLiteral("Trebuchet MS"));
-    font.setPointSize(11);
-    font.setBold(true);
+    font.setFamily(QStringLiteral("Trajan Pro 3"));
+    font.setPixelSize(12);
+    font.setBold(false);
+    font.setUnderline(false);
 
     titleLabel->setFont(font);
     titleLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
     titleLabel->setWordWrap(true);
-    titleLabel->setText("<a style=\"color: white; text-decoration:none;\" href = '" + news_src + "'>" + title + "</a>");
+    titleLabel->setText("<a style=\"color: #cfa644; text-decoration:none;\" href = '" + news_src + "'>" + title + "</a>");
     titleLabel->setOpenExternalLinks(true);
 
     news_piece_layout->addWidget(titleLabel, 0, 1, 1, 1);
@@ -133,11 +144,12 @@ void NewsWidget::constructNewsPiece(int piece_id, QString title, QString text, Q
     contentLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
     contentLabel->setWordWrap(true);
     contentLabel->setText(text);
+    contentLabel->setSizePolicy(sizePolicy);
 
     news_piece_layout->addWidget(contentLabel, 1, 1, 1, 1);
     app->window.changeFontSizeRecursive(app->properties.value("settings/ui_scale", 100).toInt(), news_piece);
 
-    ui->news_layout->addWidget(news_piece);
+    ui->news_layout->addWidget(news_piece, piece_id, 0);
 }
 
 void NewsWidget::setImgToNewsPiece(int piece_id, QPixmap img)

+ 35 - 3
gui/newswidget.ui

@@ -89,11 +89,14 @@ QScrollBar:vertical {
       <enum>Qt::ScrollBarAlwaysOff</enum>
      </property>
      <property name="sizeAdjustPolicy">
-      <enum>QAbstractScrollArea::AdjustToContents</enum>
+      <enum>QAbstractScrollArea::AdjustIgnored</enum>
      </property>
      <property name="widgetResizable">
       <bool>true</bool>
      </property>
+     <property name="alignment">
+      <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+     </property>
      <widget class="QWidget" name="scrollAreaWidgetContents">
       <property name="geometry">
        <rect>
@@ -143,6 +146,21 @@ background-color:rgba(0,0,0,0);
 }</string>
          </property>
          <layout class="QGridLayout" name="news_piece_layout">
+          <property name="leftMargin">
+           <number>11</number>
+          </property>
+          <property name="topMargin">
+           <number>11</number>
+          </property>
+          <property name="rightMargin">
+           <number>11</number>
+          </property>
+          <property name="bottomMargin">
+           <number>11</number>
+          </property>
+          <property name="spacing">
+           <number>4</number>
+          </property>
           <item row="0" column="0" rowspan="2">
            <widget class="QLabel" name="iconLabel">
             <property name="sizePolicy">
@@ -163,11 +181,19 @@ background-color:rgba(0,0,0,0);
               <height>60</height>
              </size>
             </property>
+            <property name="styleSheet">
+             <string notr="true">QWidget{
+border-radius: 10px;
+}</string>
+            </property>
+            <property name="frameShape">
+             <enum>QFrame::NoFrame</enum>
+            </property>
             <property name="text">
              <string/>
             </property>
             <property name="pixmap">
-             <pixmap resource="../res.qrc">:/assets/appicon.ico</pixmap>
+             <pixmap resource="../common.qrc">:/assets/buttons/question.png</pixmap>
             </property>
            </widget>
           </item>
@@ -202,6 +228,12 @@ text-decoration: none;</string>
           </item>
           <item row="1" column="1">
            <widget class="QLabel" name="contentLabel">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
             <property name="text">
              <string>Контент контент контент контент контент контент контент контент контент контент контент контент</string>
             </property>
@@ -223,7 +255,7 @@ text-decoration: none;</string>
   </layout>
  </widget>
  <resources>
-  <include location="../res.qrc"/>
+  <include location="../common.qrc"/>
  </resources>
  <connections/>
 </ui>

+ 3 - 0
gui/rusificationwidget.cpp

@@ -60,6 +60,9 @@ void RusificationWidget::updateUI()
     if (app->properties.value("settings/expert_mode", 0).toBool()) {
         ui->tabWidget_common->tabBar()->show();
     } else {
+        if (ui->tabWidget_common->currentIndex() != 0)
+            ui->tabWidget_common->setCurrentIndex(0);
+
         ui->tabWidget_common->tabBar()->hide();
     }
 }

+ 2 - 2
gui/rusificationwidget.ui

@@ -1678,7 +1678,7 @@ background-color: none;</string>
              </size>
             </property>
             <property name="styleSheet">
-             <string notr="true">border-image: url(:/assets/folder.png);
+             <string notr="true">border-image: url(:/assets/buttons/folder.png);
 
 background-color: none;</string>
             </property>
@@ -1798,7 +1798,7 @@ background-color: none;</string>
              </size>
             </property>
             <property name="styleSheet">
-             <string notr="true">border-image: url(:/assets/folder.png);
+             <string notr="true">border-image: url(:/assets/buttons/folder.png);
 
 background-color: none;</string>
             </property>

+ 3 - 3
gui/settingswidget.cpp

@@ -34,9 +34,9 @@ void SettingsWidget::updateUI()
     QString path = app->properties.value("settings/lotro_folder", "(не выбрана)").toString();
     ui->folder_value_common->setText(path);
 
-    ui->data_protection_checkbox_common->setChecked(app->properties.value("settings/data_protection", 0).toBool());
-    ui->restore_checkbox_common->setChecked(app->properties.value("settings/auto_restore", 0).toBool());
-    ui->download_updates_checkbox_common->setChecked(app->properties.value("settings/download_updates", 0).toBool());
+    ui->data_protection_checkbox_common->setChecked(app->properties.value("settings/data_protection", 1).toBool());
+    ui->restore_checkbox_common->setChecked(app->properties.value("settings/auto_restore", 1).toBool());
+    ui->download_updates_checkbox_common->setChecked(app->properties.value("settings/download_updates", 1).toBool());
     ui->expert_tabs_checkbox_common->setChecked(app->properties.value("settings/expert_mode", 0).toBool());
     ui->restrict_download_speed_checkbox_common->setChecked(app->properties.value("settings/limit_download_speed", 0).toBool());
     ui->download_restrict_slider->setValue(app->properties.value("settings/download_speed", 64).toInt());

+ 1 - 1
gui/settingswidget.ui

@@ -507,7 +507,7 @@ background-color: none;</string>
          <cursorShape>PointingHandCursor</cursorShape>
         </property>
         <property name="styleSheet">
-         <string notr="true">border-image: url(:/assets/folder.png);
+         <string notr="true">border-image: url(:/assets/buttons/folder.png);
 
 background-color: none;</string>
         </property>

+ 2 - 2
gui/statuswidget.ui

@@ -382,7 +382,7 @@ background-color: rgba(30, 0, 0, 100);</string>
             <bool>false</bool>
            </property>
            <property name="styleSheet">
-            <string notr="true">border-image: url(:/assets/gray-button-hi.png);
+            <string notr="true">border-image: url(:/assets/buttons/gray-button-hi.png);
 color: rgb(85, 0, 0);
 font: 24px &quot;Times New Roman&quot;;
 font-weight: bold;</string>
@@ -440,7 +440,7 @@ font-weight: bold;</string>
          </size>
         </property>
         <property name="styleSheet">
-         <string notr="true">image: url(:/assets/info.png);</string>
+         <string notr="true">image: url(:/assets/status/info.png);</string>
         </property>
        </widget>
       </item>

+ 0 - 14
res.qrc

@@ -1,27 +1,13 @@
 <RCC>
     <qresource prefix="/">
-        <file>assets/bg1.png</file>
         <file>assets/close.png</file>
         <file>assets/minimize.png</file>
         <file>assets/appicon.ico</file>
-        <file>assets/critical.png</file>
-        <file>assets/error.png</file>
-        <file>assets/info.png</file>
-        <file>assets/ok.png</file>
         <file>assets/orange-button-hi.png</file>
-        <file>assets/warning.png</file>
         <file>assets/green-button-hi.png</file>
         <file>assets/folder.png</file>
         <file>assets/question.png</file>
         <file>assets/gray-button-hi.png</file>
         <file>assets/teksty-photo-normal.png</file>
-        <file>assets/bg2.png</file>
-        <file>assets/bg3.png</file>
-        <file>assets/bg4.png</file>
-        <file>assets/bg5.png</file>
-        <file>assets/bg6.png</file>
-        <file>assets/bg7.png</file>
-        <file>assets/bg8.png</file>
-        <file>assets/bg9.png</file>
     </qresource>
 </RCC>