Skip to content

Commit

Permalink
Add file browser application
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Sep 20, 2024
1 parent c2dd716 commit 92c8cc4
Show file tree
Hide file tree
Showing 99 changed files with 3,811 additions and 950 deletions.
417 changes: 209 additions & 208 deletions .gitignore

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/etc/${PROJECT_NAME}.conf)
COPYONLY)

endif()
INSTALL(FILES ${CMAKE_BINARY_DIR}/etc/${PROJECT_NAME}.conf
DESTINATION etc
INSTALL_FILE(SOURCES ${CMAKE_BINARY_DIR}/etc/${PROJECT_NAME}.conf
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}
COMPONENT Application)
if(NOT EXISTS ${CMAKE_BINARY_DIR}/etc/RabbitCommon_logqt.ini)
configure_file(${CMAKE_SOURCE_DIR}/Src/etc/logqt.ini
${CMAKE_BINARY_DIR}/etc/RabbitCommon_logqt.ini
COPYONLY)
endif()
INSTALL(FILES ${CMAKE_BINARY_DIR}/etc/RabbitCommon_logqt.ini
DESTINATION etc
INSTALL_FILE(SOURCES ${CMAKE_BINARY_DIR}/etc/RabbitCommon_logqt.ini
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}
COMPONENT Application)

if(NOT ANDROID AND UNIX)
Expand Down
4 changes: 2 additions & 2 deletions App/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void MainWindow::slotDownloadError(int nErr, const QString szErr)

void MainWindow::on_actionFolder_browser_triggered()
{
CFileBrowser *pBF = new CFileBrowser();
pBF->exec();
CDlgFileBrowser fb;
fb.exec();
}

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ if (BUILD_SHARED_LIBS)
endif()

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckIncludeFileCXX)
Expand Down Expand Up @@ -128,6 +127,7 @@ SET(CMAKE_VERBOSE_MAKEFILE ON)

option(BUILD_TEST "Set to ON to build tests" OFF)
add_subdirectory(Src)
add_subdirectory(FileBrowser)
option(BUILD_APP "Set to ON to build application" ON)
if(BUILD_APP)
add_subdirectory(App)
Expand Down
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Add environment in about dialog
- Add CDlgEdit
- Add CFileBrowser
- Add file browser application

### Version v2.2.6
- Modify debian package files
Expand Down
1 change: 1 addition & 0 deletions ChangeLog_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- 在关于对话框中增加环境变量
- 增加 CDlgEdit
- 增加 CFileBrowser
- 增加文件浏览器应用程序

### 版本: v2.2.6
- 修改 debian 打包文件
Expand Down
50 changes: 50 additions & 0 deletions FileBrowser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Author: Kang Lin([email protected])

project(FileBrowser LANGUAGES CXX)

include(GNUInstallDirs)

set(SOURCE_FILES
main.cpp
MainWindow.cpp
MainWindow.h
)

set(SOURCE_UI_FILES MainWindow.ui)

ADD_TARGET(NAME ${PROJECT_NAME}
ISEXE
SOURCE_FILES ${SOURCE_FILES} ${RESOURCE_FILES} ${SOURCE_UI_FILES}
PRIVATE_LIBS RabbitCommon ${QT_LIBRARIES}
INCLUDE_DIRS "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/Src>"
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Src>"
)

if(NOT EXISTS ${CMAKE_BINARY_DIR}/etc/RabbitCommon_logqt.ini)
configure_file(${CMAKE_SOURCE_DIR}/Src/etc/logqt.ini
${CMAKE_BINARY_DIR}/etc/RabbitCommon_logqt.ini
COPYONLY)
endif()
INSTALL_FILE(SOURCES ${CMAKE_BINARY_DIR}/etc/RabbitCommon_logqt.ini
DESTINATION etc
COMPONENT Application)

if(NOT ANDROID AND UNIX)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/share/org.Rabbit.FileBrower.desktop
DESTINATION "share/applications" COMPONENT Application)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/Src/Resource/icons/rabbit-green/svg/browser.svg
RENAME org.Rabbit.FileBrower.svg
DESTINATION "share/pixmaps" COMPONENT Application)
endif()

set(OTHER_FILES
${CMAKE_SOURCE_DIR}/License.md
${CMAKE_SOURCE_DIR}/Authors.md
${CMAKE_SOURCE_DIR}/Authors_zh_CN.md
${CMAKE_SOURCE_DIR}/ChangeLog.md
${CMAKE_SOURCE_DIR}/ChangeLog_zh_CN.md
)
# Install other files
INSTALL_FILE(SOURCES ${OTHER_FILES}
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT Application)
102 changes: 102 additions & 0 deletions FileBrowser/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#include <QLoggingCategory>
#include <QSettings>
#include "RabbitCommonTools.h"
#include "MainWindow.h"
#include "./ui_MainWindow.h"
#include "FileBrowser.h"
#include "RabbitCommonDir.h"
#include "FrmUpdater.h"
#include "DlgAbout.h"

static Q_LOGGING_CATEGORY(log, "FileBrowser.MainWindow")
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
bool check = false;
ui->setupUi(this);

#ifdef HAVE_RABBITCOMMON_GUI
RabbitCommon::CTools::InsertStyleMenu(ui->menuTools, ui->actionStatus_S, this);
ui->menuTools->insertMenu(ui->actionStatus_S, RabbitCommon::CTools::GetLogMenu(this));
ui->menuTools->insertSeparator(ui->actionStatus_S);
#endif

CFileBrowser* pFB = new CFileBrowser(this);
check = connect(pFB, SIGNAL(destroyed(QObject*)), this, SLOT(close()));
Q_ASSERT(check);
setCentralWidget(pFB);
setWindowIcon(pFB->windowIcon());
setWindowTitle(pFB->windowTitle());

QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
QSettings::IniFormat);
QByteArray geometry
= set.value("MainWindow/Status/Geometry").toByteArray();
if(!geometry.isEmpty())
restoreGeometry(geometry);
QByteArray state = set.value("MainWindow/Status/State").toByteArray();
if(!state.isEmpty())
restoreState(state);

bool bStatusBar = set.value("MainWindow/Status/Bar", !statusBar()->isHidden()).toBool();
ui->actionStatus_S->setChecked(bStatusBar);
statusBar()->setVisible(bStatusBar);
}

MainWindow::~MainWindow()
{
QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
QSettings::IniFormat);
set.setValue("MainWindow/Status/Geometry", saveGeometry());
set.setValue("MainWindow/Status/State", saveState());
set.setValue("MainWindow/Status/Bar", !statusBar()->isHidden());

delete ui;
}

void MainWindow::on_actionStatus_S_triggered(bool checked)
{
statusBar()->setVisible(checked);
}

void MainWindow::on_actionAbout_A_triggered()
{
#ifdef HAVE_ABOUT
CDlgAbout* dlg = new CDlgAbout();
dlg->setAttribute(Qt::WA_QuitOnClose, true);
#if defined (Q_OS_ANDROID)
dlg->showMaximized();
#else
dlg->show();
#endif
#endif

#ifdef BUILD_QUIWidget
QUIWidget::setFormInCenter(dlg);
#endif
}

void MainWindow::on_actionUpdate_U_triggered()
{
#ifdef HAVE_UPDATE
// [Use CFrmUpdater]
CFrmUpdater* m_pfrmUpdater = new CFrmUpdater();
QIcon icon = windowIcon();
if(icon.isNull()) return;
auto sizeList = icon.availableSizes();
if(sizeList.isEmpty()) return;
QPixmap p = icon.pixmap(*sizeList.begin());
m_pfrmUpdater->SetTitle(p.toImage());
m_pfrmUpdater->SetInstallAutoStartup();
#if defined (Q_OS_ANDROID)
m_pfrmUpdater->showMaximized();
#else
m_pfrmUpdater->show();
#endif
// [Use CFrmUpdater]
#endif
#ifdef BUILD_QUIWidget
QUIWidget::setFormInCenter(m_pfrmUpdater);
#endif
}
28 changes: 28 additions & 0 deletions FileBrowser/MainWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();

private slots:
void on_actionStatus_S_triggered(bool checked);
void on_actionAbout_A_triggered();
void on_actionUpdate_U_triggered();

private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
82 changes: 82 additions & 0 deletions FileBrowser/MainWindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>File browser</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>27</height>
</rect>
</property>
<widget class="QMenu" name="menuTools">
<property name="title">
<string>Tools(&amp;T)</string>
</property>
<addaction name="actionStatus_S"/>
</widget>
<widget class="QMenu" name="menuHelp_H">
<property name="title">
<string>Help(&amp;H)</string>
</property>
<addaction name="actionAbout_A"/>
<addaction name="actionUpdate_U"/>
</widget>
<addaction name="menuTools"/>
<addaction name="menuHelp_H"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionStatus_S">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Status(&amp;S)</string>
</property>
<property name="iconText">
<string>Status</string>
</property>
<property name="toolTip">
<string>Status</string>
</property>
<property name="statusTip">
<string>Status</string>
</property>
<property name="whatsThis">
<string>Status</string>
</property>
</action>
<action name="actionAbout_A">
<property name="icon">
<iconset theme="help-about"/>
</property>
<property name="text">
<string>About(&amp;A)</string>
</property>
</action>
<action name="actionUpdate_U">
<property name="icon">
<iconset theme="system-software-update"/>
</property>
<property name="text">
<string>Update(&amp;U)</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
38 changes: 38 additions & 0 deletions FileBrowser/Resource/Translations/FileBrowser_ar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ar_EG">
<context>
<name>MainWindow</name>
<message>
<location filename="../../MainWindow.ui" line="14"/>
<source>File browser</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../MainWindow.ui" line="28"/>
<source>Tools(&amp;T)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../MainWindow.ui" line="40"/>
<source>Status(&amp;S)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../MainWindow.ui" line="43"/>
<location filename="../../MainWindow.ui" line="46"/>
<location filename="../../MainWindow.ui" line="49"/>
<location filename="../../MainWindow.ui" line="52"/>
<source>Status</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../../main.cpp" line="17"/>
<source>File browser</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
Loading

0 comments on commit 92c8cc4

Please sign in to comment.