예제 #1
0
ThemeConfig::ThemeConfig(QWidget *parent) :
    QWidget(parent)
{
    mConfig = KSharedConfig::openConfig(SDDM_CONFIG_FILE, KConfig::SimpleConfig);
    
    configUi = new Ui::ThemeConfig();
    configUi->setupUi(this);
    configUi->messageWidget->setVisible(false);

    ThemesModel *model = new ThemesModel(this);
    configUi->themesListView->setModel(model);

    ThemesDelegate *delegate = new ThemesDelegate(configUi->themesListView);
    delegate->setPreviewSize(QSize(128,128));
    configUi->themesListView->setItemDelegate(delegate);
    model->populate();
    connect(this, &ThemeConfig::themesChanged, model, &ThemesModel::populate);

    connect(configUi->themesListView, SIGNAL(activated(QModelIndex)), SLOT(themeSelected(QModelIndex)));
    connect(configUi->themesListView, SIGNAL(clicked(QModelIndex)), SLOT(themeSelected(QModelIndex)));
    connect(configUi->selectBackgroundButton, SIGNAL(imagePathChanged(QString)), SLOT(backgroundChanged(QString)));

    connect(configUi->getNewButton, &QPushButton::clicked, this, &ThemeConfig::getNewStuffClicked);
    connect(configUi->installFromFileButton, &QPushButton::clicked, this, &ThemeConfig::installFromFileClicked);
    connect(configUi->removeThemeButton, &QPushButton::clicked, this, &ThemeConfig::removeThemeClicked);


    prepareInitialTheme();
}
예제 #2
0
ThemeSelector::ThemeSelector(QWidget *parent)
    : QDialog(parent)
{
    m_widgets.setupUi(this);
    connect(m_widgets.lwSkinSelection, SIGNAL(itemSelectionChanged()), SLOT(themeSelected()));
    refresh();
}
예제 #3
0
ThemeSelector::ThemeSelector(QWidget *parent)
    : QDialog(parent)
{
    setModal(false);
    m_widgets.setupUi(this);
    connect(m_widgets.lwSkinSelection, SIGNAL(itemSelectionChanged()), SLOT(themeSelected()));
    connect(m_widgets.btnObjectInspector, SIGNAL(clicked()), 
        &Core::instance(), SLOT(openObjectInspector()));
    refresh();
}
예제 #4
0
void ThemeConfig::prepareInitialTheme()
{
    const QString initialTheme = mConfig->group("Theme").readEntry("Current");

    QModelIndex index = findThemeIndex(initialTheme);
    if (!index.isValid() && configUi->themesListView->model()->rowCount() > 0) {
        //if we can't find the currently configured theme from the config, just select the first theme in the UI
        index = configUi->themesListView->model()->index(0,0);
    }
    configUi->themesListView->setCurrentIndex(index);
    themeSelected(index);
}
예제 #5
0
// AppearanceSettings ----------------------------------------------------
AppearanceSettings::AppearanceSettings( QWidget* parent, Qt::WFlags fl )
    : QDialog(parent, fl),
    mIsStatusView(false), mIsFromActiveProfile(false)
{
    setupUi();
    readThemeSettings();
    readColorSchemeSettings();

    // Populate the first combo box (theme).
    populate();

    // Select the theme to populate the other combo boxes.
    // Note that they are not connected yet, so no preview is requested.
    themeSelected(mActiveThemeIndex);

    // Connect the combo boxes.
    connect( mThemeCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(themeSelected(int)) );
    connect( mColorCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(colorSelected(int)) );
    connect( mBgCombo, SIGNAL(currentIndexChanged(QString)),
            this, SLOT(backgroundSelected(QString)) );
    connect( mLabelCkBox, SIGNAL(toggled(bool)),
            this, SLOT(labelToggled(bool)) );

    connect( qApp, SIGNAL(appMessage(QString,QByteArray)),
        this, SLOT(receive(QString,QByteArray)) );

    // Re-select the theme to request the previews.
    themeSelected(mActiveThemeIndex);

    QSoftMenuBar::menuFor( this )->addAction
        ( QIcon( ":icon/Note" ), tr( "Add to current profile" ), this, SLOT(pushSettingStatus()) );
    QSoftMenuBar::menuFor( this )->addAction
        ( QIcon( ":image/homescreen/homescreen" ), tr( "Homescreen Settings..." ), this, SLOT(openHomescreenSettings()) );
}
예제 #6
0
void ThemeManager::editTheme()
{
	QListWidgetItem* item = m_themes->currentItem();
	if (!item) {
		return;
	}

	Theme theme(item->data(Qt::UserRole).toString(), false);
	ThemeDialog dialog(theme, this);
	if (dialog.exec() == QDialog::Rejected) {
		return;
	}

	item->setText(theme.name());
	item->setIcon(QIcon(Theme::iconPath(theme.id(), false, devicePixelRatioF())));
	emit themeSelected(theme);
}
예제 #7
0
void ThemeManager::currentThemeChanged(QListWidgetItem* current)
{
	if (current) {
		bool is_default = current->listWidget() == m_default_themes;
		if (is_default) {
			m_themes->setCurrentIndex(m_themes->rootIndex());
		} else {
			m_default_themes->setCurrentIndex(m_default_themes->rootIndex());
		}

		selectionChanged(is_default);

		QString id = current->data(Qt::UserRole).toString();
		m_settings.setValue("ThemeManager/Theme", id);
		m_settings.setValue("ThemeManager/ThemeDefault", is_default);
		emit themeSelected(Theme(id, is_default));
	}
}
예제 #8
0
Window::Window()
	: m_toolbar(0),
	m_fullscreen(true),
	m_typewriter_sounds(true),
	m_auto_save(true),
	m_save_positions(true),
	m_goal_type(0),
	m_time_goal(0),
	m_wordcount_goal(0),
	m_current_time(0),
	m_current_wordcount(0)
{
	setAcceptDrops(true);
	setAttribute(Qt::WA_DeleteOnClose);
	setContextMenuPolicy(Qt::NoContextMenu);
	setWindowIcon(QIcon(":/focuswriter.png"));

	// Set up icons
	if (QIcon::themeName().isEmpty()) {
		QIcon::setThemeName("hicolor");
		setIconSize(QSize(22,22));
	}

	// Create window contents first so they stack behind documents
	menuBar();
	m_toolbar = new QToolBar(this);
	m_toolbar->setFloatable(false);
	m_toolbar->setMovable(false);
	addToolBar(m_toolbar);
	QWidget* contents = new QWidget(this);
	setCentralWidget(contents);

	// Create documents
	m_documents = new Stack(this);
	m_sessions = new SessionManager(this);
	m_timers = new TimerManager(m_documents, this);
	m_load_screen = new LoadScreen(this);
	connect(m_documents, SIGNAL(footerVisible(bool)), m_timers->display(), SLOT(setVisible(bool)));
	connect(m_documents, SIGNAL(formattingEnabled(bool)), this, SLOT(setFormattingEnabled(bool)));
	connect(m_documents, SIGNAL(updateFormatActions()), this, SLOT(updateFormatActions()));
	connect(m_documents, SIGNAL(updateFormatAlignmentActions()), this, SLOT(updateFormatAlignmentActions()));
        connect(m_documents, SIGNAL(updateFormatHeadingActions()), this, SLOT(updateFormatHeadingActions()));
	connect(m_sessions, SIGNAL(themeChanged(Theme)), m_documents, SLOT(themeSelected(Theme)));

	// Set up menubar and toolbar
	initMenus();

	// Set up details
	m_footer = new QWidget(contents);
	QWidget* details = new QWidget(m_footer);
	m_wordcount_label = new QLabel(tr("Words: 0"), details);
	m_page_label = new QLabel(tr("Pages: 0"), details);
	m_paragraph_label = new QLabel(tr("Paragraphs: 0"), details);
	m_character_label = new QLabel(tr("Characters: 0"), details);
	m_progress_label = new QLabel(tr("0% of daily goal"), details);
	m_clock_label = new QLabel(details);
	updateClock();

	// Set up clock
	m_clock_timer = new QTimer(this);
	m_clock_timer->setInterval(60000);
	connect(m_clock_timer, SIGNAL(timeout()), this, SLOT(updateClock()));
	connect(m_clock_timer, SIGNAL(timeout()), m_timers, SLOT(saveTimers()));
	int delay = (60 - QTime::currentTime().second()) * 1000;
	QTimer::singleShot(delay, m_clock_timer, SLOT(start()));
	QTimer::singleShot(delay, this, SLOT(updateClock()));

	// Set up tabs
	m_tabs = new QTabBar(m_footer);
	m_tabs->setShape(QTabBar::RoundedSouth);
	m_tabs->setDocumentMode(true);
	m_tabs->setExpanding(false);
	m_tabs->setMovable(true);
	m_tabs->setTabsClosable(true);
	m_tabs->setUsesScrollButtons(true);
	connect(m_tabs, SIGNAL(currentChanged(int)), this, SLOT(tabClicked(int)));
	connect(m_tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(tabClosed(int)));
	connect(m_tabs, SIGNAL(tabMoved(int, int)), this, SLOT(tabMoved(int, int)));
	new QShortcut(QKeySequence::NextChild, this, SLOT(nextDocument()));
	new QShortcut(QKeySequence::PreviousChild, this, SLOT(previousDocument()));

	// Lay out details
	QHBoxLayout* clock_layout = new QHBoxLayout;
	clock_layout->setMargin(0);
	clock_layout->setSpacing(6);
	clock_layout->addWidget(m_timers->display(), 0, Qt::AlignCenter);
	clock_layout->addWidget(m_clock_label);

	QHBoxLayout* details_layout = new QHBoxLayout(details);
	details_layout->setSpacing(25);
	details_layout->setMargin(6);
	details_layout->addWidget(m_wordcount_label);
	details_layout->addWidget(m_page_label);
	details_layout->addWidget(m_paragraph_label);
	details_layout->addWidget(m_character_label);
	details_layout->addStretch();
	details_layout->addWidget(m_progress_label);
	details_layout->addStretch();
	details_layout->addLayout(clock_layout);

	// Lay out footer
	QVBoxLayout* footer_layout = new QVBoxLayout(m_footer);
	footer_layout->setSpacing(0);
	footer_layout->setMargin(0);
	footer_layout->addWidget(details);
	footer_layout->addWidget(m_tabs);

	// Lay out window
	QVBoxLayout* layout = new QVBoxLayout(contents);
	layout->setSpacing(0);
	layout->setMargin(0);
	layout->addStretch();
	layout->addWidget(m_footer);

	// Load current daily progress
	QSettings settings;
	if (settings.value("Progress/Date").toDate() != QDate::currentDate()) {
		settings.remove("Progress");
	}
	settings.setValue("Progress/Date", QDate::currentDate().toString(Qt::ISODate));
	m_current_wordcount = settings.value("Progress/Words", 0).toInt();
	m_current_time = settings.value("Progress/Time", 0).toInt();
	updateProgress();

	// Load settings
	Preferences preferences;
	loadPreferences(preferences);
	m_documents->themeSelected(settings.value("ThemeManager/Theme").toString());

	// Restore window geometry
	setMinimumSize(640, 480);
	resize(800, 600);
	restoreGeometry(settings.value("Window/Geometry").toByteArray());
	m_fullscreen = !settings.value("Window/Fullscreen", true).toBool();
	toggleFullscreen();
	m_actions["Fullscreen"]->setChecked(m_fullscreen);
	show();

	// Update themes
	m_load_screen->setText(tr("Loading themes"));
	Theme::copyBackgrounds();

	// Load sounds
	m_load_screen->setText(tr("Loading sounds"));
	m_key_sound = new Sound("keyany.wav", this);
	m_enter_key_sound = new Sound("keyenter.wav", this);

	// Update margin
	m_tabs->blockSignals(true);
	m_tabs->addTab(tr("Untitled"));
	updateMargin();
	m_tabs->removeTab(0);
	m_tabs->blockSignals(false);

	// Open previous documents
	QString session = settings.value("SessionManager/Session").toString();
	QStringList files = QApplication::arguments().mid(1);
	if (!files.isEmpty()) {
		session.clear();
		settings.setValue("Save/Current", files);
		settings.setValue("Save/Positions", QStringList());
		settings.setValue("Save/Active", 0);
	}
	m_sessions->setCurrent(session);
}
void U2Panel::keyRel(int key){
    cout<<"Key Released :"<<key<<endl;
	if(aboutDialogShows){
		aboutDialogShows=FALSE;
		repaint();
		return;
	}
	if(themeDialogShows){
		switch(key){
			case 4100:
				themeSelected();
				break;
			case 4114:
				themeIndex+=themeAvilable.count()-1;
				themeIndex=themeIndex%themeAvilable.count();
				break;
			case 4116:
				themeIndex+=1;
				themeIndex=themeIndex%themeAvilable.count();
				break;
			case 4146:
				themeDialogShows=FALSE;
				break;
		}
		repaint();
		return;
	}
	if(selectMode){//选词模式
		cout<<"select mode"<<endl;
	
		//是数字键
		if(key==4100){
			//输入
			doInput();
			num_buf="";
			alpha_buf="";
			cw_page_list.clear();
			cw_list.clear();
			selectMode=FALSE;
		}else if(key>48&&key<58){
			doInputByNum(key);
			num_buf="";
			alpha_buf="";
			cw_page_list.clear();
			cw_list.clear();
			selectMode=FALSE;
		}
		
		
	}else{//非选词模式
		cout<<"not select mode"<<endl;
		if(key>48&&key<58){
			if(!menuShows){
				num_buf+=QString::number(key-48);
				//数字发生变化============================================================
				numBufChanged();
				getCWords();
				CWPaging();
			}
		}else if(key==4100){
			if(!menuShows){
				justTheOne();
				num_buf="";
				alpha_buf="";
				cw_page_list.clear();
				cw_list.clear();
			}else{
				switch(menu_index){
					case 0:
						emit(rejected());
						break;
					case 1:
						doCopy();
						break;
					case 2:
						doPaste();
						break;
					case 3:
						doTheme();
						break;
					case 4:
						doAbout();
						return;
						break;

				}
				menuShows=!menuShows;
			}
		}else if(key==4152){
			if(num_buf==""){
				menuShows=!menuShows;
			}
		}else if(key==4154){
			emit(accepted());
			//接受
		}
	}

	repaint();
}
예제 #10
0
KDMThemeWidget::KDMThemeWidget(QWidget *parent)
    : QWidget(parent)
{
    QGridLayout *ml = new QGridLayout(this);
    ml->setSizeConstraint(QLayout::SetMinAndMaxSize);
    ml->setSpacing(KDialog::spacingHint());
    ml->setMargin(KDialog::marginHint());

    themeWidget = new QTreeWidget(this);
    themeWidget->setHeaderLabels(QStringList()
                                 << i18nc("@title:column", "Theme")
                                 << i18nc("@title:column", "Author"));
    themeWidget->setSortingEnabled(true);
    themeWidget->sortItems(0, Qt::AscendingOrder);
    themeWidget->setRootIsDecorated(false);
    themeWidget->setWhatsThis(i18n("This is a list of installed themes.\n"
                                   "Click the one to be used."));

    ml->addWidget(themeWidget, 0, 0, 2, 4);

    preview = new QLabel(this);
    preview->setFixedSize(QSize(200, 150));
    preview->setScaledContents(true);
    preview->setWhatsThis(i18n("This is a screen shot of what KDM will look like."));

    ml->addWidget(preview, 0, 4);

    info = new QLabel(this);
    info->setMaximumWidth(200);
    info->setAlignment(Qt::AlignTop);
    info->setWordWrap(true);
    info->setWhatsThis(i18n("This contains information about the selected theme."));

    ml->addWidget(info, 1, 4);

    bInstallTheme = new QPushButton(i18nc("@action:button", "Install &new theme"), this);
    bInstallTheme->setWhatsThis(i18n("This will install a theme into the theme directory."));

    ml->addWidget(bInstallTheme, 2, 0);

    bRemoveTheme = new QPushButton(i18nc("@action:button", "&Remove theme"), this);
    bRemoveTheme->setWhatsThis(i18n("This will remove the selected theme."));

    ml->addWidget(bRemoveTheme, 2, 1);

    bGetNewThemes = new QPushButton(i18nc("@action:button", "&Get New Themes"), this);

    ml->addWidget(bGetNewThemes, 2, 2);

    connect(themeWidget, SIGNAL(itemSelectionChanged()), SLOT(themeSelected()));
    connect(bInstallTheme, SIGNAL(clicked()), SLOT(installNewTheme()));
    connect(bRemoveTheme, SIGNAL(clicked()), SLOT(removeSelectedThemes()));
    connect(bGetNewThemes, SIGNAL(clicked()), SLOT(getNewStuff()));

    themeDir = KStandardDirs::installPath("data") + "kdm/themes/";
    defaultTheme = 0;

    foreach (const QString &ent,
             QDir(themeDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Unsorted))
        insertTheme(themeDir + ent);
}