2021-05-22 21:29:43 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program is free 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
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: zhangjiaping <zhangjiaping@kylinos.cn>
|
|
|
|
* Modified by: zhangpengfei <zhangpengfei@kylinos.cn>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QPropertyAnimation>
|
|
|
|
#include <QPaintEvent>
|
|
|
|
#include <QPainterPath>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QtMath>
|
|
|
|
#include <QEvent>
|
|
|
|
#include <QSpacerItem>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QPropertyAnimation>
|
|
|
|
#include <QGraphicsDropShadowEffect>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QPropertyAnimation>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QGSettings/QGSettings>
|
|
|
|
#include <QSystemTrayIcon>
|
|
|
|
#include <QTimer>
|
|
|
|
|
2021-09-23 10:31:13 +08:00
|
|
|
#include "index-generator.h"
|
2021-05-22 21:29:43 +08:00
|
|
|
#include "libsearch.h"
|
|
|
|
#include "create-index-ask-dialog.h"
|
2021-09-23 10:31:13 +08:00
|
|
|
#include "search-line-edit.h"
|
|
|
|
#include "search-result-page.h"
|
2021-05-22 21:29:43 +08:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
|
|
|
#include "xatom-helper.h"
|
|
|
|
#endif
|
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
|
|
|
|
#include "settings-widget.h"
|
|
|
|
#endif
|
|
|
|
|
2021-12-14 14:43:35 +08:00
|
|
|
namespace UkuiSearch {
|
2021-05-22 21:29:43 +08:00
|
|
|
class SearchResult;
|
|
|
|
class MainWindow : public QMainWindow {
|
|
|
|
friend class SearchResult;
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MainWindow(QWidget *parent = nullptr);
|
|
|
|
~MainWindow();
|
|
|
|
/**
|
|
|
|
* @brief Load the main window
|
|
|
|
*/
|
|
|
|
|
|
|
|
// The position which mainwindow shows follow the ukui-panel.
|
|
|
|
void moveToPanel();
|
|
|
|
|
|
|
|
// The position which mainwindow shows in the center of screen where the cursor in.
|
|
|
|
void centerToScreen(QWidget* widget);
|
|
|
|
void initGsettings();
|
|
|
|
|
2021-07-21 17:01:34 +08:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *);
|
|
|
|
void keyPressEvent(QKeyEvent *event);
|
|
|
|
void initUi();
|
|
|
|
void initConnections();
|
|
|
|
|
2022-04-21 17:15:32 +08:00
|
|
|
public:
|
|
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
|
2021-07-21 17:01:34 +08:00
|
|
|
Q_SIGNALS:
|
|
|
|
void searchMethodChanged(FileUtils::SearchMethod);
|
|
|
|
void webEngineChanged();
|
2021-08-11 17:50:00 +08:00
|
|
|
void setText(QString keyword);
|
2021-07-21 17:01:34 +08:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
/**
|
|
|
|
* @brief Monitor screen resolution
|
|
|
|
* @param rect: Screen resolution
|
|
|
|
*/
|
|
|
|
void monitorResolutionChange(QRect rect);
|
|
|
|
/**
|
|
|
|
* @brief Monitor primary screen changes
|
|
|
|
* @param screen: Primary screen
|
|
|
|
*/
|
|
|
|
void primaryScreenChangedSlot(QScreen *screen);
|
|
|
|
|
|
|
|
void bootOptionsFilter(QString opt); // 过滤终端命令
|
|
|
|
void clearSearchResult(); //清空搜索结果
|
|
|
|
void trayIconActivatedSlot(QSystemTrayIcon::ActivationReason reason);
|
|
|
|
void settingsBtnClickedSlot();
|
|
|
|
void searchKeywordSlot(const QString&);
|
2021-07-26 15:08:46 +08:00
|
|
|
void resizeHeight(int height);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2021-07-23 16:10:30 +08:00
|
|
|
QWidget *m_widget = nullptr; // central widget
|
2021-05-22 21:29:43 +08:00
|
|
|
QFrame * m_titleFrame = nullptr; // Title bar frame
|
|
|
|
QHBoxLayout * m_titleLyt = nullptr; // Title layout
|
|
|
|
QLabel * m_iconLabel = nullptr; // Icon lable
|
|
|
|
QLabel * m_titleLabel = nullptr; // Title lable
|
|
|
|
QPushButton * m_settingsBtn = nullptr; // Menu button
|
2021-07-23 16:10:30 +08:00
|
|
|
// StackedWidget * m_stackedWidget = nullptr; // Stacked widget
|
2021-07-21 17:01:34 +08:00
|
|
|
// SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout
|
|
|
|
// SeachBarWidget * m_searchWidget = nullptr; // Search bar
|
2021-10-20 16:30:20 +08:00
|
|
|
SeachBarWidget * m_searchBarWidget;
|
|
|
|
SearchResultPage * m_searchResultPage;
|
2021-05-22 21:29:43 +08:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
|
|
|
|
SettingsWidget * m_settingsWidget = nullptr; // Settings Widget
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QStringList m_dirList;
|
|
|
|
|
2021-10-20 16:30:20 +08:00
|
|
|
QQueue<QString> * m_search_result_file = nullptr;
|
|
|
|
QQueue<QString> * m_search_result_dir = nullptr;
|
|
|
|
QQueue<QPair<QString, QStringList>> * m_search_result_content = nullptr;
|
2021-05-22 21:29:43 +08:00
|
|
|
|
2021-10-20 16:30:20 +08:00
|
|
|
QSystemTrayIcon * m_sys_tray_icon = nullptr;
|
2021-05-22 21:29:43 +08:00
|
|
|
CreateIndexAskDialog * m_askDialog = nullptr;
|
|
|
|
bool m_isAskDialogVisible = false;
|
|
|
|
|
|
|
|
QTimer * m_askTimer = nullptr; //询问是否创建索引弹窗弹出的计时器
|
|
|
|
QTimer * m_researchTimer = nullptr; //创建索引后重新执行一次搜索的计时器
|
|
|
|
bool m_currentSearchAsked = false; //本次搜索是否已经询问过是否创建索引了
|
|
|
|
QGSettings * m_search_gsettings = nullptr;
|
|
|
|
|
|
|
|
void setSearchMethod(const bool&);
|
|
|
|
double getTransparentData();
|
|
|
|
void initTimer();
|
|
|
|
bool tryHideMainwindow();
|
|
|
|
void setSearchMethodConfig(const bool&, const bool&);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|