[win-nix] refactoring

This commit is contained in:
Maxim Kadushkin
2017-08-03 15:07:32 +03:00
parent cefa1bfbe7
commit 160e2fb038
6 changed files with 42 additions and 37 deletions

View File

@ -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
*/

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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 {

View File

@ -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"