mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-04-07 14:09:22 +08:00
[win-nix] refactoring
This commit is contained in:
@ -359,28 +359,8 @@ void CAscTabWidget::applyCustomTheme(bool iscustom)
|
||||
|
||||
void CAscTabWidget::updateIcons()
|
||||
{
|
||||
QString icon_name;
|
||||
int current = isActive() ? tabBar()->currentIndex() : -1;
|
||||
for (int i(count()); i-- > 0;) {
|
||||
CCefViewEditor * pEditor = (CCefViewEditor *)((QCefView*)(widget(i)))->GetCefView();
|
||||
|
||||
if (pEditor) {
|
||||
if (pEditor->GetType() == cvwtSimple) {
|
||||
icon_name = ":/portal.png";
|
||||
} else {
|
||||
switch (pEditor->GetEditorType()) {
|
||||
case etPresentation: icon_name = i == current ? ":/pe_active.png" : ":/pe_normal.png"; break;
|
||||
case etSpreadsheet: icon_name = i == current ? ":/se_active.png" : ":/se_normal.png"; break;
|
||||
case etDocument: icon_name = i == current ? ":/de_active.png" : ":/de_normal.png"; break;
|
||||
default: icon_name = ":/newdocument.png"; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_dpi_ratio > 1)
|
||||
icon_name.replace(".png", "@2x.png");
|
||||
|
||||
tabBar()->setTabIcon(i, QIcon(icon_name));
|
||||
}
|
||||
updateTabIcon(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,19 +371,23 @@ void CAscTabWidget::updateTabIcon(int index)
|
||||
|
||||
if (pEditor) {
|
||||
QString icon_name;
|
||||
if (pEditor->GetType() == cvwtSimple) {
|
||||
icon_name = ":/portal.png";
|
||||
} else {
|
||||
bool is_active = isActive() && index == currentIndex();
|
||||
bool is_active = isActive() && index == currentIndex();
|
||||
int tab_type = etUndefined;
|
||||
|
||||
switch (pEditor->GetEditorType()) {
|
||||
case etPresentation: icon_name = is_active ? ":/pe_active.png" : ":/pe_normal.png"; break;
|
||||
case etSpreadsheet: icon_name = is_active ? ":/se_active.png" : ":/se_normal.png"; break;
|
||||
case etDocument: icon_name = is_active ? ":/de_active.png" : ":/de_normal.png"; break;
|
||||
default: icon_name = ":/newdocument.png"; break;
|
||||
if (pEditor->GetType() == cvwtSimple) {
|
||||
tab_type = etPortal;
|
||||
} else {
|
||||
tab_type = pEditor->GetEditorType();
|
||||
switch ( tab_type ) {
|
||||
case etPresentation:
|
||||
case etSpreadsheet:
|
||||
case etDocument: break;
|
||||
default: tab_type = etUndefined; break;
|
||||
}
|
||||
}
|
||||
|
||||
icon_name = is_active ? m_mapTabIcons.at(tab_type).second : m_mapTabIcons.at(tab_type).first;
|
||||
|
||||
if (g_dpi_ratio > 1)
|
||||
icon_name.replace(".png", "@2x.png");
|
||||
|
||||
@ -412,6 +396,11 @@ void CAscTabWidget::updateTabIcon(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void CAscTabWidget::setTabIcons(CTabIconSet& icons)
|
||||
{
|
||||
m_mapTabIcons = icons;
|
||||
}
|
||||
|
||||
/*
|
||||
* Slots
|
||||
*/
|
||||
|
||||
@ -112,6 +112,8 @@ class CAscTabWidget : public QTabWidget
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::map< int, std::pair<QString, QString> > CTabIconSet;
|
||||
|
||||
public:
|
||||
QWidget* m_pMainWidget;
|
||||
QPushButton* m_pMainButton;
|
||||
@ -122,6 +124,8 @@ private:
|
||||
CFullScreenData * m_dataFullScreen;
|
||||
size_params m_widthParams;
|
||||
bool m_isCustomStyle;
|
||||
CTabIconSet m_mapTabIcons;
|
||||
|
||||
|
||||
signals:
|
||||
// void sendAddEditor();
|
||||
@ -163,6 +167,7 @@ public:
|
||||
void activate(bool);
|
||||
bool isActive();
|
||||
|
||||
void setTabIcons(CTabIconSet&);
|
||||
void updateIcons();
|
||||
void updateTabIcon(int);
|
||||
void setFocusedView(int index = -1);
|
||||
|
||||
@ -223,6 +223,15 @@ CMainPanel::CMainPanel(QWidget *parent, CAscApplicationManager *manager, bool is
|
||||
m_pTabs->setPalette(palette);
|
||||
m_pTabs->applyCustomTheme(isCustomWindow);
|
||||
|
||||
std::map<int, std::pair<QString, QString> > icons{
|
||||
{etUndefined, std::make_pair(":/newdocument.png", ":/newdocument.png")},
|
||||
{etDocument, std::make_pair(":/de_normal.png", ":/de_active.png")},
|
||||
{etPresentation, std::make_pair(":/pe_normal.png", ":/pe_active.png")},
|
||||
{etSpreadsheet, std::make_pair(":/se_normal.png", ":/se_active.png")},
|
||||
{etPortal, std::make_pair(":/portal.png", ":/portal.png")}
|
||||
};
|
||||
m_pTabs->setTabIcons(icons);
|
||||
|
||||
styleFile.close();
|
||||
|
||||
// download menu
|
||||
|
||||
@ -144,6 +144,9 @@ public slots:
|
||||
void onFileChecked(const QString&, int, bool);
|
||||
void onCheckUpdates();
|
||||
|
||||
protected:
|
||||
CAscTabWidget * m_pTabs;
|
||||
|
||||
private:
|
||||
std::wstring m_sDownloadName;
|
||||
|
||||
@ -158,7 +161,6 @@ private:
|
||||
|
||||
QHBoxLayout * m_layoutBtns;
|
||||
QWidget * m_boxTitleBtns;
|
||||
CAscTabWidget * m_pTabs;
|
||||
bool m_isMaximized;
|
||||
bool m_isCustomWindow;
|
||||
|
||||
|
||||
@ -382,8 +382,8 @@ void CTabBar::paintEvent(QPaintEvent * event)
|
||||
if (i == selected)
|
||||
continue;
|
||||
|
||||
QString text = tab.text;
|
||||
tab.text = "";
|
||||
QString text(tab.text);
|
||||
tab.text.clear();
|
||||
p.drawControl(QStyle::CE_TabBarTab, tab);
|
||||
drawTabCaption(&p, text, tab);
|
||||
}
|
||||
@ -397,8 +397,8 @@ void CTabBar::paintEvent(QPaintEvent * event)
|
||||
tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset);
|
||||
}
|
||||
if (!d->dragInProgress) {
|
||||
QString text = tab.text;
|
||||
tab.text = "";
|
||||
QString text(tab.text);
|
||||
tab.text.clear();
|
||||
p.drawControl(QStyle::CE_TabBarTab, tab);
|
||||
drawTabCaption(&p, text, tab);
|
||||
} else {
|
||||
|
||||
@ -33,8 +33,8 @@
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define VER_FILEVERSION 4,4,1,342
|
||||
#define VER_FILEVERSION_STR "4.4.1.342\0"
|
||||
#define VER_FILEVERSION 4,4,2,350
|
||||
#define VER_FILEVERSION_STR "4.4.2.350\0"
|
||||
|
||||
#define VER_PRODUCTVERSION VER_FILEVERSION
|
||||
#define VER_PRODUCTVERSION_STR "4.4\0"
|
||||
|
||||
Reference in New Issue
Block a user