void AccountsPage::skipClicked(bool /*_checked*/) { bool found = false; for (auto account : profiles_) { if (account.selected() && account.type() != MacProfileType::ICQ) { manager_->loginProfile(account, MacProfile()); found = true; break; } } if (!found) { MacProfilesList tmp; for (auto a : profiles_) { if (tmp.isEmpty() || tmp.back().type() == a.type()) tmp.push_back(a); } if (tmp.size() == 1) { manager_->loginProfile(tmp.back(), MacProfile()); emit account_selected(); return; } Ui::get_gui_settings()->set_value<bool>(settings_mac_accounts_migrated, true); auto w = Utils::InterConnector::instance().getMainWindow(); if (w) w->showLoginPage(false); return; } emit account_selected(); }
MainWindow::MainWindow(QApplication* app) : main_page_(nullptr) , login_page_(nullptr) #ifdef __APPLE__ , accounts_page_(nullptr) #endif //_APPLE__ , app_(app) , event_filter_(new TitleWidgetEventFilter(this)) , tray_icon_(new TrayIcon(this)) , backgroundPixmap_(QPixmap()) , Shadow_(0) , SkipRead_(false) , TaskBarIconHidden_(false) , liveChats_(new LiveChats(this)) { Utils::InterConnector::instance().setMainWindow(this); #ifdef _WIN32 Utils::init_crash_handlers_in_core(); core::dump::crash_handler chandler; chandler.set_process_exception_handlers(); chandler.set_thread_exception_handlers(); #endif //_WIN32 setStyleSheet(Utils::LoadStyle(":/main_window/main_window.qss", Utils::get_scale_coefficient(), true)); #ifdef __APPLE__ mac_support_ = new MacSupport(this); mac_support_->enableMacCrashReport(); #endif app_->installNativeEventFilter(this); if (this->objectName().isEmpty()) this->setObjectName(QStringLiteral("main_window")); this->resize(329, 331); QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth()); this->setSizePolicy(sizePolicy); this->setLayoutDirection(Qt::LeftToRight); this->setAutoFillBackground(false); main_widget_ = new QWidget(this); main_widget_->setObjectName(QStringLiteral("main_widget")); sizePolicy.setHeightForWidth(main_widget_->sizePolicy().hasHeightForWidth()); main_widget_->setSizePolicy(sizePolicy); vertical_layout_ = new QVBoxLayout(main_widget_); vertical_layout_->setSpacing(0); vertical_layout_->setObjectName(QStringLiteral("verticalLayout_9")); vertical_layout_->setSizeConstraint(QLayout::SetDefaultConstraint); vertical_layout_->setContentsMargins(0, 0, 0, 0); title_widget_ = new QWidget(main_widget_); title_widget_->setObjectName(QStringLiteral("title_widget")); QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Fixed); sizePolicy1.setHorizontalStretch(0); sizePolicy1.setVerticalStretch(0); sizePolicy1.setHeightForWidth(title_widget_->sizePolicy().hasHeightForWidth()); title_widget_->setSizePolicy(sizePolicy1); title_widget_->setProperty("TitleWidget", QVariant(true)); horizontal_layout_ = new QHBoxLayout(title_widget_); horizontal_layout_->setSpacing(0); horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout")); horizontal_layout_->setContentsMargins(0, 0, 0, 0); logo_ = new QPushButton(title_widget_); logo_->setObjectName(QStringLiteral("logo")); QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed); sizePolicy2.setHorizontalStretch(0); sizePolicy2.setVerticalStretch(0); sizePolicy2.setHeightForWidth(logo_->sizePolicy().hasHeightForWidth()); logo_->setSizePolicy(sizePolicy2); logo_->setProperty("WindowIcon", QVariant(true)); horizontal_layout_->addWidget(logo_); title_ = new QLabel(title_widget_); title_->setObjectName(QStringLiteral("title")); title_->setProperty("Title", QVariant(true)); horizontal_layout_->addWidget(title_); horizontal_spacer_ = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontal_layout_->addItem(horizontal_spacer_); hide_button_ = new QPushButton(title_widget_); hide_button_->setObjectName(QStringLiteral("hide_button")); hide_button_->setProperty("HideButton", QVariant(true)); horizontal_layout_->addWidget(hide_button_); maximize_button_ = new QPushButton(title_widget_); maximize_button_->setObjectName(QStringLiteral("maximize_button")); sizePolicy2.setHeightForWidth(maximize_button_->sizePolicy().hasHeightForWidth()); maximize_button_->setSizePolicy(sizePolicy2); maximize_button_->setProperty("MaximizeButton", QVariant(true)); horizontal_layout_->addWidget(maximize_button_); close_button_ = new QPushButton(title_widget_); close_button_->setObjectName(QStringLiteral("close_button")); sizePolicy2.setHeightForWidth(close_button_->sizePolicy().hasHeightForWidth()); close_button_->setSizePolicy(sizePolicy2); close_button_->setProperty("CloseButton", QVariant(true)); horizontal_layout_->addWidget(close_button_); vertical_layout_->addWidget(title_widget_); stacked_widget_ = new BackgroundWidget(main_widget_, ""); stacked_widget_->setObjectName(QStringLiteral("stacked_widget")); QPixmap p(":/resources/main_window/pat_100.png"); setBackgroundPixmap(p, true); //Utils::InterConnector::instance().setMainWindow(this); get_qt_theme_settings()->setOrLoadDefaultTheme(); vertical_layout_->addWidget(stacked_widget_); this->setCentralWidget(main_widget_); logo_->setText(QString()); hide_button_->setText(QString()); maximize_button_->setText(QString()); close_button_->setText(QString()); stacked_widget_->setCurrentIndex(-1); QMetaObject::connectSlotsByName(this); if (!get_gui_settings()->get_value(settings_keep_logged_in, true))// || !get_gui_settings()->contains_value(settings_keep_logged_in)) { showLoginPage(); } else { showMainPage(); } title_widget_->installEventFilter(event_filter_); title_->setText("ICQ"); title_->setAttribute(Qt::WA_TransparentForMouseEvents); logo_->setAttribute(Qt::WA_TransparentForMouseEvents); setWindowTitle("ICQ"); #ifdef _WIN32 setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::WindowMinimizeButtonHint); fake_parent_window_ = Utils::create_fake_parent_window(); #else title_widget_->hide(); #endif title_->setMouseTracking(true); connect(hide_button_, SIGNAL(clicked()), this, SLOT(minimize()), Qt::QueuedConnection); connect(maximize_button_, SIGNAL(clicked()), this, SLOT(maximize()), Qt::QueuedConnection); connect(close_button_, SIGNAL(clicked()), this, SLOT(hideWindow()), Qt::QueuedConnection); hide_button_->setCursor(Qt::PointingHandCursor); maximize_button_->setCursor(Qt::PointingHandCursor); close_button_->setCursor(Qt::PointingHandCursor); connect(event_filter_, SIGNAL(doubleClick()), this, SLOT(maximize()), Qt::QueuedConnection); connect(event_filter_, SIGNAL(moveRequest(QPoint)), this, SLOT(moveRequest(QPoint)), Qt::QueuedConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipResetComplete()), this, SLOT(onVoipResetComplete()), Qt::QueuedConnection); connect(Ui::GetDispatcher(), SIGNAL(needLogin()), this, SLOT(showLoginPage()), Qt::DirectConnection); connect(&Utils::InterConnector::instance(), SIGNAL(showIconInTaskbar(bool)), this, SLOT(showIconInTaskbar(bool)), Qt::QueuedConnection); connect(this, SIGNAL(needActivate()), this, SLOT(activate()), Qt::QueuedConnection); connect(get_gui_settings(), SIGNAL(changed(QString)), this, SLOT(guiSettingsChanged(QString)), Qt::QueuedConnection); QFont f = QApplication::font(); f.setStyleStrategy(QFont::PreferAntialias); QApplication::setFont(f); if (platform::is_windows()) { int shadowWidth = get_gui_settings()->get_shadow_width(); QBrush b = stacked_widget_->palette().background(); QMatrix m; m.translate(shadowWidth, title_widget_->height() + shadowWidth); b.setMatrix(m); Shadow_ = new ShadowWindow(b, shadowWidth); QPoint pos = mapToGlobal(QPoint(rect().x(), rect().y())); Shadow_->move(pos.x(), pos.y()); Shadow_->resize(rect().width(), rect().height()); Shadow_->setActive(true); Shadow_->show(); } initSettings(); #ifdef _WIN32 DragAcceptFiles((HWND)winId(), TRUE); #endif //_WIN32 if (!get_gui_settings()->get_value<bool>(settings_show_in_taskbar, true)) hide_taskbar_icon(); #ifdef __APPLE__ mac_support_->enableMacUpdater(); mac_support_->enableMacPreview(this->winId()); #endif }