第一次提交
|
@ -0,0 +1,3 @@
|
|||
.idea/
|
||||
cmake-build-debug/
|
||||
cmake-build-release/
|
|
@ -0,0 +1,50 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(officeassistant)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.6.3/5.6.3/mingw49_32")
|
||||
add_definitions(-DOFFICEASSISTANT_NO_CONSOLE)
|
||||
find_package(Qt5 COMPONENTS
|
||||
Core
|
||||
Gui
|
||||
Widgets
|
||||
REQUIRED)
|
||||
|
||||
add_executable(officeassistant main.cpp mainwindow.cpp mainwindow.h mainwindow.ui mainwindowlayout.cpp mainwindowlayout.h mainwindowlayout.ui navbar.cpp navbar.h navbar.ui MyButton.cpp MyButton.h buttonstruct.h)
|
||||
target_link_libraries(officeassistant
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
Qt5::Widgets
|
||||
)
|
||||
if (WIN32 AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
set(DEBUG_SUFFIX)
|
||||
if (MSVC AND CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
set(DEBUG_SUFFIX "d")
|
||||
endif ()
|
||||
set(QT_INSTALL_PATH "${CMAKE_PREFIX_PATH}")
|
||||
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
|
||||
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
|
||||
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
|
||||
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
|
||||
endif ()
|
||||
endif ()
|
||||
if (EXISTS "${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll")
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
"${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll"
|
||||
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
|
||||
endif ()
|
||||
foreach (QT_LIB Core Gui Widgets)
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
"${QT_INSTALL_PATH}/bin/Qt5${QT_LIB}${DEBUG_SUFFIX}.dll"
|
||||
"$<TARGET_FILE_DIR:${PROJECT_NAME}>")
|
||||
endforeach (QT_LIB)
|
||||
endif ()
|
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// Created by HW on 2023/07/26.
|
||||
//
|
||||
|
||||
#include "MyButton.h"
|
||||
MyButton::MyButton(QString logo,QString text,int width,int height,QWidget *parent) : QPushButton(parent) {
|
||||
this->width2=width;
|
||||
this->height2=height;
|
||||
this->text=text;
|
||||
this->logo=new QImage;
|
||||
this->logo->load(logo);
|
||||
this->setStyleSheet("background-color:#333332;");
|
||||
}
|
||||
|
||||
MyButton::~MyButton() {
|
||||
delete logo;
|
||||
}
|
||||
|
||||
void MyButton::paintEvent(QPaintEvent *e) {
|
||||
QPushButton::paintEvent(e);
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
int logo_width=width()/2;
|
||||
int logo_x=width()/4;
|
||||
QFont ft;
|
||||
ft.setPixelSize(7);
|
||||
int text_x=0;
|
||||
int text_y=(logo_width+logo_x);
|
||||
QRectF logo_rect(logo_x, logo_x, logo_width, logo_width);
|
||||
QRectF text_rect(text_x,text_y,7*text.length(),7);
|
||||
painter.setPen(QColor("#FFFFFF"));
|
||||
painter.drawImage(logo_rect, *logo);
|
||||
painter.drawText(text_rect, Qt::AlignCenter, text);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// Created by HW on 2023/07/26.
|
||||
//
|
||||
|
||||
#ifndef OFFICEASSISTANT_MYBUTTON_H
|
||||
#define OFFICEASSISTANT_MYBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QPaintEvent>
|
||||
#include <QtSvg/QtSvg>
|
||||
#include <QtSvg/QSvgWidget>
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
|
||||
class MyButton: public QPushButton{
|
||||
public:
|
||||
MyButton(QString logo,QString text,int width,int height,QWidget *parent=nullptr);
|
||||
~MyButton() override;
|
||||
QString getText(){
|
||||
return text;
|
||||
}
|
||||
QSize sizeHint() const override {
|
||||
return QSize(width2/2,height2/2);
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
private:
|
||||
QImage *logo;
|
||||
QLabel *logo_label;
|
||||
QLabel *text_label;
|
||||
QVBoxLayout *layout;
|
||||
QPixmap* logo_pixmap;
|
||||
QString text;
|
||||
int width2;
|
||||
int height2;
|
||||
};
|
||||
|
||||
|
||||
#endif //OFFICEASSISTANT_MYBUTTON_H
|
|
@ -0,0 +1,13 @@
|
|||
//
|
||||
// Created by HW on 2023/07/26.
|
||||
//
|
||||
|
||||
#ifndef OFFICEASSISTANT_BUTTONSTRUCT_H
|
||||
#define OFFICEASSISTANT_BUTTONSTRUCT_H
|
||||
#include <QString>
|
||||
typedef struct taButtonStruct{
|
||||
int index;
|
||||
QString logo;
|
||||
QString text;
|
||||
}ButtonStruct;
|
||||
#endif //OFFICEASSISTANT_BUTTONSTRUCT_H
|
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
|
@ -0,0 +1,12 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// Created by HW on 2023/07/26.
|
||||
//
|
||||
|
||||
// You may need to build the project (run Qt uic code generator) to get "ui_MainWindow.h" resolved
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
QDesktopWidget* desktopWidget = QApplication::desktop();
|
||||
QRect deskRect = desktopWidget->availableGeometry();
|
||||
if(deskRect.width()>=1920){
|
||||
resize(1920,1080);
|
||||
}else if(deskRect.width()>=1333&&deskRect.width()<=1920) {
|
||||
resize(800, 540);
|
||||
}
|
||||
delete desktopWidget;
|
||||
mainWindowLayout=new MainWindowLayout(this);
|
||||
setCentralWidget(mainWindowLayout);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
delete mainWindowLayout;
|
||||
delete layout;
|
||||
delete ui;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// Created by HW on 2023/07/26.
|
||||
//
|
||||
|
||||
#ifndef UNTITLED_MAINWINDOW_H
|
||||
#define UNTITLED_MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QVBoxLayout>
|
||||
#include "mainwindowlayout.h"
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
|
||||
~MainWindow() override;
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QVBoxLayout *layout;
|
||||
MainWindowLayout *mainWindowLayout;
|
||||
};
|
||||
|
||||
|
||||
#endif //UNTITLED_MAINWINDOW_H
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author/>
|
||||
<comment/>
|
||||
<exportmacro/>
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<pixmapfunction/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// Created by HW on 2023/07/26.
|
||||
//
|
||||
|
||||
// You may need to build the project (run Qt uic code generator) to get "ui_MainWindowLagout.h" resolved
|
||||
|
||||
#include "mainwindowlayout.h"
|
||||
#include "ui_MainWindowLayout.h"
|
||||
|
||||
|
||||
MainWindowLayout::MainWindowLayout(QWidget *parent) :
|
||||
QWidget(parent), ui(new Ui::MainWindowLayout) {
|
||||
ui->setupUi(this);
|
||||
layout=new QVBoxLayout(this);
|
||||
buttons=new ButtonStruct[4];
|
||||
buttons[0].text="主页";
|
||||
buttons[0].logo=".\\images\\home.png";
|
||||
buttons[0].index=0;
|
||||
buttons[1].text="我的网址";
|
||||
buttons[1].logo=".\\images\\address.png";
|
||||
buttons[1].index=1;
|
||||
buttons[2].text="我的资产";
|
||||
buttons[2].logo=".\\images\\money.png";
|
||||
buttons[2].index=2;
|
||||
buttons[3].text="个人中心";
|
||||
buttons[3].logo=".\\images\\personalcenter.png";
|
||||
buttons[3].index=3;
|
||||
for(auto i=0;i<4;i++){
|
||||
list<<&buttons[i];
|
||||
}
|
||||
navBar=new NavBar(list,this);
|
||||
layout->addWidget(navBar,1);
|
||||
layout->addStretch(4);
|
||||
layout->setMargin(0);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
MainWindowLayout::~MainWindowLayout() {
|
||||
|
||||
delete[] list[0];
|
||||
delete navBar;
|
||||
delete layout;
|
||||
delete ui;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
//
|
||||
// Created by HW on 2023/07/26.
|
||||
//
|
||||
|
||||
#ifndef OFFICEASSISTANT_MAINWINDOWLAYOUT_H
|
||||
#define OFFICEASSISTANT_MAINWINDOWLAYOUT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include "navbar.h"
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindowLayout; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindowLayout : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindowLayout(QWidget *parent = nullptr);
|
||||
|
||||
~MainWindowLayout() override;
|
||||
|
||||
private:
|
||||
Ui::MainWindowLayout *ui;
|
||||
QVBoxLayout *layout;
|
||||
QList<ButtonStruct *> list;
|
||||
NavBar *navBar;
|
||||
ButtonStruct *buttons;
|
||||
};
|
||||
|
||||
|
||||
#endif //OFFICEASSISTANT_MAINWINDOWLAYOUT_H
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindowLayout</class>
|
||||
<widget class="QWidget" name="MainWindowLayout">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindowLagout</string>
|
||||
</property>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Created by HW on 2023/07/26.
|
||||
//
|
||||
|
||||
// You may need to build the project (run Qt uic code generator) to get "ui_NavBar.h" resolved
|
||||
|
||||
#include "navbar.h"
|
||||
#include "ui_NavBar.h"
|
||||
|
||||
|
||||
NavBar::NavBar(QList<ButtonStruct *> &buttonNames,QWidget *parent) :
|
||||
QWidget(parent), ui(new Ui::NavBar) {
|
||||
ui->setupUi(this);
|
||||
layout=new QHBoxLayout();
|
||||
layout->setMargin(0);
|
||||
this->setMinimumHeight(48);
|
||||
this->setMaximumHeight(150);
|
||||
for(auto buttonName : buttonNames){
|
||||
MyButton *button=new MyButton(buttonName->logo,buttonName->text,height(),height());
|
||||
//QSizePolicy sizePolicy(QSizePolicy::Policy::Maximum, QSizePolicy::QSizePolicy::Maximum);
|
||||
//button->setSizePolicy(sizePolicy);
|
||||
layout->addWidget(button);
|
||||
buttons<<button;
|
||||
}
|
||||
layout->setAlignment(Qt::AlignHCenter);
|
||||
|
||||
this->setLayout(layout);
|
||||
|
||||
}
|
||||
|
||||
NavBar::~NavBar() {
|
||||
for(auto button : buttons){
|
||||
delete button;
|
||||
}
|
||||
delete layout;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void NavBar::paintEvent(QPaintEvent *event) {
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QRectF rect(0, 0, this->width(), this->height());
|
||||
painter.fillRect(rect, QColor("#333332"));
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// Created by HW on 2023/07/26.
|
||||
//
|
||||
|
||||
#ifndef OFFICEASSISTANT_NAVBAR_H
|
||||
#define OFFICEASSISTANT_NAVBAR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include <map>
|
||||
#include "MyButton.h"
|
||||
#include "buttonstruct.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class NavBar; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class NavBar : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NavBar(QList<ButtonStruct *> &buttonNames,QWidget *parent = nullptr);
|
||||
|
||||
~NavBar() override;
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
private:
|
||||
Ui::NavBar *ui;
|
||||
QHBoxLayout *layout;
|
||||
QList<MyButton *> buttons;
|
||||
};
|
||||
|
||||
|
||||
#endif //OFFICEASSISTANT_NAVBAR_H
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author/>
|
||||
<comment/>
|
||||
<exportmacro/>
|
||||
<class>NavBar</class>
|
||||
<widget class="QWidget" name="NavBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>NavBar</string>
|
||||
</property>
|
||||
</widget>
|
||||
<pixmapfunction/>
|
||||
<connections/>
|
||||
</ui>
|