📄 mainform.ui.h
字号:
colorTable->setCurrentCell( row, 0 ); else if ( colorTable->numRows() ) colorTable->setCurrentCell( colorTable->numRows() - 1, 0 ); m_icons_dirty = TRUE; } else if ( visible == iconsPage && colorIconView->currentItem() ) { QIconViewItem *item = colorIconView->currentItem(); name = item->text(); QIconViewItem *current = item->nextItem(); if ( ! current ) current = item->prevItem(); delete item; if ( current ) colorIconView->setCurrentItem( current ); colorIconView->arrangeItemsInGrid(); m_table_dirty = TRUE; } if ( ! name.isNull() ) { m_colors.remove( name ); m_changed = TRUE; statusBar()->message( QString( "Deleted '%1'" ).arg( name ), 5000 ); } else statusBar()->message( QString( "Failed to delete '%1'" ).arg( name ), 5000 );}void MainForm::editCopy(){ QString text; QWidget *visible = colorWidgetStack->visibleWidget(); if ( visible == tablePage && colorTable->numRows() ) { int row = colorTable->currentRow(); text = colorTable->text( row, 0 ); } else if ( visible == iconsPage && colorIconView->currentItem() ) { QIconViewItem *item = colorIconView->currentItem(); text = item->text(); } if ( ! text.isNull() ) { QColor color = m_colors[text]; switch ( m_clip_as ) { case CLIP_AS_HEX: text = color.name(); break; case CLIP_AS_NAME: break; case CLIP_AS_RGB: text = QString( "%1,%2,%3" ). arg( color.red() ). arg( color.green() ). arg( color.blue() ); break; } clipboard->setText( text ); statusBar()->message( "Copied '" + text + "' to the clipboard" ); }}void MainForm::editFind(){ if ( ! findForm ) { findForm = new FindForm( this ); connect( findForm, SIGNAL( lookfor(const QString&) ), this, SLOT( lookfor(const QString&) ) ); } findForm->show();}void MainForm::lookfor( const QString& text ){ if ( text.isEmpty() ) return; QString ltext = text.lower(); QWidget *visible = colorWidgetStack->visibleWidget(); bool found = FALSE; if ( visible == tablePage && colorTable->numRows() ) { int row = colorTable->currentRow(); for ( int i = row + 1; i < colorTable->numRows(); ++i ) if ( colorTable->text( i, 0 ).lower().contains( ltext ) ) { colorTable->setCurrentCell( i, 0 ); colorTable->clearSelection(); colorTable->selectRow( i ); found = TRUE; break; } if ( ! found ) colorTable->setCurrentCell( row, 0 ); } else if ( visible == iconsPage ) { QIconViewItem *start = colorIconView->currentItem(); for ( QIconViewItem *item = start->nextItem(); item; item = item->nextItem() ) if ( item->text().lower().contains( ltext ) ) { colorIconView->setCurrentItem( item ); colorIconView->ensureItemVisible( item ); found = TRUE; break; } if ( ! found && start ) colorIconView->setCurrentItem( start ); } if ( ! found ) { statusBar()->message( QString( "Could not find '%1' after here" ). arg( text ) ); findForm->notfound(); }}void MainForm::helpIndex(){}void MainForm::helpContents(){}void MainForm::helpAbout(){}void MainForm::changedTableColor( int row, int ){ changedColor( colorTable->text( row, COL_NAME ) );}void MainForm::changedIconColor( QIconViewItem *item ){ changedColor( item->text() );}void MainForm::changedColor( const QString& name ){ QColor color = m_colors[name]; int r = color.red(); int g = color.green(); int b = color.blue(); statusBar()->message( QString( "%1 \"%2\" (%3,%4,%5)%6 {%7 %8 %9}" ). arg( name ). arg( color.name().upper() ). arg( r ).arg( g ).arg( b ). arg( isWebColor( color ) ? " web" : "" ). arg( r / 255.0, 1, 'f', 3 ). arg( g / 255.0, 1, 'f', 3 ). arg( b / 255.0, 1, 'f', 3 ) );}void MainForm::changeView(QAction* action){ if ( action == viewTableAction ) colorWidgetStack->raiseWidget( tablePage ); else colorWidgetStack->raiseWidget( iconsPage );}bool MainForm::isWebColor( QColor color ){ int r = color.red(); int g = color.green(); int b = color.blue(); return ( ( r == 0 || r == 51 || r == 102 || r == 153 || r == 204 || r == 255 ) && ( g == 0 || g == 51 || g == 102 || g == 153 || g == 204 || g == 255 ) && ( b == 0 || b == 51 || b == 102 || b == 153 || b == 204 || b == 255 ) );}void MainForm::editAdd(){ QColor color = white; if ( ! m_colors.isEmpty() ) { QWidget *visible = colorWidgetStack->visibleWidget(); if ( visible == tablePage ) color = colorTable->text( colorTable->currentRow(), colorTable->currentColumn() ); else color = colorIconView->currentItem()->text(); } color = QColorDialog::getColor( color, this ); if ( color.isValid() ) { QPixmap pixmap( 80, 10 ); pixmap.fill( color ); ColorNameForm *colorForm = new ColorNameForm( this, "color", TRUE ); colorForm->setColors( m_colors ); colorForm->colorLabel->setPixmap( pixmap ); if ( colorForm->exec() ) { QString name = colorForm->colorLineEdit->text(); m_colors[name] = color; QPixmap pixmap( 22, 22 ); pixmap.fill( color ); int row = colorTable->currentRow(); colorTable->insertRows( row, 1 ); colorTable->setText( row, COL_NAME, name ); colorTable->setPixmap( row, COL_NAME, pixmap ); colorTable->setText( row, COL_HEX, color.name().upper() ); if ( m_show_web ) { QCheckTableItem *item = new QCheckTableItem( colorTable, "" ); item->setChecked( isWebColor( color ) ); colorTable->setItem( row, COL_WEB, item ); } colorTable->setCurrentCell( row, colorTable->currentColumn() ); (void) new QIconViewItem( colorIconView, name, colorSwatch( color ) ); m_changed = TRUE; } }}void MainForm::editOptions(){ OptionsForm *options = new OptionsForm( this, "options", TRUE ); switch ( m_clip_as ) { case CLIP_AS_HEX: options->hexRadioButton->setChecked( TRUE ); break; case CLIP_AS_NAME: options->nameRadioButton->setChecked( TRUE ); break; case CLIP_AS_RGB: options->rgbRadioButton->setChecked( TRUE ); break; } options->webCheckBox->setChecked( m_show_web ); if ( options->exec() ) { if ( options->hexRadioButton->isChecked() ) m_clip_as = CLIP_AS_HEX; else if ( options->nameRadioButton->isChecked() ) m_clip_as = CLIP_AS_NAME; else if ( options->rgbRadioButton->isChecked() ) m_clip_as = CLIP_AS_RGB; m_table_dirty = m_show_web != options->webCheckBox->isChecked(); m_show_web = options->webCheckBox->isChecked(); populate(); }}void MainForm::loadSettings(){ QSettings settings; settings.insertSearchPath( QSettings::Windows, WINDOWS_REGISTRY ); int windowWidth = settings.readNumEntry( APP_KEY + "WindowWidth", 550 ); int windowHeight = settings.readNumEntry( APP_KEY + "WindowHeight", 500 ); int windowX = settings.readNumEntry( APP_KEY + "WindowX", 0 ); int windowY = settings.readNumEntry( APP_KEY + "WindowY", 0 ); m_clip_as = settings.readNumEntry( APP_KEY + "ClipAs", CLIP_AS_HEX ); m_show_web = settings.readBoolEntry( APP_KEY + "ShowWeb", TRUE ); if ( ! settings.readBoolEntry( APP_KEY + "View", TRUE ) ) colorWidgetStack->raiseWidget( iconsPage ); resize( windowWidth, windowHeight ); move( windowX, windowY );}void MainForm::saveSettings(){ QSettings settings; settings.insertSearchPath( QSettings::Windows, WINDOWS_REGISTRY ); settings.writeEntry( APP_KEY + "WindowWidth", width() ); settings.writeEntry( APP_KEY + "WindowHeight", height() ); settings.writeEntry( APP_KEY + "WindowX", x() ); settings.writeEntry( APP_KEY + "WindowY", y() ); settings.writeEntry( APP_KEY + "ClipAs", m_clip_as ); settings.writeEntry( APP_KEY + "ShowWeb", m_show_web ); settings.writeEntry( APP_KEY + "View", colorWidgetStack->visibleWidget() == tablePage );}void MainForm::aboutToShow(){ populate();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -